documentation.d.ts 3.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used throughout the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependencies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the resource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the resource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the resource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the resource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailed logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve normal index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1130. /**
  1131. * Constant used to retrieve albedo index in the textures array in the prepass
  1132. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1133. */
  1134. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1135. /**
  1136. * Prefixes used by the engine for custom effects
  1137. */
  1138. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1139. }
  1140. }
  1141. declare module BABYLON {
  1142. /** @hidden */
  1143. export interface HardwareTextureWrapper {
  1144. underlyingResource: any;
  1145. set(hardwareTexture: any): void;
  1146. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1147. reset(): void;
  1148. release(): void;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /**
  1153. * This represents the required contract to create a new type of texture loader.
  1154. */
  1155. export interface IInternalTextureLoader {
  1156. /**
  1157. * Defines whether the loader supports cascade loading the different faces.
  1158. */
  1159. supportCascades: boolean;
  1160. /**
  1161. * This returns if the loader support the current file information.
  1162. * @param extension defines the file extension of the file being loaded
  1163. * @param mimeType defines the optional mime type of the file being loaded
  1164. * @returns true if the loader can load the specified file
  1165. */
  1166. canLoad(extension: string, mimeType?: string): boolean;
  1167. /**
  1168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1169. * @param data contains the texture data
  1170. * @param texture defines the BabylonJS internal texture
  1171. * @param createPolynomials will be true if polynomials have been requested
  1172. * @param onLoad defines the callback to trigger once the texture is ready
  1173. * @param onError defines the callback to trigger in case of error
  1174. * @param options options to be passed to the loader
  1175. */
  1176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1177. /**
  1178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1179. * @param data contains the texture data
  1180. * @param texture defines the BabylonJS internal texture
  1181. * @param callback defines the method to call once ready to upload
  1182. * @param options options to be passed to the loader
  1183. */
  1184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /**
  1189. * @hidden
  1190. */
  1191. export interface IColor4Like {
  1192. r: float;
  1193. g: float;
  1194. b: float;
  1195. a: float;
  1196. }
  1197. /**
  1198. * @hidden
  1199. */
  1200. export interface IColor3Like {
  1201. r: float;
  1202. g: float;
  1203. b: float;
  1204. }
  1205. /**
  1206. * @hidden
  1207. */
  1208. export interface IVector4Like {
  1209. x: float;
  1210. y: float;
  1211. z: float;
  1212. w: float;
  1213. }
  1214. /**
  1215. * @hidden
  1216. */
  1217. export interface IVector3Like {
  1218. x: float;
  1219. y: float;
  1220. z: float;
  1221. }
  1222. /**
  1223. * @hidden
  1224. */
  1225. export interface IVector2Like {
  1226. x: float;
  1227. y: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IMatrixLike {
  1233. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1234. updateFlag: int;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IViewportLike {
  1240. x: float;
  1241. y: float;
  1242. width: float;
  1243. height: float;
  1244. }
  1245. /**
  1246. * @hidden
  1247. */
  1248. export interface IPlaneLike {
  1249. normal: IVector3Like;
  1250. d: float;
  1251. normalize(): void;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /**
  1256. * Class used to store and describe the pipeline context associated with an effect
  1257. */
  1258. export interface IPipelineContext {
  1259. /**
  1260. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1261. */
  1262. isAsync: boolean;
  1263. /**
  1264. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1265. */
  1266. isReady: boolean;
  1267. /** @hidden */
  1268. _name?: string;
  1269. /** @hidden */
  1270. _getVertexShaderCode(): string | null;
  1271. /** @hidden */
  1272. _getFragmentShaderCode(): string | null;
  1273. /** @hidden */
  1274. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1275. /** @hidden */
  1276. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1277. [key: string]: number;
  1278. }, uniformsNames: string[], uniforms: {
  1279. [key: string]: Nullable<WebGLUniformLocation>;
  1280. }, samplerList: string[], samplers: {
  1281. [key: string]: number;
  1282. }, attributesNames: string[], attributes: number[]): void;
  1283. /** Releases the resources associated with the pipeline. */
  1284. dispose(): void;
  1285. /**
  1286. * Sets an integer value on a uniform variable.
  1287. * @param uniformName Name of the variable.
  1288. * @param value Value to be set.
  1289. */
  1290. setInt(uniformName: string, value: number): void;
  1291. /**
  1292. * Sets an int2 value on a uniform variable.
  1293. * @param uniformName Name of the variable.
  1294. * @param x First int in int2.
  1295. * @param y Second int in int2.
  1296. */
  1297. setInt2(uniformName: string, x: number, y: number): void;
  1298. /**
  1299. * Sets an int3 value on a uniform variable.
  1300. * @param uniformName Name of the variable.
  1301. * @param x First int in int3.
  1302. * @param y Second int in int3.
  1303. * @param z Third int in int3.
  1304. */
  1305. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1306. /**
  1307. * Sets an int4 value on a uniform variable.
  1308. * @param uniformName Name of the variable.
  1309. * @param x First int in int4.
  1310. * @param y Second int in int4.
  1311. * @param z Third int in int4.
  1312. * @param w Fourth int in int4.
  1313. */
  1314. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1315. /**
  1316. * Sets an int array on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param array array to be set.
  1319. */
  1320. setIntArray(uniformName: string, array: Int32Array): void;
  1321. /**
  1322. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1323. * @param uniformName Name of the variable.
  1324. * @param array array to be set.
  1325. */
  1326. setIntArray2(uniformName: string, array: Int32Array): void;
  1327. /**
  1328. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1329. * @param uniformName Name of the variable.
  1330. * @param array array to be set.
  1331. */
  1332. setIntArray3(uniformName: string, array: Int32Array): void;
  1333. /**
  1334. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1335. * @param uniformName Name of the variable.
  1336. * @param array array to be set.
  1337. */
  1338. setIntArray4(uniformName: string, array: Int32Array): void;
  1339. /**
  1340. * Sets an array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setArray(uniformName: string, array: number[] | Float32Array): void;
  1345. /**
  1346. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1351. /**
  1352. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1357. /**
  1358. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1363. /**
  1364. * Sets matrices on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param matrices matrices to be set.
  1367. */
  1368. setMatrices(uniformName: string, matrices: Float32Array): void;
  1369. /**
  1370. * Sets matrix on a uniform variable.
  1371. * @param uniformName Name of the variable.
  1372. * @param matrix matrix to be set.
  1373. */
  1374. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1375. /**
  1376. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1377. * @param uniformName Name of the variable.
  1378. * @param matrix matrix to be set.
  1379. */
  1380. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1381. /**
  1382. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1383. * @param uniformName Name of the variable.
  1384. * @param matrix matrix to be set.
  1385. */
  1386. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1387. /**
  1388. * Sets a float on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param value value to be set.
  1391. */
  1392. setFloat(uniformName: string, value: number): void;
  1393. /**
  1394. * Sets a Vector2 on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param vector2 vector2 to be set.
  1397. */
  1398. setVector2(uniformName: string, vector2: IVector2Like): void;
  1399. /**
  1400. * Sets a float2 on a uniform variable.
  1401. * @param uniformName Name of the variable.
  1402. * @param x First float in float2.
  1403. * @param y Second float in float2.
  1404. */
  1405. setFloat2(uniformName: string, x: number, y: number): void;
  1406. /**
  1407. * Sets a Vector3 on a uniform variable.
  1408. * @param uniformName Name of the variable.
  1409. * @param vector3 Value to be set.
  1410. */
  1411. setVector3(uniformName: string, vector3: IVector3Like): void;
  1412. /**
  1413. * Sets a float3 on a uniform variable.
  1414. * @param uniformName Name of the variable.
  1415. * @param x First float in float3.
  1416. * @param y Second float in float3.
  1417. * @param z Third float in float3.
  1418. */
  1419. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1420. /**
  1421. * Sets a Vector4 on a uniform variable.
  1422. * @param uniformName Name of the variable.
  1423. * @param vector4 Value to be set.
  1424. */
  1425. setVector4(uniformName: string, vector4: IVector4Like): void;
  1426. /**
  1427. * Sets a float4 on a uniform variable.
  1428. * @param uniformName Name of the variable.
  1429. * @param x First float in float4.
  1430. * @param y Second float in float4.
  1431. * @param z Third float in float4.
  1432. * @param w Fourth float in float4.
  1433. */
  1434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1435. /**
  1436. * Sets a Color3 on a uniform variable.
  1437. * @param uniformName Name of the variable.
  1438. * @param color3 Value to be set.
  1439. */
  1440. setColor3(uniformName: string, color3: IColor3Like): void;
  1441. /**
  1442. * Sets a Color4 on a uniform variable.
  1443. * @param uniformName Name of the variable.
  1444. * @param color3 Value to be set.
  1445. * @param alpha Alpha value to be set.
  1446. */
  1447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1448. /**
  1449. * Sets a Color4 on a uniform variable
  1450. * @param uniformName defines the name of the variable
  1451. * @param color4 defines the value to be set
  1452. */
  1453. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1454. }
  1455. }
  1456. declare module BABYLON {
  1457. /**
  1458. * Class used to store gfx data (like WebGLBuffer)
  1459. */
  1460. export class DataBuffer {
  1461. private static _Counter;
  1462. /**
  1463. * Gets or sets the number of objects referencing this buffer
  1464. */
  1465. references: number;
  1466. /** Gets or sets the size of the underlying buffer */
  1467. capacity: number;
  1468. /**
  1469. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1470. */
  1471. is32Bits: boolean;
  1472. /**
  1473. * Gets the underlying buffer
  1474. */
  1475. get underlyingResource(): any;
  1476. /**
  1477. * Gets the unique id of this buffer
  1478. */
  1479. readonly uniqueId: number;
  1480. /**
  1481. * Constructs the buffer
  1482. */
  1483. constructor();
  1484. }
  1485. }
  1486. declare module BABYLON {
  1487. /** @hidden */
  1488. export interface IShaderProcessor {
  1489. attributeProcessor?: (attribute: string, preProcessors: {
  1490. [key: string]: string;
  1491. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1492. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1493. [key: string]: string;
  1494. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1496. [key: string]: string;
  1497. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1502. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1503. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1504. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1505. vertexCode: string;
  1506. fragmentCode: string;
  1507. };
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface ShaderProcessingContext {
  1513. }
  1514. /** @hidden */
  1515. export interface ProcessingOptions {
  1516. defines: string[];
  1517. indexParameters: any;
  1518. isFragment: boolean;
  1519. shouldUseHighPrecisionShader: boolean;
  1520. supportsUniformBuffers: boolean;
  1521. shadersRepository: string;
  1522. includesShadersStore: {
  1523. [key: string]: string;
  1524. };
  1525. processor: Nullable<IShaderProcessor>;
  1526. version: string;
  1527. platformName: string;
  1528. lookForClosingBracketForUniformBuffer?: boolean;
  1529. processingContext: Nullable<ShaderProcessingContext>;
  1530. }
  1531. }
  1532. declare module BABYLON {
  1533. /** @hidden */
  1534. export class ShaderCodeNode {
  1535. line: string;
  1536. children: ShaderCodeNode[];
  1537. additionalDefineKey?: string;
  1538. additionalDefineValue?: string;
  1539. isValid(preprocessors: {
  1540. [key: string]: string;
  1541. }): boolean;
  1542. process(preprocessors: {
  1543. [key: string]: string;
  1544. }, options: ProcessingOptions): string;
  1545. }
  1546. }
  1547. declare module BABYLON {
  1548. /** @hidden */
  1549. export class ShaderCodeCursor {
  1550. private _lines;
  1551. lineIndex: number;
  1552. get currentLine(): string;
  1553. get canRead(): boolean;
  1554. set lines(value: string[]);
  1555. }
  1556. }
  1557. declare module BABYLON {
  1558. /** @hidden */
  1559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1560. process(preprocessors: {
  1561. [key: string]: string;
  1562. }, options: ProcessingOptions): string;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /** @hidden */
  1567. export class ShaderDefineExpression {
  1568. isTrue(preprocessors: {
  1569. [key: string]: string;
  1570. }): boolean;
  1571. private static _OperatorPriority;
  1572. private static _Stack;
  1573. static postfixToInfix(postfix: string[]): string;
  1574. static infixToPostfix(infix: string): string[];
  1575. }
  1576. }
  1577. declare module BABYLON {
  1578. /** @hidden */
  1579. export class ShaderCodeTestNode extends ShaderCodeNode {
  1580. testExpression: ShaderDefineExpression;
  1581. isValid(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. }
  1585. }
  1586. declare module BABYLON {
  1587. /** @hidden */
  1588. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1589. define: string;
  1590. not: boolean;
  1591. constructor(define: string, not?: boolean);
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. }
  1596. }
  1597. declare module BABYLON {
  1598. /** @hidden */
  1599. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1600. leftOperand: ShaderDefineExpression;
  1601. rightOperand: ShaderDefineExpression;
  1602. isTrue(preprocessors: {
  1603. [key: string]: string;
  1604. }): boolean;
  1605. }
  1606. }
  1607. declare module BABYLON {
  1608. /** @hidden */
  1609. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1610. leftOperand: ShaderDefineExpression;
  1611. rightOperand: ShaderDefineExpression;
  1612. isTrue(preprocessors: {
  1613. [key: string]: string;
  1614. }): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /** @hidden */
  1619. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1620. define: string;
  1621. operand: string;
  1622. testValue: string;
  1623. constructor(define: string, operand: string, testValue: string);
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Class used to enable access to offline support
  1632. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1633. */
  1634. export interface IOfflineProvider {
  1635. /**
  1636. * Gets a boolean indicating if scene must be saved in the database
  1637. */
  1638. enableSceneOffline: boolean;
  1639. /**
  1640. * Gets a boolean indicating if textures must be saved in the database
  1641. */
  1642. enableTexturesOffline: boolean;
  1643. /**
  1644. * Open the offline support and make it available
  1645. * @param successCallback defines the callback to call on success
  1646. * @param errorCallback defines the callback to call on error
  1647. */
  1648. open(successCallback: () => void, errorCallback: () => void): void;
  1649. /**
  1650. * Loads an image from the offline support
  1651. * @param url defines the url to load from
  1652. * @param image defines the target DOM image
  1653. */
  1654. loadImage(url: string, image: HTMLImageElement): void;
  1655. /**
  1656. * Loads a file from offline support
  1657. * @param url defines the URL to load from
  1658. * @param sceneLoaded defines a callback to call on success
  1659. * @param progressCallBack defines a callback to call when progress changed
  1660. * @param errorCallback defines a callback to call on error
  1661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1662. */
  1663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to help managing file picking and drag'n'drop
  1669. * File Storage
  1670. */
  1671. export class FilesInputStore {
  1672. /**
  1673. * List of files ready to be loaded
  1674. */
  1675. static FilesToLoad: {
  1676. [key: string]: File;
  1677. };
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Class used to define a retry strategy when error happens while loading assets
  1683. */
  1684. export class RetryStrategy {
  1685. /**
  1686. * Function used to defines an exponential back off strategy
  1687. * @param maxRetries defines the maximum number of retries (3 by default)
  1688. * @param baseInterval defines the interval between retries
  1689. * @returns the strategy function to use
  1690. */
  1691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1692. }
  1693. }
  1694. declare module BABYLON {
  1695. /**
  1696. * @ignore
  1697. * Application error to support additional information when loading a file
  1698. */
  1699. export abstract class BaseError extends Error {
  1700. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1701. }
  1702. }
  1703. declare module BABYLON {
  1704. /** @ignore */
  1705. export class LoadFileError extends BaseError {
  1706. request?: WebRequest;
  1707. file?: File;
  1708. /**
  1709. * Creates a new LoadFileError
  1710. * @param message defines the message of the error
  1711. * @param request defines the optional web request
  1712. * @param file defines the optional file
  1713. */
  1714. constructor(message: string, object?: WebRequest | File);
  1715. }
  1716. /** @ignore */
  1717. export class RequestFileError extends BaseError {
  1718. request: WebRequest;
  1719. /**
  1720. * Creates a new LoadFileError
  1721. * @param message defines the message of the error
  1722. * @param request defines the optional web request
  1723. */
  1724. constructor(message: string, request: WebRequest);
  1725. }
  1726. /** @ignore */
  1727. export class ReadFileError extends BaseError {
  1728. file: File;
  1729. /**
  1730. * Creates a new ReadFileError
  1731. * @param message defines the message of the error
  1732. * @param file defines the optional file
  1733. */
  1734. constructor(message: string, file: File);
  1735. }
  1736. /**
  1737. * @hidden
  1738. */
  1739. export class FileTools {
  1740. /**
  1741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1742. */
  1743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1744. /**
  1745. * Gets or sets the base URL to use to load assets
  1746. */
  1747. static BaseUrl: string;
  1748. /**
  1749. * Default behaviour for cors in the application.
  1750. * It can be a string if the expected behavior is identical in the entire app.
  1751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1752. */
  1753. static CorsBehavior: string | ((url: string | string[]) => string);
  1754. /**
  1755. * Gets or sets a function used to pre-process url before using them to load assets
  1756. */
  1757. static PreprocessUrl: (url: string) => string;
  1758. /**
  1759. * Removes unwanted characters from an url
  1760. * @param url defines the url to clean
  1761. * @returns the cleaned url
  1762. */
  1763. private static _CleanUrl;
  1764. /**
  1765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1766. * @param url define the url we are trying
  1767. * @param element define the dom element where to configure the cors policy
  1768. */
  1769. static SetCorsBehavior(url: string | string[], element: {
  1770. crossOrigin: string | null;
  1771. }): void;
  1772. /**
  1773. * Loads an image as an HTMLImageElement.
  1774. * @param input url string, ArrayBuffer, or Blob to load
  1775. * @param onLoad callback called when the image successfully loads
  1776. * @param onError callback called when the image fails to load
  1777. * @param offlineProvider offline provider for caching
  1778. * @param mimeType optional mime type
  1779. * @returns the HTMLImageElement of the loaded image
  1780. */
  1781. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1782. /**
  1783. * Reads a file from a File object
  1784. * @param file defines the file to load
  1785. * @param onSuccess defines the callback to call when data is loaded
  1786. * @param onProgress defines the callback to call during loading process
  1787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1788. * @param onError defines the callback to call when an error occurs
  1789. * @returns a file request object
  1790. */
  1791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1792. /**
  1793. * Loads a file from a url
  1794. * @param url url to load
  1795. * @param onSuccess callback called when the file successfully loads
  1796. * @param onProgress callback called while file is loading (if the server supports this mode)
  1797. * @param offlineProvider defines the offline provider for caching
  1798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1799. * @param onError callback called when the file fails to load
  1800. * @returns a file request object
  1801. */
  1802. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1803. /**
  1804. * Loads a file
  1805. * @param url url to load
  1806. * @param onSuccess callback called when the file successfully loads
  1807. * @param onProgress callback called while file is loading (if the server supports this mode)
  1808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1809. * @param onError callback called when the file fails to load
  1810. * @param onOpened callback called when the web request is opened
  1811. * @returns a file request object
  1812. */
  1813. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1814. /**
  1815. * Checks if the loaded document was accessed via `file:`-Protocol.
  1816. * @returns boolean
  1817. */
  1818. static IsFileURL(): boolean;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /** @hidden */
  1823. export class ShaderProcessor {
  1824. static Initialize(options: ProcessingOptions): void;
  1825. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1826. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1827. vertexCode: string;
  1828. fragmentCode: string;
  1829. };
  1830. private static _ProcessPrecision;
  1831. private static _ExtractOperation;
  1832. private static _BuildSubExpression;
  1833. private static _BuildExpression;
  1834. private static _MoveCursorWithinIf;
  1835. private static _MoveCursor;
  1836. private static _EvaluatePreProcessors;
  1837. private static _PreparePreProcessors;
  1838. private static _ProcessShaderConversion;
  1839. private static _ProcessIncludes;
  1840. /**
  1841. * Loads a file from a url
  1842. * @param url url to load
  1843. * @param onSuccess callback called when the file successfully loads
  1844. * @param onProgress callback called while file is loading (if the server supports this mode)
  1845. * @param offlineProvider defines the offline provider for caching
  1846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1847. * @param onError callback called when the file fails to load
  1848. * @returns a file request object
  1849. * @hidden
  1850. */
  1851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1852. }
  1853. }
  1854. declare module BABYLON {
  1855. /**
  1856. * Interface used to define common properties for effect fallbacks
  1857. */
  1858. export interface IEffectFallbacks {
  1859. /**
  1860. * Removes the defines that should be removed when falling back.
  1861. * @param currentDefines defines the current define statements for the shader.
  1862. * @param effect defines the current effect we try to compile
  1863. * @returns The resulting defines with defines of the current rank removed.
  1864. */
  1865. reduce(currentDefines: string, effect: Effect): string;
  1866. /**
  1867. * Removes the fallback from the bound mesh.
  1868. */
  1869. unBindMesh(): void;
  1870. /**
  1871. * Checks to see if more fallbacks are still available.
  1872. */
  1873. hasMoreFallbacks: boolean;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Interface for the size containing width and height
  1879. */
  1880. export interface ISize {
  1881. /**
  1882. * Width
  1883. */
  1884. width: number;
  1885. /**
  1886. * Heighht
  1887. */
  1888. height: number;
  1889. }
  1890. /**
  1891. * Size containing widht and height
  1892. */
  1893. export class Size implements ISize {
  1894. /**
  1895. * Width
  1896. */
  1897. width: number;
  1898. /**
  1899. * Height
  1900. */
  1901. height: number;
  1902. /**
  1903. * Creates a Size object from the given width and height (floats).
  1904. * @param width width of the new size
  1905. * @param height height of the new size
  1906. */
  1907. constructor(width: number, height: number);
  1908. /**
  1909. * Returns a string with the Size width and height
  1910. * @returns a string with the Size width and height
  1911. */
  1912. toString(): string;
  1913. /**
  1914. * "Size"
  1915. * @returns the string "Size"
  1916. */
  1917. getClassName(): string;
  1918. /**
  1919. * Returns the Size hash code.
  1920. * @returns a hash code for a unique width and height
  1921. */
  1922. getHashCode(): number;
  1923. /**
  1924. * Updates the current size from the given one.
  1925. * @param src the given size
  1926. */
  1927. copyFrom(src: Size): void;
  1928. /**
  1929. * Updates in place the current Size from the given floats.
  1930. * @param width width of the new size
  1931. * @param height height of the new size
  1932. * @returns the updated Size.
  1933. */
  1934. copyFromFloats(width: number, height: number): Size;
  1935. /**
  1936. * Updates in place the current Size from the given floats.
  1937. * @param width width to set
  1938. * @param height height to set
  1939. * @returns the updated Size.
  1940. */
  1941. set(width: number, height: number): Size;
  1942. /**
  1943. * Multiplies the width and height by numbers
  1944. * @param w factor to multiple the width by
  1945. * @param h factor to multiple the height by
  1946. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1947. */
  1948. multiplyByFloats(w: number, h: number): Size;
  1949. /**
  1950. * Clones the size
  1951. * @returns a new Size copied from the given one.
  1952. */
  1953. clone(): Size;
  1954. /**
  1955. * True if the current Size and the given one width and height are strictly equal.
  1956. * @param other the other size to compare against
  1957. * @returns True if the current Size and the given one width and height are strictly equal.
  1958. */
  1959. equals(other: Size): boolean;
  1960. /**
  1961. * The surface of the Size : width * height (float).
  1962. */
  1963. get surface(): number;
  1964. /**
  1965. * Create a new size of zero
  1966. * @returns a new Size set to (0.0, 0.0)
  1967. */
  1968. static Zero(): Size;
  1969. /**
  1970. * Sums the width and height of two sizes
  1971. * @param otherSize size to add to this size
  1972. * @returns a new Size set as the addition result of the current Size and the given one.
  1973. */
  1974. add(otherSize: Size): Size;
  1975. /**
  1976. * Subtracts the width and height of two
  1977. * @param otherSize size to subtract to this size
  1978. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1979. */
  1980. subtract(otherSize: Size): Size;
  1981. /**
  1982. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1983. * @param start starting size to lerp between
  1984. * @param end end size to lerp between
  1985. * @param amount amount to lerp between the start and end values
  1986. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1987. */
  1988. static Lerp(start: Size, end: Size, amount: number): Size;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Base class of all the textures in babylon.
  1994. * It groups all the common properties required to work with Thin Engine.
  1995. */
  1996. export class ThinTexture {
  1997. protected _wrapU: number;
  1998. /**
  1999. * | Value | Type | Description |
  2000. * | ----- | ------------------ | ----------- |
  2001. * | 0 | CLAMP_ADDRESSMODE | |
  2002. * | 1 | WRAP_ADDRESSMODE | |
  2003. * | 2 | MIRROR_ADDRESSMODE | |
  2004. */
  2005. get wrapU(): number;
  2006. set wrapU(value: number);
  2007. protected _wrapV: number;
  2008. /**
  2009. * | Value | Type | Description |
  2010. * | ----- | ------------------ | ----------- |
  2011. * | 0 | CLAMP_ADDRESSMODE | |
  2012. * | 1 | WRAP_ADDRESSMODE | |
  2013. * | 2 | MIRROR_ADDRESSMODE | |
  2014. */
  2015. get wrapV(): number;
  2016. set wrapV(value: number);
  2017. /**
  2018. * | Value | Type | Description |
  2019. * | ----- | ------------------ | ----------- |
  2020. * | 0 | CLAMP_ADDRESSMODE | |
  2021. * | 1 | WRAP_ADDRESSMODE | |
  2022. * | 2 | MIRROR_ADDRESSMODE | |
  2023. */
  2024. wrapR: number;
  2025. /**
  2026. * With compliant hardware and browser (supporting anisotropic filtering)
  2027. * this defines the level of anisotropic filtering in the texture.
  2028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2029. */
  2030. anisotropicFilteringLevel: number;
  2031. /**
  2032. * Define the current state of the loading sequence when in delayed load mode.
  2033. */
  2034. delayLoadState: number;
  2035. /**
  2036. * How a texture is mapped.
  2037. * Unused in thin texture mode.
  2038. */
  2039. get coordinatesMode(): number;
  2040. /**
  2041. * Define if the texture is a cube texture or if false a 2d texture.
  2042. */
  2043. get isCube(): boolean;
  2044. set isCube(value: boolean);
  2045. /**
  2046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is3D(): boolean;
  2049. set is3D(value: boolean);
  2050. /**
  2051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2052. */
  2053. get is2DArray(): boolean;
  2054. set is2DArray(value: boolean);
  2055. /**
  2056. * Get the class name of the texture.
  2057. * @returns "ThinTexture"
  2058. */
  2059. getClassName(): string;
  2060. /** @hidden */
  2061. _texture: Nullable<InternalTexture>;
  2062. protected _engine: Nullable<ThinEngine>;
  2063. private _cachedSize;
  2064. private _cachedBaseSize;
  2065. /**
  2066. * Instantiates a new ThinTexture.
  2067. * Base class of all the textures in babylon.
  2068. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2069. * @param internalTexture Define the internalTexture to wrap
  2070. */
  2071. constructor(internalTexture: Nullable<InternalTexture>);
  2072. /**
  2073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2074. * @returns true if fully ready
  2075. */
  2076. isReady(): boolean;
  2077. /**
  2078. * Triggers the load sequence in delayed load mode.
  2079. */
  2080. delayLoad(): void;
  2081. /**
  2082. * Get the underlying lower level texture from Babylon.
  2083. * @returns the internal texture
  2084. */
  2085. getInternalTexture(): Nullable<InternalTexture>;
  2086. /**
  2087. * Get the size of the texture.
  2088. * @returns the texture size.
  2089. */
  2090. getSize(): ISize;
  2091. /**
  2092. * Get the base size of the texture.
  2093. * It can be different from the size if the texture has been resized for POT for instance
  2094. * @returns the base size
  2095. */
  2096. getBaseSize(): ISize;
  2097. /**
  2098. * Update the sampling mode of the texture.
  2099. * Default is Trilinear mode.
  2100. *
  2101. * | Value | Type | Description |
  2102. * | ----- | ------------------ | ----------- |
  2103. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2104. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2105. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2106. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2107. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2108. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2109. * | 7 | NEAREST_LINEAR | |
  2110. * | 8 | NEAREST_NEAREST | |
  2111. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2112. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2113. * | 11 | LINEAR_LINEAR | |
  2114. * | 12 | LINEAR_NEAREST | |
  2115. *
  2116. * > _mag_: magnification filter (close to the viewer)
  2117. * > _min_: minification filter (far from the viewer)
  2118. * > _mip_: filter used between mip map levels
  2119. *@param samplingMode Define the new sampling mode of the texture
  2120. */
  2121. updateSamplingMode(samplingMode: number): void;
  2122. /**
  2123. * Release and destroy the underlying lower level texture aka internalTexture.
  2124. */
  2125. releaseInternalTexture(): void;
  2126. /**
  2127. * Dispose the texture and release its associated resources.
  2128. */
  2129. dispose(): void;
  2130. }
  2131. }
  2132. declare module BABYLON {
  2133. /**
  2134. * Defines an array and its length.
  2135. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2136. */
  2137. export interface ISmartArrayLike<T> {
  2138. /**
  2139. * The data of the array.
  2140. */
  2141. data: Array<T>;
  2142. /**
  2143. * The active length of the array.
  2144. */
  2145. length: number;
  2146. }
  2147. /**
  2148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2149. */
  2150. export class SmartArray<T> implements ISmartArrayLike<T> {
  2151. /**
  2152. * The full set of data from the array.
  2153. */
  2154. data: Array<T>;
  2155. /**
  2156. * The active length of the array.
  2157. */
  2158. length: number;
  2159. protected _id: number;
  2160. /**
  2161. * Instantiates a Smart Array.
  2162. * @param capacity defines the default capacity of the array.
  2163. */
  2164. constructor(capacity: number);
  2165. /**
  2166. * Pushes a value at the end of the active data.
  2167. * @param value defines the object to push in the array.
  2168. */
  2169. push(value: T): void;
  2170. /**
  2171. * Iterates over the active data and apply the lambda to them.
  2172. * @param func defines the action to apply on each value.
  2173. */
  2174. forEach(func: (content: T) => void): void;
  2175. /**
  2176. * Sorts the full sets of data.
  2177. * @param compareFn defines the comparison function to apply.
  2178. */
  2179. sort(compareFn: (a: T, b: T) => number): void;
  2180. /**
  2181. * Resets the active data to an empty array.
  2182. */
  2183. reset(): void;
  2184. /**
  2185. * Releases all the data from the array as well as the array.
  2186. */
  2187. dispose(): void;
  2188. /**
  2189. * Concats the active data with a given array.
  2190. * @param array defines the data to concatenate with.
  2191. */
  2192. concat(array: any): void;
  2193. /**
  2194. * Returns the position of a value in the active data.
  2195. * @param value defines the value to find the index for
  2196. * @returns the index if found in the active data otherwise -1
  2197. */
  2198. indexOf(value: T): number;
  2199. /**
  2200. * Returns whether an element is part of the active data.
  2201. * @param value defines the value to look for
  2202. * @returns true if found in the active data otherwise false
  2203. */
  2204. contains(value: T): boolean;
  2205. private static _GlobalId;
  2206. }
  2207. /**
  2208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2209. * The data in this array can only be present once
  2210. */
  2211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2212. private _duplicateId;
  2213. /**
  2214. * Pushes a value at the end of the active data.
  2215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2216. * @param value defines the object to push in the array.
  2217. */
  2218. push(value: T): void;
  2219. /**
  2220. * Pushes a value at the end of the active data.
  2221. * If the data is already present, it won t be added again
  2222. * @param value defines the object to push in the array.
  2223. * @returns true if added false if it was already present
  2224. */
  2225. pushNoDuplicate(value: T): boolean;
  2226. /**
  2227. * Resets the active data to an empty array.
  2228. */
  2229. reset(): void;
  2230. /**
  2231. * Concats the active data with a given array.
  2232. * This ensures no duplicate will be present in the result.
  2233. * @param array defines the data to concatenate with.
  2234. */
  2235. concatWithNoDuplicate(array: any): void;
  2236. }
  2237. }
  2238. declare module BABYLON {
  2239. /**
  2240. * Class used to evaluate queries containing `and` and `or` operators
  2241. */
  2242. export class AndOrNotEvaluator {
  2243. /**
  2244. * Evaluate a query
  2245. * @param query defines the query to evaluate
  2246. * @param evaluateCallback defines the callback used to filter result
  2247. * @returns true if the query matches
  2248. */
  2249. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2250. private static _HandleParenthesisContent;
  2251. private static _SimplifyNegation;
  2252. }
  2253. }
  2254. declare module BABYLON {
  2255. /**
  2256. * Class used to store custom tags
  2257. */
  2258. export class Tags {
  2259. /**
  2260. * Adds support for tags on the given object
  2261. * @param obj defines the object to use
  2262. */
  2263. static EnableFor(obj: any): void;
  2264. /**
  2265. * Removes tags support
  2266. * @param obj defines the object to use
  2267. */
  2268. static DisableFor(obj: any): void;
  2269. /**
  2270. * Gets a boolean indicating if the given object has tags
  2271. * @param obj defines the object to use
  2272. * @returns a boolean
  2273. */
  2274. static HasTags(obj: any): boolean;
  2275. /**
  2276. * Gets the tags available on a given object
  2277. * @param obj defines the object to use
  2278. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2279. * @returns the tags
  2280. */
  2281. static GetTags(obj: any, asString?: boolean): any;
  2282. /**
  2283. * Adds tags to an object
  2284. * @param obj defines the object to use
  2285. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2286. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2287. */
  2288. static AddTagsTo(obj: any, tagsString: string): void;
  2289. /**
  2290. * @hidden
  2291. */
  2292. static _AddTagTo(obj: any, tag: string): void;
  2293. /**
  2294. * Removes specific tags from a specific object
  2295. * @param obj defines the object to use
  2296. * @param tagsString defines the tags to remove
  2297. */
  2298. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2299. /**
  2300. * @hidden
  2301. */
  2302. static _RemoveTagFrom(obj: any, tag: string): void;
  2303. /**
  2304. * Defines if tags hosted on an object match a given query
  2305. * @param obj defines the object to use
  2306. * @param tagsQuery defines the tag query
  2307. * @returns a boolean
  2308. */
  2309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2310. }
  2311. }
  2312. declare module BABYLON {
  2313. /**
  2314. * Scalar computation library
  2315. */
  2316. export class Scalar {
  2317. /**
  2318. * Two pi constants convenient for computation.
  2319. */
  2320. static TwoPi: number;
  2321. /**
  2322. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2323. * @param a number
  2324. * @param b number
  2325. * @param epsilon (default = 1.401298E-45)
  2326. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2327. */
  2328. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2329. /**
  2330. * Returns a string : the upper case translation of the number i to hexadecimal.
  2331. * @param i number
  2332. * @returns the upper case translation of the number i to hexadecimal.
  2333. */
  2334. static ToHex(i: number): string;
  2335. /**
  2336. * Returns -1 if value is negative and +1 is value is positive.
  2337. * @param value the value
  2338. * @returns the value itself if it's equal to zero.
  2339. */
  2340. static Sign(value: number): number;
  2341. /**
  2342. * Returns the value itself if it's between min and max.
  2343. * Returns min if the value is lower than min.
  2344. * Returns max if the value is greater than max.
  2345. * @param value the value to clmap
  2346. * @param min the min value to clamp to (default: 0)
  2347. * @param max the max value to clamp to (default: 1)
  2348. * @returns the clamped value
  2349. */
  2350. static Clamp(value: number, min?: number, max?: number): number;
  2351. /**
  2352. * the log2 of value.
  2353. * @param value the value to compute log2 of
  2354. * @returns the log2 of value.
  2355. */
  2356. static Log2(value: number): number;
  2357. /**
  2358. * the floor part of a log2 value.
  2359. * @param value the value to compute log2 of
  2360. * @returns the log2 of value.
  2361. */
  2362. static ILog2(value: number): number;
  2363. /**
  2364. * Loops the value, so that it is never larger than length and never smaller than 0.
  2365. *
  2366. * This is similar to the modulo operator but it works with floating point numbers.
  2367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2368. * With t = 5 and length = 2.5, the result would be 0.0.
  2369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2370. * @param value the value
  2371. * @param length the length
  2372. * @returns the looped value
  2373. */
  2374. static Repeat(value: number, length: number): number;
  2375. /**
  2376. * Normalize the value between 0.0 and 1.0 using min and max values
  2377. * @param value value to normalize
  2378. * @param min max to normalize between
  2379. * @param max min to normalize between
  2380. * @returns the normalized value
  2381. */
  2382. static Normalize(value: number, min: number, max: number): number;
  2383. /**
  2384. * Denormalize the value from 0.0 and 1.0 using min and max values
  2385. * @param normalized value to denormalize
  2386. * @param min max to denormalize between
  2387. * @param max min to denormalize between
  2388. * @returns the denormalized value
  2389. */
  2390. static Denormalize(normalized: number, min: number, max: number): number;
  2391. /**
  2392. * Calculates the shortest difference between two given angles given in degrees.
  2393. * @param current current angle in degrees
  2394. * @param target target angle in degrees
  2395. * @returns the delta
  2396. */
  2397. static DeltaAngle(current: number, target: number): number;
  2398. /**
  2399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2400. * @param tx value
  2401. * @param length length
  2402. * @returns The returned value will move back and forth between 0 and length
  2403. */
  2404. static PingPong(tx: number, length: number): number;
  2405. /**
  2406. * Interpolates between min and max with smoothing at the limits.
  2407. *
  2408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2410. * @param from from
  2411. * @param to to
  2412. * @param tx value
  2413. * @returns the smooth stepped value
  2414. */
  2415. static SmoothStep(from: number, to: number, tx: number): number;
  2416. /**
  2417. * Moves a value current towards target.
  2418. *
  2419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2420. * Negative values of maxDelta pushes the value away from target.
  2421. * @param current current value
  2422. * @param target target value
  2423. * @param maxDelta max distance to move
  2424. * @returns resulting value
  2425. */
  2426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2427. /**
  2428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2429. *
  2430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2432. * @param current current value
  2433. * @param target target value
  2434. * @param maxDelta max distance to move
  2435. * @returns resulting angle
  2436. */
  2437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2438. /**
  2439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2440. * @param start start value
  2441. * @param end target value
  2442. * @param amount amount to lerp between
  2443. * @returns the lerped value
  2444. */
  2445. static Lerp(start: number, end: number, amount: number): number;
  2446. /**
  2447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2449. * @param start start value
  2450. * @param end target value
  2451. * @param amount amount to lerp between
  2452. * @returns the lerped value
  2453. */
  2454. static LerpAngle(start: number, end: number, amount: number): number;
  2455. /**
  2456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2457. * @param a start value
  2458. * @param b target value
  2459. * @param value value between a and b
  2460. * @returns the inverseLerp value
  2461. */
  2462. static InverseLerp(a: number, b: number, value: number): number;
  2463. /**
  2464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2466. * @param value1 spline value
  2467. * @param tangent1 spline value
  2468. * @param value2 spline value
  2469. * @param tangent2 spline value
  2470. * @param amount input value
  2471. * @returns hermite result
  2472. */
  2473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2474. /**
  2475. * Returns a random float number between and min and max values
  2476. * @param min min value of random
  2477. * @param max max value of random
  2478. * @returns random value
  2479. */
  2480. static RandomRange(min: number, max: number): number;
  2481. /**
  2482. * This function returns percentage of a number in a given range.
  2483. *
  2484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2486. * @param number to convert to percentage
  2487. * @param min min range
  2488. * @param max max range
  2489. * @returns the percentage
  2490. */
  2491. static RangeToPercent(number: number, min: number, max: number): number;
  2492. /**
  2493. * This function returns number that corresponds to the percentage in a given range.
  2494. *
  2495. * PercentToRange(0.34,0,100) will return 34.
  2496. * @param percent to convert to number
  2497. * @param min min range
  2498. * @param max max range
  2499. * @returns the number
  2500. */
  2501. static PercentToRange(percent: number, min: number, max: number): number;
  2502. /**
  2503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2504. * @param angle The angle to normalize in radian.
  2505. * @return The converted angle.
  2506. */
  2507. static NormalizeRadians(angle: number): number;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Constant used to convert a value to gamma space
  2513. * @ignorenaming
  2514. */
  2515. export const ToGammaSpace: number;
  2516. /**
  2517. * Constant used to convert a value to linear space
  2518. * @ignorenaming
  2519. */
  2520. export const ToLinearSpace = 2.2;
  2521. /**
  2522. * Constant used to define the minimal number value in Babylon.js
  2523. * @ignorenaming
  2524. */
  2525. let Epsilon: number;
  2526. }
  2527. declare module BABYLON {
  2528. /**
  2529. * Class used to represent a viewport on screen
  2530. */
  2531. export class Viewport {
  2532. /** viewport left coordinate */
  2533. x: number;
  2534. /** viewport top coordinate */
  2535. y: number;
  2536. /**viewport width */
  2537. width: number;
  2538. /** viewport height */
  2539. height: number;
  2540. /**
  2541. * Creates a Viewport object located at (x, y) and sized (width, height)
  2542. * @param x defines viewport left coordinate
  2543. * @param y defines viewport top coordinate
  2544. * @param width defines the viewport width
  2545. * @param height defines the viewport height
  2546. */
  2547. constructor(
  2548. /** viewport left coordinate */
  2549. x: number,
  2550. /** viewport top coordinate */
  2551. y: number,
  2552. /**viewport width */
  2553. width: number,
  2554. /** viewport height */
  2555. height: number);
  2556. /**
  2557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2558. * @param renderWidth defines the rendering width
  2559. * @param renderHeight defines the rendering height
  2560. * @returns a new Viewport
  2561. */
  2562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2563. /**
  2564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2565. * @param renderWidth defines the rendering width
  2566. * @param renderHeight defines the rendering height
  2567. * @param ref defines the target viewport
  2568. * @returns the current viewport
  2569. */
  2570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2571. /**
  2572. * Returns a new Viewport copied from the current one
  2573. * @returns a new Viewport
  2574. */
  2575. clone(): Viewport;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Class containing a set of static utilities functions for arrays.
  2581. */
  2582. export class ArrayTools {
  2583. /**
  2584. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2585. * @param size the number of element to construct and put in the array
  2586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2587. * @returns a new array filled with new objects
  2588. */
  2589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /**
  2594. * Represents a plane by the equation ax + by + cz + d = 0
  2595. */
  2596. export class Plane {
  2597. private static _TmpMatrix;
  2598. /**
  2599. * Normal of the plane (a,b,c)
  2600. */
  2601. normal: Vector3;
  2602. /**
  2603. * d component of the plane
  2604. */
  2605. d: number;
  2606. /**
  2607. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2608. * @param a a component of the plane
  2609. * @param b b component of the plane
  2610. * @param c c component of the plane
  2611. * @param d d component of the plane
  2612. */
  2613. constructor(a: number, b: number, c: number, d: number);
  2614. /**
  2615. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2616. */
  2617. asArray(): number[];
  2618. /**
  2619. * @returns a new plane copied from the current Plane.
  2620. */
  2621. clone(): Plane;
  2622. /**
  2623. * @returns the string "Plane".
  2624. */
  2625. getClassName(): string;
  2626. /**
  2627. * @returns the Plane hash code.
  2628. */
  2629. getHashCode(): number;
  2630. /**
  2631. * Normalize the current Plane in place.
  2632. * @returns the updated Plane.
  2633. */
  2634. normalize(): Plane;
  2635. /**
  2636. * Applies a transformation the plane and returns the result
  2637. * @param transformation the transformation matrix to be applied to the plane
  2638. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2639. */
  2640. transform(transformation: DeepImmutable<Matrix>): Plane;
  2641. /**
  2642. * Compute the dot product between the point and the plane normal
  2643. * @param point point to calculate the dot product with
  2644. * @returns the dot product (float) of the point coordinates and the plane normal.
  2645. */
  2646. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2647. /**
  2648. * Updates the current Plane from the plane defined by the three given points.
  2649. * @param point1 one of the points used to contruct the plane
  2650. * @param point2 one of the points used to contruct the plane
  2651. * @param point3 one of the points used to contruct the plane
  2652. * @returns the updated Plane.
  2653. */
  2654. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2655. /**
  2656. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2657. * Note that for this function to work as expected you should make sure that:
  2658. * - direction and the plane normal are normalized
  2659. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2660. * @param direction the direction to check if the plane is facing
  2661. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2662. * @returns True if the plane is facing the given direction
  2663. */
  2664. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2665. /**
  2666. * Calculates the distance to a point
  2667. * @param point point to calculate distance to
  2668. * @returns the signed distance (float) from the given point to the Plane.
  2669. */
  2670. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Creates a plane from an array
  2673. * @param array the array to create a plane from
  2674. * @returns a new Plane from the given array.
  2675. */
  2676. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2677. /**
  2678. * Creates a plane from three points
  2679. * @param point1 point used to create the plane
  2680. * @param point2 point used to create the plane
  2681. * @param point3 point used to create the plane
  2682. * @returns a new Plane defined by the three given points.
  2683. */
  2684. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * Creates a plane from an origin point and a normal
  2687. * @param origin origin of the plane to be constructed
  2688. * @param normal normal of the plane to be constructed
  2689. * @returns a new Plane the normal vector to this plane at the given origin point.
  2690. * Note : the vector "normal" is updated because normalized.
  2691. */
  2692. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2693. /**
  2694. * Calculates the distance from a plane and a point
  2695. * @param origin origin of the plane to be constructed
  2696. * @param normal normal of the plane to be constructed
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2699. */
  2700. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. /** @hidden */
  2705. export class PerformanceConfigurator {
  2706. /** @hidden */
  2707. static MatrixUse64Bits: boolean;
  2708. /** @hidden */
  2709. static MatrixTrackPrecisionChange: boolean;
  2710. /** @hidden */
  2711. static MatrixCurrentType: any;
  2712. /** @hidden */
  2713. static MatrixTrackedMatrices: Array<any> | null;
  2714. /** @hidden */
  2715. static SetMatrixPrecision(use64bits: boolean): void;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * Class representing a vector containing 2 coordinates
  2721. */
  2722. export class Vector2 {
  2723. /** defines the first coordinate */
  2724. x: number;
  2725. /** defines the second coordinate */
  2726. y: number;
  2727. /**
  2728. * Creates a new Vector2 from the given x and y coordinates
  2729. * @param x defines the first coordinate
  2730. * @param y defines the second coordinate
  2731. */
  2732. constructor(
  2733. /** defines the first coordinate */
  2734. x?: number,
  2735. /** defines the second coordinate */
  2736. y?: number);
  2737. /**
  2738. * Gets a string with the Vector2 coordinates
  2739. * @returns a string with the Vector2 coordinates
  2740. */
  2741. toString(): string;
  2742. /**
  2743. * Gets class name
  2744. * @returns the string "Vector2"
  2745. */
  2746. getClassName(): string;
  2747. /**
  2748. * Gets current vector hash code
  2749. * @returns the Vector2 hash code as a number
  2750. */
  2751. getHashCode(): number;
  2752. /**
  2753. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2754. * @param array defines the source array
  2755. * @param index defines the offset in source array
  2756. * @returns the current Vector2
  2757. */
  2758. toArray(array: FloatArray, index?: number): Vector2;
  2759. /**
  2760. * Update the current vector from an array
  2761. * @param array defines the destination array
  2762. * @param index defines the offset in the destination array
  2763. * @returns the current Vector3
  2764. */
  2765. fromArray(array: FloatArray, index?: number): Vector2;
  2766. /**
  2767. * Copy the current vector to an array
  2768. * @returns a new array with 2 elements: the Vector2 coordinates.
  2769. */
  2770. asArray(): number[];
  2771. /**
  2772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2773. * @param source defines the source Vector2
  2774. * @returns the current updated Vector2
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2777. /**
  2778. * Sets the Vector2 coordinates with the given floats
  2779. * @param x defines the first coordinate
  2780. * @param y defines the second coordinate
  2781. * @returns the current updated Vector2
  2782. */
  2783. copyFromFloats(x: number, y: number): Vector2;
  2784. /**
  2785. * Sets the Vector2 coordinates with the given floats
  2786. * @param x defines the first coordinate
  2787. * @param y defines the second coordinate
  2788. * @returns the current updated Vector2
  2789. */
  2790. set(x: number, y: number): Vector2;
  2791. /**
  2792. * Add another vector with the current one
  2793. * @param otherVector defines the other vector
  2794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2795. */
  2796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2797. /**
  2798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2799. * @param otherVector defines the other vector
  2800. * @param result defines the target vector
  2801. * @returns the unmodified current Vector2
  2802. */
  2803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2804. /**
  2805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2806. * @param otherVector defines the other vector
  2807. * @returns the current updated Vector2
  2808. */
  2809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2810. /**
  2811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2812. * @param otherVector defines the other vector
  2813. * @returns a new Vector2
  2814. */
  2815. addVector3(otherVector: Vector3): Vector2;
  2816. /**
  2817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2818. * @param otherVector defines the other vector
  2819. * @returns a new Vector2
  2820. */
  2821. subtract(otherVector: Vector2): Vector2;
  2822. /**
  2823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2824. * @param otherVector defines the other vector
  2825. * @param result defines the target vector
  2826. * @returns the unmodified current Vector2
  2827. */
  2828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2829. /**
  2830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2831. * @param otherVector defines the other vector
  2832. * @returns the current updated Vector2
  2833. */
  2834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2835. /**
  2836. * Multiplies in place the current Vector2 coordinates by the given ones
  2837. * @param otherVector defines the other vector
  2838. * @returns the current updated Vector2
  2839. */
  2840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2841. /**
  2842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2843. * @param otherVector defines the other vector
  2844. * @returns a new Vector2
  2845. */
  2846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2847. /**
  2848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @param result defines the target vector
  2851. * @returns the unmodified current Vector2
  2852. */
  2853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2854. /**
  2855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2856. * @param x defines the first coordinate
  2857. * @param y defines the second coordinate
  2858. * @returns a new Vector2
  2859. */
  2860. multiplyByFloats(x: number, y: number): Vector2;
  2861. /**
  2862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2863. * @param otherVector defines the other vector
  2864. * @returns a new Vector2
  2865. */
  2866. divide(otherVector: Vector2): Vector2;
  2867. /**
  2868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2869. * @param otherVector defines the other vector
  2870. * @param result defines the target vector
  2871. * @returns the unmodified current Vector2
  2872. */
  2873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2874. /**
  2875. * Divides the current Vector2 coordinates by the given ones
  2876. * @param otherVector defines the other vector
  2877. * @returns the current updated Vector2
  2878. */
  2879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets a new Vector2 with current Vector2 negated coordinates
  2882. * @returns a new Vector2
  2883. */
  2884. negate(): Vector2;
  2885. /**
  2886. * Negate this vector in place
  2887. * @returns this
  2888. */
  2889. negateInPlace(): Vector2;
  2890. /**
  2891. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2892. * @param result defines the Vector3 object where to store the result
  2893. * @returns the current Vector2
  2894. */
  2895. negateToRef(result: Vector2): Vector2;
  2896. /**
  2897. * Multiply the Vector2 coordinates by scale
  2898. * @param scale defines the scaling factor
  2899. * @returns the current updated Vector2
  2900. */
  2901. scaleInPlace(scale: number): Vector2;
  2902. /**
  2903. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2904. * @param scale defines the scaling factor
  2905. * @returns a new Vector2
  2906. */
  2907. scale(scale: number): Vector2;
  2908. /**
  2909. * Scale the current Vector2 values by a factor to a given Vector2
  2910. * @param scale defines the scale factor
  2911. * @param result defines the Vector2 object where to store the result
  2912. * @returns the unmodified current Vector2
  2913. */
  2914. scaleToRef(scale: number, result: Vector2): Vector2;
  2915. /**
  2916. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2917. * @param scale defines the scale factor
  2918. * @param result defines the Vector2 object where to store the result
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2922. /**
  2923. * Gets a boolean if two vectors are equals
  2924. * @param otherVector defines the other vector
  2925. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2926. */
  2927. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2928. /**
  2929. * Gets a boolean if two vectors are equals (using an epsilon value)
  2930. * @param otherVector defines the other vector
  2931. * @param epsilon defines the minimal distance to consider equality
  2932. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2933. */
  2934. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. floor(): Vector2;
  2940. /**
  2941. * Gets a new Vector2 from current Vector2 floored values
  2942. * @returns a new Vector2
  2943. */
  2944. fract(): Vector2;
  2945. /**
  2946. * Gets the length of the vector
  2947. * @returns the vector length (float)
  2948. */
  2949. length(): number;
  2950. /**
  2951. * Gets the vector squared length
  2952. * @returns the vector squared length (float)
  2953. */
  2954. lengthSquared(): number;
  2955. /**
  2956. * Normalize the vector
  2957. * @returns the current updated Vector2
  2958. */
  2959. normalize(): Vector2;
  2960. /**
  2961. * Gets a new Vector2 copied from the Vector2
  2962. * @returns a new Vector2
  2963. */
  2964. clone(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(0, 0)
  2967. * @returns a new Vector2
  2968. */
  2969. static Zero(): Vector2;
  2970. /**
  2971. * Gets a new Vector2(1, 1)
  2972. * @returns a new Vector2
  2973. */
  2974. static One(): Vector2;
  2975. /**
  2976. * Gets a new Vector2 set from the given index element of the given array
  2977. * @param array defines the data source
  2978. * @param offset defines the offset in the data source
  2979. * @returns a new Vector2
  2980. */
  2981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2982. /**
  2983. * Sets "result" from the given index element of the given array
  2984. * @param array defines the data source
  2985. * @param offset defines the offset in the data source
  2986. * @param result defines the target vector
  2987. */
  2988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2989. /**
  2990. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2991. * @param value1 defines 1st point of control
  2992. * @param value2 defines 2nd point of control
  2993. * @param value3 defines 3rd point of control
  2994. * @param value4 defines 4th point of control
  2995. * @param amount defines the interpolation factor
  2996. * @returns a new Vector2
  2997. */
  2998. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2999. /**
  3000. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  3001. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3002. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3003. * @param value defines the value to clamp
  3004. * @param min defines the lower limit
  3005. * @param max defines the upper limit
  3006. * @returns a new Vector2
  3007. */
  3008. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3009. /**
  3010. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3011. * @param value1 defines the 1st control point
  3012. * @param tangent1 defines the outgoing tangent
  3013. * @param value2 defines the 2nd control point
  3014. * @param tangent2 defines the incoming tangent
  3015. * @param amount defines the interpolation factor
  3016. * @returns a new Vector2
  3017. */
  3018. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3019. /**
  3020. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3021. * @param start defines the start vector
  3022. * @param end defines the end vector
  3023. * @param amount defines the interpolation factor
  3024. * @returns a new Vector2
  3025. */
  3026. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3027. /**
  3028. * Gets the dot product of the vector "left" and the vector "right"
  3029. * @param left defines first vector
  3030. * @param right defines second vector
  3031. * @returns the dot product (float)
  3032. */
  3033. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3034. /**
  3035. * Returns a new Vector2 equal to the normalized given vector
  3036. * @param vector defines the vector to normalize
  3037. * @returns a new Vector2
  3038. */
  3039. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3042. * @param left defines 1st vector
  3043. * @param right defines 2nd vector
  3044. * @returns a new Vector2
  3045. */
  3046. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3047. /**
  3048. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3049. * @param left defines 1st vector
  3050. * @param right defines 2nd vector
  3051. * @returns a new Vector2
  3052. */
  3053. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3054. /**
  3055. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3056. * @param vector defines the vector to transform
  3057. * @param transformation defines the matrix to apply
  3058. * @returns a new Vector2
  3059. */
  3060. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3061. /**
  3062. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3063. * @param vector defines the vector to transform
  3064. * @param transformation defines the matrix to apply
  3065. * @param result defines the target vector
  3066. */
  3067. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3068. /**
  3069. * Determines if a given vector is included in a triangle
  3070. * @param p defines the vector to test
  3071. * @param p0 defines 1st triangle point
  3072. * @param p1 defines 2nd triangle point
  3073. * @param p2 defines 3rd triangle point
  3074. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3075. */
  3076. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3077. /**
  3078. * Gets the distance between the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns the distance between vectors
  3082. */
  3083. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3084. /**
  3085. * Returns the squared distance between the vectors "value1" and "value2"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @returns the squared distance between vectors
  3089. */
  3090. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3091. /**
  3092. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3093. * @param value1 defines first vector
  3094. * @param value2 defines second vector
  3095. * @returns a new Vector2
  3096. */
  3097. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3098. /**
  3099. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3100. * @param value1 defines first vector
  3101. * @param value2 defines second vector
  3102. * @param ref defines third vector
  3103. * @returns ref
  3104. */
  3105. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3106. /**
  3107. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3108. * @param p defines the middle point
  3109. * @param segA defines one point of the segment
  3110. * @param segB defines the other point of the segment
  3111. * @returns the shortest distance
  3112. */
  3113. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3114. }
  3115. /**
  3116. * Class used to store (x,y,z) vector representation
  3117. * A Vector3 is the main object used in 3D geometry
  3118. * It can represent etiher the coordinates of a point the space, either a direction
  3119. * Reminder: js uses a left handed forward facing system
  3120. */
  3121. export class Vector3 {
  3122. private static _UpReadOnly;
  3123. private static _ZeroReadOnly;
  3124. /** @hidden */
  3125. _x: number;
  3126. /** @hidden */
  3127. _y: number;
  3128. /** @hidden */
  3129. _z: number;
  3130. /** @hidden */
  3131. _isDirty: boolean;
  3132. /** Gets or sets the x coordinate */
  3133. get x(): number;
  3134. set x(value: number);
  3135. /** Gets or sets the y coordinate */
  3136. get y(): number;
  3137. set y(value: number);
  3138. /** Gets or sets the z coordinate */
  3139. get z(): number;
  3140. set z(value: number);
  3141. /**
  3142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3143. * @param x defines the first coordinates (on X axis)
  3144. * @param y defines the second coordinates (on Y axis)
  3145. * @param z defines the third coordinates (on Z axis)
  3146. */
  3147. constructor(x?: number, y?: number, z?: number);
  3148. /**
  3149. * Creates a string representation of the Vector3
  3150. * @returns a string with the Vector3 coordinates.
  3151. */
  3152. toString(): string;
  3153. /**
  3154. * Gets the class name
  3155. * @returns the string "Vector3"
  3156. */
  3157. getClassName(): string;
  3158. /**
  3159. * Creates the Vector3 hash code
  3160. * @returns a number which tends to be unique between Vector3 instances
  3161. */
  3162. getHashCode(): number;
  3163. /**
  3164. * Creates an array containing three elements : the coordinates of the Vector3
  3165. * @returns a new array of numbers
  3166. */
  3167. asArray(): number[];
  3168. /**
  3169. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3170. * @param array defines the destination array
  3171. * @param index defines the offset in the destination array
  3172. * @returns the current Vector3
  3173. */
  3174. toArray(array: FloatArray, index?: number): Vector3;
  3175. /**
  3176. * Update the current vector from an array
  3177. * @param array defines the destination array
  3178. * @param index defines the offset in the destination array
  3179. * @returns the current Vector3
  3180. */
  3181. fromArray(array: FloatArray, index?: number): Vector3;
  3182. /**
  3183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3185. */
  3186. toQuaternion(): Quaternion;
  3187. /**
  3188. * Adds the given vector to the current Vector3
  3189. * @param otherVector defines the second operand
  3190. * @returns the current updated Vector3
  3191. */
  3192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the given coordinates to the current Vector3
  3195. * @param x defines the x coordinate of the operand
  3196. * @param y defines the y coordinate of the operand
  3197. * @param z defines the z coordinate of the operand
  3198. * @returns the current updated Vector3
  3199. */
  3200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3201. /**
  3202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3203. * @param otherVector defines the second operand
  3204. * @returns the resulting Vector3
  3205. */
  3206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3207. /**
  3208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3209. * @param otherVector defines the second operand
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector3
  3212. */
  3213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3214. /**
  3215. * Subtract the given vector from the current Vector3
  3216. * @param otherVector defines the second operand
  3217. * @returns the current updated Vector3
  3218. */
  3219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3222. * @param otherVector defines the second operand
  3223. * @returns the resulting Vector3
  3224. */
  3225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3226. /**
  3227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3228. * @param otherVector defines the second operand
  3229. * @param result defines the Vector3 object where to store the result
  3230. * @returns the current Vector3
  3231. */
  3232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3235. * @param x defines the x coordinate of the operand
  3236. * @param y defines the y coordinate of the operand
  3237. * @param z defines the z coordinate of the operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3241. /**
  3242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @param result defines the Vector3 object where to store the result
  3247. * @returns the current Vector3
  3248. */
  3249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3250. /**
  3251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3252. * @returns a new Vector3
  3253. */
  3254. negate(): Vector3;
  3255. /**
  3256. * Negate this vector in place
  3257. * @returns this
  3258. */
  3259. negateInPlace(): Vector3;
  3260. /**
  3261. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3262. * @param result defines the Vector3 object where to store the result
  3263. * @returns the current Vector3
  3264. */
  3265. negateToRef(result: Vector3): Vector3;
  3266. /**
  3267. * Multiplies the Vector3 coordinates by the float "scale"
  3268. * @param scale defines the multiplier factor
  3269. * @returns the current updated Vector3
  3270. */
  3271. scaleInPlace(scale: number): Vector3;
  3272. /**
  3273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3274. * @param scale defines the multiplier factor
  3275. * @returns a new Vector3
  3276. */
  3277. scale(scale: number): Vector3;
  3278. /**
  3279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3280. * @param scale defines the multiplier factor
  3281. * @param result defines the Vector3 object where to store the result
  3282. * @returns the current Vector3
  3283. */
  3284. scaleToRef(scale: number, result: Vector3): Vector3;
  3285. /**
  3286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3287. * @param scale defines the scale factor
  3288. * @param result defines the Vector3 object where to store the result
  3289. * @returns the unmodified current Vector3
  3290. */
  3291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3292. /**
  3293. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3294. * @param origin defines the origin of the projection ray
  3295. * @param plane defines the plane to project to
  3296. * @returns the projected vector3
  3297. */
  3298. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3299. /**
  3300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3301. * @param origin defines the origin of the projection ray
  3302. * @param plane defines the plane to project to
  3303. * @param result defines the Vector3 where to store the result
  3304. */
  3305. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3306. /**
  3307. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3308. * @param otherVector defines the second operand
  3309. * @returns true if both vectors are equals
  3310. */
  3311. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3312. /**
  3313. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3314. * @param otherVector defines the second operand
  3315. * @param epsilon defines the minimal distance to define values as equals
  3316. * @returns true if both vectors are distant less than epsilon
  3317. */
  3318. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3319. /**
  3320. * Returns true if the current Vector3 coordinates equals the given floats
  3321. * @param x defines the x coordinate of the operand
  3322. * @param y defines the y coordinate of the operand
  3323. * @param z defines the z coordinate of the operand
  3324. * @returns true if both vectors are equals
  3325. */
  3326. equalsToFloats(x: number, y: number, z: number): boolean;
  3327. /**
  3328. * Multiplies the current Vector3 coordinates by the given ones
  3329. * @param otherVector defines the second operand
  3330. * @returns the current updated Vector3
  3331. */
  3332. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3333. /**
  3334. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3335. * @param otherVector defines the second operand
  3336. * @returns the new Vector3
  3337. */
  3338. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3339. /**
  3340. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3341. * @param otherVector defines the second operand
  3342. * @param result defines the Vector3 object where to store the result
  3343. * @returns the current Vector3
  3344. */
  3345. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3348. * @param x defines the x coordinate of the operand
  3349. * @param y defines the y coordinate of the operand
  3350. * @param z defines the z coordinate of the operand
  3351. * @returns the new Vector3
  3352. */
  3353. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3356. * @param otherVector defines the second operand
  3357. * @returns the new Vector3
  3358. */
  3359. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3360. /**
  3361. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3362. * @param otherVector defines the second operand
  3363. * @param result defines the Vector3 object where to store the result
  3364. * @returns the current Vector3
  3365. */
  3366. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3367. /**
  3368. * Divides the current Vector3 coordinates by the given ones.
  3369. * @param otherVector defines the second operand
  3370. * @returns the current updated Vector3
  3371. */
  3372. divideInPlace(otherVector: Vector3): Vector3;
  3373. /**
  3374. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3375. * @param other defines the second operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3381. * @param other defines the second operand
  3382. * @returns the current updated Vector3
  3383. */
  3384. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3385. /**
  3386. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3387. * @param x defines the x coordinate of the operand
  3388. * @param y defines the y coordinate of the operand
  3389. * @param z defines the z coordinate of the operand
  3390. * @returns the current updated Vector3
  3391. */
  3392. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3393. /**
  3394. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3395. * @param x defines the x coordinate of the operand
  3396. * @param y defines the y coordinate of the operand
  3397. * @param z defines the z coordinate of the operand
  3398. * @returns the current updated Vector3
  3399. */
  3400. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3401. /**
  3402. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3403. * Check if is non uniform within a certain amount of decimal places to account for this
  3404. * @param epsilon the amount the values can differ
  3405. * @returns if the the vector is non uniform to a certain number of decimal places
  3406. */
  3407. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3408. /**
  3409. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3410. */
  3411. get isNonUniform(): boolean;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. floor(): Vector3;
  3417. /**
  3418. * Gets a new Vector3 from current Vector3 floored values
  3419. * @returns a new Vector3
  3420. */
  3421. fract(): Vector3;
  3422. /**
  3423. * Gets the length of the Vector3
  3424. * @returns the length of the Vector3
  3425. */
  3426. length(): number;
  3427. /**
  3428. * Gets the squared length of the Vector3
  3429. * @returns squared length of the Vector3
  3430. */
  3431. lengthSquared(): number;
  3432. /**
  3433. * Normalize the current Vector3.
  3434. * Please note that this is an in place operation.
  3435. * @returns the current updated Vector3
  3436. */
  3437. normalize(): Vector3;
  3438. /**
  3439. * Reorders the x y z properties of the vector in place
  3440. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3441. * @returns the current updated vector
  3442. */
  3443. reorderInPlace(order: string): this;
  3444. /**
  3445. * Rotates the vector around 0,0,0 by a quaternion
  3446. * @param quaternion the rotation quaternion
  3447. * @param result vector to store the result
  3448. * @returns the resulting vector
  3449. */
  3450. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3451. /**
  3452. * Rotates a vector around a given point
  3453. * @param quaternion the rotation quaternion
  3454. * @param point the point to rotate around
  3455. * @param result vector to store the result
  3456. * @returns the resulting vector
  3457. */
  3458. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3459. /**
  3460. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3461. * The cross product is then orthogonal to both current and "other"
  3462. * @param other defines the right operand
  3463. * @returns the cross product
  3464. */
  3465. cross(other: Vector3): Vector3;
  3466. /**
  3467. * Normalize the current Vector3 with the given input length.
  3468. * Please note that this is an in place operation.
  3469. * @param len the length of the vector
  3470. * @returns the current updated Vector3
  3471. */
  3472. normalizeFromLength(len: number): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to a new vector
  3475. * @returns the new Vector3
  3476. */
  3477. normalizeToNew(): Vector3;
  3478. /**
  3479. * Normalize the current Vector3 to the reference
  3480. * @param reference define the Vector3 to update
  3481. * @returns the updated Vector3
  3482. */
  3483. normalizeToRef(reference: Vector3): Vector3;
  3484. /**
  3485. * Creates a new Vector3 copied from the current Vector3
  3486. * @returns the new Vector3
  3487. */
  3488. clone(): Vector3;
  3489. /**
  3490. * Copies the given vector coordinates to the current Vector3 ones
  3491. * @param source defines the source Vector3
  3492. * @returns the current updated Vector3
  3493. */
  3494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3495. /**
  3496. * Copies the given floats to the current Vector3 coordinates
  3497. * @param x defines the x coordinate of the operand
  3498. * @param y defines the y coordinate of the operand
  3499. * @param z defines the z coordinate of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number): Vector3;
  3503. /**
  3504. * Copies the given floats to the current Vector3 coordinates
  3505. * @param x defines the x coordinate of the operand
  3506. * @param y defines the y coordinate of the operand
  3507. * @param z defines the z coordinate of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. set(x: number, y: number, z: number): Vector3;
  3511. /**
  3512. * Copies the given float to the current Vector3 coordinates
  3513. * @param v defines the x, y and z coordinates of the operand
  3514. * @returns the current updated Vector3
  3515. */
  3516. setAll(v: number): Vector3;
  3517. /**
  3518. * Get the clip factor between two vectors
  3519. * @param vector0 defines the first operand
  3520. * @param vector1 defines the second operand
  3521. * @param axis defines the axis to use
  3522. * @param size defines the size along the axis
  3523. * @returns the clip factor
  3524. */
  3525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3526. /**
  3527. * Get angle between two vectors
  3528. * @param vector0 angle between vector0 and vector1
  3529. * @param vector1 angle between vector0 and vector1
  3530. * @param normal direction of the normal
  3531. * @return the angle between vector0 and vector1
  3532. */
  3533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3534. /**
  3535. * Returns a new Vector3 set from the index "offset" of the given array
  3536. * @param array defines the source array
  3537. * @param offset defines the offset in the source array
  3538. * @returns the new Vector3
  3539. */
  3540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3541. /**
  3542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3543. * @param array defines the source array
  3544. * @param offset defines the offset in the source array
  3545. * @returns the new Vector3
  3546. * @deprecated Please use FromArray instead.
  3547. */
  3548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3549. /**
  3550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3551. * @param array defines the source array
  3552. * @param offset defines the offset in the source array
  3553. * @param result defines the Vector3 where to store the result
  3554. */
  3555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3556. /**
  3557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3558. * @param array defines the source array
  3559. * @param offset defines the offset in the source array
  3560. * @param result defines the Vector3 where to store the result
  3561. * @deprecated Please use FromArrayToRef instead.
  3562. */
  3563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3564. /**
  3565. * Sets the given vector "result" with the given floats.
  3566. * @param x defines the x coordinate of the source
  3567. * @param y defines the y coordinate of the source
  3568. * @param z defines the z coordinate of the source
  3569. * @param result defines the Vector3 where to store the result
  3570. */
  3571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3572. /**
  3573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3574. * @returns a new empty Vector3
  3575. */
  3576. static Zero(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3579. * @returns a new unit Vector3
  3580. */
  3581. static One(): Vector3;
  3582. /**
  3583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3584. * @returns a new up Vector3
  3585. */
  3586. static Up(): Vector3;
  3587. /**
  3588. * Gets a up Vector3 that must not be updated
  3589. */
  3590. static get UpReadOnly(): DeepImmutable<Vector3>;
  3591. /**
  3592. * Gets a zero Vector3 that must not be updated
  3593. */
  3594. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3597. * @returns a new down Vector3
  3598. */
  3599. static Down(): Vector3;
  3600. /**
  3601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3602. * @param rightHandedSystem is the scene right-handed (negative z)
  3603. * @returns a new forward Vector3
  3604. */
  3605. static Forward(rightHandedSystem?: boolean): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3608. * @param rightHandedSystem is the scene right-handed (negative-z)
  3609. * @returns a new forward Vector3
  3610. */
  3611. static Backward(rightHandedSystem?: boolean): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3614. * @returns a new right Vector3
  3615. */
  3616. static Right(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3619. * @returns a new left Vector3
  3620. */
  3621. static Left(): Vector3;
  3622. /**
  3623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3625. * @param vector defines the Vector3 to transform
  3626. * @param transformation defines the transformation matrix
  3627. * @returns the transformed Vector3
  3628. */
  3629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3630. /**
  3631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3633. * @param vector defines the Vector3 to transform
  3634. * @param transformation defines the transformation matrix
  3635. * @param result defines the Vector3 where to store the result
  3636. */
  3637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3638. /**
  3639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3640. * This method computes tranformed coordinates only, not transformed direction vectors
  3641. * @param x define the x coordinate of the source vector
  3642. * @param y define the y coordinate of the source vector
  3643. * @param z define the z coordinate of the source vector
  3644. * @param transformation defines the transformation matrix
  3645. * @param result defines the Vector3 where to store the result
  3646. */
  3647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3648. /**
  3649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3651. * @param vector defines the Vector3 to transform
  3652. * @param transformation defines the transformation matrix
  3653. * @returns the new Vector3
  3654. */
  3655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3656. /**
  3657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @param result defines the Vector3 where to store the result
  3662. */
  3663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3664. /**
  3665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3667. * @param x define the x coordinate of the source vector
  3668. * @param y define the y coordinate of the source vector
  3669. * @param z define the z coordinate of the source vector
  3670. * @param transformation defines the transformation matrix
  3671. * @param result defines the Vector3 where to store the result
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3674. /**
  3675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3676. * @param value1 defines the first control point
  3677. * @param value2 defines the second control point
  3678. * @param value3 defines the third control point
  3679. * @param value4 defines the fourth control point
  3680. * @param amount defines the amount on the spline to use
  3681. * @returns the new Vector3
  3682. */
  3683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3684. /**
  3685. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3688. * @param value defines the current value
  3689. * @param min defines the lower range value
  3690. * @param max defines the upper range value
  3691. * @returns the new Vector3
  3692. */
  3693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3694. /**
  3695. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3698. * @param value defines the current value
  3699. * @param min defines the lower range value
  3700. * @param max defines the upper range value
  3701. * @param result defines the Vector3 where to store the result
  3702. */
  3703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3704. /**
  3705. * Checks if a given vector is inside a specific range
  3706. * @param v defines the vector to test
  3707. * @param min defines the minimum range
  3708. * @param max defines the maximum range
  3709. */
  3710. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3711. /**
  3712. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3713. * @param value1 defines the first control point
  3714. * @param tangent1 defines the first tangent vector
  3715. * @param value2 defines the second control point
  3716. * @param tangent2 defines the second tangent vector
  3717. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3718. * @returns the new Vector3
  3719. */
  3720. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3721. /**
  3722. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3723. * @param start defines the start value
  3724. * @param end defines the end value
  3725. * @param amount max defines amount between both (between 0 and 1)
  3726. * @returns the new Vector3
  3727. */
  3728. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3729. /**
  3730. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3731. * @param start defines the start value
  3732. * @param end defines the end value
  3733. * @param amount max defines amount between both (between 0 and 1)
  3734. * @param result defines the Vector3 where to store the result
  3735. */
  3736. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3737. /**
  3738. * Returns the dot product (float) between the vectors "left" and "right"
  3739. * @param left defines the left operand
  3740. * @param right defines the right operand
  3741. * @returns the dot product
  3742. */
  3743. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3744. /**
  3745. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3746. * The cross product is then orthogonal to both "left" and "right"
  3747. * @param left defines the left operand
  3748. * @param right defines the right operand
  3749. * @returns the cross product
  3750. */
  3751. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the cross product of "left" and "right"
  3754. * The cross product is then orthogonal to both "left" and "right"
  3755. * @param left defines the left operand
  3756. * @param right defines the right operand
  3757. * @param result defines the Vector3 where to store the result
  3758. */
  3759. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3760. /**
  3761. * Returns a new Vector3 as the normalization of the given vector
  3762. * @param vector defines the Vector3 to normalize
  3763. * @returns the new Vector3
  3764. */
  3765. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3766. /**
  3767. * Sets the given vector "result" with the normalization of the given first vector
  3768. * @param vector defines the Vector3 to normalize
  3769. * @param result defines the Vector3 where to store the result
  3770. */
  3771. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3772. /**
  3773. * Project a Vector3 onto screen space
  3774. * @param vector defines the Vector3 to project
  3775. * @param world defines the world matrix to use
  3776. * @param transform defines the transform (view x projection) matrix to use
  3777. * @param viewport defines the screen viewport to use
  3778. * @returns the new Vector3
  3779. */
  3780. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3781. /**
  3782. * Project a Vector3 onto screen space to reference
  3783. * @param vector defines the Vector3 to project
  3784. * @param world defines the world matrix to use
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @param viewport defines the screen viewport to use
  3787. * @param result the vector in which the screen space will be stored
  3788. * @returns the new Vector3
  3789. */
  3790. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3791. /** @hidden */
  3792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3793. /**
  3794. * Unproject from screen space to object space
  3795. * @param source defines the screen space Vector3 to use
  3796. * @param viewportWidth defines the current width of the viewport
  3797. * @param viewportHeight defines the current height of the viewport
  3798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3799. * @param transform defines the transform (view x projection) matrix to use
  3800. * @returns the new Vector3
  3801. */
  3802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3803. /**
  3804. * Unproject from screen space to object space
  3805. * @param source defines the screen space Vector3 to use
  3806. * @param viewportWidth defines the current width of the viewport
  3807. * @param viewportHeight defines the current height of the viewport
  3808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3809. * @param view defines the view matrix to use
  3810. * @param projection defines the projection matrix to use
  3811. * @returns the new Vector3
  3812. */
  3813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3814. /**
  3815. * Unproject from screen space to object space
  3816. * @param source defines the screen space Vector3 to use
  3817. * @param viewportWidth defines the current width of the viewport
  3818. * @param viewportHeight defines the current height of the viewport
  3819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3820. * @param view defines the view matrix to use
  3821. * @param projection defines the projection matrix to use
  3822. * @param result defines the Vector3 where to store the result
  3823. */
  3824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3825. /**
  3826. * Unproject from screen space to object space
  3827. * @param sourceX defines the screen space x coordinate to use
  3828. * @param sourceY defines the screen space y coordinate to use
  3829. * @param sourceZ defines the screen space z coordinate to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param view defines the view matrix to use
  3834. * @param projection defines the projection matrix to use
  3835. * @param result defines the Vector3 where to store the result
  3836. */
  3837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3838. /**
  3839. * Gets the minimal coordinate values between two Vector3
  3840. * @param left defines the first operand
  3841. * @param right defines the second operand
  3842. * @returns the new Vector3
  3843. */
  3844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3845. /**
  3846. * Gets the maximal coordinate values between two Vector3
  3847. * @param left defines the first operand
  3848. * @param right defines the second operand
  3849. * @returns the new Vector3
  3850. */
  3851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3852. /**
  3853. * Returns the distance between the vectors "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the distance
  3857. */
  3858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3859. /**
  3860. * Returns the squared distance between the vectors "value1" and "value2"
  3861. * @param value1 defines the first operand
  3862. * @param value2 defines the second operand
  3863. * @returns the squared distance
  3864. */
  3865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3866. /**
  3867. * Returns a new Vector3 located at the center between "value1" and "value2"
  3868. * @param value1 defines the first operand
  3869. * @param value2 defines the second operand
  3870. * @returns the new Vector3
  3871. */
  3872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3873. /**
  3874. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3875. * @param value1 defines first vector
  3876. * @param value2 defines second vector
  3877. * @param ref defines third vector
  3878. * @returns ref
  3879. */
  3880. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3881. /**
  3882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3884. * to something in order to rotate it from its local system to the given target system
  3885. * Note: axis1, axis2 and axis3 are normalized during this operation
  3886. * @param axis1 defines the first axis
  3887. * @param axis2 defines the second axis
  3888. * @param axis3 defines the third axis
  3889. * @returns a new Vector3
  3890. */
  3891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3892. /**
  3893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3894. * @param axis1 defines the first axis
  3895. * @param axis2 defines the second axis
  3896. * @param axis3 defines the third axis
  3897. * @param ref defines the Vector3 where to store the result
  3898. */
  3899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3900. }
  3901. /**
  3902. * Vector4 class created for EulerAngle class conversion to Quaternion
  3903. */
  3904. export class Vector4 {
  3905. /** x value of the vector */
  3906. x: number;
  3907. /** y value of the vector */
  3908. y: number;
  3909. /** z value of the vector */
  3910. z: number;
  3911. /** w value of the vector */
  3912. w: number;
  3913. /**
  3914. * Creates a Vector4 object from the given floats.
  3915. * @param x x value of the vector
  3916. * @param y y value of the vector
  3917. * @param z z value of the vector
  3918. * @param w w value of the vector
  3919. */
  3920. constructor(
  3921. /** x value of the vector */
  3922. x: number,
  3923. /** y value of the vector */
  3924. y: number,
  3925. /** z value of the vector */
  3926. z: number,
  3927. /** w value of the vector */
  3928. w: number);
  3929. /**
  3930. * Returns the string with the Vector4 coordinates.
  3931. * @returns a string containing all the vector values
  3932. */
  3933. toString(): string;
  3934. /**
  3935. * Returns the string "Vector4".
  3936. * @returns "Vector4"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Returns the Vector4 hash code.
  3941. * @returns a unique hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3946. * @returns the resulting array
  3947. */
  3948. asArray(): number[];
  3949. /**
  3950. * Populates the given array from the given index with the Vector4 coordinates.
  3951. * @param array array to populate
  3952. * @param index index of the array to start at (default: 0)
  3953. * @returns the Vector4.
  3954. */
  3955. toArray(array: FloatArray, index?: number): Vector4;
  3956. /**
  3957. * Update the current vector from an array
  3958. * @param array defines the destination array
  3959. * @param index defines the offset in the destination array
  3960. * @returns the current Vector3
  3961. */
  3962. fromArray(array: FloatArray, index?: number): Vector4;
  3963. /**
  3964. * Adds the given vector to the current Vector4.
  3965. * @param otherVector the vector to add
  3966. * @returns the updated Vector4.
  3967. */
  3968. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3969. /**
  3970. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3971. * @param otherVector the vector to add
  3972. * @returns the resulting vector
  3973. */
  3974. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3975. /**
  3976. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3977. * @param otherVector the vector to add
  3978. * @param result the vector to store the result
  3979. * @returns the current Vector4.
  3980. */
  3981. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3982. /**
  3983. * Subtract in place the given vector from the current Vector4.
  3984. * @param otherVector the vector to subtract
  3985. * @returns the updated Vector4.
  3986. */
  3987. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3988. /**
  3989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3990. * @param otherVector the vector to add
  3991. * @returns the new vector with the result
  3992. */
  3993. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3994. /**
  3995. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3996. * @param otherVector the vector to subtract
  3997. * @param result the vector to store the result
  3998. * @returns the current Vector4.
  3999. */
  4000. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4003. */
  4004. /**
  4005. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4006. * @param x value to subtract
  4007. * @param y value to subtract
  4008. * @param z value to subtract
  4009. * @param w value to subtract
  4010. * @returns new vector containing the result
  4011. */
  4012. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4013. /**
  4014. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4015. * @param x value to subtract
  4016. * @param y value to subtract
  4017. * @param z value to subtract
  4018. * @param w value to subtract
  4019. * @param result the vector to store the result in
  4020. * @returns the current Vector4.
  4021. */
  4022. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4023. /**
  4024. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4025. * @returns a new vector with the negated values
  4026. */
  4027. negate(): Vector4;
  4028. /**
  4029. * Negate this vector in place
  4030. * @returns this
  4031. */
  4032. negateInPlace(): Vector4;
  4033. /**
  4034. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4035. * @param result defines the Vector3 object where to store the result
  4036. * @returns the current Vector4
  4037. */
  4038. negateToRef(result: Vector4): Vector4;
  4039. /**
  4040. * Multiplies the current Vector4 coordinates by scale (float).
  4041. * @param scale the number to scale with
  4042. * @returns the updated Vector4.
  4043. */
  4044. scaleInPlace(scale: number): Vector4;
  4045. /**
  4046. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4047. * @param scale the number to scale with
  4048. * @returns a new vector with the result
  4049. */
  4050. scale(scale: number): Vector4;
  4051. /**
  4052. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4053. * @param scale the number to scale with
  4054. * @param result a vector to store the result in
  4055. * @returns the current Vector4.
  4056. */
  4057. scaleToRef(scale: number, result: Vector4): Vector4;
  4058. /**
  4059. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4060. * @param scale defines the scale factor
  4061. * @param result defines the Vector4 object where to store the result
  4062. * @returns the unmodified current Vector4
  4063. */
  4064. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4065. /**
  4066. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4067. * @param otherVector the vector to compare against
  4068. * @returns true if they are equal
  4069. */
  4070. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4071. /**
  4072. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4073. * @param otherVector vector to compare against
  4074. * @param epsilon (Default: very small number)
  4075. * @returns true if they are equal
  4076. */
  4077. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4078. /**
  4079. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4080. * @param x x value to compare against
  4081. * @param y y value to compare against
  4082. * @param z z value to compare against
  4083. * @param w w value to compare against
  4084. * @returns true if equal
  4085. */
  4086. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4087. /**
  4088. * Multiplies in place the current Vector4 by the given one.
  4089. * @param otherVector vector to multiple with
  4090. * @returns the updated Vector4.
  4091. */
  4092. multiplyInPlace(otherVector: Vector4): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4095. * @param otherVector vector to multiple with
  4096. * @returns resulting new vector
  4097. */
  4098. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4099. /**
  4100. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4101. * @param otherVector vector to multiple with
  4102. * @param result vector to store the result
  4103. * @returns the current Vector4.
  4104. */
  4105. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4106. /**
  4107. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4108. * @param x x value multiply with
  4109. * @param y y value multiply with
  4110. * @param z z value multiply with
  4111. * @param w w value multiply with
  4112. * @returns resulting new vector
  4113. */
  4114. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4115. /**
  4116. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4117. * @param otherVector vector to devide with
  4118. * @returns resulting new vector
  4119. */
  4120. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4121. /**
  4122. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4123. * @param otherVector vector to devide with
  4124. * @param result vector to store the result
  4125. * @returns the current Vector4.
  4126. */
  4127. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4128. /**
  4129. * Divides the current Vector3 coordinates by the given ones.
  4130. * @param otherVector vector to devide with
  4131. * @returns the updated Vector3.
  4132. */
  4133. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4134. /**
  4135. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4136. * @param other defines the second operand
  4137. * @returns the current updated Vector4
  4138. */
  4139. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4140. /**
  4141. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4142. * @param other defines the second operand
  4143. * @returns the current updated Vector4
  4144. */
  4145. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector4 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. floor(): Vector4;
  4151. /**
  4152. * Gets a new Vector4 from current Vector3 floored values
  4153. * @returns a new Vector4
  4154. */
  4155. fract(): Vector4;
  4156. /**
  4157. * Returns the Vector4 length (float).
  4158. * @returns the length
  4159. */
  4160. length(): number;
  4161. /**
  4162. * Returns the Vector4 squared length (float).
  4163. * @returns the length squared
  4164. */
  4165. lengthSquared(): number;
  4166. /**
  4167. * Normalizes in place the Vector4.
  4168. * @returns the updated Vector4.
  4169. */
  4170. normalize(): Vector4;
  4171. /**
  4172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4173. * @returns this converted to a new vector3
  4174. */
  4175. toVector3(): Vector3;
  4176. /**
  4177. * Returns a new Vector4 copied from the current one.
  4178. * @returns the new cloned vector
  4179. */
  4180. clone(): Vector4;
  4181. /**
  4182. * Updates the current Vector4 with the given one coordinates.
  4183. * @param source the source vector to copy from
  4184. * @returns the updated Vector4.
  4185. */
  4186. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4187. /**
  4188. * Updates the current Vector4 coordinates with the given floats.
  4189. * @param x float to copy from
  4190. * @param y float to copy from
  4191. * @param z float to copy from
  4192. * @param w float to copy from
  4193. * @returns the updated Vector4.
  4194. */
  4195. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4196. /**
  4197. * Updates the current Vector4 coordinates with the given floats.
  4198. * @param x float to set from
  4199. * @param y float to set from
  4200. * @param z float to set from
  4201. * @param w float to set from
  4202. * @returns the updated Vector4.
  4203. */
  4204. set(x: number, y: number, z: number, w: number): Vector4;
  4205. /**
  4206. * Copies the given float to the current Vector3 coordinates
  4207. * @param v defines the x, y, z and w coordinates of the operand
  4208. * @returns the current updated Vector3
  4209. */
  4210. setAll(v: number): Vector4;
  4211. /**
  4212. * Returns a new Vector4 set from the starting index of the given array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @returns the new vector
  4216. */
  4217. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4218. /**
  4219. * Updates the given vector "result" from the starting index of the given array.
  4220. * @param array the array to pull values from
  4221. * @param offset the offset into the array to start at
  4222. * @param result the vector to store the result in
  4223. */
  4224. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4225. /**
  4226. * Updates the given vector "result" from the starting index of the given Float32Array.
  4227. * @param array the array to pull values from
  4228. * @param offset the offset into the array to start at
  4229. * @param result the vector to store the result in
  4230. */
  4231. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4232. /**
  4233. * Updates the given vector "result" coordinates from the given floats.
  4234. * @param x float to set from
  4235. * @param y float to set from
  4236. * @param z float to set from
  4237. * @param w float to set from
  4238. * @param result the vector to the floats in
  4239. */
  4240. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4241. /**
  4242. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4243. * @returns the new vector
  4244. */
  4245. static Zero(): Vector4;
  4246. /**
  4247. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4248. * @returns the new vector
  4249. */
  4250. static One(): Vector4;
  4251. /**
  4252. * Returns a new normalized Vector4 from the given one.
  4253. * @param vector the vector to normalize
  4254. * @returns the vector
  4255. */
  4256. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4257. /**
  4258. * Updates the given vector "result" from the normalization of the given one.
  4259. * @param vector the vector to normalize
  4260. * @param result the vector to store the result in
  4261. */
  4262. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4263. /**
  4264. * Returns a vector with the minimum values from the left and right vectors
  4265. * @param left left vector to minimize
  4266. * @param right right vector to minimize
  4267. * @returns a new vector with the minimum of the left and right vector values
  4268. */
  4269. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4270. /**
  4271. * Returns a vector with the maximum values from the left and right vectors
  4272. * @param left left vector to maximize
  4273. * @param right right vector to maximize
  4274. * @returns a new vector with the maximum of the left and right vector values
  4275. */
  4276. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4277. /**
  4278. * Returns the distance (float) between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the distance between
  4280. * @param value2 value to calulate the distance between
  4281. * @return the distance between the two vectors
  4282. */
  4283. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4284. /**
  4285. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4286. * @param value1 value to calulate the distance between
  4287. * @param value2 value to calulate the distance between
  4288. * @return the distance between the two vectors squared
  4289. */
  4290. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4291. /**
  4292. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4293. * @param value1 value to calulate the center between
  4294. * @param value2 value to calulate the center between
  4295. * @return the center between the two vectors
  4296. */
  4297. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4298. /**
  4299. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4300. * @param value1 defines first vector
  4301. * @param value2 defines second vector
  4302. * @param ref defines third vector
  4303. * @returns ref
  4304. */
  4305. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4306. /**
  4307. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4308. * This methods computes transformed normalized direction vectors only.
  4309. * @param vector the vector to transform
  4310. * @param transformation the transformation matrix to apply
  4311. * @returns the new vector
  4312. */
  4313. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4314. /**
  4315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4316. * This methods computes transformed normalized direction vectors only.
  4317. * @param vector the vector to transform
  4318. * @param transformation the transformation matrix to apply
  4319. * @param result the vector to store the result in
  4320. */
  4321. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4322. /**
  4323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4324. * This methods computes transformed normalized direction vectors only.
  4325. * @param x value to transform
  4326. * @param y value to transform
  4327. * @param z value to transform
  4328. * @param w value to transform
  4329. * @param transformation the transformation matrix to apply
  4330. * @param result the vector to store the results in
  4331. */
  4332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4333. /**
  4334. * Creates a new Vector4 from a Vector3
  4335. * @param source defines the source data
  4336. * @param w defines the 4th component (default is 0)
  4337. * @returns a new Vector4
  4338. */
  4339. static FromVector3(source: Vector3, w?: number): Vector4;
  4340. }
  4341. /**
  4342. * Class used to store quaternion data
  4343. * @see https://en.wikipedia.org/wiki/Quaternion
  4344. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4345. */
  4346. export class Quaternion {
  4347. /** @hidden */
  4348. _x: number;
  4349. /** @hidden */
  4350. _y: number;
  4351. /** @hidden */
  4352. _z: number;
  4353. /** @hidden */
  4354. _w: number;
  4355. /** @hidden */
  4356. _isDirty: boolean;
  4357. /** Gets or sets the x coordinate */
  4358. get x(): number;
  4359. set x(value: number);
  4360. /** Gets or sets the y coordinate */
  4361. get y(): number;
  4362. set y(value: number);
  4363. /** Gets or sets the z coordinate */
  4364. get z(): number;
  4365. set z(value: number);
  4366. /** Gets or sets the w coordinate */
  4367. get w(): number;
  4368. set w(value: number);
  4369. /**
  4370. * Creates a new Quaternion from the given floats
  4371. * @param x defines the first component (0 by default)
  4372. * @param y defines the second component (0 by default)
  4373. * @param z defines the third component (0 by default)
  4374. * @param w defines the fourth component (1.0 by default)
  4375. */
  4376. constructor(x?: number, y?: number, z?: number, w?: number);
  4377. /**
  4378. * Gets a string representation for the current quaternion
  4379. * @returns a string with the Quaternion coordinates
  4380. */
  4381. toString(): string;
  4382. /**
  4383. * Gets the class name of the quaternion
  4384. * @returns the string "Quaternion"
  4385. */
  4386. getClassName(): string;
  4387. /**
  4388. * Gets a hash code for this quaternion
  4389. * @returns the quaternion hash code
  4390. */
  4391. getHashCode(): number;
  4392. /**
  4393. * Copy the quaternion to an array
  4394. * @returns a new array populated with 4 elements from the quaternion coordinates
  4395. */
  4396. asArray(): number[];
  4397. /**
  4398. * Check if two quaternions are equals
  4399. * @param otherQuaternion defines the second operand
  4400. * @return true if the current quaternion and the given one coordinates are strictly equals
  4401. */
  4402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4403. /**
  4404. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4405. * @param otherQuaternion defines the other quaternion
  4406. * @param epsilon defines the minimal distance to consider equality
  4407. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4408. */
  4409. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4410. /**
  4411. * Clone the current quaternion
  4412. * @returns a new quaternion copied from the current one
  4413. */
  4414. clone(): Quaternion;
  4415. /**
  4416. * Copy a quaternion to the current one
  4417. * @param other defines the other quaternion
  4418. * @returns the updated current quaternion
  4419. */
  4420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4421. /**
  4422. * Updates the current quaternion with the given float coordinates
  4423. * @param x defines the x coordinate
  4424. * @param y defines the y coordinate
  4425. * @param z defines the z coordinate
  4426. * @param w defines the w coordinate
  4427. * @returns the updated current quaternion
  4428. */
  4429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4430. /**
  4431. * Updates the current quaternion from the given float coordinates
  4432. * @param x defines the x coordinate
  4433. * @param y defines the y coordinate
  4434. * @param z defines the z coordinate
  4435. * @param w defines the w coordinate
  4436. * @returns the updated current quaternion
  4437. */
  4438. set(x: number, y: number, z: number, w: number): Quaternion;
  4439. /**
  4440. * Adds two quaternions
  4441. * @param other defines the second operand
  4442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4443. */
  4444. add(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Add a quaternion to the current one
  4447. * @param other defines the quaternion to add
  4448. * @returns the current quaternion
  4449. */
  4450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4451. /**
  4452. * Subtract two quaternions
  4453. * @param other defines the second operand
  4454. * @returns a new quaternion as the subtraction result of the given one from the current one
  4455. */
  4456. subtract(other: Quaternion): Quaternion;
  4457. /**
  4458. * Multiplies the current quaternion by a scale factor
  4459. * @param value defines the scale factor
  4460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4461. */
  4462. scale(value: number): Quaternion;
  4463. /**
  4464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4465. * @param scale defines the scale factor
  4466. * @param result defines the Quaternion object where to store the result
  4467. * @returns the unmodified current quaternion
  4468. */
  4469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4470. /**
  4471. * Multiplies in place the current quaternion by a scale factor
  4472. * @param value defines the scale factor
  4473. * @returns the current modified quaternion
  4474. */
  4475. scaleInPlace(value: number): Quaternion;
  4476. /**
  4477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4478. * @param scale defines the scale factor
  4479. * @param result defines the Quaternion object where to store the result
  4480. * @returns the unmodified current quaternion
  4481. */
  4482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4483. /**
  4484. * Multiplies two quaternions
  4485. * @param q1 defines the second operand
  4486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4487. */
  4488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4489. /**
  4490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4491. * @param q1 defines the second operand
  4492. * @param result defines the target quaternion
  4493. * @returns the current quaternion
  4494. */
  4495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4496. /**
  4497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4498. * @param q1 defines the second operand
  4499. * @returns the currentupdated quaternion
  4500. */
  4501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4502. /**
  4503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4504. * @param ref defines the target quaternion
  4505. * @returns the current quaternion
  4506. */
  4507. conjugateToRef(ref: Quaternion): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns the current updated quaternion
  4511. */
  4512. conjugateInPlace(): Quaternion;
  4513. /**
  4514. * Conjugates in place (1-q) the current quaternion
  4515. * @returns a new quaternion
  4516. */
  4517. conjugate(): Quaternion;
  4518. /**
  4519. * Gets length of current quaternion
  4520. * @returns the quaternion length (float)
  4521. */
  4522. length(): number;
  4523. /**
  4524. * Normalize in place the current quaternion
  4525. * @returns the current updated quaternion
  4526. */
  4527. normalize(): Quaternion;
  4528. /**
  4529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4530. * @param order is a reserved parameter and is ignored for now
  4531. * @returns a new Vector3 containing the Euler angles
  4532. */
  4533. toEulerAngles(order?: string): Vector3;
  4534. /**
  4535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4536. * @param result defines the vector which will be filled with the Euler angles
  4537. * @returns the current unchanged quaternion
  4538. */
  4539. toEulerAnglesToRef(result: Vector3): Quaternion;
  4540. /**
  4541. * Updates the given rotation matrix with the current quaternion values
  4542. * @param result defines the target matrix
  4543. * @returns the current unchanged quaternion
  4544. */
  4545. toRotationMatrix(result: Matrix): Quaternion;
  4546. /**
  4547. * Updates the current quaternion from the given rotation matrix values
  4548. * @param matrix defines the source matrix
  4549. * @returns the current updated quaternion
  4550. */
  4551. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4552. /**
  4553. * Creates a new quaternion from a rotation matrix
  4554. * @param matrix defines the source matrix
  4555. * @returns a new quaternion created from the given rotation matrix values
  4556. */
  4557. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4558. /**
  4559. * Updates the given quaternion with the given rotation matrix values
  4560. * @param matrix defines the source matrix
  4561. * @param result defines the target quaternion
  4562. */
  4563. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4564. /**
  4565. * Returns the dot product (float) between the quaternions "left" and "right"
  4566. * @param left defines the left operand
  4567. * @param right defines the right operand
  4568. * @returns the dot product
  4569. */
  4570. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4571. /**
  4572. * Checks if the two quaternions are close to each other
  4573. * @param quat0 defines the first quaternion to check
  4574. * @param quat1 defines the second quaternion to check
  4575. * @returns true if the two quaternions are close to each other
  4576. */
  4577. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4578. /**
  4579. * Creates an empty quaternion
  4580. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4581. */
  4582. static Zero(): Quaternion;
  4583. /**
  4584. * Inverse a given quaternion
  4585. * @param q defines the source quaternion
  4586. * @returns a new quaternion as the inverted current quaternion
  4587. */
  4588. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4589. /**
  4590. * Inverse a given quaternion
  4591. * @param q defines the source quaternion
  4592. * @param result the quaternion the result will be stored in
  4593. * @returns the result quaternion
  4594. */
  4595. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4596. /**
  4597. * Creates an identity quaternion
  4598. * @returns the identity quaternion
  4599. */
  4600. static Identity(): Quaternion;
  4601. /**
  4602. * Gets a boolean indicating if the given quaternion is identity
  4603. * @param quaternion defines the quaternion to check
  4604. * @returns true if the quaternion is identity
  4605. */
  4606. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4607. /**
  4608. * Creates a quaternion from a rotation around an axis
  4609. * @param axis defines the axis to use
  4610. * @param angle defines the angle to use
  4611. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4612. */
  4613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4614. /**
  4615. * Creates a rotation around an axis and stores it into the given quaternion
  4616. * @param axis defines the axis to use
  4617. * @param angle defines the angle to use
  4618. * @param result defines the target quaternion
  4619. * @returns the target quaternion
  4620. */
  4621. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4622. /**
  4623. * Creates a new quaternion from data stored into an array
  4624. * @param array defines the data source
  4625. * @param offset defines the offset in the source array where the data starts
  4626. * @returns a new quaternion
  4627. */
  4628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4629. /**
  4630. * Updates the given quaternion "result" from the starting index of the given array.
  4631. * @param array the array to pull values from
  4632. * @param offset the offset into the array to start at
  4633. * @param result the quaternion to store the result in
  4634. */
  4635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4636. /**
  4637. * Create a quaternion from Euler rotation angles
  4638. * @param x Pitch
  4639. * @param y Yaw
  4640. * @param z Roll
  4641. * @returns the new Quaternion
  4642. */
  4643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4644. /**
  4645. * Updates a quaternion from Euler rotation angles
  4646. * @param x Pitch
  4647. * @param y Yaw
  4648. * @param z Roll
  4649. * @param result the quaternion to store the result
  4650. * @returns the updated quaternion
  4651. */
  4652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4653. /**
  4654. * Create a quaternion from Euler rotation vector
  4655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4656. * @returns the new Quaternion
  4657. */
  4658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4659. /**
  4660. * Updates a quaternion from Euler rotation vector
  4661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4662. * @param result the quaternion to store the result
  4663. * @returns the updated quaternion
  4664. */
  4665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4666. /**
  4667. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4668. * @param vecFrom defines the direction vector from which to rotate
  4669. * @param vecTo defines the direction vector to which to rotate
  4670. * @param result the quaternion to store the result
  4671. * @returns the updated quaternion
  4672. */
  4673. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4674. /**
  4675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4676. * @param yaw defines the rotation around Y axis
  4677. * @param pitch defines the rotation around X axis
  4678. * @param roll defines the rotation around Z axis
  4679. * @returns the new quaternion
  4680. */
  4681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4682. /**
  4683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4684. * @param yaw defines the rotation around Y axis
  4685. * @param pitch defines the rotation around X axis
  4686. * @param roll defines the rotation around Z axis
  4687. * @param result defines the target quaternion
  4688. */
  4689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4690. /**
  4691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4692. * @param alpha defines the rotation around first axis
  4693. * @param beta defines the rotation around second axis
  4694. * @param gamma defines the rotation around third axis
  4695. * @returns the new quaternion
  4696. */
  4697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4700. * @param alpha defines the rotation around first axis
  4701. * @param beta defines the rotation around second axis
  4702. * @param gamma defines the rotation around third axis
  4703. * @param result defines the target quaternion
  4704. */
  4705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4706. /**
  4707. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4708. * @param axis1 defines the first axis
  4709. * @param axis2 defines the second axis
  4710. * @param axis3 defines the third axis
  4711. * @returns the new quaternion
  4712. */
  4713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4714. /**
  4715. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4716. * @param axis1 defines the first axis
  4717. * @param axis2 defines the second axis
  4718. * @param axis3 defines the third axis
  4719. * @param ref defines the target quaternion
  4720. */
  4721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4722. /**
  4723. * Interpolates between two quaternions
  4724. * @param left defines first quaternion
  4725. * @param right defines second quaternion
  4726. * @param amount defines the gradient to use
  4727. * @returns the new interpolated quaternion
  4728. */
  4729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4730. /**
  4731. * Interpolates between two quaternions and stores it into a target quaternion
  4732. * @param left defines first quaternion
  4733. * @param right defines second quaternion
  4734. * @param amount defines the gradient to use
  4735. * @param result defines the target quaternion
  4736. */
  4737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4738. /**
  4739. * Interpolate between two quaternions using Hermite interpolation
  4740. * @param value1 defines first quaternion
  4741. * @param tangent1 defines the incoming tangent
  4742. * @param value2 defines second quaternion
  4743. * @param tangent2 defines the outgoing tangent
  4744. * @param amount defines the target quaternion
  4745. * @returns the new interpolated quaternion
  4746. */
  4747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4748. }
  4749. /**
  4750. * Class used to store matrix data (4x4)
  4751. */
  4752. export class Matrix {
  4753. /**
  4754. * Gets the precision of matrix computations
  4755. */
  4756. static get Use64Bits(): boolean;
  4757. private static _updateFlagSeed;
  4758. private static _identityReadOnly;
  4759. private _isIdentity;
  4760. private _isIdentityDirty;
  4761. private _isIdentity3x2;
  4762. private _isIdentity3x2Dirty;
  4763. /**
  4764. * Gets the update flag of the matrix which is an unique number for the matrix.
  4765. * It will be incremented every time the matrix data change.
  4766. * You can use it to speed the comparison between two versions of the same matrix.
  4767. */
  4768. updateFlag: number;
  4769. private readonly _m;
  4770. /**
  4771. * Gets the internal data of the matrix
  4772. */
  4773. get m(): DeepImmutable<Float32Array | Array<number>>;
  4774. /** @hidden */
  4775. _markAsUpdated(): void;
  4776. /** @hidden */
  4777. private _updateIdentityStatus;
  4778. /**
  4779. * Creates an empty matrix (filled with zeros)
  4780. */
  4781. constructor();
  4782. /**
  4783. * Check if the current matrix is identity
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentity(): boolean;
  4787. /**
  4788. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4789. * @returns true is the matrix is the identity matrix
  4790. */
  4791. isIdentityAs3x2(): boolean;
  4792. /**
  4793. * Gets the determinant of the matrix
  4794. * @returns the matrix determinant
  4795. */
  4796. determinant(): number;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array
  4800. */
  4801. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Returns the matrix as a Float32Array or Array<number>
  4804. * @returns the matrix underlying array.
  4805. */
  4806. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4807. /**
  4808. * Inverts the current matrix in place
  4809. * @returns the current inverted matrix
  4810. */
  4811. invert(): Matrix;
  4812. /**
  4813. * Sets all the matrix elements to zero
  4814. * @returns the current matrix
  4815. */
  4816. reset(): Matrix;
  4817. /**
  4818. * Adds the current matrix with a second one
  4819. * @param other defines the matrix to add
  4820. * @returns a new matrix as the addition of the current matrix and the given one
  4821. */
  4822. add(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4825. * @param other defines the matrix to add
  4826. * @param result defines the target matrix
  4827. * @returns the current matrix
  4828. */
  4829. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4830. /**
  4831. * Adds in place the given matrix to the current matrix
  4832. * @param other defines the second operand
  4833. * @returns the current updated matrix
  4834. */
  4835. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4836. /**
  4837. * Sets the given matrix to the current inverted Matrix
  4838. * @param other defines the target matrix
  4839. * @returns the unmodified current matrix
  4840. */
  4841. invertToRef(other: Matrix): Matrix;
  4842. /**
  4843. * add a value at the specified position in the current Matrix
  4844. * @param index the index of the value within the matrix. between 0 and 15.
  4845. * @param value the value to be added
  4846. * @returns the current updated matrix
  4847. */
  4848. addAtIndex(index: number, value: number): Matrix;
  4849. /**
  4850. * mutiply the specified position in the current Matrix by a value
  4851. * @param index the index of the value within the matrix. between 0 and 15.
  4852. * @param value the value to be added
  4853. * @returns the current updated matrix
  4854. */
  4855. multiplyAtIndex(index: number, value: number): Matrix;
  4856. /**
  4857. * Inserts the translation vector (using 3 floats) in the current matrix
  4858. * @param x defines the 1st component of the translation
  4859. * @param y defines the 2nd component of the translation
  4860. * @param z defines the 3rd component of the translation
  4861. * @returns the current updated matrix
  4862. */
  4863. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4864. /**
  4865. * Adds the translation vector (using 3 floats) in the current matrix
  4866. * @param x defines the 1st component of the translation
  4867. * @param y defines the 2nd component of the translation
  4868. * @param z defines the 3rd component of the translation
  4869. * @returns the current updated matrix
  4870. */
  4871. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4872. /**
  4873. * Inserts the translation vector in the current matrix
  4874. * @param vector3 defines the translation to insert
  4875. * @returns the current updated matrix
  4876. */
  4877. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4878. /**
  4879. * Gets the translation value of the current matrix
  4880. * @returns a new Vector3 as the extracted translation from the matrix
  4881. */
  4882. getTranslation(): Vector3;
  4883. /**
  4884. * Fill a Vector3 with the extracted translation from the matrix
  4885. * @param result defines the Vector3 where to store the translation
  4886. * @returns the current matrix
  4887. */
  4888. getTranslationToRef(result: Vector3): Matrix;
  4889. /**
  4890. * Remove rotation and scaling part from the matrix
  4891. * @returns the updated matrix
  4892. */
  4893. removeRotationAndScaling(): Matrix;
  4894. /**
  4895. * Multiply two matrices
  4896. * @param other defines the second operand
  4897. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4898. */
  4899. multiply(other: DeepImmutable<Matrix>): Matrix;
  4900. /**
  4901. * Copy the current matrix from the given one
  4902. * @param other defines the source matrix
  4903. * @returns the current updated matrix
  4904. */
  4905. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4906. /**
  4907. * Populates the given array from the starting index with the current matrix values
  4908. * @param array defines the target array
  4909. * @param offset defines the offset in the target array where to start storing values
  4910. * @returns the current matrix
  4911. */
  4912. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4913. /**
  4914. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4915. * @param other defines the second operand
  4916. * @param result defines the matrix where to store the multiplication
  4917. * @returns the current matrix
  4918. */
  4919. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4920. /**
  4921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4922. * @param other defines the second operand
  4923. * @param result defines the array where to store the multiplication
  4924. * @param offset defines the offset in the target array where to start storing values
  4925. * @returns the current matrix
  4926. */
  4927. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4928. /**
  4929. * Check equality between this matrix and a second one
  4930. * @param value defines the second matrix to compare
  4931. * @returns true is the current matrix and the given one values are strictly equal
  4932. */
  4933. equals(value: DeepImmutable<Matrix>): boolean;
  4934. /**
  4935. * Clone the current matrix
  4936. * @returns a new matrix from the current matrix
  4937. */
  4938. clone(): Matrix;
  4939. /**
  4940. * Returns the name of the current matrix class
  4941. * @returns the string "Matrix"
  4942. */
  4943. getClassName(): string;
  4944. /**
  4945. * Gets the hash code of the current matrix
  4946. * @returns the hash code
  4947. */
  4948. getHashCode(): number;
  4949. /**
  4950. * Decomposes the current Matrix into a translation, rotation and scaling components
  4951. * @param scale defines the scale vector3 given as a reference to update
  4952. * @param rotation defines the rotation quaternion given as a reference to update
  4953. * @param translation defines the translation vector3 given as a reference to update
  4954. * @returns true if operation was successful
  4955. */
  4956. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4957. /**
  4958. * Gets specific row of the matrix
  4959. * @param index defines the number of the row to get
  4960. * @returns the index-th row of the current matrix as a new Vector4
  4961. */
  4962. getRow(index: number): Nullable<Vector4>;
  4963. /**
  4964. * Sets the index-th row of the current matrix to the vector4 values
  4965. * @param index defines the number of the row to set
  4966. * @param row defines the target vector4
  4967. * @returns the updated current matrix
  4968. */
  4969. setRow(index: number, row: Vector4): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix
  4972. * @returns the new transposed matrix
  4973. */
  4974. transpose(): Matrix;
  4975. /**
  4976. * Compute the transpose of the matrix and store it in a given matrix
  4977. * @param result defines the target matrix
  4978. * @returns the current matrix
  4979. */
  4980. transposeToRef(result: Matrix): Matrix;
  4981. /**
  4982. * Sets the index-th row of the current matrix with the given 4 x float values
  4983. * @param index defines the row index
  4984. * @param x defines the x component to set
  4985. * @param y defines the y component to set
  4986. * @param z defines the z component to set
  4987. * @param w defines the w component to set
  4988. * @returns the updated current matrix
  4989. */
  4990. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4991. /**
  4992. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4993. * @param scale defines the scale factor
  4994. * @returns a new matrix
  4995. */
  4996. scale(scale: number): Matrix;
  4997. /**
  4998. * Scale the current matrix values by a factor to a given result matrix
  4999. * @param scale defines the scale factor
  5000. * @param result defines the matrix to store the result
  5001. * @returns the current matrix
  5002. */
  5003. scaleToRef(scale: number, result: Matrix): Matrix;
  5004. /**
  5005. * Scale the current matrix values by a factor and add the result to a given matrix
  5006. * @param scale defines the scale factor
  5007. * @param result defines the Matrix to store the result
  5008. * @returns the current matrix
  5009. */
  5010. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5011. /**
  5012. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5013. * @param ref matrix to store the result
  5014. */
  5015. toNormalMatrix(ref: Matrix): void;
  5016. /**
  5017. * Gets only rotation part of the current matrix
  5018. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5019. */
  5020. getRotationMatrix(): Matrix;
  5021. /**
  5022. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5023. * @param result defines the target matrix to store data to
  5024. * @returns the current matrix
  5025. */
  5026. getRotationMatrixToRef(result: Matrix): Matrix;
  5027. /**
  5028. * Toggles model matrix from being right handed to left handed in place and vice versa
  5029. */
  5030. toggleModelMatrixHandInPlace(): void;
  5031. /**
  5032. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5033. */
  5034. toggleProjectionMatrixHandInPlace(): void;
  5035. /**
  5036. * Creates a matrix from an array
  5037. * @param array defines the source array
  5038. * @param offset defines an offset in the source array
  5039. * @returns a new Matrix set from the starting index of the given array
  5040. */
  5041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5042. /**
  5043. * Copy the content of an array into a given matrix
  5044. * @param array defines the source array
  5045. * @param offset defines an offset in the source array
  5046. * @param result defines the target matrix
  5047. */
  5048. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5049. /**
  5050. * Stores an array into a matrix after having multiplied each component by a given factor
  5051. * @param array defines the source array
  5052. * @param offset defines the offset in the source array
  5053. * @param scale defines the scaling factor
  5054. * @param result defines the target matrix
  5055. */
  5056. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5057. /**
  5058. * Gets an identity matrix that must not be updated
  5059. */
  5060. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5061. /**
  5062. * Stores a list of values (16) inside a given matrix
  5063. * @param initialM11 defines 1st value of 1st row
  5064. * @param initialM12 defines 2nd value of 1st row
  5065. * @param initialM13 defines 3rd value of 1st row
  5066. * @param initialM14 defines 4th value of 1st row
  5067. * @param initialM21 defines 1st value of 2nd row
  5068. * @param initialM22 defines 2nd value of 2nd row
  5069. * @param initialM23 defines 3rd value of 2nd row
  5070. * @param initialM24 defines 4th value of 2nd row
  5071. * @param initialM31 defines 1st value of 3rd row
  5072. * @param initialM32 defines 2nd value of 3rd row
  5073. * @param initialM33 defines 3rd value of 3rd row
  5074. * @param initialM34 defines 4th value of 3rd row
  5075. * @param initialM41 defines 1st value of 4th row
  5076. * @param initialM42 defines 2nd value of 4th row
  5077. * @param initialM43 defines 3rd value of 4th row
  5078. * @param initialM44 defines 4th value of 4th row
  5079. * @param result defines the target matrix
  5080. */
  5081. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5082. /**
  5083. * Creates new matrix from a list of values (16)
  5084. * @param initialM11 defines 1st value of 1st row
  5085. * @param initialM12 defines 2nd value of 1st row
  5086. * @param initialM13 defines 3rd value of 1st row
  5087. * @param initialM14 defines 4th value of 1st row
  5088. * @param initialM21 defines 1st value of 2nd row
  5089. * @param initialM22 defines 2nd value of 2nd row
  5090. * @param initialM23 defines 3rd value of 2nd row
  5091. * @param initialM24 defines 4th value of 2nd row
  5092. * @param initialM31 defines 1st value of 3rd row
  5093. * @param initialM32 defines 2nd value of 3rd row
  5094. * @param initialM33 defines 3rd value of 3rd row
  5095. * @param initialM34 defines 4th value of 3rd row
  5096. * @param initialM41 defines 1st value of 4th row
  5097. * @param initialM42 defines 2nd value of 4th row
  5098. * @param initialM43 defines 3rd value of 4th row
  5099. * @param initialM44 defines 4th value of 4th row
  5100. * @returns the new matrix
  5101. */
  5102. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5103. /**
  5104. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5105. * @param scale defines the scale vector3
  5106. * @param rotation defines the rotation quaternion
  5107. * @param translation defines the translation vector3
  5108. * @returns a new matrix
  5109. */
  5110. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5111. /**
  5112. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5113. * @param scale defines the scale vector3
  5114. * @param rotation defines the rotation quaternion
  5115. * @param translation defines the translation vector3
  5116. * @param result defines the target matrix
  5117. */
  5118. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5119. /**
  5120. * Creates a new identity matrix
  5121. * @returns a new identity matrix
  5122. */
  5123. static Identity(): Matrix;
  5124. /**
  5125. * Creates a new identity matrix and stores the result in a given matrix
  5126. * @param result defines the target matrix
  5127. */
  5128. static IdentityToRef(result: Matrix): void;
  5129. /**
  5130. * Creates a new zero matrix
  5131. * @returns a new zero matrix
  5132. */
  5133. static Zero(): Matrix;
  5134. /**
  5135. * Creates a new rotation matrix for "angle" radians around the X axis
  5136. * @param angle defines the angle (in radians) to use
  5137. * @return the new matrix
  5138. */
  5139. static RotationX(angle: number): Matrix;
  5140. /**
  5141. * Creates a new matrix as the invert of a given matrix
  5142. * @param source defines the source matrix
  5143. * @returns the new matrix
  5144. */
  5145. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5146. /**
  5147. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5148. * @param angle defines the angle (in radians) to use
  5149. * @param result defines the target matrix
  5150. */
  5151. static RotationXToRef(angle: number, result: Matrix): void;
  5152. /**
  5153. * Creates a new rotation matrix for "angle" radians around the Y axis
  5154. * @param angle defines the angle (in radians) to use
  5155. * @return the new matrix
  5156. */
  5157. static RotationY(angle: number): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5160. * @param angle defines the angle (in radians) to use
  5161. * @param result defines the target matrix
  5162. */
  5163. static RotationYToRef(angle: number, result: Matrix): void;
  5164. /**
  5165. * Creates a new rotation matrix for "angle" radians around the Z axis
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationZ(angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5172. * @param angle defines the angle (in radians) to use
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationZToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the given axis
  5178. * @param axis defines the axis to use
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5183. /**
  5184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5185. * @param axis defines the axis to use
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5190. /**
  5191. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5192. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5193. * @param from defines the vector to align
  5194. * @param to defines the vector to align to
  5195. * @param result defines the target matrix
  5196. */
  5197. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5198. /**
  5199. * Creates a rotation matrix
  5200. * @param yaw defines the yaw angle in radians (Y axis)
  5201. * @param pitch defines the pitch angle in radians (X axis)
  5202. * @param roll defines the roll angle in radians (Z axis)
  5203. * @returns the new rotation matrix
  5204. */
  5205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5206. /**
  5207. * Creates a rotation matrix and stores it in a given matrix
  5208. * @param yaw defines the yaw angle in radians (Y axis)
  5209. * @param pitch defines the pitch angle in radians (X axis)
  5210. * @param roll defines the roll angle in radians (Z axis)
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5214. /**
  5215. * Creates a scaling matrix
  5216. * @param x defines the scale factor on X axis
  5217. * @param y defines the scale factor on Y axis
  5218. * @param z defines the scale factor on Z axis
  5219. * @returns the new matrix
  5220. */
  5221. static Scaling(x: number, y: number, z: number): Matrix;
  5222. /**
  5223. * Creates a scaling matrix and stores it in a given matrix
  5224. * @param x defines the scale factor on X axis
  5225. * @param y defines the scale factor on Y axis
  5226. * @param z defines the scale factor on Z axis
  5227. * @param result defines the target matrix
  5228. */
  5229. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5230. /**
  5231. * Creates a translation matrix
  5232. * @param x defines the translation on X axis
  5233. * @param y defines the translation on Y axis
  5234. * @param z defines the translationon Z axis
  5235. * @returns the new matrix
  5236. */
  5237. static Translation(x: number, y: number, z: number): Matrix;
  5238. /**
  5239. * Creates a translation matrix and stores it in a given matrix
  5240. * @param x defines the translation on X axis
  5241. * @param y defines the translation on Y axis
  5242. * @param z defines the translationon Z axis
  5243. * @param result defines the target matrix
  5244. */
  5245. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5246. /**
  5247. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5248. * @param startValue defines the start value
  5249. * @param endValue defines the end value
  5250. * @param gradient defines the gradient factor
  5251. * @returns the new matrix
  5252. */
  5253. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5254. /**
  5255. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5256. * @param startValue defines the start value
  5257. * @param endValue defines the end value
  5258. * @param gradient defines the gradient factor
  5259. * @param result defines the Matrix object where to store data
  5260. */
  5261. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Builds a new matrix whose values are computed by:
  5264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5267. * @param startValue defines the first matrix
  5268. * @param endValue defines the second matrix
  5269. * @param gradient defines the gradient between the two matrices
  5270. * @returns the new matrix
  5271. */
  5272. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5273. /**
  5274. * Update a matrix to values which are computed by:
  5275. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5276. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5277. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5278. * @param startValue defines the first matrix
  5279. * @param endValue defines the second matrix
  5280. * @param gradient defines the gradient between the two matrices
  5281. * @param result defines the target matrix
  5282. */
  5283. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5284. /**
  5285. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5286. * This function works in left handed mode
  5287. * @param eye defines the final position of the entity
  5288. * @param target defines where the entity should look at
  5289. * @param up defines the up vector for the entity
  5290. * @returns the new matrix
  5291. */
  5292. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5293. /**
  5294. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5295. * This function works in left handed mode
  5296. * @param eye defines the final position of the entity
  5297. * @param target defines where the entity should look at
  5298. * @param up defines the up vector for the entity
  5299. * @param result defines the target matrix
  5300. */
  5301. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5302. /**
  5303. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5304. * This function works in right handed mode
  5305. * @param eye defines the final position of the entity
  5306. * @param target defines where the entity should look at
  5307. * @param up defines the up vector for the entity
  5308. * @returns the new matrix
  5309. */
  5310. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5311. /**
  5312. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5313. * This function works in right handed mode
  5314. * @param eye defines the final position of the entity
  5315. * @param target defines where the entity should look at
  5316. * @param up defines the up vector for the entity
  5317. * @param result defines the target matrix
  5318. */
  5319. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5320. /**
  5321. * Create a left-handed orthographic projection matrix
  5322. * @param width defines the viewport width
  5323. * @param height defines the viewport height
  5324. * @param znear defines the near clip plane
  5325. * @param zfar defines the far clip plane
  5326. * @returns a new matrix as a left-handed orthographic projection matrix
  5327. */
  5328. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5329. /**
  5330. * Store a left-handed orthographic projection to a given matrix
  5331. * @param width defines the viewport width
  5332. * @param height defines the viewport height
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Create a left-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a left-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a left-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a right-handed orthographic projection matrix
  5362. * @param left defines the viewport left coordinate
  5363. * @param right defines the viewport right coordinate
  5364. * @param bottom defines the viewport bottom coordinate
  5365. * @param top defines the viewport top coordinate
  5366. * @param znear defines the near clip plane
  5367. * @param zfar defines the far clip plane
  5368. * @returns a new matrix as a right-handed orthographic projection matrix
  5369. */
  5370. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5371. /**
  5372. * Stores a right-handed orthographic projection into a given matrix
  5373. * @param left defines the viewport left coordinate
  5374. * @param right defines the viewport right coordinate
  5375. * @param bottom defines the viewport bottom coordinate
  5376. * @param top defines the viewport top coordinate
  5377. * @param znear defines the near clip plane
  5378. * @param zfar defines the far clip plane
  5379. * @param result defines the target matrix
  5380. */
  5381. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5382. /**
  5383. * Creates a left-handed perspective projection matrix
  5384. * @param width defines the viewport width
  5385. * @param height defines the viewport height
  5386. * @param znear defines the near clip plane
  5387. * @param zfar defines the far clip plane
  5388. * @returns a new matrix as a left-handed perspective projection matrix
  5389. */
  5390. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5391. /**
  5392. * Creates a left-handed perspective projection matrix
  5393. * @param fov defines the horizontal field of view
  5394. * @param aspect defines the aspect ratio
  5395. * @param znear defines the near clip plane
  5396. * @param zfar defines the far clip plane
  5397. * @returns a new matrix as a left-handed perspective projection matrix
  5398. */
  5399. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5400. /**
  5401. * Stores a left-handed perspective projection into a given matrix
  5402. * @param fov defines the horizontal field of view
  5403. * @param aspect defines the aspect ratio
  5404. * @param znear defines the near clip plane
  5405. * @param zfar defines the far clip plane
  5406. * @param result defines the target matrix
  5407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5408. */
  5409. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5410. /**
  5411. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5412. * @param fov defines the horizontal field of view
  5413. * @param aspect defines the aspect ratio
  5414. * @param znear defines the near clip plane
  5415. * @param zfar not used as infinity is used as far clip
  5416. * @param result defines the target matrix
  5417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5418. */
  5419. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5420. /**
  5421. * Creates a right-handed perspective projection matrix
  5422. * @param fov defines the horizontal field of view
  5423. * @param aspect defines the aspect ratio
  5424. * @param znear defines the near clip plane
  5425. * @param zfar defines the far clip plane
  5426. * @returns a new matrix as a right-handed perspective projection matrix
  5427. */
  5428. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5429. /**
  5430. * Stores a right-handed perspective projection into a given matrix
  5431. * @param fov defines the horizontal field of view
  5432. * @param aspect defines the aspect ratio
  5433. * @param znear defines the near clip plane
  5434. * @param zfar defines the far clip plane
  5435. * @param result defines the target matrix
  5436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5437. */
  5438. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5439. /**
  5440. * Stores a right-handed perspective projection into a given matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar not used as infinity is used as far clip
  5445. * @param result defines the target matrix
  5446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5447. */
  5448. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5449. /**
  5450. * Stores a perspective projection for WebVR info a given matrix
  5451. * @param fov defines the field of view
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5456. */
  5457. static PerspectiveFovWebVRToRef(fov: {
  5458. upDegrees: number;
  5459. downDegrees: number;
  5460. leftDegrees: number;
  5461. rightDegrees: number;
  5462. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5463. /**
  5464. * Computes a complete transformation matrix
  5465. * @param viewport defines the viewport to use
  5466. * @param world defines the world matrix
  5467. * @param view defines the view matrix
  5468. * @param projection defines the projection matrix
  5469. * @param zmin defines the near clip plane
  5470. * @param zmax defines the far clip plane
  5471. * @returns the transformation matrix
  5472. */
  5473. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5474. /**
  5475. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5476. * @param matrix defines the matrix to use
  5477. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5478. */
  5479. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5480. /**
  5481. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5482. * @param matrix defines the matrix to use
  5483. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5484. */
  5485. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5486. /**
  5487. * Compute the transpose of a given matrix
  5488. * @param matrix defines the matrix to transpose
  5489. * @returns the new matrix
  5490. */
  5491. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5492. /**
  5493. * Compute the transpose of a matrix and store it in a target matrix
  5494. * @param matrix defines the matrix to transpose
  5495. * @param result defines the target matrix
  5496. */
  5497. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5498. /**
  5499. * Computes a reflection matrix from a plane
  5500. * @param plane defines the reflection plane
  5501. * @returns a new matrix
  5502. */
  5503. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5504. /**
  5505. * Computes a reflection matrix from a plane
  5506. * @param plane defines the reflection plane
  5507. * @param result defines the target matrix
  5508. */
  5509. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5510. /**
  5511. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5512. * @param xaxis defines the value of the 1st axis
  5513. * @param yaxis defines the value of the 2nd axis
  5514. * @param zaxis defines the value of the 3rd axis
  5515. * @param result defines the target matrix
  5516. */
  5517. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5518. /**
  5519. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5520. * @param quat defines the quaternion to use
  5521. * @param result defines the target matrix
  5522. */
  5523. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5524. }
  5525. /**
  5526. * @hidden
  5527. */
  5528. export class TmpVectors {
  5529. static Vector2: Vector2[];
  5530. static Vector3: Vector3[];
  5531. static Vector4: Vector4[];
  5532. static Quaternion: Quaternion[];
  5533. static Matrix: Matrix[];
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Defines potential orientation for back face culling
  5539. */
  5540. export enum Orientation {
  5541. /**
  5542. * Clockwise
  5543. */
  5544. CW = 0,
  5545. /** Counter clockwise */
  5546. CCW = 1
  5547. }
  5548. /** Class used to represent a Bezier curve */
  5549. export class BezierCurve {
  5550. /**
  5551. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5552. * @param t defines the time
  5553. * @param x1 defines the left coordinate on X axis
  5554. * @param y1 defines the left coordinate on Y axis
  5555. * @param x2 defines the right coordinate on X axis
  5556. * @param y2 defines the right coordinate on Y axis
  5557. * @returns the interpolated value
  5558. */
  5559. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5560. }
  5561. /**
  5562. * Defines angle representation
  5563. */
  5564. export class Angle {
  5565. private _radians;
  5566. /**
  5567. * Creates an Angle object of "radians" radians (float).
  5568. * @param radians the angle in radians
  5569. */
  5570. constructor(radians: number);
  5571. /**
  5572. * Get value in degrees
  5573. * @returns the Angle value in degrees (float)
  5574. */
  5575. degrees(): number;
  5576. /**
  5577. * Get value in radians
  5578. * @returns the Angle value in radians (float)
  5579. */
  5580. radians(): number;
  5581. /**
  5582. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5583. * @param a defines first point as the origin
  5584. * @param b defines point
  5585. * @returns a new Angle
  5586. */
  5587. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5588. /**
  5589. * Gets a new Angle object from the given float in radians
  5590. * @param radians defines the angle value in radians
  5591. * @returns a new Angle
  5592. */
  5593. static FromRadians(radians: number): Angle;
  5594. /**
  5595. * Gets a new Angle object from the given float in degrees
  5596. * @param degrees defines the angle value in degrees
  5597. * @returns a new Angle
  5598. */
  5599. static FromDegrees(degrees: number): Angle;
  5600. }
  5601. /**
  5602. * This represents an arc in a 2d space.
  5603. */
  5604. export class Arc2 {
  5605. /** Defines the start point of the arc */
  5606. startPoint: Vector2;
  5607. /** Defines the mid point of the arc */
  5608. midPoint: Vector2;
  5609. /** Defines the end point of the arc */
  5610. endPoint: Vector2;
  5611. /**
  5612. * Defines the center point of the arc.
  5613. */
  5614. centerPoint: Vector2;
  5615. /**
  5616. * Defines the radius of the arc.
  5617. */
  5618. radius: number;
  5619. /**
  5620. * Defines the angle of the arc (from mid point to end point).
  5621. */
  5622. angle: Angle;
  5623. /**
  5624. * Defines the start angle of the arc (from start point to middle point).
  5625. */
  5626. startAngle: Angle;
  5627. /**
  5628. * Defines the orientation of the arc (clock wise/counter clock wise).
  5629. */
  5630. orientation: Orientation;
  5631. /**
  5632. * Creates an Arc object from the three given points : start, middle and end.
  5633. * @param startPoint Defines the start point of the arc
  5634. * @param midPoint Defines the midlle point of the arc
  5635. * @param endPoint Defines the end point of the arc
  5636. */
  5637. constructor(
  5638. /** Defines the start point of the arc */
  5639. startPoint: Vector2,
  5640. /** Defines the mid point of the arc */
  5641. midPoint: Vector2,
  5642. /** Defines the end point of the arc */
  5643. endPoint: Vector2);
  5644. }
  5645. /**
  5646. * Represents a 2D path made up of multiple 2D points
  5647. */
  5648. export class Path2 {
  5649. private _points;
  5650. private _length;
  5651. /**
  5652. * If the path start and end point are the same
  5653. */
  5654. closed: boolean;
  5655. /**
  5656. * Creates a Path2 object from the starting 2D coordinates x and y.
  5657. * @param x the starting points x value
  5658. * @param y the starting points y value
  5659. */
  5660. constructor(x: number, y: number);
  5661. /**
  5662. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5663. * @param x the added points x value
  5664. * @param y the added points y value
  5665. * @returns the updated Path2.
  5666. */
  5667. addLineTo(x: number, y: number): Path2;
  5668. /**
  5669. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5670. * @param midX middle point x value
  5671. * @param midY middle point y value
  5672. * @param endX end point x value
  5673. * @param endY end point y value
  5674. * @param numberOfSegments (default: 36)
  5675. * @returns the updated Path2.
  5676. */
  5677. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5678. /**
  5679. * Closes the Path2.
  5680. * @returns the Path2.
  5681. */
  5682. close(): Path2;
  5683. /**
  5684. * Gets the sum of the distance between each sequential point in the path
  5685. * @returns the Path2 total length (float).
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Gets the points which construct the path
  5690. * @returns the Path2 internal array of points.
  5691. */
  5692. getPoints(): Vector2[];
  5693. /**
  5694. * Retreives the point at the distance aways from the starting point
  5695. * @param normalizedLengthPosition the length along the path to retreive the point from
  5696. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5697. */
  5698. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5699. /**
  5700. * Creates a new path starting from an x and y position
  5701. * @param x starting x value
  5702. * @param y starting y value
  5703. * @returns a new Path2 starting at the coordinates (x, y).
  5704. */
  5705. static StartingAt(x: number, y: number): Path2;
  5706. }
  5707. /**
  5708. * Represents a 3D path made up of multiple 3D points
  5709. */
  5710. export class Path3D {
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[];
  5715. private _curve;
  5716. private _distances;
  5717. private _tangents;
  5718. private _normals;
  5719. private _binormals;
  5720. private _raw;
  5721. private _alignTangentsWithPath;
  5722. private readonly _pointAtData;
  5723. /**
  5724. * new Path3D(path, normal, raw)
  5725. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5726. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5727. * @param path an array of Vector3, the curve axis of the Path3D
  5728. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5729. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5730. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5731. */
  5732. constructor(
  5733. /**
  5734. * an array of Vector3, the curve axis of the Path3D
  5735. */
  5736. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getCurve(): Vector3[];
  5742. /**
  5743. * Returns the Path3D array of successive Vector3 designing its curve.
  5744. * @returns the Path3D array of successive Vector3 designing its curve.
  5745. */
  5746. getPoints(): Vector3[];
  5747. /**
  5748. * @returns the computed length (float) of the path.
  5749. */
  5750. length(): number;
  5751. /**
  5752. * Returns an array populated with tangent vectors on each Path3D curve point.
  5753. * @returns an array populated with tangent vectors on each Path3D curve point.
  5754. */
  5755. getTangents(): Vector3[];
  5756. /**
  5757. * Returns an array populated with normal vectors on each Path3D curve point.
  5758. * @returns an array populated with normal vectors on each Path3D curve point.
  5759. */
  5760. getNormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with binormal vectors on each Path3D curve point.
  5763. * @returns an array populated with binormal vectors on each Path3D curve point.
  5764. */
  5765. getBinormals(): Vector3[];
  5766. /**
  5767. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5768. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5769. */
  5770. getDistances(): number[];
  5771. /**
  5772. * Returns an interpolated point along this path
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @returns a new Vector3 as the point
  5775. */
  5776. getPointAt(position: number): Vector3;
  5777. /**
  5778. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5779. * @param position the position of the point along this path, from 0.0 to 1.0
  5780. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5781. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5782. */
  5783. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5784. /**
  5785. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5786. * @param position the position of the point along this path, from 0.0 to 1.0
  5787. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5788. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5789. */
  5790. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5791. /**
  5792. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5793. * @param position the position of the point along this path, from 0.0 to 1.0
  5794. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5795. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5796. */
  5797. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5798. /**
  5799. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5800. * @param position the position of the point along this path, from 0.0 to 1.0
  5801. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5802. */
  5803. getDistanceAt(position: number): number;
  5804. /**
  5805. * Returns the array index of the previous point of an interpolated point along this path
  5806. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5807. * @returns the array index
  5808. */
  5809. getPreviousPointIndexAt(position: number): number;
  5810. /**
  5811. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5812. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5813. * @returns the sub position
  5814. */
  5815. getSubPositionAt(position: number): number;
  5816. /**
  5817. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5818. * @param target the vector of which to get the closest position to
  5819. * @returns the position of the closest virtual point on this path to the target vector
  5820. */
  5821. getClosestPositionTo(target: Vector3): number;
  5822. /**
  5823. * Returns a sub path (slice) of this path
  5824. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5825. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5826. * @returns a sub path (slice) of this path
  5827. */
  5828. slice(start?: number, end?: number): Path3D;
  5829. /**
  5830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5831. * @param path path which all values are copied into the curves points
  5832. * @param firstNormal which should be projected onto the curve
  5833. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5834. * @returns the same object updated.
  5835. */
  5836. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5837. private _compute;
  5838. private _getFirstNonNullVector;
  5839. private _getLastNonNullVector;
  5840. private _normalVector;
  5841. /**
  5842. * Updates the point at data for an interpolated point along this curve
  5843. * @param position the position of the point along this curve, from 0.0 to 1.0
  5844. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5845. * @returns the (updated) point at data
  5846. */
  5847. private _updatePointAtData;
  5848. /**
  5849. * Updates the point at data from the specified parameters
  5850. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5851. * @param point the interpolated point
  5852. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5853. */
  5854. private _setPointAtData;
  5855. /**
  5856. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5857. */
  5858. private _updateInterpolationMatrix;
  5859. }
  5860. /**
  5861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5862. * A Curve3 is designed from a series of successive Vector3.
  5863. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5864. */
  5865. export class Curve3 {
  5866. private _points;
  5867. private _length;
  5868. /**
  5869. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5871. * @param v1 (Vector3) the control point
  5872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5873. * @param nbPoints (integer) the wanted number of points in the curve
  5874. * @returns the created Curve3
  5875. */
  5876. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5877. /**
  5878. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5879. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5880. * @param v1 (Vector3) the first control point
  5881. * @param v2 (Vector3) the second control point
  5882. * @param v3 (Vector3) the end point of the Cubic Bezier
  5883. * @param nbPoints (integer) the wanted number of points in the curve
  5884. * @returns the created Curve3
  5885. */
  5886. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5887. /**
  5888. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5889. * @param p1 (Vector3) the origin point of the Hermite Spline
  5890. * @param t1 (Vector3) the tangent vector at the origin point
  5891. * @param p2 (Vector3) the end point of the Hermite Spline
  5892. * @param t2 (Vector3) the tangent vector at the end point
  5893. * @param nbPoints (integer) the wanted number of points in the curve
  5894. * @returns the created Curve3
  5895. */
  5896. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5897. /**
  5898. * Returns a Curve3 object along a CatmullRom Spline curve :
  5899. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5900. * @param nbPoints (integer) the wanted number of points between each curve control points
  5901. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5909. * @param points points which make up the curve
  5910. */
  5911. constructor(points: Vector3[]);
  5912. /**
  5913. * @returns the Curve3 stored array of successive Vector3
  5914. */
  5915. getPoints(): Vector3[];
  5916. /**
  5917. * @returns the computed length (float) of the curve.
  5918. */
  5919. length(): number;
  5920. /**
  5921. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5922. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5923. * curveA and curveB keep unchanged.
  5924. * @param curve the curve to continue from this curve
  5925. * @returns the newly constructed curve
  5926. */
  5927. continue(curve: DeepImmutable<Curve3>): Curve3;
  5928. private _computeLength;
  5929. }
  5930. }
  5931. declare module BABYLON {
  5932. /**
  5933. * This represents the main contract an easing function should follow.
  5934. * Easing functions are used throughout the animation system.
  5935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5936. */
  5937. export interface IEasingFunction {
  5938. /**
  5939. * Given an input gradient between 0 and 1, this returns the corresponding value
  5940. * of the easing function.
  5941. * The link below provides some of the most common examples of easing functions.
  5942. * @see https://easings.net/
  5943. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5944. * @returns the corresponding value on the curve defined by the easing function
  5945. */
  5946. ease(gradient: number): number;
  5947. }
  5948. /**
  5949. * Base class used for every default easing function.
  5950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5951. */
  5952. export class EasingFunction implements IEasingFunction {
  5953. /**
  5954. * Interpolation follows the mathematical formula associated with the easing function.
  5955. */
  5956. static readonly EASINGMODE_EASEIN: number;
  5957. /**
  5958. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5959. */
  5960. static readonly EASINGMODE_EASEOUT: number;
  5961. /**
  5962. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5963. */
  5964. static readonly EASINGMODE_EASEINOUT: number;
  5965. private _easingMode;
  5966. /**
  5967. * Sets the easing mode of the current function.
  5968. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5969. */
  5970. setEasingMode(easingMode: number): void;
  5971. /**
  5972. * Gets the current easing mode.
  5973. * @returns the easing mode
  5974. */
  5975. getEasingMode(): number;
  5976. /**
  5977. * @hidden
  5978. */
  5979. easeInCore(gradient: number): number;
  5980. /**
  5981. * Given an input gradient between 0 and 1, this returns the corresponding value
  5982. * of the easing function.
  5983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5984. * @returns the corresponding value on the curve defined by the easing function
  5985. */
  5986. ease(gradient: number): number;
  5987. }
  5988. /**
  5989. * Easing function with a circle shape (see link below).
  5990. * @see https://easings.net/#easeInCirc
  5991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5992. */
  5993. export class CircleEase extends EasingFunction implements IEasingFunction {
  5994. /** @hidden */
  5995. easeInCore(gradient: number): number;
  5996. }
  5997. /**
  5998. * Easing function with a ease back shape (see link below).
  5999. * @see https://easings.net/#easeInBack
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class BackEase extends EasingFunction implements IEasingFunction {
  6003. /** Defines the amplitude of the function */
  6004. amplitude: number;
  6005. /**
  6006. * Instantiates a back ease easing
  6007. * @see https://easings.net/#easeInBack
  6008. * @param amplitude Defines the amplitude of the function
  6009. */
  6010. constructor(
  6011. /** Defines the amplitude of the function */
  6012. amplitude?: number);
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a bouncing shape (see link below).
  6018. * @see https://easings.net/#easeInBounce
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class BounceEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of bounces */
  6023. bounces: number;
  6024. /** Defines the amplitude of the bounce */
  6025. bounciness: number;
  6026. /**
  6027. * Instantiates a bounce easing
  6028. * @see https://easings.net/#easeInBounce
  6029. * @param bounces Defines the number of bounces
  6030. * @param bounciness Defines the amplitude of the bounce
  6031. */
  6032. constructor(
  6033. /** Defines the number of bounces */
  6034. bounces?: number,
  6035. /** Defines the amplitude of the bounce */
  6036. bounciness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a power of 3 shape (see link below).
  6042. * @see https://easings.net/#easeInCubic
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class CubicEase extends EasingFunction implements IEasingFunction {
  6046. /** @hidden */
  6047. easeInCore(gradient: number): number;
  6048. }
  6049. /**
  6050. * Easing function with an elastic shape (see link below).
  6051. * @see https://easings.net/#easeInElastic
  6052. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6053. */
  6054. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6055. /** Defines the number of oscillations*/
  6056. oscillations: number;
  6057. /** Defines the amplitude of the oscillations*/
  6058. springiness: number;
  6059. /**
  6060. * Instantiates an elastic easing function
  6061. * @see https://easings.net/#easeInElastic
  6062. * @param oscillations Defines the number of oscillations
  6063. * @param springiness Defines the amplitude of the oscillations
  6064. */
  6065. constructor(
  6066. /** Defines the number of oscillations*/
  6067. oscillations?: number,
  6068. /** Defines the amplitude of the oscillations*/
  6069. springiness?: number);
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an exponential shape (see link below).
  6075. * @see https://easings.net/#easeInExpo
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the exponent of the function */
  6080. exponent: number;
  6081. /**
  6082. * Instantiates an exponential easing function
  6083. * @see https://easings.net/#easeInExpo
  6084. * @param exponent Defines the exponent of the function
  6085. */
  6086. constructor(
  6087. /** Defines the exponent of the function */
  6088. exponent?: number);
  6089. /** @hidden */
  6090. easeInCore(gradient: number): number;
  6091. }
  6092. /**
  6093. * Easing function with a power shape (see link below).
  6094. * @see https://easings.net/#easeInQuad
  6095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6096. */
  6097. export class PowerEase extends EasingFunction implements IEasingFunction {
  6098. /** Defines the power of the function */
  6099. power: number;
  6100. /**
  6101. * Instantiates an power base easing function
  6102. * @see https://easings.net/#easeInQuad
  6103. * @param power Defines the power of the function
  6104. */
  6105. constructor(
  6106. /** Defines the power of the function */
  6107. power?: number);
  6108. /** @hidden */
  6109. easeInCore(gradient: number): number;
  6110. }
  6111. /**
  6112. * Easing function with a power of 2 shape (see link below).
  6113. * @see https://easings.net/#easeInQuad
  6114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power of 4 shape (see link below).
  6122. * @see https://easings.net/#easeInQuart
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power of 5 shape (see link below).
  6131. * @see https://easings.net/#easeInQuint
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6135. /** @hidden */
  6136. easeInCore(gradient: number): number;
  6137. }
  6138. /**
  6139. * Easing function with a sin shape (see link below).
  6140. * @see https://easings.net/#easeInSine
  6141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6142. */
  6143. export class SineEase extends EasingFunction implements IEasingFunction {
  6144. /** @hidden */
  6145. easeInCore(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a bezier shape (see link below).
  6149. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6153. /** Defines the x component of the start tangent in the bezier curve */
  6154. x1: number;
  6155. /** Defines the y component of the start tangent in the bezier curve */
  6156. y1: number;
  6157. /** Defines the x component of the end tangent in the bezier curve */
  6158. x2: number;
  6159. /** Defines the y component of the end tangent in the bezier curve */
  6160. y2: number;
  6161. /**
  6162. * Instantiates a bezier function
  6163. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6164. * @param x1 Defines the x component of the start tangent in the bezier curve
  6165. * @param y1 Defines the y component of the start tangent in the bezier curve
  6166. * @param x2 Defines the x component of the end tangent in the bezier curve
  6167. * @param y2 Defines the y component of the end tangent in the bezier curve
  6168. */
  6169. constructor(
  6170. /** Defines the x component of the start tangent in the bezier curve */
  6171. x1?: number,
  6172. /** Defines the y component of the start tangent in the bezier curve */
  6173. y1?: number,
  6174. /** Defines the x component of the end tangent in the bezier curve */
  6175. x2?: number,
  6176. /** Defines the y component of the end tangent in the bezier curve */
  6177. y2?: number);
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * Class used to hold a RGB color
  6185. */
  6186. export class Color3 {
  6187. /**
  6188. * Defines the red component (between 0 and 1, default is 0)
  6189. */
  6190. r: number;
  6191. /**
  6192. * Defines the green component (between 0 and 1, default is 0)
  6193. */
  6194. g: number;
  6195. /**
  6196. * Defines the blue component (between 0 and 1, default is 0)
  6197. */
  6198. b: number;
  6199. /**
  6200. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6201. * @param r defines the red component (between 0 and 1, default is 0)
  6202. * @param g defines the green component (between 0 and 1, default is 0)
  6203. * @param b defines the blue component (between 0 and 1, default is 0)
  6204. */
  6205. constructor(
  6206. /**
  6207. * Defines the red component (between 0 and 1, default is 0)
  6208. */
  6209. r?: number,
  6210. /**
  6211. * Defines the green component (between 0 and 1, default is 0)
  6212. */
  6213. g?: number,
  6214. /**
  6215. * Defines the blue component (between 0 and 1, default is 0)
  6216. */
  6217. b?: number);
  6218. /**
  6219. * Creates a string with the Color3 current values
  6220. * @returns the string representation of the Color3 object
  6221. */
  6222. toString(): string;
  6223. /**
  6224. * Returns the string "Color3"
  6225. * @returns "Color3"
  6226. */
  6227. getClassName(): string;
  6228. /**
  6229. * Compute the Color3 hash code
  6230. * @returns an unique number that can be used to hash Color3 objects
  6231. */
  6232. getHashCode(): number;
  6233. /**
  6234. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6235. * @param array defines the array where to store the r,g,b components
  6236. * @param index defines an optional index in the target array to define where to start storing values
  6237. * @returns the current Color3 object
  6238. */
  6239. toArray(array: FloatArray, index?: number): Color3;
  6240. /**
  6241. * Update the current color with values stored in an array from the starting index of the given array
  6242. * @param array defines the source array
  6243. * @param offset defines an offset in the source array
  6244. * @returns the current Color3 object
  6245. */
  6246. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6247. /**
  6248. * Returns a new Color4 object from the current Color3 and the given alpha
  6249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6250. * @returns a new Color4 object
  6251. */
  6252. toColor4(alpha?: number): Color4;
  6253. /**
  6254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6255. * @returns the new array
  6256. */
  6257. asArray(): number[];
  6258. /**
  6259. * Returns the luminance value
  6260. * @returns a float value
  6261. */
  6262. toLuminance(): number;
  6263. /**
  6264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6265. * @param otherColor defines the second operand
  6266. * @returns the new Color3 object
  6267. */
  6268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6269. /**
  6270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6271. * @param otherColor defines the second operand
  6272. * @param result defines the Color3 object where to store the result
  6273. * @returns the current Color3
  6274. */
  6275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6276. /**
  6277. * Determines equality between Color3 objects
  6278. * @param otherColor defines the second operand
  6279. * @returns true if the rgb values are equal to the given ones
  6280. */
  6281. equals(otherColor: DeepImmutable<Color3>): boolean;
  6282. /**
  6283. * Determines equality between the current Color3 object and a set of r,b,g values
  6284. * @param r defines the red component to check
  6285. * @param g defines the green component to check
  6286. * @param b defines the blue component to check
  6287. * @returns true if the rgb values are equal to the given ones
  6288. */
  6289. equalsFloats(r: number, g: number, b: number): boolean;
  6290. /**
  6291. * Multiplies in place each rgb value by scale
  6292. * @param scale defines the scaling factor
  6293. * @returns the updated Color3
  6294. */
  6295. scale(scale: number): Color3;
  6296. /**
  6297. * Multiplies the rgb values by scale and stores the result into "result"
  6298. * @param scale defines the scaling factor
  6299. * @param result defines the Color3 object where to store the result
  6300. * @returns the unmodified current Color3
  6301. */
  6302. scaleToRef(scale: number, result: Color3): Color3;
  6303. /**
  6304. * Scale the current Color3 values by a factor and add the result to a given Color3
  6305. * @param scale defines the scale factor
  6306. * @param result defines color to store the result into
  6307. * @returns the unmodified current Color3
  6308. */
  6309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6310. /**
  6311. * Clamps the rgb values by the min and max values and stores the result into "result"
  6312. * @param min defines minimum clamping value (default is 0)
  6313. * @param max defines maximum clamping value (default is 1)
  6314. * @param result defines color to store the result into
  6315. * @returns the original Color3
  6316. */
  6317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6318. /**
  6319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. add(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6333. * @param otherColor defines the second operand
  6334. * @returns the new Color3
  6335. */
  6336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6337. /**
  6338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6339. * @param otherColor defines the second operand
  6340. * @param result defines Color3 object to store the result into
  6341. * @returns the unmodified current Color3
  6342. */
  6343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6344. /**
  6345. * Copy the current object
  6346. * @returns a new Color3 copied the current one
  6347. */
  6348. clone(): Color3;
  6349. /**
  6350. * Copies the rgb values from the source in the current Color3
  6351. * @param source defines the source Color3 object
  6352. * @returns the updated Color3 object
  6353. */
  6354. copyFrom(source: DeepImmutable<Color3>): Color3;
  6355. /**
  6356. * Updates the Color3 rgb values from the given floats
  6357. * @param r defines the red component to read from
  6358. * @param g defines the green component to read from
  6359. * @param b defines the blue component to read from
  6360. * @returns the current Color3 object
  6361. */
  6362. copyFromFloats(r: number, g: number, b: number): Color3;
  6363. /**
  6364. * Updates the Color3 rgb values from the given floats
  6365. * @param r defines the red component to read from
  6366. * @param g defines the green component to read from
  6367. * @param b defines the blue component to read from
  6368. * @returns the current Color3 object
  6369. */
  6370. set(r: number, g: number, b: number): Color3;
  6371. /**
  6372. * Compute the Color3 hexadecimal code as a string
  6373. * @returns a string containing the hexadecimal representation of the Color3 object
  6374. */
  6375. toHexString(): string;
  6376. /**
  6377. * Computes a new Color3 converted from the current one to linear space
  6378. * @returns a new Color3 object
  6379. */
  6380. toLinearSpace(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @returns a new color3 representing the HSV values
  6384. */
  6385. toHSV(): Color3;
  6386. /**
  6387. * Converts current color in rgb space to HSV values
  6388. * @param result defines the Color3 where to store the HSV values
  6389. */
  6390. toHSVToRef(result: Color3): void;
  6391. /**
  6392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6393. * @param convertedColor defines the Color3 object where to store the linear space version
  6394. * @returns the unmodified Color3
  6395. */
  6396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6397. /**
  6398. * Computes a new Color3 converted from the current one to gamma space
  6399. * @returns a new Color3 object
  6400. */
  6401. toGammaSpace(): Color3;
  6402. /**
  6403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6404. * @param convertedColor defines the Color3 object where to store the gamma space version
  6405. * @returns the unmodified Color3
  6406. */
  6407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6408. private static _BlackReadOnly;
  6409. /**
  6410. * Convert Hue, saturation and value to a Color3 (RGB)
  6411. * @param hue defines the hue
  6412. * @param saturation defines the saturation
  6413. * @param value defines the value
  6414. * @param result defines the Color3 where to store the RGB values
  6415. */
  6416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6417. /**
  6418. * Creates a new Color3 from the string containing valid hexadecimal values
  6419. * @param hex defines a string containing valid hexadecimal values
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromHexString(hex: string): Color3;
  6423. /**
  6424. * Creates a new Color3 from the starting index of the given array
  6425. * @param array defines the source array
  6426. * @param offset defines an offset in the source array
  6427. * @returns a new Color3 object
  6428. */
  6429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6430. /**
  6431. * Creates a new Color3 from the starting index element of the given array
  6432. * @param array defines the source array to read from
  6433. * @param offset defines the offset in the source array
  6434. * @param result defines the target Color3 object
  6435. */
  6436. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6437. /**
  6438. * Creates a new Color3 from integer values (< 256)
  6439. * @param r defines the red component to read from (value between 0 and 255)
  6440. * @param g defines the green component to read from (value between 0 and 255)
  6441. * @param b defines the blue component to read from (value between 0 and 255)
  6442. * @returns a new Color3 object
  6443. */
  6444. static FromInts(r: number, g: number, b: number): Color3;
  6445. /**
  6446. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6447. * @param start defines the start Color3 value
  6448. * @param end defines the end Color3 value
  6449. * @param amount defines the gradient value between start and end
  6450. * @returns a new Color3 object
  6451. */
  6452. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6453. /**
  6454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6455. * @param left defines the start value
  6456. * @param right defines the end value
  6457. * @param amount defines the gradient factor
  6458. * @param result defines the Color3 object where to store the result
  6459. */
  6460. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6461. /**
  6462. * Returns a Color3 value containing a red color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Red(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a green color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Green(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a blue color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Blue(): Color3;
  6476. /**
  6477. * Returns a Color3 value containing a black color
  6478. * @returns a new Color3 object
  6479. */
  6480. static Black(): Color3;
  6481. /**
  6482. * Gets a Color3 value containing a black color that must not be updated
  6483. */
  6484. static get BlackReadOnly(): DeepImmutable<Color3>;
  6485. /**
  6486. * Returns a Color3 value containing a white color
  6487. * @returns a new Color3 object
  6488. */
  6489. static White(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a purple color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Purple(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a magenta color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Magenta(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a yellow color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Yellow(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a gray color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Gray(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a teal color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Teal(): Color3;
  6515. /**
  6516. * Returns a Color3 value containing a random color
  6517. * @returns a new Color3 object
  6518. */
  6519. static Random(): Color3;
  6520. }
  6521. /**
  6522. * Class used to hold a RBGA color
  6523. */
  6524. export class Color4 {
  6525. /**
  6526. * Defines the red component (between 0 and 1, default is 0)
  6527. */
  6528. r: number;
  6529. /**
  6530. * Defines the green component (between 0 and 1, default is 0)
  6531. */
  6532. g: number;
  6533. /**
  6534. * Defines the blue component (between 0 and 1, default is 0)
  6535. */
  6536. b: number;
  6537. /**
  6538. * Defines the alpha component (between 0 and 1, default is 1)
  6539. */
  6540. a: number;
  6541. /**
  6542. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6543. * @param r defines the red component (between 0 and 1, default is 0)
  6544. * @param g defines the green component (between 0 and 1, default is 0)
  6545. * @param b defines the blue component (between 0 and 1, default is 0)
  6546. * @param a defines the alpha component (between 0 and 1, default is 1)
  6547. */
  6548. constructor(
  6549. /**
  6550. * Defines the red component (between 0 and 1, default is 0)
  6551. */
  6552. r?: number,
  6553. /**
  6554. * Defines the green component (between 0 and 1, default is 0)
  6555. */
  6556. g?: number,
  6557. /**
  6558. * Defines the blue component (between 0 and 1, default is 0)
  6559. */
  6560. b?: number,
  6561. /**
  6562. * Defines the alpha component (between 0 and 1, default is 1)
  6563. */
  6564. a?: number);
  6565. /**
  6566. * Adds in place the given Color4 values to the current Color4 object
  6567. * @param right defines the second operand
  6568. * @returns the current updated Color4 object
  6569. */
  6570. addInPlace(right: DeepImmutable<Color4>): Color4;
  6571. /**
  6572. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6573. * @returns the new array
  6574. */
  6575. asArray(): number[];
  6576. /**
  6577. * Stores from the starting index in the given array the Color4 successive values
  6578. * @param array defines the array where to store the r,g,b components
  6579. * @param index defines an optional index in the target array to define where to start storing values
  6580. * @returns the current Color4 object
  6581. */
  6582. toArray(array: number[], index?: number): Color4;
  6583. /**
  6584. * Update the current color with values stored in an array from the starting index of the given array
  6585. * @param array defines the source array
  6586. * @param offset defines an offset in the source array
  6587. * @returns the current Color4 object
  6588. */
  6589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6590. /**
  6591. * Determines equality between Color4 objects
  6592. * @param otherColor defines the second operand
  6593. * @returns true if the rgba values are equal to the given ones
  6594. */
  6595. equals(otherColor: DeepImmutable<Color4>): boolean;
  6596. /**
  6597. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6598. * @param right defines the second operand
  6599. * @returns a new Color4 object
  6600. */
  6601. add(right: DeepImmutable<Color4>): Color4;
  6602. /**
  6603. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6604. * @param right defines the second operand
  6605. * @returns a new Color4 object
  6606. */
  6607. subtract(right: DeepImmutable<Color4>): Color4;
  6608. /**
  6609. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6610. * @param right defines the second operand
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current Color4 object
  6613. */
  6614. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6615. /**
  6616. * Creates a new Color4 with the current Color4 values multiplied by scale
  6617. * @param scale defines the scaling factor to apply
  6618. * @returns a new Color4 object
  6619. */
  6620. scale(scale: number): Color4;
  6621. /**
  6622. * Multiplies the current Color4 values by scale and stores the result in "result"
  6623. * @param scale defines the scaling factor to apply
  6624. * @param result defines the Color4 object where to store the result
  6625. * @returns the current unmodified Color4
  6626. */
  6627. scaleToRef(scale: number, result: Color4): Color4;
  6628. /**
  6629. * Scale the current Color4 values by a factor and add the result to a given Color4
  6630. * @param scale defines the scale factor
  6631. * @param result defines the Color4 object where to store the result
  6632. * @returns the unmodified current Color4
  6633. */
  6634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6635. /**
  6636. * Clamps the rgb values by the min and max values and stores the result into "result"
  6637. * @param min defines minimum clamping value (default is 0)
  6638. * @param max defines maximum clamping value (default is 1)
  6639. * @param result defines color to store the result into.
  6640. * @returns the cuurent Color4
  6641. */
  6642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6643. /**
  6644. * Multipy an Color4 value by another and return a new Color4 object
  6645. * @param color defines the Color4 value to multiply by
  6646. * @returns a new Color4 object
  6647. */
  6648. multiply(color: Color4): Color4;
  6649. /**
  6650. * Multipy a Color4 value by another and push the result in a reference value
  6651. * @param color defines the Color4 value to multiply by
  6652. * @param result defines the Color4 to fill the result in
  6653. * @returns the result Color4
  6654. */
  6655. multiplyToRef(color: Color4, result: Color4): Color4;
  6656. /**
  6657. * Creates a string with the Color4 current values
  6658. * @returns the string representation of the Color4 object
  6659. */
  6660. toString(): string;
  6661. /**
  6662. * Returns the string "Color4"
  6663. * @returns "Color4"
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Compute the Color4 hash code
  6668. * @returns an unique number that can be used to hash Color4 objects
  6669. */
  6670. getHashCode(): number;
  6671. /**
  6672. * Creates a new Color4 copied from the current one
  6673. * @returns a new Color4 object
  6674. */
  6675. clone(): Color4;
  6676. /**
  6677. * Copies the given Color4 values into the current one
  6678. * @param source defines the source Color4 object
  6679. * @returns the current updated Color4 object
  6680. */
  6681. copyFrom(source: Color4): Color4;
  6682. /**
  6683. * Copies the given float values into the current one
  6684. * @param r defines the red component to read from
  6685. * @param g defines the green component to read from
  6686. * @param b defines the blue component to read from
  6687. * @param a defines the alpha component to read from
  6688. * @returns the current updated Color4 object
  6689. */
  6690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6691. /**
  6692. * Copies the given float values into the current one
  6693. * @param r defines the red component to read from
  6694. * @param g defines the green component to read from
  6695. * @param b defines the blue component to read from
  6696. * @param a defines the alpha component to read from
  6697. * @returns the current updated Color4 object
  6698. */
  6699. set(r: number, g: number, b: number, a: number): Color4;
  6700. /**
  6701. * Compute the Color4 hexadecimal code as a string
  6702. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6703. * @returns a string containing the hexadecimal representation of the Color4 object
  6704. */
  6705. toHexString(returnAsColor3?: boolean): string;
  6706. /**
  6707. * Computes a new Color4 converted from the current one to linear space
  6708. * @returns a new Color4 object
  6709. */
  6710. toLinearSpace(): Color4;
  6711. /**
  6712. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6713. * @param convertedColor defines the Color4 object where to store the linear space version
  6714. * @returns the unmodified Color4
  6715. */
  6716. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6717. /**
  6718. * Computes a new Color4 converted from the current one to gamma space
  6719. * @returns a new Color4 object
  6720. */
  6721. toGammaSpace(): Color4;
  6722. /**
  6723. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6724. * @param convertedColor defines the Color4 object where to store the gamma space version
  6725. * @returns the unmodified Color4
  6726. */
  6727. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6728. /**
  6729. * Creates a new Color4 from the string containing valid hexadecimal values
  6730. * @param hex defines a string containing valid hexadecimal values
  6731. * @returns a new Color4 object
  6732. */
  6733. static FromHexString(hex: string): Color4;
  6734. /**
  6735. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6736. * @param left defines the start value
  6737. * @param right defines the end value
  6738. * @param amount defines the gradient factor
  6739. * @returns a new Color4 object
  6740. */
  6741. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6742. /**
  6743. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6744. * @param left defines the start value
  6745. * @param right defines the end value
  6746. * @param amount defines the gradient factor
  6747. * @param result defines the Color4 object where to store data
  6748. */
  6749. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6750. /**
  6751. * Creates a new Color4 from a Color3 and an alpha value
  6752. * @param color3 defines the source Color3 to read from
  6753. * @param alpha defines the alpha component (1.0 by default)
  6754. * @returns a new Color4 object
  6755. */
  6756. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6757. /**
  6758. * Creates a new Color4 from the starting index element of the given array
  6759. * @param array defines the source array to read from
  6760. * @param offset defines the offset in the source array
  6761. * @returns a new Color4 object
  6762. */
  6763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6764. /**
  6765. * Creates a new Color4 from the starting index element of the given array
  6766. * @param array defines the source array to read from
  6767. * @param offset defines the offset in the source array
  6768. * @param result defines the target Color4 object
  6769. */
  6770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6771. /**
  6772. * Creates a new Color3 from integer values (< 256)
  6773. * @param r defines the red component to read from (value between 0 and 255)
  6774. * @param g defines the green component to read from (value between 0 and 255)
  6775. * @param b defines the blue component to read from (value between 0 and 255)
  6776. * @param a defines the alpha component to read from (value between 0 and 255)
  6777. * @returns a new Color3 object
  6778. */
  6779. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6780. /**
  6781. * Check the content of a given array and convert it to an array containing RGBA data
  6782. * If the original array was already containing count * 4 values then it is returned directly
  6783. * @param colors defines the array to check
  6784. * @param count defines the number of RGBA data to expect
  6785. * @returns an array containing count * 4 values (RGBA)
  6786. */
  6787. static CheckColors4(colors: number[], count: number): number[];
  6788. }
  6789. /**
  6790. * @hidden
  6791. */
  6792. export class TmpColors {
  6793. static Color3: Color3[];
  6794. static Color4: Color4[];
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. /**
  6799. * Defines an interface which represents an animation key frame
  6800. */
  6801. export interface IAnimationKey {
  6802. /**
  6803. * Frame of the key frame
  6804. */
  6805. frame: number;
  6806. /**
  6807. * Value at the specifies key frame
  6808. */
  6809. value: any;
  6810. /**
  6811. * The input tangent for the cubic hermite spline
  6812. */
  6813. inTangent?: any;
  6814. /**
  6815. * The output tangent for the cubic hermite spline
  6816. */
  6817. outTangent?: any;
  6818. /**
  6819. * The animation interpolation type
  6820. */
  6821. interpolation?: AnimationKeyInterpolation;
  6822. }
  6823. /**
  6824. * Enum for the animation key frame interpolation type
  6825. */
  6826. export enum AnimationKeyInterpolation {
  6827. /**
  6828. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6829. */
  6830. STEP = 1
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Represents the range of an animation
  6836. */
  6837. export class AnimationRange {
  6838. /**The name of the animation range**/
  6839. name: string;
  6840. /**The starting frame of the animation */
  6841. from: number;
  6842. /**The ending frame of the animation*/
  6843. to: number;
  6844. /**
  6845. * Initializes the range of an animation
  6846. * @param name The name of the animation range
  6847. * @param from The starting frame of the animation
  6848. * @param to The ending frame of the animation
  6849. */
  6850. constructor(
  6851. /**The name of the animation range**/
  6852. name: string,
  6853. /**The starting frame of the animation */
  6854. from: number,
  6855. /**The ending frame of the animation*/
  6856. to: number);
  6857. /**
  6858. * Makes a copy of the animation range
  6859. * @returns A copy of the animation range
  6860. */
  6861. clone(): AnimationRange;
  6862. }
  6863. }
  6864. declare module BABYLON {
  6865. /**
  6866. * Composed of a frame, and an action function
  6867. */
  6868. export class AnimationEvent {
  6869. /** The frame for which the event is triggered **/
  6870. frame: number;
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void;
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined;
  6875. /**
  6876. * Specifies if the animation event is done
  6877. */
  6878. isDone: boolean;
  6879. /**
  6880. * Initializes the animation event
  6881. * @param frame The frame for which the event is triggered
  6882. * @param action The event to perform when triggered
  6883. * @param onlyOnce Specifies if the event should be triggered only once
  6884. */
  6885. constructor(
  6886. /** The frame for which the event is triggered **/
  6887. frame: number,
  6888. /** The event to perform when triggered **/
  6889. action: (currentFrame: number) => void,
  6890. /** Specifies if the event should be triggered only once**/
  6891. onlyOnce?: boolean | undefined);
  6892. /** @hidden */
  6893. _clone(): AnimationEvent;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Interface used to define a behavior
  6899. */
  6900. export interface Behavior<T> {
  6901. /** gets or sets behavior's name */
  6902. name: string;
  6903. /**
  6904. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6905. */
  6906. init(): void;
  6907. /**
  6908. * Called when the behavior is attached to a target
  6909. * @param target defines the target where the behavior is attached to
  6910. */
  6911. attach(target: T): void;
  6912. /**
  6913. * Called when the behavior is detached from its target
  6914. */
  6915. detach(): void;
  6916. }
  6917. /**
  6918. * Interface implemented by classes supporting behaviors
  6919. */
  6920. export interface IBehaviorAware<T> {
  6921. /**
  6922. * Attach a behavior
  6923. * @param behavior defines the behavior to attach
  6924. * @returns the current host
  6925. */
  6926. addBehavior(behavior: Behavior<T>): T;
  6927. /**
  6928. * Remove a behavior from the current object
  6929. * @param behavior defines the behavior to detach
  6930. * @returns the current host
  6931. */
  6932. removeBehavior(behavior: Behavior<T>): T;
  6933. /**
  6934. * Gets a behavior using its name to search
  6935. * @param name defines the name to search
  6936. * @returns the behavior or null if not found
  6937. */
  6938. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to provide helpers for slicing
  6944. */
  6945. export class SliceTools {
  6946. /**
  6947. * Provides a slice function that will work even on IE
  6948. * @param data defines the array to slice
  6949. * @param start defines the start of the data (optional)
  6950. * @param end defines the end of the data (optional)
  6951. * @returns the new sliced array
  6952. */
  6953. static Slice<T>(data: T, start?: number, end?: number): T;
  6954. /**
  6955. * Provides a slice function that will work even on IE
  6956. * The difference between this and Slice is that this will force-convert to array
  6957. * @param data defines the array to slice
  6958. * @param start defines the start of the data (optional)
  6959. * @param end defines the end of the data (optional)
  6960. * @returns the new sliced array
  6961. */
  6962. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to store data that will be store in GPU memory
  6968. */
  6969. export class Buffer {
  6970. private _engine;
  6971. private _buffer;
  6972. /** @hidden */
  6973. _data: Nullable<DataArray>;
  6974. private _updatable;
  6975. private _instanced;
  6976. private _divisor;
  6977. private _isAlreadyOwned;
  6978. /**
  6979. * Gets the byte stride.
  6980. */
  6981. readonly byteStride: number;
  6982. /**
  6983. * Constructor
  6984. * @param engine the engine
  6985. * @param data the data to use for this buffer
  6986. * @param updatable whether the data is updatable
  6987. * @param stride the stride (optional)
  6988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6989. * @param instanced whether the buffer is instanced (optional)
  6990. * @param useBytes set to true if the stride in in bytes (optional)
  6991. * @param divisor sets an optional divisor for instances (1 by default)
  6992. */
  6993. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6994. /**
  6995. * Create a new VertexBuffer based on the current buffer
  6996. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6997. * @param offset defines offset in the buffer (0 by default)
  6998. * @param size defines the size in floats of attributes (position is 3 for instance)
  6999. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7000. * @param instanced defines if the vertex buffer contains indexed data
  7001. * @param useBytes defines if the offset and stride are in bytes *
  7002. * @param divisor sets an optional divisor for instances (1 by default)
  7003. * @returns the new vertex buffer
  7004. */
  7005. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7006. /**
  7007. * Gets a boolean indicating if the Buffer is updatable?
  7008. * @returns true if the buffer is updatable
  7009. */
  7010. isUpdatable(): boolean;
  7011. /**
  7012. * Gets current buffer's data
  7013. * @returns a DataArray or null
  7014. */
  7015. getData(): Nullable<DataArray>;
  7016. /**
  7017. * Gets underlying native buffer
  7018. * @returns underlying native buffer
  7019. */
  7020. getBuffer(): Nullable<DataBuffer>;
  7021. /**
  7022. * Gets the stride in float32 units (i.e. byte stride / 4).
  7023. * May not be an integer if the byte stride is not divisible by 4.
  7024. * @returns the stride in float32 units
  7025. * @deprecated Please use byteStride instead.
  7026. */
  7027. getStrideSize(): number;
  7028. /**
  7029. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7030. * @param data defines the data to store
  7031. */
  7032. create(data?: Nullable<DataArray>): void;
  7033. /** @hidden */
  7034. _rebuild(): void;
  7035. /**
  7036. * Update current buffer data
  7037. * @param data defines the data to store
  7038. */
  7039. update(data: DataArray): void;
  7040. /**
  7041. * Updates the data directly.
  7042. * @param data the new data
  7043. * @param offset the new offset
  7044. * @param vertexCount the vertex count (optional)
  7045. * @param useBytes set to true if the offset is in bytes
  7046. */
  7047. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7048. /** @hidden */
  7049. _increaseReferences(): void;
  7050. /**
  7051. * Release all resources
  7052. */
  7053. dispose(): void;
  7054. }
  7055. /**
  7056. * Specialized buffer used to store vertex data
  7057. */
  7058. export class VertexBuffer {
  7059. private static _Counter;
  7060. /** @hidden */
  7061. _buffer: Buffer;
  7062. private _kind;
  7063. private _size;
  7064. private _ownsBuffer;
  7065. private _instanced;
  7066. private _instanceDivisor;
  7067. /**
  7068. * The byte type.
  7069. */
  7070. static readonly BYTE: number;
  7071. /**
  7072. * The unsigned byte type.
  7073. */
  7074. static readonly UNSIGNED_BYTE: number;
  7075. /**
  7076. * The short type.
  7077. */
  7078. static readonly SHORT: number;
  7079. /**
  7080. * The unsigned short type.
  7081. */
  7082. static readonly UNSIGNED_SHORT: number;
  7083. /**
  7084. * The integer type.
  7085. */
  7086. static readonly INT: number;
  7087. /**
  7088. * The unsigned integer type.
  7089. */
  7090. static readonly UNSIGNED_INT: number;
  7091. /**
  7092. * The float type.
  7093. */
  7094. static readonly FLOAT: number;
  7095. /**
  7096. * Gets or sets the instance divisor when in instanced mode
  7097. */
  7098. get instanceDivisor(): number;
  7099. set instanceDivisor(value: number);
  7100. /**
  7101. * Gets the byte stride.
  7102. */
  7103. readonly byteStride: number;
  7104. /**
  7105. * Gets the byte offset.
  7106. */
  7107. readonly byteOffset: number;
  7108. /**
  7109. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7110. */
  7111. readonly normalized: boolean;
  7112. /**
  7113. * Gets the data type of each component in the array.
  7114. */
  7115. readonly type: number;
  7116. /**
  7117. * Gets the unique id of this vertex buffer
  7118. */
  7119. readonly uniqueId: number;
  7120. /**
  7121. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  7122. * All buffers with the same format will have the same hash code
  7123. */
  7124. readonly hashCode: number;
  7125. /**
  7126. * Constructor
  7127. * @param engine the engine
  7128. * @param data the data to use for this vertex buffer
  7129. * @param kind the vertex buffer kind
  7130. * @param updatable whether the data is updatable
  7131. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7132. * @param stride the stride (optional)
  7133. * @param instanced whether the buffer is instanced (optional)
  7134. * @param offset the offset of the data (optional)
  7135. * @param size the number of components (optional)
  7136. * @param type the type of the component (optional)
  7137. * @param normalized whether the data contains normalized data (optional)
  7138. * @param useBytes set to true if stride and offset are in bytes (optional)
  7139. * @param divisor defines the instance divisor to use (1 by default)
  7140. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7141. */
  7142. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7143. private _computeHashCode;
  7144. /** @hidden */
  7145. _rebuild(): void;
  7146. /**
  7147. * Returns the kind of the VertexBuffer (string)
  7148. * @returns a string
  7149. */
  7150. getKind(): string;
  7151. /**
  7152. * Gets a boolean indicating if the VertexBuffer is updatable?
  7153. * @returns true if the buffer is updatable
  7154. */
  7155. isUpdatable(): boolean;
  7156. /**
  7157. * Gets current buffer's data
  7158. * @returns a DataArray or null
  7159. */
  7160. getData(): Nullable<DataArray>;
  7161. /**
  7162. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7163. * @param totalVertices number of vertices in the buffer to take into account
  7164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7165. * @returns a float array containing vertex data
  7166. */
  7167. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7168. /**
  7169. * Gets underlying native buffer
  7170. * @returns underlying native buffer
  7171. */
  7172. getBuffer(): Nullable<DataBuffer>;
  7173. /**
  7174. * Gets the stride in float32 units (i.e. byte stride / 4).
  7175. * May not be an integer if the byte stride is not divisible by 4.
  7176. * @returns the stride in float32 units
  7177. * @deprecated Please use byteStride instead.
  7178. */
  7179. getStrideSize(): number;
  7180. /**
  7181. * Returns the offset as a multiple of the type byte length.
  7182. * @returns the offset in bytes
  7183. * @deprecated Please use byteOffset instead.
  7184. */
  7185. getOffset(): number;
  7186. /**
  7187. * Returns the number of components per vertex attribute (integer)
  7188. * @returns the size in float
  7189. */
  7190. getSize(): number;
  7191. /**
  7192. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7193. * @returns true if this buffer is instanced
  7194. */
  7195. getIsInstanced(): boolean;
  7196. /**
  7197. * Returns the instancing divisor, zero for non-instanced (integer).
  7198. * @returns a number
  7199. */
  7200. getInstanceDivisor(): number;
  7201. /**
  7202. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7203. * @param data defines the data to store
  7204. */
  7205. create(data?: DataArray): void;
  7206. /**
  7207. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7208. * This function will create a new buffer if the current one is not updatable
  7209. * @param data defines the data to store
  7210. */
  7211. update(data: DataArray): void;
  7212. /**
  7213. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7214. * Returns the directly updated WebGLBuffer.
  7215. * @param data the new data
  7216. * @param offset the new offset
  7217. * @param useBytes set to true if the offset is in bytes
  7218. */
  7219. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7220. /**
  7221. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7222. */
  7223. dispose(): void;
  7224. /**
  7225. * Enumerates each value of this vertex buffer as numbers.
  7226. * @param count the number of values to enumerate
  7227. * @param callback the callback function called for each value
  7228. */
  7229. forEach(count: number, callback: (value: number, index: number) => void): void;
  7230. /**
  7231. * Positions
  7232. */
  7233. static readonly PositionKind: string;
  7234. /**
  7235. * Normals
  7236. */
  7237. static readonly NormalKind: string;
  7238. /**
  7239. * Tangents
  7240. */
  7241. static readonly TangentKind: string;
  7242. /**
  7243. * Texture coordinates
  7244. */
  7245. static readonly UVKind: string;
  7246. /**
  7247. * Texture coordinates 2
  7248. */
  7249. static readonly UV2Kind: string;
  7250. /**
  7251. * Texture coordinates 3
  7252. */
  7253. static readonly UV3Kind: string;
  7254. /**
  7255. * Texture coordinates 4
  7256. */
  7257. static readonly UV4Kind: string;
  7258. /**
  7259. * Texture coordinates 5
  7260. */
  7261. static readonly UV5Kind: string;
  7262. /**
  7263. * Texture coordinates 6
  7264. */
  7265. static readonly UV6Kind: string;
  7266. /**
  7267. * Colors
  7268. */
  7269. static readonly ColorKind: string;
  7270. /**
  7271. * Matrix indices (for bones)
  7272. */
  7273. static readonly MatricesIndicesKind: string;
  7274. /**
  7275. * Matrix weights (for bones)
  7276. */
  7277. static readonly MatricesWeightsKind: string;
  7278. /**
  7279. * Additional matrix indices (for bones)
  7280. */
  7281. static readonly MatricesIndicesExtraKind: string;
  7282. /**
  7283. * Additional matrix weights (for bones)
  7284. */
  7285. static readonly MatricesWeightsExtraKind: string;
  7286. /**
  7287. * Deduces the stride given a kind.
  7288. * @param kind The kind string to deduce
  7289. * @returns The deduced stride
  7290. */
  7291. static DeduceStride(kind: string): number;
  7292. /**
  7293. * Gets the byte length of the given type.
  7294. * @param type the type
  7295. * @returns the number of bytes
  7296. */
  7297. static GetTypeByteLength(type: number): number;
  7298. /**
  7299. * Enumerates each value of the given parameters as numbers.
  7300. * @param data the data to enumerate
  7301. * @param byteOffset the byte offset of the data
  7302. * @param byteStride the byte stride of the data
  7303. * @param componentCount the number of components per element
  7304. * @param componentType the type of the component
  7305. * @param count the number of values to enumerate
  7306. * @param normalized whether the data is normalized
  7307. * @param callback the callback function called for each value
  7308. */
  7309. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7310. private static _GetFloatValue;
  7311. }
  7312. }
  7313. declare module BABYLON {
  7314. /**
  7315. * @hidden
  7316. */
  7317. export class IntersectionInfo {
  7318. bu: Nullable<number>;
  7319. bv: Nullable<number>;
  7320. distance: number;
  7321. faceId: number;
  7322. subMeshId: number;
  7323. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7324. }
  7325. }
  7326. declare module BABYLON {
  7327. /**
  7328. * Class used to store bounding sphere information
  7329. */
  7330. export class BoundingSphere {
  7331. /**
  7332. * Gets the center of the bounding sphere in local space
  7333. */
  7334. readonly center: Vector3;
  7335. /**
  7336. * Radius of the bounding sphere in local space
  7337. */
  7338. radius: number;
  7339. /**
  7340. * Gets the center of the bounding sphere in world space
  7341. */
  7342. readonly centerWorld: Vector3;
  7343. /**
  7344. * Radius of the bounding sphere in world space
  7345. */
  7346. radiusWorld: number;
  7347. /**
  7348. * Gets the minimum vector in local space
  7349. */
  7350. readonly minimum: Vector3;
  7351. /**
  7352. * Gets the maximum vector in local space
  7353. */
  7354. readonly maximum: Vector3;
  7355. private _worldMatrix;
  7356. private static readonly TmpVector3;
  7357. /**
  7358. * Creates a new bounding sphere
  7359. * @param min defines the minimum vector (in local space)
  7360. * @param max defines the maximum vector (in local space)
  7361. * @param worldMatrix defines the new world matrix
  7362. */
  7363. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7364. /**
  7365. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7366. * @param min defines the new minimum vector (in local space)
  7367. * @param max defines the new maximum vector (in local space)
  7368. * @param worldMatrix defines the new world matrix
  7369. */
  7370. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7371. /**
  7372. * Scale the current bounding sphere by applying a scale factor
  7373. * @param factor defines the scale factor to apply
  7374. * @returns the current bounding box
  7375. */
  7376. scale(factor: number): BoundingSphere;
  7377. /**
  7378. * Gets the world matrix of the bounding box
  7379. * @returns a matrix
  7380. */
  7381. getWorldMatrix(): DeepImmutable<Matrix>;
  7382. /** @hidden */
  7383. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7384. /**
  7385. * Tests if the bounding sphere is intersecting the frustum planes
  7386. * @param frustumPlanes defines the frustum planes to test
  7387. * @returns true if there is an intersection
  7388. */
  7389. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7390. /**
  7391. * Tests if the bounding sphere center is in between the frustum planes.
  7392. * Used for optimistic fast inclusion.
  7393. * @param frustumPlanes defines the frustum planes to test
  7394. * @returns true if the sphere center is in between the frustum planes
  7395. */
  7396. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7397. /**
  7398. * Tests if a point is inside the bounding sphere
  7399. * @param point defines the point to test
  7400. * @returns true if the point is inside the bounding sphere
  7401. */
  7402. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7403. /**
  7404. * Checks if two sphere intersect
  7405. * @param sphere0 sphere 0
  7406. * @param sphere1 sphere 1
  7407. * @returns true if the spheres intersect
  7408. */
  7409. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7410. }
  7411. }
  7412. declare module BABYLON {
  7413. /**
  7414. * Class used to store bounding box information
  7415. */
  7416. export class BoundingBox implements ICullable {
  7417. /**
  7418. * Gets the 8 vectors representing the bounding box in local space
  7419. */
  7420. readonly vectors: Vector3[];
  7421. /**
  7422. * Gets the center of the bounding box in local space
  7423. */
  7424. readonly center: Vector3;
  7425. /**
  7426. * Gets the center of the bounding box in world space
  7427. */
  7428. readonly centerWorld: Vector3;
  7429. /**
  7430. * Gets the extend size in local space
  7431. */
  7432. readonly extendSize: Vector3;
  7433. /**
  7434. * Gets the extend size in world space
  7435. */
  7436. readonly extendSizeWorld: Vector3;
  7437. /**
  7438. * Gets the OBB (object bounding box) directions
  7439. */
  7440. readonly directions: Vector3[];
  7441. /**
  7442. * Gets the 8 vectors representing the bounding box in world space
  7443. */
  7444. readonly vectorsWorld: Vector3[];
  7445. /**
  7446. * Gets the minimum vector in world space
  7447. */
  7448. readonly minimumWorld: Vector3;
  7449. /**
  7450. * Gets the maximum vector in world space
  7451. */
  7452. readonly maximumWorld: Vector3;
  7453. /**
  7454. * Gets the minimum vector in local space
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * Gets the maximum vector in local space
  7459. */
  7460. readonly maximum: Vector3;
  7461. private _worldMatrix;
  7462. private static readonly TmpVector3;
  7463. /**
  7464. * @hidden
  7465. */
  7466. _tag: number;
  7467. /**
  7468. * Creates a new bounding box
  7469. * @param min defines the minimum vector (in local space)
  7470. * @param max defines the maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7474. /**
  7475. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7476. * @param min defines the new minimum vector (in local space)
  7477. * @param max defines the new maximum vector (in local space)
  7478. * @param worldMatrix defines the new world matrix
  7479. */
  7480. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7481. /**
  7482. * Scale the current bounding box by applying a scale factor
  7483. * @param factor defines the scale factor to apply
  7484. * @returns the current bounding box
  7485. */
  7486. scale(factor: number): BoundingBox;
  7487. /**
  7488. * Gets the world matrix of the bounding box
  7489. * @returns a matrix
  7490. */
  7491. getWorldMatrix(): DeepImmutable<Matrix>;
  7492. /** @hidden */
  7493. _update(world: DeepImmutable<Matrix>): void;
  7494. /**
  7495. * Tests if the bounding box is intersecting the frustum planes
  7496. * @param frustumPlanes defines the frustum planes to test
  7497. * @returns true if there is an intersection
  7498. */
  7499. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7500. /**
  7501. * Tests if the bounding box is entirely inside the frustum planes
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @returns true if there is an inclusion
  7504. */
  7505. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a point is inside the bounding box
  7508. * @param point defines the point to test
  7509. * @returns true if the point is inside the bounding box
  7510. */
  7511. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7512. /**
  7513. * Tests if the bounding box intersects with a bounding sphere
  7514. * @param sphere defines the sphere to test
  7515. * @returns true if there is an intersection
  7516. */
  7517. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7518. /**
  7519. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7520. * @param min defines the min vector to use
  7521. * @param max defines the max vector to use
  7522. * @returns true if there is an intersection
  7523. */
  7524. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7525. /**
  7526. * Tests if two bounding boxes are intersections
  7527. * @param box0 defines the first box to test
  7528. * @param box1 defines the second box to test
  7529. * @returns true if there is an intersection
  7530. */
  7531. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7532. /**
  7533. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7534. * @param minPoint defines the minimum vector of the bounding box
  7535. * @param maxPoint defines the maximum vector of the bounding box
  7536. * @param sphereCenter defines the sphere center
  7537. * @param sphereRadius defines the sphere radius
  7538. * @returns true if there is an intersection
  7539. */
  7540. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7541. /**
  7542. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7543. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7544. * @param frustumPlanes defines the frustum planes to test
  7545. * @return true if there is an inclusion
  7546. */
  7547. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7548. /**
  7549. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7550. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7551. * @param frustumPlanes defines the frustum planes to test
  7552. * @return true if there is an intersection
  7553. */
  7554. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /** @hidden */
  7559. export class Collider {
  7560. /** Define if a collision was found */
  7561. collisionFound: boolean;
  7562. /**
  7563. * Define last intersection point in local space
  7564. */
  7565. intersectionPoint: Vector3;
  7566. /**
  7567. * Define last collided mesh
  7568. */
  7569. collidedMesh: Nullable<AbstractMesh>;
  7570. private _collisionPoint;
  7571. private _planeIntersectionPoint;
  7572. private _tempVector;
  7573. private _tempVector2;
  7574. private _tempVector3;
  7575. private _tempVector4;
  7576. private _edge;
  7577. private _baseToVertex;
  7578. private _destinationPoint;
  7579. private _slidePlaneNormal;
  7580. private _displacementVector;
  7581. /** @hidden */
  7582. _radius: Vector3;
  7583. /** @hidden */
  7584. _retry: number;
  7585. private _velocity;
  7586. private _basePoint;
  7587. private _epsilon;
  7588. /** @hidden */
  7589. _velocityWorldLength: number;
  7590. /** @hidden */
  7591. _basePointWorld: Vector3;
  7592. private _velocityWorld;
  7593. private _normalizedVelocity;
  7594. /** @hidden */
  7595. _initialVelocity: Vector3;
  7596. /** @hidden */
  7597. _initialPosition: Vector3;
  7598. private _nearestDistance;
  7599. private _collisionMask;
  7600. get collisionMask(): number;
  7601. set collisionMask(mask: number);
  7602. /**
  7603. * Gets the plane normal used to compute the sliding response (in local space)
  7604. */
  7605. get slidePlaneNormal(): Vector3;
  7606. /** @hidden */
  7607. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7608. /** @hidden */
  7609. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7610. /** @hidden */
  7611. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7612. /** @hidden */
  7613. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7614. /** @hidden */
  7615. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7616. /** @hidden */
  7617. _getResponse(pos: Vector3, vel: Vector3): void;
  7618. }
  7619. }
  7620. declare module BABYLON {
  7621. /**
  7622. * Interface for cullable objects
  7623. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7624. */
  7625. export interface ICullable {
  7626. /**
  7627. * Checks if the object or part of the object is in the frustum
  7628. * @param frustumPlanes Camera near/planes
  7629. * @returns true if the object is in frustum otherwise false
  7630. */
  7631. isInFrustum(frustumPlanes: Plane[]): boolean;
  7632. /**
  7633. * Checks if a cullable object (mesh...) is in the camera frustum
  7634. * Unlike isInFrustum this checks the full bounding box
  7635. * @param frustumPlanes Camera near/planes
  7636. * @returns true if the object is in frustum otherwise false
  7637. */
  7638. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7639. }
  7640. /**
  7641. * Info for a bounding data of a mesh
  7642. */
  7643. export class BoundingInfo implements ICullable {
  7644. /**
  7645. * Bounding box for the mesh
  7646. */
  7647. readonly boundingBox: BoundingBox;
  7648. /**
  7649. * Bounding sphere for the mesh
  7650. */
  7651. readonly boundingSphere: BoundingSphere;
  7652. private _isLocked;
  7653. private static readonly TmpVector3;
  7654. /**
  7655. * Constructs bounding info
  7656. * @param minimum min vector of the bounding box/sphere
  7657. * @param maximum max vector of the bounding box/sphere
  7658. * @param worldMatrix defines the new world matrix
  7659. */
  7660. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7661. /**
  7662. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7663. * @param min defines the new minimum vector (in local space)
  7664. * @param max defines the new maximum vector (in local space)
  7665. * @param worldMatrix defines the new world matrix
  7666. */
  7667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7668. /**
  7669. * min vector of the bounding box/sphere
  7670. */
  7671. get minimum(): Vector3;
  7672. /**
  7673. * max vector of the bounding box/sphere
  7674. */
  7675. get maximum(): Vector3;
  7676. /**
  7677. * If the info is locked and won't be updated to avoid perf overhead
  7678. */
  7679. get isLocked(): boolean;
  7680. set isLocked(value: boolean);
  7681. /**
  7682. * Updates the bounding sphere and box
  7683. * @param world world matrix to be used to update
  7684. */
  7685. update(world: DeepImmutable<Matrix>): void;
  7686. /**
  7687. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7688. * @param center New center of the bounding info
  7689. * @param extend New extend of the bounding info
  7690. * @returns the current bounding info
  7691. */
  7692. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7693. /**
  7694. * Grows the bounding info to include the given point.
  7695. * @param point The point that will be included in the current bounding info
  7696. * @returns the current bounding info
  7697. */
  7698. encapsulate(point: Vector3): BoundingInfo;
  7699. /**
  7700. * Grows the bounding info to encapsulate the given bounding info.
  7701. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7702. * @returns the current bounding info
  7703. */
  7704. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7705. /**
  7706. * Scale the current bounding info by applying a scale factor
  7707. * @param factor defines the scale factor to apply
  7708. * @returns the current bounding info
  7709. */
  7710. scale(factor: number): BoundingInfo;
  7711. /**
  7712. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7713. * @param frustumPlanes defines the frustum to test
  7714. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7715. * @returns true if the bounding info is in the frustum planes
  7716. */
  7717. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7718. /**
  7719. * Gets the world distance between the min and max points of the bounding box
  7720. */
  7721. get diagonalLength(): number;
  7722. /**
  7723. * Checks if a cullable object (mesh...) is in the camera frustum
  7724. * Unlike isInFrustum this checks the full bounding box
  7725. * @param frustumPlanes Camera near/planes
  7726. * @returns true if the object is in frustum otherwise false
  7727. */
  7728. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7729. /** @hidden */
  7730. _checkCollision(collider: Collider): boolean;
  7731. /**
  7732. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7733. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7734. * @param point the point to check intersection with
  7735. * @returns if the point intersects
  7736. */
  7737. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7738. /**
  7739. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7741. * @param boundingInfo the bounding info to check intersection with
  7742. * @param precise if the intersection should be done using OBB
  7743. * @returns if the bounding info intersects
  7744. */
  7745. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Extracts minimum and maximum values from a list of indexed positions
  7751. * @param positions defines the positions to use
  7752. * @param indices defines the indices to the positions
  7753. * @param indexStart defines the start index
  7754. * @param indexCount defines the end index
  7755. * @param bias defines bias value to add to the result
  7756. * @return minimum and maximum values
  7757. */
  7758. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7759. minimum: Vector3;
  7760. maximum: Vector3;
  7761. };
  7762. /**
  7763. * Extracts minimum and maximum values from a list of positions
  7764. * @param positions defines the positions to use
  7765. * @param start defines the start index in the positions array
  7766. * @param count defines the number of positions to handle
  7767. * @param bias defines bias value to add to the result
  7768. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7769. * @return minimum and maximum values
  7770. */
  7771. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7772. minimum: Vector3;
  7773. maximum: Vector3;
  7774. };
  7775. }
  7776. declare module BABYLON {
  7777. /**
  7778. * Class used to manipulate GUIDs
  7779. */
  7780. export class GUID {
  7781. /**
  7782. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7783. * Be aware Math.random() could cause collisions, but:
  7784. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7785. * @returns a pseudo random id
  7786. */
  7787. static RandomId(): string;
  7788. }
  7789. }
  7790. declare module BABYLON {
  7791. /**
  7792. * Base class of all the textures in babylon.
  7793. * It groups all the common properties the materials, post process, lights... might need
  7794. * in order to make a correct use of the texture.
  7795. */
  7796. export class BaseTexture extends ThinTexture implements IAnimatable {
  7797. /**
  7798. * Default anisotropic filtering level for the application.
  7799. * It is set to 4 as a good tradeoff between perf and quality.
  7800. */
  7801. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7802. /**
  7803. * Gets or sets the unique id of the texture
  7804. */
  7805. uniqueId: number;
  7806. /**
  7807. * Define the name of the texture.
  7808. */
  7809. name: string;
  7810. /**
  7811. * Gets or sets an object used to store user defined information.
  7812. */
  7813. metadata: any;
  7814. /**
  7815. * For internal use only. Please do not use.
  7816. */
  7817. reservedDataStore: any;
  7818. private _hasAlpha;
  7819. /**
  7820. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7821. */
  7822. set hasAlpha(value: boolean);
  7823. get hasAlpha(): boolean;
  7824. /**
  7825. * Defines if the alpha value should be determined via the rgb values.
  7826. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7827. */
  7828. getAlphaFromRGB: boolean;
  7829. /**
  7830. * Intensity or strength of the texture.
  7831. * It is commonly used by materials to fine tune the intensity of the texture
  7832. */
  7833. level: number;
  7834. /**
  7835. * Define the UV channel to use starting from 0 and defaulting to 0.
  7836. * This is part of the texture as textures usually maps to one uv set.
  7837. */
  7838. coordinatesIndex: number;
  7839. protected _coordinatesMode: number;
  7840. /**
  7841. * How a texture is mapped.
  7842. *
  7843. * | Value | Type | Description |
  7844. * | ----- | ----------------------------------- | ----------- |
  7845. * | 0 | EXPLICIT_MODE | |
  7846. * | 1 | SPHERICAL_MODE | |
  7847. * | 2 | PLANAR_MODE | |
  7848. * | 3 | CUBIC_MODE | |
  7849. * | 4 | PROJECTION_MODE | |
  7850. * | 5 | SKYBOX_MODE | |
  7851. * | 6 | INVCUBIC_MODE | |
  7852. * | 7 | EQUIRECTANGULAR_MODE | |
  7853. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7854. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7855. */
  7856. set coordinatesMode(value: number);
  7857. get coordinatesMode(): number;
  7858. /**
  7859. * | Value | Type | Description |
  7860. * | ----- | ------------------ | ----------- |
  7861. * | 0 | CLAMP_ADDRESSMODE | |
  7862. * | 1 | WRAP_ADDRESSMODE | |
  7863. * | 2 | MIRROR_ADDRESSMODE | |
  7864. */
  7865. get wrapU(): number;
  7866. set wrapU(value: number);
  7867. /**
  7868. * | Value | Type | Description |
  7869. * | ----- | ------------------ | ----------- |
  7870. * | 0 | CLAMP_ADDRESSMODE | |
  7871. * | 1 | WRAP_ADDRESSMODE | |
  7872. * | 2 | MIRROR_ADDRESSMODE | |
  7873. */
  7874. get wrapV(): number;
  7875. set wrapV(value: number);
  7876. /**
  7877. * | Value | Type | Description |
  7878. * | ----- | ------------------ | ----------- |
  7879. * | 0 | CLAMP_ADDRESSMODE | |
  7880. * | 1 | WRAP_ADDRESSMODE | |
  7881. * | 2 | MIRROR_ADDRESSMODE | |
  7882. */
  7883. wrapR: number;
  7884. /**
  7885. * With compliant hardware and browser (supporting anisotropic filtering)
  7886. * this defines the level of anisotropic filtering in the texture.
  7887. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7888. */
  7889. anisotropicFilteringLevel: number;
  7890. private _isCube;
  7891. /**
  7892. * Define if the texture is a cube texture or if false a 2d texture.
  7893. */
  7894. get isCube(): boolean;
  7895. set isCube(value: boolean);
  7896. /**
  7897. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7898. */
  7899. get is3D(): boolean;
  7900. set is3D(value: boolean);
  7901. /**
  7902. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7903. */
  7904. get is2DArray(): boolean;
  7905. set is2DArray(value: boolean);
  7906. private _gammaSpace;
  7907. /**
  7908. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7909. * HDR texture are usually stored in linear space.
  7910. * This only impacts the PBR and Background materials
  7911. */
  7912. get gammaSpace(): boolean;
  7913. set gammaSpace(gamma: boolean);
  7914. /**
  7915. * Gets or sets whether or not the texture contains RGBD data.
  7916. */
  7917. get isRGBD(): boolean;
  7918. set isRGBD(value: boolean);
  7919. /**
  7920. * Is Z inverted in the texture (useful in a cube texture).
  7921. */
  7922. invertZ: boolean;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. /**
  7928. * @hidden
  7929. */
  7930. lodLevelInAlpha: boolean;
  7931. /**
  7932. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7933. */
  7934. get lodGenerationOffset(): number;
  7935. set lodGenerationOffset(value: number);
  7936. /**
  7937. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7938. */
  7939. get lodGenerationScale(): number;
  7940. set lodGenerationScale(value: number);
  7941. /**
  7942. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7943. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7944. * average roughness values.
  7945. */
  7946. get linearSpecularLOD(): boolean;
  7947. set linearSpecularLOD(value: boolean);
  7948. /**
  7949. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7950. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7951. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7952. */
  7953. get irradianceTexture(): Nullable<BaseTexture>;
  7954. set irradianceTexture(value: Nullable<BaseTexture>);
  7955. /**
  7956. * Define if the texture is a render target.
  7957. */
  7958. isRenderTarget: boolean;
  7959. /**
  7960. * Define the unique id of the texture in the scene.
  7961. */
  7962. get uid(): string;
  7963. /** @hidden */
  7964. _prefiltered: boolean;
  7965. /**
  7966. * Return a string representation of the texture.
  7967. * @returns the texture as a string
  7968. */
  7969. toString(): string;
  7970. /**
  7971. * Get the class name of the texture.
  7972. * @returns "BaseTexture"
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Define the list of animation attached to the texture.
  7977. */
  7978. animations: Animation[];
  7979. /**
  7980. * An event triggered when the texture is disposed.
  7981. */
  7982. onDisposeObservable: Observable<BaseTexture>;
  7983. private _onDisposeObserver;
  7984. /**
  7985. * Callback triggered when the texture has been disposed.
  7986. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7987. */
  7988. set onDispose(callback: () => void);
  7989. protected _scene: Nullable<Scene>;
  7990. /** @hidden */
  7991. _texture: Nullable<InternalTexture>;
  7992. private _uid;
  7993. /**
  7994. * Define if the texture is preventing a material to render or not.
  7995. * If not and the texture is not ready, the engine will use a default black texture instead.
  7996. */
  7997. get isBlocking(): boolean;
  7998. /**
  7999. * Instantiates a new BaseTexture.
  8000. * Base class of all the textures in babylon.
  8001. * It groups all the common properties the materials, post process, lights... might need
  8002. * in order to make a correct use of the texture.
  8003. * @param sceneOrEngine Define the scene or engine the texture belongs to
  8004. */
  8005. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8006. /**
  8007. * Get the scene the texture belongs to.
  8008. * @returns the scene or null if undefined
  8009. */
  8010. getScene(): Nullable<Scene>;
  8011. /** @hidden */
  8012. protected _getEngine(): Nullable<ThinEngine>;
  8013. /**
  8014. * Checks if the texture has the same transform matrix than another texture
  8015. * @param texture texture to check against
  8016. * @returns true if the transforms are the same, else false
  8017. */
  8018. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8019. /**
  8020. * Get the texture transform matrix used to offset tile the texture for instance.
  8021. * @returns the transformation matrix
  8022. */
  8023. getTextureMatrix(): Matrix;
  8024. /**
  8025. * Get the texture reflection matrix used to rotate/transform the reflection.
  8026. * @returns the reflection matrix
  8027. */
  8028. getReflectionTextureMatrix(): Matrix;
  8029. /**
  8030. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8031. * @returns true if ready or not blocking
  8032. */
  8033. isReadyOrNotBlocking(): boolean;
  8034. /**
  8035. * Scales the texture if is `canRescale()`
  8036. * @param ratio the resize factor we want to use to rescale
  8037. */
  8038. scale(ratio: number): void;
  8039. /**
  8040. * Get if the texture can rescale.
  8041. */
  8042. get canRescale(): boolean;
  8043. /** @hidden */
  8044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8045. /** @hidden */
  8046. _rebuild(): void;
  8047. /**
  8048. * Clones the texture.
  8049. * @returns the cloned texture
  8050. */
  8051. clone(): Nullable<BaseTexture>;
  8052. /**
  8053. * Get the texture underlying type (INT, FLOAT...)
  8054. */
  8055. get textureType(): number;
  8056. /**
  8057. * Get the texture underlying format (RGB, RGBA...)
  8058. */
  8059. get textureFormat(): number;
  8060. /**
  8061. * Indicates that textures need to be re-calculated for all materials
  8062. */
  8063. protected _markAllSubMeshesAsTexturesDirty(): void;
  8064. /**
  8065. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8066. * This will returns an RGBA array buffer containing either in values (0-255) or
  8067. * float values (0-1) depending of the underlying buffer type.
  8068. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8069. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8070. * @param buffer defines a user defined buffer to fill with data (can be null)
  8071. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8072. * @returns The Array buffer promise containing the pixels data.
  8073. */
  8074. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8075. /** @hidden */
  8076. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8077. /** @hidden */
  8078. get _lodTextureHigh(): Nullable<BaseTexture>;
  8079. /** @hidden */
  8080. get _lodTextureMid(): Nullable<BaseTexture>;
  8081. /** @hidden */
  8082. get _lodTextureLow(): Nullable<BaseTexture>;
  8083. /**
  8084. * Dispose the texture and release its associated resources.
  8085. */
  8086. dispose(): void;
  8087. /**
  8088. * Serialize the texture into a JSON representation that can be parsed later on.
  8089. * @returns the JSON representation of the texture
  8090. */
  8091. serialize(): any;
  8092. /**
  8093. * Helper function to be called back once a list of texture contains only ready textures.
  8094. * @param textures Define the list of textures to wait for
  8095. * @param callback Define the callback triggered once the entire list will be ready
  8096. */
  8097. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8098. private static _isScene;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /** @hidden */
  8103. export class WebGLDataBuffer extends DataBuffer {
  8104. private _buffer;
  8105. constructor(resource: WebGLBuffer);
  8106. get underlyingResource(): any;
  8107. }
  8108. }
  8109. declare module BABYLON {
  8110. /** @hidden */
  8111. export class WebGLPipelineContext implements IPipelineContext {
  8112. private _valueCache;
  8113. private _uniforms;
  8114. engine: ThinEngine;
  8115. program: Nullable<WebGLProgram>;
  8116. context?: WebGLRenderingContext;
  8117. vertexShader?: WebGLShader;
  8118. fragmentShader?: WebGLShader;
  8119. isParallelCompiled: boolean;
  8120. onCompiled?: () => void;
  8121. transformFeedback?: WebGLTransformFeedback | null;
  8122. vertexCompilationError: Nullable<string>;
  8123. fragmentCompilationError: Nullable<string>;
  8124. programLinkError: Nullable<string>;
  8125. programValidationError: Nullable<string>;
  8126. get isAsync(): boolean;
  8127. get isReady(): boolean;
  8128. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8129. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8130. [key: string]: number;
  8131. }, uniformsNames: string[], uniforms: {
  8132. [key: string]: Nullable<WebGLUniformLocation>;
  8133. }, samplerList: string[], samplers: {
  8134. [key: string]: number;
  8135. }, attributesNames: string[], attributes: number[]): void;
  8136. /**
  8137. * Release all associated resources.
  8138. **/
  8139. dispose(): void;
  8140. /** @hidden */
  8141. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8142. /** @hidden */
  8143. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8144. /** @hidden */
  8145. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8146. /** @hidden */
  8147. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8148. /**
  8149. * Sets an integer value on a uniform variable.
  8150. * @param uniformName Name of the variable.
  8151. * @param value Value to be set.
  8152. */
  8153. setInt(uniformName: string, value: number): void;
  8154. /**
  8155. * Sets a int2 on a uniform variable.
  8156. * @param uniformName Name of the variable.
  8157. * @param x First int in int2.
  8158. * @param y Second int in int2.
  8159. */
  8160. setInt2(uniformName: string, x: number, y: number): void;
  8161. /**
  8162. * Sets a int3 on a uniform variable.
  8163. * @param uniformName Name of the variable.
  8164. * @param x First int in int3.
  8165. * @param y Second int in int3.
  8166. * @param y Third int in int3.
  8167. */
  8168. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8169. /**
  8170. * Sets a int4 on a uniform variable.
  8171. * @param uniformName Name of the variable.
  8172. * @param x First int in int4.
  8173. * @param y Second int in int4.
  8174. * @param y Third int in int4.
  8175. * @param w Fourth int in int4.
  8176. */
  8177. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8178. /**
  8179. * Sets an int array on a uniform variable.
  8180. * @param uniformName Name of the variable.
  8181. * @param array array to be set.
  8182. */
  8183. setIntArray(uniformName: string, array: Int32Array): void;
  8184. /**
  8185. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8186. * @param uniformName Name of the variable.
  8187. * @param array array to be set.
  8188. */
  8189. setIntArray2(uniformName: string, array: Int32Array): void;
  8190. /**
  8191. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray3(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setIntArray4(uniformName: string, array: Int32Array): void;
  8202. /**
  8203. * Sets an array on a uniform variable.
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setArray(uniformName: string, array: number[]): void;
  8208. /**
  8209. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. */
  8213. setArray2(uniformName: string, array: number[]): void;
  8214. /**
  8215. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8216. * @param uniformName Name of the variable.
  8217. * @param array array to be set.
  8218. * @returns this effect.
  8219. */
  8220. setArray3(uniformName: string, array: number[]): void;
  8221. /**
  8222. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8223. * @param uniformName Name of the variable.
  8224. * @param array array to be set.
  8225. */
  8226. setArray4(uniformName: string, array: number[]): void;
  8227. /**
  8228. * Sets matrices on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param matrices matrices to be set.
  8231. */
  8232. setMatrices(uniformName: string, matrices: Float32Array): void;
  8233. /**
  8234. * Sets matrix on a uniform variable.
  8235. * @param uniformName Name of the variable.
  8236. * @param matrix matrix to be set.
  8237. */
  8238. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8239. /**
  8240. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8241. * @param uniformName Name of the variable.
  8242. * @param matrix matrix to be set.
  8243. */
  8244. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8245. /**
  8246. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8247. * @param uniformName Name of the variable.
  8248. * @param matrix matrix to be set.
  8249. */
  8250. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8251. /**
  8252. * Sets a float on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param value value to be set.
  8255. * @returns this effect.
  8256. */
  8257. setFloat(uniformName: string, value: number): void;
  8258. /**
  8259. * Sets a Vector2 on a uniform variable.
  8260. * @param uniformName Name of the variable.
  8261. * @param vector2 vector2 to be set.
  8262. */
  8263. setVector2(uniformName: string, vector2: IVector2Like): void;
  8264. /**
  8265. * Sets a float2 on a uniform variable.
  8266. * @param uniformName Name of the variable.
  8267. * @param x First float in float2.
  8268. * @param y Second float in float2.
  8269. */
  8270. setFloat2(uniformName: string, x: number, y: number): void;
  8271. /**
  8272. * Sets a Vector3 on a uniform variable.
  8273. * @param uniformName Name of the variable.
  8274. * @param vector3 Value to be set.
  8275. */
  8276. setVector3(uniformName: string, vector3: IVector3Like): void;
  8277. /**
  8278. * Sets a float3 on a uniform variable.
  8279. * @param uniformName Name of the variable.
  8280. * @param x First float in float3.
  8281. * @param y Second float in float3.
  8282. * @param z Third float in float3.
  8283. */
  8284. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8285. /**
  8286. * Sets a Vector4 on a uniform variable.
  8287. * @param uniformName Name of the variable.
  8288. * @param vector4 Value to be set.
  8289. */
  8290. setVector4(uniformName: string, vector4: IVector4Like): void;
  8291. /**
  8292. * Sets a float4 on a uniform variable.
  8293. * @param uniformName Name of the variable.
  8294. * @param x First float in float4.
  8295. * @param y Second float in float4.
  8296. * @param z Third float in float4.
  8297. * @param w Fourth float in float4.
  8298. * @returns this effect.
  8299. */
  8300. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8301. /**
  8302. * Sets a Color3 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param color3 Value to be set.
  8305. */
  8306. setColor3(uniformName: string, color3: IColor3Like): void;
  8307. /**
  8308. * Sets a Color4 on a uniform variable.
  8309. * @param uniformName Name of the variable.
  8310. * @param color3 Value to be set.
  8311. * @param alpha Alpha value to be set.
  8312. */
  8313. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8314. /**
  8315. * Sets a Color4 on a uniform variable
  8316. * @param uniformName defines the name of the variable
  8317. * @param color4 defines the value to be set
  8318. */
  8319. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8320. _getVertexShaderCode(): string | null;
  8321. _getFragmentShaderCode(): string | null;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. interface ThinEngine {
  8326. /**
  8327. * Create an uniform buffer
  8328. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8329. * @param elements defines the content of the uniform buffer
  8330. * @returns the webGL uniform buffer
  8331. */
  8332. createUniformBuffer(elements: FloatArray): DataBuffer;
  8333. /**
  8334. * Create a dynamic uniform buffer
  8335. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8336. * @param elements defines the content of the uniform buffer
  8337. * @returns the webGL uniform buffer
  8338. */
  8339. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8340. /**
  8341. * Update an existing uniform buffer
  8342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8343. * @param uniformBuffer defines the target uniform buffer
  8344. * @param elements defines the content to update
  8345. * @param offset defines the offset in the uniform buffer where update should start
  8346. * @param count defines the size of the data to update
  8347. */
  8348. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8349. /**
  8350. * Bind an uniform buffer to the current webGL context
  8351. * @param buffer defines the buffer to bind
  8352. */
  8353. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8354. /**
  8355. * Bind a buffer to the current webGL context at a given location
  8356. * @param buffer defines the buffer to bind
  8357. * @param location defines the index where to bind the buffer
  8358. * @param name Name of the uniform variable to bind
  8359. */
  8360. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8361. /**
  8362. * Bind a specific block at a given index in a specific shader program
  8363. * @param pipelineContext defines the pipeline context to use
  8364. * @param blockName defines the block name
  8365. * @param index defines the index where to bind the block
  8366. */
  8367. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8368. }
  8369. }
  8370. declare module BABYLON {
  8371. /**
  8372. * Uniform buffer objects.
  8373. *
  8374. * Handles blocks of uniform on the GPU.
  8375. *
  8376. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8377. *
  8378. * For more information, please refer to :
  8379. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8380. */
  8381. export class UniformBuffer {
  8382. /** @hidden */
  8383. static _updatedUbosInFrame: {
  8384. [name: string]: number;
  8385. };
  8386. private _engine;
  8387. private _buffer;
  8388. private _buffers;
  8389. private _bufferIndex;
  8390. private _createBufferOnWrite;
  8391. private _data;
  8392. private _bufferData;
  8393. private _dynamic?;
  8394. private _uniformLocations;
  8395. private _uniformSizes;
  8396. private _uniformArraySizes;
  8397. private _uniformLocationPointer;
  8398. private _needSync;
  8399. private _noUBO;
  8400. private _currentEffect;
  8401. private _currentEffectName;
  8402. private _name;
  8403. private _currentFrameId;
  8404. /** @hidden */
  8405. _alreadyBound: boolean;
  8406. private static _MAX_UNIFORM_SIZE;
  8407. private static _tempBuffer;
  8408. private static _tempBufferInt32View;
  8409. /**
  8410. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8415. /**
  8416. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8421. /**
  8422. * Lambda to Update a single float in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateFloat: (name: string, x: number) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of float in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of float in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of float in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Lambda to Update an array of float in a uniform buffer.
  8447. * This is dynamic to allow compat with webgl 1 and 2.
  8448. * You will need to pass the name of the uniform as well as the value.
  8449. */
  8450. updateFloatArray: (name: string, array: Float32Array) => void;
  8451. /**
  8452. * Lambda to Update an array of number in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateArray: (name: string, array: number[]) => void;
  8457. /**
  8458. * Lambda to Update an array of number in a uniform buffer.
  8459. * This is dynamic to allow compat with webgl 1 and 2.
  8460. * You will need to pass the name of the uniform as well as the value.
  8461. */
  8462. updateIntArray: (name: string, array: Int32Array) => void;
  8463. /**
  8464. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8469. /**
  8470. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8471. * This is dynamic to allow compat with webgl 1 and 2.
  8472. * You will need to pass the name of the uniform as well as the value.
  8473. */
  8474. updateMatrices: (name: string, mat: Float32Array) => void;
  8475. /**
  8476. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateVector3: (name: string, vector: Vector3) => void;
  8481. /**
  8482. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8483. * This is dynamic to allow compat with webgl 1 and 2.
  8484. * You will need to pass the name of the uniform as well as the value.
  8485. */
  8486. updateVector4: (name: string, vector: Vector4) => void;
  8487. /**
  8488. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8489. * This is dynamic to allow compat with webgl 1 and 2.
  8490. * You will need to pass the name of the uniform as well as the value.
  8491. */
  8492. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8493. /**
  8494. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8495. * This is dynamic to allow compat with webgl 1 and 2.
  8496. * You will need to pass the name of the uniform as well as the value.
  8497. */
  8498. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8499. /**
  8500. * Lambda to Update a int a uniform buffer.
  8501. * This is dynamic to allow compat with webgl 1 and 2.
  8502. * You will need to pass the name of the uniform as well as the value.
  8503. */
  8504. updateInt: (name: string, x: number, suffix?: string) => void;
  8505. /**
  8506. * Lambda to Update a vec2 of int in a uniform buffer.
  8507. * This is dynamic to allow compat with webgl 1 and 2.
  8508. * You will need to pass the name of the uniform as well as the value.
  8509. */
  8510. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8511. /**
  8512. * Lambda to Update a vec3 of int in a uniform buffer.
  8513. * This is dynamic to allow compat with webgl 1 and 2.
  8514. * You will need to pass the name of the uniform as well as the value.
  8515. */
  8516. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8517. /**
  8518. * Lambda to Update a vec4 of int in a uniform buffer.
  8519. * This is dynamic to allow compat with webgl 1 and 2.
  8520. * You will need to pass the name of the uniform as well as the value.
  8521. */
  8522. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8523. /**
  8524. * Instantiates a new Uniform buffer objects.
  8525. *
  8526. * Handles blocks of uniform on the GPU.
  8527. *
  8528. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8529. *
  8530. * For more information, please refer to :
  8531. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8532. * @param engine Define the engine the buffer is associated with
  8533. * @param data Define the data contained in the buffer
  8534. * @param dynamic Define if the buffer is updatable
  8535. * @param name to assign to the buffer (debugging purpose)
  8536. */
  8537. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8538. /**
  8539. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8540. * or just falling back on setUniformXXX calls.
  8541. */
  8542. get useUbo(): boolean;
  8543. /**
  8544. * Indicates if the WebGL underlying uniform buffer is in sync
  8545. * with the javascript cache data.
  8546. */
  8547. get isSync(): boolean;
  8548. /**
  8549. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8550. * Also, a dynamic UniformBuffer will disable cache verification and always
  8551. * update the underlying WebGL uniform buffer to the GPU.
  8552. * @returns if Dynamic, otherwise false
  8553. */
  8554. isDynamic(): boolean;
  8555. /**
  8556. * The data cache on JS side.
  8557. * @returns the underlying data as a float array
  8558. */
  8559. getData(): Float32Array;
  8560. /**
  8561. * The underlying WebGL Uniform buffer.
  8562. * @returns the webgl buffer
  8563. */
  8564. getBuffer(): Nullable<DataBuffer>;
  8565. /**
  8566. * std140 layout specifies how to align data within an UBO structure.
  8567. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8568. * for specs.
  8569. */
  8570. private _fillAlignment;
  8571. /**
  8572. * Adds an uniform in the buffer.
  8573. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8574. * for the layout to be correct !
  8575. * @param name Name of the uniform, as used in the uniform block in the shader.
  8576. * @param size Data size, or data directly.
  8577. * @param arraySize The number of elements in the array, 0 if not an array.
  8578. */
  8579. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8580. /**
  8581. * Adds a Matrix 4x4 to the uniform buffer.
  8582. * @param name Name of the uniform, as used in the uniform block in the shader.
  8583. * @param mat A 4x4 matrix.
  8584. */
  8585. addMatrix(name: string, mat: Matrix): void;
  8586. /**
  8587. * Adds a vec2 to the uniform buffer.
  8588. * @param name Name of the uniform, as used in the uniform block in the shader.
  8589. * @param x Define the x component value of the vec2
  8590. * @param y Define the y component value of the vec2
  8591. */
  8592. addFloat2(name: string, x: number, y: number): void;
  8593. /**
  8594. * Adds a vec3 to the uniform buffer.
  8595. * @param name Name of the uniform, as used in the uniform block in the shader.
  8596. * @param x Define the x component value of the vec3
  8597. * @param y Define the y component value of the vec3
  8598. * @param z Define the z component value of the vec3
  8599. */
  8600. addFloat3(name: string, x: number, y: number, z: number): void;
  8601. /**
  8602. * Adds a vec3 to the uniform buffer.
  8603. * @param name Name of the uniform, as used in the uniform block in the shader.
  8604. * @param color Define the vec3 from a Color
  8605. */
  8606. addColor3(name: string, color: Color3): void;
  8607. /**
  8608. * Adds a vec4 to the uniform buffer.
  8609. * @param name Name of the uniform, as used in the uniform block in the shader.
  8610. * @param color Define the rgb components from a Color
  8611. * @param alpha Define the a component of the vec4
  8612. */
  8613. addColor4(name: string, color: Color3, alpha: number): void;
  8614. /**
  8615. * Adds a vec3 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. * @param vector Define the vec3 components from a Vector
  8618. */
  8619. addVector3(name: string, vector: Vector3): void;
  8620. /**
  8621. * Adds a Matrix 3x3 to the uniform buffer.
  8622. * @param name Name of the uniform, as used in the uniform block in the shader.
  8623. */
  8624. addMatrix3x3(name: string): void;
  8625. /**
  8626. * Adds a Matrix 2x2 to the uniform buffer.
  8627. * @param name Name of the uniform, as used in the uniform block in the shader.
  8628. */
  8629. addMatrix2x2(name: string): void;
  8630. /**
  8631. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8632. */
  8633. create(): void;
  8634. /** @hidden */
  8635. _rebuild(): void;
  8636. /** @hidden */
  8637. get _numBuffers(): number;
  8638. /** @hidden */
  8639. get _indexBuffer(): number;
  8640. /** Gets the name of this buffer */
  8641. get name(): string;
  8642. /**
  8643. * Updates the WebGL Uniform Buffer on the GPU.
  8644. * If the `dynamic` flag is set to true, no cache comparison is done.
  8645. * Otherwise, the buffer will be updated only if the cache differs.
  8646. */
  8647. update(): void;
  8648. private _createNewBuffer;
  8649. private _checkNewFrame;
  8650. /**
  8651. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8652. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8653. * @param data Define the flattened data
  8654. * @param size Define the size of the data.
  8655. */
  8656. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8657. /**
  8658. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8659. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8660. * @param data Define the flattened data
  8661. * @param size Define the size of the data.
  8662. */
  8663. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8664. private _valueCache;
  8665. private _cacheMatrix;
  8666. private _updateMatrix3x3ForUniform;
  8667. private _updateMatrix3x3ForEffect;
  8668. private _updateMatrix2x2ForEffect;
  8669. private _updateMatrix2x2ForUniform;
  8670. private _updateFloatForEffect;
  8671. private _updateFloatForUniform;
  8672. private _updateFloat2ForEffect;
  8673. private _updateFloat2ForUniform;
  8674. private _updateFloat3ForEffect;
  8675. private _updateFloat3ForUniform;
  8676. private _updateFloat4ForEffect;
  8677. private _updateFloat4ForUniform;
  8678. private _updateFloatArrayForEffect;
  8679. private _updateFloatArrayForUniform;
  8680. private _updateArrayForEffect;
  8681. private _updateArrayForUniform;
  8682. private _updateIntArrayForEffect;
  8683. private _updateIntArrayForUniform;
  8684. private _updateMatrixForEffect;
  8685. private _updateMatrixForUniform;
  8686. private _updateMatricesForEffect;
  8687. private _updateMatricesForUniform;
  8688. private _updateVector3ForEffect;
  8689. private _updateVector3ForUniform;
  8690. private _updateVector4ForEffect;
  8691. private _updateVector4ForUniform;
  8692. private _updateColor3ForEffect;
  8693. private _updateColor3ForUniform;
  8694. private _updateColor4ForEffect;
  8695. private _updateColor4ForUniform;
  8696. private _updateIntForEffect;
  8697. private _updateIntForUniform;
  8698. private _updateInt2ForEffect;
  8699. private _updateInt2ForUniform;
  8700. private _updateInt3ForEffect;
  8701. private _updateInt3ForUniform;
  8702. private _updateInt4ForEffect;
  8703. private _updateInt4ForUniform;
  8704. /**
  8705. * Sets a sampler uniform on the effect.
  8706. * @param name Define the name of the sampler.
  8707. * @param texture Define the texture to set in the sampler
  8708. */
  8709. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8710. /**
  8711. * Directly updates the value of the uniform in the cache AND on the GPU.
  8712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8713. * @param data Define the flattened data
  8714. */
  8715. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8716. /**
  8717. * Binds this uniform buffer to an effect.
  8718. * @param effect Define the effect to bind the buffer to
  8719. * @param name Name of the uniform block in the shader.
  8720. */
  8721. bindToEffect(effect: Effect, name: string): void;
  8722. /**
  8723. * Disposes the uniform buffer.
  8724. */
  8725. dispose(): void;
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Manages the defines for the Material
  8731. */
  8732. export class MaterialDefines {
  8733. /** @hidden */
  8734. protected _keys: string[];
  8735. private _isDirty;
  8736. /** @hidden */
  8737. _renderId: number;
  8738. /** @hidden */
  8739. _areLightsDirty: boolean;
  8740. /** @hidden */
  8741. _areLightsDisposed: boolean;
  8742. /** @hidden */
  8743. _areAttributesDirty: boolean;
  8744. /** @hidden */
  8745. _areTexturesDirty: boolean;
  8746. /** @hidden */
  8747. _areFresnelDirty: boolean;
  8748. /** @hidden */
  8749. _areMiscDirty: boolean;
  8750. /** @hidden */
  8751. _arePrePassDirty: boolean;
  8752. /** @hidden */
  8753. _areImageProcessingDirty: boolean;
  8754. /** @hidden */
  8755. _normals: boolean;
  8756. /** @hidden */
  8757. _uvs: boolean;
  8758. /** @hidden */
  8759. _needNormals: boolean;
  8760. /** @hidden */
  8761. _needUVs: boolean;
  8762. [id: string]: any;
  8763. /**
  8764. * Specifies if the material needs to be re-calculated
  8765. */
  8766. get isDirty(): boolean;
  8767. /**
  8768. * Marks the material to indicate that it has been re-calculated
  8769. */
  8770. markAsProcessed(): void;
  8771. /**
  8772. * Marks the material to indicate that it needs to be re-calculated
  8773. */
  8774. markAsUnprocessed(): void;
  8775. /**
  8776. * Marks the material to indicate all of its defines need to be re-calculated
  8777. */
  8778. markAllAsDirty(): void;
  8779. /**
  8780. * Marks the material to indicate that image processing needs to be re-calculated
  8781. */
  8782. markAsImageProcessingDirty(): void;
  8783. /**
  8784. * Marks the material to indicate the lights need to be re-calculated
  8785. * @param disposed Defines whether the light is dirty due to dispose or not
  8786. */
  8787. markAsLightDirty(disposed?: boolean): void;
  8788. /**
  8789. * Marks the attribute state as changed
  8790. */
  8791. markAsAttributesDirty(): void;
  8792. /**
  8793. * Marks the texture state as changed
  8794. */
  8795. markAsTexturesDirty(): void;
  8796. /**
  8797. * Marks the fresnel state as changed
  8798. */
  8799. markAsFresnelDirty(): void;
  8800. /**
  8801. * Marks the misc state as changed
  8802. */
  8803. markAsMiscDirty(): void;
  8804. /**
  8805. * Marks the prepass state as changed
  8806. */
  8807. markAsPrePassDirty(): void;
  8808. /**
  8809. * Rebuilds the material defines
  8810. */
  8811. rebuild(): void;
  8812. /**
  8813. * Specifies if two material defines are equal
  8814. * @param other - A material define instance to compare to
  8815. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8816. */
  8817. isEqual(other: MaterialDefines): boolean;
  8818. /**
  8819. * Clones this instance's defines to another instance
  8820. * @param other - material defines to clone values to
  8821. */
  8822. cloneTo(other: MaterialDefines): void;
  8823. /**
  8824. * Resets the material define values
  8825. */
  8826. reset(): void;
  8827. /**
  8828. * Converts the material define values to a string
  8829. * @returns - String of material define information
  8830. */
  8831. toString(): string;
  8832. }
  8833. }
  8834. declare module BABYLON {
  8835. /**
  8836. * Enum that determines the text-wrapping mode to use.
  8837. */
  8838. export enum InspectableType {
  8839. /**
  8840. * Checkbox for booleans
  8841. */
  8842. Checkbox = 0,
  8843. /**
  8844. * Sliders for numbers
  8845. */
  8846. Slider = 1,
  8847. /**
  8848. * Vector3
  8849. */
  8850. Vector3 = 2,
  8851. /**
  8852. * Quaternions
  8853. */
  8854. Quaternion = 3,
  8855. /**
  8856. * Color3
  8857. */
  8858. Color3 = 4,
  8859. /**
  8860. * String
  8861. */
  8862. String = 5
  8863. }
  8864. /**
  8865. * Interface used to define custom inspectable properties.
  8866. * This interface is used by the inspector to display custom property grids
  8867. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8868. */
  8869. export interface IInspectable {
  8870. /**
  8871. * Gets the label to display
  8872. */
  8873. label: string;
  8874. /**
  8875. * Gets the name of the property to edit
  8876. */
  8877. propertyName: string;
  8878. /**
  8879. * Gets the type of the editor to use
  8880. */
  8881. type: InspectableType;
  8882. /**
  8883. * Gets the minimum value of the property when using in "slider" mode
  8884. */
  8885. min?: number;
  8886. /**
  8887. * Gets the maximum value of the property when using in "slider" mode
  8888. */
  8889. max?: number;
  8890. /**
  8891. * Gets the setp to use when using in "slider" mode
  8892. */
  8893. step?: number;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8900. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  8901. */
  8902. export abstract class Light extends Node {
  8903. /**
  8904. * Falloff Default: light is falling off following the material specification:
  8905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8906. */
  8907. static readonly FALLOFF_DEFAULT: number;
  8908. /**
  8909. * Falloff Physical: light is falling off following the inverse squared distance law.
  8910. */
  8911. static readonly FALLOFF_PHYSICAL: number;
  8912. /**
  8913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8914. * to enhance interoperability with other engines.
  8915. */
  8916. static readonly FALLOFF_GLTF: number;
  8917. /**
  8918. * Falloff Standard: light is falling off like in the standard material
  8919. * to enhance interoperability with other materials.
  8920. */
  8921. static readonly FALLOFF_STANDARD: number;
  8922. /**
  8923. * If every light affecting the material is in this lightmapMode,
  8924. * material.lightmapTexture adds or multiplies
  8925. * (depends on material.useLightmapAsShadowmap)
  8926. * after every other light calculations.
  8927. */
  8928. static readonly LIGHTMAP_DEFAULT: number;
  8929. /**
  8930. * material.lightmapTexture as only diffuse lighting from this light
  8931. * adds only specular lighting from this light
  8932. * adds dynamic shadows
  8933. */
  8934. static readonly LIGHTMAP_SPECULAR: number;
  8935. /**
  8936. * material.lightmapTexture as only lighting
  8937. * no light calculation from this light
  8938. * only adds dynamic shadows from this light
  8939. */
  8940. static readonly LIGHTMAP_SHADOWSONLY: number;
  8941. /**
  8942. * Each light type uses the default quantity according to its type:
  8943. * point/spot lights use luminous intensity
  8944. * directional lights use illuminance
  8945. */
  8946. static readonly INTENSITYMODE_AUTOMATIC: number;
  8947. /**
  8948. * lumen (lm)
  8949. */
  8950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8951. /**
  8952. * candela (lm/sr)
  8953. */
  8954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8955. /**
  8956. * lux (lm/m^2)
  8957. */
  8958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8959. /**
  8960. * nit (cd/m^2)
  8961. */
  8962. static readonly INTENSITYMODE_LUMINANCE: number;
  8963. /**
  8964. * Light type const id of the point light.
  8965. */
  8966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8967. /**
  8968. * Light type const id of the directional light.
  8969. */
  8970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8971. /**
  8972. * Light type const id of the spot light.
  8973. */
  8974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8975. /**
  8976. * Light type const id of the hemispheric light.
  8977. */
  8978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8979. /**
  8980. * Diffuse gives the basic color to an object.
  8981. */
  8982. diffuse: Color3;
  8983. /**
  8984. * Specular produces a highlight color on an object.
  8985. * Note: This is note affecting PBR materials.
  8986. */
  8987. specular: Color3;
  8988. /**
  8989. * Defines the falloff type for this light. This lets overriding how punctual light are
  8990. * falling off base on range or angle.
  8991. * This can be set to any values in Light.FALLOFF_x.
  8992. *
  8993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8994. * other types of materials.
  8995. */
  8996. falloffType: number;
  8997. /**
  8998. * Strength of the light.
  8999. * Note: By default it is define in the framework own unit.
  9000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9001. */
  9002. intensity: number;
  9003. private _range;
  9004. protected _inverseSquaredRange: number;
  9005. /**
  9006. * Defines how far from the source the light is impacting in scene units.
  9007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9008. */
  9009. get range(): number;
  9010. /**
  9011. * Defines how far from the source the light is impacting in scene units.
  9012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9013. */
  9014. set range(value: number);
  9015. /**
  9016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9017. * of light.
  9018. */
  9019. private _photometricScale;
  9020. private _intensityMode;
  9021. /**
  9022. * Gets the photometric scale used to interpret the intensity.
  9023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9024. */
  9025. get intensityMode(): number;
  9026. /**
  9027. * Sets the photometric scale used to interpret the intensity.
  9028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9029. */
  9030. set intensityMode(value: number);
  9031. private _radius;
  9032. /**
  9033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9034. */
  9035. get radius(): number;
  9036. /**
  9037. * sets the light radius used by PBR Materials to simulate soft area lights.
  9038. */
  9039. set radius(value: number);
  9040. private _renderPriority;
  9041. /**
  9042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9043. * exceeding the number allowed of the materials.
  9044. */
  9045. renderPriority: number;
  9046. private _shadowEnabled;
  9047. /**
  9048. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9049. * the current shadow generator.
  9050. */
  9051. get shadowEnabled(): boolean;
  9052. /**
  9053. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9054. * the current shadow generator.
  9055. */
  9056. set shadowEnabled(value: boolean);
  9057. private _includedOnlyMeshes;
  9058. /**
  9059. * Gets the only meshes impacted by this light.
  9060. */
  9061. get includedOnlyMeshes(): AbstractMesh[];
  9062. /**
  9063. * Sets the only meshes impacted by this light.
  9064. */
  9065. set includedOnlyMeshes(value: AbstractMesh[]);
  9066. private _excludedMeshes;
  9067. /**
  9068. * Gets the meshes not impacted by this light.
  9069. */
  9070. get excludedMeshes(): AbstractMesh[];
  9071. /**
  9072. * Sets the meshes not impacted by this light.
  9073. */
  9074. set excludedMeshes(value: AbstractMesh[]);
  9075. private _excludeWithLayerMask;
  9076. /**
  9077. * Gets the layer id use to find what meshes are not impacted by the light.
  9078. * Inactive if 0
  9079. */
  9080. get excludeWithLayerMask(): number;
  9081. /**
  9082. * Sets the layer id use to find what meshes are not impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. set excludeWithLayerMask(value: number);
  9086. private _includeOnlyWithLayerMask;
  9087. /**
  9088. * Gets the layer id use to find what meshes are impacted by the light.
  9089. * Inactive if 0
  9090. */
  9091. get includeOnlyWithLayerMask(): number;
  9092. /**
  9093. * Sets the layer id use to find what meshes are impacted by the light.
  9094. * Inactive if 0
  9095. */
  9096. set includeOnlyWithLayerMask(value: number);
  9097. private _lightmapMode;
  9098. /**
  9099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9100. */
  9101. get lightmapMode(): number;
  9102. /**
  9103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9104. */
  9105. set lightmapMode(value: number);
  9106. /**
  9107. * Shadow generator associated to the light.
  9108. * @hidden Internal use only.
  9109. */
  9110. _shadowGenerator: Nullable<IShadowGenerator>;
  9111. /**
  9112. * @hidden Internal use only.
  9113. */
  9114. _excludedMeshesIds: string[];
  9115. /**
  9116. * @hidden Internal use only.
  9117. */
  9118. _includedOnlyMeshesIds: string[];
  9119. /**
  9120. * The current light uniform buffer.
  9121. * @hidden Internal use only.
  9122. */
  9123. _uniformBuffer: UniformBuffer;
  9124. /** @hidden */
  9125. _renderId: number;
  9126. /**
  9127. * Creates a Light object in the scene.
  9128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9129. * @param name The friendly name of the light
  9130. * @param scene The scene the light belongs too
  9131. */
  9132. constructor(name: string, scene: Scene);
  9133. protected abstract _buildUniformLayout(): void;
  9134. /**
  9135. * Sets the passed Effect "effect" with the Light information.
  9136. * @param effect The effect to update
  9137. * @param lightIndex The index of the light in the effect to update
  9138. * @returns The light
  9139. */
  9140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9141. /**
  9142. * Sets the passed Effect "effect" with the Light textures.
  9143. * @param effect The effect to update
  9144. * @param lightIndex The index of the light in the effect to update
  9145. * @returns The light
  9146. */
  9147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9148. /**
  9149. * Binds the lights information from the scene to the effect for the given mesh.
  9150. * @param lightIndex Light index
  9151. * @param scene The scene where the light belongs to
  9152. * @param effect The effect we are binding the data to
  9153. * @param useSpecular Defines if specular is supported
  9154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9155. */
  9156. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9157. /**
  9158. * Sets the passed Effect "effect" with the Light information.
  9159. * @param effect The effect to update
  9160. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9161. * @returns The light
  9162. */
  9163. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9164. /**
  9165. * Returns the string "Light".
  9166. * @returns the class name
  9167. */
  9168. getClassName(): string;
  9169. /** @hidden */
  9170. readonly _isLight: boolean;
  9171. /**
  9172. * Converts the light information to a readable string for debug purpose.
  9173. * @param fullDetails Supports for multiple levels of logging within scene loading
  9174. * @returns the human readable light info
  9175. */
  9176. toString(fullDetails?: boolean): string;
  9177. /** @hidden */
  9178. protected _syncParentEnabledState(): void;
  9179. /**
  9180. * Set the enabled state of this node.
  9181. * @param value - the new enabled state
  9182. */
  9183. setEnabled(value: boolean): void;
  9184. /**
  9185. * Returns the Light associated shadow generator if any.
  9186. * @return the associated shadow generator.
  9187. */
  9188. getShadowGenerator(): Nullable<IShadowGenerator>;
  9189. /**
  9190. * Returns a Vector3, the absolute light position in the World.
  9191. * @returns the world space position of the light
  9192. */
  9193. getAbsolutePosition(): Vector3;
  9194. /**
  9195. * Specifies if the light will affect the passed mesh.
  9196. * @param mesh The mesh to test against the light
  9197. * @return true the mesh is affected otherwise, false.
  9198. */
  9199. canAffectMesh(mesh: AbstractMesh): boolean;
  9200. /**
  9201. * Sort function to order lights for rendering.
  9202. * @param a First Light object to compare to second.
  9203. * @param b Second Light object to compare first.
  9204. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9205. */
  9206. static CompareLightsPriority(a: Light, b: Light): number;
  9207. /**
  9208. * Releases resources associated with this node.
  9209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9211. */
  9212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9213. /**
  9214. * Returns the light type ID (integer).
  9215. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9216. */
  9217. getTypeID(): number;
  9218. /**
  9219. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9220. * @returns the scaled intensity in intensity mode unit
  9221. */
  9222. getScaledIntensity(): number;
  9223. /**
  9224. * Returns a new Light object, named "name", from the current one.
  9225. * @param name The name of the cloned light
  9226. * @param newParent The parent of this light, if it has one
  9227. * @returns the new created light
  9228. */
  9229. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9230. /**
  9231. * Serializes the current light into a Serialization object.
  9232. * @returns the serialized object.
  9233. */
  9234. serialize(): any;
  9235. /**
  9236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9237. * This new light is named "name" and added to the passed scene.
  9238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9239. * @param name The friendly name of the light
  9240. * @param scene The scene the new light will belong to
  9241. * @returns the constructor function
  9242. */
  9243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9244. /**
  9245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9246. * @param parsedLight The JSON representation of the light
  9247. * @param scene The scene to create the parsed light in
  9248. * @returns the created light after parsing
  9249. */
  9250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9251. private _hookArrayForExcluded;
  9252. private _hookArrayForIncludedOnly;
  9253. private _resyncMeshes;
  9254. /**
  9255. * Forces the meshes to update their light related information in their rendering used effects
  9256. * @hidden Internal Use Only
  9257. */
  9258. _markMeshesAsLightDirty(): void;
  9259. /**
  9260. * Recomputes the cached photometric scale if needed.
  9261. */
  9262. private _computePhotometricScale;
  9263. /**
  9264. * Returns the Photometric Scale according to the light type and intensity mode.
  9265. */
  9266. private _getPhotometricScale;
  9267. /**
  9268. * Reorder the light in the scene according to their defined priority.
  9269. * @hidden Internal Use Only
  9270. */
  9271. _reorderLightsInScene(): void;
  9272. /**
  9273. * Prepares the list of defines specific to the light type.
  9274. * @param defines the list of defines
  9275. * @param lightIndex defines the index of the light for the effect
  9276. */
  9277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9278. }
  9279. }
  9280. declare module BABYLON {
  9281. /** Defines supported spaces */
  9282. export enum Space {
  9283. /** Local (object) space */
  9284. LOCAL = 0,
  9285. /** World space */
  9286. WORLD = 1,
  9287. /** Bone space */
  9288. BONE = 2
  9289. }
  9290. /** Defines the 3 main axes */
  9291. export class Axis {
  9292. /** X axis */
  9293. static X: Vector3;
  9294. /** Y axis */
  9295. static Y: Vector3;
  9296. /** Z axis */
  9297. static Z: Vector3;
  9298. }
  9299. /**
  9300. * Defines cartesian components.
  9301. */
  9302. export enum Coordinate {
  9303. /** X axis */
  9304. X = 0,
  9305. /** Y axis */
  9306. Y = 1,
  9307. /** Z axis */
  9308. Z = 2
  9309. }
  9310. }
  9311. declare module BABYLON {
  9312. /**
  9313. * Interface describing all the common properties and methods a shadow light needs to implement.
  9314. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9315. * as well as binding the different shadow properties to the effects.
  9316. */
  9317. export interface IShadowLight extends Light {
  9318. /**
  9319. * The light id in the scene (used in scene.findLightById for instance)
  9320. */
  9321. id: string;
  9322. /**
  9323. * The position the shadow will be casted from.
  9324. */
  9325. position: Vector3;
  9326. /**
  9327. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9328. */
  9329. direction: Vector3;
  9330. /**
  9331. * The transformed position. Position of the light in world space taking parenting in account.
  9332. */
  9333. transformedPosition: Vector3;
  9334. /**
  9335. * The transformed direction. Direction of the light in world space taking parenting in account.
  9336. */
  9337. transformedDirection: Vector3;
  9338. /**
  9339. * The friendly name of the light in the scene.
  9340. */
  9341. name: string;
  9342. /**
  9343. * Defines the shadow projection clipping minimum z value.
  9344. */
  9345. shadowMinZ: number;
  9346. /**
  9347. * Defines the shadow projection clipping maximum z value.
  9348. */
  9349. shadowMaxZ: number;
  9350. /**
  9351. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9352. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9353. */
  9354. computeTransformedInformation(): boolean;
  9355. /**
  9356. * Gets the scene the light belongs to.
  9357. * @returns The scene
  9358. */
  9359. getScene(): Scene;
  9360. /**
  9361. * Callback defining a custom Projection Matrix Builder.
  9362. * This can be used to override the default projection matrix computation.
  9363. */
  9364. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9365. /**
  9366. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9367. * @param matrix The matrix to updated with the projection information
  9368. * @param viewMatrix The transform matrix of the light
  9369. * @param renderList The list of mesh to render in the map
  9370. * @returns The current light
  9371. */
  9372. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9373. /**
  9374. * Gets the current depth scale used in ESM.
  9375. * @returns The scale
  9376. */
  9377. getDepthScale(): number;
  9378. /**
  9379. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9380. * @returns true if a cube texture needs to be use
  9381. */
  9382. needCube(): boolean;
  9383. /**
  9384. * Detects if the projection matrix requires to be recomputed this frame.
  9385. * @returns true if it requires to be recomputed otherwise, false.
  9386. */
  9387. needProjectionMatrixCompute(): boolean;
  9388. /**
  9389. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9390. */
  9391. forceProjectionMatrixCompute(): void;
  9392. /**
  9393. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9394. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9395. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9396. */
  9397. getShadowDirection(faceIndex?: number): Vector3;
  9398. /**
  9399. * Gets the minZ used for shadow according to both the scene and the light.
  9400. * @param activeCamera The camera we are returning the min for
  9401. * @returns the depth min z
  9402. */
  9403. getDepthMinZ(activeCamera: Camera): number;
  9404. /**
  9405. * Gets the maxZ used for shadow according to both the scene and the light.
  9406. * @param activeCamera The camera we are returning the max for
  9407. * @returns the depth max z
  9408. */
  9409. getDepthMaxZ(activeCamera: Camera): number;
  9410. }
  9411. /**
  9412. * Base implementation IShadowLight
  9413. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9414. */
  9415. export abstract class ShadowLight extends Light implements IShadowLight {
  9416. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9417. protected _position: Vector3;
  9418. protected _setPosition(value: Vector3): void;
  9419. /**
  9420. * Sets the position the shadow will be casted from. Also use as the light position for both
  9421. * point and spot lights.
  9422. */
  9423. get position(): Vector3;
  9424. /**
  9425. * Sets the position the shadow will be casted from. Also use as the light position for both
  9426. * point and spot lights.
  9427. */
  9428. set position(value: Vector3);
  9429. protected _direction: Vector3;
  9430. protected _setDirection(value: Vector3): void;
  9431. /**
  9432. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9433. * Also use as the light direction on spot and directional lights.
  9434. */
  9435. get direction(): Vector3;
  9436. /**
  9437. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9438. * Also use as the light direction on spot and directional lights.
  9439. */
  9440. set direction(value: Vector3);
  9441. protected _shadowMinZ: number;
  9442. /**
  9443. * Gets the shadow projection clipping minimum z value.
  9444. */
  9445. get shadowMinZ(): number;
  9446. /**
  9447. * Sets the shadow projection clipping minimum z value.
  9448. */
  9449. set shadowMinZ(value: number);
  9450. protected _shadowMaxZ: number;
  9451. /**
  9452. * Sets the shadow projection clipping maximum z value.
  9453. */
  9454. get shadowMaxZ(): number;
  9455. /**
  9456. * Gets the shadow projection clipping maximum z value.
  9457. */
  9458. set shadowMaxZ(value: number);
  9459. /**
  9460. * Callback defining a custom Projection Matrix Builder.
  9461. * This can be used to override the default projection matrix computation.
  9462. */
  9463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9464. /**
  9465. * The transformed position. Position of the light in world space taking parenting in account.
  9466. */
  9467. transformedPosition: Vector3;
  9468. /**
  9469. * The transformed direction. Direction of the light in world space taking parenting in account.
  9470. */
  9471. transformedDirection: Vector3;
  9472. private _needProjectionMatrixCompute;
  9473. /**
  9474. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9475. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9476. */
  9477. computeTransformedInformation(): boolean;
  9478. /**
  9479. * Return the depth scale used for the shadow map.
  9480. * @returns the depth scale.
  9481. */
  9482. getDepthScale(): number;
  9483. /**
  9484. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9485. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9486. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9487. */
  9488. getShadowDirection(faceIndex?: number): Vector3;
  9489. /**
  9490. * Returns the ShadowLight absolute position in the World.
  9491. * @returns the position vector in world space
  9492. */
  9493. getAbsolutePosition(): Vector3;
  9494. /**
  9495. * Sets the ShadowLight direction toward the passed target.
  9496. * @param target The point to target in local space
  9497. * @returns the updated ShadowLight direction
  9498. */
  9499. setDirectionToTarget(target: Vector3): Vector3;
  9500. /**
  9501. * Returns the light rotation in euler definition.
  9502. * @returns the x y z rotation in local space.
  9503. */
  9504. getRotation(): Vector3;
  9505. /**
  9506. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9507. * @returns true if a cube texture needs to be use
  9508. */
  9509. needCube(): boolean;
  9510. /**
  9511. * Detects if the projection matrix requires to be recomputed this frame.
  9512. * @returns true if it requires to be recomputed otherwise, false.
  9513. */
  9514. needProjectionMatrixCompute(): boolean;
  9515. /**
  9516. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9517. */
  9518. forceProjectionMatrixCompute(): void;
  9519. /** @hidden */
  9520. _initCache(): void;
  9521. /** @hidden */
  9522. _isSynchronized(): boolean;
  9523. /**
  9524. * Computes the world matrix of the node
  9525. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9526. * @returns the world matrix
  9527. */
  9528. computeWorldMatrix(force?: boolean): Matrix;
  9529. /**
  9530. * Gets the minZ used for shadow according to both the scene and the light.
  9531. * @param activeCamera The camera we are returning the min for
  9532. * @returns the depth min z
  9533. */
  9534. getDepthMinZ(activeCamera: Camera): number;
  9535. /**
  9536. * Gets the maxZ used for shadow according to both the scene and the light.
  9537. * @param activeCamera The camera we are returning the max for
  9538. * @returns the depth max z
  9539. */
  9540. getDepthMaxZ(activeCamera: Camera): number;
  9541. /**
  9542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9543. * @param matrix The matrix to updated with the projection information
  9544. * @param viewMatrix The transform matrix of the light
  9545. * @param renderList The list of mesh to render in the map
  9546. * @returns The current light
  9547. */
  9548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9549. }
  9550. }
  9551. declare module BABYLON {
  9552. /**
  9553. * Configuration needed for prepass-capable materials
  9554. */
  9555. export class PrePassConfiguration {
  9556. /**
  9557. * Previous world matrices of meshes carrying this material
  9558. * Used for computing velocity
  9559. */
  9560. previousWorldMatrices: {
  9561. [index: number]: Matrix;
  9562. };
  9563. /**
  9564. * Previous view project matrix
  9565. * Used for computing velocity
  9566. */
  9567. previousViewProjection: Matrix;
  9568. /**
  9569. * Previous bones of meshes carrying this material
  9570. * Used for computing velocity
  9571. */
  9572. previousBones: {
  9573. [index: number]: Float32Array;
  9574. };
  9575. /**
  9576. * Add the required uniforms to the current list.
  9577. * @param uniforms defines the current uniform list.
  9578. */
  9579. static AddUniforms(uniforms: string[]): void;
  9580. /**
  9581. * Add the required samplers to the current list.
  9582. * @param samplers defines the current sampler list.
  9583. */
  9584. static AddSamplers(samplers: string[]): void;
  9585. /**
  9586. * Binds the material data.
  9587. * @param effect defines the effect to update
  9588. * @param scene defines the scene the material belongs to.
  9589. * @param mesh The mesh
  9590. * @param world World matrix of this mesh
  9591. * @param isFrozen Is the material frozen
  9592. */
  9593. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9599. * This is the base of the follow, arc rotate cameras and Free camera
  9600. * @see https://doc.babylonjs.com/features/cameras
  9601. */
  9602. export class TargetCamera extends Camera {
  9603. private static _RigCamTransformMatrix;
  9604. private static _TargetTransformMatrix;
  9605. private static _TargetFocalPoint;
  9606. private _tmpUpVector;
  9607. private _tmpTargetVector;
  9608. /**
  9609. * Define the current direction the camera is moving to
  9610. */
  9611. cameraDirection: Vector3;
  9612. /**
  9613. * Define the current rotation the camera is rotating to
  9614. */
  9615. cameraRotation: Vector2;
  9616. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9617. ignoreParentScaling: boolean;
  9618. /**
  9619. * When set, the up vector of the camera will be updated by the rotation of the camera
  9620. */
  9621. updateUpVectorFromRotation: boolean;
  9622. private _tmpQuaternion;
  9623. /**
  9624. * Define the current rotation of the camera
  9625. */
  9626. rotation: Vector3;
  9627. /**
  9628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9629. */
  9630. rotationQuaternion: Quaternion;
  9631. /**
  9632. * Define the current speed of the camera
  9633. */
  9634. speed: number;
  9635. /**
  9636. * Add constraint to the camera to prevent it to move freely in all directions and
  9637. * around all axis.
  9638. */
  9639. noRotationConstraint: boolean;
  9640. /**
  9641. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9642. * panning
  9643. */
  9644. invertRotation: boolean;
  9645. /**
  9646. * Speed multiplier for inverse camera panning
  9647. */
  9648. inverseRotationSpeed: number;
  9649. /**
  9650. * Define the current target of the camera as an object or a position.
  9651. */
  9652. lockedTarget: any;
  9653. /** @hidden */
  9654. _currentTarget: Vector3;
  9655. /** @hidden */
  9656. _initialFocalDistance: number;
  9657. /** @hidden */
  9658. _viewMatrix: Matrix;
  9659. /** @hidden */
  9660. _camMatrix: Matrix;
  9661. /** @hidden */
  9662. _cameraTransformMatrix: Matrix;
  9663. /** @hidden */
  9664. _cameraRotationMatrix: Matrix;
  9665. /** @hidden */
  9666. _referencePoint: Vector3;
  9667. /** @hidden */
  9668. _transformedReferencePoint: Vector3;
  9669. /** @hidden */
  9670. _reset: () => void;
  9671. private _defaultUp;
  9672. /**
  9673. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9674. * This is the base of the follow, arc rotate cameras and Free camera
  9675. * @see https://doc.babylonjs.com/features/cameras
  9676. * @param name Defines the name of the camera in the scene
  9677. * @param position Defines the start position of the camera in the scene
  9678. * @param scene Defines the scene the camera belongs to
  9679. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9680. */
  9681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9682. /**
  9683. * Gets the position in front of the camera at a given distance.
  9684. * @param distance The distance from the camera we want the position to be
  9685. * @returns the position
  9686. */
  9687. getFrontPosition(distance: number): Vector3;
  9688. /** @hidden */
  9689. _getLockedTargetPosition(): Nullable<Vector3>;
  9690. private _storedPosition;
  9691. private _storedRotation;
  9692. private _storedRotationQuaternion;
  9693. /**
  9694. * Store current camera state of the camera (fov, position, rotation, etc..)
  9695. * @returns the camera
  9696. */
  9697. storeState(): Camera;
  9698. /**
  9699. * Restored camera state. You must call storeState() first
  9700. * @returns whether it was successful or not
  9701. * @hidden
  9702. */
  9703. _restoreStateValues(): boolean;
  9704. /** @hidden */
  9705. _initCache(): void;
  9706. /** @hidden */
  9707. _updateCache(ignoreParentClass?: boolean): void;
  9708. /** @hidden */
  9709. _isSynchronizedViewMatrix(): boolean;
  9710. /** @hidden */
  9711. _computeLocalCameraSpeed(): number;
  9712. /**
  9713. * Defines the target the camera should look at.
  9714. * @param target Defines the new target as a Vector or a mesh
  9715. */
  9716. setTarget(target: Vector3): void;
  9717. /**
  9718. * Defines the target point of the camera.
  9719. * The camera looks towards it form the radius distance.
  9720. */
  9721. get target(): Vector3;
  9722. set target(value: Vector3);
  9723. /**
  9724. * Return the current target position of the camera. This value is expressed in local space.
  9725. * @returns the target position
  9726. */
  9727. getTarget(): Vector3;
  9728. /** @hidden */
  9729. _decideIfNeedsToMove(): boolean;
  9730. /** @hidden */
  9731. _updatePosition(): void;
  9732. /** @hidden */
  9733. _checkInputs(): void;
  9734. protected _updateCameraRotationMatrix(): void;
  9735. /**
  9736. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9737. * @returns the current camera
  9738. */
  9739. private _rotateUpVectorWithCameraRotationMatrix;
  9740. private _cachedRotationZ;
  9741. private _cachedQuaternionRotationZ;
  9742. /** @hidden */
  9743. _getViewMatrix(): Matrix;
  9744. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9745. /**
  9746. * @hidden
  9747. */
  9748. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9749. /**
  9750. * @hidden
  9751. */
  9752. _updateRigCameras(): void;
  9753. private _getRigCamPositionAndTarget;
  9754. /**
  9755. * Gets the current object class name.
  9756. * @return the class name
  9757. */
  9758. getClassName(): string;
  9759. }
  9760. }
  9761. declare module BABYLON {
  9762. /**
  9763. * @ignore
  9764. * This is a list of all the different input types that are available in the application.
  9765. * Fo instance: ArcRotateCameraGamepadInput...
  9766. */
  9767. export var CameraInputTypes: {};
  9768. /**
  9769. * This is the contract to implement in order to create a new input class.
  9770. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9771. */
  9772. export interface ICameraInput<TCamera extends Camera> {
  9773. /**
  9774. * Defines the camera the input is attached to.
  9775. */
  9776. camera: Nullable<TCamera>;
  9777. /**
  9778. * Gets the class name of the current input.
  9779. * @returns the class name
  9780. */
  9781. getClassName(): string;
  9782. /**
  9783. * Get the friendly name associated with the input class.
  9784. * @returns the input friendly name
  9785. */
  9786. getSimpleName(): string;
  9787. /**
  9788. * Attach the input controls to a specific dom element to get the input from.
  9789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9790. */
  9791. attachControl(noPreventDefault?: boolean): void;
  9792. /**
  9793. * Detach the current controls from the specified dom element.
  9794. */
  9795. detachControl(): void;
  9796. /**
  9797. * Update the current camera state depending on the inputs that have been used this frame.
  9798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9799. */
  9800. checkInputs?: () => void;
  9801. }
  9802. /**
  9803. * Represents a map of input types to input instance or input index to input instance.
  9804. */
  9805. export interface CameraInputsMap<TCamera extends Camera> {
  9806. /**
  9807. * Accessor to the input by input type.
  9808. */
  9809. [name: string]: ICameraInput<TCamera>;
  9810. /**
  9811. * Accessor to the input by input index.
  9812. */
  9813. [idx: number]: ICameraInput<TCamera>;
  9814. }
  9815. /**
  9816. * This represents the input manager used within a camera.
  9817. * It helps dealing with all the different kind of input attached to a camera.
  9818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9819. */
  9820. export class CameraInputsManager<TCamera extends Camera> {
  9821. /**
  9822. * Defines the list of inputs attached to the camera.
  9823. */
  9824. attached: CameraInputsMap<TCamera>;
  9825. /**
  9826. * Defines the dom element the camera is collecting inputs from.
  9827. * This is null if the controls have not been attached.
  9828. */
  9829. attachedToElement: boolean;
  9830. /**
  9831. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9832. */
  9833. noPreventDefault: boolean;
  9834. /**
  9835. * Defined the camera the input manager belongs to.
  9836. */
  9837. camera: TCamera;
  9838. /**
  9839. * Update the current camera state depending on the inputs that have been used this frame.
  9840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9841. */
  9842. checkInputs: () => void;
  9843. /**
  9844. * Instantiate a new Camera Input Manager.
  9845. * @param camera Defines the camera the input manager belongs to
  9846. */
  9847. constructor(camera: TCamera);
  9848. /**
  9849. * Add an input method to a camera
  9850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9851. * @param input camera input method
  9852. */
  9853. add(input: ICameraInput<TCamera>): void;
  9854. /**
  9855. * Remove a specific input method from a camera
  9856. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9857. * @param inputToRemove camera input method
  9858. */
  9859. remove(inputToRemove: ICameraInput<TCamera>): void;
  9860. /**
  9861. * Remove a specific input type from a camera
  9862. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9863. * @param inputType the type of the input to remove
  9864. */
  9865. removeByType(inputType: string): void;
  9866. private _addCheckInputs;
  9867. /**
  9868. * Attach the input controls to the currently attached dom element to listen the events from.
  9869. * @param input Defines the input to attach
  9870. */
  9871. attachInput(input: ICameraInput<TCamera>): void;
  9872. /**
  9873. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9874. * @param element Defines the dom element to collect the events from
  9875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9876. */
  9877. attachElement(noPreventDefault?: boolean): void;
  9878. /**
  9879. * Detach the current manager inputs controls from a specific dom element.
  9880. * @param element Defines the dom element to collect the events from
  9881. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9882. */
  9883. detachElement(disconnect?: boolean): void;
  9884. /**
  9885. * Rebuild the dynamic inputCheck function from the current list of
  9886. * defined inputs in the manager.
  9887. */
  9888. rebuildInputCheck(): void;
  9889. /**
  9890. * Remove all attached input methods from a camera
  9891. */
  9892. clear(): void;
  9893. /**
  9894. * Serialize the current input manager attached to a camera.
  9895. * This ensures than once parsed,
  9896. * the input associated to the camera will be identical to the current ones
  9897. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9898. */
  9899. serialize(serializedCamera: any): void;
  9900. /**
  9901. * Parses an input manager serialized JSON to restore the previous list of inputs
  9902. * and states associated to a camera.
  9903. * @param parsedCamera Defines the JSON to parse
  9904. */
  9905. parse(parsedCamera: any): void;
  9906. }
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Gather the list of keyboard event types as constants.
  9911. */
  9912. export class KeyboardEventTypes {
  9913. /**
  9914. * The keydown event is fired when a key becomes active (pressed).
  9915. */
  9916. static readonly KEYDOWN: number;
  9917. /**
  9918. * The keyup event is fired when a key has been released.
  9919. */
  9920. static readonly KEYUP: number;
  9921. }
  9922. /**
  9923. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9924. */
  9925. export class KeyboardInfo {
  9926. /**
  9927. * Defines the type of event (KeyboardEventTypes)
  9928. */
  9929. type: number;
  9930. /**
  9931. * Defines the related dom event
  9932. */
  9933. event: KeyboardEvent;
  9934. /**
  9935. * Instantiates a new keyboard info.
  9936. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9937. * @param type Defines the type of event (KeyboardEventTypes)
  9938. * @param event Defines the related dom event
  9939. */
  9940. constructor(
  9941. /**
  9942. * Defines the type of event (KeyboardEventTypes)
  9943. */
  9944. type: number,
  9945. /**
  9946. * Defines the related dom event
  9947. */
  9948. event: KeyboardEvent);
  9949. }
  9950. /**
  9951. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9952. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9953. */
  9954. export class KeyboardInfoPre extends KeyboardInfo {
  9955. /**
  9956. * Defines the type of event (KeyboardEventTypes)
  9957. */
  9958. type: number;
  9959. /**
  9960. * Defines the related dom event
  9961. */
  9962. event: KeyboardEvent;
  9963. /**
  9964. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9965. */
  9966. skipOnPointerObservable: boolean;
  9967. /**
  9968. * Instantiates a new keyboard pre info.
  9969. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9970. * @param type Defines the type of event (KeyboardEventTypes)
  9971. * @param event Defines the related dom event
  9972. */
  9973. constructor(
  9974. /**
  9975. * Defines the type of event (KeyboardEventTypes)
  9976. */
  9977. type: number,
  9978. /**
  9979. * Defines the related dom event
  9980. */
  9981. event: KeyboardEvent);
  9982. }
  9983. }
  9984. declare module BABYLON {
  9985. /**
  9986. * Manage the keyboard inputs to control the movement of a free camera.
  9987. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9988. */
  9989. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9990. /**
  9991. * Defines the camera the input is attached to.
  9992. */
  9993. camera: FreeCamera;
  9994. /**
  9995. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9996. */
  9997. keysUp: number[];
  9998. /**
  9999. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10000. */
  10001. keysUpward: number[];
  10002. /**
  10003. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10004. */
  10005. keysDown: number[];
  10006. /**
  10007. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10008. */
  10009. keysDownward: number[];
  10010. /**
  10011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10012. */
  10013. keysLeft: number[];
  10014. /**
  10015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10016. */
  10017. keysRight: number[];
  10018. private _keys;
  10019. private _onCanvasBlurObserver;
  10020. private _onKeyboardObserver;
  10021. private _engine;
  10022. private _scene;
  10023. /**
  10024. * Attach the input controls to a specific dom element to get the input from.
  10025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10026. */
  10027. attachControl(noPreventDefault?: boolean): void;
  10028. /**
  10029. * Detach the current controls from the specified dom element.
  10030. */
  10031. detachControl(): void;
  10032. /**
  10033. * Update the current camera state depending on the inputs that have been used this frame.
  10034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10035. */
  10036. checkInputs(): void;
  10037. /**
  10038. * Gets the class name of the current input.
  10039. * @returns the class name
  10040. */
  10041. getClassName(): string;
  10042. /** @hidden */
  10043. _onLostFocus(): void;
  10044. /**
  10045. * Get the friendly name associated with the input class.
  10046. * @returns the input friendly name
  10047. */
  10048. getSimpleName(): string;
  10049. }
  10050. }
  10051. declare module BABYLON {
  10052. /**
  10053. * Interface used to define Action
  10054. */
  10055. export interface IAction {
  10056. /**
  10057. * Trigger for the action
  10058. */
  10059. trigger: number;
  10060. /** Options of the trigger */
  10061. triggerOptions: any;
  10062. /**
  10063. * Gets the trigger parameters
  10064. * @returns the trigger parameters
  10065. */
  10066. getTriggerParameter(): any;
  10067. /**
  10068. * Internal only - executes current action event
  10069. * @hidden
  10070. */
  10071. _executeCurrent(evt?: ActionEvent): void;
  10072. /**
  10073. * Serialize placeholder for child classes
  10074. * @param parent of child
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. /**
  10079. * Internal only
  10080. * @hidden
  10081. */
  10082. _prepare(): void;
  10083. /**
  10084. * Internal only - manager for action
  10085. * @hidden
  10086. */
  10087. _actionManager: Nullable<AbstractActionManager>;
  10088. /**
  10089. * Adds action to chain of actions, may be a DoNothingAction
  10090. * @param action defines the next action to execute
  10091. * @returns The action passed in
  10092. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10093. */
  10094. then(action: IAction): IAction;
  10095. }
  10096. /**
  10097. * The action to be carried out following a trigger
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10099. */
  10100. export class Action implements IAction {
  10101. /** the trigger, with or without parameters, for the action */
  10102. triggerOptions: any;
  10103. /**
  10104. * Trigger for the action
  10105. */
  10106. trigger: number;
  10107. /**
  10108. * Internal only - manager for action
  10109. * @hidden
  10110. */
  10111. _actionManager: ActionManager;
  10112. private _nextActiveAction;
  10113. private _child;
  10114. private _condition?;
  10115. private _triggerParameter;
  10116. /**
  10117. * An event triggered prior to action being executed.
  10118. */
  10119. onBeforeExecuteObservable: Observable<Action>;
  10120. /**
  10121. * Creates a new Action
  10122. * @param triggerOptions the trigger, with or without parameters, for the action
  10123. * @param condition an optional determinant of action
  10124. */
  10125. constructor(
  10126. /** the trigger, with or without parameters, for the action */
  10127. triggerOptions: any, condition?: Condition);
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _prepare(): void;
  10133. /**
  10134. * Gets the trigger parameter
  10135. * @returns the trigger parameter
  10136. */
  10137. getTriggerParameter(): any;
  10138. /**
  10139. * Sets the trigger parameter
  10140. * @param value defines the new trigger parameter
  10141. */
  10142. setTriggerParameter(value: any): void;
  10143. /**
  10144. * Internal only - executes current action event
  10145. * @hidden
  10146. */
  10147. _executeCurrent(evt?: ActionEvent): void;
  10148. /**
  10149. * Execute placeholder for child classes
  10150. * @param evt optional action event
  10151. */
  10152. execute(evt?: ActionEvent): void;
  10153. /**
  10154. * Skips to next active action
  10155. */
  10156. skipToNextActiveAction(): void;
  10157. /**
  10158. * Adds action to chain of actions, may be a DoNothingAction
  10159. * @param action defines the next action to execute
  10160. * @returns The action passed in
  10161. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10162. */
  10163. then(action: Action): Action;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _getProperty(propertyPath: string): string;
  10169. /**
  10170. * Internal only
  10171. * @hidden
  10172. */
  10173. _getEffectiveTarget(target: any, propertyPath: string): any;
  10174. /**
  10175. * Serialize placeholder for child classes
  10176. * @param parent of child
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. /**
  10181. * Internal only called by serialize
  10182. * @hidden
  10183. */
  10184. protected _serialize(serializedAction: any, parent?: any): any;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. static _SerializeValueAsString: (value: any) => string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. static _GetTargetProperty: (target: Scene | Node) => {
  10195. name: string;
  10196. targetType: string;
  10197. value: string;
  10198. };
  10199. }
  10200. }
  10201. declare module BABYLON {
  10202. /**
  10203. * A Condition applied to an Action
  10204. */
  10205. export class Condition {
  10206. /**
  10207. * Internal only - manager for action
  10208. * @hidden
  10209. */
  10210. _actionManager: ActionManager;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. _evaluationId: number;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. _currentResult: boolean;
  10221. /**
  10222. * Creates a new Condition
  10223. * @param actionManager the manager of the action the condition is applied to
  10224. */
  10225. constructor(actionManager: ActionManager);
  10226. /**
  10227. * Check if the current condition is valid
  10228. * @returns a boolean
  10229. */
  10230. isValid(): boolean;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _getProperty(propertyPath: string): string;
  10236. /**
  10237. * Internal only
  10238. * @hidden
  10239. */
  10240. _getEffectiveTarget(target: any, propertyPath: string): any;
  10241. /**
  10242. * Serialize placeholder for child classes
  10243. * @returns the serialized object
  10244. */
  10245. serialize(): any;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. protected _serialize(serializedCondition: any): any;
  10251. }
  10252. /**
  10253. * Defines specific conditional operators as extensions of Condition
  10254. */
  10255. export class ValueCondition extends Condition {
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string;
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any;
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator: number;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */
  10266. private static _IsEqual;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. private static _IsDifferent;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. private static _IsGreater;
  10277. /**
  10278. * Internal only
  10279. * @hidden
  10280. */
  10281. private static _IsLesser;
  10282. /**
  10283. * returns the number for IsEqual
  10284. */
  10285. static get IsEqual(): number;
  10286. /**
  10287. * Returns the number for IsDifferent
  10288. */
  10289. static get IsDifferent(): number;
  10290. /**
  10291. * Returns the number for IsGreater
  10292. */
  10293. static get IsGreater(): number;
  10294. /**
  10295. * Returns the number for IsLesser
  10296. */
  10297. static get IsLesser(): number;
  10298. /**
  10299. * Internal only The action manager for the condition
  10300. * @hidden
  10301. */
  10302. _actionManager: ActionManager;
  10303. /**
  10304. * Internal only
  10305. * @hidden
  10306. */
  10307. private _target;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. private _effectiveTarget;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. private _property;
  10318. /**
  10319. * Creates a new ValueCondition
  10320. * @param actionManager manager for the action the condition applies to
  10321. * @param target for the action
  10322. * @param propertyPath path to specify the property of the target the conditional operator uses
  10323. * @param value the value compared by the conditional operator against the current value of the property
  10324. * @param operator the conditional operator, default ValueCondition.IsEqual
  10325. */
  10326. constructor(actionManager: ActionManager, target: any,
  10327. /** path to specify the property of the target the conditional operator uses */
  10328. propertyPath: string,
  10329. /** the value compared by the conditional operator against the current value of the property */
  10330. value: any,
  10331. /** the conditional operator, default ValueCondition.IsEqual */
  10332. operator?: number);
  10333. /**
  10334. * Compares the given value with the property value for the specified conditional operator
  10335. * @returns the result of the comparison
  10336. */
  10337. isValid(): boolean;
  10338. /**
  10339. * Serialize the ValueCondition into a JSON compatible object
  10340. * @returns serialization object
  10341. */
  10342. serialize(): any;
  10343. /**
  10344. * Gets the name of the conditional operator for the ValueCondition
  10345. * @param operator the conditional operator
  10346. * @returns the name
  10347. */
  10348. static GetOperatorName(operator: number): string;
  10349. }
  10350. /**
  10351. * Defines a predicate condition as an extension of Condition
  10352. */
  10353. export class PredicateCondition extends Condition {
  10354. /** defines the predicate function used to validate the condition */
  10355. predicate: () => boolean;
  10356. /**
  10357. * Internal only - manager for action
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Creates a new PredicateCondition
  10363. * @param actionManager manager for the action the condition applies to
  10364. * @param predicate defines the predicate function used to validate the condition
  10365. */
  10366. constructor(actionManager: ActionManager,
  10367. /** defines the predicate function used to validate the condition */
  10368. predicate: () => boolean);
  10369. /**
  10370. * @returns the validity of the predicate condition
  10371. */
  10372. isValid(): boolean;
  10373. }
  10374. /**
  10375. * Defines a state condition as an extension of Condition
  10376. */
  10377. export class StateCondition extends Condition {
  10378. /** Value to compare with target state */
  10379. value: string;
  10380. /**
  10381. * Internal only - manager for action
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Creates a new StateCondition
  10392. * @param actionManager manager for the action the condition applies to
  10393. * @param target of the condition
  10394. * @param value to compare with target state
  10395. */
  10396. constructor(actionManager: ActionManager, target: any,
  10397. /** Value to compare with target state */
  10398. value: string);
  10399. /**
  10400. * Gets a boolean indicating if the current condition is met
  10401. * @returns the validity of the state
  10402. */
  10403. isValid(): boolean;
  10404. /**
  10405. * Serialize the StateCondition into a JSON compatible object
  10406. * @returns serialization object
  10407. */
  10408. serialize(): any;
  10409. }
  10410. }
  10411. declare module BABYLON {
  10412. /**
  10413. * This defines an action responsible to toggle a boolean once triggered.
  10414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10415. */
  10416. export class SwitchBooleanAction extends Action {
  10417. /**
  10418. * The path to the boolean property in the target object
  10419. */
  10420. propertyPath: string;
  10421. private _target;
  10422. private _effectiveTarget;
  10423. private _property;
  10424. /**
  10425. * Instantiate the action
  10426. * @param triggerOptions defines the trigger options
  10427. * @param target defines the object containing the boolean
  10428. * @param propertyPath defines the path to the boolean property in the target object
  10429. * @param condition defines the trigger related conditions
  10430. */
  10431. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10432. /** @hidden */
  10433. _prepare(): void;
  10434. /**
  10435. * Execute the action toggle the boolean value.
  10436. */
  10437. execute(): void;
  10438. /**
  10439. * Serializes the actions and its related information.
  10440. * @param parent defines the object to serialize in
  10441. * @returns the serialized object
  10442. */
  10443. serialize(parent: any): any;
  10444. }
  10445. /**
  10446. * This defines an action responsible to set a the state field of the target
  10447. * to a desired value once triggered.
  10448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10449. */
  10450. export class SetStateAction extends Action {
  10451. /**
  10452. * The value to store in the state field.
  10453. */
  10454. value: string;
  10455. private _target;
  10456. /**
  10457. * Instantiate the action
  10458. * @param triggerOptions defines the trigger options
  10459. * @param target defines the object containing the state property
  10460. * @param value defines the value to store in the state field
  10461. * @param condition defines the trigger related conditions
  10462. */
  10463. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10464. /**
  10465. * Execute the action and store the value on the target state property.
  10466. */
  10467. execute(): void;
  10468. /**
  10469. * Serializes the actions and its related information.
  10470. * @param parent defines the object to serialize in
  10471. * @returns the serialized object
  10472. */
  10473. serialize(parent: any): any;
  10474. }
  10475. /**
  10476. * This defines an action responsible to set a property of the target
  10477. * to a desired value once triggered.
  10478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10479. */
  10480. export class SetValueAction extends Action {
  10481. /**
  10482. * The path of the property to set in the target.
  10483. */
  10484. propertyPath: string;
  10485. /**
  10486. * The value to set in the property
  10487. */
  10488. value: any;
  10489. private _target;
  10490. private _effectiveTarget;
  10491. private _property;
  10492. /**
  10493. * Instantiate the action
  10494. * @param triggerOptions defines the trigger options
  10495. * @param target defines the object containing the property
  10496. * @param propertyPath defines the path of the property to set in the target
  10497. * @param value defines the value to set in the property
  10498. * @param condition defines the trigger related conditions
  10499. */
  10500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10501. /** @hidden */
  10502. _prepare(): void;
  10503. /**
  10504. * Execute the action and set the targeted property to the desired value.
  10505. */
  10506. execute(): void;
  10507. /**
  10508. * Serializes the actions and its related information.
  10509. * @param parent defines the object to serialize in
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. }
  10514. /**
  10515. * This defines an action responsible to increment the target value
  10516. * to a desired value once triggered.
  10517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10518. */
  10519. export class IncrementValueAction extends Action {
  10520. /**
  10521. * The path of the property to increment in the target.
  10522. */
  10523. propertyPath: string;
  10524. /**
  10525. * The value we should increment the property by.
  10526. */
  10527. value: any;
  10528. private _target;
  10529. private _effectiveTarget;
  10530. private _property;
  10531. /**
  10532. * Instantiate the action
  10533. * @param triggerOptions defines the trigger options
  10534. * @param target defines the object containing the property
  10535. * @param propertyPath defines the path of the property to increment in the target
  10536. * @param value defines the value value we should increment the property by
  10537. * @param condition defines the trigger related conditions
  10538. */
  10539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10540. /** @hidden */
  10541. _prepare(): void;
  10542. /**
  10543. * Execute the action and increment the target of the value amount.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to start an animation once triggered.
  10555. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class PlayAnimationAction extends Action {
  10558. /**
  10559. * Where the animation should start (animation frame)
  10560. */
  10561. from: number;
  10562. /**
  10563. * Where the animation should stop (animation frame)
  10564. */
  10565. to: number;
  10566. /**
  10567. * Define if the animation should loop or stop after the first play.
  10568. */
  10569. loop?: boolean;
  10570. private _target;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the target animation or animation name
  10575. * @param from defines from where the animation should start (animation frame)
  10576. * @param to defines where the animation should stop (animation frame)
  10577. * @param loop defines if the animation should loop or stop after the first play
  10578. * @param condition defines the trigger related conditions
  10579. */
  10580. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10581. /** @hidden */
  10582. _prepare(): void;
  10583. /**
  10584. * Execute the action and play the animation.
  10585. */
  10586. execute(): void;
  10587. /**
  10588. * Serializes the actions and its related information.
  10589. * @param parent defines the object to serialize in
  10590. * @returns the serialized object
  10591. */
  10592. serialize(parent: any): any;
  10593. }
  10594. /**
  10595. * This defines an action responsible to stop an animation once triggered.
  10596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class StopAnimationAction extends Action {
  10599. private _target;
  10600. /**
  10601. * Instantiate the action
  10602. * @param triggerOptions defines the trigger options
  10603. * @param target defines the target animation or animation name
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions: any, target: any, condition?: Condition);
  10607. /** @hidden */
  10608. _prepare(): void;
  10609. /**
  10610. * Execute the action and stop the animation.
  10611. */
  10612. execute(): void;
  10613. /**
  10614. * Serializes the actions and its related information.
  10615. * @param parent defines the object to serialize in
  10616. * @returns the serialized object
  10617. */
  10618. serialize(parent: any): any;
  10619. }
  10620. /**
  10621. * This defines an action responsible that does nothing once triggered.
  10622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10623. */
  10624. export class DoNothingAction extends Action {
  10625. /**
  10626. * Instantiate the action
  10627. * @param triggerOptions defines the trigger options
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions?: any, condition?: Condition);
  10631. /**
  10632. * Execute the action and do nothing.
  10633. */
  10634. execute(): void;
  10635. /**
  10636. * Serializes the actions and its related information.
  10637. * @param parent defines the object to serialize in
  10638. * @returns the serialized object
  10639. */
  10640. serialize(parent: any): any;
  10641. }
  10642. /**
  10643. * This defines an action responsible to trigger several actions once triggered.
  10644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10645. */
  10646. export class CombineAction extends Action {
  10647. /**
  10648. * The list of aggregated animations to run.
  10649. */
  10650. children: Action[];
  10651. /**
  10652. * Instantiate the action
  10653. * @param triggerOptions defines the trigger options
  10654. * @param children defines the list of aggregated animations to run
  10655. * @param condition defines the trigger related conditions
  10656. */
  10657. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10658. /** @hidden */
  10659. _prepare(): void;
  10660. /**
  10661. * Execute the action and executes all the aggregated actions.
  10662. */
  10663. execute(evt: ActionEvent): void;
  10664. /**
  10665. * Serializes the actions and its related information.
  10666. * @param parent defines the object to serialize in
  10667. * @returns the serialized object
  10668. */
  10669. serialize(parent: any): any;
  10670. }
  10671. /**
  10672. * This defines an action responsible to run code (external event) once triggered.
  10673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class ExecuteCodeAction extends Action {
  10676. /**
  10677. * The callback function to run.
  10678. */
  10679. func: (evt: ActionEvent) => void;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param func defines the callback function to run
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10687. /**
  10688. * Execute the action and run the attached code.
  10689. */
  10690. execute(evt: ActionEvent): void;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set the parent property of the target once triggered.
  10694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SetParentAction extends Action {
  10697. private _parent;
  10698. private _target;
  10699. /**
  10700. * Instantiate the action
  10701. * @param triggerOptions defines the trigger options
  10702. * @param target defines the target containing the parent property
  10703. * @param parent defines from where the animation should start (animation frame)
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10707. /** @hidden */
  10708. _prepare(): void;
  10709. /**
  10710. * Execute the action and set the parent property.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10724. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10725. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class ActionManager extends AbstractActionManager {
  10728. /**
  10729. * Nothing
  10730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly NothingTrigger: number;
  10733. /**
  10734. * On pick
  10735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnPickTrigger: number;
  10738. /**
  10739. * On left pick
  10740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnLeftPickTrigger: number;
  10743. /**
  10744. * On right pick
  10745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnRightPickTrigger: number;
  10748. /**
  10749. * On center pick
  10750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnCenterPickTrigger: number;
  10753. /**
  10754. * On pick down
  10755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnPickDownTrigger: number;
  10758. /**
  10759. * On double pick
  10760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnDoublePickTrigger: number;
  10763. /**
  10764. * On pick up
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnPickUpTrigger: number;
  10768. /**
  10769. * On pick out.
  10770. * This trigger will only be raised if you also declared a OnPickDown
  10771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnPickOutTrigger: number;
  10774. /**
  10775. * On long press
  10776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnLongPressTrigger: number;
  10779. /**
  10780. * On pointer over
  10781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnPointerOverTrigger: number;
  10784. /**
  10785. * On pointer out
  10786. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPointerOutTrigger: number;
  10789. /**
  10790. * On every frame
  10791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10792. */
  10793. static readonly OnEveryFrameTrigger: number;
  10794. /**
  10795. * On intersection enter
  10796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10797. */
  10798. static readonly OnIntersectionEnterTrigger: number;
  10799. /**
  10800. * On intersection exit
  10801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10802. */
  10803. static readonly OnIntersectionExitTrigger: number;
  10804. /**
  10805. * On key down
  10806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10807. */
  10808. static readonly OnKeyDownTrigger: number;
  10809. /**
  10810. * On key up
  10811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10812. */
  10813. static readonly OnKeyUpTrigger: number;
  10814. private _scene;
  10815. /**
  10816. * Creates a new action manager
  10817. * @param scene defines the hosting scene
  10818. */
  10819. constructor(scene: Scene);
  10820. /**
  10821. * Releases all associated resources
  10822. */
  10823. dispose(): void;
  10824. /**
  10825. * Gets hosting scene
  10826. * @returns the hosting scene
  10827. */
  10828. getScene(): Scene;
  10829. /**
  10830. * Does this action manager handles actions of any of the given triggers
  10831. * @param triggers defines the triggers to be tested
  10832. * @return a boolean indicating whether one (or more) of the triggers is handled
  10833. */
  10834. hasSpecificTriggers(triggers: number[]): boolean;
  10835. /**
  10836. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10837. * speed.
  10838. * @param triggerA defines the trigger to be tested
  10839. * @param triggerB defines the trigger to be tested
  10840. * @return a boolean indicating whether one (or more) of the triggers is handled
  10841. */
  10842. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10843. /**
  10844. * Does this action manager handles actions of a given trigger
  10845. * @param trigger defines the trigger to be tested
  10846. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10847. * @return whether the trigger is handled
  10848. */
  10849. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10850. /**
  10851. * Does this action manager has pointer triggers
  10852. */
  10853. get hasPointerTriggers(): boolean;
  10854. /**
  10855. * Does this action manager has pick triggers
  10856. */
  10857. get hasPickTriggers(): boolean;
  10858. /**
  10859. * Registers an action to this action manager
  10860. * @param action defines the action to be registered
  10861. * @return the action amended (prepared) after registration
  10862. */
  10863. registerAction(action: IAction): Nullable<IAction>;
  10864. /**
  10865. * Unregisters an action to this action manager
  10866. * @param action defines the action to be unregistered
  10867. * @return a boolean indicating whether the action has been unregistered
  10868. */
  10869. unregisterAction(action: IAction): Boolean;
  10870. /**
  10871. * Process a specific trigger
  10872. * @param trigger defines the trigger to process
  10873. * @param evt defines the event details to be processed
  10874. */
  10875. processTrigger(trigger: number, evt?: IActionEvent): void;
  10876. /** @hidden */
  10877. _getEffectiveTarget(target: any, propertyPath: string): any;
  10878. /** @hidden */
  10879. _getProperty(propertyPath: string): string;
  10880. /**
  10881. * Serialize this manager to a JSON object
  10882. * @param name defines the property name to store this manager
  10883. * @returns a JSON representation of this manager
  10884. */
  10885. serialize(name: string): any;
  10886. /**
  10887. * Creates a new ActionManager from a JSON data
  10888. * @param parsedActions defines the JSON data to read from
  10889. * @param object defines the hosting mesh
  10890. * @param scene defines the hosting scene
  10891. */
  10892. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10893. /**
  10894. * Get a trigger name by index
  10895. * @param trigger defines the trigger index
  10896. * @returns a trigger name
  10897. */
  10898. static GetTriggerName(trigger: number): string;
  10899. }
  10900. }
  10901. declare module BABYLON {
  10902. /**
  10903. * Class representing a ray with position and direction
  10904. */
  10905. export class Ray {
  10906. /** origin point */
  10907. origin: Vector3;
  10908. /** direction */
  10909. direction: Vector3;
  10910. /** length of the ray */
  10911. length: number;
  10912. private static readonly _TmpVector3;
  10913. private _tmpRay;
  10914. /**
  10915. * Creates a new ray
  10916. * @param origin origin point
  10917. * @param direction direction
  10918. * @param length length of the ray
  10919. */
  10920. constructor(
  10921. /** origin point */
  10922. origin: Vector3,
  10923. /** direction */
  10924. direction: Vector3,
  10925. /** length of the ray */
  10926. length?: number);
  10927. /**
  10928. * Checks if the ray intersects a box
  10929. * This does not account for the ray length by design to improve perfs.
  10930. * @param minimum bound of the box
  10931. * @param maximum bound of the box
  10932. * @param intersectionTreshold extra extend to be added to the box in all direction
  10933. * @returns if the box was hit
  10934. */
  10935. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10936. /**
  10937. * Checks if the ray intersects a box
  10938. * This does not account for the ray lenght by design to improve perfs.
  10939. * @param box the bounding box to check
  10940. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10941. * @returns if the box was hit
  10942. */
  10943. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10944. /**
  10945. * If the ray hits a sphere
  10946. * @param sphere the bounding sphere to check
  10947. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10948. * @returns true if it hits the sphere
  10949. */
  10950. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10951. /**
  10952. * If the ray hits a triange
  10953. * @param vertex0 triangle vertex
  10954. * @param vertex1 triangle vertex
  10955. * @param vertex2 triangle vertex
  10956. * @returns intersection information if hit
  10957. */
  10958. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10959. /**
  10960. * Checks if ray intersects a plane
  10961. * @param plane the plane to check
  10962. * @returns the distance away it was hit
  10963. */
  10964. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10965. /**
  10966. * Calculate the intercept of a ray on a given axis
  10967. * @param axis to check 'x' | 'y' | 'z'
  10968. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10969. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10970. */
  10971. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10972. /**
  10973. * Checks if ray intersects a mesh
  10974. * @param mesh the mesh to check
  10975. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10976. * @returns picking info of the intersection
  10977. */
  10978. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10979. /**
  10980. * Checks if ray intersects a mesh
  10981. * @param meshes the meshes to check
  10982. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10983. * @param results array to store result in
  10984. * @returns Array of picking infos
  10985. */
  10986. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10987. private _comparePickingInfo;
  10988. private static smallnum;
  10989. private static rayl;
  10990. /**
  10991. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  10992. * @param sega the first point of the segment to test the intersection against
  10993. * @param segb the second point of the segment to test the intersection against
  10994. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10995. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10996. */
  10997. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10998. /**
  10999. * Update the ray from viewport position
  11000. * @param x position
  11001. * @param y y position
  11002. * @param viewportWidth viewport width
  11003. * @param viewportHeight viewport height
  11004. * @param world world matrix
  11005. * @param view view matrix
  11006. * @param projection projection matrix
  11007. * @returns this ray updated
  11008. */
  11009. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11010. /**
  11011. * Creates a ray with origin and direction of 0,0,0
  11012. * @returns the new ray
  11013. */
  11014. static Zero(): Ray;
  11015. /**
  11016. * Creates a new ray from screen space and viewport
  11017. * @param x position
  11018. * @param y y position
  11019. * @param viewportWidth viewport width
  11020. * @param viewportHeight viewport height
  11021. * @param world world matrix
  11022. * @param view view matrix
  11023. * @param projection projection matrix
  11024. * @returns new ray
  11025. */
  11026. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11027. /**
  11028. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11029. * transformed to the given world matrix.
  11030. * @param origin The origin point
  11031. * @param end The end point
  11032. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11033. * @returns the new ray
  11034. */
  11035. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11036. /**
  11037. * Transforms a ray by a matrix
  11038. * @param ray ray to transform
  11039. * @param matrix matrix to apply
  11040. * @returns the resulting new ray
  11041. */
  11042. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11043. /**
  11044. * Transforms a ray by a matrix
  11045. * @param ray ray to transform
  11046. * @param matrix matrix to apply
  11047. * @param result ray to store result in
  11048. */
  11049. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11050. /**
  11051. * Unproject a ray from screen space to object space
  11052. * @param sourceX defines the screen space x coordinate to use
  11053. * @param sourceY defines the screen space y coordinate to use
  11054. * @param viewportWidth defines the current width of the viewport
  11055. * @param viewportHeight defines the current height of the viewport
  11056. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11057. * @param view defines the view matrix to use
  11058. * @param projection defines the projection matrix to use
  11059. */
  11060. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11061. }
  11062. /**
  11063. * Type used to define predicate used to select faces when a mesh intersection is detected
  11064. */
  11065. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11066. interface Scene {
  11067. /** @hidden */
  11068. _tempPickingRay: Nullable<Ray>;
  11069. /** @hidden */
  11070. _cachedRayForTransform: Ray;
  11071. /** @hidden */
  11072. _pickWithRayInverseMatrix: Matrix;
  11073. /** @hidden */
  11074. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11075. /** @hidden */
  11076. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11077. /** @hidden */
  11078. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11079. }
  11080. }
  11081. declare module BABYLON {
  11082. /**
  11083. * Groups all the scene component constants in one place to ease maintenance.
  11084. * @hidden
  11085. */
  11086. export class SceneComponentConstants {
  11087. static readonly NAME_EFFECTLAYER: string;
  11088. static readonly NAME_LAYER: string;
  11089. static readonly NAME_LENSFLARESYSTEM: string;
  11090. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11091. static readonly NAME_PARTICLESYSTEM: string;
  11092. static readonly NAME_GAMEPAD: string;
  11093. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11094. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11095. static readonly NAME_PREPASSRENDERER: string;
  11096. static readonly NAME_DEPTHRENDERER: string;
  11097. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11098. static readonly NAME_SPRITE: string;
  11099. static readonly NAME_SUBSURFACE: string;
  11100. static readonly NAME_OUTLINERENDERER: string;
  11101. static readonly NAME_PROCEDURALTEXTURE: string;
  11102. static readonly NAME_SHADOWGENERATOR: string;
  11103. static readonly NAME_OCTREE: string;
  11104. static readonly NAME_PHYSICSENGINE: string;
  11105. static readonly NAME_AUDIO: string;
  11106. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11107. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11108. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11109. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11110. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11111. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11112. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11113. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11114. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11115. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11116. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11117. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11118. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11119. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11120. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11121. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11122. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11123. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11124. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11125. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11126. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11127. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11128. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11129. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11130. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11131. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11132. static readonly STEP_AFTERRENDER_AUDIO: number;
  11133. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11134. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11135. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11136. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11137. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11138. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11139. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11140. static readonly STEP_POINTERMOVE_SPRITE: number;
  11141. static readonly STEP_POINTERDOWN_SPRITE: number;
  11142. static readonly STEP_POINTERUP_SPRITE: number;
  11143. }
  11144. /**
  11145. * This represents a scene component.
  11146. *
  11147. * This is used to decouple the dependency the scene is having on the different workloads like
  11148. * layers, post processes...
  11149. */
  11150. export interface ISceneComponent {
  11151. /**
  11152. * The name of the component. Each component must have a unique name.
  11153. */
  11154. name: string;
  11155. /**
  11156. * The scene the component belongs to.
  11157. */
  11158. scene: Scene;
  11159. /**
  11160. * Register the component to one instance of a scene.
  11161. */
  11162. register(): void;
  11163. /**
  11164. * Rebuilds the elements related to this component in case of
  11165. * context lost for instance.
  11166. */
  11167. rebuild(): void;
  11168. /**
  11169. * Disposes the component and the associated ressources.
  11170. */
  11171. dispose(): void;
  11172. }
  11173. /**
  11174. * This represents a SERIALIZABLE scene component.
  11175. *
  11176. * This extends Scene Component to add Serialization methods on top.
  11177. */
  11178. export interface ISceneSerializableComponent extends ISceneComponent {
  11179. /**
  11180. * Adds all the elements from the container to the scene
  11181. * @param container the container holding the elements
  11182. */
  11183. addFromContainer(container: AbstractScene): void;
  11184. /**
  11185. * Removes all the elements in the container from the scene
  11186. * @param container contains the elements to remove
  11187. * @param dispose if the removed element should be disposed (default: false)
  11188. */
  11189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11190. /**
  11191. * Serializes the component data to the specified json object
  11192. * @param serializationObject The object to serialize to
  11193. */
  11194. serialize(serializationObject: any): void;
  11195. }
  11196. /**
  11197. * Strong typing of a Mesh related stage step action
  11198. */
  11199. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11200. /**
  11201. * Strong typing of a Evaluate Sub Mesh related stage step action
  11202. */
  11203. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11204. /**
  11205. * Strong typing of a pre active Mesh related stage step action
  11206. */
  11207. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11208. /**
  11209. * Strong typing of a Camera related stage step action
  11210. */
  11211. export type CameraStageAction = (camera: Camera) => void;
  11212. /**
  11213. * Strong typing of a Camera Frame buffer related stage step action
  11214. */
  11215. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11216. /**
  11217. * Strong typing of a Render Target related stage step action
  11218. */
  11219. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11220. /**
  11221. * Strong typing of a RenderingGroup related stage step action
  11222. */
  11223. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11224. /**
  11225. * Strong typing of a Mesh Render related stage step action
  11226. */
  11227. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11228. /**
  11229. * Strong typing of a simple stage step action
  11230. */
  11231. export type SimpleStageAction = () => void;
  11232. /**
  11233. * Strong typing of a render target action.
  11234. */
  11235. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11236. /**
  11237. * Strong typing of a pointer move action.
  11238. */
  11239. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11240. /**
  11241. * Strong typing of a pointer up/down action.
  11242. */
  11243. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11244. /**
  11245. * Representation of a stage in the scene (Basically a list of ordered steps)
  11246. * @hidden
  11247. */
  11248. export class Stage<T extends Function> extends Array<{
  11249. index: number;
  11250. component: ISceneComponent;
  11251. action: T;
  11252. }> {
  11253. /**
  11254. * Hide ctor from the rest of the world.
  11255. * @param items The items to add.
  11256. */
  11257. private constructor();
  11258. /**
  11259. * Creates a new Stage.
  11260. * @returns A new instance of a Stage
  11261. */
  11262. static Create<T extends Function>(): Stage<T>;
  11263. /**
  11264. * Registers a step in an ordered way in the targeted stage.
  11265. * @param index Defines the position to register the step in
  11266. * @param component Defines the component attached to the step
  11267. * @param action Defines the action to launch during the step
  11268. */
  11269. registerStep(index: number, component: ISceneComponent, action: T): void;
  11270. /**
  11271. * Clears all the steps from the stage.
  11272. */
  11273. clear(): void;
  11274. }
  11275. }
  11276. declare module BABYLON {
  11277. interface Scene {
  11278. /** @hidden */
  11279. _pointerOverSprite: Nullable<Sprite>;
  11280. /** @hidden */
  11281. _pickedDownSprite: Nullable<Sprite>;
  11282. /** @hidden */
  11283. _tempSpritePickingRay: Nullable<Ray>;
  11284. /**
  11285. * All of the sprite managers added to this scene
  11286. * @see https://doc.babylonjs.com/babylon101/sprites
  11287. */
  11288. spriteManagers: Array<ISpriteManager>;
  11289. /**
  11290. * An event triggered when sprites rendering is about to start
  11291. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11292. */
  11293. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11294. /**
  11295. * An event triggered when sprites rendering is done
  11296. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11297. */
  11298. onAfterSpritesRenderingObservable: Observable<Scene>;
  11299. /** @hidden */
  11300. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11301. /** Launch a ray to try to pick a sprite in the scene
  11302. * @param x position on screen
  11303. * @param y position on screen
  11304. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11305. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11306. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11307. * @returns a PickingInfo
  11308. */
  11309. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11310. /** Use the given ray to pick a sprite in the scene
  11311. * @param ray The ray (in world space) to use to pick meshes
  11312. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11313. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11314. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11315. * @returns a PickingInfo
  11316. */
  11317. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11318. /** @hidden */
  11319. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11320. /** Launch a ray to try to pick sprites in the scene
  11321. * @param x position on screen
  11322. * @param y position on screen
  11323. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11324. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11325. * @returns a PickingInfo array
  11326. */
  11327. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11328. /** Use the given ray to pick sprites in the scene
  11329. * @param ray The ray (in world space) to use to pick meshes
  11330. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11331. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /**
  11336. * Force the sprite under the pointer
  11337. * @param sprite defines the sprite to use
  11338. */
  11339. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11340. /**
  11341. * Gets the sprite under the pointer
  11342. * @returns a Sprite or null if no sprite is under the pointer
  11343. */
  11344. getPointerOverSprite(): Nullable<Sprite>;
  11345. }
  11346. /**
  11347. * Defines the sprite scene component responsible to manage sprites
  11348. * in a given scene.
  11349. */
  11350. export class SpriteSceneComponent implements ISceneComponent {
  11351. /**
  11352. * The component name helpfull to identify the component in the list of scene components.
  11353. */
  11354. readonly name: string;
  11355. /**
  11356. * The scene the component belongs to.
  11357. */
  11358. scene: Scene;
  11359. /** @hidden */
  11360. private _spritePredicate;
  11361. /**
  11362. * Creates a new instance of the component for the given scene
  11363. * @param scene Defines the scene to register the component in
  11364. */
  11365. constructor(scene: Scene);
  11366. /**
  11367. * Registers the component in a given scene
  11368. */
  11369. register(): void;
  11370. /**
  11371. * Rebuilds the elements related to this component in case of
  11372. * context lost for instance.
  11373. */
  11374. rebuild(): void;
  11375. /**
  11376. * Disposes the component and the associated resources.
  11377. */
  11378. dispose(): void;
  11379. private _pickSpriteButKeepRay;
  11380. private _pointerMove;
  11381. private _pointerDown;
  11382. private _pointerUp;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Class used to provide helper for timing
  11388. */
  11389. export class TimingTools {
  11390. /**
  11391. * Polyfill for setImmediate
  11392. * @param action defines the action to execute after the current execution block
  11393. */
  11394. static SetImmediate(action: () => void): void;
  11395. }
  11396. }
  11397. declare module BABYLON {
  11398. /**
  11399. * Class used to enable instantiation of objects by class name
  11400. */
  11401. export class InstantiationTools {
  11402. /**
  11403. * Use this object to register external classes like custom textures or material
  11404. * to allow the loaders to instantiate them
  11405. */
  11406. static RegisteredExternalClasses: {
  11407. [key: string]: Object;
  11408. };
  11409. /**
  11410. * Tries to instantiate a new object from a given class name
  11411. * @param className defines the class name to instantiate
  11412. * @returns the new object or null if the system was not able to do the instantiation
  11413. */
  11414. static Instantiate(className: string): any;
  11415. }
  11416. }
  11417. declare module BABYLON {
  11418. /**
  11419. * Class used to host copy specific utilities
  11420. */
  11421. export class CopyTools {
  11422. /**
  11423. * Transform some pixel data to a base64 string
  11424. * @param pixels defines the pixel data to transform to base64
  11425. * @param size defines the width and height of the (texture) data
  11426. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11427. * @returns The base64 encoded string or null
  11428. */
  11429. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11430. /**
  11431. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11432. * @param texture defines the texture to read pixels from
  11433. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11434. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11435. * @returns The base64 encoded string or null
  11436. */
  11437. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11438. /**
  11439. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11440. * @param texture defines the texture to read pixels from
  11441. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11442. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11443. * @returns The base64 encoded string or null wrapped in a promise
  11444. */
  11445. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11446. }
  11447. }
  11448. declare module BABYLON {
  11449. /**
  11450. * Define options used to create a depth texture
  11451. */
  11452. export class DepthTextureCreationOptions {
  11453. /** Specifies whether or not a stencil should be allocated in the texture */
  11454. generateStencil?: boolean;
  11455. /** Specifies whether or not bilinear filtering is enable on the texture */
  11456. bilinearFiltering?: boolean;
  11457. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11458. comparisonFunction?: number;
  11459. /** Specifies if the created texture is a cube texture */
  11460. isCube?: boolean;
  11461. /** Specifies the sample count of the depth/stencil texture texture */
  11462. samples?: number;
  11463. }
  11464. }
  11465. declare module BABYLON {
  11466. interface ThinEngine {
  11467. /**
  11468. * Creates a depth stencil cube texture.
  11469. * This is only available in WebGL 2.
  11470. * @param size The size of face edge in the cube texture.
  11471. * @param options The options defining the cube texture.
  11472. * @returns The cube texture
  11473. */
  11474. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11475. /**
  11476. * Creates a cube texture
  11477. * @param rootUrl defines the url where the files to load is located
  11478. * @param scene defines the current scene
  11479. * @param files defines the list of files to load (1 per face)
  11480. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11481. * @param onLoad defines an optional callback raised when the texture is loaded
  11482. * @param onError defines an optional callback raised if there is an issue to load the texture
  11483. * @param format defines the format of the data
  11484. * @param forcedExtension defines the extension to use to pick the right loader
  11485. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11486. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11487. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11488. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11489. * @param loaderOptions options to be passed to the loader
  11490. * @returns the cube texture as an InternalTexture
  11491. */
  11492. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11493. /**
  11494. * Creates a cube texture
  11495. * @param rootUrl defines the url where the files to load is located
  11496. * @param scene defines the current scene
  11497. * @param files defines the list of files to load (1 per face)
  11498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11499. * @param onLoad defines an optional callback raised when the texture is loaded
  11500. * @param onError defines an optional callback raised if there is an issue to load the texture
  11501. * @param format defines the format of the data
  11502. * @param forcedExtension defines the extension to use to pick the right loader
  11503. * @returns the cube texture as an InternalTexture
  11504. */
  11505. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11506. /**
  11507. * Creates a cube texture
  11508. * @param rootUrl defines the url where the files to load is located
  11509. * @param scene defines the current scene
  11510. * @param files defines the list of files to load (1 per face)
  11511. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11512. * @param onLoad defines an optional callback raised when the texture is loaded
  11513. * @param onError defines an optional callback raised if there is an issue to load the texture
  11514. * @param format defines the format of the data
  11515. * @param forcedExtension defines the extension to use to pick the right loader
  11516. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11519. * @returns the cube texture as an InternalTexture
  11520. */
  11521. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11522. /** @hidden */
  11523. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11524. /** @hidden */
  11525. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11526. /** @hidden */
  11527. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11528. /** @hidden */
  11529. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11530. /** @hidden */
  11531. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11532. /**
  11533. * @hidden
  11534. */
  11535. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11536. }
  11537. }
  11538. declare module BABYLON {
  11539. /**
  11540. * Class for creating a cube texture
  11541. */
  11542. export class CubeTexture extends BaseTexture {
  11543. private _delayedOnLoad;
  11544. /**
  11545. * Observable triggered once the texture has been loaded.
  11546. */
  11547. onLoadObservable: Observable<CubeTexture>;
  11548. /**
  11549. * The url of the texture
  11550. */
  11551. url: string;
  11552. /**
  11553. * Gets or sets the center of the bounding box associated with the cube texture.
  11554. * It must define where the camera used to render the texture was set
  11555. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11556. */
  11557. boundingBoxPosition: Vector3;
  11558. private _boundingBoxSize;
  11559. /**
  11560. * Gets or sets the size of the bounding box associated with the cube texture
  11561. * When defined, the cubemap will switch to local mode
  11562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11563. * @example https://www.babylonjs-playground.com/#RNASML
  11564. */
  11565. set boundingBoxSize(value: Vector3);
  11566. /**
  11567. * Returns the bounding box size
  11568. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11569. */
  11570. get boundingBoxSize(): Vector3;
  11571. protected _rotationY: number;
  11572. /**
  11573. * Sets texture matrix rotation angle around Y axis in radians.
  11574. */
  11575. set rotationY(value: number);
  11576. /**
  11577. * Gets texture matrix rotation angle around Y axis radians.
  11578. */
  11579. get rotationY(): number;
  11580. /**
  11581. * Are mip maps generated for this texture or not.
  11582. */
  11583. get noMipmap(): boolean;
  11584. private _noMipmap;
  11585. private _files;
  11586. protected _forcedExtension: Nullable<string>;
  11587. private _extensions;
  11588. private _textureMatrix;
  11589. private _format;
  11590. private _createPolynomials;
  11591. private _loaderOptions;
  11592. /**
  11593. * Creates a cube texture from an array of image urls
  11594. * @param files defines an array of image urls
  11595. * @param scene defines the hosting scene
  11596. * @param noMipmap specifies if mip maps are not used
  11597. * @returns a cube texture
  11598. */
  11599. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11600. /**
  11601. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11602. * @param url defines the url of the prefiltered texture
  11603. * @param scene defines the scene the texture is attached to
  11604. * @param forcedExtension defines the extension of the file if different from the url
  11605. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11606. * @return the prefiltered texture
  11607. */
  11608. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11609. /**
  11610. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11611. * as prefiltered data.
  11612. * @param rootUrl defines the url of the texture or the root name of the six images
  11613. * @param null defines the scene or engine the texture is attached to
  11614. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11615. * @param noMipmap defines if mipmaps should be created or not
  11616. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11617. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11618. * @param onError defines a callback triggered in case of error during load
  11619. * @param format defines the internal format to use for the texture once loaded
  11620. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11621. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11622. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11623. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11624. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11625. * @param loaderOptions options to be passed to the loader
  11626. * @return the cube texture
  11627. */
  11628. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11629. /**
  11630. * Get the current class name of the texture useful for serialization or dynamic coding.
  11631. * @returns "CubeTexture"
  11632. */
  11633. getClassName(): string;
  11634. /**
  11635. * Update the url (and optional buffer) of this texture if url was null during construction.
  11636. * @param url the url of the texture
  11637. * @param forcedExtension defines the extension to use
  11638. * @param onLoad callback called when the texture is loaded (defaults to null)
  11639. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11640. */
  11641. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11642. /**
  11643. * Delays loading of the cube texture
  11644. * @param forcedExtension defines the extension to use
  11645. */
  11646. delayLoad(forcedExtension?: string): void;
  11647. /**
  11648. * Returns the reflection texture matrix
  11649. * @returns the reflection texture matrix
  11650. */
  11651. getReflectionTextureMatrix(): Matrix;
  11652. /**
  11653. * Sets the reflection texture matrix
  11654. * @param value Reflection texture matrix
  11655. */
  11656. setReflectionTextureMatrix(value: Matrix): void;
  11657. /**
  11658. * Parses text to create a cube texture
  11659. * @param parsedTexture define the serialized text to read from
  11660. * @param scene defines the hosting scene
  11661. * @param rootUrl defines the root url of the cube texture
  11662. * @returns a cube texture
  11663. */
  11664. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11665. /**
  11666. * Makes a clone, or deep copy, of the cube texture
  11667. * @returns a new cube texture
  11668. */
  11669. clone(): CubeTexture;
  11670. }
  11671. }
  11672. declare module BABYLON {
  11673. /**
  11674. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11676. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11678. */
  11679. export class ColorCurves {
  11680. private _dirty;
  11681. private _tempColor;
  11682. private _globalCurve;
  11683. private _highlightsCurve;
  11684. private _midtonesCurve;
  11685. private _shadowsCurve;
  11686. private _positiveCurve;
  11687. private _negativeCurve;
  11688. private _globalHue;
  11689. private _globalDensity;
  11690. private _globalSaturation;
  11691. private _globalExposure;
  11692. /**
  11693. * Gets the global Hue value.
  11694. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11695. */
  11696. get globalHue(): number;
  11697. /**
  11698. * Sets the global Hue value.
  11699. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11700. */
  11701. set globalHue(value: number);
  11702. /**
  11703. * Gets the global Density value.
  11704. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11705. * Values less than zero provide a filter of opposite hue.
  11706. */
  11707. get globalDensity(): number;
  11708. /**
  11709. * Sets the global Density value.
  11710. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11711. * Values less than zero provide a filter of opposite hue.
  11712. */
  11713. set globalDensity(value: number);
  11714. /**
  11715. * Gets the global Saturation value.
  11716. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11717. */
  11718. get globalSaturation(): number;
  11719. /**
  11720. * Sets the global Saturation value.
  11721. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11722. */
  11723. set globalSaturation(value: number);
  11724. /**
  11725. * Gets the global Exposure value.
  11726. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11727. */
  11728. get globalExposure(): number;
  11729. /**
  11730. * Sets the global Exposure value.
  11731. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11732. */
  11733. set globalExposure(value: number);
  11734. private _highlightsHue;
  11735. private _highlightsDensity;
  11736. private _highlightsSaturation;
  11737. private _highlightsExposure;
  11738. /**
  11739. * Gets the highlights Hue value.
  11740. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11741. */
  11742. get highlightsHue(): number;
  11743. /**
  11744. * Sets the highlights Hue value.
  11745. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11746. */
  11747. set highlightsHue(value: number);
  11748. /**
  11749. * Gets the highlights Density value.
  11750. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11751. * Values less than zero provide a filter of opposite hue.
  11752. */
  11753. get highlightsDensity(): number;
  11754. /**
  11755. * Sets the highlights Density value.
  11756. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11757. * Values less than zero provide a filter of opposite hue.
  11758. */
  11759. set highlightsDensity(value: number);
  11760. /**
  11761. * Gets the highlights Saturation value.
  11762. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11763. */
  11764. get highlightsSaturation(): number;
  11765. /**
  11766. * Sets the highlights Saturation value.
  11767. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11768. */
  11769. set highlightsSaturation(value: number);
  11770. /**
  11771. * Gets the highlights Exposure value.
  11772. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11773. */
  11774. get highlightsExposure(): number;
  11775. /**
  11776. * Sets the highlights Exposure value.
  11777. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11778. */
  11779. set highlightsExposure(value: number);
  11780. private _midtonesHue;
  11781. private _midtonesDensity;
  11782. private _midtonesSaturation;
  11783. private _midtonesExposure;
  11784. /**
  11785. * Gets the midtones Hue value.
  11786. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11787. */
  11788. get midtonesHue(): number;
  11789. /**
  11790. * Sets the midtones Hue value.
  11791. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11792. */
  11793. set midtonesHue(value: number);
  11794. /**
  11795. * Gets the midtones Density value.
  11796. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11797. * Values less than zero provide a filter of opposite hue.
  11798. */
  11799. get midtonesDensity(): number;
  11800. /**
  11801. * Sets the midtones Density value.
  11802. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11803. * Values less than zero provide a filter of opposite hue.
  11804. */
  11805. set midtonesDensity(value: number);
  11806. /**
  11807. * Gets the midtones Saturation value.
  11808. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11809. */
  11810. get midtonesSaturation(): number;
  11811. /**
  11812. * Sets the midtones Saturation value.
  11813. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11814. */
  11815. set midtonesSaturation(value: number);
  11816. /**
  11817. * Gets the midtones Exposure value.
  11818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11819. */
  11820. get midtonesExposure(): number;
  11821. /**
  11822. * Sets the midtones Exposure value.
  11823. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11824. */
  11825. set midtonesExposure(value: number);
  11826. private _shadowsHue;
  11827. private _shadowsDensity;
  11828. private _shadowsSaturation;
  11829. private _shadowsExposure;
  11830. /**
  11831. * Gets the shadows Hue value.
  11832. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11833. */
  11834. get shadowsHue(): number;
  11835. /**
  11836. * Sets the shadows Hue value.
  11837. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11838. */
  11839. set shadowsHue(value: number);
  11840. /**
  11841. * Gets the shadows Density value.
  11842. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11843. * Values less than zero provide a filter of opposite hue.
  11844. */
  11845. get shadowsDensity(): number;
  11846. /**
  11847. * Sets the shadows Density value.
  11848. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11849. * Values less than zero provide a filter of opposite hue.
  11850. */
  11851. set shadowsDensity(value: number);
  11852. /**
  11853. * Gets the shadows Saturation value.
  11854. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11855. */
  11856. get shadowsSaturation(): number;
  11857. /**
  11858. * Sets the shadows Saturation value.
  11859. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11860. */
  11861. set shadowsSaturation(value: number);
  11862. /**
  11863. * Gets the shadows Exposure value.
  11864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11865. */
  11866. get shadowsExposure(): number;
  11867. /**
  11868. * Sets the shadows Exposure value.
  11869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11870. */
  11871. set shadowsExposure(value: number);
  11872. /**
  11873. * Returns the class name
  11874. * @returns The class name
  11875. */
  11876. getClassName(): string;
  11877. /**
  11878. * Binds the color curves to the shader.
  11879. * @param colorCurves The color curve to bind
  11880. * @param effect The effect to bind to
  11881. * @param positiveUniform The positive uniform shader parameter
  11882. * @param neutralUniform The neutral uniform shader parameter
  11883. * @param negativeUniform The negative uniform shader parameter
  11884. */
  11885. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11886. /**
  11887. * Prepare the list of uniforms associated with the ColorCurves effects.
  11888. * @param uniformsList The list of uniforms used in the effect
  11889. */
  11890. static PrepareUniforms(uniformsList: string[]): void;
  11891. /**
  11892. * Returns color grading data based on a hue, density, saturation and exposure value.
  11893. * @param filterHue The hue of the color filter.
  11894. * @param filterDensity The density of the color filter.
  11895. * @param saturation The saturation.
  11896. * @param exposure The exposure.
  11897. * @param result The result data container.
  11898. */
  11899. private getColorGradingDataToRef;
  11900. /**
  11901. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11902. * @param value The input slider value in range [-100,100].
  11903. * @returns Adjusted value.
  11904. */
  11905. private static applyColorGradingSliderNonlinear;
  11906. /**
  11907. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11908. * @param hue The hue (H) input.
  11909. * @param saturation The saturation (S) input.
  11910. * @param brightness The brightness (B) input.
  11911. * @result An RGBA color represented as Vector4.
  11912. */
  11913. private static fromHSBToRef;
  11914. /**
  11915. * Returns a value clamped between min and max
  11916. * @param value The value to clamp
  11917. * @param min The minimum of value
  11918. * @param max The maximum of value
  11919. * @returns The clamped value.
  11920. */
  11921. private static clamp;
  11922. /**
  11923. * Clones the current color curve instance.
  11924. * @return The cloned curves
  11925. */
  11926. clone(): ColorCurves;
  11927. /**
  11928. * Serializes the current color curve instance to a json representation.
  11929. * @return a JSON representation
  11930. */
  11931. serialize(): any;
  11932. /**
  11933. * Parses the color curve from a json representation.
  11934. * @param source the JSON source to parse
  11935. * @return The parsed curves
  11936. */
  11937. static Parse(source: any): ColorCurves;
  11938. }
  11939. }
  11940. declare module BABYLON {
  11941. /**
  11942. * Interface to follow in your material defines to integrate easily the
  11943. * Image processing functions.
  11944. * @hidden
  11945. */
  11946. export interface IImageProcessingConfigurationDefines {
  11947. IMAGEPROCESSING: boolean;
  11948. VIGNETTE: boolean;
  11949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11950. VIGNETTEBLENDMODEOPAQUE: boolean;
  11951. TONEMAPPING: boolean;
  11952. TONEMAPPING_ACES: boolean;
  11953. CONTRAST: boolean;
  11954. EXPOSURE: boolean;
  11955. COLORCURVES: boolean;
  11956. COLORGRADING: boolean;
  11957. COLORGRADING3D: boolean;
  11958. SAMPLER3DGREENDEPTH: boolean;
  11959. SAMPLER3DBGRMAP: boolean;
  11960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11961. }
  11962. /**
  11963. * @hidden
  11964. */
  11965. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11966. IMAGEPROCESSING: boolean;
  11967. VIGNETTE: boolean;
  11968. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11969. VIGNETTEBLENDMODEOPAQUE: boolean;
  11970. TONEMAPPING: boolean;
  11971. TONEMAPPING_ACES: boolean;
  11972. CONTRAST: boolean;
  11973. COLORCURVES: boolean;
  11974. COLORGRADING: boolean;
  11975. COLORGRADING3D: boolean;
  11976. SAMPLER3DGREENDEPTH: boolean;
  11977. SAMPLER3DBGRMAP: boolean;
  11978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11979. EXPOSURE: boolean;
  11980. constructor();
  11981. }
  11982. /**
  11983. * This groups together the common properties used for image processing either in direct forward pass
  11984. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11985. * or not.
  11986. */
  11987. export class ImageProcessingConfiguration {
  11988. /**
  11989. * Default tone mapping applied in BabylonJS.
  11990. */
  11991. static readonly TONEMAPPING_STANDARD: number;
  11992. /**
  11993. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11994. * to other engines rendering to increase portability.
  11995. */
  11996. static readonly TONEMAPPING_ACES: number;
  11997. /**
  11998. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11999. */
  12000. colorCurves: Nullable<ColorCurves>;
  12001. private _colorCurvesEnabled;
  12002. /**
  12003. * Gets whether the color curves effect is enabled.
  12004. */
  12005. get colorCurvesEnabled(): boolean;
  12006. /**
  12007. * Sets whether the color curves effect is enabled.
  12008. */
  12009. set colorCurvesEnabled(value: boolean);
  12010. private _colorGradingTexture;
  12011. /**
  12012. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12013. */
  12014. get colorGradingTexture(): Nullable<BaseTexture>;
  12015. /**
  12016. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12017. */
  12018. set colorGradingTexture(value: Nullable<BaseTexture>);
  12019. private _colorGradingEnabled;
  12020. /**
  12021. * Gets whether the color grading effect is enabled.
  12022. */
  12023. get colorGradingEnabled(): boolean;
  12024. /**
  12025. * Sets whether the color grading effect is enabled.
  12026. */
  12027. set colorGradingEnabled(value: boolean);
  12028. private _colorGradingWithGreenDepth;
  12029. /**
  12030. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12031. */
  12032. get colorGradingWithGreenDepth(): boolean;
  12033. /**
  12034. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12035. */
  12036. set colorGradingWithGreenDepth(value: boolean);
  12037. private _colorGradingBGR;
  12038. /**
  12039. * Gets whether the color grading texture contains BGR values.
  12040. */
  12041. get colorGradingBGR(): boolean;
  12042. /**
  12043. * Sets whether the color grading texture contains BGR values.
  12044. */
  12045. set colorGradingBGR(value: boolean);
  12046. /** @hidden */
  12047. _exposure: number;
  12048. /**
  12049. * Gets the Exposure used in the effect.
  12050. */
  12051. get exposure(): number;
  12052. /**
  12053. * Sets the Exposure used in the effect.
  12054. */
  12055. set exposure(value: number);
  12056. private _toneMappingEnabled;
  12057. /**
  12058. * Gets whether the tone mapping effect is enabled.
  12059. */
  12060. get toneMappingEnabled(): boolean;
  12061. /**
  12062. * Sets whether the tone mapping effect is enabled.
  12063. */
  12064. set toneMappingEnabled(value: boolean);
  12065. private _toneMappingType;
  12066. /**
  12067. * Gets the type of tone mapping effect.
  12068. */
  12069. get toneMappingType(): number;
  12070. /**
  12071. * Sets the type of tone mapping effect used in BabylonJS.
  12072. */
  12073. set toneMappingType(value: number);
  12074. protected _contrast: number;
  12075. /**
  12076. * Gets the contrast used in the effect.
  12077. */
  12078. get contrast(): number;
  12079. /**
  12080. * Sets the contrast used in the effect.
  12081. */
  12082. set contrast(value: number);
  12083. /**
  12084. * Vignette stretch size.
  12085. */
  12086. vignetteStretch: number;
  12087. /**
  12088. * Vignette centre X Offset.
  12089. */
  12090. vignetteCentreX: number;
  12091. /**
  12092. * Vignette centre Y Offset.
  12093. */
  12094. vignetteCentreY: number;
  12095. /**
  12096. * Vignette weight or intensity of the vignette effect.
  12097. */
  12098. vignetteWeight: number;
  12099. /**
  12100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12101. * if vignetteEnabled is set to true.
  12102. */
  12103. vignetteColor: Color4;
  12104. /**
  12105. * Camera field of view used by the Vignette effect.
  12106. */
  12107. vignetteCameraFov: number;
  12108. private _vignetteBlendMode;
  12109. /**
  12110. * Gets the vignette blend mode allowing different kind of effect.
  12111. */
  12112. get vignetteBlendMode(): number;
  12113. /**
  12114. * Sets the vignette blend mode allowing different kind of effect.
  12115. */
  12116. set vignetteBlendMode(value: number);
  12117. private _vignetteEnabled;
  12118. /**
  12119. * Gets whether the vignette effect is enabled.
  12120. */
  12121. get vignetteEnabled(): boolean;
  12122. /**
  12123. * Sets whether the vignette effect is enabled.
  12124. */
  12125. set vignetteEnabled(value: boolean);
  12126. private _applyByPostProcess;
  12127. /**
  12128. * Gets whether the image processing is applied through a post process or not.
  12129. */
  12130. get applyByPostProcess(): boolean;
  12131. /**
  12132. * Sets whether the image processing is applied through a post process or not.
  12133. */
  12134. set applyByPostProcess(value: boolean);
  12135. private _isEnabled;
  12136. /**
  12137. * Gets whether the image processing is enabled or not.
  12138. */
  12139. get isEnabled(): boolean;
  12140. /**
  12141. * Sets whether the image processing is enabled or not.
  12142. */
  12143. set isEnabled(value: boolean);
  12144. /**
  12145. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12146. */
  12147. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12148. /**
  12149. * Method called each time the image processing information changes requires to recompile the effect.
  12150. */
  12151. protected _updateParameters(): void;
  12152. /**
  12153. * Gets the current class name.
  12154. * @return "ImageProcessingConfiguration"
  12155. */
  12156. getClassName(): string;
  12157. /**
  12158. * Prepare the list of uniforms associated with the Image Processing effects.
  12159. * @param uniforms The list of uniforms used in the effect
  12160. * @param defines the list of defines currently in use
  12161. */
  12162. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12163. /**
  12164. * Prepare the list of samplers associated with the Image Processing effects.
  12165. * @param samplersList The list of uniforms used in the effect
  12166. * @param defines the list of defines currently in use
  12167. */
  12168. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12169. /**
  12170. * Prepare the list of defines associated to the shader.
  12171. * @param defines the list of defines to complete
  12172. * @param forPostProcess Define if we are currently in post process mode or not
  12173. */
  12174. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12175. /**
  12176. * Returns true if all the image processing information are ready.
  12177. * @returns True if ready, otherwise, false
  12178. */
  12179. isReady(): boolean;
  12180. /**
  12181. * Binds the image processing to the shader.
  12182. * @param effect The effect to bind to
  12183. * @param overrideAspectRatio Override the aspect ratio of the effect
  12184. */
  12185. bind(effect: Effect, overrideAspectRatio?: number): void;
  12186. /**
  12187. * Clones the current image processing instance.
  12188. * @return The cloned image processing
  12189. */
  12190. clone(): ImageProcessingConfiguration;
  12191. /**
  12192. * Serializes the current image processing instance to a json representation.
  12193. * @return a JSON representation
  12194. */
  12195. serialize(): any;
  12196. /**
  12197. * Parses the image processing from a json representation.
  12198. * @param source the JSON source to parse
  12199. * @return The parsed image processing
  12200. */
  12201. static Parse(source: any): ImageProcessingConfiguration;
  12202. private static _VIGNETTEMODE_MULTIPLY;
  12203. private static _VIGNETTEMODE_OPAQUE;
  12204. /**
  12205. * Used to apply the vignette as a mix with the pixel color.
  12206. */
  12207. static get VIGNETTEMODE_MULTIPLY(): number;
  12208. /**
  12209. * Used to apply the vignette as a replacement of the pixel color.
  12210. */
  12211. static get VIGNETTEMODE_OPAQUE(): number;
  12212. }
  12213. }
  12214. declare module BABYLON {
  12215. /** @hidden */
  12216. export var postprocessVertexShader: {
  12217. name: string;
  12218. shader: string;
  12219. };
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12224. */
  12225. export type RenderTargetTextureSize = number | {
  12226. width: number;
  12227. height: number;
  12228. layers?: number;
  12229. };
  12230. interface ThinEngine {
  12231. /**
  12232. * Creates a new render target texture
  12233. * @param size defines the size of the texture
  12234. * @param options defines the options used to create the texture
  12235. * @returns a new render target texture stored in an InternalTexture
  12236. */
  12237. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12238. /**
  12239. * Creates a depth stencil texture.
  12240. * This is only available in WebGL 2 or with the depth texture extension available.
  12241. * @param size The size of face edge in the texture.
  12242. * @param options The options defining the texture.
  12243. * @returns The texture
  12244. */
  12245. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12246. /** @hidden */
  12247. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Defines the kind of connection point for node based material
  12253. */
  12254. export enum NodeMaterialBlockConnectionPointTypes {
  12255. /** Float */
  12256. Float = 1,
  12257. /** Int */
  12258. Int = 2,
  12259. /** Vector2 */
  12260. Vector2 = 4,
  12261. /** Vector3 */
  12262. Vector3 = 8,
  12263. /** Vector4 */
  12264. Vector4 = 16,
  12265. /** Color3 */
  12266. Color3 = 32,
  12267. /** Color4 */
  12268. Color4 = 64,
  12269. /** Matrix */
  12270. Matrix = 128,
  12271. /** Custom object */
  12272. Object = 256,
  12273. /** Detect type based on connection */
  12274. AutoDetect = 1024,
  12275. /** Output type that will be defined by input type */
  12276. BasedOnInput = 2048
  12277. }
  12278. }
  12279. declare module BABYLON {
  12280. /**
  12281. * Enum used to define the target of a block
  12282. */
  12283. export enum NodeMaterialBlockTargets {
  12284. /** Vertex shader */
  12285. Vertex = 1,
  12286. /** Fragment shader */
  12287. Fragment = 2,
  12288. /** Neutral */
  12289. Neutral = 4,
  12290. /** Vertex and Fragment */
  12291. VertexAndFragment = 3
  12292. }
  12293. }
  12294. declare module BABYLON {
  12295. /**
  12296. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12297. */
  12298. export enum NodeMaterialBlockConnectionPointMode {
  12299. /** Value is an uniform */
  12300. Uniform = 0,
  12301. /** Value is a mesh attribute */
  12302. Attribute = 1,
  12303. /** Value is a varying between vertex and fragment shaders */
  12304. Varying = 2,
  12305. /** Mode is undefined */
  12306. Undefined = 3
  12307. }
  12308. }
  12309. declare module BABYLON {
  12310. /**
  12311. * Enum used to define system values e.g. values automatically provided by the system
  12312. */
  12313. export enum NodeMaterialSystemValues {
  12314. /** World */
  12315. World = 1,
  12316. /** View */
  12317. View = 2,
  12318. /** Projection */
  12319. Projection = 3,
  12320. /** ViewProjection */
  12321. ViewProjection = 4,
  12322. /** WorldView */
  12323. WorldView = 5,
  12324. /** WorldViewProjection */
  12325. WorldViewProjection = 6,
  12326. /** CameraPosition */
  12327. CameraPosition = 7,
  12328. /** Fog Color */
  12329. FogColor = 8,
  12330. /** Delta time */
  12331. DeltaTime = 9
  12332. }
  12333. }
  12334. declare module BABYLON {
  12335. /**
  12336. * Represents a camera frustum
  12337. */
  12338. export class Frustum {
  12339. /**
  12340. * Gets the planes representing the frustum
  12341. * @param transform matrix to be applied to the returned planes
  12342. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12343. */
  12344. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12345. /**
  12346. * Gets the near frustum plane transformed by the transform matrix
  12347. * @param transform transformation matrix to be applied to the resulting frustum plane
  12348. * @param frustumPlane the resuling frustum plane
  12349. */
  12350. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12351. /**
  12352. * Gets the far frustum plane transformed by the transform matrix
  12353. * @param transform transformation matrix to be applied to the resulting frustum plane
  12354. * @param frustumPlane the resuling frustum plane
  12355. */
  12356. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12357. /**
  12358. * Gets the left frustum plane transformed by the transform matrix
  12359. * @param transform transformation matrix to be applied to the resulting frustum plane
  12360. * @param frustumPlane the resuling frustum plane
  12361. */
  12362. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12363. /**
  12364. * Gets the right frustum plane transformed by the transform matrix
  12365. * @param transform transformation matrix to be applied to the resulting frustum plane
  12366. * @param frustumPlane the resuling frustum plane
  12367. */
  12368. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12369. /**
  12370. * Gets the top frustum plane transformed by the transform matrix
  12371. * @param transform transformation matrix to be applied to the resulting frustum plane
  12372. * @param frustumPlane the resuling frustum plane
  12373. */
  12374. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12375. /**
  12376. * Gets the bottom frustum plane transformed by the transform matrix
  12377. * @param transform transformation matrix to be applied to the resulting frustum plane
  12378. * @param frustumPlane the resuling frustum plane
  12379. */
  12380. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12381. /**
  12382. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12383. * @param transform transformation matrix to be applied to the resulting frustum planes
  12384. * @param frustumPlanes the resuling frustum planes
  12385. */
  12386. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12387. }
  12388. }
  12389. declare module BABYLON {
  12390. /**
  12391. * Contains position and normal vectors for a vertex
  12392. */
  12393. export class PositionNormalVertex {
  12394. /** the position of the vertex (defaut: 0,0,0) */
  12395. position: Vector3;
  12396. /** the normal of the vertex (defaut: 0,1,0) */
  12397. normal: Vector3;
  12398. /**
  12399. * Creates a PositionNormalVertex
  12400. * @param position the position of the vertex (defaut: 0,0,0)
  12401. * @param normal the normal of the vertex (defaut: 0,1,0)
  12402. */
  12403. constructor(
  12404. /** the position of the vertex (defaut: 0,0,0) */
  12405. position?: Vector3,
  12406. /** the normal of the vertex (defaut: 0,1,0) */
  12407. normal?: Vector3);
  12408. /**
  12409. * Clones the PositionNormalVertex
  12410. * @returns the cloned PositionNormalVertex
  12411. */
  12412. clone(): PositionNormalVertex;
  12413. }
  12414. /**
  12415. * Contains position, normal and uv vectors for a vertex
  12416. */
  12417. export class PositionNormalTextureVertex {
  12418. /** the position of the vertex (defaut: 0,0,0) */
  12419. position: Vector3;
  12420. /** the normal of the vertex (defaut: 0,1,0) */
  12421. normal: Vector3;
  12422. /** the uv of the vertex (default: 0,0) */
  12423. uv: Vector2;
  12424. /**
  12425. * Creates a PositionNormalTextureVertex
  12426. * @param position the position of the vertex (defaut: 0,0,0)
  12427. * @param normal the normal of the vertex (defaut: 0,1,0)
  12428. * @param uv the uv of the vertex (default: 0,0)
  12429. */
  12430. constructor(
  12431. /** the position of the vertex (defaut: 0,0,0) */
  12432. position?: Vector3,
  12433. /** the normal of the vertex (defaut: 0,1,0) */
  12434. normal?: Vector3,
  12435. /** the uv of the vertex (default: 0,0) */
  12436. uv?: Vector2);
  12437. /**
  12438. * Clones the PositionNormalTextureVertex
  12439. * @returns the cloned PositionNormalTextureVertex
  12440. */
  12441. clone(): PositionNormalTextureVertex;
  12442. }
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Enum defining the type of animations supported by InputBlock
  12447. */
  12448. export enum AnimatedInputBlockTypes {
  12449. /** No animation */
  12450. None = 0,
  12451. /** Time based animation. Will only work for floats */
  12452. Time = 1
  12453. }
  12454. }
  12455. declare module BABYLON {
  12456. /**
  12457. * Block used to expose an input value
  12458. */
  12459. export class InputBlock extends NodeMaterialBlock {
  12460. private _mode;
  12461. private _associatedVariableName;
  12462. private _storedValue;
  12463. private _valueCallback;
  12464. private _type;
  12465. private _animationType;
  12466. /** Gets or set a value used to limit the range of float values */
  12467. min: number;
  12468. /** Gets or set a value used to limit the range of float values */
  12469. max: number;
  12470. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12471. isBoolean: boolean;
  12472. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12473. matrixMode: number;
  12474. /** @hidden */
  12475. _systemValue: Nullable<NodeMaterialSystemValues>;
  12476. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12477. isConstant: boolean;
  12478. /** Gets or sets the group to use to display this block in the Inspector */
  12479. groupInInspector: string;
  12480. /** Gets an observable raised when the value is changed */
  12481. onValueChangedObservable: Observable<InputBlock>;
  12482. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12483. convertToGammaSpace: boolean;
  12484. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12485. convertToLinearSpace: boolean;
  12486. /**
  12487. * Gets or sets the connection point type (default is float)
  12488. */
  12489. get type(): NodeMaterialBlockConnectionPointTypes;
  12490. /**
  12491. * Creates a new InputBlock
  12492. * @param name defines the block name
  12493. * @param target defines the target of that block (Vertex by default)
  12494. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12495. */
  12496. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12497. /**
  12498. * Validates if a name is a reserve word.
  12499. * @param newName the new name to be given to the node.
  12500. * @returns false if the name is a reserve word, else true.
  12501. */
  12502. validateBlockName(newName: string): boolean;
  12503. /**
  12504. * Gets the output component
  12505. */
  12506. get output(): NodeMaterialConnectionPoint;
  12507. /**
  12508. * Set the source of this connection point to a vertex attribute
  12509. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12510. * @returns the current connection point
  12511. */
  12512. setAsAttribute(attributeName?: string): InputBlock;
  12513. /**
  12514. * Set the source of this connection point to a system value
  12515. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12516. * @returns the current connection point
  12517. */
  12518. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12519. /**
  12520. * Gets or sets the value of that point.
  12521. * Please note that this value will be ignored if valueCallback is defined
  12522. */
  12523. get value(): any;
  12524. set value(value: any);
  12525. /**
  12526. * Gets or sets a callback used to get the value of that point.
  12527. * Please note that setting this value will force the connection point to ignore the value property
  12528. */
  12529. get valueCallback(): () => any;
  12530. set valueCallback(value: () => any);
  12531. /**
  12532. * Gets or sets the associated variable name in the shader
  12533. */
  12534. get associatedVariableName(): string;
  12535. set associatedVariableName(value: string);
  12536. /** Gets or sets the type of animation applied to the input */
  12537. get animationType(): AnimatedInputBlockTypes;
  12538. set animationType(value: AnimatedInputBlockTypes);
  12539. /**
  12540. * Gets a boolean indicating that this connection point not defined yet
  12541. */
  12542. get isUndefined(): boolean;
  12543. /**
  12544. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12545. * In this case the connection point name must be the name of the uniform to use.
  12546. * Can only be set on inputs
  12547. */
  12548. get isUniform(): boolean;
  12549. set isUniform(value: boolean);
  12550. /**
  12551. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12552. * In this case the connection point name must be the name of the attribute to use
  12553. * Can only be set on inputs
  12554. */
  12555. get isAttribute(): boolean;
  12556. set isAttribute(value: boolean);
  12557. /**
  12558. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12559. * Can only be set on exit points
  12560. */
  12561. get isVarying(): boolean;
  12562. set isVarying(value: boolean);
  12563. /**
  12564. * Gets a boolean indicating that the current connection point is a system value
  12565. */
  12566. get isSystemValue(): boolean;
  12567. /**
  12568. * Gets or sets the current well known value or null if not defined as a system value
  12569. */
  12570. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12571. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12572. /**
  12573. * Gets the current class name
  12574. * @returns the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Animate the input if animationType !== None
  12579. * @param scene defines the rendering scene
  12580. */
  12581. animate(scene: Scene): void;
  12582. private _emitDefine;
  12583. initialize(state: NodeMaterialBuildState): void;
  12584. /**
  12585. * Set the input block to its default value (based on its type)
  12586. */
  12587. setDefaultValue(): void;
  12588. private _emitConstant;
  12589. /** @hidden */
  12590. get _noContextSwitch(): boolean;
  12591. private _emit;
  12592. /** @hidden */
  12593. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12594. /** @hidden */
  12595. _transmit(effect: Effect, scene: Scene): void;
  12596. protected _buildBlock(state: NodeMaterialBuildState): void;
  12597. protected _dumpPropertiesCode(): string;
  12598. dispose(): void;
  12599. serialize(): any;
  12600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12601. }
  12602. }
  12603. declare module BABYLON {
  12604. /**
  12605. * Enum used to define the compatibility state between two connection points
  12606. */
  12607. export enum NodeMaterialConnectionPointCompatibilityStates {
  12608. /** Points are compatibles */
  12609. Compatible = 0,
  12610. /** Points are incompatible because of their types */
  12611. TypeIncompatible = 1,
  12612. /** Points are incompatible because of their targets (vertex vs fragment) */
  12613. TargetIncompatible = 2
  12614. }
  12615. /**
  12616. * Defines the direction of a connection point
  12617. */
  12618. export enum NodeMaterialConnectionPointDirection {
  12619. /** Input */
  12620. Input = 0,
  12621. /** Output */
  12622. Output = 1
  12623. }
  12624. /**
  12625. * Defines a connection point for a block
  12626. */
  12627. export class NodeMaterialConnectionPoint {
  12628. /**
  12629. * Checks if two types are equivalent
  12630. * @param type1 type 1 to check
  12631. * @param type2 type 2 to check
  12632. * @returns true if both types are equivalent, else false
  12633. */
  12634. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12635. /** @hidden */
  12636. _ownerBlock: NodeMaterialBlock;
  12637. /** @hidden */
  12638. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12639. private _endpoints;
  12640. private _associatedVariableName;
  12641. private _direction;
  12642. /** @hidden */
  12643. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12644. /** @hidden */
  12645. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12646. /** @hidden */
  12647. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12648. private _type;
  12649. /** @hidden */
  12650. _enforceAssociatedVariableName: boolean;
  12651. /** Gets the direction of the point */
  12652. get direction(): NodeMaterialConnectionPointDirection;
  12653. /** Indicates that this connection point needs dual validation before being connected to another point */
  12654. needDualDirectionValidation: boolean;
  12655. /**
  12656. * Gets or sets the additional types supported by this connection point
  12657. */
  12658. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12659. /**
  12660. * Gets or sets the additional types excluded by this connection point
  12661. */
  12662. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12663. /**
  12664. * Observable triggered when this point is connected
  12665. */
  12666. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12667. /**
  12668. * Gets or sets the associated variable name in the shader
  12669. */
  12670. get associatedVariableName(): string;
  12671. set associatedVariableName(value: string);
  12672. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12673. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12674. /**
  12675. * Gets or sets the connection point type (default is float)
  12676. */
  12677. get type(): NodeMaterialBlockConnectionPointTypes;
  12678. set type(value: NodeMaterialBlockConnectionPointTypes);
  12679. /**
  12680. * Gets or sets the connection point name
  12681. */
  12682. name: string;
  12683. /**
  12684. * Gets or sets the connection point name
  12685. */
  12686. displayName: string;
  12687. /**
  12688. * Gets or sets a boolean indicating that this connection point can be omitted
  12689. */
  12690. isOptional: boolean;
  12691. /**
  12692. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12693. */
  12694. isExposedOnFrame: boolean;
  12695. /**
  12696. * Gets or sets number indicating the position that the port is exposed to on a frame
  12697. */
  12698. exposedPortPosition: number;
  12699. /**
  12700. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12701. */
  12702. define: string;
  12703. /** @hidden */
  12704. _prioritizeVertex: boolean;
  12705. private _target;
  12706. /** Gets or sets the target of that connection point */
  12707. get target(): NodeMaterialBlockTargets;
  12708. set target(value: NodeMaterialBlockTargets);
  12709. /**
  12710. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12711. */
  12712. get isConnected(): boolean;
  12713. /**
  12714. * Gets a boolean indicating that the current point is connected to an input block
  12715. */
  12716. get isConnectedToInputBlock(): boolean;
  12717. /**
  12718. * Gets a the connected input block (if any)
  12719. */
  12720. get connectInputBlock(): Nullable<InputBlock>;
  12721. /** Get the other side of the connection (if any) */
  12722. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12723. /** Get the block that owns this connection point */
  12724. get ownerBlock(): NodeMaterialBlock;
  12725. /** Get the block connected on the other side of this connection (if any) */
  12726. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12727. /** Get the block connected on the endpoints of this connection (if any) */
  12728. get connectedBlocks(): Array<NodeMaterialBlock>;
  12729. /** Gets the list of connected endpoints */
  12730. get endpoints(): NodeMaterialConnectionPoint[];
  12731. /** Gets a boolean indicating if that output point is connected to at least one input */
  12732. get hasEndpoints(): boolean;
  12733. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12734. get isConnectedInVertexShader(): boolean;
  12735. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12736. get isConnectedInFragmentShader(): boolean;
  12737. /**
  12738. * Creates a block suitable to be used as an input for this input point.
  12739. * If null is returned, a block based on the point type will be created.
  12740. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12741. */
  12742. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12743. /**
  12744. * Creates a new connection point
  12745. * @param name defines the connection point name
  12746. * @param ownerBlock defines the block hosting this connection point
  12747. * @param direction defines the direction of the connection point
  12748. */
  12749. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12750. /**
  12751. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets a boolean indicating if the current point can be connected to another point
  12757. * @param connectionPoint defines the other connection point
  12758. * @returns a boolean
  12759. */
  12760. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12761. /**
  12762. * Gets a number indicating if the current point can be connected to another point
  12763. * @param connectionPoint defines the other connection point
  12764. * @returns a number defining the compatibility state
  12765. */
  12766. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12767. /**
  12768. * Connect this point to another connection point
  12769. * @param connectionPoint defines the other connection point
  12770. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12771. * @returns the current connection point
  12772. */
  12773. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Disconnect this point from one of his endpoint
  12776. * @param endpoint defines the other connection point
  12777. * @returns the current connection point
  12778. */
  12779. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12780. /**
  12781. * Serializes this point in a JSON representation
  12782. * @param isInput defines if the connection point is an input (default is true)
  12783. * @returns the serialized point object
  12784. */
  12785. serialize(isInput?: boolean): any;
  12786. /**
  12787. * Release resources
  12788. */
  12789. dispose(): void;
  12790. }
  12791. }
  12792. declare module BABYLON {
  12793. /**
  12794. * Enum used to define the material modes
  12795. */
  12796. export enum NodeMaterialModes {
  12797. /** Regular material */
  12798. Material = 0,
  12799. /** For post process */
  12800. PostProcess = 1,
  12801. /** For particle system */
  12802. Particle = 2,
  12803. /** For procedural texture */
  12804. ProceduralTexture = 3
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /** @hidden */
  12809. export var helperFunctions: {
  12810. name: string;
  12811. shader: string;
  12812. };
  12813. }
  12814. declare module BABYLON {
  12815. /**
  12816. * Block used to read a texture from a sampler
  12817. */
  12818. export class TextureBlock extends NodeMaterialBlock {
  12819. private _defineName;
  12820. private _linearDefineName;
  12821. private _gammaDefineName;
  12822. private _tempTextureRead;
  12823. private _samplerName;
  12824. private _transformedUVName;
  12825. private _textureTransformName;
  12826. private _textureInfoName;
  12827. private _mainUVName;
  12828. private _mainUVDefineName;
  12829. private _fragmentOnly;
  12830. protected _texture: Nullable<Texture>;
  12831. /**
  12832. * Gets or sets the texture associated with the node
  12833. */
  12834. get texture(): Nullable<Texture>;
  12835. set texture(texture: Nullable<Texture>);
  12836. /**
  12837. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12838. */
  12839. convertToGammaSpace: boolean;
  12840. /**
  12841. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12842. */
  12843. convertToLinearSpace: boolean;
  12844. /**
  12845. * Create a new TextureBlock
  12846. * @param name defines the block name
  12847. */
  12848. constructor(name: string, fragmentOnly?: boolean);
  12849. /**
  12850. * Gets the current class name
  12851. * @returns the class name
  12852. */
  12853. getClassName(): string;
  12854. /**
  12855. * Gets the uv input component
  12856. */
  12857. get uv(): NodeMaterialConnectionPoint;
  12858. /**
  12859. * Gets the rgba output component
  12860. */
  12861. get rgba(): NodeMaterialConnectionPoint;
  12862. /**
  12863. * Gets the rgb output component
  12864. */
  12865. get rgb(): NodeMaterialConnectionPoint;
  12866. /**
  12867. * Gets the r output component
  12868. */
  12869. get r(): NodeMaterialConnectionPoint;
  12870. /**
  12871. * Gets the g output component
  12872. */
  12873. get g(): NodeMaterialConnectionPoint;
  12874. /**
  12875. * Gets the b output component
  12876. */
  12877. get b(): NodeMaterialConnectionPoint;
  12878. /**
  12879. * Gets the a output component
  12880. */
  12881. get a(): NodeMaterialConnectionPoint;
  12882. get target(): NodeMaterialBlockTargets;
  12883. autoConfigure(material: NodeMaterial): void;
  12884. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12886. isReady(): boolean;
  12887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12888. private get _isMixed();
  12889. private _injectVertexCode;
  12890. private _writeTextureRead;
  12891. private _generateConversionCode;
  12892. private _writeOutput;
  12893. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12894. protected _dumpPropertiesCode(): string;
  12895. serialize(): any;
  12896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12897. }
  12898. }
  12899. declare module BABYLON {
  12900. /** @hidden */
  12901. export var reflectionFunction: {
  12902. name: string;
  12903. shader: string;
  12904. };
  12905. }
  12906. declare module BABYLON {
  12907. /**
  12908. * Base block used to read a reflection texture from a sampler
  12909. */
  12910. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12911. /** @hidden */
  12912. _define3DName: string;
  12913. /** @hidden */
  12914. _defineCubicName: string;
  12915. /** @hidden */
  12916. _defineExplicitName: string;
  12917. /** @hidden */
  12918. _defineProjectionName: string;
  12919. /** @hidden */
  12920. _defineLocalCubicName: string;
  12921. /** @hidden */
  12922. _defineSphericalName: string;
  12923. /** @hidden */
  12924. _definePlanarName: string;
  12925. /** @hidden */
  12926. _defineEquirectangularName: string;
  12927. /** @hidden */
  12928. _defineMirroredEquirectangularFixedName: string;
  12929. /** @hidden */
  12930. _defineEquirectangularFixedName: string;
  12931. /** @hidden */
  12932. _defineSkyboxName: string;
  12933. /** @hidden */
  12934. _defineOppositeZ: string;
  12935. /** @hidden */
  12936. _cubeSamplerName: string;
  12937. /** @hidden */
  12938. _2DSamplerName: string;
  12939. protected _positionUVWName: string;
  12940. protected _directionWName: string;
  12941. protected _reflectionVectorName: string;
  12942. /** @hidden */
  12943. _reflectionCoordsName: string;
  12944. /** @hidden */
  12945. _reflectionMatrixName: string;
  12946. protected _reflectionColorName: string;
  12947. protected _texture: Nullable<BaseTexture>;
  12948. /**
  12949. * Gets or sets the texture associated with the node
  12950. */
  12951. get texture(): Nullable<BaseTexture>;
  12952. set texture(texture: Nullable<BaseTexture>);
  12953. /**
  12954. * Create a new ReflectionTextureBaseBlock
  12955. * @param name defines the block name
  12956. */
  12957. constructor(name: string);
  12958. /**
  12959. * Gets the current class name
  12960. * @returns the class name
  12961. */
  12962. getClassName(): string;
  12963. /**
  12964. * Gets the world position input component
  12965. */
  12966. abstract get position(): NodeMaterialConnectionPoint;
  12967. /**
  12968. * Gets the world position input component
  12969. */
  12970. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12971. /**
  12972. * Gets the world normal input component
  12973. */
  12974. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12975. /**
  12976. * Gets the world input component
  12977. */
  12978. abstract get world(): NodeMaterialConnectionPoint;
  12979. /**
  12980. * Gets the camera (or eye) position component
  12981. */
  12982. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12983. /**
  12984. * Gets the view input component
  12985. */
  12986. abstract get view(): NodeMaterialConnectionPoint;
  12987. protected _getTexture(): Nullable<BaseTexture>;
  12988. autoConfigure(material: NodeMaterial): void;
  12989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12990. isReady(): boolean;
  12991. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12992. /**
  12993. * Gets the code to inject in the vertex shader
  12994. * @param state current state of the node material building
  12995. * @returns the shader code
  12996. */
  12997. handleVertexSide(state: NodeMaterialBuildState): string;
  12998. /**
  12999. * Handles the inits for the fragment code path
  13000. * @param state node material build state
  13001. */
  13002. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13003. /**
  13004. * Generates the reflection coords code for the fragment code path
  13005. * @param worldNormalVarName name of the world normal variable
  13006. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13007. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13008. * @returns the shader code
  13009. */
  13010. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13011. /**
  13012. * Generates the reflection color code for the fragment code path
  13013. * @param lodVarName name of the lod variable
  13014. * @param swizzleLookupTexture swizzle to use for the final color variable
  13015. * @returns the shader code
  13016. */
  13017. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13018. /**
  13019. * Generates the code corresponding to the connected output points
  13020. * @param state node material build state
  13021. * @param varName name of the variable to output
  13022. * @returns the shader code
  13023. */
  13024. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13025. protected _buildBlock(state: NodeMaterialBuildState): this;
  13026. protected _dumpPropertiesCode(): string;
  13027. serialize(): any;
  13028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13029. }
  13030. }
  13031. declare module BABYLON {
  13032. /**
  13033. * Defines a connection point to be used for points with a custom object type
  13034. */
  13035. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13036. private _blockType;
  13037. private _blockName;
  13038. private _nameForCheking?;
  13039. /**
  13040. * Creates a new connection point
  13041. * @param name defines the connection point name
  13042. * @param ownerBlock defines the block hosting this connection point
  13043. * @param direction defines the direction of the connection point
  13044. */
  13045. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13046. /**
  13047. * Gets a number indicating if the current point can be connected to another point
  13048. * @param connectionPoint defines the other connection point
  13049. * @returns a number defining the compatibility state
  13050. */
  13051. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13052. /**
  13053. * Creates a block suitable to be used as an input for this input point.
  13054. * If null is returned, a block based on the point type will be created.
  13055. * @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
  13056. */
  13057. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13058. }
  13059. }
  13060. declare module BABYLON {
  13061. /**
  13062. * Enum defining the type of properties that can be edited in the property pages in the NME
  13063. */
  13064. export enum PropertyTypeForEdition {
  13065. /** property is a boolean */
  13066. Boolean = 0,
  13067. /** property is a float */
  13068. Float = 1,
  13069. /** property is a Vector2 */
  13070. Vector2 = 2,
  13071. /** property is a list of values */
  13072. List = 3
  13073. }
  13074. /**
  13075. * Interface that defines an option in a variable of type list
  13076. */
  13077. export interface IEditablePropertyListOption {
  13078. /** label of the option */
  13079. "label": string;
  13080. /** value of the option */
  13081. "value": number;
  13082. }
  13083. /**
  13084. * Interface that defines the options available for an editable property
  13085. */
  13086. export interface IEditablePropertyOption {
  13087. /** min value */
  13088. "min"?: number;
  13089. /** max value */
  13090. "max"?: number;
  13091. /** notifiers: indicates which actions to take when the property is changed */
  13092. "notifiers"?: {
  13093. /** the material should be rebuilt */
  13094. "rebuild"?: boolean;
  13095. /** the preview should be updated */
  13096. "update"?: boolean;
  13097. };
  13098. /** list of the options for a variable of type list */
  13099. "options"?: IEditablePropertyListOption[];
  13100. }
  13101. /**
  13102. * Interface that describes an editable property
  13103. */
  13104. export interface IPropertyDescriptionForEdition {
  13105. /** name of the property */
  13106. "propertyName": string;
  13107. /** display name of the property */
  13108. "displayName": string;
  13109. /** type of the property */
  13110. "type": PropertyTypeForEdition;
  13111. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13112. "groupName": string;
  13113. /** options for the property */
  13114. "options": IEditablePropertyOption;
  13115. }
  13116. /**
  13117. * Decorator that flags a property in a node material block as being editable
  13118. */
  13119. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13120. }
  13121. declare module BABYLON {
  13122. /**
  13123. * Block used to implement the refraction part of the sub surface module of the PBR material
  13124. */
  13125. export class RefractionBlock extends NodeMaterialBlock {
  13126. /** @hidden */
  13127. _define3DName: string;
  13128. /** @hidden */
  13129. _refractionMatrixName: string;
  13130. /** @hidden */
  13131. _defineLODRefractionAlpha: string;
  13132. /** @hidden */
  13133. _defineLinearSpecularRefraction: string;
  13134. /** @hidden */
  13135. _defineOppositeZ: string;
  13136. /** @hidden */
  13137. _cubeSamplerName: string;
  13138. /** @hidden */
  13139. _2DSamplerName: string;
  13140. /** @hidden */
  13141. _vRefractionMicrosurfaceInfosName: string;
  13142. /** @hidden */
  13143. _vRefractionInfosName: string;
  13144. /** @hidden */
  13145. _vRefractionFilteringInfoName: string;
  13146. private _scene;
  13147. /**
  13148. * The properties below are set by the main PBR block prior to calling methods of this class.
  13149. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13150. * It's less burden on the user side in the editor part.
  13151. */
  13152. /** @hidden */
  13153. viewConnectionPoint: NodeMaterialConnectionPoint;
  13154. /** @hidden */
  13155. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13156. /**
  13157. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13158. * Materials half opaque for instance using refraction could benefit from this control.
  13159. */
  13160. linkRefractionWithTransparency: boolean;
  13161. /**
  13162. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13163. */
  13164. invertRefractionY: boolean;
  13165. /**
  13166. * Gets or sets the texture associated with the node
  13167. */
  13168. texture: Nullable<BaseTexture>;
  13169. /**
  13170. * Create a new RefractionBlock
  13171. * @param name defines the block name
  13172. */
  13173. constructor(name: string);
  13174. /**
  13175. * Gets the current class name
  13176. * @returns the class name
  13177. */
  13178. getClassName(): string;
  13179. /**
  13180. * Gets the intensity input component
  13181. */
  13182. get intensity(): NodeMaterialConnectionPoint;
  13183. /**
  13184. * Gets the tint at distance input component
  13185. */
  13186. get tintAtDistance(): NodeMaterialConnectionPoint;
  13187. /**
  13188. * Gets the view input component
  13189. */
  13190. get view(): NodeMaterialConnectionPoint;
  13191. /**
  13192. * Gets the refraction object output component
  13193. */
  13194. get refraction(): NodeMaterialConnectionPoint;
  13195. /**
  13196. * Returns true if the block has a texture
  13197. */
  13198. get hasTexture(): boolean;
  13199. protected _getTexture(): Nullable<BaseTexture>;
  13200. autoConfigure(material: NodeMaterial): void;
  13201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13202. isReady(): boolean;
  13203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13204. /**
  13205. * Gets the main code of the block (fragment side)
  13206. * @param state current state of the node material building
  13207. * @returns the shader code
  13208. */
  13209. getCode(state: NodeMaterialBuildState): string;
  13210. protected _buildBlock(state: NodeMaterialBuildState): this;
  13211. protected _dumpPropertiesCode(): string;
  13212. serialize(): any;
  13213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13214. }
  13215. }
  13216. declare module BABYLON {
  13217. /**
  13218. * Base block used as input for post process
  13219. */
  13220. export class CurrentScreenBlock extends NodeMaterialBlock {
  13221. private _samplerName;
  13222. private _linearDefineName;
  13223. private _gammaDefineName;
  13224. private _mainUVName;
  13225. private _tempTextureRead;
  13226. /**
  13227. * Gets or sets the texture associated with the node
  13228. */
  13229. texture: Nullable<BaseTexture>;
  13230. /**
  13231. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13232. */
  13233. convertToGammaSpace: boolean;
  13234. /**
  13235. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13236. */
  13237. convertToLinearSpace: boolean;
  13238. /**
  13239. * Create a new CurrentScreenBlock
  13240. * @param name defines the block name
  13241. */
  13242. constructor(name: string);
  13243. /**
  13244. * Gets the current class name
  13245. * @returns the class name
  13246. */
  13247. getClassName(): string;
  13248. /**
  13249. * Gets the uv input component
  13250. */
  13251. get uv(): NodeMaterialConnectionPoint;
  13252. /**
  13253. * Gets the rgba output component
  13254. */
  13255. get rgba(): NodeMaterialConnectionPoint;
  13256. /**
  13257. * Gets the rgb output component
  13258. */
  13259. get rgb(): NodeMaterialConnectionPoint;
  13260. /**
  13261. * Gets the r output component
  13262. */
  13263. get r(): NodeMaterialConnectionPoint;
  13264. /**
  13265. * Gets the g output component
  13266. */
  13267. get g(): NodeMaterialConnectionPoint;
  13268. /**
  13269. * Gets the b output component
  13270. */
  13271. get b(): NodeMaterialConnectionPoint;
  13272. /**
  13273. * Gets the a output component
  13274. */
  13275. get a(): NodeMaterialConnectionPoint;
  13276. /**
  13277. * Initialize the block and prepare the context for build
  13278. * @param state defines the state that will be used for the build
  13279. */
  13280. initialize(state: NodeMaterialBuildState): void;
  13281. get target(): NodeMaterialBlockTargets;
  13282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13283. isReady(): boolean;
  13284. private _injectVertexCode;
  13285. private _writeTextureRead;
  13286. private _writeOutput;
  13287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13288. serialize(): any;
  13289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13290. }
  13291. }
  13292. declare module BABYLON {
  13293. /**
  13294. * Base block used for the particle texture
  13295. */
  13296. export class ParticleTextureBlock extends NodeMaterialBlock {
  13297. private _samplerName;
  13298. private _linearDefineName;
  13299. private _gammaDefineName;
  13300. private _tempTextureRead;
  13301. /**
  13302. * Gets or sets the texture associated with the node
  13303. */
  13304. texture: Nullable<BaseTexture>;
  13305. /**
  13306. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13307. */
  13308. convertToGammaSpace: boolean;
  13309. /**
  13310. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13311. */
  13312. convertToLinearSpace: boolean;
  13313. /**
  13314. * Create a new ParticleTextureBlock
  13315. * @param name defines the block name
  13316. */
  13317. constructor(name: string);
  13318. /**
  13319. * Gets the current class name
  13320. * @returns the class name
  13321. */
  13322. getClassName(): string;
  13323. /**
  13324. * Gets the uv input component
  13325. */
  13326. get uv(): NodeMaterialConnectionPoint;
  13327. /**
  13328. * Gets the rgba output component
  13329. */
  13330. get rgba(): NodeMaterialConnectionPoint;
  13331. /**
  13332. * Gets the rgb output component
  13333. */
  13334. get rgb(): NodeMaterialConnectionPoint;
  13335. /**
  13336. * Gets the r output component
  13337. */
  13338. get r(): NodeMaterialConnectionPoint;
  13339. /**
  13340. * Gets the g output component
  13341. */
  13342. get g(): NodeMaterialConnectionPoint;
  13343. /**
  13344. * Gets the b output component
  13345. */
  13346. get b(): NodeMaterialConnectionPoint;
  13347. /**
  13348. * Gets the a output component
  13349. */
  13350. get a(): NodeMaterialConnectionPoint;
  13351. /**
  13352. * Initialize the block and prepare the context for build
  13353. * @param state defines the state that will be used for the build
  13354. */
  13355. initialize(state: NodeMaterialBuildState): void;
  13356. autoConfigure(material: NodeMaterial): void;
  13357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13358. isReady(): boolean;
  13359. private _writeOutput;
  13360. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13361. serialize(): any;
  13362. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13363. }
  13364. }
  13365. declare module BABYLON {
  13366. /**
  13367. * Class used to store shared data between 2 NodeMaterialBuildState
  13368. */
  13369. export class NodeMaterialBuildStateSharedData {
  13370. /**
  13371. * Gets the list of emitted varyings
  13372. */
  13373. temps: string[];
  13374. /**
  13375. * Gets the list of emitted varyings
  13376. */
  13377. varyings: string[];
  13378. /**
  13379. * Gets the varying declaration string
  13380. */
  13381. varyingDeclaration: string;
  13382. /**
  13383. * Input blocks
  13384. */
  13385. inputBlocks: InputBlock[];
  13386. /**
  13387. * Input blocks
  13388. */
  13389. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13390. /**
  13391. * Bindable blocks (Blocks that need to set data to the effect)
  13392. */
  13393. bindableBlocks: NodeMaterialBlock[];
  13394. /**
  13395. * List of blocks that can provide a compilation fallback
  13396. */
  13397. blocksWithFallbacks: NodeMaterialBlock[];
  13398. /**
  13399. * List of blocks that can provide a define update
  13400. */
  13401. blocksWithDefines: NodeMaterialBlock[];
  13402. /**
  13403. * List of blocks that can provide a repeatable content
  13404. */
  13405. repeatableContentBlocks: NodeMaterialBlock[];
  13406. /**
  13407. * List of blocks that can provide a dynamic list of uniforms
  13408. */
  13409. dynamicUniformBlocks: NodeMaterialBlock[];
  13410. /**
  13411. * List of blocks that can block the isReady function for the material
  13412. */
  13413. blockingBlocks: NodeMaterialBlock[];
  13414. /**
  13415. * Gets the list of animated inputs
  13416. */
  13417. animatedInputs: InputBlock[];
  13418. /**
  13419. * Build Id used to avoid multiple recompilations
  13420. */
  13421. buildId: number;
  13422. /** List of emitted variables */
  13423. variableNames: {
  13424. [key: string]: number;
  13425. };
  13426. /** List of emitted defines */
  13427. defineNames: {
  13428. [key: string]: number;
  13429. };
  13430. /** Should emit comments? */
  13431. emitComments: boolean;
  13432. /** Emit build activity */
  13433. verbose: boolean;
  13434. /** Gets or sets the hosting scene */
  13435. scene: Scene;
  13436. /**
  13437. * Gets the compilation hints emitted at compilation time
  13438. */
  13439. hints: {
  13440. needWorldViewMatrix: boolean;
  13441. needWorldViewProjectionMatrix: boolean;
  13442. needAlphaBlending: boolean;
  13443. needAlphaTesting: boolean;
  13444. };
  13445. /**
  13446. * List of compilation checks
  13447. */
  13448. checks: {
  13449. emitVertex: boolean;
  13450. emitFragment: boolean;
  13451. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13452. };
  13453. /**
  13454. * Is vertex program allowed to be empty?
  13455. */
  13456. allowEmptyVertexProgram: boolean;
  13457. /** Creates a new shared data */
  13458. constructor();
  13459. /**
  13460. * Emits console errors and exceptions if there is a failing check
  13461. */
  13462. emitErrors(): void;
  13463. }
  13464. }
  13465. declare module BABYLON {
  13466. /**
  13467. * Class used to store node based material build state
  13468. */
  13469. export class NodeMaterialBuildState {
  13470. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13471. supportUniformBuffers: boolean;
  13472. /**
  13473. * Gets the list of emitted attributes
  13474. */
  13475. attributes: string[];
  13476. /**
  13477. * Gets the list of emitted uniforms
  13478. */
  13479. uniforms: string[];
  13480. /**
  13481. * Gets the list of emitted constants
  13482. */
  13483. constants: string[];
  13484. /**
  13485. * Gets the list of emitted samplers
  13486. */
  13487. samplers: string[];
  13488. /**
  13489. * Gets the list of emitted functions
  13490. */
  13491. functions: {
  13492. [key: string]: string;
  13493. };
  13494. /**
  13495. * Gets the list of emitted extensions
  13496. */
  13497. extensions: {
  13498. [key: string]: string;
  13499. };
  13500. /**
  13501. * Gets the target of the compilation state
  13502. */
  13503. target: NodeMaterialBlockTargets;
  13504. /**
  13505. * Gets the list of emitted counters
  13506. */
  13507. counters: {
  13508. [key: string]: number;
  13509. };
  13510. /**
  13511. * Shared data between multiple NodeMaterialBuildState instances
  13512. */
  13513. sharedData: NodeMaterialBuildStateSharedData;
  13514. /** @hidden */
  13515. _vertexState: NodeMaterialBuildState;
  13516. /** @hidden */
  13517. _attributeDeclaration: string;
  13518. /** @hidden */
  13519. _uniformDeclaration: string;
  13520. /** @hidden */
  13521. _constantDeclaration: string;
  13522. /** @hidden */
  13523. _samplerDeclaration: string;
  13524. /** @hidden */
  13525. _varyingTransfer: string;
  13526. /** @hidden */
  13527. _injectAtEnd: string;
  13528. private _repeatableContentAnchorIndex;
  13529. /** @hidden */
  13530. _builtCompilationString: string;
  13531. /**
  13532. * Gets the emitted compilation strings
  13533. */
  13534. compilationString: string;
  13535. /**
  13536. * Finalize the compilation strings
  13537. * @param state defines the current compilation state
  13538. */
  13539. finalize(state: NodeMaterialBuildState): void;
  13540. /** @hidden */
  13541. get _repeatableContentAnchor(): string;
  13542. /** @hidden */
  13543. _getFreeVariableName(prefix: string): string;
  13544. /** @hidden */
  13545. _getFreeDefineName(prefix: string): string;
  13546. /** @hidden */
  13547. _excludeVariableName(name: string): void;
  13548. /** @hidden */
  13549. _emit2DSampler(name: string): void;
  13550. /** @hidden */
  13551. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13552. /** @hidden */
  13553. _emitExtension(name: string, extension: string, define?: string): void;
  13554. /** @hidden */
  13555. _emitFunction(name: string, code: string, comments: string): void;
  13556. /** @hidden */
  13557. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13558. replaceStrings?: {
  13559. search: RegExp;
  13560. replace: string;
  13561. }[];
  13562. repeatKey?: string;
  13563. }): string;
  13564. /** @hidden */
  13565. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13566. repeatKey?: string;
  13567. removeAttributes?: boolean;
  13568. removeUniforms?: boolean;
  13569. removeVaryings?: boolean;
  13570. removeIfDef?: boolean;
  13571. replaceStrings?: {
  13572. search: RegExp;
  13573. replace: string;
  13574. }[];
  13575. }, storeKey?: string): void;
  13576. /** @hidden */
  13577. _registerTempVariable(name: string): boolean;
  13578. /** @hidden */
  13579. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13580. /** @hidden */
  13581. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13582. /** @hidden */
  13583. _emitFloat(value: number): string;
  13584. }
  13585. }
  13586. declare module BABYLON {
  13587. /**
  13588. * Helper class used to generate session unique ID
  13589. */
  13590. export class UniqueIdGenerator {
  13591. private static _UniqueIdCounter;
  13592. /**
  13593. * Gets an unique (relatively to the current scene) Id
  13594. */
  13595. static get UniqueId(): number;
  13596. }
  13597. }
  13598. declare module BABYLON {
  13599. /**
  13600. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13601. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13602. */
  13603. export class EffectFallbacks implements IEffectFallbacks {
  13604. private _defines;
  13605. private _currentRank;
  13606. private _maxRank;
  13607. private _mesh;
  13608. /**
  13609. * Removes the fallback from the bound mesh.
  13610. */
  13611. unBindMesh(): void;
  13612. /**
  13613. * Adds a fallback on the specified property.
  13614. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13615. * @param define The name of the define in the shader
  13616. */
  13617. addFallback(rank: number, define: string): void;
  13618. /**
  13619. * Sets the mesh to use CPU skinning when needing to fallback.
  13620. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13621. * @param mesh The mesh to use the fallbacks.
  13622. */
  13623. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13624. /**
  13625. * Checks to see if more fallbacks are still available.
  13626. */
  13627. get hasMoreFallbacks(): boolean;
  13628. /**
  13629. * Removes the defines that should be removed when falling back.
  13630. * @param currentDefines defines the current define statements for the shader.
  13631. * @param effect defines the current effect we try to compile
  13632. * @returns The resulting defines with defines of the current rank removed.
  13633. */
  13634. reduce(currentDefines: string, effect: Effect): string;
  13635. }
  13636. }
  13637. declare module BABYLON {
  13638. /**
  13639. * Defines a block that can be used inside a node based material
  13640. */
  13641. export class NodeMaterialBlock {
  13642. private _buildId;
  13643. private _buildTarget;
  13644. private _target;
  13645. private _isFinalMerger;
  13646. private _isInput;
  13647. private _name;
  13648. protected _isUnique: boolean;
  13649. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13650. inputsAreExclusive: boolean;
  13651. /** @hidden */
  13652. _codeVariableName: string;
  13653. /** @hidden */
  13654. _inputs: NodeMaterialConnectionPoint[];
  13655. /** @hidden */
  13656. _outputs: NodeMaterialConnectionPoint[];
  13657. /** @hidden */
  13658. _preparationId: number;
  13659. /** @hidden */
  13660. readonly _originalTargetIsNeutral: boolean;
  13661. /**
  13662. * Gets the name of the block
  13663. */
  13664. get name(): string;
  13665. /**
  13666. * Sets the name of the block. Will check if the name is valid.
  13667. */
  13668. set name(newName: string);
  13669. /**
  13670. * Gets or sets the unique id of the node
  13671. */
  13672. uniqueId: number;
  13673. /**
  13674. * Gets or sets the comments associated with this block
  13675. */
  13676. comments: string;
  13677. /**
  13678. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13679. */
  13680. get isUnique(): boolean;
  13681. /**
  13682. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13683. */
  13684. get isFinalMerger(): boolean;
  13685. /**
  13686. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13687. */
  13688. get isInput(): boolean;
  13689. /**
  13690. * Gets or sets the build Id
  13691. */
  13692. get buildId(): number;
  13693. set buildId(value: number);
  13694. /**
  13695. * Gets or sets the target of the block
  13696. */
  13697. get target(): NodeMaterialBlockTargets;
  13698. set target(value: NodeMaterialBlockTargets);
  13699. /**
  13700. * Gets the list of input points
  13701. */
  13702. get inputs(): NodeMaterialConnectionPoint[];
  13703. /** Gets the list of output points */
  13704. get outputs(): NodeMaterialConnectionPoint[];
  13705. /**
  13706. * Find an input by its name
  13707. * @param name defines the name of the input to look for
  13708. * @returns the input or null if not found
  13709. */
  13710. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13711. /**
  13712. * Find an output by its name
  13713. * @param name defines the name of the output to look for
  13714. * @returns the output or null if not found
  13715. */
  13716. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13717. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13718. visibleInInspector: boolean;
  13719. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13720. visibleOnFrame: boolean;
  13721. /**
  13722. * Creates a new NodeMaterialBlock
  13723. * @param name defines the block name
  13724. * @param target defines the target of that block (Vertex by default)
  13725. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13726. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13727. */
  13728. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13729. /**
  13730. * Initialize the block and prepare the context for build
  13731. * @param state defines the state that will be used for the build
  13732. */
  13733. initialize(state: NodeMaterialBuildState): void;
  13734. /**
  13735. * Bind data to effect. Will only be called for blocks with isBindable === true
  13736. * @param effect defines the effect to bind data to
  13737. * @param nodeMaterial defines the hosting NodeMaterial
  13738. * @param mesh defines the mesh that will be rendered
  13739. * @param subMesh defines the submesh that will be rendered
  13740. */
  13741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13742. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13743. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13744. protected _writeFloat(value: number): string;
  13745. /**
  13746. * Gets the current class name e.g. "NodeMaterialBlock"
  13747. * @returns the class name
  13748. */
  13749. getClassName(): string;
  13750. /**
  13751. * Register a new input. Must be called inside a block constructor
  13752. * @param name defines the connection point name
  13753. * @param type defines the connection point type
  13754. * @param isOptional defines a boolean indicating that this input can be omitted
  13755. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13756. * @param point an already created connection point. If not provided, create a new one
  13757. * @returns the current block
  13758. */
  13759. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13760. /**
  13761. * Register a new output. Must be called inside a block constructor
  13762. * @param name defines the connection point name
  13763. * @param type defines the connection point type
  13764. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13765. * @param point an already created connection point. If not provided, create a new one
  13766. * @returns the current block
  13767. */
  13768. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13769. /**
  13770. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13771. * @param forOutput defines an optional connection point to check compatibility with
  13772. * @returns the first available input or null
  13773. */
  13774. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13775. /**
  13776. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13777. * @param forBlock defines an optional block to check compatibility with
  13778. * @returns the first available input or null
  13779. */
  13780. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13781. /**
  13782. * Gets the sibling of the given output
  13783. * @param current defines the current output
  13784. * @returns the next output in the list or null
  13785. */
  13786. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13787. /**
  13788. * Connect current block with another block
  13789. * @param other defines the block to connect with
  13790. * @param options define the various options to help pick the right connections
  13791. * @returns the current block
  13792. */
  13793. connectTo(other: NodeMaterialBlock, options?: {
  13794. input?: string;
  13795. output?: string;
  13796. outputSwizzle?: string;
  13797. }): this | undefined;
  13798. protected _buildBlock(state: NodeMaterialBuildState): void;
  13799. /**
  13800. * Add uniforms, samplers and uniform buffers at compilation time
  13801. * @param state defines the state to update
  13802. * @param nodeMaterial defines the node material requesting the update
  13803. * @param defines defines the material defines to update
  13804. * @param uniformBuffers defines the list of uniform buffer names
  13805. */
  13806. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13807. /**
  13808. * Add potential fallbacks if shader compilation fails
  13809. * @param mesh defines the mesh to be rendered
  13810. * @param fallbacks defines the current prioritized list of fallbacks
  13811. */
  13812. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13813. /**
  13814. * Initialize defines for shader compilation
  13815. * @param mesh defines the mesh to be rendered
  13816. * @param nodeMaterial defines the node material requesting the update
  13817. * @param defines defines the material defines to update
  13818. * @param useInstances specifies that instances should be used
  13819. */
  13820. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13821. /**
  13822. * Update defines for shader compilation
  13823. * @param mesh defines the mesh to be rendered
  13824. * @param nodeMaterial defines the node material requesting the update
  13825. * @param defines defines the material defines to update
  13826. * @param useInstances specifies that instances should be used
  13827. * @param subMesh defines which submesh to render
  13828. */
  13829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13830. /**
  13831. * Lets the block try to connect some inputs automatically
  13832. * @param material defines the hosting NodeMaterial
  13833. */
  13834. autoConfigure(material: NodeMaterial): void;
  13835. /**
  13836. * Function called when a block is declared as repeatable content generator
  13837. * @param vertexShaderState defines the current compilation state for the vertex shader
  13838. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13839. * @param mesh defines the mesh to be rendered
  13840. * @param defines defines the material defines to update
  13841. */
  13842. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13843. /**
  13844. * Checks if the block is ready
  13845. * @param mesh defines the mesh to be rendered
  13846. * @param nodeMaterial defines the node material requesting the update
  13847. * @param defines defines the material defines to update
  13848. * @param useInstances specifies that instances should be used
  13849. * @returns true if the block is ready
  13850. */
  13851. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13852. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13853. private _processBuild;
  13854. /**
  13855. * Validates the new name for the block node.
  13856. * @param newName the new name to be given to the node.
  13857. * @returns false if the name is a reserve word, else true.
  13858. */
  13859. validateBlockName(newName: string): boolean;
  13860. /**
  13861. * Compile the current node and generate the shader code
  13862. * @param state defines the current compilation state (uniforms, samplers, current string)
  13863. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13864. * @returns true if already built
  13865. */
  13866. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13867. protected _inputRename(name: string): string;
  13868. protected _outputRename(name: string): string;
  13869. protected _dumpPropertiesCode(): string;
  13870. /** @hidden */
  13871. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13872. /** @hidden */
  13873. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13874. /**
  13875. * Clone the current block to a new identical block
  13876. * @param scene defines the hosting scene
  13877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13878. * @returns a copy of the current block
  13879. */
  13880. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13881. /**
  13882. * Serializes this block in a JSON representation
  13883. * @returns the serialized block object
  13884. */
  13885. serialize(): any;
  13886. /** @hidden */
  13887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13888. private _deserializePortDisplayNamesAndExposedOnFrame;
  13889. /**
  13890. * Release resources
  13891. */
  13892. dispose(): void;
  13893. }
  13894. }
  13895. declare module BABYLON {
  13896. /**
  13897. * Base class of materials working in push mode in babylon JS
  13898. * @hidden
  13899. */
  13900. export class PushMaterial extends Material {
  13901. protected _activeEffect: Effect;
  13902. protected _normalMatrix: Matrix;
  13903. constructor(name: string, scene: Scene);
  13904. getEffect(): Effect;
  13905. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13906. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13907. /**
  13908. * Binds the given world matrix to the active effect
  13909. *
  13910. * @param world the matrix to bind
  13911. */
  13912. bindOnlyWorldMatrix(world: Matrix): void;
  13913. /**
  13914. * Binds the given normal matrix to the active effect
  13915. *
  13916. * @param normalMatrix the matrix to bind
  13917. */
  13918. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13919. bind(world: Matrix, mesh?: Mesh): void;
  13920. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13921. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13922. }
  13923. }
  13924. declare module BABYLON {
  13925. /**
  13926. * Root class for all node material optimizers
  13927. */
  13928. export class NodeMaterialOptimizer {
  13929. /**
  13930. * Function used to optimize a NodeMaterial graph
  13931. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13932. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13933. */
  13934. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13935. }
  13936. }
  13937. declare module BABYLON {
  13938. /**
  13939. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13940. */
  13941. export class TransformBlock extends NodeMaterialBlock {
  13942. /**
  13943. * Defines the value to use to complement W value to transform it to a Vector4
  13944. */
  13945. complementW: number;
  13946. /**
  13947. * Defines the value to use to complement z value to transform it to a Vector4
  13948. */
  13949. complementZ: number;
  13950. /**
  13951. * Creates a new TransformBlock
  13952. * @param name defines the block name
  13953. */
  13954. constructor(name: string);
  13955. /**
  13956. * Gets the current class name
  13957. * @returns the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Gets the vector input
  13962. */
  13963. get vector(): NodeMaterialConnectionPoint;
  13964. /**
  13965. * Gets the output component
  13966. */
  13967. get output(): NodeMaterialConnectionPoint;
  13968. /**
  13969. * Gets the xyz output component
  13970. */
  13971. get xyz(): NodeMaterialConnectionPoint;
  13972. /**
  13973. * Gets the matrix transform input
  13974. */
  13975. get transform(): NodeMaterialConnectionPoint;
  13976. protected _buildBlock(state: NodeMaterialBuildState): this;
  13977. /**
  13978. * Update defines for shader compilation
  13979. * @param mesh defines the mesh to be rendered
  13980. * @param nodeMaterial defines the node material requesting the update
  13981. * @param defines defines the material defines to update
  13982. * @param useInstances specifies that instances should be used
  13983. * @param subMesh defines which submesh to render
  13984. */
  13985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13986. serialize(): any;
  13987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13988. protected _dumpPropertiesCode(): string;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. /**
  13993. * Block used to output the vertex position
  13994. */
  13995. export class VertexOutputBlock extends NodeMaterialBlock {
  13996. /**
  13997. * Creates a new VertexOutputBlock
  13998. * @param name defines the block name
  13999. */
  14000. constructor(name: string);
  14001. /**
  14002. * Gets the current class name
  14003. * @returns the class name
  14004. */
  14005. getClassName(): string;
  14006. /**
  14007. * Gets the vector input component
  14008. */
  14009. get vector(): NodeMaterialConnectionPoint;
  14010. protected _buildBlock(state: NodeMaterialBuildState): this;
  14011. }
  14012. }
  14013. declare module BABYLON {
  14014. /**
  14015. * Block used to output the final color
  14016. */
  14017. export class FragmentOutputBlock extends NodeMaterialBlock {
  14018. private _linearDefineName;
  14019. private _gammaDefineName;
  14020. /**
  14021. * Create a new FragmentOutputBlock
  14022. * @param name defines the block name
  14023. */
  14024. constructor(name: string);
  14025. /** Gets or sets a boolean indicating if content needs to be converted to gamma space */
  14026. convertToGammaSpace: boolean;
  14027. /** Gets or sets a boolean indicating if content needs to be converted to linear space */
  14028. convertToLinearSpace: boolean;
  14029. /**
  14030. * Gets the current class name
  14031. * @returns the class name
  14032. */
  14033. getClassName(): string;
  14034. /**
  14035. * Gets the rgba input component
  14036. */
  14037. get rgba(): NodeMaterialConnectionPoint;
  14038. /**
  14039. * Gets the rgb input component
  14040. */
  14041. get rgb(): NodeMaterialConnectionPoint;
  14042. /**
  14043. * Gets the a input component
  14044. */
  14045. get a(): NodeMaterialConnectionPoint;
  14046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  14047. protected _buildBlock(state: NodeMaterialBuildState): this;
  14048. protected _dumpPropertiesCode(): string;
  14049. serialize(): any;
  14050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14051. }
  14052. }
  14053. declare module BABYLON {
  14054. /**
  14055. * Block used for the particle ramp gradient section
  14056. */
  14057. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14058. /**
  14059. * Create a new ParticleRampGradientBlock
  14060. * @param name defines the block name
  14061. */
  14062. constructor(name: string);
  14063. /**
  14064. * Gets the current class name
  14065. * @returns the class name
  14066. */
  14067. getClassName(): string;
  14068. /**
  14069. * Gets the color input component
  14070. */
  14071. get color(): NodeMaterialConnectionPoint;
  14072. /**
  14073. * Gets the rampColor output component
  14074. */
  14075. get rampColor(): NodeMaterialConnectionPoint;
  14076. /**
  14077. * Initialize the block and prepare the context for build
  14078. * @param state defines the state that will be used for the build
  14079. */
  14080. initialize(state: NodeMaterialBuildState): void;
  14081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14082. }
  14083. }
  14084. declare module BABYLON {
  14085. /**
  14086. * Block used for the particle blend multiply section
  14087. */
  14088. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14089. /**
  14090. * Create a new ParticleBlendMultiplyBlock
  14091. * @param name defines the block name
  14092. */
  14093. constructor(name: string);
  14094. /**
  14095. * Gets the current class name
  14096. * @returns the class name
  14097. */
  14098. getClassName(): string;
  14099. /**
  14100. * Gets the color input component
  14101. */
  14102. get color(): NodeMaterialConnectionPoint;
  14103. /**
  14104. * Gets the alphaTexture input component
  14105. */
  14106. get alphaTexture(): NodeMaterialConnectionPoint;
  14107. /**
  14108. * Gets the alphaColor input component
  14109. */
  14110. get alphaColor(): NodeMaterialConnectionPoint;
  14111. /**
  14112. * Gets the blendColor output component
  14113. */
  14114. get blendColor(): NodeMaterialConnectionPoint;
  14115. /**
  14116. * Initialize the block and prepare the context for build
  14117. * @param state defines the state that will be used for the build
  14118. */
  14119. initialize(state: NodeMaterialBuildState): void;
  14120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14121. }
  14122. }
  14123. declare module BABYLON {
  14124. /**
  14125. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14126. */
  14127. export class VectorMergerBlock extends NodeMaterialBlock {
  14128. /**
  14129. * Create a new VectorMergerBlock
  14130. * @param name defines the block name
  14131. */
  14132. constructor(name: string);
  14133. /**
  14134. * Gets the current class name
  14135. * @returns the class name
  14136. */
  14137. getClassName(): string;
  14138. /**
  14139. * Gets the xyz component (input)
  14140. */
  14141. get xyzIn(): NodeMaterialConnectionPoint;
  14142. /**
  14143. * Gets the xy component (input)
  14144. */
  14145. get xyIn(): NodeMaterialConnectionPoint;
  14146. /**
  14147. * Gets the x component (input)
  14148. */
  14149. get x(): NodeMaterialConnectionPoint;
  14150. /**
  14151. * Gets the y component (input)
  14152. */
  14153. get y(): NodeMaterialConnectionPoint;
  14154. /**
  14155. * Gets the z component (input)
  14156. */
  14157. get z(): NodeMaterialConnectionPoint;
  14158. /**
  14159. * Gets the w component (input)
  14160. */
  14161. get w(): NodeMaterialConnectionPoint;
  14162. /**
  14163. * Gets the xyzw component (output)
  14164. */
  14165. get xyzw(): NodeMaterialConnectionPoint;
  14166. /**
  14167. * Gets the xyz component (output)
  14168. */
  14169. get xyzOut(): NodeMaterialConnectionPoint;
  14170. /**
  14171. * Gets the xy component (output)
  14172. */
  14173. get xyOut(): NodeMaterialConnectionPoint;
  14174. /**
  14175. * Gets the xy component (output)
  14176. * @deprecated Please use xyOut instead.
  14177. */
  14178. get xy(): NodeMaterialConnectionPoint;
  14179. /**
  14180. * Gets the xyz component (output)
  14181. * @deprecated Please use xyzOut instead.
  14182. */
  14183. get xyz(): NodeMaterialConnectionPoint;
  14184. protected _buildBlock(state: NodeMaterialBuildState): this;
  14185. }
  14186. }
  14187. declare module BABYLON {
  14188. /**
  14189. * Block used to remap a float from a range to a new one
  14190. */
  14191. export class RemapBlock extends NodeMaterialBlock {
  14192. /**
  14193. * Gets or sets the source range
  14194. */
  14195. sourceRange: Vector2;
  14196. /**
  14197. * Gets or sets the target range
  14198. */
  14199. targetRange: Vector2;
  14200. /**
  14201. * Creates a new RemapBlock
  14202. * @param name defines the block name
  14203. */
  14204. constructor(name: string);
  14205. /**
  14206. * Gets the current class name
  14207. * @returns the class name
  14208. */
  14209. getClassName(): string;
  14210. /**
  14211. * Gets the input component
  14212. */
  14213. get input(): NodeMaterialConnectionPoint;
  14214. /**
  14215. * Gets the source min input component
  14216. */
  14217. get sourceMin(): NodeMaterialConnectionPoint;
  14218. /**
  14219. * Gets the source max input component
  14220. */
  14221. get sourceMax(): NodeMaterialConnectionPoint;
  14222. /**
  14223. * Gets the target min input component
  14224. */
  14225. get targetMin(): NodeMaterialConnectionPoint;
  14226. /**
  14227. * Gets the target max input component
  14228. */
  14229. get targetMax(): NodeMaterialConnectionPoint;
  14230. /**
  14231. * Gets the output component
  14232. */
  14233. get output(): NodeMaterialConnectionPoint;
  14234. protected _buildBlock(state: NodeMaterialBuildState): this;
  14235. protected _dumpPropertiesCode(): string;
  14236. serialize(): any;
  14237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14238. }
  14239. }
  14240. declare module BABYLON {
  14241. /**
  14242. * Block used to multiply 2 values
  14243. */
  14244. export class MultiplyBlock extends NodeMaterialBlock {
  14245. /**
  14246. * Creates a new MultiplyBlock
  14247. * @param name defines the block name
  14248. */
  14249. constructor(name: string);
  14250. /**
  14251. * Gets the current class name
  14252. * @returns the class name
  14253. */
  14254. getClassName(): string;
  14255. /**
  14256. * Gets the left operand input component
  14257. */
  14258. get left(): NodeMaterialConnectionPoint;
  14259. /**
  14260. * Gets the right operand input component
  14261. */
  14262. get right(): NodeMaterialConnectionPoint;
  14263. /**
  14264. * Gets the output component
  14265. */
  14266. get output(): NodeMaterialConnectionPoint;
  14267. protected _buildBlock(state: NodeMaterialBuildState): this;
  14268. }
  14269. }
  14270. declare module BABYLON {
  14271. /** Interface used by value gradients (color, factor, ...) */
  14272. export interface IValueGradient {
  14273. /**
  14274. * Gets or sets the gradient value (between 0 and 1)
  14275. */
  14276. gradient: number;
  14277. }
  14278. /** Class used to store color4 gradient */
  14279. export class ColorGradient implements IValueGradient {
  14280. /**
  14281. * Gets or sets the gradient value (between 0 and 1)
  14282. */
  14283. gradient: number;
  14284. /**
  14285. * Gets or sets first associated color
  14286. */
  14287. color1: Color4;
  14288. /**
  14289. * Gets or sets second associated color
  14290. */
  14291. color2?: Color4 | undefined;
  14292. /**
  14293. * Creates a new color4 gradient
  14294. * @param gradient gets or sets the gradient value (between 0 and 1)
  14295. * @param color1 gets or sets first associated color
  14296. * @param color2 gets or sets first second color
  14297. */
  14298. constructor(
  14299. /**
  14300. * Gets or sets the gradient value (between 0 and 1)
  14301. */
  14302. gradient: number,
  14303. /**
  14304. * Gets or sets first associated color
  14305. */
  14306. color1: Color4,
  14307. /**
  14308. * Gets or sets second associated color
  14309. */
  14310. color2?: Color4 | undefined);
  14311. /**
  14312. * Will get a color picked randomly between color1 and color2.
  14313. * If color2 is undefined then color1 will be used
  14314. * @param result defines the target Color4 to store the result in
  14315. */
  14316. getColorToRef(result: Color4): void;
  14317. }
  14318. /** Class used to store color 3 gradient */
  14319. export class Color3Gradient implements IValueGradient {
  14320. /**
  14321. * Gets or sets the gradient value (between 0 and 1)
  14322. */
  14323. gradient: number;
  14324. /**
  14325. * Gets or sets the associated color
  14326. */
  14327. color: Color3;
  14328. /**
  14329. * Creates a new color3 gradient
  14330. * @param gradient gets or sets the gradient value (between 0 and 1)
  14331. * @param color gets or sets associated color
  14332. */
  14333. constructor(
  14334. /**
  14335. * Gets or sets the gradient value (between 0 and 1)
  14336. */
  14337. gradient: number,
  14338. /**
  14339. * Gets or sets the associated color
  14340. */
  14341. color: Color3);
  14342. }
  14343. /** Class used to store factor gradient */
  14344. export class FactorGradient implements IValueGradient {
  14345. /**
  14346. * Gets or sets the gradient value (between 0 and 1)
  14347. */
  14348. gradient: number;
  14349. /**
  14350. * Gets or sets first associated factor
  14351. */
  14352. factor1: number;
  14353. /**
  14354. * Gets or sets second associated factor
  14355. */
  14356. factor2?: number | undefined;
  14357. /**
  14358. * Creates a new factor gradient
  14359. * @param gradient gets or sets the gradient value (between 0 and 1)
  14360. * @param factor1 gets or sets first associated factor
  14361. * @param factor2 gets or sets second associated factor
  14362. */
  14363. constructor(
  14364. /**
  14365. * Gets or sets the gradient value (between 0 and 1)
  14366. */
  14367. gradient: number,
  14368. /**
  14369. * Gets or sets first associated factor
  14370. */
  14371. factor1: number,
  14372. /**
  14373. * Gets or sets second associated factor
  14374. */
  14375. factor2?: number | undefined);
  14376. /**
  14377. * Will get a number picked randomly between factor1 and factor2.
  14378. * If factor2 is undefined then factor1 will be used
  14379. * @returns the picked number
  14380. */
  14381. getFactor(): number;
  14382. }
  14383. /**
  14384. * Helper used to simplify some generic gradient tasks
  14385. */
  14386. export class GradientHelper {
  14387. /**
  14388. * Gets the current gradient from an array of IValueGradient
  14389. * @param ratio defines the current ratio to get
  14390. * @param gradients defines the array of IValueGradient
  14391. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14392. */
  14393. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14394. }
  14395. }
  14396. declare module BABYLON {
  14397. interface ThinEngine {
  14398. /**
  14399. * Creates a raw texture
  14400. * @param data defines the data to store in the texture
  14401. * @param width defines the width of the texture
  14402. * @param height defines the height of the texture
  14403. * @param format defines the format of the data
  14404. * @param generateMipMaps defines if the engine should generate the mip levels
  14405. * @param invertY defines if data must be stored with Y axis inverted
  14406. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14407. * @param compression defines the compression used (null by default)
  14408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14409. * @returns the raw texture inside an InternalTexture
  14410. */
  14411. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14412. /**
  14413. * Update a raw texture
  14414. * @param texture defines the texture to update
  14415. * @param data defines the data to store in the texture
  14416. * @param format defines the format of the data
  14417. * @param invertY defines if data must be stored with Y axis inverted
  14418. */
  14419. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14420. /**
  14421. * Update a raw texture
  14422. * @param texture defines the texture to update
  14423. * @param data defines the data to store in the texture
  14424. * @param format defines the format of the data
  14425. * @param invertY defines if data must be stored with Y axis inverted
  14426. * @param compression defines the compression used (null by default)
  14427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14428. */
  14429. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14430. /**
  14431. * Creates a new raw cube texture
  14432. * @param data defines the array of data to use to create each face
  14433. * @param size defines the size of the textures
  14434. * @param format defines the format of the data
  14435. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14436. * @param generateMipMaps defines if the engine should generate the mip levels
  14437. * @param invertY defines if data must be stored with Y axis inverted
  14438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14439. * @param compression defines the compression used (null by default)
  14440. * @returns the cube texture as an InternalTexture
  14441. */
  14442. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14443. /**
  14444. * Update a raw cube texture
  14445. * @param texture defines the texture to update
  14446. * @param data defines the data to store
  14447. * @param format defines the data format
  14448. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14449. * @param invertY defines if data must be stored with Y axis inverted
  14450. */
  14451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14452. /**
  14453. * Update a raw cube texture
  14454. * @param texture defines the texture to update
  14455. * @param data defines the data to store
  14456. * @param format defines the data format
  14457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14458. * @param invertY defines if data must be stored with Y axis inverted
  14459. * @param compression defines the compression used (null by default)
  14460. */
  14461. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14462. /**
  14463. * Update a raw cube texture
  14464. * @param texture defines the texture to update
  14465. * @param data defines the data to store
  14466. * @param format defines the data format
  14467. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14468. * @param invertY defines if data must be stored with Y axis inverted
  14469. * @param compression defines the compression used (null by default)
  14470. * @param level defines which level of the texture to update
  14471. */
  14472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14473. /**
  14474. * Creates a new raw cube texture from a specified url
  14475. * @param url defines the url where the data is located
  14476. * @param scene defines the current scene
  14477. * @param size defines the size of the textures
  14478. * @param format defines the format of the data
  14479. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14480. * @param noMipmap defines if the engine should avoid generating the mip levels
  14481. * @param callback defines a callback used to extract texture data from loaded data
  14482. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14483. * @param onLoad defines a callback called when texture is loaded
  14484. * @param onError defines a callback called if there is an error
  14485. * @returns the cube texture as an InternalTexture
  14486. */
  14487. 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;
  14488. /**
  14489. * Creates a new raw cube texture from a specified url
  14490. * @param url defines the url where the data is located
  14491. * @param scene defines the current scene
  14492. * @param size defines the size of the textures
  14493. * @param format defines the format of the data
  14494. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14495. * @param noMipmap defines if the engine should avoid generating the mip levels
  14496. * @param callback defines a callback used to extract texture data from loaded data
  14497. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14498. * @param onLoad defines a callback called when texture is loaded
  14499. * @param onError defines a callback called if there is an error
  14500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14501. * @param invertY defines if data must be stored with Y axis inverted
  14502. * @returns the cube texture as an InternalTexture
  14503. */
  14504. 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;
  14505. /**
  14506. * Creates a new raw 3D texture
  14507. * @param data defines the data used to create the texture
  14508. * @param width defines the width of the texture
  14509. * @param height defines the height of the texture
  14510. * @param depth defines the depth of the texture
  14511. * @param format defines the format of the texture
  14512. * @param generateMipMaps defines if the engine must generate mip levels
  14513. * @param invertY defines if data must be stored with Y axis inverted
  14514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14515. * @param compression defines the compressed used (can be null)
  14516. * @param textureType defines the compressed used (can be null)
  14517. * @returns a new raw 3D texture (stored in an InternalTexture)
  14518. */
  14519. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14520. /**
  14521. * Update a raw 3D texture
  14522. * @param texture defines the texture to update
  14523. * @param data defines the data to store
  14524. * @param format defines the data format
  14525. * @param invertY defines if data must be stored with Y axis inverted
  14526. */
  14527. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14528. /**
  14529. * Update a raw 3D texture
  14530. * @param texture defines the texture to update
  14531. * @param data defines the data to store
  14532. * @param format defines the data format
  14533. * @param invertY defines if data must be stored with Y axis inverted
  14534. * @param compression defines the used compression (can be null)
  14535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14536. */
  14537. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14538. /**
  14539. * Creates a new raw 2D array texture
  14540. * @param data defines the data used to create the texture
  14541. * @param width defines the width of the texture
  14542. * @param height defines the height of the texture
  14543. * @param depth defines the number of layers of the texture
  14544. * @param format defines the format of the texture
  14545. * @param generateMipMaps defines if the engine must generate mip levels
  14546. * @param invertY defines if data must be stored with Y axis inverted
  14547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14548. * @param compression defines the compressed used (can be null)
  14549. * @param textureType defines the compressed used (can be null)
  14550. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14551. */
  14552. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14553. /**
  14554. * Update a raw 2D array texture
  14555. * @param texture defines the texture to update
  14556. * @param data defines the data to store
  14557. * @param format defines the data format
  14558. * @param invertY defines if data must be stored with Y axis inverted
  14559. */
  14560. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14561. /**
  14562. * Update a raw 2D array texture
  14563. * @param texture defines the texture to update
  14564. * @param data defines the data to store
  14565. * @param format defines the data format
  14566. * @param invertY defines if data must be stored with Y axis inverted
  14567. * @param compression defines the used compression (can be null)
  14568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14569. */
  14570. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14571. }
  14572. }
  14573. declare module BABYLON {
  14574. /**
  14575. * Raw texture can help creating a texture directly from an array of data.
  14576. * This can be super useful if you either get the data from an uncompressed source or
  14577. * if you wish to create your texture pixel by pixel.
  14578. */
  14579. export class RawTexture extends Texture {
  14580. /**
  14581. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14582. */
  14583. format: number;
  14584. /**
  14585. * Instantiates a new RawTexture.
  14586. * Raw texture can help creating a texture directly from an array of data.
  14587. * This can be super useful if you either get the data from an uncompressed source or
  14588. * if you wish to create your texture pixel by pixel.
  14589. * @param data define the array of data to use to create the texture
  14590. * @param width define the width of the texture
  14591. * @param height define the height of the texture
  14592. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14593. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14594. * @param generateMipMaps define whether mip maps should be generated or not
  14595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14598. */
  14599. constructor(data: ArrayBufferView, width: number, height: number,
  14600. /**
  14601. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14602. */
  14603. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14604. /**
  14605. * Updates the texture underlying data.
  14606. * @param data Define the new data of the texture
  14607. */
  14608. update(data: ArrayBufferView): void;
  14609. /**
  14610. * Creates a luminance texture from some data.
  14611. * @param data Define the texture data
  14612. * @param width Define the width of the texture
  14613. * @param height Define the height of the texture
  14614. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14615. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14616. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14617. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14618. * @returns the luminance texture
  14619. */
  14620. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14621. /**
  14622. * Creates a luminance alpha texture from some data.
  14623. * @param data Define the texture data
  14624. * @param width Define the width of the texture
  14625. * @param height Define the height of the texture
  14626. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14630. * @returns the luminance alpha texture
  14631. */
  14632. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14633. /**
  14634. * Creates an alpha texture from some data.
  14635. * @param data Define the texture data
  14636. * @param width Define the width of the texture
  14637. * @param height Define the height of the texture
  14638. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14642. * @returns the alpha texture
  14643. */
  14644. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14645. /**
  14646. * Creates a RGB texture from some data.
  14647. * @param data Define the texture data
  14648. * @param width Define the width of the texture
  14649. * @param height Define the height of the texture
  14650. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14654. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14655. * @returns the RGB alpha texture
  14656. */
  14657. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14658. /**
  14659. * Creates a RGBA texture from some data.
  14660. * @param data Define the texture data
  14661. * @param width Define the width of the texture
  14662. * @param height Define the height of the texture
  14663. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14667. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14668. * @returns the RGBA texture
  14669. */
  14670. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14671. /**
  14672. * Creates a R texture from some data.
  14673. * @param data Define the texture data
  14674. * @param width Define the width of the texture
  14675. * @param height Define the height of the texture
  14676. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14677. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14678. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14679. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14680. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14681. * @returns the R texture
  14682. */
  14683. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14684. }
  14685. }
  14686. declare module BABYLON {
  14687. interface ThinEngine {
  14688. /**
  14689. * Update a dynamic index buffer
  14690. * @param indexBuffer defines the target index buffer
  14691. * @param indices defines the data to update
  14692. * @param offset defines the offset in the target index buffer where update should start
  14693. */
  14694. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14695. /**
  14696. * Updates a dynamic vertex buffer.
  14697. * @param vertexBuffer the vertex buffer to update
  14698. * @param data the data used to update the vertex buffer
  14699. * @param byteOffset the byte offset of the data
  14700. * @param byteLength the byte length of the data
  14701. */
  14702. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14703. }
  14704. }
  14705. declare module BABYLON {
  14706. interface AbstractScene {
  14707. /**
  14708. * The list of procedural textures added to the scene
  14709. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14710. */
  14711. proceduralTextures: Array<ProceduralTexture>;
  14712. }
  14713. /**
  14714. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14715. * in a given scene.
  14716. */
  14717. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14718. /**
  14719. * The component name helpful to identify the component in the list of scene components.
  14720. */
  14721. readonly name: string;
  14722. /**
  14723. * The scene the component belongs to.
  14724. */
  14725. scene: Scene;
  14726. /**
  14727. * Creates a new instance of the component for the given scene
  14728. * @param scene Defines the scene to register the component in
  14729. */
  14730. constructor(scene: Scene);
  14731. /**
  14732. * Registers the component in a given scene
  14733. */
  14734. register(): void;
  14735. /**
  14736. * Rebuilds the elements related to this component in case of
  14737. * context lost for instance.
  14738. */
  14739. rebuild(): void;
  14740. /**
  14741. * Disposes the component and the associated resources.
  14742. */
  14743. dispose(): void;
  14744. private _beforeClear;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. interface ThinEngine {
  14749. /**
  14750. * Creates a new render target cube texture
  14751. * @param size defines the size of the texture
  14752. * @param options defines the options used to create the texture
  14753. * @returns a new render target cube texture stored in an InternalTexture
  14754. */
  14755. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14756. }
  14757. }
  14758. declare module BABYLON {
  14759. /** @hidden */
  14760. export var proceduralVertexShader: {
  14761. name: string;
  14762. shader: string;
  14763. };
  14764. }
  14765. declare module BABYLON {
  14766. /**
  14767. * 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.
  14768. * This is the base class of any Procedural texture and contains most of the shareable code.
  14769. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14770. */
  14771. export class ProceduralTexture extends Texture {
  14772. /**
  14773. * Define if the texture is enabled or not (disabled texture will not render)
  14774. */
  14775. isEnabled: boolean;
  14776. /**
  14777. * Define if the texture must be cleared before rendering (default is true)
  14778. */
  14779. autoClear: boolean;
  14780. /**
  14781. * Callback called when the texture is generated
  14782. */
  14783. onGenerated: () => void;
  14784. /**
  14785. * Event raised when the texture is generated
  14786. */
  14787. onGeneratedObservable: Observable<ProceduralTexture>;
  14788. /**
  14789. * Event raised before the texture is generated
  14790. */
  14791. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14792. /**
  14793. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14794. */
  14795. nodeMaterialSource: Nullable<NodeMaterial>;
  14796. /** @hidden */
  14797. _generateMipMaps: boolean;
  14798. /** @hidden **/
  14799. _effect: Effect;
  14800. /** @hidden */
  14801. _textures: {
  14802. [key: string]: Texture;
  14803. };
  14804. /** @hidden */
  14805. protected _fallbackTexture: Nullable<Texture>;
  14806. private _size;
  14807. private _textureType;
  14808. private _currentRefreshId;
  14809. private _frameId;
  14810. private _refreshRate;
  14811. private _vertexBuffers;
  14812. private _indexBuffer;
  14813. private _uniforms;
  14814. private _samplers;
  14815. private _fragment;
  14816. private _floats;
  14817. private _ints;
  14818. private _floatsArrays;
  14819. private _colors3;
  14820. private _colors4;
  14821. private _vectors2;
  14822. private _vectors3;
  14823. private _matrices;
  14824. private _fallbackTextureUsed;
  14825. private _fullEngine;
  14826. private _cachedDefines;
  14827. private _contentUpdateId;
  14828. private _contentData;
  14829. /**
  14830. * Instantiates a new procedural texture.
  14831. * 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.
  14832. * This is the base class of any Procedural texture and contains most of the shareable code.
  14833. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14834. * @param name Define the name of the texture
  14835. * @param size Define the size of the texture to create
  14836. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14837. * @param scene Define the scene the texture belongs to
  14838. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14839. * @param generateMipMaps Define if the texture should creates mip maps or not
  14840. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14841. * @param textureType The FBO internal texture type
  14842. */
  14843. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14844. /**
  14845. * The effect that is created when initializing the post process.
  14846. * @returns The created effect corresponding the the postprocess.
  14847. */
  14848. getEffect(): Effect;
  14849. /**
  14850. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14851. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14852. */
  14853. getContent(): Nullable<Promise<ArrayBufferView>>;
  14854. private _createIndexBuffer;
  14855. /** @hidden */
  14856. _rebuild(): void;
  14857. /**
  14858. * Resets the texture in order to recreate its associated resources.
  14859. * This can be called in case of context loss
  14860. */
  14861. reset(): void;
  14862. protected _getDefines(): string;
  14863. /**
  14864. * Is the texture ready to be used ? (rendered at least once)
  14865. * @returns true if ready, otherwise, false.
  14866. */
  14867. isReady(): boolean;
  14868. /**
  14869. * Resets the refresh counter of the texture and start bak from scratch.
  14870. * Could be useful to regenerate the texture if it is setup to render only once.
  14871. */
  14872. resetRefreshCounter(): void;
  14873. /**
  14874. * Set the fragment shader to use in order to render the texture.
  14875. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14876. */
  14877. setFragment(fragment: any): void;
  14878. /**
  14879. * Define the refresh rate of the texture or the rendering frequency.
  14880. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14881. */
  14882. get refreshRate(): number;
  14883. set refreshRate(value: number);
  14884. /** @hidden */
  14885. _shouldRender(): boolean;
  14886. /**
  14887. * Get the size the texture is rendering at.
  14888. * @returns the size (on cube texture it is always squared)
  14889. */
  14890. getRenderSize(): RenderTargetTextureSize;
  14891. /**
  14892. * Resize the texture to new value.
  14893. * @param size Define the new size the texture should have
  14894. * @param generateMipMaps Define whether the new texture should create mip maps
  14895. */
  14896. resize(size: number, generateMipMaps: boolean): void;
  14897. private _checkUniform;
  14898. /**
  14899. * Set a texture in the shader program used to render.
  14900. * @param name Define the name of the uniform samplers as defined in the shader
  14901. * @param texture Define the texture to bind to this sampler
  14902. * @return the texture itself allowing "fluent" like uniform updates
  14903. */
  14904. setTexture(name: string, texture: Texture): ProceduralTexture;
  14905. /**
  14906. * Set a float in the shader.
  14907. * @param name Define the name of the uniform as defined in the shader
  14908. * @param value Define the value to give to the uniform
  14909. * @return the texture itself allowing "fluent" like uniform updates
  14910. */
  14911. setFloat(name: string, value: number): ProceduralTexture;
  14912. /**
  14913. * Set a int in the shader.
  14914. * @param name Define the name of the uniform as defined in the shader
  14915. * @param value Define the value to give to the uniform
  14916. * @return the texture itself allowing "fluent" like uniform updates
  14917. */
  14918. setInt(name: string, value: number): ProceduralTexture;
  14919. /**
  14920. * Set an array of floats in the shader.
  14921. * @param name Define the name of the uniform as defined in the shader
  14922. * @param value Define the value to give to the uniform
  14923. * @return the texture itself allowing "fluent" like uniform updates
  14924. */
  14925. setFloats(name: string, value: number[]): ProceduralTexture;
  14926. /**
  14927. * Set a vec3 in the shader from a Color3.
  14928. * @param name Define the name of the uniform as defined in the shader
  14929. * @param value Define the value to give to the uniform
  14930. * @return the texture itself allowing "fluent" like uniform updates
  14931. */
  14932. setColor3(name: string, value: Color3): ProceduralTexture;
  14933. /**
  14934. * Set a vec4 in the shader from a Color4.
  14935. * @param name Define the name of the uniform as defined in the shader
  14936. * @param value Define the value to give to the uniform
  14937. * @return the texture itself allowing "fluent" like uniform updates
  14938. */
  14939. setColor4(name: string, value: Color4): ProceduralTexture;
  14940. /**
  14941. * Set a vec2 in the shader from a Vector2.
  14942. * @param name Define the name of the uniform as defined in the shader
  14943. * @param value Define the value to give to the uniform
  14944. * @return the texture itself allowing "fluent" like uniform updates
  14945. */
  14946. setVector2(name: string, value: Vector2): ProceduralTexture;
  14947. /**
  14948. * Set a vec3 in the shader from a Vector3.
  14949. * @param name Define the name of the uniform as defined in the shader
  14950. * @param value Define the value to give to the uniform
  14951. * @return the texture itself allowing "fluent" like uniform updates
  14952. */
  14953. setVector3(name: string, value: Vector3): ProceduralTexture;
  14954. /**
  14955. * Set a mat4 in the shader from a MAtrix.
  14956. * @param name Define the name of the uniform as defined in the shader
  14957. * @param value Define the value to give to the uniform
  14958. * @return the texture itself allowing "fluent" like uniform updates
  14959. */
  14960. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14961. /**
  14962. * Render the texture to its associated render target.
  14963. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14964. */
  14965. render(useCameraPostProcess?: boolean): void;
  14966. /**
  14967. * Clone the texture.
  14968. * @returns the cloned texture
  14969. */
  14970. clone(): ProceduralTexture;
  14971. /**
  14972. * Dispose the texture and release its associated resources.
  14973. */
  14974. dispose(): void;
  14975. }
  14976. }
  14977. declare module BABYLON {
  14978. /**
  14979. * This represents the base class for particle system in Babylon.
  14980. * 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.
  14981. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14982. * @example https://doc.babylonjs.com/babylon101/particles
  14983. */
  14984. export class BaseParticleSystem {
  14985. /**
  14986. * Source color is added to the destination color without alpha affecting the result
  14987. */
  14988. static BLENDMODE_ONEONE: number;
  14989. /**
  14990. * Blend current color and particle color using particle’s alpha
  14991. */
  14992. static BLENDMODE_STANDARD: number;
  14993. /**
  14994. * Add current color and particle color multiplied by particle’s alpha
  14995. */
  14996. static BLENDMODE_ADD: number;
  14997. /**
  14998. * Multiply current color with particle color
  14999. */
  15000. static BLENDMODE_MULTIPLY: number;
  15001. /**
  15002. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15003. */
  15004. static BLENDMODE_MULTIPLYADD: number;
  15005. /**
  15006. * List of animations used by the particle system.
  15007. */
  15008. animations: Animation[];
  15009. /**
  15010. * Gets or sets the unique id of the particle system
  15011. */
  15012. uniqueId: number;
  15013. /**
  15014. * The id of the Particle system.
  15015. */
  15016. id: string;
  15017. /**
  15018. * The friendly name of the Particle system.
  15019. */
  15020. name: string;
  15021. /**
  15022. * Snippet ID if the particle system was created from the snippet server
  15023. */
  15024. snippetId: string;
  15025. /**
  15026. * The rendering group used by the Particle system to chose when to render.
  15027. */
  15028. renderingGroupId: number;
  15029. /**
  15030. * The emitter represents the Mesh or position we are attaching the particle system to.
  15031. */
  15032. emitter: Nullable<AbstractMesh | Vector3>;
  15033. /**
  15034. * The maximum number of particles to emit per frame
  15035. */
  15036. emitRate: number;
  15037. /**
  15038. * If you want to launch only a few particles at once, that can be done, as well.
  15039. */
  15040. manualEmitCount: number;
  15041. /**
  15042. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15043. */
  15044. updateSpeed: number;
  15045. /**
  15046. * The amount of time the particle system is running (depends of the overall update speed).
  15047. */
  15048. targetStopDuration: number;
  15049. /**
  15050. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15051. */
  15052. disposeOnStop: boolean;
  15053. /**
  15054. * Minimum power of emitting particles.
  15055. */
  15056. minEmitPower: number;
  15057. /**
  15058. * Maximum power of emitting particles.
  15059. */
  15060. maxEmitPower: number;
  15061. /**
  15062. * Minimum life time of emitting particles.
  15063. */
  15064. minLifeTime: number;
  15065. /**
  15066. * Maximum life time of emitting particles.
  15067. */
  15068. maxLifeTime: number;
  15069. /**
  15070. * Minimum Size of emitting particles.
  15071. */
  15072. minSize: number;
  15073. /**
  15074. * Maximum Size of emitting particles.
  15075. */
  15076. maxSize: number;
  15077. /**
  15078. * Minimum scale of emitting particles on X axis.
  15079. */
  15080. minScaleX: number;
  15081. /**
  15082. * Maximum scale of emitting particles on X axis.
  15083. */
  15084. maxScaleX: number;
  15085. /**
  15086. * Minimum scale of emitting particles on Y axis.
  15087. */
  15088. minScaleY: number;
  15089. /**
  15090. * Maximum scale of emitting particles on Y axis.
  15091. */
  15092. maxScaleY: number;
  15093. /**
  15094. * Gets or sets the minimal initial rotation in radians.
  15095. */
  15096. minInitialRotation: number;
  15097. /**
  15098. * Gets or sets the maximal initial rotation in radians.
  15099. */
  15100. maxInitialRotation: number;
  15101. /**
  15102. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15103. */
  15104. minAngularSpeed: number;
  15105. /**
  15106. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15107. */
  15108. maxAngularSpeed: number;
  15109. /**
  15110. * The texture used to render each particle. (this can be a spritesheet)
  15111. */
  15112. particleTexture: Nullable<BaseTexture>;
  15113. /**
  15114. * The layer mask we are rendering the particles through.
  15115. */
  15116. layerMask: number;
  15117. /**
  15118. * This can help using your own shader to render the particle system.
  15119. * The according effect will be created
  15120. */
  15121. customShader: any;
  15122. /**
  15123. * By default particle system starts as soon as they are created. This prevents the
  15124. * automatic start to happen and let you decide when to start emitting particles.
  15125. */
  15126. preventAutoStart: boolean;
  15127. protected _rootUrl: string;
  15128. private _noiseTexture;
  15129. /**
  15130. * Gets or sets a texture used to add random noise to particle positions
  15131. */
  15132. get noiseTexture(): Nullable<ProceduralTexture>;
  15133. set noiseTexture(value: Nullable<ProceduralTexture>);
  15134. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15135. noiseStrength: Vector3;
  15136. /**
  15137. * Callback triggered when the particle animation is ending.
  15138. */
  15139. onAnimationEnd: Nullable<() => void>;
  15140. /**
  15141. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15142. */
  15143. blendMode: number;
  15144. /**
  15145. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15146. * to override the particles.
  15147. */
  15148. forceDepthWrite: boolean;
  15149. /** 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 */
  15150. preWarmCycles: number;
  15151. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15152. preWarmStepOffset: number;
  15153. /**
  15154. * 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)
  15155. */
  15156. spriteCellChangeSpeed: number;
  15157. /**
  15158. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15159. */
  15160. startSpriteCellID: number;
  15161. /**
  15162. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15163. */
  15164. endSpriteCellID: number;
  15165. /**
  15166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15167. */
  15168. spriteCellWidth: number;
  15169. /**
  15170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15171. */
  15172. spriteCellHeight: number;
  15173. /**
  15174. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15175. */
  15176. spriteRandomStartCell: boolean;
  15177. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15178. translationPivot: Vector2;
  15179. /** @hidden */
  15180. protected _isAnimationSheetEnabled: boolean;
  15181. /**
  15182. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15183. */
  15184. beginAnimationOnStart: boolean;
  15185. /**
  15186. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15187. */
  15188. beginAnimationFrom: number;
  15189. /**
  15190. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15191. */
  15192. beginAnimationTo: number;
  15193. /**
  15194. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15195. */
  15196. beginAnimationLoop: boolean;
  15197. /**
  15198. * Gets or sets a world offset applied to all particles
  15199. */
  15200. worldOffset: Vector3;
  15201. /**
  15202. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15203. */
  15204. get isAnimationSheetEnabled(): boolean;
  15205. set isAnimationSheetEnabled(value: boolean);
  15206. /**
  15207. * Get hosting scene
  15208. * @returns the scene
  15209. */
  15210. getScene(): Nullable<Scene>;
  15211. /**
  15212. * You can use gravity if you want to give an orientation to your particles.
  15213. */
  15214. gravity: Vector3;
  15215. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15216. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15217. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15218. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15219. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15220. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15221. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15222. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15223. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15224. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15225. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15226. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15227. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15228. /**
  15229. * Defines the delay in milliseconds before starting the system (0 by default)
  15230. */
  15231. startDelay: number;
  15232. /**
  15233. * Gets the current list of drag gradients.
  15234. * You must use addDragGradient and removeDragGradient to update this list
  15235. * @returns the list of drag gradients
  15236. */
  15237. getDragGradients(): Nullable<Array<FactorGradient>>;
  15238. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15239. limitVelocityDamping: number;
  15240. /**
  15241. * Gets the current list of limit velocity gradients.
  15242. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15243. * @returns the list of limit velocity gradients
  15244. */
  15245. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15246. /**
  15247. * Gets the current list of color gradients.
  15248. * You must use addColorGradient and removeColorGradient to update this list
  15249. * @returns the list of color gradients
  15250. */
  15251. getColorGradients(): Nullable<Array<ColorGradient>>;
  15252. /**
  15253. * Gets the current list of size gradients.
  15254. * You must use addSizeGradient and removeSizeGradient to update this list
  15255. * @returns the list of size gradients
  15256. */
  15257. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15258. /**
  15259. * Gets the current list of color remap gradients.
  15260. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15261. * @returns the list of color remap gradients
  15262. */
  15263. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15264. /**
  15265. * Gets the current list of alpha remap gradients.
  15266. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15267. * @returns the list of alpha remap gradients
  15268. */
  15269. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15270. /**
  15271. * Gets the current list of life time gradients.
  15272. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15273. * @returns the list of life time gradients
  15274. */
  15275. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15276. /**
  15277. * Gets the current list of angular speed gradients.
  15278. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15279. * @returns the list of angular speed gradients
  15280. */
  15281. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15282. /**
  15283. * Gets the current list of velocity gradients.
  15284. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15285. * @returns the list of velocity gradients
  15286. */
  15287. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15288. /**
  15289. * Gets the current list of start size gradients.
  15290. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15291. * @returns the list of start size gradients
  15292. */
  15293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15294. /**
  15295. * Gets the current list of emit rate gradients.
  15296. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15297. * @returns the list of emit rate gradients
  15298. */
  15299. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15300. /**
  15301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15302. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15303. */
  15304. get direction1(): Vector3;
  15305. set direction1(value: Vector3);
  15306. /**
  15307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15308. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15309. */
  15310. get direction2(): Vector3;
  15311. set direction2(value: Vector3);
  15312. /**
  15313. * 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.
  15314. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15315. */
  15316. get minEmitBox(): Vector3;
  15317. set minEmitBox(value: Vector3);
  15318. /**
  15319. * 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.
  15320. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15321. */
  15322. get maxEmitBox(): Vector3;
  15323. set maxEmitBox(value: Vector3);
  15324. /**
  15325. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15326. */
  15327. color1: Color4;
  15328. /**
  15329. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15330. */
  15331. color2: Color4;
  15332. /**
  15333. * Color the particle will have at the end of its lifetime
  15334. */
  15335. colorDead: Color4;
  15336. /**
  15337. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15338. */
  15339. textureMask: Color4;
  15340. /**
  15341. * The particle emitter type defines the emitter used by the particle system.
  15342. * It can be for example box, sphere, or cone...
  15343. */
  15344. particleEmitterType: IParticleEmitterType;
  15345. /** @hidden */
  15346. _isSubEmitter: boolean;
  15347. /**
  15348. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15349. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15350. */
  15351. billboardMode: number;
  15352. protected _isBillboardBased: boolean;
  15353. /**
  15354. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15355. */
  15356. get isBillboardBased(): boolean;
  15357. set isBillboardBased(value: boolean);
  15358. /**
  15359. * The scene the particle system belongs to.
  15360. */
  15361. protected _scene: Nullable<Scene>;
  15362. /**
  15363. * The engine the particle system belongs to.
  15364. */
  15365. protected _engine: ThinEngine;
  15366. /**
  15367. * Local cache of defines for image processing.
  15368. */
  15369. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15370. /**
  15371. * Default configuration related to image processing available in the standard Material.
  15372. */
  15373. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15374. /**
  15375. * Gets the image processing configuration used either in this material.
  15376. */
  15377. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15378. /**
  15379. * Sets the Default image processing configuration used either in the this material.
  15380. *
  15381. * If sets to null, the scene one is in use.
  15382. */
  15383. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15384. /**
  15385. * Attaches a new image processing configuration to the Standard Material.
  15386. * @param configuration
  15387. */
  15388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15389. /** @hidden */
  15390. protected _reset(): void;
  15391. /** @hidden */
  15392. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15393. /**
  15394. * Instantiates a particle system.
  15395. * 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.
  15396. * @param name The name of the particle system
  15397. */
  15398. constructor(name: string);
  15399. /**
  15400. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15401. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15402. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15403. * @returns the emitter
  15404. */
  15405. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15406. /**
  15407. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15408. * @param radius The radius of the hemisphere to emit from
  15409. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15410. * @returns the emitter
  15411. */
  15412. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15413. /**
  15414. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15415. * @param radius The radius of the sphere to emit from
  15416. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15417. * @returns the emitter
  15418. */
  15419. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15420. /**
  15421. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15422. * @param radius The radius of the sphere to emit from
  15423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15425. * @returns the emitter
  15426. */
  15427. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15428. /**
  15429. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15430. * @param radius The radius of the emission cylinder
  15431. * @param height The height of the emission cylinder
  15432. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15433. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15434. * @returns the emitter
  15435. */
  15436. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15437. /**
  15438. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15439. * @param radius The radius of the cylinder to emit from
  15440. * @param height The height of the emission cylinder
  15441. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15444. * @returns the emitter
  15445. */
  15446. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15447. /**
  15448. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15449. * @param radius The radius of the cone to emit from
  15450. * @param angle The base angle of the cone
  15451. * @returns the emitter
  15452. */
  15453. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15454. /**
  15455. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15458. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15459. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15460. * @returns the emitter
  15461. */
  15462. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15463. }
  15464. }
  15465. declare module BABYLON {
  15466. /**
  15467. * Type of sub emitter
  15468. */
  15469. export enum SubEmitterType {
  15470. /**
  15471. * Attached to the particle over it's lifetime
  15472. */
  15473. ATTACHED = 0,
  15474. /**
  15475. * Created when the particle dies
  15476. */
  15477. END = 1
  15478. }
  15479. /**
  15480. * Sub emitter class used to emit particles from an existing particle
  15481. */
  15482. export class SubEmitter {
  15483. /**
  15484. * the particle system to be used by the sub emitter
  15485. */
  15486. particleSystem: ParticleSystem;
  15487. /**
  15488. * Type of the submitter (Default: END)
  15489. */
  15490. type: SubEmitterType;
  15491. /**
  15492. * 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)
  15493. * Note: This only is supported when using an emitter of type Mesh
  15494. */
  15495. inheritDirection: boolean;
  15496. /**
  15497. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15498. */
  15499. inheritedVelocityAmount: number;
  15500. /**
  15501. * Creates a sub emitter
  15502. * @param particleSystem the particle system to be used by the sub emitter
  15503. */
  15504. constructor(
  15505. /**
  15506. * the particle system to be used by the sub emitter
  15507. */
  15508. particleSystem: ParticleSystem);
  15509. /**
  15510. * Clones the sub emitter
  15511. * @returns the cloned sub emitter
  15512. */
  15513. clone(): SubEmitter;
  15514. /**
  15515. * Serialize current object to a JSON object
  15516. * @returns the serialized object
  15517. */
  15518. serialize(): any;
  15519. /** @hidden */
  15520. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15521. /**
  15522. * Creates a new SubEmitter from a serialized JSON version
  15523. * @param serializationObject defines the JSON object to read from
  15524. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15525. * @param rootUrl defines the rootUrl for data loading
  15526. * @returns a new SubEmitter
  15527. */
  15528. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15529. /** Release associated resources */
  15530. dispose(): void;
  15531. }
  15532. }
  15533. declare module BABYLON {
  15534. /** @hidden */
  15535. export var clipPlaneFragmentDeclaration: {
  15536. name: string;
  15537. shader: string;
  15538. };
  15539. }
  15540. declare module BABYLON {
  15541. /** @hidden */
  15542. export var imageProcessingDeclaration: {
  15543. name: string;
  15544. shader: string;
  15545. };
  15546. }
  15547. declare module BABYLON {
  15548. /** @hidden */
  15549. export var imageProcessingFunctions: {
  15550. name: string;
  15551. shader: string;
  15552. };
  15553. }
  15554. declare module BABYLON {
  15555. /** @hidden */
  15556. export var clipPlaneFragment: {
  15557. name: string;
  15558. shader: string;
  15559. };
  15560. }
  15561. declare module BABYLON {
  15562. /** @hidden */
  15563. export var particlesPixelShader: {
  15564. name: string;
  15565. shader: string;
  15566. };
  15567. }
  15568. declare module BABYLON {
  15569. /** @hidden */
  15570. export var clipPlaneVertexDeclaration: {
  15571. name: string;
  15572. shader: string;
  15573. };
  15574. }
  15575. declare module BABYLON {
  15576. /** @hidden */
  15577. export var clipPlaneVertex: {
  15578. name: string;
  15579. shader: string;
  15580. };
  15581. }
  15582. declare module BABYLON {
  15583. /** @hidden */
  15584. export var particlesVertexShader: {
  15585. name: string;
  15586. shader: string;
  15587. };
  15588. }
  15589. declare module BABYLON {
  15590. /**
  15591. * Interface used to define entities containing multiple clip planes
  15592. */
  15593. export interface IClipPlanesHolder {
  15594. /**
  15595. * Gets or sets the active clipplane 1
  15596. */
  15597. clipPlane: Nullable<Plane>;
  15598. /**
  15599. * Gets or sets the active clipplane 2
  15600. */
  15601. clipPlane2: Nullable<Plane>;
  15602. /**
  15603. * Gets or sets the active clipplane 3
  15604. */
  15605. clipPlane3: Nullable<Plane>;
  15606. /**
  15607. * Gets or sets the active clipplane 4
  15608. */
  15609. clipPlane4: Nullable<Plane>;
  15610. /**
  15611. * Gets or sets the active clipplane 5
  15612. */
  15613. clipPlane5: Nullable<Plane>;
  15614. /**
  15615. * Gets or sets the active clipplane 6
  15616. */
  15617. clipPlane6: Nullable<Plane>;
  15618. }
  15619. }
  15620. declare module BABYLON {
  15621. /**
  15622. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15623. *
  15624. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15625. *
  15626. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15627. */
  15628. export class ThinMaterialHelper {
  15629. /**
  15630. * Binds the clip plane information from the holder to the effect.
  15631. * @param effect The effect we are binding the data to
  15632. * @param holder The entity containing the clip plane information
  15633. */
  15634. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15635. }
  15636. }
  15637. declare module BABYLON {
  15638. interface ThinEngine {
  15639. /**
  15640. * Sets alpha constants used by some alpha blending modes
  15641. * @param r defines the red component
  15642. * @param g defines the green component
  15643. * @param b defines the blue component
  15644. * @param a defines the alpha component
  15645. */
  15646. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15647. /**
  15648. * Sets the current alpha mode
  15649. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15650. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15651. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15652. */
  15653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15654. /**
  15655. * Gets the current alpha mode
  15656. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15657. * @returns the current alpha mode
  15658. */
  15659. getAlphaMode(): number;
  15660. /**
  15661. * Sets the current alpha equation
  15662. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15663. */
  15664. setAlphaEquation(equation: number): void;
  15665. /**
  15666. * Gets the current alpha equation.
  15667. * @returns the current alpha equation
  15668. */
  15669. getAlphaEquation(): number;
  15670. }
  15671. }
  15672. declare module BABYLON {
  15673. /**
  15674. * This represents a particle system in Babylon.
  15675. * 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.
  15676. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15677. * @example https://doc.babylonjs.com/babylon101/particles
  15678. */
  15679. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15680. /**
  15681. * Billboard mode will only apply to Y axis
  15682. */
  15683. static readonly BILLBOARDMODE_Y: number;
  15684. /**
  15685. * Billboard mode will apply to all axes
  15686. */
  15687. static readonly BILLBOARDMODE_ALL: number;
  15688. /**
  15689. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15690. */
  15691. static readonly BILLBOARDMODE_STRETCHED: number;
  15692. /**
  15693. * This function can be defined to provide custom update for active particles.
  15694. * This function will be called instead of regular update (age, position, color, etc.).
  15695. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15696. */
  15697. updateFunction: (particles: Particle[]) => void;
  15698. private _emitterWorldMatrix;
  15699. /**
  15700. * This function can be defined to specify initial direction for every new particle.
  15701. * It by default use the emitterType defined function
  15702. */
  15703. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15704. /**
  15705. * This function can be defined to specify initial position for every new particle.
  15706. * It by default use the emitterType defined function
  15707. */
  15708. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15709. /**
  15710. * @hidden
  15711. */
  15712. _inheritedVelocityOffset: Vector3;
  15713. /**
  15714. * An event triggered when the system is disposed
  15715. */
  15716. onDisposeObservable: Observable<IParticleSystem>;
  15717. /**
  15718. * An event triggered when the system is stopped
  15719. */
  15720. onStoppedObservable: Observable<IParticleSystem>;
  15721. private _onDisposeObserver;
  15722. /**
  15723. * Sets a callback that will be triggered when the system is disposed
  15724. */
  15725. set onDispose(callback: () => void);
  15726. private _particles;
  15727. private _epsilon;
  15728. private _capacity;
  15729. private _stockParticles;
  15730. private _newPartsExcess;
  15731. private _vertexData;
  15732. private _vertexBuffer;
  15733. private _vertexBuffers;
  15734. private _spriteBuffer;
  15735. private _indexBuffer;
  15736. private _effect;
  15737. private _customEffect;
  15738. private _cachedDefines;
  15739. private _scaledColorStep;
  15740. private _colorDiff;
  15741. private _scaledDirection;
  15742. private _scaledGravity;
  15743. private _currentRenderId;
  15744. private _alive;
  15745. private _useInstancing;
  15746. private _vertexArrayObject;
  15747. private _started;
  15748. private _stopped;
  15749. private _actualFrame;
  15750. private _scaledUpdateSpeed;
  15751. private _vertexBufferSize;
  15752. /** @hidden */
  15753. _currentEmitRateGradient: Nullable<FactorGradient>;
  15754. /** @hidden */
  15755. _currentEmitRate1: number;
  15756. /** @hidden */
  15757. _currentEmitRate2: number;
  15758. /** @hidden */
  15759. _currentStartSizeGradient: Nullable<FactorGradient>;
  15760. /** @hidden */
  15761. _currentStartSize1: number;
  15762. /** @hidden */
  15763. _currentStartSize2: number;
  15764. private readonly _rawTextureWidth;
  15765. private _rampGradientsTexture;
  15766. private _useRampGradients;
  15767. /** Gets or sets a matrix to use to compute projection */
  15768. defaultProjectionMatrix: Matrix;
  15769. /** Gets or sets a matrix to use to compute view */
  15770. defaultViewMatrix: Matrix;
  15771. /** Gets or sets a boolean indicating that ramp gradients must be used
  15772. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15773. */
  15774. get useRampGradients(): boolean;
  15775. set useRampGradients(value: boolean);
  15776. /**
  15777. * 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.
  15778. * 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: [])
  15779. */
  15780. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15781. private _subEmitters;
  15782. /**
  15783. * @hidden
  15784. * If the particle systems emitter should be disposed when the particle system is disposed
  15785. */
  15786. _disposeEmitterOnDispose: boolean;
  15787. /**
  15788. * The current active Sub-systems, this property is used by the root particle system only.
  15789. */
  15790. activeSubSystems: Array<ParticleSystem>;
  15791. /**
  15792. * Specifies if the particles are updated in emitter local space or world space
  15793. */
  15794. isLocal: boolean;
  15795. private _rootParticleSystem;
  15796. /**
  15797. * Gets the current list of active particles
  15798. */
  15799. get particles(): Particle[];
  15800. /**
  15801. * Gets the number of particles active at the same time.
  15802. * @returns The number of active particles.
  15803. */
  15804. getActiveCount(): number;
  15805. /**
  15806. * Returns the string "ParticleSystem"
  15807. * @returns a string containing the class name
  15808. */
  15809. getClassName(): string;
  15810. /**
  15811. * Gets a boolean indicating that the system is stopping
  15812. * @returns true if the system is currently stopping
  15813. */
  15814. isStopping(): boolean;
  15815. /**
  15816. * Gets the custom effect used to render the particles
  15817. * @param blendMode Blend mode for which the effect should be retrieved
  15818. * @returns The effect
  15819. */
  15820. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15821. /**
  15822. * Sets the custom effect used to render the particles
  15823. * @param effect The effect to set
  15824. * @param blendMode Blend mode for which the effect should be set
  15825. */
  15826. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15827. /** @hidden */
  15828. private _onBeforeDrawParticlesObservable;
  15829. /**
  15830. * Observable that will be called just before the particles are drawn
  15831. */
  15832. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15833. /**
  15834. * Gets the name of the particle vertex shader
  15835. */
  15836. get vertexShaderName(): string;
  15837. /**
  15838. * Instantiates a particle system.
  15839. * 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.
  15840. * @param name The name of the particle system
  15841. * @param capacity The max number of particles alive at the same time
  15842. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15843. * @param customEffect a custom effect used to change the way particles are rendered by default
  15844. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15845. * @param epsilon Offset used to render the particles
  15846. */
  15847. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15848. private _addFactorGradient;
  15849. private _removeFactorGradient;
  15850. /**
  15851. * Adds a new life time gradient
  15852. * @param gradient defines the gradient to use (between 0 and 1)
  15853. * @param factor defines the life time factor to affect to the specified gradient
  15854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15855. * @returns the current particle system
  15856. */
  15857. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15858. /**
  15859. * Remove a specific life time gradient
  15860. * @param gradient defines the gradient to remove
  15861. * @returns the current particle system
  15862. */
  15863. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15864. /**
  15865. * Adds a new size gradient
  15866. * @param gradient defines the gradient to use (between 0 and 1)
  15867. * @param factor defines the size factor to affect to the specified gradient
  15868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15869. * @returns the current particle system
  15870. */
  15871. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15872. /**
  15873. * Remove a specific size gradient
  15874. * @param gradient defines the gradient to remove
  15875. * @returns the current particle system
  15876. */
  15877. removeSizeGradient(gradient: number): IParticleSystem;
  15878. /**
  15879. * Adds a new color remap gradient
  15880. * @param gradient defines the gradient to use (between 0 and 1)
  15881. * @param min defines the color remap minimal range
  15882. * @param max defines the color remap maximal range
  15883. * @returns the current particle system
  15884. */
  15885. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15886. /**
  15887. * Remove a specific color remap gradient
  15888. * @param gradient defines the gradient to remove
  15889. * @returns the current particle system
  15890. */
  15891. removeColorRemapGradient(gradient: number): IParticleSystem;
  15892. /**
  15893. * Adds a new alpha remap gradient
  15894. * @param gradient defines the gradient to use (between 0 and 1)
  15895. * @param min defines the alpha remap minimal range
  15896. * @param max defines the alpha remap maximal range
  15897. * @returns the current particle system
  15898. */
  15899. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15900. /**
  15901. * Remove a specific alpha remap gradient
  15902. * @param gradient defines the gradient to remove
  15903. * @returns the current particle system
  15904. */
  15905. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15906. /**
  15907. * Adds a new angular speed gradient
  15908. * @param gradient defines the gradient to use (between 0 and 1)
  15909. * @param factor defines the angular speed to affect to the specified gradient
  15910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15911. * @returns the current particle system
  15912. */
  15913. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15914. /**
  15915. * Remove a specific angular speed gradient
  15916. * @param gradient defines the gradient to remove
  15917. * @returns the current particle system
  15918. */
  15919. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15920. /**
  15921. * Adds a new velocity gradient
  15922. * @param gradient defines the gradient to use (between 0 and 1)
  15923. * @param factor defines the velocity to affect to the specified gradient
  15924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15925. * @returns the current particle system
  15926. */
  15927. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15928. /**
  15929. * Remove a specific velocity gradient
  15930. * @param gradient defines the gradient to remove
  15931. * @returns the current particle system
  15932. */
  15933. removeVelocityGradient(gradient: number): IParticleSystem;
  15934. /**
  15935. * Adds a new limit velocity gradient
  15936. * @param gradient defines the gradient to use (between 0 and 1)
  15937. * @param factor defines the limit velocity value to affect to the specified gradient
  15938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15939. * @returns the current particle system
  15940. */
  15941. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15942. /**
  15943. * Remove a specific limit velocity gradient
  15944. * @param gradient defines the gradient to remove
  15945. * @returns the current particle system
  15946. */
  15947. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15948. /**
  15949. * Adds a new drag gradient
  15950. * @param gradient defines the gradient to use (between 0 and 1)
  15951. * @param factor defines the drag value to affect to the specified gradient
  15952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15953. * @returns the current particle system
  15954. */
  15955. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15956. /**
  15957. * Remove a specific drag gradient
  15958. * @param gradient defines the gradient to remove
  15959. * @returns the current particle system
  15960. */
  15961. removeDragGradient(gradient: number): IParticleSystem;
  15962. /**
  15963. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15964. * @param gradient defines the gradient to use (between 0 and 1)
  15965. * @param factor defines the emit rate value to affect to the specified gradient
  15966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15967. * @returns the current particle system
  15968. */
  15969. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15970. /**
  15971. * Remove a specific emit rate gradient
  15972. * @param gradient defines the gradient to remove
  15973. * @returns the current particle system
  15974. */
  15975. removeEmitRateGradient(gradient: number): IParticleSystem;
  15976. /**
  15977. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15978. * @param gradient defines the gradient to use (between 0 and 1)
  15979. * @param factor defines the start size value to affect to the specified gradient
  15980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15981. * @returns the current particle system
  15982. */
  15983. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15984. /**
  15985. * Remove a specific start size gradient
  15986. * @param gradient defines the gradient to remove
  15987. * @returns the current particle system
  15988. */
  15989. removeStartSizeGradient(gradient: number): IParticleSystem;
  15990. private _createRampGradientTexture;
  15991. /**
  15992. * Gets the current list of ramp gradients.
  15993. * You must use addRampGradient and removeRampGradient to update this list
  15994. * @returns the list of ramp gradients
  15995. */
  15996. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15997. /** Force the system to rebuild all gradients that need to be resync */
  15998. forceRefreshGradients(): void;
  15999. private _syncRampGradientTexture;
  16000. /**
  16001. * Adds a new ramp gradient used to remap particle colors
  16002. * @param gradient defines the gradient to use (between 0 and 1)
  16003. * @param color defines the color to affect to the specified gradient
  16004. * @returns the current particle system
  16005. */
  16006. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16007. /**
  16008. * Remove a specific ramp gradient
  16009. * @param gradient defines the gradient to remove
  16010. * @returns the current particle system
  16011. */
  16012. removeRampGradient(gradient: number): ParticleSystem;
  16013. /**
  16014. * Adds a new color gradient
  16015. * @param gradient defines the gradient to use (between 0 and 1)
  16016. * @param color1 defines the color to affect to the specified gradient
  16017. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16018. * @returns this particle system
  16019. */
  16020. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16021. /**
  16022. * Remove a specific color gradient
  16023. * @param gradient defines the gradient to remove
  16024. * @returns this particle system
  16025. */
  16026. removeColorGradient(gradient: number): IParticleSystem;
  16027. private _fetchR;
  16028. protected _reset(): void;
  16029. private _resetEffect;
  16030. private _createVertexBuffers;
  16031. private _createIndexBuffer;
  16032. /**
  16033. * Gets the maximum number of particles active at the same time.
  16034. * @returns The max number of active particles.
  16035. */
  16036. getCapacity(): number;
  16037. /**
  16038. * Gets whether there are still active particles in the system.
  16039. * @returns True if it is alive, otherwise false.
  16040. */
  16041. isAlive(): boolean;
  16042. /**
  16043. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16044. * @returns True if it has been started, otherwise false.
  16045. */
  16046. isStarted(): boolean;
  16047. private _prepareSubEmitterInternalArray;
  16048. /**
  16049. * Starts the particle system and begins to emit
  16050. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16051. */
  16052. start(delay?: number): void;
  16053. /**
  16054. * Stops the particle system.
  16055. * @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.
  16056. */
  16057. stop(stopSubEmitters?: boolean): void;
  16058. /**
  16059. * Remove all active particles
  16060. */
  16061. reset(): void;
  16062. /**
  16063. * @hidden (for internal use only)
  16064. */
  16065. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16066. /**
  16067. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16068. * Its lifetime will start back at 0.
  16069. */
  16070. recycleParticle: (particle: Particle) => void;
  16071. private _stopSubEmitters;
  16072. private _createParticle;
  16073. private _removeFromRoot;
  16074. private _emitFromParticle;
  16075. private _update;
  16076. /** @hidden */
  16077. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16078. /** @hidden */
  16079. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16080. /**
  16081. * Fill the defines array according to the current settings of the particle system
  16082. * @param defines Array to be updated
  16083. * @param blendMode blend mode to take into account when updating the array
  16084. */
  16085. fillDefines(defines: Array<string>, blendMode: number): void;
  16086. /**
  16087. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16088. * @param uniforms Uniforms array to fill
  16089. * @param attributes Attributes array to fill
  16090. * @param samplers Samplers array to fill
  16091. */
  16092. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16093. /** @hidden */
  16094. private _getEffect;
  16095. /**
  16096. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16097. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16098. */
  16099. animate(preWarmOnly?: boolean): void;
  16100. private _appendParticleVertices;
  16101. /**
  16102. * Rebuilds the particle system.
  16103. */
  16104. rebuild(): void;
  16105. /**
  16106. * Is this system ready to be used/rendered
  16107. * @return true if the system is ready
  16108. */
  16109. isReady(): boolean;
  16110. private _render;
  16111. /**
  16112. * Renders the particle system in its current state.
  16113. * @returns the current number of particles
  16114. */
  16115. render(): number;
  16116. /**
  16117. * Disposes the particle system and free the associated resources
  16118. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16119. */
  16120. dispose(disposeTexture?: boolean): void;
  16121. /**
  16122. * Clones the particle system.
  16123. * @param name The name of the cloned object
  16124. * @param newEmitter The new emitter to use
  16125. * @returns the cloned particle system
  16126. */
  16127. clone(name: string, newEmitter: any): ParticleSystem;
  16128. /**
  16129. * Serializes the particle system to a JSON object
  16130. * @param serializeTexture defines if the texture must be serialized as well
  16131. * @returns the JSON object
  16132. */
  16133. serialize(serializeTexture?: boolean): any;
  16134. /** @hidden */
  16135. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16136. /** @hidden */
  16137. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16138. /**
  16139. * Parses a JSON object to create a particle system.
  16140. * @param parsedParticleSystem The JSON object to parse
  16141. * @param sceneOrEngine The scene or the engine to create the particle system in
  16142. * @param rootUrl The root url to use to load external dependencies like texture
  16143. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16144. * @returns the Parsed particle system
  16145. */
  16146. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16147. }
  16148. }
  16149. declare module BABYLON {
  16150. /**
  16151. * A particle represents one of the element emitted by a particle system.
  16152. * This is mainly define by its coordinates, direction, velocity and age.
  16153. */
  16154. export class Particle {
  16155. /**
  16156. * The particle system the particle belongs to.
  16157. */
  16158. particleSystem: ParticleSystem;
  16159. private static _Count;
  16160. /**
  16161. * Unique ID of the particle
  16162. */
  16163. id: number;
  16164. /**
  16165. * The world position of the particle in the scene.
  16166. */
  16167. position: Vector3;
  16168. /**
  16169. * The world direction of the particle in the scene.
  16170. */
  16171. direction: Vector3;
  16172. /**
  16173. * The color of the particle.
  16174. */
  16175. color: Color4;
  16176. /**
  16177. * The color change of the particle per step.
  16178. */
  16179. colorStep: Color4;
  16180. /**
  16181. * Defines how long will the life of the particle be.
  16182. */
  16183. lifeTime: number;
  16184. /**
  16185. * The current age of the particle.
  16186. */
  16187. age: number;
  16188. /**
  16189. * The current size of the particle.
  16190. */
  16191. size: number;
  16192. /**
  16193. * The current scale of the particle.
  16194. */
  16195. scale: Vector2;
  16196. /**
  16197. * The current angle of the particle.
  16198. */
  16199. angle: number;
  16200. /**
  16201. * Defines how fast is the angle changing.
  16202. */
  16203. angularSpeed: number;
  16204. /**
  16205. * Defines the cell index used by the particle to be rendered from a sprite.
  16206. */
  16207. cellIndex: number;
  16208. /**
  16209. * The information required to support color remapping
  16210. */
  16211. remapData: Vector4;
  16212. /** @hidden */
  16213. _randomCellOffset?: number;
  16214. /** @hidden */
  16215. _initialDirection: Nullable<Vector3>;
  16216. /** @hidden */
  16217. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16218. /** @hidden */
  16219. _initialStartSpriteCellID: number;
  16220. /** @hidden */
  16221. _initialEndSpriteCellID: number;
  16222. /** @hidden */
  16223. _currentColorGradient: Nullable<ColorGradient>;
  16224. /** @hidden */
  16225. _currentColor1: Color4;
  16226. /** @hidden */
  16227. _currentColor2: Color4;
  16228. /** @hidden */
  16229. _currentSizeGradient: Nullable<FactorGradient>;
  16230. /** @hidden */
  16231. _currentSize1: number;
  16232. /** @hidden */
  16233. _currentSize2: number;
  16234. /** @hidden */
  16235. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16236. /** @hidden */
  16237. _currentAngularSpeed1: number;
  16238. /** @hidden */
  16239. _currentAngularSpeed2: number;
  16240. /** @hidden */
  16241. _currentVelocityGradient: Nullable<FactorGradient>;
  16242. /** @hidden */
  16243. _currentVelocity1: number;
  16244. /** @hidden */
  16245. _currentVelocity2: number;
  16246. /** @hidden */
  16247. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16248. /** @hidden */
  16249. _currentLimitVelocity1: number;
  16250. /** @hidden */
  16251. _currentLimitVelocity2: number;
  16252. /** @hidden */
  16253. _currentDragGradient: Nullable<FactorGradient>;
  16254. /** @hidden */
  16255. _currentDrag1: number;
  16256. /** @hidden */
  16257. _currentDrag2: number;
  16258. /** @hidden */
  16259. _randomNoiseCoordinates1: Vector3;
  16260. /** @hidden */
  16261. _randomNoiseCoordinates2: Vector3;
  16262. /** @hidden */
  16263. _localPosition?: Vector3;
  16264. /**
  16265. * Creates a new instance Particle
  16266. * @param particleSystem the particle system the particle belongs to
  16267. */
  16268. constructor(
  16269. /**
  16270. * The particle system the particle belongs to.
  16271. */
  16272. particleSystem: ParticleSystem);
  16273. private updateCellInfoFromSystem;
  16274. /**
  16275. * Defines how the sprite cell index is updated for the particle
  16276. */
  16277. updateCellIndex(): void;
  16278. /** @hidden */
  16279. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16280. /** @hidden */
  16281. _inheritParticleInfoToSubEmitters(): void;
  16282. /** @hidden */
  16283. _reset(): void;
  16284. /**
  16285. * Copy the properties of particle to another one.
  16286. * @param other the particle to copy the information to.
  16287. */
  16288. copyTo(other: Particle): void;
  16289. }
  16290. }
  16291. declare module BABYLON {
  16292. /**
  16293. * Particle emitter represents a volume emitting particles.
  16294. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16295. */
  16296. export interface IParticleEmitterType {
  16297. /**
  16298. * Called by the particle System when the direction is computed for the created particle.
  16299. * @param worldMatrix is the world matrix of the particle system
  16300. * @param directionToUpdate is the direction vector to update with the result
  16301. * @param particle is the particle we are computed the direction for
  16302. * @param isLocal defines if the direction should be set in local space
  16303. */
  16304. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16305. /**
  16306. * Called by the particle System when the position is computed for the created particle.
  16307. * @param worldMatrix is the world matrix of the particle system
  16308. * @param positionToUpdate is the position vector to update with the result
  16309. * @param particle is the particle we are computed the position for
  16310. * @param isLocal defines if the position should be set in local space
  16311. */
  16312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16313. /**
  16314. * Clones the current emitter and returns a copy of it
  16315. * @returns the new emitter
  16316. */
  16317. clone(): IParticleEmitterType;
  16318. /**
  16319. * Called by the GPUParticleSystem to setup the update shader
  16320. * @param effect defines the update shader
  16321. */
  16322. applyToShader(effect: Effect): void;
  16323. /**
  16324. * Returns a string to use to update the GPU particles update shader
  16325. * @returns the effect defines string
  16326. */
  16327. getEffectDefines(): string;
  16328. /**
  16329. * Returns a string representing the class name
  16330. * @returns a string containing the class name
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Serializes the particle system to a JSON object.
  16335. * @returns the JSON object
  16336. */
  16337. serialize(): any;
  16338. /**
  16339. * Parse properties from a JSON object
  16340. * @param serializationObject defines the JSON object
  16341. * @param scene defines the hosting scene
  16342. */
  16343. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16344. }
  16345. }
  16346. declare module BABYLON {
  16347. /**
  16348. * Particle emitter emitting particles from the inside of a box.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class BoxParticleEmitter implements IParticleEmitterType {
  16352. /**
  16353. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16354. */
  16355. direction1: Vector3;
  16356. /**
  16357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16358. */
  16359. direction2: Vector3;
  16360. /**
  16361. * 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.
  16362. */
  16363. minEmitBox: Vector3;
  16364. /**
  16365. * 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.
  16366. */
  16367. maxEmitBox: Vector3;
  16368. /**
  16369. * Creates a new instance BoxParticleEmitter
  16370. */
  16371. constructor();
  16372. /**
  16373. * Called by the particle System when the direction is computed for the created particle.
  16374. * @param worldMatrix is the world matrix of the particle system
  16375. * @param directionToUpdate is the direction vector to update with the result
  16376. * @param particle is the particle we are computed the direction for
  16377. * @param isLocal defines if the direction should be set in local space
  16378. */
  16379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16380. /**
  16381. * Called by the particle System when the position is computed for the created particle.
  16382. * @param worldMatrix is the world matrix of the particle system
  16383. * @param positionToUpdate is the position vector to update with the result
  16384. * @param particle is the particle we are computed the position for
  16385. * @param isLocal defines if the position should be set in local space
  16386. */
  16387. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16388. /**
  16389. * Clones the current emitter and returns a copy of it
  16390. * @returns the new emitter
  16391. */
  16392. clone(): BoxParticleEmitter;
  16393. /**
  16394. * Called by the GPUParticleSystem to setup the update shader
  16395. * @param effect defines the update shader
  16396. */
  16397. applyToShader(effect: Effect): void;
  16398. /**
  16399. * Returns a string to use to update the GPU particles update shader
  16400. * @returns a string containing the defines string
  16401. */
  16402. getEffectDefines(): string;
  16403. /**
  16404. * Returns the string "BoxParticleEmitter"
  16405. * @returns a string containing the class name
  16406. */
  16407. getClassName(): string;
  16408. /**
  16409. * Serializes the particle system to a JSON object.
  16410. * @returns the JSON object
  16411. */
  16412. serialize(): any;
  16413. /**
  16414. * Parse properties from a JSON object
  16415. * @param serializationObject defines the JSON object
  16416. */
  16417. parse(serializationObject: any): void;
  16418. }
  16419. }
  16420. declare module BABYLON {
  16421. /**
  16422. * Particle emitter emitting particles from the inside of a cone.
  16423. * It emits the particles alongside the cone volume from the base to the particle.
  16424. * The emission direction might be randomized.
  16425. */
  16426. export class ConeParticleEmitter implements IParticleEmitterType {
  16427. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16428. directionRandomizer: number;
  16429. private _radius;
  16430. private _angle;
  16431. private _height;
  16432. /**
  16433. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16434. */
  16435. radiusRange: number;
  16436. /**
  16437. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16438. */
  16439. heightRange: number;
  16440. /**
  16441. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16442. */
  16443. emitFromSpawnPointOnly: boolean;
  16444. /**
  16445. * Gets or sets the radius of the emission cone
  16446. */
  16447. get radius(): number;
  16448. set radius(value: number);
  16449. /**
  16450. * Gets or sets the angle of the emission cone
  16451. */
  16452. get angle(): number;
  16453. set angle(value: number);
  16454. private _buildHeight;
  16455. /**
  16456. * Creates a new instance ConeParticleEmitter
  16457. * @param radius the radius of the emission cone (1 by default)
  16458. * @param angle the cone base angle (PI by default)
  16459. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16460. */
  16461. constructor(radius?: number, angle?: number,
  16462. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16463. directionRandomizer?: number);
  16464. /**
  16465. * Called by the particle System when the direction is computed for the created particle.
  16466. * @param worldMatrix is the world matrix of the particle system
  16467. * @param directionToUpdate is the direction vector to update with the result
  16468. * @param particle is the particle we are computed the direction for
  16469. * @param isLocal defines if the direction should be set in local space
  16470. */
  16471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16472. /**
  16473. * Called by the particle System when the position is computed for the created particle.
  16474. * @param worldMatrix is the world matrix of the particle system
  16475. * @param positionToUpdate is the position vector to update with the result
  16476. * @param particle is the particle we are computed the position for
  16477. * @param isLocal defines if the position should be set in local space
  16478. */
  16479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16480. /**
  16481. * Clones the current emitter and returns a copy of it
  16482. * @returns the new emitter
  16483. */
  16484. clone(): ConeParticleEmitter;
  16485. /**
  16486. * Called by the GPUParticleSystem to setup the update shader
  16487. * @param effect defines the update shader
  16488. */
  16489. applyToShader(effect: Effect): void;
  16490. /**
  16491. * Returns a string to use to update the GPU particles update shader
  16492. * @returns a string containing the defines string
  16493. */
  16494. getEffectDefines(): string;
  16495. /**
  16496. * Returns the string "ConeParticleEmitter"
  16497. * @returns a string containing the class name
  16498. */
  16499. getClassName(): string;
  16500. /**
  16501. * Serializes the particle system to a JSON object.
  16502. * @returns the JSON object
  16503. */
  16504. serialize(): any;
  16505. /**
  16506. * Parse properties from a JSON object
  16507. * @param serializationObject defines the JSON object
  16508. */
  16509. parse(serializationObject: any): void;
  16510. }
  16511. }
  16512. declare module BABYLON {
  16513. /**
  16514. * Particle emitter emitting particles from the inside of a cylinder.
  16515. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16516. */
  16517. export class CylinderParticleEmitter implements IParticleEmitterType {
  16518. /**
  16519. * The radius of the emission cylinder.
  16520. */
  16521. radius: number;
  16522. /**
  16523. * The height of the emission cylinder.
  16524. */
  16525. height: number;
  16526. /**
  16527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16528. */
  16529. radiusRange: number;
  16530. /**
  16531. * How much to randomize the particle direction [0-1].
  16532. */
  16533. directionRandomizer: number;
  16534. /**
  16535. * Creates a new instance CylinderParticleEmitter
  16536. * @param radius the radius of the emission cylinder (1 by default)
  16537. * @param height the height of the emission cylinder (1 by default)
  16538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16539. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16540. */
  16541. constructor(
  16542. /**
  16543. * The radius of the emission cylinder.
  16544. */
  16545. radius?: number,
  16546. /**
  16547. * The height of the emission cylinder.
  16548. */
  16549. height?: number,
  16550. /**
  16551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16552. */
  16553. radiusRange?: number,
  16554. /**
  16555. * How much to randomize the particle direction [0-1].
  16556. */
  16557. directionRandomizer?: number);
  16558. /**
  16559. * Called by the particle System when the direction is computed for the created particle.
  16560. * @param worldMatrix is the world matrix of the particle system
  16561. * @param directionToUpdate is the direction vector to update with the result
  16562. * @param particle is the particle we are computed the direction for
  16563. * @param isLocal defines if the direction should be set in local space
  16564. */
  16565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16566. /**
  16567. * Called by the particle System when the position is computed for the created particle.
  16568. * @param worldMatrix is the world matrix of the particle system
  16569. * @param positionToUpdate is the position vector to update with the result
  16570. * @param particle is the particle we are computed the position for
  16571. * @param isLocal defines if the position should be set in local space
  16572. */
  16573. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16574. /**
  16575. * Clones the current emitter and returns a copy of it
  16576. * @returns the new emitter
  16577. */
  16578. clone(): CylinderParticleEmitter;
  16579. /**
  16580. * Called by the GPUParticleSystem to setup the update shader
  16581. * @param effect defines the update shader
  16582. */
  16583. applyToShader(effect: Effect): void;
  16584. /**
  16585. * Returns a string to use to update the GPU particles update shader
  16586. * @returns a string containing the defines string
  16587. */
  16588. getEffectDefines(): string;
  16589. /**
  16590. * Returns the string "CylinderParticleEmitter"
  16591. * @returns a string containing the class name
  16592. */
  16593. getClassName(): string;
  16594. /**
  16595. * Serializes the particle system to a JSON object.
  16596. * @returns the JSON object
  16597. */
  16598. serialize(): any;
  16599. /**
  16600. * Parse properties from a JSON object
  16601. * @param serializationObject defines the JSON object
  16602. */
  16603. parse(serializationObject: any): void;
  16604. }
  16605. /**
  16606. * Particle emitter emitting particles from the inside of a cylinder.
  16607. * It emits the particles randomly between two vectors.
  16608. */
  16609. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16610. /**
  16611. * The min limit of the emission direction.
  16612. */
  16613. direction1: Vector3;
  16614. /**
  16615. * The max limit of the emission direction.
  16616. */
  16617. direction2: Vector3;
  16618. /**
  16619. * Creates a new instance CylinderDirectedParticleEmitter
  16620. * @param radius the radius of the emission cylinder (1 by default)
  16621. * @param height the height of the emission cylinder (1 by default)
  16622. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16623. * @param direction1 the min limit of the emission direction (up vector by default)
  16624. * @param direction2 the max limit of the emission direction (up vector by default)
  16625. */
  16626. constructor(radius?: number, height?: number, radiusRange?: number,
  16627. /**
  16628. * The min limit of the emission direction.
  16629. */
  16630. direction1?: Vector3,
  16631. /**
  16632. * The max limit of the emission direction.
  16633. */
  16634. direction2?: Vector3);
  16635. /**
  16636. * Called by the particle System when the direction is computed for the created particle.
  16637. * @param worldMatrix is the world matrix of the particle system
  16638. * @param directionToUpdate is the direction vector to update with the result
  16639. * @param particle is the particle we are computed the direction for
  16640. */
  16641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16642. /**
  16643. * Clones the current emitter and returns a copy of it
  16644. * @returns the new emitter
  16645. */
  16646. clone(): CylinderDirectedParticleEmitter;
  16647. /**
  16648. * Called by the GPUParticleSystem to setup the update shader
  16649. * @param effect defines the update shader
  16650. */
  16651. applyToShader(effect: Effect): void;
  16652. /**
  16653. * Returns a string to use to update the GPU particles update shader
  16654. * @returns a string containing the defines string
  16655. */
  16656. getEffectDefines(): string;
  16657. /**
  16658. * Returns the string "CylinderDirectedParticleEmitter"
  16659. * @returns a string containing the class name
  16660. */
  16661. getClassName(): string;
  16662. /**
  16663. * Serializes the particle system to a JSON object.
  16664. * @returns the JSON object
  16665. */
  16666. serialize(): any;
  16667. /**
  16668. * Parse properties from a JSON object
  16669. * @param serializationObject defines the JSON object
  16670. */
  16671. parse(serializationObject: any): void;
  16672. }
  16673. }
  16674. declare module BABYLON {
  16675. /**
  16676. * Particle emitter emitting particles from the inside of a hemisphere.
  16677. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16678. */
  16679. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16680. /**
  16681. * The radius of the emission hemisphere.
  16682. */
  16683. radius: number;
  16684. /**
  16685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16686. */
  16687. radiusRange: number;
  16688. /**
  16689. * How much to randomize the particle direction [0-1].
  16690. */
  16691. directionRandomizer: number;
  16692. /**
  16693. * Creates a new instance HemisphericParticleEmitter
  16694. * @param radius the radius of the emission hemisphere (1 by default)
  16695. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16696. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16697. */
  16698. constructor(
  16699. /**
  16700. * The radius of the emission hemisphere.
  16701. */
  16702. radius?: number,
  16703. /**
  16704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16705. */
  16706. radiusRange?: number,
  16707. /**
  16708. * How much to randomize the particle direction [0-1].
  16709. */
  16710. directionRandomizer?: number);
  16711. /**
  16712. * Called by the particle System when the direction is computed for the created particle.
  16713. * @param worldMatrix is the world matrix of the particle system
  16714. * @param directionToUpdate is the direction vector to update with the result
  16715. * @param particle is the particle we are computed the direction for
  16716. * @param isLocal defines if the direction should be set in local space
  16717. */
  16718. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16719. /**
  16720. * Called by the particle System when the position is computed for the created particle.
  16721. * @param worldMatrix is the world matrix of the particle system
  16722. * @param positionToUpdate is the position vector to update with the result
  16723. * @param particle is the particle we are computed the position for
  16724. * @param isLocal defines if the position should be set in local space
  16725. */
  16726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16727. /**
  16728. * Clones the current emitter and returns a copy of it
  16729. * @returns the new emitter
  16730. */
  16731. clone(): HemisphericParticleEmitter;
  16732. /**
  16733. * Called by the GPUParticleSystem to setup the update shader
  16734. * @param effect defines the update shader
  16735. */
  16736. applyToShader(effect: Effect): void;
  16737. /**
  16738. * Returns a string to use to update the GPU particles update shader
  16739. * @returns a string containing the defines string
  16740. */
  16741. getEffectDefines(): string;
  16742. /**
  16743. * Returns the string "HemisphericParticleEmitter"
  16744. * @returns a string containing the class name
  16745. */
  16746. getClassName(): string;
  16747. /**
  16748. * Serializes the particle system to a JSON object.
  16749. * @returns the JSON object
  16750. */
  16751. serialize(): any;
  16752. /**
  16753. * Parse properties from a JSON object
  16754. * @param serializationObject defines the JSON object
  16755. */
  16756. parse(serializationObject: any): void;
  16757. }
  16758. }
  16759. declare module BABYLON {
  16760. /**
  16761. * Particle emitter emitting particles from a point.
  16762. * It emits the particles randomly between 2 given directions.
  16763. */
  16764. export class PointParticleEmitter implements IParticleEmitterType {
  16765. /**
  16766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16767. */
  16768. direction1: Vector3;
  16769. /**
  16770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16771. */
  16772. direction2: Vector3;
  16773. /**
  16774. * Creates a new instance PointParticleEmitter
  16775. */
  16776. constructor();
  16777. /**
  16778. * Called by the particle System when the direction is computed for the created particle.
  16779. * @param worldMatrix is the world matrix of the particle system
  16780. * @param directionToUpdate is the direction vector to update with the result
  16781. * @param particle is the particle we are computed the direction for
  16782. * @param isLocal defines if the direction should be set in local space
  16783. */
  16784. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16785. /**
  16786. * Called by the particle System when the position is computed for the created particle.
  16787. * @param worldMatrix is the world matrix of the particle system
  16788. * @param positionToUpdate is the position vector to update with the result
  16789. * @param particle is the particle we are computed the position for
  16790. * @param isLocal defines if the position should be set in local space
  16791. */
  16792. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16793. /**
  16794. * Clones the current emitter and returns a copy of it
  16795. * @returns the new emitter
  16796. */
  16797. clone(): PointParticleEmitter;
  16798. /**
  16799. * Called by the GPUParticleSystem to setup the update shader
  16800. * @param effect defines the update shader
  16801. */
  16802. applyToShader(effect: Effect): void;
  16803. /**
  16804. * Returns a string to use to update the GPU particles update shader
  16805. * @returns a string containing the defines string
  16806. */
  16807. getEffectDefines(): string;
  16808. /**
  16809. * Returns the string "PointParticleEmitter"
  16810. * @returns a string containing the class name
  16811. */
  16812. getClassName(): string;
  16813. /**
  16814. * Serializes the particle system to a JSON object.
  16815. * @returns the JSON object
  16816. */
  16817. serialize(): any;
  16818. /**
  16819. * Parse properties from a JSON object
  16820. * @param serializationObject defines the JSON object
  16821. */
  16822. parse(serializationObject: any): void;
  16823. }
  16824. }
  16825. declare module BABYLON {
  16826. /**
  16827. * Particle emitter emitting particles from the inside of a sphere.
  16828. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16829. */
  16830. export class SphereParticleEmitter implements IParticleEmitterType {
  16831. /**
  16832. * The radius of the emission sphere.
  16833. */
  16834. radius: number;
  16835. /**
  16836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16837. */
  16838. radiusRange: number;
  16839. /**
  16840. * How much to randomize the particle direction [0-1].
  16841. */
  16842. directionRandomizer: number;
  16843. /**
  16844. * Creates a new instance SphereParticleEmitter
  16845. * @param radius the radius of the emission sphere (1 by default)
  16846. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16847. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16848. */
  16849. constructor(
  16850. /**
  16851. * The radius of the emission sphere.
  16852. */
  16853. radius?: number,
  16854. /**
  16855. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16856. */
  16857. radiusRange?: number,
  16858. /**
  16859. * How much to randomize the particle direction [0-1].
  16860. */
  16861. directionRandomizer?: number);
  16862. /**
  16863. * Called by the particle System when the direction is computed for the created particle.
  16864. * @param worldMatrix is the world matrix of the particle system
  16865. * @param directionToUpdate is the direction vector to update with the result
  16866. * @param particle is the particle we are computed the direction for
  16867. * @param isLocal defines if the direction should be set in local space
  16868. */
  16869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16870. /**
  16871. * Called by the particle System when the position is computed for the created particle.
  16872. * @param worldMatrix is the world matrix of the particle system
  16873. * @param positionToUpdate is the position vector to update with the result
  16874. * @param particle is the particle we are computed the position for
  16875. * @param isLocal defines if the position should be set in local space
  16876. */
  16877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16878. /**
  16879. * Clones the current emitter and returns a copy of it
  16880. * @returns the new emitter
  16881. */
  16882. clone(): SphereParticleEmitter;
  16883. /**
  16884. * Called by the GPUParticleSystem to setup the update shader
  16885. * @param effect defines the update shader
  16886. */
  16887. applyToShader(effect: Effect): void;
  16888. /**
  16889. * Returns a string to use to update the GPU particles update shader
  16890. * @returns a string containing the defines string
  16891. */
  16892. getEffectDefines(): string;
  16893. /**
  16894. * Returns the string "SphereParticleEmitter"
  16895. * @returns a string containing the class name
  16896. */
  16897. getClassName(): string;
  16898. /**
  16899. * Serializes the particle system to a JSON object.
  16900. * @returns the JSON object
  16901. */
  16902. serialize(): any;
  16903. /**
  16904. * Parse properties from a JSON object
  16905. * @param serializationObject defines the JSON object
  16906. */
  16907. parse(serializationObject: any): void;
  16908. }
  16909. /**
  16910. * Particle emitter emitting particles from the inside of a sphere.
  16911. * It emits the particles randomly between two vectors.
  16912. */
  16913. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16914. /**
  16915. * The min limit of the emission direction.
  16916. */
  16917. direction1: Vector3;
  16918. /**
  16919. * The max limit of the emission direction.
  16920. */
  16921. direction2: Vector3;
  16922. /**
  16923. * Creates a new instance SphereDirectedParticleEmitter
  16924. * @param radius the radius of the emission sphere (1 by default)
  16925. * @param direction1 the min limit of the emission direction (up vector by default)
  16926. * @param direction2 the max limit of the emission direction (up vector by default)
  16927. */
  16928. constructor(radius?: number,
  16929. /**
  16930. * The min limit of the emission direction.
  16931. */
  16932. direction1?: Vector3,
  16933. /**
  16934. * The max limit of the emission direction.
  16935. */
  16936. direction2?: Vector3);
  16937. /**
  16938. * Called by the particle System when the direction is computed for the created particle.
  16939. * @param worldMatrix is the world matrix of the particle system
  16940. * @param directionToUpdate is the direction vector to update with the result
  16941. * @param particle is the particle we are computed the direction for
  16942. */
  16943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16944. /**
  16945. * Clones the current emitter and returns a copy of it
  16946. * @returns the new emitter
  16947. */
  16948. clone(): SphereDirectedParticleEmitter;
  16949. /**
  16950. * Called by the GPUParticleSystem to setup the update shader
  16951. * @param effect defines the update shader
  16952. */
  16953. applyToShader(effect: Effect): void;
  16954. /**
  16955. * Returns a string to use to update the GPU particles update shader
  16956. * @returns a string containing the defines string
  16957. */
  16958. getEffectDefines(): string;
  16959. /**
  16960. * Returns the string "SphereDirectedParticleEmitter"
  16961. * @returns a string containing the class name
  16962. */
  16963. getClassName(): string;
  16964. /**
  16965. * Serializes the particle system to a JSON object.
  16966. * @returns the JSON object
  16967. */
  16968. serialize(): any;
  16969. /**
  16970. * Parse properties from a JSON object
  16971. * @param serializationObject defines the JSON object
  16972. */
  16973. parse(serializationObject: any): void;
  16974. }
  16975. }
  16976. declare module BABYLON {
  16977. /**
  16978. * Particle emitter emitting particles from a custom list of positions.
  16979. */
  16980. export class CustomParticleEmitter implements IParticleEmitterType {
  16981. /**
  16982. * Gets or sets the position generator that will create the initial position of each particle.
  16983. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16984. */
  16985. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16986. /**
  16987. * Gets or sets the destination generator that will create the final destination of each particle.
  16988. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16989. */
  16990. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16991. /**
  16992. * Creates a new instance CustomParticleEmitter
  16993. */
  16994. constructor();
  16995. /**
  16996. * Called by the particle System when the direction is computed for the created particle.
  16997. * @param worldMatrix is the world matrix of the particle system
  16998. * @param directionToUpdate is the direction vector to update with the result
  16999. * @param particle is the particle we are computed the direction for
  17000. * @param isLocal defines if the direction should be set in local space
  17001. */
  17002. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17003. /**
  17004. * Called by the particle System when the position is computed for the created particle.
  17005. * @param worldMatrix is the world matrix of the particle system
  17006. * @param positionToUpdate is the position vector to update with the result
  17007. * @param particle is the particle we are computed the position for
  17008. * @param isLocal defines if the position should be set in local space
  17009. */
  17010. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17011. /**
  17012. * Clones the current emitter and returns a copy of it
  17013. * @returns the new emitter
  17014. */
  17015. clone(): CustomParticleEmitter;
  17016. /**
  17017. * Called by the GPUParticleSystem to setup the update shader
  17018. * @param effect defines the update shader
  17019. */
  17020. applyToShader(effect: Effect): void;
  17021. /**
  17022. * Returns a string to use to update the GPU particles update shader
  17023. * @returns a string containing the defines string
  17024. */
  17025. getEffectDefines(): string;
  17026. /**
  17027. * Returns the string "PointParticleEmitter"
  17028. * @returns a string containing the class name
  17029. */
  17030. getClassName(): string;
  17031. /**
  17032. * Serializes the particle system to a JSON object.
  17033. * @returns the JSON object
  17034. */
  17035. serialize(): any;
  17036. /**
  17037. * Parse properties from a JSON object
  17038. * @param serializationObject defines the JSON object
  17039. */
  17040. parse(serializationObject: any): void;
  17041. }
  17042. }
  17043. declare module BABYLON {
  17044. /**
  17045. * Particle emitter emitting particles from the inside of a box.
  17046. * It emits the particles randomly between 2 given directions.
  17047. */
  17048. export class MeshParticleEmitter implements IParticleEmitterType {
  17049. private _indices;
  17050. private _positions;
  17051. private _normals;
  17052. private _storedNormal;
  17053. private _mesh;
  17054. /**
  17055. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17056. */
  17057. direction1: Vector3;
  17058. /**
  17059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17060. */
  17061. direction2: Vector3;
  17062. /**
  17063. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17064. */
  17065. useMeshNormalsForDirection: boolean;
  17066. /** Defines the mesh to use as source */
  17067. get mesh(): Nullable<AbstractMesh>;
  17068. set mesh(value: Nullable<AbstractMesh>);
  17069. /**
  17070. * Creates a new instance MeshParticleEmitter
  17071. * @param mesh defines the mesh to use as source
  17072. */
  17073. constructor(mesh?: Nullable<AbstractMesh>);
  17074. /**
  17075. * Called by the particle System when the direction is computed for the created particle.
  17076. * @param worldMatrix is the world matrix of the particle system
  17077. * @param directionToUpdate is the direction vector to update with the result
  17078. * @param particle is the particle we are computed the direction for
  17079. * @param isLocal defines if the direction should be set in local space
  17080. */
  17081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17082. /**
  17083. * Called by the particle System when the position is computed for the created particle.
  17084. * @param worldMatrix is the world matrix of the particle system
  17085. * @param positionToUpdate is the position vector to update with the result
  17086. * @param particle is the particle we are computed the position for
  17087. * @param isLocal defines if the position should be set in local space
  17088. */
  17089. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17090. /**
  17091. * Clones the current emitter and returns a copy of it
  17092. * @returns the new emitter
  17093. */
  17094. clone(): MeshParticleEmitter;
  17095. /**
  17096. * Called by the GPUParticleSystem to setup the update shader
  17097. * @param effect defines the update shader
  17098. */
  17099. applyToShader(effect: Effect): void;
  17100. /**
  17101. * Returns a string to use to update the GPU particles update shader
  17102. * @returns a string containing the defines string
  17103. */
  17104. getEffectDefines(): string;
  17105. /**
  17106. * Returns the string "BoxParticleEmitter"
  17107. * @returns a string containing the class name
  17108. */
  17109. getClassName(): string;
  17110. /**
  17111. * Serializes the particle system to a JSON object.
  17112. * @returns the JSON object
  17113. */
  17114. serialize(): any;
  17115. /**
  17116. * Parse properties from a JSON object
  17117. * @param serializationObject defines the JSON object
  17118. * @param scene defines the hosting scene
  17119. */
  17120. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17121. }
  17122. }
  17123. declare module BABYLON {
  17124. /**
  17125. * Interface representing a particle system in Babylon.js.
  17126. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17127. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17128. */
  17129. export interface IParticleSystem {
  17130. /**
  17131. * List of animations used by the particle system.
  17132. */
  17133. animations: Animation[];
  17134. /**
  17135. * The id of the Particle system.
  17136. */
  17137. id: string;
  17138. /**
  17139. * The name of the Particle system.
  17140. */
  17141. name: string;
  17142. /**
  17143. * The emitter represents the Mesh or position we are attaching the particle system to.
  17144. */
  17145. emitter: Nullable<AbstractMesh | Vector3>;
  17146. /**
  17147. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17148. */
  17149. isBillboardBased: boolean;
  17150. /**
  17151. * The rendering group used by the Particle system to chose when to render.
  17152. */
  17153. renderingGroupId: number;
  17154. /**
  17155. * The layer mask we are rendering the particles through.
  17156. */
  17157. layerMask: number;
  17158. /**
  17159. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17160. */
  17161. updateSpeed: number;
  17162. /**
  17163. * The amount of time the particle system is running (depends of the overall update speed).
  17164. */
  17165. targetStopDuration: number;
  17166. /**
  17167. * The texture used to render each particle. (this can be a spritesheet)
  17168. */
  17169. particleTexture: Nullable<BaseTexture>;
  17170. /**
  17171. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17172. */
  17173. blendMode: number;
  17174. /**
  17175. * Minimum life time of emitting particles.
  17176. */
  17177. minLifeTime: number;
  17178. /**
  17179. * Maximum life time of emitting particles.
  17180. */
  17181. maxLifeTime: number;
  17182. /**
  17183. * Minimum Size of emitting particles.
  17184. */
  17185. minSize: number;
  17186. /**
  17187. * Maximum Size of emitting particles.
  17188. */
  17189. maxSize: number;
  17190. /**
  17191. * Minimum scale of emitting particles on X axis.
  17192. */
  17193. minScaleX: number;
  17194. /**
  17195. * Maximum scale of emitting particles on X axis.
  17196. */
  17197. maxScaleX: number;
  17198. /**
  17199. * Minimum scale of emitting particles on Y axis.
  17200. */
  17201. minScaleY: number;
  17202. /**
  17203. * Maximum scale of emitting particles on Y axis.
  17204. */
  17205. maxScaleY: number;
  17206. /**
  17207. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17208. */
  17209. color1: Color4;
  17210. /**
  17211. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17212. */
  17213. color2: Color4;
  17214. /**
  17215. * Color the particle will have at the end of its lifetime.
  17216. */
  17217. colorDead: Color4;
  17218. /**
  17219. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17220. */
  17221. emitRate: number;
  17222. /**
  17223. * You can use gravity if you want to give an orientation to your particles.
  17224. */
  17225. gravity: Vector3;
  17226. /**
  17227. * Minimum power of emitting particles.
  17228. */
  17229. minEmitPower: number;
  17230. /**
  17231. * Maximum power of emitting particles.
  17232. */
  17233. maxEmitPower: number;
  17234. /**
  17235. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17236. */
  17237. minAngularSpeed: number;
  17238. /**
  17239. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17240. */
  17241. maxAngularSpeed: number;
  17242. /**
  17243. * Gets or sets the minimal initial rotation in radians.
  17244. */
  17245. minInitialRotation: number;
  17246. /**
  17247. * Gets or sets the maximal initial rotation in radians.
  17248. */
  17249. maxInitialRotation: number;
  17250. /**
  17251. * The particle emitter type defines the emitter used by the particle system.
  17252. * It can be for example box, sphere, or cone...
  17253. */
  17254. particleEmitterType: Nullable<IParticleEmitterType>;
  17255. /**
  17256. * Defines the delay in milliseconds before starting the system (0 by default)
  17257. */
  17258. startDelay: number;
  17259. /**
  17260. * 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
  17261. */
  17262. preWarmCycles: number;
  17263. /**
  17264. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17265. */
  17266. preWarmStepOffset: number;
  17267. /**
  17268. * 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)
  17269. */
  17270. spriteCellChangeSpeed: number;
  17271. /**
  17272. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17273. */
  17274. startSpriteCellID: number;
  17275. /**
  17276. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17277. */
  17278. endSpriteCellID: number;
  17279. /**
  17280. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17281. */
  17282. spriteCellWidth: number;
  17283. /**
  17284. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17285. */
  17286. spriteCellHeight: number;
  17287. /**
  17288. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17289. */
  17290. spriteRandomStartCell: boolean;
  17291. /**
  17292. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17293. */
  17294. isAnimationSheetEnabled: boolean;
  17295. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17296. translationPivot: Vector2;
  17297. /**
  17298. * Gets or sets a texture used to add random noise to particle positions
  17299. */
  17300. noiseTexture: Nullable<BaseTexture>;
  17301. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17302. noiseStrength: Vector3;
  17303. /**
  17304. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17305. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17306. */
  17307. billboardMode: number;
  17308. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17309. limitVelocityDamping: number;
  17310. /**
  17311. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17312. */
  17313. beginAnimationOnStart: boolean;
  17314. /**
  17315. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17316. */
  17317. beginAnimationFrom: number;
  17318. /**
  17319. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17320. */
  17321. beginAnimationTo: number;
  17322. /**
  17323. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17324. */
  17325. beginAnimationLoop: boolean;
  17326. /**
  17327. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17328. */
  17329. disposeOnStop: boolean;
  17330. /**
  17331. * If you want to launch only a few particles at once, that can be done, as well.
  17332. */
  17333. manualEmitCount: number;
  17334. /**
  17335. * Specifies if the particles are updated in emitter local space or world space
  17336. */
  17337. isLocal: boolean;
  17338. /** Snippet ID if the particle system was created from the snippet server */
  17339. snippetId: string;
  17340. /** Gets or sets a matrix to use to compute projection */
  17341. defaultProjectionMatrix: Matrix;
  17342. /**
  17343. * Gets the maximum number of particles active at the same time.
  17344. * @returns The max number of active particles.
  17345. */
  17346. getCapacity(): number;
  17347. /**
  17348. * Gets the number of particles active at the same time.
  17349. * @returns The number of active particles.
  17350. */
  17351. getActiveCount(): number;
  17352. /**
  17353. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17354. * @returns True if it has been started, otherwise false.
  17355. */
  17356. isStarted(): boolean;
  17357. /**
  17358. * Animates the particle system for this frame.
  17359. */
  17360. animate(): void;
  17361. /**
  17362. * Renders the particle system in its current state.
  17363. * @returns the current number of particles
  17364. */
  17365. render(): number;
  17366. /**
  17367. * Dispose the particle system and frees its associated resources.
  17368. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17369. */
  17370. dispose(disposeTexture?: boolean): void;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<IParticleSystem>;
  17375. /**
  17376. * An event triggered when the system is stopped
  17377. */
  17378. onStoppedObservable: Observable<IParticleSystem>;
  17379. /**
  17380. * Clones the particle system.
  17381. * @param name The name of the cloned object
  17382. * @param newEmitter The new emitter to use
  17383. * @returns the cloned particle system
  17384. */
  17385. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17386. /**
  17387. * Serializes the particle system to a JSON object
  17388. * @param serializeTexture defines if the texture must be serialized as well
  17389. * @returns the JSON object
  17390. */
  17391. serialize(serializeTexture: boolean): any;
  17392. /**
  17393. * Rebuild the particle system
  17394. */
  17395. rebuild(): void;
  17396. /** Force the system to rebuild all gradients that need to be resync */
  17397. forceRefreshGradients(): void;
  17398. /**
  17399. * Starts the particle system and begins to emit
  17400. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17401. */
  17402. start(delay?: number): void;
  17403. /**
  17404. * Stops the particle system.
  17405. */
  17406. stop(): void;
  17407. /**
  17408. * Remove all active particles
  17409. */
  17410. reset(): void;
  17411. /**
  17412. * Gets a boolean indicating that the system is stopping
  17413. * @returns true if the system is currently stopping
  17414. */
  17415. isStopping(): boolean;
  17416. /**
  17417. * Is this system ready to be used/rendered
  17418. * @return true if the system is ready
  17419. */
  17420. isReady(): boolean;
  17421. /**
  17422. * Returns the string "ParticleSystem"
  17423. * @returns a string containing the class name
  17424. */
  17425. getClassName(): string;
  17426. /**
  17427. * Gets the custom effect used to render the particles
  17428. * @param blendMode Blend mode for which the effect should be retrieved
  17429. * @returns The effect
  17430. */
  17431. getCustomEffect(blendMode: number): Nullable<Effect>;
  17432. /**
  17433. * Sets the custom effect used to render the particles
  17434. * @param effect The effect to set
  17435. * @param blendMode Blend mode for which the effect should be set
  17436. */
  17437. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17438. /**
  17439. * Fill the defines array according to the current settings of the particle system
  17440. * @param defines Array to be updated
  17441. * @param blendMode blend mode to take into account when updating the array
  17442. */
  17443. fillDefines(defines: Array<string>, blendMode: number): void;
  17444. /**
  17445. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17446. * @param uniforms Uniforms array to fill
  17447. * @param attributes Attributes array to fill
  17448. * @param samplers Samplers array to fill
  17449. */
  17450. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17451. /**
  17452. * Observable that will be called just before the particles are drawn
  17453. */
  17454. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17455. /**
  17456. * Gets the name of the particle vertex shader
  17457. */
  17458. vertexShaderName: string;
  17459. /**
  17460. * Adds a new color gradient
  17461. * @param gradient defines the gradient to use (between 0 and 1)
  17462. * @param color1 defines the color to affect to the specified gradient
  17463. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17464. * @returns the current particle system
  17465. */
  17466. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17467. /**
  17468. * Remove a specific color gradient
  17469. * @param gradient defines the gradient to remove
  17470. * @returns the current particle system
  17471. */
  17472. removeColorGradient(gradient: number): IParticleSystem;
  17473. /**
  17474. * Adds a new size gradient
  17475. * @param gradient defines the gradient to use (between 0 and 1)
  17476. * @param factor defines the size factor to affect to the specified gradient
  17477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17478. * @returns the current particle system
  17479. */
  17480. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17481. /**
  17482. * Remove a specific size gradient
  17483. * @param gradient defines the gradient to remove
  17484. * @returns the current particle system
  17485. */
  17486. removeSizeGradient(gradient: number): IParticleSystem;
  17487. /**
  17488. * Gets the current list of color gradients.
  17489. * You must use addColorGradient and removeColorGradient to update this list
  17490. * @returns the list of color gradients
  17491. */
  17492. getColorGradients(): Nullable<Array<ColorGradient>>;
  17493. /**
  17494. * Gets the current list of size gradients.
  17495. * You must use addSizeGradient and removeSizeGradient to update this list
  17496. * @returns the list of size gradients
  17497. */
  17498. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17499. /**
  17500. * Gets the current list of angular speed gradients.
  17501. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17502. * @returns the list of angular speed gradients
  17503. */
  17504. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17505. /**
  17506. * Adds a new angular speed gradient
  17507. * @param gradient defines the gradient to use (between 0 and 1)
  17508. * @param factor defines the angular speed to affect to the specified gradient
  17509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17510. * @returns the current particle system
  17511. */
  17512. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17513. /**
  17514. * Remove a specific angular speed gradient
  17515. * @param gradient defines the gradient to remove
  17516. * @returns the current particle system
  17517. */
  17518. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17519. /**
  17520. * Gets the current list of velocity gradients.
  17521. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17522. * @returns the list of velocity gradients
  17523. */
  17524. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17525. /**
  17526. * Adds a new velocity gradient
  17527. * @param gradient defines the gradient to use (between 0 and 1)
  17528. * @param factor defines the velocity to affect to the specified gradient
  17529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17530. * @returns the current particle system
  17531. */
  17532. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17533. /**
  17534. * Remove a specific velocity gradient
  17535. * @param gradient defines the gradient to remove
  17536. * @returns the current particle system
  17537. */
  17538. removeVelocityGradient(gradient: number): IParticleSystem;
  17539. /**
  17540. * Gets the current list of limit velocity gradients.
  17541. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17542. * @returns the list of limit velocity gradients
  17543. */
  17544. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17545. /**
  17546. * Adds a new limit velocity gradient
  17547. * @param gradient defines the gradient to use (between 0 and 1)
  17548. * @param factor defines the limit velocity to affect to the specified gradient
  17549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17550. * @returns the current particle system
  17551. */
  17552. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17553. /**
  17554. * Remove a specific limit velocity gradient
  17555. * @param gradient defines the gradient to remove
  17556. * @returns the current particle system
  17557. */
  17558. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17559. /**
  17560. * Adds a new drag gradient
  17561. * @param gradient defines the gradient to use (between 0 and 1)
  17562. * @param factor defines the drag to affect to the specified gradient
  17563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17564. * @returns the current particle system
  17565. */
  17566. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17567. /**
  17568. * Remove a specific drag gradient
  17569. * @param gradient defines the gradient to remove
  17570. * @returns the current particle system
  17571. */
  17572. removeDragGradient(gradient: number): IParticleSystem;
  17573. /**
  17574. * Gets the current list of drag gradients.
  17575. * You must use addDragGradient and removeDragGradient to update this list
  17576. * @returns the list of drag gradients
  17577. */
  17578. getDragGradients(): Nullable<Array<FactorGradient>>;
  17579. /**
  17580. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17581. * @param gradient defines the gradient to use (between 0 and 1)
  17582. * @param factor defines the emit rate to affect to the specified gradient
  17583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17584. * @returns the current particle system
  17585. */
  17586. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17587. /**
  17588. * Remove a specific emit rate gradient
  17589. * @param gradient defines the gradient to remove
  17590. * @returns the current particle system
  17591. */
  17592. removeEmitRateGradient(gradient: number): IParticleSystem;
  17593. /**
  17594. * Gets the current list of emit rate gradients.
  17595. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17596. * @returns the list of emit rate gradients
  17597. */
  17598. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17599. /**
  17600. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17601. * @param gradient defines the gradient to use (between 0 and 1)
  17602. * @param factor defines the start size to affect to the specified gradient
  17603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17604. * @returns the current particle system
  17605. */
  17606. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17607. /**
  17608. * Remove a specific start size gradient
  17609. * @param gradient defines the gradient to remove
  17610. * @returns the current particle system
  17611. */
  17612. removeStartSizeGradient(gradient: number): IParticleSystem;
  17613. /**
  17614. * Gets the current list of start size gradients.
  17615. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17616. * @returns the list of start size gradients
  17617. */
  17618. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17619. /**
  17620. * Adds a new life time gradient
  17621. * @param gradient defines the gradient to use (between 0 and 1)
  17622. * @param factor defines the life time factor to affect to the specified gradient
  17623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17624. * @returns the current particle system
  17625. */
  17626. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17627. /**
  17628. * Remove a specific life time gradient
  17629. * @param gradient defines the gradient to remove
  17630. * @returns the current particle system
  17631. */
  17632. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17633. /**
  17634. * Gets the current list of life time gradients.
  17635. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17636. * @returns the list of life time gradients
  17637. */
  17638. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17639. /**
  17640. * Gets the current list of color gradients.
  17641. * You must use addColorGradient and removeColorGradient to update this list
  17642. * @returns the list of color gradients
  17643. */
  17644. getColorGradients(): Nullable<Array<ColorGradient>>;
  17645. /**
  17646. * Adds a new ramp gradient used to remap particle colors
  17647. * @param gradient defines the gradient to use (between 0 and 1)
  17648. * @param color defines the color to affect to the specified gradient
  17649. * @returns the current particle system
  17650. */
  17651. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17652. /**
  17653. * Gets the current list of ramp gradients.
  17654. * You must use addRampGradient and removeRampGradient to update this list
  17655. * @returns the list of ramp gradients
  17656. */
  17657. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17658. /** Gets or sets a boolean indicating that ramp gradients must be used
  17659. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17660. */
  17661. useRampGradients: boolean;
  17662. /**
  17663. * Adds a new color remap gradient
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param min defines the color remap minimal range
  17666. * @param max defines the color remap maximal range
  17667. * @returns the current particle system
  17668. */
  17669. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17670. /**
  17671. * Gets the current list of color remap gradients.
  17672. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17673. * @returns the list of color remap gradients
  17674. */
  17675. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17676. /**
  17677. * Adds a new alpha remap gradient
  17678. * @param gradient defines the gradient to use (between 0 and 1)
  17679. * @param min defines the alpha remap minimal range
  17680. * @param max defines the alpha remap maximal range
  17681. * @returns the current particle system
  17682. */
  17683. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17684. /**
  17685. * Gets the current list of alpha remap gradients.
  17686. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17687. * @returns the list of alpha remap gradients
  17688. */
  17689. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17690. /**
  17691. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17694. * @returns the emitter
  17695. */
  17696. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17697. /**
  17698. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17699. * @param radius The radius of the hemisphere to emit from
  17700. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17701. * @returns the emitter
  17702. */
  17703. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17704. /**
  17705. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17706. * @param radius The radius of the sphere to emit from
  17707. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17708. * @returns the emitter
  17709. */
  17710. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17711. /**
  17712. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17713. * @param radius The radius of the sphere to emit from
  17714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17716. * @returns the emitter
  17717. */
  17718. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17719. /**
  17720. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17721. * @param radius The radius of the emission cylinder
  17722. * @param height The height of the emission cylinder
  17723. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17724. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17725. * @returns the emitter
  17726. */
  17727. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17728. /**
  17729. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17730. * @param radius The radius of the cylinder to emit from
  17731. * @param height The height of the emission cylinder
  17732. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17735. * @returns the emitter
  17736. */
  17737. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17738. /**
  17739. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17740. * @param radius The radius of the cone to emit from
  17741. * @param angle The base angle of the cone
  17742. * @returns the emitter
  17743. */
  17744. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17745. /**
  17746. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17747. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17748. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17749. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17750. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17751. * @returns the emitter
  17752. */
  17753. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17754. /**
  17755. * Get hosting scene
  17756. * @returns the scene
  17757. */
  17758. getScene(): Nullable<Scene>;
  17759. }
  17760. }
  17761. declare module BABYLON {
  17762. /**
  17763. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17764. */
  17765. export class ColorSplitterBlock extends NodeMaterialBlock {
  17766. /**
  17767. * Create a new ColorSplitterBlock
  17768. * @param name defines the block name
  17769. */
  17770. constructor(name: string);
  17771. /**
  17772. * Gets the current class name
  17773. * @returns the class name
  17774. */
  17775. getClassName(): string;
  17776. /**
  17777. * Gets the rgba component (input)
  17778. */
  17779. get rgba(): NodeMaterialConnectionPoint;
  17780. /**
  17781. * Gets the rgb component (input)
  17782. */
  17783. get rgbIn(): NodeMaterialConnectionPoint;
  17784. /**
  17785. * Gets the rgb component (output)
  17786. */
  17787. get rgbOut(): NodeMaterialConnectionPoint;
  17788. /**
  17789. * Gets the r component (output)
  17790. */
  17791. get r(): NodeMaterialConnectionPoint;
  17792. /**
  17793. * Gets the g component (output)
  17794. */
  17795. get g(): NodeMaterialConnectionPoint;
  17796. /**
  17797. * Gets the b component (output)
  17798. */
  17799. get b(): NodeMaterialConnectionPoint;
  17800. /**
  17801. * Gets the a component (output)
  17802. */
  17803. get a(): NodeMaterialConnectionPoint;
  17804. protected _inputRename(name: string): string;
  17805. protected _outputRename(name: string): string;
  17806. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17807. }
  17808. }
  17809. declare module BABYLON {
  17810. /**
  17811. * Operations supported by the Trigonometry block
  17812. */
  17813. export enum TrigonometryBlockOperations {
  17814. /** Cos */
  17815. Cos = 0,
  17816. /** Sin */
  17817. Sin = 1,
  17818. /** Abs */
  17819. Abs = 2,
  17820. /** Exp */
  17821. Exp = 3,
  17822. /** Exp2 */
  17823. Exp2 = 4,
  17824. /** Round */
  17825. Round = 5,
  17826. /** Floor */
  17827. Floor = 6,
  17828. /** Ceiling */
  17829. Ceiling = 7,
  17830. /** Square root */
  17831. Sqrt = 8,
  17832. /** Log */
  17833. Log = 9,
  17834. /** Tangent */
  17835. Tan = 10,
  17836. /** Arc tangent */
  17837. ArcTan = 11,
  17838. /** Arc cosinus */
  17839. ArcCos = 12,
  17840. /** Arc sinus */
  17841. ArcSin = 13,
  17842. /** Fraction */
  17843. Fract = 14,
  17844. /** Sign */
  17845. Sign = 15,
  17846. /** To radians (from degrees) */
  17847. Radians = 16,
  17848. /** To degrees (from radians) */
  17849. Degrees = 17
  17850. }
  17851. /**
  17852. * Block used to apply trigonometry operation to floats
  17853. */
  17854. export class TrigonometryBlock extends NodeMaterialBlock {
  17855. /**
  17856. * Gets or sets the operation applied by the block
  17857. */
  17858. operation: TrigonometryBlockOperations;
  17859. /**
  17860. * Creates a new TrigonometryBlock
  17861. * @param name defines the block name
  17862. */
  17863. constructor(name: string);
  17864. /**
  17865. * Gets the current class name
  17866. * @returns the class name
  17867. */
  17868. getClassName(): string;
  17869. /**
  17870. * Gets the input component
  17871. */
  17872. get input(): NodeMaterialConnectionPoint;
  17873. /**
  17874. * Gets the output component
  17875. */
  17876. get output(): NodeMaterialConnectionPoint;
  17877. protected _buildBlock(state: NodeMaterialBuildState): this;
  17878. serialize(): any;
  17879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17880. protected _dumpPropertiesCode(): string;
  17881. }
  17882. }
  17883. declare module BABYLON {
  17884. /**
  17885. * Interface used to configure the node material editor
  17886. */
  17887. export interface INodeMaterialEditorOptions {
  17888. /** Define the URl to load node editor script */
  17889. editorURL?: string;
  17890. }
  17891. /** @hidden */
  17892. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17893. NORMAL: boolean;
  17894. TANGENT: boolean;
  17895. UV1: boolean;
  17896. /** BONES */
  17897. NUM_BONE_INFLUENCERS: number;
  17898. BonesPerMesh: number;
  17899. BONETEXTURE: boolean;
  17900. /** MORPH TARGETS */
  17901. MORPHTARGETS: boolean;
  17902. MORPHTARGETS_NORMAL: boolean;
  17903. MORPHTARGETS_TANGENT: boolean;
  17904. MORPHTARGETS_UV: boolean;
  17905. NUM_MORPH_INFLUENCERS: number;
  17906. MORPHTARGETS_TEXTURE: boolean;
  17907. /** IMAGE PROCESSING */
  17908. IMAGEPROCESSING: boolean;
  17909. VIGNETTE: boolean;
  17910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17911. VIGNETTEBLENDMODEOPAQUE: boolean;
  17912. TONEMAPPING: boolean;
  17913. TONEMAPPING_ACES: boolean;
  17914. CONTRAST: boolean;
  17915. EXPOSURE: boolean;
  17916. COLORCURVES: boolean;
  17917. COLORGRADING: boolean;
  17918. COLORGRADING3D: boolean;
  17919. SAMPLER3DGREENDEPTH: boolean;
  17920. SAMPLER3DBGRMAP: boolean;
  17921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17922. /** MISC. */
  17923. BUMPDIRECTUV: number;
  17924. constructor();
  17925. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17926. }
  17927. /**
  17928. * Class used to configure NodeMaterial
  17929. */
  17930. export interface INodeMaterialOptions {
  17931. /**
  17932. * Defines if blocks should emit comments
  17933. */
  17934. emitComments: boolean;
  17935. }
  17936. /**
  17937. * Class used to create a node based material built by assembling shader blocks
  17938. */
  17939. export class NodeMaterial extends PushMaterial {
  17940. private static _BuildIdGenerator;
  17941. private _options;
  17942. private _vertexCompilationState;
  17943. private _fragmentCompilationState;
  17944. private _sharedData;
  17945. private _buildId;
  17946. private _buildWasSuccessful;
  17947. private _cachedWorldViewMatrix;
  17948. private _cachedWorldViewProjectionMatrix;
  17949. private _optimizers;
  17950. private _animationFrame;
  17951. /** Define the Url to load node editor script */
  17952. static EditorURL: string;
  17953. /** Define the Url to load snippets */
  17954. static SnippetUrl: string;
  17955. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17956. static IgnoreTexturesAtLoadTime: boolean;
  17957. private BJSNODEMATERIALEDITOR;
  17958. /** Get the inspector from bundle or global */
  17959. private _getGlobalNodeMaterialEditor;
  17960. /**
  17961. * Snippet ID if the material was created from the snippet server
  17962. */
  17963. snippetId: string;
  17964. /**
  17965. * Gets or sets data used by visual editor
  17966. * @see https://nme.babylonjs.com
  17967. */
  17968. editorData: any;
  17969. /**
  17970. * 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)
  17971. */
  17972. ignoreAlpha: boolean;
  17973. /**
  17974. * Defines the maximum number of lights that can be used in the material
  17975. */
  17976. maxSimultaneousLights: number;
  17977. /**
  17978. * Observable raised when the material is built
  17979. */
  17980. onBuildObservable: Observable<NodeMaterial>;
  17981. /**
  17982. * Gets or sets the root nodes of the material vertex shader
  17983. */
  17984. _vertexOutputNodes: NodeMaterialBlock[];
  17985. /**
  17986. * Gets or sets the root nodes of the material fragment (pixel) shader
  17987. */
  17988. _fragmentOutputNodes: NodeMaterialBlock[];
  17989. /** Gets or sets options to control the node material overall behavior */
  17990. get options(): INodeMaterialOptions;
  17991. set options(options: INodeMaterialOptions);
  17992. /**
  17993. * Default configuration related to image processing available in the standard Material.
  17994. */
  17995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17996. /**
  17997. * Gets the image processing configuration used either in this material.
  17998. */
  17999. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18000. /**
  18001. * Sets the Default image processing configuration used either in the this material.
  18002. *
  18003. * If sets to null, the scene one is in use.
  18004. */
  18005. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18006. /**
  18007. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18008. */
  18009. attachedBlocks: NodeMaterialBlock[];
  18010. /**
  18011. * Specifies the mode of the node material
  18012. * @hidden
  18013. */
  18014. _mode: NodeMaterialModes;
  18015. /**
  18016. * Gets the mode property
  18017. */
  18018. get mode(): NodeMaterialModes;
  18019. /**
  18020. * A free comment about the material
  18021. */
  18022. comment: string;
  18023. /**
  18024. * Create a new node based material
  18025. * @param name defines the material name
  18026. * @param scene defines the hosting scene
  18027. * @param options defines creation option
  18028. */
  18029. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18030. /**
  18031. * Gets the current class name of the material e.g. "NodeMaterial"
  18032. * @returns the class name
  18033. */
  18034. getClassName(): string;
  18035. /**
  18036. * Keep track of the image processing observer to allow dispose and replace.
  18037. */
  18038. private _imageProcessingObserver;
  18039. /**
  18040. * Attaches a new image processing configuration to the Standard Material.
  18041. * @param configuration
  18042. */
  18043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18044. /**
  18045. * Get a block by its name
  18046. * @param name defines the name of the block to retrieve
  18047. * @returns the required block or null if not found
  18048. */
  18049. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18050. /**
  18051. * Get a block by its name
  18052. * @param predicate defines the predicate used to find the good candidate
  18053. * @returns the required block or null if not found
  18054. */
  18055. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18056. /**
  18057. * Get an input block by its name
  18058. * @param predicate defines the predicate used to find the good candidate
  18059. * @returns the required input block or null if not found
  18060. */
  18061. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18062. /**
  18063. * Gets the list of input blocks attached to this material
  18064. * @returns an array of InputBlocks
  18065. */
  18066. getInputBlocks(): InputBlock[];
  18067. /**
  18068. * Adds a new optimizer to the list of optimizers
  18069. * @param optimizer defines the optimizers to add
  18070. * @returns the current material
  18071. */
  18072. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18073. /**
  18074. * Remove an optimizer from the list of optimizers
  18075. * @param optimizer defines the optimizers to remove
  18076. * @returns the current material
  18077. */
  18078. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18079. /**
  18080. * Add a new block to the list of output nodes
  18081. * @param node defines the node to add
  18082. * @returns the current material
  18083. */
  18084. addOutputNode(node: NodeMaterialBlock): this;
  18085. /**
  18086. * Remove a block from the list of root nodes
  18087. * @param node defines the node to remove
  18088. * @returns the current material
  18089. */
  18090. removeOutputNode(node: NodeMaterialBlock): this;
  18091. private _addVertexOutputNode;
  18092. private _removeVertexOutputNode;
  18093. private _addFragmentOutputNode;
  18094. private _removeFragmentOutputNode;
  18095. /**
  18096. * Specifies if the material will require alpha blending
  18097. * @returns a boolean specifying if alpha blending is needed
  18098. */
  18099. needAlphaBlending(): boolean;
  18100. /**
  18101. * Specifies if this material should be rendered in alpha test mode
  18102. * @returns a boolean specifying if an alpha test is needed.
  18103. */
  18104. needAlphaTesting(): boolean;
  18105. private _initializeBlock;
  18106. private _resetDualBlocks;
  18107. /**
  18108. * Remove a block from the current node material
  18109. * @param block defines the block to remove
  18110. */
  18111. removeBlock(block: NodeMaterialBlock): void;
  18112. /**
  18113. * Build the material and generates the inner effect
  18114. * @param verbose defines if the build should log activity
  18115. */
  18116. build(verbose?: boolean): void;
  18117. /**
  18118. * Runs an otpimization phase to try to improve the shader code
  18119. */
  18120. optimize(): void;
  18121. private _prepareDefinesForAttributes;
  18122. /**
  18123. * Create a post process from the material
  18124. * @param camera The camera to apply the render pass to.
  18125. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18127. * @param engine The engine which the post process will be applied. (default: current engine)
  18128. * @param reusable If the post process can be reused on the same frame. (default: false)
  18129. * @param textureType Type of textures used when performing the post process. (default: 0)
  18130. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18131. * @returns the post process created
  18132. */
  18133. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18134. /**
  18135. * Create the post process effect from the material
  18136. * @param postProcess The post process to create the effect for
  18137. */
  18138. createEffectForPostProcess(postProcess: PostProcess): void;
  18139. private _createEffectForPostProcess;
  18140. /**
  18141. * Create a new procedural texture based on this node material
  18142. * @param size defines the size of the texture
  18143. * @param scene defines the hosting scene
  18144. * @returns the new procedural texture attached to this node material
  18145. */
  18146. createProceduralTexture(size: number | {
  18147. width: number;
  18148. height: number;
  18149. layers?: number;
  18150. }, scene: Scene): Nullable<ProceduralTexture>;
  18151. private _createEffectForParticles;
  18152. private _checkInternals;
  18153. /**
  18154. * Create the effect to be used as the custom effect for a particle system
  18155. * @param particleSystem Particle system to create the effect for
  18156. * @param onCompiled defines a function to call when the effect creation is successful
  18157. * @param onError defines a function to call when the effect creation has failed
  18158. */
  18159. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18160. private _processDefines;
  18161. /**
  18162. * Get if the submesh is ready to be used and all its information available.
  18163. * Child classes can use it to update shaders
  18164. * @param mesh defines the mesh to check
  18165. * @param subMesh defines which submesh to check
  18166. * @param useInstances specifies that instances should be used
  18167. * @returns a boolean indicating that the submesh is ready or not
  18168. */
  18169. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18170. /**
  18171. * Get a string representing the shaders built by the current node graph
  18172. */
  18173. get compiledShaders(): string;
  18174. /**
  18175. * Binds the world matrix to the material
  18176. * @param world defines the world transformation matrix
  18177. */
  18178. bindOnlyWorldMatrix(world: Matrix): void;
  18179. /**
  18180. * Binds the submesh to this material by preparing the effect and shader to draw
  18181. * @param world defines the world transformation matrix
  18182. * @param mesh defines the mesh containing the submesh
  18183. * @param subMesh defines the submesh to bind the material to
  18184. */
  18185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18186. /**
  18187. * Gets the active textures from the material
  18188. * @returns an array of textures
  18189. */
  18190. getActiveTextures(): BaseTexture[];
  18191. /**
  18192. * Gets the list of texture blocks
  18193. * @returns an array of texture blocks
  18194. */
  18195. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18196. /**
  18197. * Specifies if the material uses a texture
  18198. * @param texture defines the texture to check against the material
  18199. * @returns a boolean specifying if the material uses the texture
  18200. */
  18201. hasTexture(texture: BaseTexture): boolean;
  18202. /**
  18203. * Disposes the material
  18204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18205. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18206. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18207. */
  18208. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18209. /** Creates the node editor window. */
  18210. private _createNodeEditor;
  18211. /**
  18212. * Launch the node material editor
  18213. * @param config Define the configuration of the editor
  18214. * @return a promise fulfilled when the node editor is visible
  18215. */
  18216. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18217. /**
  18218. * Clear the current material
  18219. */
  18220. clear(): void;
  18221. /**
  18222. * Clear the current material and set it to a default state
  18223. */
  18224. setToDefault(): void;
  18225. /**
  18226. * Clear the current material and set it to a default state for post process
  18227. */
  18228. setToDefaultPostProcess(): void;
  18229. /**
  18230. * Clear the current material and set it to a default state for procedural texture
  18231. */
  18232. setToDefaultProceduralTexture(): void;
  18233. /**
  18234. * Clear the current material and set it to a default state for particle
  18235. */
  18236. setToDefaultParticle(): void;
  18237. /**
  18238. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18239. * @param url defines the url to load from
  18240. * @returns a promise that will fulfil when the material is fully loaded
  18241. */
  18242. loadAsync(url: string): Promise<void>;
  18243. private _gatherBlocks;
  18244. /**
  18245. * Generate a string containing the code declaration required to create an equivalent of this material
  18246. * @returns a string
  18247. */
  18248. generateCode(): string;
  18249. /**
  18250. * Serializes this material in a JSON representation
  18251. * @returns the serialized material object
  18252. */
  18253. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18254. private _restoreConnections;
  18255. /**
  18256. * Clear the current graph and load a new one from a serialization object
  18257. * @param source defines the JSON representation of the material
  18258. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18259. * @param merge defines whether or not the source must be merged or replace the current content
  18260. */
  18261. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18262. /**
  18263. * Makes a duplicate of the current material.
  18264. * @param name - name to use for the new material.
  18265. */
  18266. clone(name: string): NodeMaterial;
  18267. /**
  18268. * Creates a node material from parsed material data
  18269. * @param source defines the JSON representation of the material
  18270. * @param scene defines the hosting scene
  18271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18272. * @returns a new node material
  18273. */
  18274. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18275. /**
  18276. * Creates a node material from a snippet saved in a remote file
  18277. * @param name defines the name of the material to create
  18278. * @param url defines the url to load from
  18279. * @param scene defines the hosting scene
  18280. * @returns a promise that will resolve to the new node material
  18281. */
  18282. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18283. /**
  18284. * Creates a node material from a snippet saved by the node material editor
  18285. * @param snippetId defines the snippet to load
  18286. * @param scene defines the hosting scene
  18287. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18288. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18289. * @returns a promise that will resolve to the new node material
  18290. */
  18291. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18292. /**
  18293. * Creates a new node material set to default basic configuration
  18294. * @param name defines the name of the material
  18295. * @param scene defines the hosting scene
  18296. * @returns a new NodeMaterial
  18297. */
  18298. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18299. }
  18300. }
  18301. declare module BABYLON {
  18302. interface ThinEngine {
  18303. /**
  18304. * Unbind a list of render target textures from the webGL context
  18305. * This is used only when drawBuffer extension or webGL2 are active
  18306. * @param textures defines the render target textures to unbind
  18307. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18308. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18309. */
  18310. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18311. /**
  18312. * Create a multi render target texture
  18313. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18314. * @param size defines the size of the texture
  18315. * @param options defines the creation options
  18316. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18317. * @returns the cube texture as an InternalTexture
  18318. */
  18319. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18320. /**
  18321. * Update the sample count for a given multiple render target texture
  18322. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18323. * @param textures defines the textures to update
  18324. * @param samples defines the sample count to set
  18325. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18326. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18327. */
  18328. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18329. /**
  18330. * Select a subsets of attachments to draw to.
  18331. * @param attachments gl attachments
  18332. */
  18333. bindAttachments(attachments: number[]): void;
  18334. /**
  18335. * Creates a layout object to draw/clear on specific textures in a MRT
  18336. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18337. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18338. */
  18339. buildTextureLayout(textureStatus: boolean[]): number[];
  18340. /**
  18341. * Restores the webgl state to only draw on the main color attachment
  18342. * when the frame buffer associated is the canvas frame buffer
  18343. */
  18344. restoreSingleAttachment(): void;
  18345. /**
  18346. * Restores the webgl state to only draw on the main color attachment
  18347. * when the frame buffer associated is not the canvas frame buffer
  18348. */
  18349. restoreSingleAttachmentForRenderTarget(): void;
  18350. /**
  18351. * Clears a list of attachments
  18352. * @param attachments list of the attachments
  18353. * @param colorMain clear color for the main attachment (the first one)
  18354. * @param colorOthers clear color for the other attachments
  18355. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18356. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18357. */
  18358. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18359. }
  18360. }
  18361. declare module BABYLON {
  18362. /**
  18363. * Creation options of the multi render target texture.
  18364. */
  18365. export interface IMultiRenderTargetOptions {
  18366. /**
  18367. * Define if the texture needs to create mip maps after render.
  18368. */
  18369. generateMipMaps?: boolean;
  18370. /**
  18371. * Define the types of all the draw buffers we want to create
  18372. */
  18373. types?: number[];
  18374. /**
  18375. * Define the sampling modes of all the draw buffers we want to create
  18376. */
  18377. samplingModes?: number[];
  18378. /**
  18379. * Define if a depth buffer is required
  18380. */
  18381. generateDepthBuffer?: boolean;
  18382. /**
  18383. * Define if a stencil buffer is required
  18384. */
  18385. generateStencilBuffer?: boolean;
  18386. /**
  18387. * Define if a depth texture is required instead of a depth buffer
  18388. */
  18389. generateDepthTexture?: boolean;
  18390. /**
  18391. * Define the number of desired draw buffers
  18392. */
  18393. textureCount?: number;
  18394. /**
  18395. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18396. */
  18397. doNotChangeAspectRatio?: boolean;
  18398. /**
  18399. * Define the default type of the buffers we are creating
  18400. */
  18401. defaultType?: number;
  18402. /**
  18403. * Define the default type of the buffers we are creating
  18404. */
  18405. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18406. }
  18407. /**
  18408. * A multi render target, like a render target provides the ability to render to a texture.
  18409. * Unlike the render target, it can render to several draw buffers in one draw.
  18410. * This is specially interesting in deferred rendering or for any effects requiring more than
  18411. * just one color from a single pass.
  18412. */
  18413. export class MultiRenderTarget extends RenderTargetTexture {
  18414. private _internalTextures;
  18415. private _textures;
  18416. private _multiRenderTargetOptions;
  18417. private _count;
  18418. private _drawOnlyOnFirstAttachmentByDefault;
  18419. /**
  18420. * Get if draw buffers are currently supported by the used hardware and browser.
  18421. */
  18422. get isSupported(): boolean;
  18423. /**
  18424. * Get the list of textures generated by the multi render target.
  18425. */
  18426. get textures(): Texture[];
  18427. /**
  18428. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18429. */
  18430. get count(): number;
  18431. /**
  18432. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18433. */
  18434. get depthTexture(): Texture;
  18435. /**
  18436. * Set the wrapping mode on U of all the textures we are rendering to.
  18437. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18438. */
  18439. set wrapU(wrap: number);
  18440. /**
  18441. * Set the wrapping mode on V of all the textures we are rendering to.
  18442. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18443. */
  18444. set wrapV(wrap: number);
  18445. /**
  18446. * Instantiate a new multi render target texture.
  18447. * A multi render target, like a render target provides the ability to render to a texture.
  18448. * Unlike the render target, it can render to several draw buffers in one draw.
  18449. * This is specially interesting in deferred rendering or for any effects requiring more than
  18450. * just one color from a single pass.
  18451. * @param name Define the name of the texture
  18452. * @param size Define the size of the buffers to render to
  18453. * @param count Define the number of target we are rendering into
  18454. * @param scene Define the scene the texture belongs to
  18455. * @param options Define the options used to create the multi render target
  18456. */
  18457. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18458. private _initTypes;
  18459. /** @hidden */
  18460. _rebuild(forceFullRebuild?: boolean): void;
  18461. private _createInternalTextures;
  18462. private _createTextures;
  18463. /**
  18464. * Replaces a texture within the MRT.
  18465. * @param texture The new texture to insert in the MRT
  18466. * @param index The index of the texture to replace
  18467. */
  18468. replaceTexture(texture: Texture, index: number): void;
  18469. /**
  18470. * Define the number of samples used if MSAA is enabled.
  18471. */
  18472. get samples(): number;
  18473. set samples(value: number);
  18474. /**
  18475. * Resize all the textures in the multi render target.
  18476. * Be careful as it will recreate all the data in the new texture.
  18477. * @param size Define the new size
  18478. */
  18479. resize(size: any): void;
  18480. /**
  18481. * Changes the number of render targets in this MRT
  18482. * Be careful as it will recreate all the data in the new texture.
  18483. * @param count new texture count
  18484. * @param options Specifies texture types and sampling modes for new textures
  18485. */
  18486. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18487. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18488. /**
  18489. * Dispose the render targets and their associated resources
  18490. */
  18491. dispose(): void;
  18492. /**
  18493. * Release all the underlying texture used as draw buffers.
  18494. */
  18495. releaseInternalTextures(): void;
  18496. }
  18497. }
  18498. declare module BABYLON {
  18499. /** @hidden */
  18500. export var imageProcessingPixelShader: {
  18501. name: string;
  18502. shader: string;
  18503. };
  18504. }
  18505. declare module BABYLON {
  18506. /**
  18507. * ImageProcessingPostProcess
  18508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18509. */
  18510. export class ImageProcessingPostProcess extends PostProcess {
  18511. /**
  18512. * Default configuration related to image processing available in the PBR Material.
  18513. */
  18514. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18515. /**
  18516. * Gets the image processing configuration used either in this material.
  18517. */
  18518. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18519. /**
  18520. * Sets the Default image processing configuration used either in the this material.
  18521. *
  18522. * If sets to null, the scene one is in use.
  18523. */
  18524. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18525. /**
  18526. * Keep track of the image processing observer to allow dispose and replace.
  18527. */
  18528. private _imageProcessingObserver;
  18529. /**
  18530. * Attaches a new image processing configuration to the PBR Material.
  18531. * @param configuration
  18532. */
  18533. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18534. /**
  18535. * If the post process is supported.
  18536. */
  18537. get isSupported(): boolean;
  18538. /**
  18539. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18540. */
  18541. get colorCurves(): Nullable<ColorCurves>;
  18542. /**
  18543. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18544. */
  18545. set colorCurves(value: Nullable<ColorCurves>);
  18546. /**
  18547. * Gets whether the color curves effect is enabled.
  18548. */
  18549. get colorCurvesEnabled(): boolean;
  18550. /**
  18551. * Sets whether the color curves effect is enabled.
  18552. */
  18553. set colorCurvesEnabled(value: boolean);
  18554. /**
  18555. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18556. */
  18557. get colorGradingTexture(): Nullable<BaseTexture>;
  18558. /**
  18559. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18560. */
  18561. set colorGradingTexture(value: Nullable<BaseTexture>);
  18562. /**
  18563. * Gets whether the color grading effect is enabled.
  18564. */
  18565. get colorGradingEnabled(): boolean;
  18566. /**
  18567. * Gets whether the color grading effect is enabled.
  18568. */
  18569. set colorGradingEnabled(value: boolean);
  18570. /**
  18571. * Gets exposure used in the effect.
  18572. */
  18573. get exposure(): number;
  18574. /**
  18575. * Sets exposure used in the effect.
  18576. */
  18577. set exposure(value: number);
  18578. /**
  18579. * Gets whether tonemapping is enabled or not.
  18580. */
  18581. get toneMappingEnabled(): boolean;
  18582. /**
  18583. * Sets whether tonemapping is enabled or not
  18584. */
  18585. set toneMappingEnabled(value: boolean);
  18586. /**
  18587. * Gets the type of tone mapping effect.
  18588. */
  18589. get toneMappingType(): number;
  18590. /**
  18591. * Sets the type of tone mapping effect.
  18592. */
  18593. set toneMappingType(value: number);
  18594. /**
  18595. * Gets contrast used in the effect.
  18596. */
  18597. get contrast(): number;
  18598. /**
  18599. * Sets contrast used in the effect.
  18600. */
  18601. set contrast(value: number);
  18602. /**
  18603. * Gets Vignette stretch size.
  18604. */
  18605. get vignetteStretch(): number;
  18606. /**
  18607. * Sets Vignette stretch size.
  18608. */
  18609. set vignetteStretch(value: number);
  18610. /**
  18611. * Gets Vignette centre X Offset.
  18612. */
  18613. get vignetteCentreX(): number;
  18614. /**
  18615. * Sets Vignette centre X Offset.
  18616. */
  18617. set vignetteCentreX(value: number);
  18618. /**
  18619. * Gets Vignette centre Y Offset.
  18620. */
  18621. get vignetteCentreY(): number;
  18622. /**
  18623. * Sets Vignette centre Y Offset.
  18624. */
  18625. set vignetteCentreY(value: number);
  18626. /**
  18627. * Gets Vignette weight or intensity of the vignette effect.
  18628. */
  18629. get vignetteWeight(): number;
  18630. /**
  18631. * Sets Vignette weight or intensity of the vignette effect.
  18632. */
  18633. set vignetteWeight(value: number);
  18634. /**
  18635. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18636. * if vignetteEnabled is set to true.
  18637. */
  18638. get vignetteColor(): Color4;
  18639. /**
  18640. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18641. * if vignetteEnabled is set to true.
  18642. */
  18643. set vignetteColor(value: Color4);
  18644. /**
  18645. * Gets Camera field of view used by the Vignette effect.
  18646. */
  18647. get vignetteCameraFov(): number;
  18648. /**
  18649. * Sets Camera field of view used by the Vignette effect.
  18650. */
  18651. set vignetteCameraFov(value: number);
  18652. /**
  18653. * Gets the vignette blend mode allowing different kind of effect.
  18654. */
  18655. get vignetteBlendMode(): number;
  18656. /**
  18657. * Sets the vignette blend mode allowing different kind of effect.
  18658. */
  18659. set vignetteBlendMode(value: number);
  18660. /**
  18661. * Gets whether the vignette effect is enabled.
  18662. */
  18663. get vignetteEnabled(): boolean;
  18664. /**
  18665. * Sets whether the vignette effect is enabled.
  18666. */
  18667. set vignetteEnabled(value: boolean);
  18668. private _fromLinearSpace;
  18669. /**
  18670. * Gets whether the input of the processing is in Gamma or Linear Space.
  18671. */
  18672. get fromLinearSpace(): boolean;
  18673. /**
  18674. * Sets whether the input of the processing is in Gamma or Linear Space.
  18675. */
  18676. set fromLinearSpace(value: boolean);
  18677. /**
  18678. * Defines cache preventing GC.
  18679. */
  18680. private _defines;
  18681. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18682. /**
  18683. * "ImageProcessingPostProcess"
  18684. * @returns "ImageProcessingPostProcess"
  18685. */
  18686. getClassName(): string;
  18687. /**
  18688. * @hidden
  18689. */
  18690. _updateParameters(): void;
  18691. dispose(camera?: Camera): void;
  18692. }
  18693. }
  18694. declare module BABYLON {
  18695. /**
  18696. * A multi render target designed to render the prepass.
  18697. * Prepass is a scene component used to render information in multiple textures
  18698. * alongside with the scene materials rendering.
  18699. * Note : This is an internal class, and you should NOT need to instanciate this.
  18700. * Only the `PrePassRenderer` should instanciate this class.
  18701. * It is more likely that you need a regular `MultiRenderTarget`
  18702. * @hidden
  18703. */
  18704. export class PrePassRenderTarget extends MultiRenderTarget {
  18705. /**
  18706. * @hidden
  18707. */
  18708. _beforeCompositionPostProcesses: PostProcess[];
  18709. /**
  18710. * Image processing post process for composition
  18711. */
  18712. imageProcessingPostProcess: ImageProcessingPostProcess;
  18713. /**
  18714. * @hidden
  18715. */
  18716. _engine: Engine;
  18717. /**
  18718. * @hidden
  18719. */
  18720. _scene: Scene;
  18721. /**
  18722. * @hidden
  18723. */
  18724. _outputPostProcess: Nullable<PostProcess>;
  18725. /**
  18726. * @hidden
  18727. */
  18728. _internalTextureDirty: boolean;
  18729. /**
  18730. * Is this render target enabled for prepass rendering
  18731. */
  18732. enabled: boolean;
  18733. /**
  18734. * Render target associated with this prePassRenderTarget
  18735. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18736. */
  18737. renderTargetTexture: Nullable<RenderTargetTexture>;
  18738. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18739. /**
  18740. * Creates a composition effect for this RT
  18741. * @hidden
  18742. */
  18743. _createCompositionEffect(): void;
  18744. /**
  18745. * Checks that the size of this RT is still adapted to the desired render size.
  18746. * @hidden
  18747. */
  18748. _checkSize(): void;
  18749. /**
  18750. * Changes the number of render targets in this MRT
  18751. * Be careful as it will recreate all the data in the new texture.
  18752. * @param count new texture count
  18753. * @param options Specifies texture types and sampling modes for new textures
  18754. */
  18755. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18756. /**
  18757. * Resets the post processes chains applied to this RT.
  18758. * @hidden
  18759. */
  18760. _resetPostProcessChain(): void;
  18761. /**
  18762. * Diposes this render target
  18763. */
  18764. dispose(): void;
  18765. }
  18766. }
  18767. declare module BABYLON {
  18768. /**
  18769. * Interface for defining prepass effects in the prepass post-process pipeline
  18770. */
  18771. export interface PrePassEffectConfiguration {
  18772. /**
  18773. * Name of the effect
  18774. */
  18775. name: string;
  18776. /**
  18777. * Post process to attach for this effect
  18778. */
  18779. postProcess?: PostProcess;
  18780. /**
  18781. * Textures required in the MRT
  18782. */
  18783. texturesRequired: number[];
  18784. /**
  18785. * Is the effect enabled
  18786. */
  18787. enabled: boolean;
  18788. /**
  18789. * Does the output of this prepass need to go through imageprocessing
  18790. */
  18791. needsImageProcessing?: boolean;
  18792. /**
  18793. * Disposes the effect configuration
  18794. */
  18795. dispose?: () => void;
  18796. /**
  18797. * Creates the associated post process
  18798. */
  18799. createPostProcess?: () => PostProcess;
  18800. }
  18801. }
  18802. declare module BABYLON {
  18803. /**
  18804. * Options to be used when creating a FresnelParameters.
  18805. */
  18806. export type IFresnelParametersCreationOptions = {
  18807. /**
  18808. * Define the color used on edges (grazing angle)
  18809. */
  18810. leftColor?: Color3;
  18811. /**
  18812. * Define the color used on center
  18813. */
  18814. rightColor?: Color3;
  18815. /**
  18816. * Define bias applied to computed fresnel term
  18817. */
  18818. bias?: number;
  18819. /**
  18820. * Defined the power exponent applied to fresnel term
  18821. */
  18822. power?: number;
  18823. /**
  18824. * Define if the fresnel effect is enable or not.
  18825. */
  18826. isEnabled?: boolean;
  18827. };
  18828. /**
  18829. * Serialized format for FresnelParameters.
  18830. */
  18831. export type IFresnelParametersSerialized = {
  18832. /**
  18833. * Define the color used on edges (grazing angle) [as an array]
  18834. */
  18835. leftColor: number[];
  18836. /**
  18837. * Define the color used on center [as an array]
  18838. */
  18839. rightColor: number[];
  18840. /**
  18841. * Define bias applied to computed fresnel term
  18842. */
  18843. bias: number;
  18844. /**
  18845. * Defined the power exponent applied to fresnel term
  18846. */
  18847. power?: number;
  18848. /**
  18849. * Define if the fresnel effect is enable or not.
  18850. */
  18851. isEnabled: boolean;
  18852. };
  18853. /**
  18854. * This represents all the required information to add a fresnel effect on a material:
  18855. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18856. */
  18857. export class FresnelParameters {
  18858. private _isEnabled;
  18859. /**
  18860. * Define if the fresnel effect is enable or not.
  18861. */
  18862. get isEnabled(): boolean;
  18863. set isEnabled(value: boolean);
  18864. /**
  18865. * Define the color used on edges (grazing angle)
  18866. */
  18867. leftColor: Color3;
  18868. /**
  18869. * Define the color used on center
  18870. */
  18871. rightColor: Color3;
  18872. /**
  18873. * Define bias applied to computed fresnel term
  18874. */
  18875. bias: number;
  18876. /**
  18877. * Defined the power exponent applied to fresnel term
  18878. */
  18879. power: number;
  18880. /**
  18881. * Creates a new FresnelParameters object.
  18882. *
  18883. * @param options provide your own settings to optionally to override defaults
  18884. */
  18885. constructor(options?: IFresnelParametersCreationOptions);
  18886. /**
  18887. * Clones the current fresnel and its values
  18888. * @returns a clone fresnel configuration
  18889. */
  18890. clone(): FresnelParameters;
  18891. /**
  18892. * Determines equality between FresnelParameters objects
  18893. * @param otherFresnelParameters defines the second operand
  18894. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18895. */
  18896. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18897. /**
  18898. * Serializes the current fresnel parameters to a JSON representation.
  18899. * @return the JSON serialization
  18900. */
  18901. serialize(): IFresnelParametersSerialized;
  18902. /**
  18903. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18904. * @param parsedFresnelParameters Define the JSON representation
  18905. * @returns the parsed parameters
  18906. */
  18907. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18908. }
  18909. }
  18910. declare module BABYLON {
  18911. /**
  18912. * This groups all the flags used to control the materials channel.
  18913. */
  18914. export class MaterialFlags {
  18915. private static _DiffuseTextureEnabled;
  18916. /**
  18917. * Are diffuse textures enabled in the application.
  18918. */
  18919. static get DiffuseTextureEnabled(): boolean;
  18920. static set DiffuseTextureEnabled(value: boolean);
  18921. private static _DetailTextureEnabled;
  18922. /**
  18923. * Are detail textures enabled in the application.
  18924. */
  18925. static get DetailTextureEnabled(): boolean;
  18926. static set DetailTextureEnabled(value: boolean);
  18927. private static _AmbientTextureEnabled;
  18928. /**
  18929. * Are ambient textures enabled in the application.
  18930. */
  18931. static get AmbientTextureEnabled(): boolean;
  18932. static set AmbientTextureEnabled(value: boolean);
  18933. private static _OpacityTextureEnabled;
  18934. /**
  18935. * Are opacity textures enabled in the application.
  18936. */
  18937. static get OpacityTextureEnabled(): boolean;
  18938. static set OpacityTextureEnabled(value: boolean);
  18939. private static _ReflectionTextureEnabled;
  18940. /**
  18941. * Are reflection textures enabled in the application.
  18942. */
  18943. static get ReflectionTextureEnabled(): boolean;
  18944. static set ReflectionTextureEnabled(value: boolean);
  18945. private static _EmissiveTextureEnabled;
  18946. /**
  18947. * Are emissive textures enabled in the application.
  18948. */
  18949. static get EmissiveTextureEnabled(): boolean;
  18950. static set EmissiveTextureEnabled(value: boolean);
  18951. private static _SpecularTextureEnabled;
  18952. /**
  18953. * Are specular textures enabled in the application.
  18954. */
  18955. static get SpecularTextureEnabled(): boolean;
  18956. static set SpecularTextureEnabled(value: boolean);
  18957. private static _BumpTextureEnabled;
  18958. /**
  18959. * Are bump textures enabled in the application.
  18960. */
  18961. static get BumpTextureEnabled(): boolean;
  18962. static set BumpTextureEnabled(value: boolean);
  18963. private static _LightmapTextureEnabled;
  18964. /**
  18965. * Are lightmap textures enabled in the application.
  18966. */
  18967. static get LightmapTextureEnabled(): boolean;
  18968. static set LightmapTextureEnabled(value: boolean);
  18969. private static _RefractionTextureEnabled;
  18970. /**
  18971. * Are refraction textures enabled in the application.
  18972. */
  18973. static get RefractionTextureEnabled(): boolean;
  18974. static set RefractionTextureEnabled(value: boolean);
  18975. private static _ColorGradingTextureEnabled;
  18976. /**
  18977. * Are color grading textures enabled in the application.
  18978. */
  18979. static get ColorGradingTextureEnabled(): boolean;
  18980. static set ColorGradingTextureEnabled(value: boolean);
  18981. private static _FresnelEnabled;
  18982. /**
  18983. * Are fresnels enabled in the application.
  18984. */
  18985. static get FresnelEnabled(): boolean;
  18986. static set FresnelEnabled(value: boolean);
  18987. private static _ClearCoatTextureEnabled;
  18988. /**
  18989. * Are clear coat textures enabled in the application.
  18990. */
  18991. static get ClearCoatTextureEnabled(): boolean;
  18992. static set ClearCoatTextureEnabled(value: boolean);
  18993. private static _ClearCoatBumpTextureEnabled;
  18994. /**
  18995. * Are clear coat bump textures enabled in the application.
  18996. */
  18997. static get ClearCoatBumpTextureEnabled(): boolean;
  18998. static set ClearCoatBumpTextureEnabled(value: boolean);
  18999. private static _ClearCoatTintTextureEnabled;
  19000. /**
  19001. * Are clear coat tint textures enabled in the application.
  19002. */
  19003. static get ClearCoatTintTextureEnabled(): boolean;
  19004. static set ClearCoatTintTextureEnabled(value: boolean);
  19005. private static _SheenTextureEnabled;
  19006. /**
  19007. * Are sheen textures enabled in the application.
  19008. */
  19009. static get SheenTextureEnabled(): boolean;
  19010. static set SheenTextureEnabled(value: boolean);
  19011. private static _AnisotropicTextureEnabled;
  19012. /**
  19013. * Are anisotropic textures enabled in the application.
  19014. */
  19015. static get AnisotropicTextureEnabled(): boolean;
  19016. static set AnisotropicTextureEnabled(value: boolean);
  19017. private static _ThicknessTextureEnabled;
  19018. /**
  19019. * Are thickness textures enabled in the application.
  19020. */
  19021. static get ThicknessTextureEnabled(): boolean;
  19022. static set ThicknessTextureEnabled(value: boolean);
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /** @hidden */
  19027. export var defaultFragmentDeclaration: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module BABYLON {
  19033. /** @hidden */
  19034. export var sceneUboDeclaration: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module BABYLON {
  19040. /** @hidden */
  19041. export var meshUboDeclaration: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module BABYLON {
  19047. /** @hidden */
  19048. export var defaultUboDeclaration: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module BABYLON {
  19054. /** @hidden */
  19055. export var prePassDeclaration: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var lightFragmentDeclaration: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var lightUboDeclaration: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /** @hidden */
  19076. export var lightsFragmentFunctions: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module BABYLON {
  19082. /** @hidden */
  19083. export var shadowsFragmentFunctions: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module BABYLON {
  19089. /** @hidden */
  19090. export var fresnelFunction: {
  19091. name: string;
  19092. shader: string;
  19093. };
  19094. }
  19095. declare module BABYLON {
  19096. /** @hidden */
  19097. export var bumpFragmentMainFunctions: {
  19098. name: string;
  19099. shader: string;
  19100. };
  19101. }
  19102. declare module BABYLON {
  19103. /** @hidden */
  19104. export var bumpFragmentFunctions: {
  19105. name: string;
  19106. shader: string;
  19107. };
  19108. }
  19109. declare module BABYLON {
  19110. /** @hidden */
  19111. export var logDepthDeclaration: {
  19112. name: string;
  19113. shader: string;
  19114. };
  19115. }
  19116. declare module BABYLON {
  19117. /** @hidden */
  19118. export var fogFragmentDeclaration: {
  19119. name: string;
  19120. shader: string;
  19121. };
  19122. }
  19123. declare module BABYLON {
  19124. /** @hidden */
  19125. export var bumpFragment: {
  19126. name: string;
  19127. shader: string;
  19128. };
  19129. }
  19130. declare module BABYLON {
  19131. /** @hidden */
  19132. export var depthPrePass: {
  19133. name: string;
  19134. shader: string;
  19135. };
  19136. }
  19137. declare module BABYLON {
  19138. /** @hidden */
  19139. export var lightFragment: {
  19140. name: string;
  19141. shader: string;
  19142. };
  19143. }
  19144. declare module BABYLON {
  19145. /** @hidden */
  19146. export var logDepthFragment: {
  19147. name: string;
  19148. shader: string;
  19149. };
  19150. }
  19151. declare module BABYLON {
  19152. /** @hidden */
  19153. export var fogFragment: {
  19154. name: string;
  19155. shader: string;
  19156. };
  19157. }
  19158. declare module BABYLON {
  19159. /** @hidden */
  19160. export var defaultPixelShader: {
  19161. name: string;
  19162. shader: string;
  19163. };
  19164. }
  19165. declare module BABYLON {
  19166. /** @hidden */
  19167. export var defaultVertexDeclaration: {
  19168. name: string;
  19169. shader: string;
  19170. };
  19171. }
  19172. declare module BABYLON {
  19173. /** @hidden */
  19174. export var bonesDeclaration: {
  19175. name: string;
  19176. shader: string;
  19177. };
  19178. }
  19179. declare module BABYLON {
  19180. /** @hidden */
  19181. export var prePassVertexDeclaration: {
  19182. name: string;
  19183. shader: string;
  19184. };
  19185. }
  19186. declare module BABYLON {
  19187. /** @hidden */
  19188. export var bumpVertexDeclaration: {
  19189. name: string;
  19190. shader: string;
  19191. };
  19192. }
  19193. declare module BABYLON {
  19194. /** @hidden */
  19195. export var fogVertexDeclaration: {
  19196. name: string;
  19197. shader: string;
  19198. };
  19199. }
  19200. declare module BABYLON {
  19201. /** @hidden */
  19202. export var lightVxFragmentDeclaration: {
  19203. name: string;
  19204. shader: string;
  19205. };
  19206. }
  19207. declare module BABYLON {
  19208. /** @hidden */
  19209. export var lightVxUboDeclaration: {
  19210. name: string;
  19211. shader: string;
  19212. };
  19213. }
  19214. declare module BABYLON {
  19215. /** @hidden */
  19216. export var morphTargetsVertexGlobalDeclaration: {
  19217. name: string;
  19218. shader: string;
  19219. };
  19220. }
  19221. declare module BABYLON {
  19222. /** @hidden */
  19223. export var morphTargetsVertexDeclaration: {
  19224. name: string;
  19225. shader: string;
  19226. };
  19227. }
  19228. declare module BABYLON {
  19229. /** @hidden */
  19230. export var morphTargetsVertexGlobal: {
  19231. name: string;
  19232. shader: string;
  19233. };
  19234. }
  19235. declare module BABYLON {
  19236. /** @hidden */
  19237. export var morphTargetsVertex: {
  19238. name: string;
  19239. shader: string;
  19240. };
  19241. }
  19242. declare module BABYLON {
  19243. /** @hidden */
  19244. export var instancesVertex: {
  19245. name: string;
  19246. shader: string;
  19247. };
  19248. }
  19249. declare module BABYLON {
  19250. /** @hidden */
  19251. export var bonesVertex: {
  19252. name: string;
  19253. shader: string;
  19254. };
  19255. }
  19256. declare module BABYLON {
  19257. /** @hidden */
  19258. export var prePassVertex: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module BABYLON {
  19264. /** @hidden */
  19265. export var bumpVertex: {
  19266. name: string;
  19267. shader: string;
  19268. };
  19269. }
  19270. declare module BABYLON {
  19271. /** @hidden */
  19272. export var fogVertex: {
  19273. name: string;
  19274. shader: string;
  19275. };
  19276. }
  19277. declare module BABYLON {
  19278. /** @hidden */
  19279. export var shadowsVertex: {
  19280. name: string;
  19281. shader: string;
  19282. };
  19283. }
  19284. declare module BABYLON {
  19285. /** @hidden */
  19286. export var pointCloudVertex: {
  19287. name: string;
  19288. shader: string;
  19289. };
  19290. }
  19291. declare module BABYLON {
  19292. /** @hidden */
  19293. export var logDepthVertex: {
  19294. name: string;
  19295. shader: string;
  19296. };
  19297. }
  19298. declare module BABYLON {
  19299. /** @hidden */
  19300. export var defaultVertexShader: {
  19301. name: string;
  19302. shader: string;
  19303. };
  19304. }
  19305. declare module BABYLON {
  19306. /**
  19307. * @hidden
  19308. */
  19309. export interface IMaterialDetailMapDefines {
  19310. DETAIL: boolean;
  19311. DETAILDIRECTUV: number;
  19312. DETAIL_NORMALBLENDMETHOD: number;
  19313. /** @hidden */
  19314. _areTexturesDirty: boolean;
  19315. }
  19316. /**
  19317. * Define the code related to the detail map parameters of a material
  19318. *
  19319. * Inspired from:
  19320. * 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
  19321. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19322. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19323. */
  19324. export class DetailMapConfiguration {
  19325. private _texture;
  19326. /**
  19327. * The detail texture of the material.
  19328. */
  19329. texture: Nullable<BaseTexture>;
  19330. /**
  19331. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19332. * Bigger values mean stronger blending
  19333. */
  19334. diffuseBlendLevel: number;
  19335. /**
  19336. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19337. * Bigger values mean stronger blending. Only used with PBR materials
  19338. */
  19339. roughnessBlendLevel: number;
  19340. /**
  19341. * Defines how strong the bump effect from the detail map is
  19342. * Bigger values mean stronger effect
  19343. */
  19344. bumpLevel: number;
  19345. private _normalBlendMethod;
  19346. /**
  19347. * The method used to blend the bump and detail normals together
  19348. */
  19349. normalBlendMethod: number;
  19350. private _isEnabled;
  19351. /**
  19352. * Enable or disable the detail map on this material
  19353. */
  19354. isEnabled: boolean;
  19355. /** @hidden */
  19356. private _internalMarkAllSubMeshesAsTexturesDirty;
  19357. /** @hidden */
  19358. _markAllSubMeshesAsTexturesDirty(): void;
  19359. /**
  19360. * Instantiate a new detail map
  19361. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19362. */
  19363. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19364. /**
  19365. * Gets whether the submesh is ready to be used or not.
  19366. * @param defines the list of "defines" to update.
  19367. * @param scene defines the scene the material belongs to.
  19368. * @returns - boolean indicating that the submesh is ready or not.
  19369. */
  19370. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19371. /**
  19372. * Update the defines for detail map usage
  19373. * @param defines the list of "defines" to update.
  19374. * @param scene defines the scene the material belongs to.
  19375. */
  19376. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19377. /**
  19378. * Binds the material data.
  19379. * @param uniformBuffer defines the Uniform buffer to fill in.
  19380. * @param scene defines the scene the material belongs to.
  19381. * @param isFrozen defines whether the material is frozen or not.
  19382. */
  19383. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19384. /**
  19385. * Checks to see if a texture is used in the material.
  19386. * @param texture - Base texture to use.
  19387. * @returns - Boolean specifying if a texture is used in the material.
  19388. */
  19389. hasTexture(texture: BaseTexture): boolean;
  19390. /**
  19391. * Returns an array of the actively used textures.
  19392. * @param activeTextures Array of BaseTextures
  19393. */
  19394. getActiveTextures(activeTextures: BaseTexture[]): void;
  19395. /**
  19396. * Returns the animatable textures.
  19397. * @param animatables Array of animatable textures.
  19398. */
  19399. getAnimatables(animatables: IAnimatable[]): void;
  19400. /**
  19401. * Disposes the resources of the material.
  19402. * @param forceDisposeTextures - Forces the disposal of all textures.
  19403. */
  19404. dispose(forceDisposeTextures?: boolean): void;
  19405. /**
  19406. * Get the current class name useful for serialization or dynamic coding.
  19407. * @returns "DetailMap"
  19408. */
  19409. getClassName(): string;
  19410. /**
  19411. * Add the required uniforms to the current list.
  19412. * @param uniforms defines the current uniform list.
  19413. */
  19414. static AddUniforms(uniforms: string[]): void;
  19415. /**
  19416. * Add the required samplers to the current list.
  19417. * @param samplers defines the current sampler list.
  19418. */
  19419. static AddSamplers(samplers: string[]): void;
  19420. /**
  19421. * Add the required uniforms to the current buffer.
  19422. * @param uniformBuffer defines the current uniform buffer.
  19423. */
  19424. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19425. /**
  19426. * Makes a duplicate of the current instance into another one.
  19427. * @param detailMap define the instance where to copy the info
  19428. */
  19429. copyTo(detailMap: DetailMapConfiguration): void;
  19430. /**
  19431. * Serializes this detail map instance
  19432. * @returns - An object with the serialized instance.
  19433. */
  19434. serialize(): any;
  19435. /**
  19436. * Parses a detail map setting from a serialized object.
  19437. * @param source - Serialized object.
  19438. * @param scene Defines the scene we are parsing for
  19439. * @param rootUrl Defines the rootUrl to load from
  19440. */
  19441. parse(source: any, scene: Scene, rootUrl: string): void;
  19442. }
  19443. }
  19444. declare module BABYLON {
  19445. /** @hidden */
  19446. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19447. MAINUV1: boolean;
  19448. MAINUV2: boolean;
  19449. DIFFUSE: boolean;
  19450. DIFFUSEDIRECTUV: number;
  19451. DETAIL: boolean;
  19452. DETAILDIRECTUV: number;
  19453. DETAIL_NORMALBLENDMETHOD: number;
  19454. AMBIENT: boolean;
  19455. AMBIENTDIRECTUV: number;
  19456. OPACITY: boolean;
  19457. OPACITYDIRECTUV: number;
  19458. OPACITYRGB: boolean;
  19459. REFLECTION: boolean;
  19460. EMISSIVE: boolean;
  19461. EMISSIVEDIRECTUV: number;
  19462. SPECULAR: boolean;
  19463. SPECULARDIRECTUV: number;
  19464. BUMP: boolean;
  19465. BUMPDIRECTUV: number;
  19466. PARALLAX: boolean;
  19467. PARALLAXOCCLUSION: boolean;
  19468. SPECULAROVERALPHA: boolean;
  19469. CLIPPLANE: boolean;
  19470. CLIPPLANE2: boolean;
  19471. CLIPPLANE3: boolean;
  19472. CLIPPLANE4: boolean;
  19473. CLIPPLANE5: boolean;
  19474. CLIPPLANE6: boolean;
  19475. ALPHATEST: boolean;
  19476. DEPTHPREPASS: boolean;
  19477. ALPHAFROMDIFFUSE: boolean;
  19478. POINTSIZE: boolean;
  19479. FOG: boolean;
  19480. SPECULARTERM: boolean;
  19481. DIFFUSEFRESNEL: boolean;
  19482. OPACITYFRESNEL: boolean;
  19483. REFLECTIONFRESNEL: boolean;
  19484. REFRACTIONFRESNEL: boolean;
  19485. EMISSIVEFRESNEL: boolean;
  19486. FRESNEL: boolean;
  19487. NORMAL: boolean;
  19488. UV1: boolean;
  19489. UV2: boolean;
  19490. VERTEXCOLOR: boolean;
  19491. VERTEXALPHA: boolean;
  19492. NUM_BONE_INFLUENCERS: number;
  19493. BonesPerMesh: number;
  19494. BONETEXTURE: boolean;
  19495. BONES_VELOCITY_ENABLED: boolean;
  19496. INSTANCES: boolean;
  19497. THIN_INSTANCES: boolean;
  19498. GLOSSINESS: boolean;
  19499. ROUGHNESS: boolean;
  19500. EMISSIVEASILLUMINATION: boolean;
  19501. LINKEMISSIVEWITHDIFFUSE: boolean;
  19502. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19503. LIGHTMAP: boolean;
  19504. LIGHTMAPDIRECTUV: number;
  19505. OBJECTSPACE_NORMALMAP: boolean;
  19506. USELIGHTMAPASSHADOWMAP: boolean;
  19507. REFLECTIONMAP_3D: boolean;
  19508. REFLECTIONMAP_SPHERICAL: boolean;
  19509. REFLECTIONMAP_PLANAR: boolean;
  19510. REFLECTIONMAP_CUBIC: boolean;
  19511. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19512. REFLECTIONMAP_PROJECTION: boolean;
  19513. REFLECTIONMAP_SKYBOX: boolean;
  19514. REFLECTIONMAP_EXPLICIT: boolean;
  19515. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19516. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19517. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19518. REFLECTIONMAP_OPPOSITEZ: boolean;
  19519. INVERTCUBICMAP: boolean;
  19520. LOGARITHMICDEPTH: boolean;
  19521. REFRACTION: boolean;
  19522. REFRACTIONMAP_3D: boolean;
  19523. REFLECTIONOVERALPHA: boolean;
  19524. TWOSIDEDLIGHTING: boolean;
  19525. SHADOWFLOAT: boolean;
  19526. MORPHTARGETS: boolean;
  19527. MORPHTARGETS_NORMAL: boolean;
  19528. MORPHTARGETS_TANGENT: boolean;
  19529. MORPHTARGETS_UV: boolean;
  19530. NUM_MORPH_INFLUENCERS: number;
  19531. MORPHTARGETS_TEXTURE: boolean;
  19532. NONUNIFORMSCALING: boolean;
  19533. PREMULTIPLYALPHA: boolean;
  19534. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19535. ALPHABLEND: boolean;
  19536. PREPASS: boolean;
  19537. PREPASS_IRRADIANCE: boolean;
  19538. PREPASS_IRRADIANCE_INDEX: number;
  19539. PREPASS_ALBEDO: boolean;
  19540. PREPASS_ALBEDO_INDEX: number;
  19541. PREPASS_DEPTH: boolean;
  19542. PREPASS_DEPTH_INDEX: number;
  19543. PREPASS_NORMAL: boolean;
  19544. PREPASS_NORMAL_INDEX: number;
  19545. PREPASS_POSITION: boolean;
  19546. PREPASS_POSITION_INDEX: number;
  19547. PREPASS_VELOCITY: boolean;
  19548. PREPASS_VELOCITY_INDEX: number;
  19549. PREPASS_REFLECTIVITY: boolean;
  19550. PREPASS_REFLECTIVITY_INDEX: number;
  19551. SCENE_MRT_COUNT: number;
  19552. RGBDLIGHTMAP: boolean;
  19553. RGBDREFLECTION: boolean;
  19554. RGBDREFRACTION: boolean;
  19555. IMAGEPROCESSING: boolean;
  19556. VIGNETTE: boolean;
  19557. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19558. VIGNETTEBLENDMODEOPAQUE: boolean;
  19559. TONEMAPPING: boolean;
  19560. TONEMAPPING_ACES: boolean;
  19561. CONTRAST: boolean;
  19562. COLORCURVES: boolean;
  19563. COLORGRADING: boolean;
  19564. COLORGRADING3D: boolean;
  19565. SAMPLER3DGREENDEPTH: boolean;
  19566. SAMPLER3DBGRMAP: boolean;
  19567. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19568. MULTIVIEW: boolean;
  19569. /**
  19570. * If the reflection texture on this material is in linear color space
  19571. * @hidden
  19572. */
  19573. IS_REFLECTION_LINEAR: boolean;
  19574. /**
  19575. * If the refraction texture on this material is in linear color space
  19576. * @hidden
  19577. */
  19578. IS_REFRACTION_LINEAR: boolean;
  19579. EXPOSURE: boolean;
  19580. constructor();
  19581. setReflectionMode(modeToEnable: string): void;
  19582. }
  19583. /**
  19584. * This is the default material used in Babylon. It is the best trade off between quality
  19585. * and performances.
  19586. * @see https://doc.babylonjs.com/babylon101/materials
  19587. */
  19588. export class StandardMaterial extends PushMaterial {
  19589. private _diffuseTexture;
  19590. /**
  19591. * The basic texture of the material as viewed under a light.
  19592. */
  19593. diffuseTexture: Nullable<BaseTexture>;
  19594. private _ambientTexture;
  19595. /**
  19596. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19597. */
  19598. ambientTexture: Nullable<BaseTexture>;
  19599. private _opacityTexture;
  19600. /**
  19601. * Define the transparency of the material from a texture.
  19602. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19603. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19604. */
  19605. opacityTexture: Nullable<BaseTexture>;
  19606. private _reflectionTexture;
  19607. /**
  19608. * Define the texture used to display the reflection.
  19609. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19610. */
  19611. reflectionTexture: Nullable<BaseTexture>;
  19612. private _emissiveTexture;
  19613. /**
  19614. * Define texture of the material as if self lit.
  19615. * This will be mixed in the final result even in the absence of light.
  19616. */
  19617. emissiveTexture: Nullable<BaseTexture>;
  19618. private _specularTexture;
  19619. /**
  19620. * Define how the color and intensity of the highlight given by the light in the material.
  19621. */
  19622. specularTexture: Nullable<BaseTexture>;
  19623. private _bumpTexture;
  19624. /**
  19625. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19626. * 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.
  19627. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19628. */
  19629. bumpTexture: Nullable<BaseTexture>;
  19630. private _lightmapTexture;
  19631. /**
  19632. * Complex lighting can be computationally expensive to compute at runtime.
  19633. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19634. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19635. */
  19636. lightmapTexture: Nullable<BaseTexture>;
  19637. private _refractionTexture;
  19638. /**
  19639. * Define the texture used to display the refraction.
  19640. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19641. */
  19642. refractionTexture: Nullable<BaseTexture>;
  19643. /**
  19644. * The color of the material lit by the environmental background lighting.
  19645. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19646. */
  19647. ambientColor: Color3;
  19648. /**
  19649. * The basic color of the material as viewed under a light.
  19650. */
  19651. diffuseColor: Color3;
  19652. /**
  19653. * Define how the color and intensity of the highlight given by the light in the material.
  19654. */
  19655. specularColor: Color3;
  19656. /**
  19657. * Define the color of the material as if self lit.
  19658. * This will be mixed in the final result even in the absence of light.
  19659. */
  19660. emissiveColor: Color3;
  19661. /**
  19662. * Defines how sharp are the highlights in the material.
  19663. * The bigger the value the sharper giving a more glossy feeling to the result.
  19664. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19665. */
  19666. specularPower: number;
  19667. private _useAlphaFromDiffuseTexture;
  19668. /**
  19669. * Does the transparency come from the diffuse texture alpha channel.
  19670. */
  19671. useAlphaFromDiffuseTexture: boolean;
  19672. private _useEmissiveAsIllumination;
  19673. /**
  19674. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19675. */
  19676. useEmissiveAsIllumination: boolean;
  19677. private _linkEmissiveWithDiffuse;
  19678. /**
  19679. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19680. * the emissive level when the final color is close to one.
  19681. */
  19682. linkEmissiveWithDiffuse: boolean;
  19683. private _useSpecularOverAlpha;
  19684. /**
  19685. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19686. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19687. */
  19688. useSpecularOverAlpha: boolean;
  19689. private _useReflectionOverAlpha;
  19690. /**
  19691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19692. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19693. */
  19694. useReflectionOverAlpha: boolean;
  19695. private _disableLighting;
  19696. /**
  19697. * Does lights from the scene impacts this material.
  19698. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19699. */
  19700. disableLighting: boolean;
  19701. private _useObjectSpaceNormalMap;
  19702. /**
  19703. * Allows using an object space normal map (instead of tangent space).
  19704. */
  19705. useObjectSpaceNormalMap: boolean;
  19706. private _useParallax;
  19707. /**
  19708. * Is parallax enabled or not.
  19709. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19710. */
  19711. useParallax: boolean;
  19712. private _useParallaxOcclusion;
  19713. /**
  19714. * Is parallax occlusion enabled or not.
  19715. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19716. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19717. */
  19718. useParallaxOcclusion: boolean;
  19719. /**
  19720. * 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.
  19721. */
  19722. parallaxScaleBias: number;
  19723. private _roughness;
  19724. /**
  19725. * Helps to define how blurry the reflections should appears in the material.
  19726. */
  19727. roughness: number;
  19728. /**
  19729. * In case of refraction, define the value of the index of refraction.
  19730. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19731. */
  19732. indexOfRefraction: number;
  19733. /**
  19734. * Invert the refraction texture alongside the y axis.
  19735. * It can be useful with procedural textures or probe for instance.
  19736. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19737. */
  19738. invertRefractionY: boolean;
  19739. /**
  19740. * Defines the alpha limits in alpha test mode.
  19741. */
  19742. alphaCutOff: number;
  19743. private _useLightmapAsShadowmap;
  19744. /**
  19745. * In case of light mapping, define whether the map contains light or shadow informations.
  19746. */
  19747. useLightmapAsShadowmap: boolean;
  19748. private _diffuseFresnelParameters;
  19749. /**
  19750. * Define the diffuse fresnel parameters of the material.
  19751. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19752. */
  19753. diffuseFresnelParameters: FresnelParameters;
  19754. private _opacityFresnelParameters;
  19755. /**
  19756. * Define the opacity fresnel parameters of the material.
  19757. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19758. */
  19759. opacityFresnelParameters: FresnelParameters;
  19760. private _reflectionFresnelParameters;
  19761. /**
  19762. * Define the reflection fresnel parameters of the material.
  19763. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19764. */
  19765. reflectionFresnelParameters: FresnelParameters;
  19766. private _refractionFresnelParameters;
  19767. /**
  19768. * Define the refraction fresnel parameters of the material.
  19769. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19770. */
  19771. refractionFresnelParameters: FresnelParameters;
  19772. private _emissiveFresnelParameters;
  19773. /**
  19774. * Define the emissive fresnel parameters of the material.
  19775. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19776. */
  19777. emissiveFresnelParameters: FresnelParameters;
  19778. private _useReflectionFresnelFromSpecular;
  19779. /**
  19780. * If true automatically deducts the fresnels values from the material specularity.
  19781. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19782. */
  19783. useReflectionFresnelFromSpecular: boolean;
  19784. private _useGlossinessFromSpecularMapAlpha;
  19785. /**
  19786. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19787. */
  19788. useGlossinessFromSpecularMapAlpha: boolean;
  19789. private _maxSimultaneousLights;
  19790. /**
  19791. * Defines the maximum number of lights that can be used in the material
  19792. */
  19793. maxSimultaneousLights: number;
  19794. private _invertNormalMapX;
  19795. /**
  19796. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19797. */
  19798. invertNormalMapX: boolean;
  19799. private _invertNormalMapY;
  19800. /**
  19801. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19802. */
  19803. invertNormalMapY: boolean;
  19804. private _twoSidedLighting;
  19805. /**
  19806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19807. */
  19808. twoSidedLighting: boolean;
  19809. /**
  19810. * Default configuration related to image processing available in the standard Material.
  19811. */
  19812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19813. /**
  19814. * Gets the image processing configuration used either in this material.
  19815. */
  19816. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19817. /**
  19818. * Sets the Default image processing configuration used either in the this material.
  19819. *
  19820. * If sets to null, the scene one is in use.
  19821. */
  19822. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19823. /**
  19824. * Keep track of the image processing observer to allow dispose and replace.
  19825. */
  19826. private _imageProcessingObserver;
  19827. /**
  19828. * Attaches a new image processing configuration to the Standard Material.
  19829. * @param configuration
  19830. */
  19831. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19832. /**
  19833. * Defines additional PrePass parameters for the material.
  19834. */
  19835. readonly prePassConfiguration: PrePassConfiguration;
  19836. /**
  19837. * Can this material render to prepass
  19838. */
  19839. get isPrePassCapable(): boolean;
  19840. /**
  19841. * Gets whether the color curves effect is enabled.
  19842. */
  19843. get cameraColorCurvesEnabled(): boolean;
  19844. /**
  19845. * Sets whether the color curves effect is enabled.
  19846. */
  19847. set cameraColorCurvesEnabled(value: boolean);
  19848. /**
  19849. * Gets whether the color grading effect is enabled.
  19850. */
  19851. get cameraColorGradingEnabled(): boolean;
  19852. /**
  19853. * Gets whether the color grading effect is enabled.
  19854. */
  19855. set cameraColorGradingEnabled(value: boolean);
  19856. /**
  19857. * Gets whether tonemapping is enabled or not.
  19858. */
  19859. get cameraToneMappingEnabled(): boolean;
  19860. /**
  19861. * Sets whether tonemapping is enabled or not
  19862. */
  19863. set cameraToneMappingEnabled(value: boolean);
  19864. /**
  19865. * The camera exposure used on this material.
  19866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19867. * This corresponds to a photographic exposure.
  19868. */
  19869. get cameraExposure(): number;
  19870. /**
  19871. * The camera exposure used on this material.
  19872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19873. * This corresponds to a photographic exposure.
  19874. */
  19875. set cameraExposure(value: number);
  19876. /**
  19877. * Gets The camera contrast used on this material.
  19878. */
  19879. get cameraContrast(): number;
  19880. /**
  19881. * Sets The camera contrast used on this material.
  19882. */
  19883. set cameraContrast(value: number);
  19884. /**
  19885. * Gets the Color Grading 2D Lookup Texture.
  19886. */
  19887. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19888. /**
  19889. * Sets the Color Grading 2D Lookup Texture.
  19890. */
  19891. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19892. /**
  19893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19895. * 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;
  19896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19897. */
  19898. get cameraColorCurves(): Nullable<ColorCurves>;
  19899. /**
  19900. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19901. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19902. * 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;
  19903. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19904. */
  19905. set cameraColorCurves(value: Nullable<ColorCurves>);
  19906. /**
  19907. * Can this material render to several textures at once
  19908. */
  19909. get canRenderToMRT(): boolean;
  19910. /**
  19911. * Defines the detail map parameters for the material.
  19912. */
  19913. readonly detailMap: DetailMapConfiguration;
  19914. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19915. protected _worldViewProjectionMatrix: Matrix;
  19916. protected _globalAmbientColor: Color3;
  19917. protected _useLogarithmicDepth: boolean;
  19918. protected _rebuildInParallel: boolean;
  19919. /**
  19920. * Instantiates a new standard material.
  19921. * This is the default material used in Babylon. It is the best trade off between quality
  19922. * and performances.
  19923. * @see https://doc.babylonjs.com/babylon101/materials
  19924. * @param name Define the name of the material in the scene
  19925. * @param scene Define the scene the material belong to
  19926. */
  19927. constructor(name: string, scene: Scene);
  19928. /**
  19929. * Gets a boolean indicating that current material needs to register RTT
  19930. */
  19931. get hasRenderTargetTextures(): boolean;
  19932. /**
  19933. * Gets the current class name of the material e.g. "StandardMaterial"
  19934. * Mainly use in serialization.
  19935. * @returns the class name
  19936. */
  19937. getClassName(): string;
  19938. /**
  19939. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19940. * You can try switching to logarithmic depth.
  19941. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19942. */
  19943. get useLogarithmicDepth(): boolean;
  19944. set useLogarithmicDepth(value: boolean);
  19945. /**
  19946. * Specifies if the material will require alpha blending
  19947. * @returns a boolean specifying if alpha blending is needed
  19948. */
  19949. needAlphaBlending(): boolean;
  19950. /**
  19951. * Specifies if this material should be rendered in alpha test mode
  19952. * @returns a boolean specifying if an alpha test is needed.
  19953. */
  19954. needAlphaTesting(): boolean;
  19955. /**
  19956. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19957. */
  19958. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19959. /**
  19960. * Specifies whether or not there is a usable alpha channel for transparency.
  19961. */
  19962. protected _hasAlphaChannel(): boolean;
  19963. /**
  19964. * Get the texture used for alpha test purpose.
  19965. * @returns the diffuse texture in case of the standard material.
  19966. */
  19967. getAlphaTestTexture(): Nullable<BaseTexture>;
  19968. /**
  19969. * Get if the submesh is ready to be used and all its information available.
  19970. * Child classes can use it to update shaders
  19971. * @param mesh defines the mesh to check
  19972. * @param subMesh defines which submesh to check
  19973. * @param useInstances specifies that instances should be used
  19974. * @returns a boolean indicating that the submesh is ready or not
  19975. */
  19976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19977. /**
  19978. * Builds the material UBO layouts.
  19979. * Used internally during the effect preparation.
  19980. */
  19981. buildUniformLayout(): void;
  19982. /**
  19983. * Unbinds the material from the mesh
  19984. */
  19985. unbind(): void;
  19986. /**
  19987. * Binds the submesh to this material by preparing the effect and shader to draw
  19988. * @param world defines the world transformation matrix
  19989. * @param mesh defines the mesh containing the submesh
  19990. * @param subMesh defines the submesh to bind the material to
  19991. */
  19992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19993. /**
  19994. * Get the list of animatables in the material.
  19995. * @returns the list of animatables object used in the material
  19996. */
  19997. getAnimatables(): IAnimatable[];
  19998. /**
  19999. * Gets the active textures from the material
  20000. * @returns an array of textures
  20001. */
  20002. getActiveTextures(): BaseTexture[];
  20003. /**
  20004. * Specifies if the material uses a texture
  20005. * @param texture defines the texture to check against the material
  20006. * @returns a boolean specifying if the material uses the texture
  20007. */
  20008. hasTexture(texture: BaseTexture): boolean;
  20009. /**
  20010. * Disposes the material
  20011. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20012. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20013. */
  20014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20015. /**
  20016. * Makes a duplicate of the material, and gives it a new name
  20017. * @param name defines the new name for the duplicated material
  20018. * @returns the cloned material
  20019. */
  20020. clone(name: string): StandardMaterial;
  20021. /**
  20022. * Serializes this material in a JSON representation
  20023. * @returns the serialized material object
  20024. */
  20025. serialize(): any;
  20026. /**
  20027. * Creates a standard material from parsed material data
  20028. * @param source defines the JSON representation of the material
  20029. * @param scene defines the hosting scene
  20030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20031. * @returns a new standard material
  20032. */
  20033. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20034. /**
  20035. * Are diffuse textures enabled in the application.
  20036. */
  20037. static get DiffuseTextureEnabled(): boolean;
  20038. static set DiffuseTextureEnabled(value: boolean);
  20039. /**
  20040. * Are detail textures enabled in the application.
  20041. */
  20042. static get DetailTextureEnabled(): boolean;
  20043. static set DetailTextureEnabled(value: boolean);
  20044. /**
  20045. * Are ambient textures enabled in the application.
  20046. */
  20047. static get AmbientTextureEnabled(): boolean;
  20048. static set AmbientTextureEnabled(value: boolean);
  20049. /**
  20050. * Are opacity textures enabled in the application.
  20051. */
  20052. static get OpacityTextureEnabled(): boolean;
  20053. static set OpacityTextureEnabled(value: boolean);
  20054. /**
  20055. * Are reflection textures enabled in the application.
  20056. */
  20057. static get ReflectionTextureEnabled(): boolean;
  20058. static set ReflectionTextureEnabled(value: boolean);
  20059. /**
  20060. * Are emissive textures enabled in the application.
  20061. */
  20062. static get EmissiveTextureEnabled(): boolean;
  20063. static set EmissiveTextureEnabled(value: boolean);
  20064. /**
  20065. * Are specular textures enabled in the application.
  20066. */
  20067. static get SpecularTextureEnabled(): boolean;
  20068. static set SpecularTextureEnabled(value: boolean);
  20069. /**
  20070. * Are bump textures enabled in the application.
  20071. */
  20072. static get BumpTextureEnabled(): boolean;
  20073. static set BumpTextureEnabled(value: boolean);
  20074. /**
  20075. * Are lightmap textures enabled in the application.
  20076. */
  20077. static get LightmapTextureEnabled(): boolean;
  20078. static set LightmapTextureEnabled(value: boolean);
  20079. /**
  20080. * Are refraction textures enabled in the application.
  20081. */
  20082. static get RefractionTextureEnabled(): boolean;
  20083. static set RefractionTextureEnabled(value: boolean);
  20084. /**
  20085. * Are color grading textures enabled in the application.
  20086. */
  20087. static get ColorGradingTextureEnabled(): boolean;
  20088. static set ColorGradingTextureEnabled(value: boolean);
  20089. /**
  20090. * Are fresnels enabled in the application.
  20091. */
  20092. static get FresnelEnabled(): boolean;
  20093. static set FresnelEnabled(value: boolean);
  20094. }
  20095. }
  20096. declare module BABYLON {
  20097. /** @hidden */
  20098. export var rgbdDecodePixelShader: {
  20099. name: string;
  20100. shader: string;
  20101. };
  20102. }
  20103. declare module BABYLON {
  20104. /** @hidden */
  20105. export var passPixelShader: {
  20106. name: string;
  20107. shader: string;
  20108. };
  20109. }
  20110. declare module BABYLON {
  20111. /** @hidden */
  20112. export var passCubePixelShader: {
  20113. name: string;
  20114. shader: string;
  20115. };
  20116. }
  20117. declare module BABYLON {
  20118. /**
  20119. * PassPostProcess which produces an output the same as it's input
  20120. */
  20121. export class PassPostProcess extends PostProcess {
  20122. /**
  20123. * Gets a string identifying the name of the class
  20124. * @returns "PassPostProcess" string
  20125. */
  20126. getClassName(): string;
  20127. /**
  20128. * Creates the PassPostProcess
  20129. * @param name The name of the effect.
  20130. * @param options The required width/height ratio to downsize to before computing the render pass.
  20131. * @param camera The camera to apply the render pass to.
  20132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20133. * @param engine The engine which the post process will be applied. (default: current engine)
  20134. * @param reusable If the post process can be reused on the same frame. (default: false)
  20135. * @param textureType The type of texture to be used when performing the post processing.
  20136. * @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)
  20137. */
  20138. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20139. /** @hidden */
  20140. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20141. }
  20142. /**
  20143. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20144. */
  20145. export class PassCubePostProcess extends PostProcess {
  20146. private _face;
  20147. /**
  20148. * Gets or sets the cube face to display.
  20149. * * 0 is +X
  20150. * * 1 is -X
  20151. * * 2 is +Y
  20152. * * 3 is -Y
  20153. * * 4 is +Z
  20154. * * 5 is -Z
  20155. */
  20156. get face(): number;
  20157. set face(value: number);
  20158. /**
  20159. * Gets a string identifying the name of the class
  20160. * @returns "PassCubePostProcess" string
  20161. */
  20162. getClassName(): string;
  20163. /**
  20164. * Creates the PassCubePostProcess
  20165. * @param name The name of the effect.
  20166. * @param options The required width/height ratio to downsize to before computing the render pass.
  20167. * @param camera The camera to apply the render pass to.
  20168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20169. * @param engine The engine which the post process will be applied. (default: current engine)
  20170. * @param reusable If the post process can be reused on the same frame. (default: false)
  20171. * @param textureType The type of texture to be used when performing the post processing.
  20172. * @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)
  20173. */
  20174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20175. /** @hidden */
  20176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20177. }
  20178. }
  20179. declare module BABYLON {
  20180. /**
  20181. * Class used to host texture specific utilities
  20182. */
  20183. export class TextureTools {
  20184. /**
  20185. * Uses the GPU to create a copy texture rescaled at a given size
  20186. * @param texture Texture to copy from
  20187. * @param width defines the desired width
  20188. * @param height defines the desired height
  20189. * @param useBilinearMode defines if bilinear mode has to be used
  20190. * @return the generated texture
  20191. */
  20192. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20193. /**
  20194. * Apply a post process to a texture
  20195. * @param postProcessName name of the fragment post process
  20196. * @param internalTexture the texture to encode
  20197. * @param scene the scene hosting the texture
  20198. * @param type type of the output texture. If not provided, use the one from internalTexture
  20199. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20200. * @param format format of the output texture. If not provided, use the one from internalTexture
  20201. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20202. */
  20203. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20204. }
  20205. }
  20206. declare module BABYLON {
  20207. /**
  20208. * Class used to host RGBD texture specific utilities
  20209. */
  20210. export class RGBDTextureTools {
  20211. /**
  20212. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20213. * @param texture the texture to expand.
  20214. */
  20215. static ExpandRGBDTexture(texture: Texture): void;
  20216. /**
  20217. * Encode the texture to RGBD if possible.
  20218. * @param internalTexture the texture to encode
  20219. * @param scene the scene hosting the texture
  20220. * @param outputTextureType type of the texture in which the encoding is performed
  20221. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20222. */
  20223. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20224. }
  20225. }
  20226. declare module BABYLON {
  20227. /**
  20228. * Class used to host texture specific utilities
  20229. */
  20230. export class BRDFTextureTools {
  20231. /**
  20232. * Prevents texture cache collision
  20233. */
  20234. private static _instanceNumber;
  20235. /**
  20236. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20237. * @param scene defines the hosting scene
  20238. * @returns the environment BRDF texture
  20239. */
  20240. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20241. private static _environmentBRDFBase64Texture;
  20242. }
  20243. }
  20244. declare module BABYLON {
  20245. /**
  20246. * @hidden
  20247. */
  20248. export interface IMaterialClearCoatDefines {
  20249. CLEARCOAT: boolean;
  20250. CLEARCOAT_DEFAULTIOR: boolean;
  20251. CLEARCOAT_TEXTURE: boolean;
  20252. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20253. CLEARCOAT_TEXTUREDIRECTUV: number;
  20254. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20255. CLEARCOAT_BUMP: boolean;
  20256. CLEARCOAT_BUMPDIRECTUV: number;
  20257. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20258. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20259. CLEARCOAT_REMAP_F0: boolean;
  20260. CLEARCOAT_TINT: boolean;
  20261. CLEARCOAT_TINT_TEXTURE: boolean;
  20262. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20263. /** @hidden */
  20264. _areTexturesDirty: boolean;
  20265. }
  20266. /**
  20267. * Define the code related to the clear coat parameters of the pbr material.
  20268. */
  20269. export class PBRClearCoatConfiguration {
  20270. /**
  20271. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20272. * The default fits with a polyurethane material.
  20273. * @hidden
  20274. */
  20275. static readonly _DefaultIndexOfRefraction: number;
  20276. private _isEnabled;
  20277. /**
  20278. * Defines if the clear coat is enabled in the material.
  20279. */
  20280. isEnabled: boolean;
  20281. /**
  20282. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20283. */
  20284. intensity: number;
  20285. /**
  20286. * Defines the clear coat layer roughness.
  20287. */
  20288. roughness: number;
  20289. private _indexOfRefraction;
  20290. /**
  20291. * Defines the index of refraction of the clear coat.
  20292. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20293. * The default fits with a polyurethane material.
  20294. * Changing the default value is more performance intensive.
  20295. */
  20296. indexOfRefraction: number;
  20297. private _texture;
  20298. /**
  20299. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20300. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20301. * if textureRoughness is not empty, else no texture roughness is used
  20302. */
  20303. texture: Nullable<BaseTexture>;
  20304. private _useRoughnessFromMainTexture;
  20305. /**
  20306. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20307. * If false, the green channel from textureRoughness is used for roughness
  20308. */
  20309. useRoughnessFromMainTexture: boolean;
  20310. private _textureRoughness;
  20311. /**
  20312. * Stores the clear coat roughness in a texture (green channel)
  20313. * Not used if useRoughnessFromMainTexture is true
  20314. */
  20315. textureRoughness: Nullable<BaseTexture>;
  20316. private _remapF0OnInterfaceChange;
  20317. /**
  20318. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20319. */
  20320. remapF0OnInterfaceChange: boolean;
  20321. private _bumpTexture;
  20322. /**
  20323. * Define the clear coat specific bump texture.
  20324. */
  20325. bumpTexture: Nullable<BaseTexture>;
  20326. private _isTintEnabled;
  20327. /**
  20328. * Defines if the clear coat tint is enabled in the material.
  20329. */
  20330. isTintEnabled: boolean;
  20331. /**
  20332. * Defines the clear coat tint of the material.
  20333. * This is only use if tint is enabled
  20334. */
  20335. tintColor: Color3;
  20336. /**
  20337. * Defines the distance at which the tint color should be found in the
  20338. * clear coat media.
  20339. * This is only use if tint is enabled
  20340. */
  20341. tintColorAtDistance: number;
  20342. /**
  20343. * Defines the clear coat layer thickness.
  20344. * This is only use if tint is enabled
  20345. */
  20346. tintThickness: number;
  20347. private _tintTexture;
  20348. /**
  20349. * Stores the clear tint values in a texture.
  20350. * rgb is tint
  20351. * a is a thickness factor
  20352. */
  20353. tintTexture: Nullable<BaseTexture>;
  20354. /** @hidden */
  20355. private _internalMarkAllSubMeshesAsTexturesDirty;
  20356. /** @hidden */
  20357. _markAllSubMeshesAsTexturesDirty(): void;
  20358. /**
  20359. * Instantiate a new instance of clear coat configuration.
  20360. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20361. */
  20362. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20363. /**
  20364. * Gets whether the submesh is ready to be used or not.
  20365. * @param defines the list of "defines" to update.
  20366. * @param scene defines the scene the material belongs to.
  20367. * @param engine defines the engine the material belongs to.
  20368. * @param disableBumpMap defines whether the material disables bump or not.
  20369. * @returns - boolean indicating that the submesh is ready or not.
  20370. */
  20371. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20372. /**
  20373. * Checks to see if a texture is used in the material.
  20374. * @param defines the list of "defines" to update.
  20375. * @param scene defines the scene to the material belongs to.
  20376. */
  20377. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20378. /**
  20379. * Binds the material data.
  20380. * @param uniformBuffer defines the Uniform buffer to fill in.
  20381. * @param scene defines the scene the material belongs to.
  20382. * @param engine defines the engine the material belongs to.
  20383. * @param disableBumpMap defines whether the material disables bump or not.
  20384. * @param isFrozen defines whether the material is frozen or not.
  20385. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20386. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20387. * @param subMesh the submesh to bind data for
  20388. */
  20389. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20390. /**
  20391. * Checks to see if a texture is used in the material.
  20392. * @param texture - Base texture to use.
  20393. * @returns - Boolean specifying if a texture is used in the material.
  20394. */
  20395. hasTexture(texture: BaseTexture): boolean;
  20396. /**
  20397. * Returns an array of the actively used textures.
  20398. * @param activeTextures Array of BaseTextures
  20399. */
  20400. getActiveTextures(activeTextures: BaseTexture[]): void;
  20401. /**
  20402. * Returns the animatable textures.
  20403. * @param animatables Array of animatable textures.
  20404. */
  20405. getAnimatables(animatables: IAnimatable[]): void;
  20406. /**
  20407. * Disposes the resources of the material.
  20408. * @param forceDisposeTextures - Forces the disposal of all textures.
  20409. */
  20410. dispose(forceDisposeTextures?: boolean): void;
  20411. /**
  20412. * Get the current class name of the texture useful for serialization or dynamic coding.
  20413. * @returns "PBRClearCoatConfiguration"
  20414. */
  20415. getClassName(): string;
  20416. /**
  20417. * Add fallbacks to the effect fallbacks list.
  20418. * @param defines defines the Base texture to use.
  20419. * @param fallbacks defines the current fallback list.
  20420. * @param currentRank defines the current fallback rank.
  20421. * @returns the new fallback rank.
  20422. */
  20423. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20424. /**
  20425. * Add the required uniforms to the current list.
  20426. * @param uniforms defines the current uniform list.
  20427. */
  20428. static AddUniforms(uniforms: string[]): void;
  20429. /**
  20430. * Add the required samplers to the current list.
  20431. * @param samplers defines the current sampler list.
  20432. */
  20433. static AddSamplers(samplers: string[]): void;
  20434. /**
  20435. * Add the required uniforms to the current buffer.
  20436. * @param uniformBuffer defines the current uniform buffer.
  20437. */
  20438. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20439. /**
  20440. * Makes a duplicate of the current configuration into another one.
  20441. * @param clearCoatConfiguration define the config where to copy the info
  20442. */
  20443. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20444. /**
  20445. * Serializes this clear coat configuration.
  20446. * @returns - An object with the serialized config.
  20447. */
  20448. serialize(): any;
  20449. /**
  20450. * Parses a anisotropy Configuration from a serialized object.
  20451. * @param source - Serialized object.
  20452. * @param scene Defines the scene we are parsing for
  20453. * @param rootUrl Defines the rootUrl to load from
  20454. */
  20455. parse(source: any, scene: Scene, rootUrl: string): void;
  20456. }
  20457. }
  20458. declare module BABYLON {
  20459. /**
  20460. * @hidden
  20461. */
  20462. export interface IMaterialAnisotropicDefines {
  20463. ANISOTROPIC: boolean;
  20464. ANISOTROPIC_TEXTURE: boolean;
  20465. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20466. MAINUV1: boolean;
  20467. _areTexturesDirty: boolean;
  20468. _needUVs: boolean;
  20469. }
  20470. /**
  20471. * Define the code related to the anisotropic parameters of the pbr material.
  20472. */
  20473. export class PBRAnisotropicConfiguration {
  20474. private _isEnabled;
  20475. /**
  20476. * Defines if the anisotropy is enabled in the material.
  20477. */
  20478. isEnabled: boolean;
  20479. /**
  20480. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20481. */
  20482. intensity: number;
  20483. /**
  20484. * Defines if the effect is along the tangents, bitangents or in between.
  20485. * By default, the effect is "stretching" the highlights along the tangents.
  20486. */
  20487. direction: Vector2;
  20488. private _texture;
  20489. /**
  20490. * Stores the anisotropy values in a texture.
  20491. * rg is direction (like normal from -1 to 1)
  20492. * b is a intensity
  20493. */
  20494. texture: Nullable<BaseTexture>;
  20495. /** @hidden */
  20496. private _internalMarkAllSubMeshesAsTexturesDirty;
  20497. /** @hidden */
  20498. _markAllSubMeshesAsTexturesDirty(): void;
  20499. /**
  20500. * Instantiate a new instance of anisotropy configuration.
  20501. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20502. */
  20503. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20504. /**
  20505. * Specifies that the submesh is ready to be used.
  20506. * @param defines the list of "defines" to update.
  20507. * @param scene defines the scene the material belongs to.
  20508. * @returns - boolean indicating that the submesh is ready or not.
  20509. */
  20510. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20511. /**
  20512. * Checks to see if a texture is used in the material.
  20513. * @param defines the list of "defines" to update.
  20514. * @param mesh the mesh we are preparing the defines for.
  20515. * @param scene defines the scene the material belongs to.
  20516. */
  20517. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20518. /**
  20519. * Binds the material data.
  20520. * @param uniformBuffer defines the Uniform buffer to fill in.
  20521. * @param scene defines the scene the material belongs to.
  20522. * @param isFrozen defines whether the material is frozen or not.
  20523. */
  20524. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20525. /**
  20526. * Checks to see if a texture is used in the material.
  20527. * @param texture - Base texture to use.
  20528. * @returns - Boolean specifying if a texture is used in the material.
  20529. */
  20530. hasTexture(texture: BaseTexture): boolean;
  20531. /**
  20532. * Returns an array of the actively used textures.
  20533. * @param activeTextures Array of BaseTextures
  20534. */
  20535. getActiveTextures(activeTextures: BaseTexture[]): void;
  20536. /**
  20537. * Returns the animatable textures.
  20538. * @param animatables Array of animatable textures.
  20539. */
  20540. getAnimatables(animatables: IAnimatable[]): void;
  20541. /**
  20542. * Disposes the resources of the material.
  20543. * @param forceDisposeTextures - Forces the disposal of all textures.
  20544. */
  20545. dispose(forceDisposeTextures?: boolean): void;
  20546. /**
  20547. * Get the current class name of the texture useful for serialization or dynamic coding.
  20548. * @returns "PBRAnisotropicConfiguration"
  20549. */
  20550. getClassName(): string;
  20551. /**
  20552. * Add fallbacks to the effect fallbacks list.
  20553. * @param defines defines the Base texture to use.
  20554. * @param fallbacks defines the current fallback list.
  20555. * @param currentRank defines the current fallback rank.
  20556. * @returns the new fallback rank.
  20557. */
  20558. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20559. /**
  20560. * Add the required uniforms to the current list.
  20561. * @param uniforms defines the current uniform list.
  20562. */
  20563. static AddUniforms(uniforms: string[]): void;
  20564. /**
  20565. * Add the required uniforms to the current buffer.
  20566. * @param uniformBuffer defines the current uniform buffer.
  20567. */
  20568. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20569. /**
  20570. * Add the required samplers to the current list.
  20571. * @param samplers defines the current sampler list.
  20572. */
  20573. static AddSamplers(samplers: string[]): void;
  20574. /**
  20575. * Makes a duplicate of the current configuration into another one.
  20576. * @param anisotropicConfiguration define the config where to copy the info
  20577. */
  20578. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20579. /**
  20580. * Serializes this anisotropy configuration.
  20581. * @returns - An object with the serialized config.
  20582. */
  20583. serialize(): any;
  20584. /**
  20585. * Parses a anisotropy Configuration from a serialized object.
  20586. * @param source - Serialized object.
  20587. * @param scene Defines the scene we are parsing for
  20588. * @param rootUrl Defines the rootUrl to load from
  20589. */
  20590. parse(source: any, scene: Scene, rootUrl: string): void;
  20591. }
  20592. }
  20593. declare module BABYLON {
  20594. /**
  20595. * @hidden
  20596. */
  20597. export interface IMaterialBRDFDefines {
  20598. BRDF_V_HEIGHT_CORRELATED: boolean;
  20599. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20600. SPHERICAL_HARMONICS: boolean;
  20601. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20602. /** @hidden */
  20603. _areMiscDirty: boolean;
  20604. }
  20605. /**
  20606. * Define the code related to the BRDF parameters of the pbr material.
  20607. */
  20608. export class PBRBRDFConfiguration {
  20609. /**
  20610. * Default value used for the energy conservation.
  20611. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20612. */
  20613. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20614. /**
  20615. * Default value used for the Smith Visibility Height Correlated mode.
  20616. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20617. */
  20618. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20619. /**
  20620. * Default value used for the IBL diffuse part.
  20621. * This can help switching back to the polynomials mode globally which is a tiny bit
  20622. * less GPU intensive at the drawback of a lower quality.
  20623. */
  20624. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20625. /**
  20626. * Default value used for activating energy conservation for the specular workflow.
  20627. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20628. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20629. */
  20630. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20631. private _useEnergyConservation;
  20632. /**
  20633. * Defines if the material uses energy conservation.
  20634. */
  20635. useEnergyConservation: boolean;
  20636. private _useSmithVisibilityHeightCorrelated;
  20637. /**
  20638. * LEGACY Mode set to false
  20639. * Defines if the material uses height smith correlated visibility term.
  20640. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20641. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20642. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20643. * Not relying on height correlated will also disable energy conservation.
  20644. */
  20645. useSmithVisibilityHeightCorrelated: boolean;
  20646. private _useSphericalHarmonics;
  20647. /**
  20648. * LEGACY Mode set to false
  20649. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20650. * diffuse part of the IBL.
  20651. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20652. * to the ground truth.
  20653. */
  20654. useSphericalHarmonics: boolean;
  20655. private _useSpecularGlossinessInputEnergyConservation;
  20656. /**
  20657. * Defines if the material uses energy conservation, when the specular workflow is active.
  20658. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20659. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20660. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20661. */
  20662. useSpecularGlossinessInputEnergyConservation: boolean;
  20663. /** @hidden */
  20664. private _internalMarkAllSubMeshesAsMiscDirty;
  20665. /** @hidden */
  20666. _markAllSubMeshesAsMiscDirty(): void;
  20667. /**
  20668. * Instantiate a new instance of clear coat configuration.
  20669. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20670. */
  20671. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20672. /**
  20673. * Checks to see if a texture is used in the material.
  20674. * @param defines the list of "defines" to update.
  20675. */
  20676. prepareDefines(defines: IMaterialBRDFDefines): void;
  20677. /**
  20678. * Get the current class name of the texture useful for serialization or dynamic coding.
  20679. * @returns "PBRClearCoatConfiguration"
  20680. */
  20681. getClassName(): string;
  20682. /**
  20683. * Makes a duplicate of the current configuration into another one.
  20684. * @param brdfConfiguration define the config where to copy the info
  20685. */
  20686. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20687. /**
  20688. * Serializes this BRDF configuration.
  20689. * @returns - An object with the serialized config.
  20690. */
  20691. serialize(): any;
  20692. /**
  20693. * Parses a anisotropy Configuration from a serialized object.
  20694. * @param source - Serialized object.
  20695. * @param scene Defines the scene we are parsing for
  20696. * @param rootUrl Defines the rootUrl to load from
  20697. */
  20698. parse(source: any, scene: Scene, rootUrl: string): void;
  20699. }
  20700. }
  20701. declare module BABYLON {
  20702. /**
  20703. * @hidden
  20704. */
  20705. export interface IMaterialSheenDefines {
  20706. SHEEN: boolean;
  20707. SHEEN_TEXTURE: boolean;
  20708. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20709. SHEEN_TEXTUREDIRECTUV: number;
  20710. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20711. SHEEN_LINKWITHALBEDO: boolean;
  20712. SHEEN_ROUGHNESS: boolean;
  20713. SHEEN_ALBEDOSCALING: boolean;
  20714. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20715. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20716. /** @hidden */
  20717. _areTexturesDirty: boolean;
  20718. }
  20719. /**
  20720. * Define the code related to the Sheen parameters of the pbr material.
  20721. */
  20722. export class PBRSheenConfiguration {
  20723. private _isEnabled;
  20724. /**
  20725. * Defines if the material uses sheen.
  20726. */
  20727. isEnabled: boolean;
  20728. private _linkSheenWithAlbedo;
  20729. /**
  20730. * Defines if the sheen is linked to the sheen color.
  20731. */
  20732. linkSheenWithAlbedo: boolean;
  20733. /**
  20734. * Defines the sheen intensity.
  20735. */
  20736. intensity: number;
  20737. /**
  20738. * Defines the sheen color.
  20739. */
  20740. color: Color3;
  20741. private _texture;
  20742. /**
  20743. * Stores the sheen tint values in a texture.
  20744. * rgb is tint
  20745. * 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)
  20746. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20747. */
  20748. texture: Nullable<BaseTexture>;
  20749. private _useRoughnessFromMainTexture;
  20750. /**
  20751. * Indicates that the alpha channel of the texture property will be used for roughness.
  20752. * Has no effect if the roughness (and texture!) property is not defined
  20753. */
  20754. useRoughnessFromMainTexture: boolean;
  20755. private _roughness;
  20756. /**
  20757. * Defines the sheen roughness.
  20758. * It is not taken into account if linkSheenWithAlbedo is true.
  20759. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20760. */
  20761. roughness: Nullable<number>;
  20762. private _textureRoughness;
  20763. /**
  20764. * Stores the sheen roughness in a texture.
  20765. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20766. */
  20767. textureRoughness: Nullable<BaseTexture>;
  20768. private _albedoScaling;
  20769. /**
  20770. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20771. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20772. * making it easier to setup and tweak the effect
  20773. */
  20774. albedoScaling: boolean;
  20775. /** @hidden */
  20776. private _internalMarkAllSubMeshesAsTexturesDirty;
  20777. /** @hidden */
  20778. _markAllSubMeshesAsTexturesDirty(): void;
  20779. /**
  20780. * Instantiate a new instance of clear coat configuration.
  20781. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20782. */
  20783. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20784. /**
  20785. * Specifies that the submesh is ready to be used.
  20786. * @param defines the list of "defines" to update.
  20787. * @param scene defines the scene the material belongs to.
  20788. * @returns - boolean indicating that the submesh is ready or not.
  20789. */
  20790. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20791. /**
  20792. * Checks to see if a texture is used in the material.
  20793. * @param defines the list of "defines" to update.
  20794. * @param scene defines the scene the material belongs to.
  20795. */
  20796. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20797. /**
  20798. * Binds the material data.
  20799. * @param uniformBuffer defines the Uniform buffer to fill in.
  20800. * @param scene defines the scene the material belongs to.
  20801. * @param isFrozen defines whether the material is frozen or not.
  20802. * @param subMesh the submesh to bind data for
  20803. */
  20804. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20805. /**
  20806. * Checks to see if a texture is used in the material.
  20807. * @param texture - Base texture to use.
  20808. * @returns - Boolean specifying if a texture is used in the material.
  20809. */
  20810. hasTexture(texture: BaseTexture): boolean;
  20811. /**
  20812. * Returns an array of the actively used textures.
  20813. * @param activeTextures Array of BaseTextures
  20814. */
  20815. getActiveTextures(activeTextures: BaseTexture[]): void;
  20816. /**
  20817. * Returns the animatable textures.
  20818. * @param animatables Array of animatable textures.
  20819. */
  20820. getAnimatables(animatables: IAnimatable[]): void;
  20821. /**
  20822. * Disposes the resources of the material.
  20823. * @param forceDisposeTextures - Forces the disposal of all textures.
  20824. */
  20825. dispose(forceDisposeTextures?: boolean): void;
  20826. /**
  20827. * Get the current class name of the texture useful for serialization or dynamic coding.
  20828. * @returns "PBRSheenConfiguration"
  20829. */
  20830. getClassName(): string;
  20831. /**
  20832. * Add fallbacks to the effect fallbacks list.
  20833. * @param defines defines the Base texture to use.
  20834. * @param fallbacks defines the current fallback list.
  20835. * @param currentRank defines the current fallback rank.
  20836. * @returns the new fallback rank.
  20837. */
  20838. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20839. /**
  20840. * Add the required uniforms to the current list.
  20841. * @param uniforms defines the current uniform list.
  20842. */
  20843. static AddUniforms(uniforms: string[]): void;
  20844. /**
  20845. * Add the required uniforms to the current buffer.
  20846. * @param uniformBuffer defines the current uniform buffer.
  20847. */
  20848. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20849. /**
  20850. * Add the required samplers to the current list.
  20851. * @param samplers defines the current sampler list.
  20852. */
  20853. static AddSamplers(samplers: string[]): void;
  20854. /**
  20855. * Makes a duplicate of the current configuration into another one.
  20856. * @param sheenConfiguration define the config where to copy the info
  20857. */
  20858. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20859. /**
  20860. * Serializes this BRDF configuration.
  20861. * @returns - An object with the serialized config.
  20862. */
  20863. serialize(): any;
  20864. /**
  20865. * Parses a anisotropy Configuration from a serialized object.
  20866. * @param source - Serialized object.
  20867. * @param scene Defines the scene we are parsing for
  20868. * @param rootUrl Defines the rootUrl to load from
  20869. */
  20870. parse(source: any, scene: Scene, rootUrl: string): void;
  20871. }
  20872. }
  20873. declare module BABYLON {
  20874. /**
  20875. * @hidden
  20876. */
  20877. export interface IMaterialSubSurfaceDefines {
  20878. SUBSURFACE: boolean;
  20879. SS_REFRACTION: boolean;
  20880. SS_TRANSLUCENCY: boolean;
  20881. SS_SCATTERING: boolean;
  20882. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20883. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20884. SS_REFRACTIONMAP_3D: boolean;
  20885. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20886. SS_LODINREFRACTIONALPHA: boolean;
  20887. SS_GAMMAREFRACTION: boolean;
  20888. SS_RGBDREFRACTION: boolean;
  20889. SS_LINEARSPECULARREFRACTION: boolean;
  20890. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20891. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20892. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20893. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20894. /** @hidden */
  20895. _areTexturesDirty: boolean;
  20896. }
  20897. /**
  20898. * Define the code related to the sub surface parameters of the pbr material.
  20899. */
  20900. export class PBRSubSurfaceConfiguration {
  20901. private _isRefractionEnabled;
  20902. /**
  20903. * Defines if the refraction is enabled in the material.
  20904. */
  20905. isRefractionEnabled: boolean;
  20906. private _isTranslucencyEnabled;
  20907. /**
  20908. * Defines if the translucency is enabled in the material.
  20909. */
  20910. isTranslucencyEnabled: boolean;
  20911. private _isScatteringEnabled;
  20912. /**
  20913. * Defines if the sub surface scattering is enabled in the material.
  20914. */
  20915. isScatteringEnabled: boolean;
  20916. private _scatteringDiffusionProfileIndex;
  20917. /**
  20918. * Diffusion profile for subsurface scattering.
  20919. * Useful for better scattering in the skins or foliages.
  20920. */
  20921. get scatteringDiffusionProfile(): Nullable<Color3>;
  20922. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20923. /**
  20924. * Defines the refraction intensity of the material.
  20925. * The refraction when enabled replaces the Diffuse part of the material.
  20926. * The intensity helps transitioning between diffuse and refraction.
  20927. */
  20928. refractionIntensity: number;
  20929. /**
  20930. * Defines the translucency intensity of the material.
  20931. * When translucency has been enabled, this defines how much of the "translucency"
  20932. * is added to the diffuse part of the material.
  20933. */
  20934. translucencyIntensity: number;
  20935. /**
  20936. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20937. */
  20938. useAlbedoToTintRefraction: boolean;
  20939. private _thicknessTexture;
  20940. /**
  20941. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20942. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20943. * 0 would mean minimumThickness
  20944. * 1 would mean maximumThickness
  20945. * The other channels might be use as a mask to vary the different effects intensity.
  20946. */
  20947. thicknessTexture: Nullable<BaseTexture>;
  20948. private _refractionTexture;
  20949. /**
  20950. * Defines the texture to use for refraction.
  20951. */
  20952. refractionTexture: Nullable<BaseTexture>;
  20953. private _indexOfRefraction;
  20954. /**
  20955. * Index of refraction of the material base layer.
  20956. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20957. *
  20958. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20959. *
  20960. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20961. */
  20962. indexOfRefraction: number;
  20963. private _volumeIndexOfRefraction;
  20964. /**
  20965. * Index of refraction of the material's volume.
  20966. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20967. *
  20968. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20969. * the volume will use the same IOR as the surface.
  20970. */
  20971. get volumeIndexOfRefraction(): number;
  20972. set volumeIndexOfRefraction(value: number);
  20973. private _invertRefractionY;
  20974. /**
  20975. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20976. */
  20977. invertRefractionY: boolean;
  20978. private _linkRefractionWithTransparency;
  20979. /**
  20980. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20981. * Materials half opaque for instance using refraction could benefit from this control.
  20982. */
  20983. linkRefractionWithTransparency: boolean;
  20984. /**
  20985. * Defines the minimum thickness stored in the thickness map.
  20986. * If no thickness map is defined, this value will be used to simulate thickness.
  20987. */
  20988. minimumThickness: number;
  20989. /**
  20990. * Defines the maximum thickness stored in the thickness map.
  20991. */
  20992. maximumThickness: number;
  20993. /**
  20994. * Defines the volume tint of the material.
  20995. * This is used for both translucency and scattering.
  20996. */
  20997. tintColor: Color3;
  20998. /**
  20999. * Defines the distance at which the tint color should be found in the media.
  21000. * This is used for refraction only.
  21001. */
  21002. tintColorAtDistance: number;
  21003. /**
  21004. * Defines how far each channel transmit through the media.
  21005. * It is defined as a color to simplify it selection.
  21006. */
  21007. diffusionDistance: Color3;
  21008. private _useMaskFromThicknessTexture;
  21009. /**
  21010. * Stores the intensity of the different subsurface effects in the thickness texture.
  21011. * * the green channel is the translucency intensity.
  21012. * * the blue channel is the scattering intensity.
  21013. * * the alpha channel is the refraction intensity.
  21014. */
  21015. useMaskFromThicknessTexture: boolean;
  21016. private _scene;
  21017. private _useMaskFromThicknessTextureGltf;
  21018. /**
  21019. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21020. * matches the channel-packing that is used by glTF.
  21021. * * the red channel is the transmission/translucency intensity.
  21022. * * the green channel is the thickness.
  21023. */
  21024. useMaskFromThicknessTextureGltf: boolean;
  21025. /** @hidden */
  21026. private _internalMarkAllSubMeshesAsTexturesDirty;
  21027. private _internalMarkScenePrePassDirty;
  21028. /** @hidden */
  21029. _markAllSubMeshesAsTexturesDirty(): void;
  21030. /** @hidden */
  21031. _markScenePrePassDirty(): void;
  21032. /**
  21033. * Instantiate a new instance of sub surface configuration.
  21034. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21035. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21036. * @param scene The scene
  21037. */
  21038. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21039. /**
  21040. * Gets whether the submesh is ready to be used or not.
  21041. * @param defines the list of "defines" to update.
  21042. * @param scene defines the scene the material belongs to.
  21043. * @returns - boolean indicating that the submesh is ready or not.
  21044. */
  21045. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21046. /**
  21047. * Checks to see if a texture is used in the material.
  21048. * @param defines the list of "defines" to update.
  21049. * @param scene defines the scene to the material belongs to.
  21050. */
  21051. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21052. /**
  21053. * Binds the material data.
  21054. * @param uniformBuffer defines the Uniform buffer to fill in.
  21055. * @param scene defines the scene the material belongs to.
  21056. * @param engine defines the engine the material belongs to.
  21057. * @param isFrozen defines whether the material is frozen or not.
  21058. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21059. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21060. */
  21061. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21062. /**
  21063. * Unbinds the material from the mesh.
  21064. * @param activeEffect defines the effect that should be unbound from.
  21065. * @returns true if unbound, otherwise false
  21066. */
  21067. unbind(activeEffect: Effect): boolean;
  21068. /**
  21069. * Returns the texture used for refraction or null if none is used.
  21070. * @param scene defines the scene the material belongs to.
  21071. * @returns - Refraction texture if present. If no refraction texture and refraction
  21072. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21073. */
  21074. private _getRefractionTexture;
  21075. /**
  21076. * Returns true if alpha blending should be disabled.
  21077. */
  21078. get disableAlphaBlending(): boolean;
  21079. /**
  21080. * Fills the list of render target textures.
  21081. * @param renderTargets the list of render targets to update
  21082. */
  21083. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21084. /**
  21085. * Checks to see if a texture is used in the material.
  21086. * @param texture - Base texture to use.
  21087. * @returns - Boolean specifying if a texture is used in the material.
  21088. */
  21089. hasTexture(texture: BaseTexture): boolean;
  21090. /**
  21091. * Gets a boolean indicating that current material needs to register RTT
  21092. * @returns true if this uses a render target otherwise false.
  21093. */
  21094. hasRenderTargetTextures(): boolean;
  21095. /**
  21096. * Returns an array of the actively used textures.
  21097. * @param activeTextures Array of BaseTextures
  21098. */
  21099. getActiveTextures(activeTextures: BaseTexture[]): void;
  21100. /**
  21101. * Returns the animatable textures.
  21102. * @param animatables Array of animatable textures.
  21103. */
  21104. getAnimatables(animatables: IAnimatable[]): void;
  21105. /**
  21106. * Disposes the resources of the material.
  21107. * @param forceDisposeTextures - Forces the disposal of all textures.
  21108. */
  21109. dispose(forceDisposeTextures?: boolean): void;
  21110. /**
  21111. * Get the current class name of the texture useful for serialization or dynamic coding.
  21112. * @returns "PBRSubSurfaceConfiguration"
  21113. */
  21114. getClassName(): string;
  21115. /**
  21116. * Add fallbacks to the effect fallbacks list.
  21117. * @param defines defines the Base texture to use.
  21118. * @param fallbacks defines the current fallback list.
  21119. * @param currentRank defines the current fallback rank.
  21120. * @returns the new fallback rank.
  21121. */
  21122. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21123. /**
  21124. * Add the required uniforms to the current list.
  21125. * @param uniforms defines the current uniform list.
  21126. */
  21127. static AddUniforms(uniforms: string[]): void;
  21128. /**
  21129. * Add the required samplers to the current list.
  21130. * @param samplers defines the current sampler list.
  21131. */
  21132. static AddSamplers(samplers: string[]): void;
  21133. /**
  21134. * Add the required uniforms to the current buffer.
  21135. * @param uniformBuffer defines the current uniform buffer.
  21136. */
  21137. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21138. /**
  21139. * Makes a duplicate of the current configuration into another one.
  21140. * @param configuration define the config where to copy the info
  21141. */
  21142. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21143. /**
  21144. * Serializes this Sub Surface configuration.
  21145. * @returns - An object with the serialized config.
  21146. */
  21147. serialize(): any;
  21148. /**
  21149. * Parses a anisotropy Configuration from a serialized object.
  21150. * @param source - Serialized object.
  21151. * @param scene Defines the scene we are parsing for
  21152. * @param rootUrl Defines the rootUrl to load from
  21153. */
  21154. parse(source: any, scene: Scene, rootUrl: string): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class representing spherical harmonics coefficients to the 3rd degree
  21160. */
  21161. export class SphericalHarmonics {
  21162. /**
  21163. * Defines whether or not the harmonics have been prescaled for rendering.
  21164. */
  21165. preScaled: boolean;
  21166. /**
  21167. * The l0,0 coefficients of the spherical harmonics
  21168. */
  21169. l00: Vector3;
  21170. /**
  21171. * The l1,-1 coefficients of the spherical harmonics
  21172. */
  21173. l1_1: Vector3;
  21174. /**
  21175. * The l1,0 coefficients of the spherical harmonics
  21176. */
  21177. l10: Vector3;
  21178. /**
  21179. * The l1,1 coefficients of the spherical harmonics
  21180. */
  21181. l11: Vector3;
  21182. /**
  21183. * The l2,-2 coefficients of the spherical harmonics
  21184. */
  21185. l2_2: Vector3;
  21186. /**
  21187. * The l2,-1 coefficients of the spherical harmonics
  21188. */
  21189. l2_1: Vector3;
  21190. /**
  21191. * The l2,0 coefficients of the spherical harmonics
  21192. */
  21193. l20: Vector3;
  21194. /**
  21195. * The l2,1 coefficients of the spherical harmonics
  21196. */
  21197. l21: Vector3;
  21198. /**
  21199. * The l2,2 coefficients of the spherical harmonics
  21200. */
  21201. l22: Vector3;
  21202. /**
  21203. * Adds a light to the spherical harmonics
  21204. * @param direction the direction of the light
  21205. * @param color the color of the light
  21206. * @param deltaSolidAngle the delta solid angle of the light
  21207. */
  21208. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21209. /**
  21210. * Scales the spherical harmonics by the given amount
  21211. * @param scale the amount to scale
  21212. */
  21213. scaleInPlace(scale: number): void;
  21214. /**
  21215. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21216. *
  21217. * ```
  21218. * E_lm = A_l * L_lm
  21219. * ```
  21220. *
  21221. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21222. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21223. * the scaling factors are given in equation 9.
  21224. */
  21225. convertIncidentRadianceToIrradiance(): void;
  21226. /**
  21227. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21228. *
  21229. * ```
  21230. * L = (1/pi) * E * rho
  21231. * ```
  21232. *
  21233. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21234. */
  21235. convertIrradianceToLambertianRadiance(): void;
  21236. /**
  21237. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21238. * required operations at run time.
  21239. *
  21240. * This is simply done by scaling back the SH with Ylm constants parameter.
  21241. * The trigonometric part being applied by the shader at run time.
  21242. */
  21243. preScaleForRendering(): void;
  21244. /**
  21245. * Constructs a spherical harmonics from an array.
  21246. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21247. * @returns the spherical harmonics
  21248. */
  21249. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21250. /**
  21251. * Gets the spherical harmonics from polynomial
  21252. * @param polynomial the spherical polynomial
  21253. * @returns the spherical harmonics
  21254. */
  21255. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21256. }
  21257. /**
  21258. * Class representing spherical polynomial coefficients to the 3rd degree
  21259. */
  21260. export class SphericalPolynomial {
  21261. private _harmonics;
  21262. /**
  21263. * The spherical harmonics used to create the polynomials.
  21264. */
  21265. get preScaledHarmonics(): SphericalHarmonics;
  21266. /**
  21267. * The x coefficients of the spherical polynomial
  21268. */
  21269. x: Vector3;
  21270. /**
  21271. * The y coefficients of the spherical polynomial
  21272. */
  21273. y: Vector3;
  21274. /**
  21275. * The z coefficients of the spherical polynomial
  21276. */
  21277. z: Vector3;
  21278. /**
  21279. * The xx coefficients of the spherical polynomial
  21280. */
  21281. xx: Vector3;
  21282. /**
  21283. * The yy coefficients of the spherical polynomial
  21284. */
  21285. yy: Vector3;
  21286. /**
  21287. * The zz coefficients of the spherical polynomial
  21288. */
  21289. zz: Vector3;
  21290. /**
  21291. * The xy coefficients of the spherical polynomial
  21292. */
  21293. xy: Vector3;
  21294. /**
  21295. * The yz coefficients of the spherical polynomial
  21296. */
  21297. yz: Vector3;
  21298. /**
  21299. * The zx coefficients of the spherical polynomial
  21300. */
  21301. zx: Vector3;
  21302. /**
  21303. * Adds an ambient color to the spherical polynomial
  21304. * @param color the color to add
  21305. */
  21306. addAmbient(color: Color3): void;
  21307. /**
  21308. * Scales the spherical polynomial by the given amount
  21309. * @param scale the amount to scale
  21310. */
  21311. scaleInPlace(scale: number): void;
  21312. /**
  21313. * Gets the spherical polynomial from harmonics
  21314. * @param harmonics the spherical harmonics
  21315. * @returns the spherical polynomial
  21316. */
  21317. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21318. /**
  21319. * Constructs a spherical polynomial from an array.
  21320. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21321. * @returns the spherical polynomial
  21322. */
  21323. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21324. }
  21325. }
  21326. declare module BABYLON {
  21327. /**
  21328. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21329. */
  21330. export interface CubeMapInfo {
  21331. /**
  21332. * The pixel array for the front face.
  21333. * This is stored in format, left to right, up to down format.
  21334. */
  21335. front: Nullable<ArrayBufferView>;
  21336. /**
  21337. * The pixel array for the back face.
  21338. * This is stored in format, left to right, up to down format.
  21339. */
  21340. back: Nullable<ArrayBufferView>;
  21341. /**
  21342. * The pixel array for the left face.
  21343. * This is stored in format, left to right, up to down format.
  21344. */
  21345. left: Nullable<ArrayBufferView>;
  21346. /**
  21347. * The pixel array for the right face.
  21348. * This is stored in format, left to right, up to down format.
  21349. */
  21350. right: Nullable<ArrayBufferView>;
  21351. /**
  21352. * The pixel array for the up face.
  21353. * This is stored in format, left to right, up to down format.
  21354. */
  21355. up: Nullable<ArrayBufferView>;
  21356. /**
  21357. * The pixel array for the down face.
  21358. * This is stored in format, left to right, up to down format.
  21359. */
  21360. down: Nullable<ArrayBufferView>;
  21361. /**
  21362. * The size of the cubemap stored.
  21363. *
  21364. * Each faces will be size * size pixels.
  21365. */
  21366. size: number;
  21367. /**
  21368. * The format of the texture.
  21369. *
  21370. * RGBA, RGB.
  21371. */
  21372. format: number;
  21373. /**
  21374. * The type of the texture data.
  21375. *
  21376. * UNSIGNED_INT, FLOAT.
  21377. */
  21378. type: number;
  21379. /**
  21380. * Specifies whether the texture is in gamma space.
  21381. */
  21382. gammaSpace: boolean;
  21383. }
  21384. /**
  21385. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21386. */
  21387. export class PanoramaToCubeMapTools {
  21388. private static FACE_LEFT;
  21389. private static FACE_RIGHT;
  21390. private static FACE_FRONT;
  21391. private static FACE_BACK;
  21392. private static FACE_DOWN;
  21393. private static FACE_UP;
  21394. /**
  21395. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21396. *
  21397. * @param float32Array The source data.
  21398. * @param inputWidth The width of the input panorama.
  21399. * @param inputHeight The height of the input panorama.
  21400. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21401. * @return The cubemap data
  21402. */
  21403. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21404. private static CreateCubemapTexture;
  21405. private static CalcProjectionSpherical;
  21406. }
  21407. }
  21408. declare module BABYLON {
  21409. /**
  21410. * Helper class dealing with the extraction of spherical polynomial dataArray
  21411. * from a cube map.
  21412. */
  21413. export class CubeMapToSphericalPolynomialTools {
  21414. private static FileFaces;
  21415. /**
  21416. * Converts a texture to the according Spherical Polynomial data.
  21417. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21418. *
  21419. * @param texture The texture to extract the information from.
  21420. * @return The Spherical Polynomial data.
  21421. */
  21422. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21423. /**
  21424. * Converts a cubemap to the according Spherical Polynomial data.
  21425. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21426. *
  21427. * @param cubeInfo The Cube map to extract the information from.
  21428. * @return The Spherical Polynomial data.
  21429. */
  21430. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21431. }
  21432. }
  21433. declare module BABYLON {
  21434. interface BaseTexture {
  21435. /**
  21436. * Get the polynomial representation of the texture data.
  21437. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21438. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21439. */
  21440. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21441. }
  21442. }
  21443. declare module BABYLON {
  21444. /** @hidden */
  21445. export var pbrFragmentDeclaration: {
  21446. name: string;
  21447. shader: string;
  21448. };
  21449. }
  21450. declare module BABYLON {
  21451. /** @hidden */
  21452. export var pbrUboDeclaration: {
  21453. name: string;
  21454. shader: string;
  21455. };
  21456. }
  21457. declare module BABYLON {
  21458. /** @hidden */
  21459. export var pbrFragmentExtraDeclaration: {
  21460. name: string;
  21461. shader: string;
  21462. };
  21463. }
  21464. declare module BABYLON {
  21465. /** @hidden */
  21466. export var pbrFragmentSamplersDeclaration: {
  21467. name: string;
  21468. shader: string;
  21469. };
  21470. }
  21471. declare module BABYLON {
  21472. /** @hidden */
  21473. export var subSurfaceScatteringFunctions: {
  21474. name: string;
  21475. shader: string;
  21476. };
  21477. }
  21478. declare module BABYLON {
  21479. /** @hidden */
  21480. export var importanceSampling: {
  21481. name: string;
  21482. shader: string;
  21483. };
  21484. }
  21485. declare module BABYLON {
  21486. /** @hidden */
  21487. export var pbrHelperFunctions: {
  21488. name: string;
  21489. shader: string;
  21490. };
  21491. }
  21492. declare module BABYLON {
  21493. /** @hidden */
  21494. export var harmonicsFunctions: {
  21495. name: string;
  21496. shader: string;
  21497. };
  21498. }
  21499. declare module BABYLON {
  21500. /** @hidden */
  21501. export var pbrDirectLightingSetupFunctions: {
  21502. name: string;
  21503. shader: string;
  21504. };
  21505. }
  21506. declare module BABYLON {
  21507. /** @hidden */
  21508. export var pbrDirectLightingFalloffFunctions: {
  21509. name: string;
  21510. shader: string;
  21511. };
  21512. }
  21513. declare module BABYLON {
  21514. /** @hidden */
  21515. export var pbrBRDFFunctions: {
  21516. name: string;
  21517. shader: string;
  21518. };
  21519. }
  21520. declare module BABYLON {
  21521. /** @hidden */
  21522. export var hdrFilteringFunctions: {
  21523. name: string;
  21524. shader: string;
  21525. };
  21526. }
  21527. declare module BABYLON {
  21528. /** @hidden */
  21529. export var pbrDirectLightingFunctions: {
  21530. name: string;
  21531. shader: string;
  21532. };
  21533. }
  21534. declare module BABYLON {
  21535. /** @hidden */
  21536. export var pbrIBLFunctions: {
  21537. name: string;
  21538. shader: string;
  21539. };
  21540. }
  21541. declare module BABYLON {
  21542. /** @hidden */
  21543. export var pbrBlockAlbedoOpacity: {
  21544. name: string;
  21545. shader: string;
  21546. };
  21547. }
  21548. declare module BABYLON {
  21549. /** @hidden */
  21550. export var pbrBlockReflectivity: {
  21551. name: string;
  21552. shader: string;
  21553. };
  21554. }
  21555. declare module BABYLON {
  21556. /** @hidden */
  21557. export var pbrBlockAmbientOcclusion: {
  21558. name: string;
  21559. shader: string;
  21560. };
  21561. }
  21562. declare module BABYLON {
  21563. /** @hidden */
  21564. export var pbrBlockAlphaFresnel: {
  21565. name: string;
  21566. shader: string;
  21567. };
  21568. }
  21569. declare module BABYLON {
  21570. /** @hidden */
  21571. export var pbrBlockAnisotropic: {
  21572. name: string;
  21573. shader: string;
  21574. };
  21575. }
  21576. declare module BABYLON {
  21577. /** @hidden */
  21578. export var pbrBlockReflection: {
  21579. name: string;
  21580. shader: string;
  21581. };
  21582. }
  21583. declare module BABYLON {
  21584. /** @hidden */
  21585. export var pbrBlockSheen: {
  21586. name: string;
  21587. shader: string;
  21588. };
  21589. }
  21590. declare module BABYLON {
  21591. /** @hidden */
  21592. export var pbrBlockClearcoat: {
  21593. name: string;
  21594. shader: string;
  21595. };
  21596. }
  21597. declare module BABYLON {
  21598. /** @hidden */
  21599. export var pbrBlockSubSurface: {
  21600. name: string;
  21601. shader: string;
  21602. };
  21603. }
  21604. declare module BABYLON {
  21605. /** @hidden */
  21606. export var pbrBlockNormalGeometric: {
  21607. name: string;
  21608. shader: string;
  21609. };
  21610. }
  21611. declare module BABYLON {
  21612. /** @hidden */
  21613. export var pbrBlockNormalFinal: {
  21614. name: string;
  21615. shader: string;
  21616. };
  21617. }
  21618. declare module BABYLON {
  21619. /** @hidden */
  21620. export var pbrBlockLightmapInit: {
  21621. name: string;
  21622. shader: string;
  21623. };
  21624. }
  21625. declare module BABYLON {
  21626. /** @hidden */
  21627. export var pbrBlockGeometryInfo: {
  21628. name: string;
  21629. shader: string;
  21630. };
  21631. }
  21632. declare module BABYLON {
  21633. /** @hidden */
  21634. export var pbrBlockReflectance0: {
  21635. name: string;
  21636. shader: string;
  21637. };
  21638. }
  21639. declare module BABYLON {
  21640. /** @hidden */
  21641. export var pbrBlockReflectance: {
  21642. name: string;
  21643. shader: string;
  21644. };
  21645. }
  21646. declare module BABYLON {
  21647. /** @hidden */
  21648. export var pbrBlockDirectLighting: {
  21649. name: string;
  21650. shader: string;
  21651. };
  21652. }
  21653. declare module BABYLON {
  21654. /** @hidden */
  21655. export var pbrBlockFinalLitComponents: {
  21656. name: string;
  21657. shader: string;
  21658. };
  21659. }
  21660. declare module BABYLON {
  21661. /** @hidden */
  21662. export var pbrBlockFinalUnlitComponents: {
  21663. name: string;
  21664. shader: string;
  21665. };
  21666. }
  21667. declare module BABYLON {
  21668. /** @hidden */
  21669. export var pbrBlockFinalColorComposition: {
  21670. name: string;
  21671. shader: string;
  21672. };
  21673. }
  21674. declare module BABYLON {
  21675. /** @hidden */
  21676. export var pbrBlockImageProcessing: {
  21677. name: string;
  21678. shader: string;
  21679. };
  21680. }
  21681. declare module BABYLON {
  21682. /** @hidden */
  21683. export var pbrDebug: {
  21684. name: string;
  21685. shader: string;
  21686. };
  21687. }
  21688. declare module BABYLON {
  21689. /** @hidden */
  21690. export var pbrPixelShader: {
  21691. name: string;
  21692. shader: string;
  21693. };
  21694. }
  21695. declare module BABYLON {
  21696. /** @hidden */
  21697. export var pbrVertexDeclaration: {
  21698. name: string;
  21699. shader: string;
  21700. };
  21701. }
  21702. declare module BABYLON {
  21703. /** @hidden */
  21704. export var pbrVertexShader: {
  21705. name: string;
  21706. shader: string;
  21707. };
  21708. }
  21709. declare module BABYLON {
  21710. /**
  21711. * Manages the defines for the PBR Material.
  21712. * @hidden
  21713. */
  21714. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21715. PBR: boolean;
  21716. NUM_SAMPLES: string;
  21717. REALTIME_FILTERING: boolean;
  21718. MAINUV1: boolean;
  21719. MAINUV2: boolean;
  21720. UV1: boolean;
  21721. UV2: boolean;
  21722. ALBEDO: boolean;
  21723. GAMMAALBEDO: boolean;
  21724. ALBEDODIRECTUV: number;
  21725. VERTEXCOLOR: boolean;
  21726. DETAIL: boolean;
  21727. DETAILDIRECTUV: number;
  21728. DETAIL_NORMALBLENDMETHOD: number;
  21729. AMBIENT: boolean;
  21730. AMBIENTDIRECTUV: number;
  21731. AMBIENTINGRAYSCALE: boolean;
  21732. OPACITY: boolean;
  21733. VERTEXALPHA: boolean;
  21734. OPACITYDIRECTUV: number;
  21735. OPACITYRGB: boolean;
  21736. ALPHATEST: boolean;
  21737. DEPTHPREPASS: boolean;
  21738. ALPHABLEND: boolean;
  21739. ALPHAFROMALBEDO: boolean;
  21740. ALPHATESTVALUE: string;
  21741. SPECULAROVERALPHA: boolean;
  21742. RADIANCEOVERALPHA: boolean;
  21743. ALPHAFRESNEL: boolean;
  21744. LINEARALPHAFRESNEL: boolean;
  21745. PREMULTIPLYALPHA: boolean;
  21746. EMISSIVE: boolean;
  21747. EMISSIVEDIRECTUV: number;
  21748. REFLECTIVITY: boolean;
  21749. REFLECTIVITYDIRECTUV: number;
  21750. SPECULARTERM: boolean;
  21751. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21752. MICROSURFACEAUTOMATIC: boolean;
  21753. LODBASEDMICROSFURACE: boolean;
  21754. MICROSURFACEMAP: boolean;
  21755. MICROSURFACEMAPDIRECTUV: number;
  21756. METALLICWORKFLOW: boolean;
  21757. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21758. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21759. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21760. AOSTOREINMETALMAPRED: boolean;
  21761. METALLIC_REFLECTANCE: boolean;
  21762. METALLIC_REFLECTANCEDIRECTUV: number;
  21763. ENVIRONMENTBRDF: boolean;
  21764. ENVIRONMENTBRDF_RGBD: boolean;
  21765. NORMAL: boolean;
  21766. TANGENT: boolean;
  21767. BUMP: boolean;
  21768. BUMPDIRECTUV: number;
  21769. OBJECTSPACE_NORMALMAP: boolean;
  21770. PARALLAX: boolean;
  21771. PARALLAXOCCLUSION: boolean;
  21772. NORMALXYSCALE: boolean;
  21773. LIGHTMAP: boolean;
  21774. LIGHTMAPDIRECTUV: number;
  21775. USELIGHTMAPASSHADOWMAP: boolean;
  21776. GAMMALIGHTMAP: boolean;
  21777. RGBDLIGHTMAP: boolean;
  21778. REFLECTION: boolean;
  21779. REFLECTIONMAP_3D: boolean;
  21780. REFLECTIONMAP_SPHERICAL: boolean;
  21781. REFLECTIONMAP_PLANAR: boolean;
  21782. REFLECTIONMAP_CUBIC: boolean;
  21783. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21784. REFLECTIONMAP_PROJECTION: boolean;
  21785. REFLECTIONMAP_SKYBOX: boolean;
  21786. REFLECTIONMAP_EXPLICIT: boolean;
  21787. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21788. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21789. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21790. INVERTCUBICMAP: boolean;
  21791. USESPHERICALFROMREFLECTIONMAP: boolean;
  21792. USEIRRADIANCEMAP: boolean;
  21793. SPHERICAL_HARMONICS: boolean;
  21794. USESPHERICALINVERTEX: boolean;
  21795. REFLECTIONMAP_OPPOSITEZ: boolean;
  21796. LODINREFLECTIONALPHA: boolean;
  21797. GAMMAREFLECTION: boolean;
  21798. RGBDREFLECTION: boolean;
  21799. LINEARSPECULARREFLECTION: boolean;
  21800. RADIANCEOCCLUSION: boolean;
  21801. HORIZONOCCLUSION: boolean;
  21802. INSTANCES: boolean;
  21803. THIN_INSTANCES: boolean;
  21804. PREPASS: boolean;
  21805. PREPASS_IRRADIANCE: boolean;
  21806. PREPASS_IRRADIANCE_INDEX: number;
  21807. PREPASS_ALBEDO: boolean;
  21808. PREPASS_ALBEDO_INDEX: number;
  21809. PREPASS_DEPTH: boolean;
  21810. PREPASS_DEPTH_INDEX: number;
  21811. PREPASS_NORMAL: boolean;
  21812. PREPASS_NORMAL_INDEX: number;
  21813. PREPASS_POSITION: boolean;
  21814. PREPASS_POSITION_INDEX: number;
  21815. PREPASS_VELOCITY: boolean;
  21816. PREPASS_VELOCITY_INDEX: number;
  21817. PREPASS_REFLECTIVITY: boolean;
  21818. PREPASS_REFLECTIVITY_INDEX: number;
  21819. SCENE_MRT_COUNT: number;
  21820. NUM_BONE_INFLUENCERS: number;
  21821. BonesPerMesh: number;
  21822. BONETEXTURE: boolean;
  21823. BONES_VELOCITY_ENABLED: boolean;
  21824. NONUNIFORMSCALING: boolean;
  21825. MORPHTARGETS: boolean;
  21826. MORPHTARGETS_NORMAL: boolean;
  21827. MORPHTARGETS_TANGENT: boolean;
  21828. MORPHTARGETS_UV: boolean;
  21829. NUM_MORPH_INFLUENCERS: number;
  21830. MORPHTARGETS_TEXTURE: boolean;
  21831. IMAGEPROCESSING: boolean;
  21832. VIGNETTE: boolean;
  21833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21834. VIGNETTEBLENDMODEOPAQUE: boolean;
  21835. TONEMAPPING: boolean;
  21836. TONEMAPPING_ACES: boolean;
  21837. CONTRAST: boolean;
  21838. COLORCURVES: boolean;
  21839. COLORGRADING: boolean;
  21840. COLORGRADING3D: boolean;
  21841. SAMPLER3DGREENDEPTH: boolean;
  21842. SAMPLER3DBGRMAP: boolean;
  21843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21844. EXPOSURE: boolean;
  21845. MULTIVIEW: boolean;
  21846. USEPHYSICALLIGHTFALLOFF: boolean;
  21847. USEGLTFLIGHTFALLOFF: boolean;
  21848. TWOSIDEDLIGHTING: boolean;
  21849. SHADOWFLOAT: boolean;
  21850. CLIPPLANE: boolean;
  21851. CLIPPLANE2: boolean;
  21852. CLIPPLANE3: boolean;
  21853. CLIPPLANE4: boolean;
  21854. CLIPPLANE5: boolean;
  21855. CLIPPLANE6: boolean;
  21856. POINTSIZE: boolean;
  21857. FOG: boolean;
  21858. LOGARITHMICDEPTH: boolean;
  21859. FORCENORMALFORWARD: boolean;
  21860. SPECULARAA: boolean;
  21861. CLEARCOAT: boolean;
  21862. CLEARCOAT_DEFAULTIOR: boolean;
  21863. CLEARCOAT_TEXTURE: boolean;
  21864. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21865. CLEARCOAT_TEXTUREDIRECTUV: number;
  21866. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21867. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21868. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21869. CLEARCOAT_BUMP: boolean;
  21870. CLEARCOAT_BUMPDIRECTUV: number;
  21871. CLEARCOAT_REMAP_F0: boolean;
  21872. CLEARCOAT_TINT: boolean;
  21873. CLEARCOAT_TINT_TEXTURE: boolean;
  21874. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21875. ANISOTROPIC: boolean;
  21876. ANISOTROPIC_TEXTURE: boolean;
  21877. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21878. BRDF_V_HEIGHT_CORRELATED: boolean;
  21879. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21880. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21881. SHEEN: boolean;
  21882. SHEEN_TEXTURE: boolean;
  21883. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21884. SHEEN_TEXTUREDIRECTUV: number;
  21885. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21886. SHEEN_LINKWITHALBEDO: boolean;
  21887. SHEEN_ROUGHNESS: boolean;
  21888. SHEEN_ALBEDOSCALING: boolean;
  21889. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21890. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21891. SUBSURFACE: boolean;
  21892. SS_REFRACTION: boolean;
  21893. SS_TRANSLUCENCY: boolean;
  21894. SS_SCATTERING: boolean;
  21895. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21896. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21897. SS_REFRACTIONMAP_3D: boolean;
  21898. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21899. SS_LODINREFRACTIONALPHA: boolean;
  21900. SS_GAMMAREFRACTION: boolean;
  21901. SS_RGBDREFRACTION: boolean;
  21902. SS_LINEARSPECULARREFRACTION: boolean;
  21903. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21904. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21905. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21906. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21907. UNLIT: boolean;
  21908. DEBUGMODE: number;
  21909. /**
  21910. * Initializes the PBR Material defines.
  21911. */
  21912. constructor();
  21913. /**
  21914. * Resets the PBR Material defines.
  21915. */
  21916. reset(): void;
  21917. }
  21918. /**
  21919. * The Physically based material base class of BJS.
  21920. *
  21921. * This offers the main features of a standard PBR material.
  21922. * For more information, please refer to the documentation :
  21923. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21924. */
  21925. export abstract class PBRBaseMaterial extends PushMaterial {
  21926. /**
  21927. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21928. */
  21929. static readonly PBRMATERIAL_OPAQUE: number;
  21930. /**
  21931. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21932. */
  21933. static readonly PBRMATERIAL_ALPHATEST: number;
  21934. /**
  21935. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21936. */
  21937. static readonly PBRMATERIAL_ALPHABLEND: number;
  21938. /**
  21939. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21940. * They are also discarded below the alpha cutoff threshold to improve performances.
  21941. */
  21942. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21943. /**
  21944. * Defines the default value of how much AO map is occluding the analytical lights
  21945. * (point spot...).
  21946. */
  21947. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21948. /**
  21949. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21950. */
  21951. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21952. /**
  21953. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21954. * to enhance interoperability with other engines.
  21955. */
  21956. static readonly LIGHTFALLOFF_GLTF: number;
  21957. /**
  21958. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21959. * to enhance interoperability with other materials.
  21960. */
  21961. static readonly LIGHTFALLOFF_STANDARD: number;
  21962. /**
  21963. * Intensity of the direct lights e.g. the four lights available in your scene.
  21964. * This impacts both the direct diffuse and specular highlights.
  21965. */
  21966. protected _directIntensity: number;
  21967. /**
  21968. * Intensity of the emissive part of the material.
  21969. * This helps controlling the emissive effect without modifying the emissive color.
  21970. */
  21971. protected _emissiveIntensity: number;
  21972. /**
  21973. * Intensity of the environment e.g. how much the environment will light the object
  21974. * either through harmonics for rough material or through the reflection for shiny ones.
  21975. */
  21976. protected _environmentIntensity: number;
  21977. /**
  21978. * This is a special control allowing the reduction of the specular highlights coming from the
  21979. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21980. */
  21981. protected _specularIntensity: number;
  21982. /**
  21983. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21984. */
  21985. private _lightingInfos;
  21986. /**
  21987. * Debug Control allowing disabling the bump map on this material.
  21988. */
  21989. protected _disableBumpMap: boolean;
  21990. /**
  21991. * AKA Diffuse Texture in standard nomenclature.
  21992. */
  21993. protected _albedoTexture: Nullable<BaseTexture>;
  21994. /**
  21995. * AKA Occlusion Texture in other nomenclature.
  21996. */
  21997. protected _ambientTexture: Nullable<BaseTexture>;
  21998. /**
  21999. * AKA Occlusion Texture Intensity in other nomenclature.
  22000. */
  22001. protected _ambientTextureStrength: number;
  22002. /**
  22003. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22004. * 1 means it completely occludes it
  22005. * 0 mean it has no impact
  22006. */
  22007. protected _ambientTextureImpactOnAnalyticalLights: number;
  22008. /**
  22009. * Stores the alpha values in a texture.
  22010. */
  22011. protected _opacityTexture: Nullable<BaseTexture>;
  22012. /**
  22013. * Stores the reflection values in a texture.
  22014. */
  22015. protected _reflectionTexture: Nullable<BaseTexture>;
  22016. /**
  22017. * Stores the emissive values in a texture.
  22018. */
  22019. protected _emissiveTexture: Nullable<BaseTexture>;
  22020. /**
  22021. * AKA Specular texture in other nomenclature.
  22022. */
  22023. protected _reflectivityTexture: Nullable<BaseTexture>;
  22024. /**
  22025. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22026. */
  22027. protected _metallicTexture: Nullable<BaseTexture>;
  22028. /**
  22029. * Specifies the metallic scalar of the metallic/roughness workflow.
  22030. * Can also be used to scale the metalness values of the metallic texture.
  22031. */
  22032. protected _metallic: Nullable<number>;
  22033. /**
  22034. * Specifies the roughness scalar of the metallic/roughness workflow.
  22035. * Can also be used to scale the roughness values of the metallic texture.
  22036. */
  22037. protected _roughness: Nullable<number>;
  22038. /**
  22039. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22040. * By default the indexOfrefraction is used to compute F0;
  22041. *
  22042. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22043. *
  22044. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22045. * F90 = metallicReflectanceColor;
  22046. */
  22047. protected _metallicF0Factor: number;
  22048. /**
  22049. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22050. * By default the F90 is always 1;
  22051. *
  22052. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22053. *
  22054. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22055. * F90 = metallicReflectanceColor;
  22056. */
  22057. protected _metallicReflectanceColor: Color3;
  22058. /**
  22059. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22060. * This is multiply against the scalar values defined in the material.
  22061. */
  22062. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22063. /**
  22064. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22065. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22066. */
  22067. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22068. /**
  22069. * Stores surface normal data used to displace a mesh in a texture.
  22070. */
  22071. protected _bumpTexture: Nullable<BaseTexture>;
  22072. /**
  22073. * Stores the pre-calculated light information of a mesh in a texture.
  22074. */
  22075. protected _lightmapTexture: Nullable<BaseTexture>;
  22076. /**
  22077. * The color of a material in ambient lighting.
  22078. */
  22079. protected _ambientColor: Color3;
  22080. /**
  22081. * AKA Diffuse Color in other nomenclature.
  22082. */
  22083. protected _albedoColor: Color3;
  22084. /**
  22085. * AKA Specular Color in other nomenclature.
  22086. */
  22087. protected _reflectivityColor: Color3;
  22088. /**
  22089. * The color applied when light is reflected from a material.
  22090. */
  22091. protected _reflectionColor: Color3;
  22092. /**
  22093. * The color applied when light is emitted from a material.
  22094. */
  22095. protected _emissiveColor: Color3;
  22096. /**
  22097. * AKA Glossiness in other nomenclature.
  22098. */
  22099. protected _microSurface: number;
  22100. /**
  22101. * Specifies that the material will use the light map as a show map.
  22102. */
  22103. protected _useLightmapAsShadowmap: boolean;
  22104. /**
  22105. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22106. * makes the reflect vector face the model (under horizon).
  22107. */
  22108. protected _useHorizonOcclusion: boolean;
  22109. /**
  22110. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22111. * too much the area relying on ambient texture to define their ambient occlusion.
  22112. */
  22113. protected _useRadianceOcclusion: boolean;
  22114. /**
  22115. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22116. */
  22117. protected _useAlphaFromAlbedoTexture: boolean;
  22118. /**
  22119. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22120. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22121. */
  22122. protected _useSpecularOverAlpha: boolean;
  22123. /**
  22124. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22125. */
  22126. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22127. /**
  22128. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22129. */
  22130. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22131. /**
  22132. * Specifies if the metallic texture contains the roughness information in its green channel.
  22133. */
  22134. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22135. /**
  22136. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22137. */
  22138. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22139. /**
  22140. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22141. */
  22142. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22143. /**
  22144. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22145. */
  22146. protected _useAmbientInGrayScale: boolean;
  22147. /**
  22148. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22149. * The material will try to infer what glossiness each pixel should be.
  22150. */
  22151. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22152. /**
  22153. * Defines the falloff type used in this material.
  22154. * It by default is Physical.
  22155. */
  22156. protected _lightFalloff: number;
  22157. /**
  22158. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22159. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22160. */
  22161. protected _useRadianceOverAlpha: boolean;
  22162. /**
  22163. * Allows using an object space normal map (instead of tangent space).
  22164. */
  22165. protected _useObjectSpaceNormalMap: boolean;
  22166. /**
  22167. * Allows using the bump map in parallax mode.
  22168. */
  22169. protected _useParallax: boolean;
  22170. /**
  22171. * Allows using the bump map in parallax occlusion mode.
  22172. */
  22173. protected _useParallaxOcclusion: boolean;
  22174. /**
  22175. * Controls the scale bias of the parallax mode.
  22176. */
  22177. protected _parallaxScaleBias: number;
  22178. /**
  22179. * If sets to true, disables all the lights affecting the material.
  22180. */
  22181. protected _disableLighting: boolean;
  22182. /**
  22183. * Number of Simultaneous lights allowed on the material.
  22184. */
  22185. protected _maxSimultaneousLights: number;
  22186. /**
  22187. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22188. */
  22189. protected _invertNormalMapX: boolean;
  22190. /**
  22191. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22192. */
  22193. protected _invertNormalMapY: boolean;
  22194. /**
  22195. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22196. */
  22197. protected _twoSidedLighting: boolean;
  22198. /**
  22199. * Defines the alpha limits in alpha test mode.
  22200. */
  22201. protected _alphaCutOff: number;
  22202. /**
  22203. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22204. */
  22205. protected _forceAlphaTest: boolean;
  22206. /**
  22207. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22208. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22209. */
  22210. protected _useAlphaFresnel: boolean;
  22211. /**
  22212. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22213. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22214. */
  22215. protected _useLinearAlphaFresnel: boolean;
  22216. /**
  22217. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22218. * from cos theta and roughness:
  22219. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22220. */
  22221. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22222. /**
  22223. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22224. */
  22225. protected _forceIrradianceInFragment: boolean;
  22226. private _realTimeFiltering;
  22227. /**
  22228. * Enables realtime filtering on the texture.
  22229. */
  22230. get realTimeFiltering(): boolean;
  22231. set realTimeFiltering(b: boolean);
  22232. private _realTimeFilteringQuality;
  22233. /**
  22234. * Quality switch for realtime filtering
  22235. */
  22236. get realTimeFilteringQuality(): number;
  22237. set realTimeFilteringQuality(n: number);
  22238. /**
  22239. * Can this material render to several textures at once
  22240. */
  22241. get canRenderToMRT(): boolean;
  22242. /**
  22243. * Force normal to face away from face.
  22244. */
  22245. protected _forceNormalForward: boolean;
  22246. /**
  22247. * Enables specular anti aliasing in the PBR shader.
  22248. * It will both interacts on the Geometry for analytical and IBL lighting.
  22249. * It also prefilter the roughness map based on the bump values.
  22250. */
  22251. protected _enableSpecularAntiAliasing: boolean;
  22252. /**
  22253. * Default configuration related to image processing available in the PBR Material.
  22254. */
  22255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22256. /**
  22257. * Keep track of the image processing observer to allow dispose and replace.
  22258. */
  22259. private _imageProcessingObserver;
  22260. /**
  22261. * Attaches a new image processing configuration to the PBR Material.
  22262. * @param configuration
  22263. */
  22264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22265. /**
  22266. * Stores the available render targets.
  22267. */
  22268. private _renderTargets;
  22269. /**
  22270. * Sets the global ambient color for the material used in lighting calculations.
  22271. */
  22272. private _globalAmbientColor;
  22273. /**
  22274. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22275. */
  22276. private _useLogarithmicDepth;
  22277. /**
  22278. * If set to true, no lighting calculations will be applied.
  22279. */
  22280. private _unlit;
  22281. private _debugMode;
  22282. /**
  22283. * @hidden
  22284. * This is reserved for the inspector.
  22285. * Defines the material debug mode.
  22286. * It helps seeing only some components of the material while troubleshooting.
  22287. */
  22288. debugMode: number;
  22289. /**
  22290. * @hidden
  22291. * This is reserved for the inspector.
  22292. * Specify from where on screen the debug mode should start.
  22293. * The value goes from -1 (full screen) to 1 (not visible)
  22294. * It helps with side by side comparison against the final render
  22295. * This defaults to -1
  22296. */
  22297. private debugLimit;
  22298. /**
  22299. * @hidden
  22300. * This is reserved for the inspector.
  22301. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22302. * You can use the factor to better multiply the final value.
  22303. */
  22304. private debugFactor;
  22305. /**
  22306. * Defines the clear coat layer parameters for the material.
  22307. */
  22308. readonly clearCoat: PBRClearCoatConfiguration;
  22309. /**
  22310. * Defines the anisotropic parameters for the material.
  22311. */
  22312. readonly anisotropy: PBRAnisotropicConfiguration;
  22313. /**
  22314. * Defines the BRDF parameters for the material.
  22315. */
  22316. readonly brdf: PBRBRDFConfiguration;
  22317. /**
  22318. * Defines the Sheen parameters for the material.
  22319. */
  22320. readonly sheen: PBRSheenConfiguration;
  22321. /**
  22322. * Defines the SubSurface parameters for the material.
  22323. */
  22324. readonly subSurface: PBRSubSurfaceConfiguration;
  22325. /**
  22326. * Defines additional PrePass parameters for the material.
  22327. */
  22328. readonly prePassConfiguration: PrePassConfiguration;
  22329. /**
  22330. * Defines the detail map parameters for the material.
  22331. */
  22332. readonly detailMap: DetailMapConfiguration;
  22333. protected _rebuildInParallel: boolean;
  22334. /**
  22335. * Instantiates a new PBRMaterial instance.
  22336. *
  22337. * @param name The material name
  22338. * @param scene The scene the material will be use in.
  22339. */
  22340. constructor(name: string, scene: Scene);
  22341. /**
  22342. * Gets a boolean indicating that current material needs to register RTT
  22343. */
  22344. get hasRenderTargetTextures(): boolean;
  22345. /**
  22346. * Can this material render to prepass
  22347. */
  22348. get isPrePassCapable(): boolean;
  22349. /**
  22350. * Gets the name of the material class.
  22351. */
  22352. getClassName(): string;
  22353. /**
  22354. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22355. */
  22356. get useLogarithmicDepth(): boolean;
  22357. /**
  22358. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22359. */
  22360. set useLogarithmicDepth(value: boolean);
  22361. /**
  22362. * Returns true if alpha blending should be disabled.
  22363. */
  22364. protected get _disableAlphaBlending(): boolean;
  22365. /**
  22366. * Specifies whether or not this material should be rendered in alpha blend mode.
  22367. */
  22368. needAlphaBlending(): boolean;
  22369. /**
  22370. * Specifies whether or not this material should be rendered in alpha test mode.
  22371. */
  22372. needAlphaTesting(): boolean;
  22373. /**
  22374. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22375. */
  22376. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22377. /**
  22378. * Specifies whether or not there is a usable alpha channel for transparency.
  22379. */
  22380. protected _hasAlphaChannel(): boolean;
  22381. /**
  22382. * Gets the texture used for the alpha test.
  22383. */
  22384. getAlphaTestTexture(): Nullable<BaseTexture>;
  22385. /**
  22386. * Specifies that the submesh is ready to be used.
  22387. * @param mesh - BJS mesh.
  22388. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22389. * @param useInstances - Specifies that instances should be used.
  22390. * @returns - boolean indicating that the submesh is ready or not.
  22391. */
  22392. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22393. /**
  22394. * Specifies if the material uses metallic roughness workflow.
  22395. * @returns boolean specifying if the material uses metallic roughness workflow.
  22396. */
  22397. isMetallicWorkflow(): boolean;
  22398. private _prepareEffect;
  22399. private _prepareDefines;
  22400. /**
  22401. * Force shader compilation
  22402. */
  22403. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22404. /**
  22405. * Initializes the uniform buffer layout for the shader.
  22406. */
  22407. buildUniformLayout(): void;
  22408. /**
  22409. * Unbinds the material from the mesh
  22410. */
  22411. unbind(): void;
  22412. /**
  22413. * Binds the submesh data.
  22414. * @param world - The world matrix.
  22415. * @param mesh - The BJS mesh.
  22416. * @param subMesh - A submesh of the BJS mesh.
  22417. */
  22418. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22419. /**
  22420. * Returns the animatable textures.
  22421. * @returns - Array of animatable textures.
  22422. */
  22423. getAnimatables(): IAnimatable[];
  22424. /**
  22425. * Returns the texture used for reflections.
  22426. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22427. */
  22428. private _getReflectionTexture;
  22429. /**
  22430. * Returns an array of the actively used textures.
  22431. * @returns - Array of BaseTextures
  22432. */
  22433. getActiveTextures(): BaseTexture[];
  22434. /**
  22435. * Checks to see if a texture is used in the material.
  22436. * @param texture - Base texture to use.
  22437. * @returns - Boolean specifying if a texture is used in the material.
  22438. */
  22439. hasTexture(texture: BaseTexture): boolean;
  22440. /**
  22441. * Sets the required values to the prepass renderer.
  22442. * @param prePassRenderer defines the prepass renderer to setup
  22443. */
  22444. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22445. /**
  22446. * Disposes the resources of the material.
  22447. * @param forceDisposeEffect - Forces the disposal of effects.
  22448. * @param forceDisposeTextures - Forces the disposal of all textures.
  22449. */
  22450. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22451. }
  22452. }
  22453. declare module BABYLON {
  22454. /**
  22455. * The Physically based material of BJS.
  22456. *
  22457. * This offers the main features of a standard PBR material.
  22458. * For more information, please refer to the documentation :
  22459. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22460. */
  22461. export class PBRMaterial extends PBRBaseMaterial {
  22462. /**
  22463. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22464. */
  22465. static readonly PBRMATERIAL_OPAQUE: number;
  22466. /**
  22467. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22468. */
  22469. static readonly PBRMATERIAL_ALPHATEST: number;
  22470. /**
  22471. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22472. */
  22473. static readonly PBRMATERIAL_ALPHABLEND: number;
  22474. /**
  22475. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22476. * They are also discarded below the alpha cutoff threshold to improve performances.
  22477. */
  22478. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22479. /**
  22480. * Defines the default value of how much AO map is occluding the analytical lights
  22481. * (point spot...).
  22482. */
  22483. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22484. /**
  22485. * Intensity of the direct lights e.g. the four lights available in your scene.
  22486. * This impacts both the direct diffuse and specular highlights.
  22487. */
  22488. directIntensity: number;
  22489. /**
  22490. * Intensity of the emissive part of the material.
  22491. * This helps controlling the emissive effect without modifying the emissive color.
  22492. */
  22493. emissiveIntensity: number;
  22494. /**
  22495. * Intensity of the environment e.g. how much the environment will light the object
  22496. * either through harmonics for rough material or through the reflection for shiny ones.
  22497. */
  22498. environmentIntensity: number;
  22499. /**
  22500. * This is a special control allowing the reduction of the specular highlights coming from the
  22501. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22502. */
  22503. specularIntensity: number;
  22504. /**
  22505. * Debug Control allowing disabling the bump map on this material.
  22506. */
  22507. disableBumpMap: boolean;
  22508. /**
  22509. * AKA Diffuse Texture in standard nomenclature.
  22510. */
  22511. albedoTexture: BaseTexture;
  22512. /**
  22513. * AKA Occlusion Texture in other nomenclature.
  22514. */
  22515. ambientTexture: BaseTexture;
  22516. /**
  22517. * AKA Occlusion Texture Intensity in other nomenclature.
  22518. */
  22519. ambientTextureStrength: number;
  22520. /**
  22521. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22522. * 1 means it completely occludes it
  22523. * 0 mean it has no impact
  22524. */
  22525. ambientTextureImpactOnAnalyticalLights: number;
  22526. /**
  22527. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22528. */
  22529. opacityTexture: BaseTexture;
  22530. /**
  22531. * Stores the reflection values in a texture.
  22532. */
  22533. reflectionTexture: Nullable<BaseTexture>;
  22534. /**
  22535. * Stores the emissive values in a texture.
  22536. */
  22537. emissiveTexture: BaseTexture;
  22538. /**
  22539. * AKA Specular texture in other nomenclature.
  22540. */
  22541. reflectivityTexture: BaseTexture;
  22542. /**
  22543. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22544. */
  22545. metallicTexture: BaseTexture;
  22546. /**
  22547. * Specifies the metallic scalar of the metallic/roughness workflow.
  22548. * Can also be used to scale the metalness values of the metallic texture.
  22549. */
  22550. metallic: Nullable<number>;
  22551. /**
  22552. * Specifies the roughness scalar of the metallic/roughness workflow.
  22553. * Can also be used to scale the roughness values of the metallic texture.
  22554. */
  22555. roughness: Nullable<number>;
  22556. /**
  22557. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22558. * By default the indexOfrefraction is used to compute F0;
  22559. *
  22560. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22561. *
  22562. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22563. * F90 = metallicReflectanceColor;
  22564. */
  22565. metallicF0Factor: number;
  22566. /**
  22567. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22568. * By default the F90 is always 1;
  22569. *
  22570. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22571. *
  22572. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22573. * F90 = metallicReflectanceColor;
  22574. */
  22575. metallicReflectanceColor: Color3;
  22576. /**
  22577. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22578. * This is multiply against the scalar values defined in the material.
  22579. */
  22580. metallicReflectanceTexture: Nullable<BaseTexture>;
  22581. /**
  22582. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22583. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22584. */
  22585. microSurfaceTexture: BaseTexture;
  22586. /**
  22587. * Stores surface normal data used to displace a mesh in a texture.
  22588. */
  22589. bumpTexture: BaseTexture;
  22590. /**
  22591. * Stores the pre-calculated light information of a mesh in a texture.
  22592. */
  22593. lightmapTexture: BaseTexture;
  22594. /**
  22595. * Stores the refracted light information in a texture.
  22596. */
  22597. get refractionTexture(): Nullable<BaseTexture>;
  22598. set refractionTexture(value: Nullable<BaseTexture>);
  22599. /**
  22600. * The color of a material in ambient lighting.
  22601. */
  22602. ambientColor: Color3;
  22603. /**
  22604. * AKA Diffuse Color in other nomenclature.
  22605. */
  22606. albedoColor: Color3;
  22607. /**
  22608. * AKA Specular Color in other nomenclature.
  22609. */
  22610. reflectivityColor: Color3;
  22611. /**
  22612. * The color reflected from the material.
  22613. */
  22614. reflectionColor: Color3;
  22615. /**
  22616. * The color emitted from the material.
  22617. */
  22618. emissiveColor: Color3;
  22619. /**
  22620. * AKA Glossiness in other nomenclature.
  22621. */
  22622. microSurface: number;
  22623. /**
  22624. * Index of refraction of the material base layer.
  22625. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22626. *
  22627. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22628. *
  22629. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22630. */
  22631. get indexOfRefraction(): number;
  22632. set indexOfRefraction(value: number);
  22633. /**
  22634. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22635. */
  22636. get invertRefractionY(): boolean;
  22637. set invertRefractionY(value: boolean);
  22638. /**
  22639. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22640. * Materials half opaque for instance using refraction could benefit from this control.
  22641. */
  22642. get linkRefractionWithTransparency(): boolean;
  22643. set linkRefractionWithTransparency(value: boolean);
  22644. /**
  22645. * If true, the light map contains occlusion information instead of lighting info.
  22646. */
  22647. useLightmapAsShadowmap: boolean;
  22648. /**
  22649. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22650. */
  22651. useAlphaFromAlbedoTexture: boolean;
  22652. /**
  22653. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22654. */
  22655. forceAlphaTest: boolean;
  22656. /**
  22657. * Defines the alpha limits in alpha test mode.
  22658. */
  22659. alphaCutOff: number;
  22660. /**
  22661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22662. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22663. */
  22664. useSpecularOverAlpha: boolean;
  22665. /**
  22666. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22667. */
  22668. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22669. /**
  22670. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22671. */
  22672. useRoughnessFromMetallicTextureAlpha: boolean;
  22673. /**
  22674. * Specifies if the metallic texture contains the roughness information in its green channel.
  22675. */
  22676. useRoughnessFromMetallicTextureGreen: boolean;
  22677. /**
  22678. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22679. */
  22680. useMetallnessFromMetallicTextureBlue: boolean;
  22681. /**
  22682. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22683. */
  22684. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22685. /**
  22686. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22687. */
  22688. useAmbientInGrayScale: boolean;
  22689. /**
  22690. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22691. * The material will try to infer what glossiness each pixel should be.
  22692. */
  22693. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22694. /**
  22695. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22696. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22698. */
  22699. get usePhysicalLightFalloff(): boolean;
  22700. /**
  22701. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22702. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22703. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22704. */
  22705. set usePhysicalLightFalloff(value: boolean);
  22706. /**
  22707. * In order to support the falloff compatibility with gltf, a special mode has been added
  22708. * to reproduce the gltf light falloff.
  22709. */
  22710. get useGLTFLightFalloff(): boolean;
  22711. /**
  22712. * In order to support the falloff compatibility with gltf, a special mode has been added
  22713. * to reproduce the gltf light falloff.
  22714. */
  22715. set useGLTFLightFalloff(value: boolean);
  22716. /**
  22717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22718. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22719. */
  22720. useRadianceOverAlpha: boolean;
  22721. /**
  22722. * Allows using an object space normal map (instead of tangent space).
  22723. */
  22724. useObjectSpaceNormalMap: boolean;
  22725. /**
  22726. * Allows using the bump map in parallax mode.
  22727. */
  22728. useParallax: boolean;
  22729. /**
  22730. * Allows using the bump map in parallax occlusion mode.
  22731. */
  22732. useParallaxOcclusion: boolean;
  22733. /**
  22734. * Controls the scale bias of the parallax mode.
  22735. */
  22736. parallaxScaleBias: number;
  22737. /**
  22738. * If sets to true, disables all the lights affecting the material.
  22739. */
  22740. disableLighting: boolean;
  22741. /**
  22742. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22743. */
  22744. forceIrradianceInFragment: boolean;
  22745. /**
  22746. * Number of Simultaneous lights allowed on the material.
  22747. */
  22748. maxSimultaneousLights: number;
  22749. /**
  22750. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22751. */
  22752. invertNormalMapX: boolean;
  22753. /**
  22754. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22755. */
  22756. invertNormalMapY: boolean;
  22757. /**
  22758. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22759. */
  22760. twoSidedLighting: boolean;
  22761. /**
  22762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22763. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22764. */
  22765. useAlphaFresnel: boolean;
  22766. /**
  22767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22768. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22769. */
  22770. useLinearAlphaFresnel: boolean;
  22771. /**
  22772. * Let user defines the brdf lookup texture used for IBL.
  22773. * A default 8bit version is embedded but you could point at :
  22774. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22775. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22776. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22777. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22778. */
  22779. environmentBRDFTexture: Nullable<BaseTexture>;
  22780. /**
  22781. * Force normal to face away from face.
  22782. */
  22783. forceNormalForward: boolean;
  22784. /**
  22785. * Enables specular anti aliasing in the PBR shader.
  22786. * It will both interacts on the Geometry for analytical and IBL lighting.
  22787. * It also prefilter the roughness map based on the bump values.
  22788. */
  22789. enableSpecularAntiAliasing: boolean;
  22790. /**
  22791. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22792. * makes the reflect vector face the model (under horizon).
  22793. */
  22794. useHorizonOcclusion: boolean;
  22795. /**
  22796. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22797. * too much the area relying on ambient texture to define their ambient occlusion.
  22798. */
  22799. useRadianceOcclusion: boolean;
  22800. /**
  22801. * If set to true, no lighting calculations will be applied.
  22802. */
  22803. unlit: boolean;
  22804. /**
  22805. * Gets the image processing configuration used either in this material.
  22806. */
  22807. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22808. /**
  22809. * Sets the Default image processing configuration used either in the this material.
  22810. *
  22811. * If sets to null, the scene one is in use.
  22812. */
  22813. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22814. /**
  22815. * Gets whether the color curves effect is enabled.
  22816. */
  22817. get cameraColorCurvesEnabled(): boolean;
  22818. /**
  22819. * Sets whether the color curves effect is enabled.
  22820. */
  22821. set cameraColorCurvesEnabled(value: boolean);
  22822. /**
  22823. * Gets whether the color grading effect is enabled.
  22824. */
  22825. get cameraColorGradingEnabled(): boolean;
  22826. /**
  22827. * Gets whether the color grading effect is enabled.
  22828. */
  22829. set cameraColorGradingEnabled(value: boolean);
  22830. /**
  22831. * Gets whether tonemapping is enabled or not.
  22832. */
  22833. get cameraToneMappingEnabled(): boolean;
  22834. /**
  22835. * Sets whether tonemapping is enabled or not
  22836. */
  22837. set cameraToneMappingEnabled(value: boolean);
  22838. /**
  22839. * The camera exposure used on this material.
  22840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22841. * This corresponds to a photographic exposure.
  22842. */
  22843. get cameraExposure(): number;
  22844. /**
  22845. * The camera exposure used on this material.
  22846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22847. * This corresponds to a photographic exposure.
  22848. */
  22849. set cameraExposure(value: number);
  22850. /**
  22851. * Gets The camera contrast used on this material.
  22852. */
  22853. get cameraContrast(): number;
  22854. /**
  22855. * Sets The camera contrast used on this material.
  22856. */
  22857. set cameraContrast(value: number);
  22858. /**
  22859. * Gets the Color Grading 2D Lookup Texture.
  22860. */
  22861. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22862. /**
  22863. * Sets the Color Grading 2D Lookup Texture.
  22864. */
  22865. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22866. /**
  22867. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22869. * 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;
  22870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22871. */
  22872. get cameraColorCurves(): Nullable<ColorCurves>;
  22873. /**
  22874. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22876. * 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;
  22877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22878. */
  22879. set cameraColorCurves(value: Nullable<ColorCurves>);
  22880. /**
  22881. * Instantiates a new PBRMaterial instance.
  22882. *
  22883. * @param name The material name
  22884. * @param scene The scene the material will be use in.
  22885. */
  22886. constructor(name: string, scene: Scene);
  22887. /**
  22888. * Returns the name of this material class.
  22889. */
  22890. getClassName(): string;
  22891. /**
  22892. * Makes a duplicate of the current material.
  22893. * @param name - name to use for the new material.
  22894. */
  22895. clone(name: string): PBRMaterial;
  22896. /**
  22897. * Serializes this PBR Material.
  22898. * @returns - An object with the serialized material.
  22899. */
  22900. serialize(): any;
  22901. /**
  22902. * Parses a PBR Material from a serialized object.
  22903. * @param source - Serialized object.
  22904. * @param scene - BJS scene instance.
  22905. * @param rootUrl - url for the scene object
  22906. * @returns - PBRMaterial
  22907. */
  22908. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22909. }
  22910. }
  22911. declare module BABYLON {
  22912. /** @hidden */
  22913. export var mrtFragmentDeclaration: {
  22914. name: string;
  22915. shader: string;
  22916. };
  22917. }
  22918. declare module BABYLON {
  22919. /** @hidden */
  22920. export var geometryPixelShader: {
  22921. name: string;
  22922. shader: string;
  22923. };
  22924. }
  22925. declare module BABYLON {
  22926. /** @hidden */
  22927. export var instancesDeclaration: {
  22928. name: string;
  22929. shader: string;
  22930. };
  22931. }
  22932. declare module BABYLON {
  22933. /** @hidden */
  22934. export var geometryVertexDeclaration: {
  22935. name: string;
  22936. shader: string;
  22937. };
  22938. }
  22939. declare module BABYLON {
  22940. /** @hidden */
  22941. export var geometryUboDeclaration: {
  22942. name: string;
  22943. shader: string;
  22944. };
  22945. }
  22946. declare module BABYLON {
  22947. /** @hidden */
  22948. export var geometryVertexShader: {
  22949. name: string;
  22950. shader: string;
  22951. };
  22952. }
  22953. declare module BABYLON {
  22954. /** @hidden */
  22955. interface ISavedTransformationMatrix {
  22956. world: Matrix;
  22957. viewProjection: Matrix;
  22958. }
  22959. /**
  22960. * This renderer is helpful to fill one of the render target with a geometry buffer.
  22961. */
  22962. export class GeometryBufferRenderer {
  22963. /**
  22964. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22965. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22966. */
  22967. static readonly DEPTH_TEXTURE_TYPE: number;
  22968. /**
  22969. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22970. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22971. */
  22972. static readonly NORMAL_TEXTURE_TYPE: number;
  22973. /**
  22974. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22975. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22976. */
  22977. static readonly POSITION_TEXTURE_TYPE: number;
  22978. /**
  22979. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22980. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22981. */
  22982. static readonly VELOCITY_TEXTURE_TYPE: number;
  22983. /**
  22984. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22985. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22986. */
  22987. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22988. /**
  22989. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22990. * in order to compute objects velocities when enableVelocity is set to "true"
  22991. * @hidden
  22992. */
  22993. _previousTransformationMatrices: {
  22994. [index: number]: ISavedTransformationMatrix;
  22995. };
  22996. /**
  22997. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22998. * in order to compute objects velocities when enableVelocity is set to "true"
  22999. * @hidden
  23000. */
  23001. _previousBonesTransformationMatrices: {
  23002. [index: number]: Float32Array;
  23003. };
  23004. /**
  23005. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23006. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23007. */
  23008. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23009. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23010. renderTransparentMeshes: boolean;
  23011. private _scene;
  23012. private _resizeObserver;
  23013. private _multiRenderTarget;
  23014. private _ratio;
  23015. private _enablePosition;
  23016. private _enableVelocity;
  23017. private _enableReflectivity;
  23018. private _positionIndex;
  23019. private _velocityIndex;
  23020. private _reflectivityIndex;
  23021. private _depthIndex;
  23022. private _normalIndex;
  23023. private _linkedWithPrePass;
  23024. private _prePassRenderer;
  23025. private _attachments;
  23026. private _useUbo;
  23027. protected _effect: Effect;
  23028. protected _cachedDefines: string;
  23029. /**
  23030. * @hidden
  23031. * Sets up internal structures to share outputs with PrePassRenderer
  23032. * This method should only be called by the PrePassRenderer itself
  23033. */
  23034. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23035. /**
  23036. * @hidden
  23037. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23038. * This method should only be called by the PrePassRenderer itself
  23039. */
  23040. _unlinkPrePassRenderer(): void;
  23041. /**
  23042. * @hidden
  23043. * Resets the geometry buffer layout
  23044. */
  23045. _resetLayout(): void;
  23046. /**
  23047. * @hidden
  23048. * Replaces a texture in the geometry buffer renderer
  23049. * Useful when linking textures of the prepass renderer
  23050. */
  23051. _forceTextureType(geometryBufferType: number, index: number): void;
  23052. /**
  23053. * @hidden
  23054. * Sets texture attachments
  23055. * Useful when linking textures of the prepass renderer
  23056. */
  23057. _setAttachments(attachments: number[]): void;
  23058. /**
  23059. * @hidden
  23060. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23061. * Useful when linking textures of the prepass renderer
  23062. */
  23063. _linkInternalTexture(internalTexture: InternalTexture): void;
  23064. /**
  23065. * Gets the render list (meshes to be rendered) used in the G buffer.
  23066. */
  23067. get renderList(): Nullable<AbstractMesh[]>;
  23068. /**
  23069. * Set the render list (meshes to be rendered) used in the G buffer.
  23070. */
  23071. set renderList(meshes: Nullable<AbstractMesh[]>);
  23072. /**
  23073. * Gets whether or not G buffer are supported by the running hardware.
  23074. * This requires draw buffer supports
  23075. */
  23076. get isSupported(): boolean;
  23077. /**
  23078. * Returns the index of the given texture type in the G-Buffer textures array
  23079. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23080. * @returns the index of the given texture type in the G-Buffer textures array
  23081. */
  23082. getTextureIndex(textureType: number): number;
  23083. /**
  23084. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23085. */
  23086. get enablePosition(): boolean;
  23087. /**
  23088. * Sets whether or not objects positions are enabled for the G buffer.
  23089. */
  23090. set enablePosition(enable: boolean);
  23091. /**
  23092. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23093. */
  23094. get enableVelocity(): boolean;
  23095. /**
  23096. * Sets whether or not objects velocities are enabled for the G buffer.
  23097. */
  23098. set enableVelocity(enable: boolean);
  23099. /**
  23100. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23101. */
  23102. get enableReflectivity(): boolean;
  23103. /**
  23104. * Sets whether or not objects roughness are enabled for the G buffer.
  23105. */
  23106. set enableReflectivity(enable: boolean);
  23107. /**
  23108. * Gets the scene associated with the buffer.
  23109. */
  23110. get scene(): Scene;
  23111. /**
  23112. * Gets the ratio used by the buffer during its creation.
  23113. * How big is the buffer related to the main canvas.
  23114. */
  23115. get ratio(): number;
  23116. /** @hidden */
  23117. static _SceneComponentInitialization: (scene: Scene) => void;
  23118. /**
  23119. * Creates a new G Buffer for the scene
  23120. * @param scene The scene the buffer belongs to
  23121. * @param ratio How big is the buffer related to the main canvas.
  23122. */
  23123. constructor(scene: Scene, ratio?: number);
  23124. /**
  23125. * Checks whether everything is ready to render a submesh to the G buffer.
  23126. * @param subMesh the submesh to check readiness for
  23127. * @param useInstances is the mesh drawn using instance or not
  23128. * @returns true if ready otherwise false
  23129. */
  23130. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23131. /**
  23132. * Gets the current underlying G Buffer.
  23133. * @returns the buffer
  23134. */
  23135. getGBuffer(): MultiRenderTarget;
  23136. /**
  23137. * Gets the number of samples used to render the buffer (anti aliasing).
  23138. */
  23139. get samples(): number;
  23140. /**
  23141. * Sets the number of samples used to render the buffer (anti aliasing).
  23142. */
  23143. set samples(value: number);
  23144. /**
  23145. * Disposes the renderer and frees up associated resources.
  23146. */
  23147. dispose(): void;
  23148. private _assignRenderTargetIndices;
  23149. protected _createRenderTargets(): void;
  23150. private _copyBonesTransformationMatrices;
  23151. }
  23152. }
  23153. declare module BABYLON {
  23154. /**
  23155. * Renders a pre pass of the scene
  23156. * This means every mesh in the scene will be rendered to a render target texture
  23157. * And then this texture will be composited to the rendering canvas with post processes
  23158. * It is necessary for effects like subsurface scattering or deferred shading
  23159. */
  23160. export class PrePassRenderer {
  23161. /** @hidden */
  23162. static _SceneComponentInitialization: (scene: Scene) => void;
  23163. /**
  23164. * To save performance, we can excluded skinned meshes from the prepass
  23165. */
  23166. excludedSkinnedMesh: AbstractMesh[];
  23167. /**
  23168. * Force material to be excluded from the prepass
  23169. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23170. * and you don't want a material to show in the effect.
  23171. */
  23172. excludedMaterials: Material[];
  23173. private _scene;
  23174. private _engine;
  23175. /**
  23176. * Number of textures in the multi render target texture where the scene is directly rendered
  23177. */
  23178. mrtCount: number;
  23179. private _mrtFormats;
  23180. private _mrtLayout;
  23181. private _textureIndices;
  23182. private _multiRenderAttachments;
  23183. private _defaultAttachments;
  23184. private _clearAttachments;
  23185. /**
  23186. * Returns the index of a texture in the multi render target texture array.
  23187. * @param type Texture type
  23188. * @return The index
  23189. */
  23190. getIndex(type: number): number;
  23191. /**
  23192. * How many samples are used for MSAA of the scene render target
  23193. */
  23194. get samples(): number;
  23195. set samples(n: number);
  23196. private static _textureFormats;
  23197. private _isDirty;
  23198. /**
  23199. * The render target where the scene is directly rendered
  23200. */
  23201. defaultRT: PrePassRenderTarget;
  23202. /**
  23203. * Configuration for prepass effects
  23204. */
  23205. private _effectConfigurations;
  23206. /**
  23207. * @return the prepass render target for the rendering pass.
  23208. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23209. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23210. */
  23211. getRenderTarget(): PrePassRenderTarget;
  23212. /**
  23213. * @hidden
  23214. * Managed by the scene component
  23215. * @param prePassRenderTarget
  23216. */
  23217. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23218. /**
  23219. * Returns true if the currently rendered prePassRenderTarget is the one
  23220. * associated with the scene.
  23221. */
  23222. get currentRTisSceneRT(): boolean;
  23223. private _geometryBuffer;
  23224. /**
  23225. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23226. */
  23227. doNotUseGeometryRendererFallback: boolean;
  23228. private _refreshGeometryBufferRendererLink;
  23229. private _currentTarget;
  23230. /**
  23231. * All the render targets generated by prepass
  23232. */
  23233. renderTargets: PrePassRenderTarget[];
  23234. private readonly _clearColor;
  23235. private _enabled;
  23236. private _needsCompositionForThisPass;
  23237. private _postProcessesSourceForThisPass;
  23238. /**
  23239. * Indicates if the prepass is enabled
  23240. */
  23241. get enabled(): boolean;
  23242. /**
  23243. * Set to true to disable gamma transform in PrePass.
  23244. * Can be useful in case you already proceed to gamma transform on a material level
  23245. * and your post processes don't need to be in linear color space.
  23246. */
  23247. disableGammaTransform: boolean;
  23248. /**
  23249. * Instanciates a prepass renderer
  23250. * @param scene The scene
  23251. */
  23252. constructor(scene: Scene);
  23253. /**
  23254. * Creates a new PrePassRenderTarget
  23255. * This should be the only way to instanciate a `PrePassRenderTarget`
  23256. * @param name Name of the `PrePassRenderTarget`
  23257. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23258. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23259. * @hidden
  23260. */
  23261. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23262. /**
  23263. * Indicates if rendering a prepass is supported
  23264. */
  23265. get isSupported(): boolean;
  23266. /**
  23267. * Sets the proper output textures to draw in the engine.
  23268. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23269. * @param subMesh Submesh on which the effect is applied
  23270. */
  23271. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23272. private _reinitializeAttachments;
  23273. private _resetLayout;
  23274. private _updateGeometryBufferLayout;
  23275. /**
  23276. * Restores attachments for single texture draw.
  23277. */
  23278. restoreAttachments(): void;
  23279. /**
  23280. * @hidden
  23281. */
  23282. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23283. private _prepareFrame;
  23284. private _renderPostProcesses;
  23285. /**
  23286. * @hidden
  23287. */
  23288. _afterDraw(faceIndex?: number, layer?: number): void;
  23289. /**
  23290. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23291. * @hidden
  23292. */
  23293. _clear(): void;
  23294. private _bindFrameBuffer;
  23295. private _setEnabled;
  23296. private _setRenderTargetEnabled;
  23297. /**
  23298. * Adds an effect configuration to the prepass render target.
  23299. * If an effect has already been added, it won't add it twice and will return the configuration
  23300. * already present.
  23301. * @param cfg the effect configuration
  23302. * @return the effect configuration now used by the prepass
  23303. */
  23304. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23305. private _enable;
  23306. private _disable;
  23307. private _getPostProcessesSource;
  23308. private _setupOutputForThisPass;
  23309. private _linkInternalTexture;
  23310. private _needsImageProcessing;
  23311. private _hasImageProcessing;
  23312. /**
  23313. * Internal, gets the first post proces.
  23314. * @returns the first post process to be run on this camera.
  23315. */
  23316. private _getFirstPostProcess;
  23317. /**
  23318. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23319. */
  23320. markAsDirty(): void;
  23321. /**
  23322. * Enables a texture on the MultiRenderTarget for prepass
  23323. */
  23324. private _enableTextures;
  23325. private _update;
  23326. private _markAllMaterialsAsPrePassDirty;
  23327. /**
  23328. * Disposes the prepass renderer.
  23329. */
  23330. dispose(): void;
  23331. }
  23332. }
  23333. declare module BABYLON {
  23334. /**
  23335. * Size options for a post process
  23336. */
  23337. export type PostProcessOptions = {
  23338. width: number;
  23339. height: number;
  23340. };
  23341. /**
  23342. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23343. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23344. */
  23345. export class PostProcess {
  23346. /**
  23347. * Gets or sets the unique id of the post process
  23348. */
  23349. uniqueId: number;
  23350. /** Name of the PostProcess. */
  23351. name: string;
  23352. /**
  23353. * Width of the texture to apply the post process on
  23354. */
  23355. width: number;
  23356. /**
  23357. * Height of the texture to apply the post process on
  23358. */
  23359. height: number;
  23360. /**
  23361. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23362. */
  23363. nodeMaterialSource: Nullable<NodeMaterial>;
  23364. /**
  23365. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23366. * @hidden
  23367. */
  23368. _outputTexture: Nullable<InternalTexture>;
  23369. /**
  23370. * Sampling mode used by the shader
  23371. * See https://doc.babylonjs.com/classes/3.1/texture
  23372. */
  23373. renderTargetSamplingMode: number;
  23374. /**
  23375. * Clear color to use when screen clearing
  23376. */
  23377. clearColor: Color4;
  23378. /**
  23379. * If the buffer needs to be cleared before applying the post process. (default: true)
  23380. * Should be set to false if shader will overwrite all previous pixels.
  23381. */
  23382. autoClear: boolean;
  23383. /**
  23384. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23385. */
  23386. alphaMode: number;
  23387. /**
  23388. * Sets the setAlphaBlendConstants of the babylon engine
  23389. */
  23390. alphaConstants: Color4;
  23391. /**
  23392. * Animations to be used for the post processing
  23393. */
  23394. animations: Animation[];
  23395. /**
  23396. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23397. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23398. */
  23399. enablePixelPerfectMode: boolean;
  23400. /**
  23401. * Force the postprocess to be applied without taking in account viewport
  23402. */
  23403. forceFullscreenViewport: boolean;
  23404. /**
  23405. * List of inspectable custom properties (used by the Inspector)
  23406. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23407. */
  23408. inspectableCustomProperties: IInspectable[];
  23409. /**
  23410. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23411. *
  23412. * | Value | Type | Description |
  23413. * | ----- | ----------------------------------- | ----------- |
  23414. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23415. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23416. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23417. *
  23418. */
  23419. scaleMode: number;
  23420. /**
  23421. * Force textures to be a power of two (default: false)
  23422. */
  23423. alwaysForcePOT: boolean;
  23424. private _samples;
  23425. /**
  23426. * Number of sample textures (default: 1)
  23427. */
  23428. get samples(): number;
  23429. set samples(n: number);
  23430. /**
  23431. * Modify the scale of the post process to be the same as the viewport (default: false)
  23432. */
  23433. adaptScaleToCurrentViewport: boolean;
  23434. private _camera;
  23435. protected _scene: Scene;
  23436. private _engine;
  23437. private _options;
  23438. private _reusable;
  23439. private _renderId;
  23440. private _textureType;
  23441. private _textureFormat;
  23442. /**
  23443. * Smart array of input and output textures for the post process.
  23444. * @hidden
  23445. */
  23446. _textures: SmartArray<InternalTexture>;
  23447. /**
  23448. * Smart array of input and output textures for the post process.
  23449. * @hidden
  23450. */
  23451. private _textureCache;
  23452. /**
  23453. * The index in _textures that corresponds to the output texture.
  23454. * @hidden
  23455. */
  23456. _currentRenderTextureInd: number;
  23457. private _effect;
  23458. private _samplers;
  23459. private _fragmentUrl;
  23460. private _vertexUrl;
  23461. private _parameters;
  23462. protected _postProcessDefines: Nullable<string>;
  23463. private _scaleRatio;
  23464. protected _indexParameters: any;
  23465. private _shareOutputWithPostProcess;
  23466. private _texelSize;
  23467. /** @hidden */
  23468. _forcedOutputTexture: Nullable<InternalTexture>;
  23469. /**
  23470. * Prepass configuration in case this post process needs a texture from prepass
  23471. * @hidden
  23472. */
  23473. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23474. /**
  23475. * Returns the fragment url or shader name used in the post process.
  23476. * @returns the fragment url or name in the shader store.
  23477. */
  23478. getEffectName(): string;
  23479. /**
  23480. * An event triggered when the postprocess is activated.
  23481. */
  23482. onActivateObservable: Observable<Camera>;
  23483. private _onActivateObserver;
  23484. /**
  23485. * A function that is added to the onActivateObservable
  23486. */
  23487. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23488. /**
  23489. * An event triggered when the postprocess changes its size.
  23490. */
  23491. onSizeChangedObservable: Observable<PostProcess>;
  23492. private _onSizeChangedObserver;
  23493. /**
  23494. * A function that is added to the onSizeChangedObservable
  23495. */
  23496. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23497. /**
  23498. * An event triggered when the postprocess applies its effect.
  23499. */
  23500. onApplyObservable: Observable<Effect>;
  23501. private _onApplyObserver;
  23502. /**
  23503. * A function that is added to the onApplyObservable
  23504. */
  23505. set onApply(callback: (effect: Effect) => void);
  23506. /**
  23507. * An event triggered before rendering the postprocess
  23508. */
  23509. onBeforeRenderObservable: Observable<Effect>;
  23510. private _onBeforeRenderObserver;
  23511. /**
  23512. * A function that is added to the onBeforeRenderObservable
  23513. */
  23514. set onBeforeRender(callback: (effect: Effect) => void);
  23515. /**
  23516. * An event triggered after rendering the postprocess
  23517. */
  23518. onAfterRenderObservable: Observable<Effect>;
  23519. private _onAfterRenderObserver;
  23520. /**
  23521. * A function that is added to the onAfterRenderObservable
  23522. */
  23523. set onAfterRender(callback: (efect: Effect) => void);
  23524. /**
  23525. * 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
  23526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23527. */
  23528. get inputTexture(): InternalTexture;
  23529. set inputTexture(value: InternalTexture);
  23530. /**
  23531. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23532. * the only way to unset it is to use this function to restore its internal state
  23533. */
  23534. restoreDefaultInputTexture(): void;
  23535. /**
  23536. * Gets the camera which post process is applied to.
  23537. * @returns The camera the post process is applied to.
  23538. */
  23539. getCamera(): Camera;
  23540. /**
  23541. * Gets the texel size of the postprocess.
  23542. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23543. */
  23544. get texelSize(): Vector2;
  23545. /**
  23546. * Creates a new instance PostProcess
  23547. * @param name The name of the PostProcess.
  23548. * @param fragmentUrl The url of the fragment shader to be used.
  23549. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23550. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23551. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23552. * @param camera The camera to apply the render pass to.
  23553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23554. * @param engine The engine which the post process will be applied. (default: current engine)
  23555. * @param reusable If the post process can be reused on the same frame. (default: false)
  23556. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23557. * @param textureType Type of textures used when performing the post process. (default: 0)
  23558. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23559. * @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
  23560. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23561. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23562. */
  23563. 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);
  23564. /**
  23565. * Gets a string identifying the name of the class
  23566. * @returns "PostProcess" string
  23567. */
  23568. getClassName(): string;
  23569. /**
  23570. * Gets the engine which this post process belongs to.
  23571. * @returns The engine the post process was enabled with.
  23572. */
  23573. getEngine(): Engine;
  23574. /**
  23575. * The effect that is created when initializing the post process.
  23576. * @returns The created effect corresponding the the postprocess.
  23577. */
  23578. getEffect(): Effect;
  23579. /**
  23580. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23581. * @param postProcess The post process to share the output with.
  23582. * @returns This post process.
  23583. */
  23584. shareOutputWith(postProcess: PostProcess): PostProcess;
  23585. /**
  23586. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23587. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23588. */
  23589. useOwnOutput(): void;
  23590. /**
  23591. * Updates the effect with the current post process compile time values and recompiles the shader.
  23592. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23593. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23594. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23595. * @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
  23596. * @param onCompiled Called when the shader has been compiled.
  23597. * @param onError Called if there is an error when compiling a shader.
  23598. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23599. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23600. */
  23601. 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;
  23602. /**
  23603. * The post process is reusable if it can be used multiple times within one frame.
  23604. * @returns If the post process is reusable
  23605. */
  23606. isReusable(): boolean;
  23607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23608. markTextureDirty(): void;
  23609. private _createRenderTargetTexture;
  23610. private _flushTextureCache;
  23611. private _resize;
  23612. /**
  23613. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23614. * 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.
  23615. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23616. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23617. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23618. * @returns The target texture that was bound to be written to.
  23619. */
  23620. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23621. /**
  23622. * If the post process is supported.
  23623. */
  23624. get isSupported(): boolean;
  23625. /**
  23626. * The aspect ratio of the output texture.
  23627. */
  23628. get aspectRatio(): number;
  23629. /**
  23630. * Get a value indicating if the post-process is ready to be used
  23631. * @returns true if the post-process is ready (shader is compiled)
  23632. */
  23633. isReady(): boolean;
  23634. /**
  23635. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23636. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23637. */
  23638. apply(): Nullable<Effect>;
  23639. private _disposeTextures;
  23640. private _disposeTextureCache;
  23641. /**
  23642. * Sets the required values to the prepass renderer.
  23643. * @param prePassRenderer defines the prepass renderer to setup.
  23644. * @returns true if the pre pass is needed.
  23645. */
  23646. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23647. /**
  23648. * Disposes the post process.
  23649. * @param camera The camera to dispose the post process on.
  23650. */
  23651. dispose(camera?: Camera): void;
  23652. /**
  23653. * Serializes the particle system to a JSON object
  23654. * @returns the JSON object
  23655. */
  23656. serialize(): any;
  23657. /**
  23658. * Clones this post process
  23659. * @returns a new post process similar to this one
  23660. */
  23661. clone(): Nullable<PostProcess>;
  23662. /**
  23663. * Creates a material from parsed material data
  23664. * @param parsedPostProcess defines parsed post process data
  23665. * @param scene defines the hosting scene
  23666. * @param rootUrl defines the root URL to use to load textures
  23667. * @returns a new post process
  23668. */
  23669. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23670. /** @hidden */
  23671. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23672. }
  23673. }
  23674. declare module BABYLON {
  23675. /** @hidden */
  23676. export var kernelBlurVaryingDeclaration: {
  23677. name: string;
  23678. shader: string;
  23679. };
  23680. }
  23681. declare module BABYLON {
  23682. /** @hidden */
  23683. export var packingFunctions: {
  23684. name: string;
  23685. shader: string;
  23686. };
  23687. }
  23688. declare module BABYLON {
  23689. /** @hidden */
  23690. export var kernelBlurFragment: {
  23691. name: string;
  23692. shader: string;
  23693. };
  23694. }
  23695. declare module BABYLON {
  23696. /** @hidden */
  23697. export var kernelBlurFragment2: {
  23698. name: string;
  23699. shader: string;
  23700. };
  23701. }
  23702. declare module BABYLON {
  23703. /** @hidden */
  23704. export var kernelBlurPixelShader: {
  23705. name: string;
  23706. shader: string;
  23707. };
  23708. }
  23709. declare module BABYLON {
  23710. /** @hidden */
  23711. export var kernelBlurVertex: {
  23712. name: string;
  23713. shader: string;
  23714. };
  23715. }
  23716. declare module BABYLON {
  23717. /** @hidden */
  23718. export var kernelBlurVertexShader: {
  23719. name: string;
  23720. shader: string;
  23721. };
  23722. }
  23723. declare module BABYLON {
  23724. /**
  23725. * The Blur Post Process which blurs an image based on a kernel and direction.
  23726. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23727. */
  23728. export class BlurPostProcess extends PostProcess {
  23729. private blockCompilation;
  23730. protected _kernel: number;
  23731. protected _idealKernel: number;
  23732. protected _packedFloat: boolean;
  23733. private _staticDefines;
  23734. /** The direction in which to blur the image. */
  23735. direction: Vector2;
  23736. /**
  23737. * Sets the length in pixels of the blur sample region
  23738. */
  23739. set kernel(v: number);
  23740. /**
  23741. * Gets the length in pixels of the blur sample region
  23742. */
  23743. get kernel(): number;
  23744. /**
  23745. * Sets whether or not the blur needs to unpack/repack floats
  23746. */
  23747. set packedFloat(v: boolean);
  23748. /**
  23749. * Gets whether or not the blur is unpacking/repacking floats
  23750. */
  23751. get packedFloat(): boolean;
  23752. /**
  23753. * Gets a string identifying the name of the class
  23754. * @returns "BlurPostProcess" string
  23755. */
  23756. getClassName(): string;
  23757. /**
  23758. * Creates a new instance BlurPostProcess
  23759. * @param name The name of the effect.
  23760. * @param direction The direction in which to blur the image.
  23761. * @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.
  23762. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23763. * @param camera The camera to apply the render pass to.
  23764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23765. * @param engine The engine which the post process will be applied. (default: current engine)
  23766. * @param reusable If the post process can be reused on the same frame. (default: false)
  23767. * @param textureType Type of textures used when performing the post process. (default: 0)
  23768. * @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)
  23769. */
  23770. 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);
  23771. /**
  23772. * Updates the effect with the current post process compile time values and recompiles the shader.
  23773. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23774. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23775. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23776. * @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
  23777. * @param onCompiled Called when the shader has been compiled.
  23778. * @param onError Called if there is an error when compiling a shader.
  23779. */
  23780. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23781. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23782. /**
  23783. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23784. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23785. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23786. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23787. * The gaps between physical kernels are compensated for in the weighting of the samples
  23788. * @param idealKernel Ideal blur kernel.
  23789. * @return Nearest best kernel.
  23790. */
  23791. protected _nearestBestKernel(idealKernel: number): number;
  23792. /**
  23793. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23794. * @param x The point on the Gaussian distribution to sample.
  23795. * @return the value of the Gaussian function at x.
  23796. */
  23797. protected _gaussianWeight(x: number): number;
  23798. /**
  23799. * Generates a string that can be used as a floating point number in GLSL.
  23800. * @param x Value to print.
  23801. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23802. * @return GLSL float string.
  23803. */
  23804. protected _glslFloat(x: number, decimalFigures?: number): string;
  23805. /** @hidden */
  23806. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /**
  23811. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23812. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23813. * You can then easily use it as a reflectionTexture on a flat surface.
  23814. * In case the surface is not a plane, please consider relying on reflection probes.
  23815. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23816. */
  23817. export class MirrorTexture extends RenderTargetTexture {
  23818. private scene;
  23819. /**
  23820. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23821. * 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.
  23822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23823. */
  23824. mirrorPlane: Plane;
  23825. /**
  23826. * Define the blur ratio used to blur the reflection if needed.
  23827. */
  23828. set blurRatio(value: number);
  23829. get blurRatio(): number;
  23830. /**
  23831. * Define the adaptive blur kernel used to blur the reflection if needed.
  23832. * This will autocompute the closest best match for the `blurKernel`
  23833. */
  23834. set adaptiveBlurKernel(value: number);
  23835. /**
  23836. * Define the blur kernel used to blur the reflection if needed.
  23837. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23838. */
  23839. set blurKernel(value: number);
  23840. /**
  23841. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23843. */
  23844. set blurKernelX(value: number);
  23845. get blurKernelX(): number;
  23846. /**
  23847. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23848. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23849. */
  23850. set blurKernelY(value: number);
  23851. get blurKernelY(): number;
  23852. private _autoComputeBlurKernel;
  23853. protected _onRatioRescale(): void;
  23854. private _updateGammaSpace;
  23855. private _imageProcessingConfigChangeObserver;
  23856. private _transformMatrix;
  23857. private _mirrorMatrix;
  23858. private _blurX;
  23859. private _blurY;
  23860. private _adaptiveBlurKernel;
  23861. private _blurKernelX;
  23862. private _blurKernelY;
  23863. private _blurRatio;
  23864. /**
  23865. * Instantiates a Mirror Texture.
  23866. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23867. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23868. * You can then easily use it as a reflectionTexture on a flat surface.
  23869. * In case the surface is not a plane, please consider relying on reflection probes.
  23870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23871. * @param name
  23872. * @param size
  23873. * @param scene
  23874. * @param generateMipMaps
  23875. * @param type
  23876. * @param samplingMode
  23877. * @param generateDepthBuffer
  23878. */
  23879. constructor(name: string, size: number | {
  23880. width: number;
  23881. height: number;
  23882. } | {
  23883. ratio: number;
  23884. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23885. private _preparePostProcesses;
  23886. /**
  23887. * Clone the mirror texture.
  23888. * @returns the cloned texture
  23889. */
  23890. clone(): MirrorTexture;
  23891. /**
  23892. * Serialize the texture to a JSON representation you could use in Parse later on
  23893. * @returns the serialized JSON representation
  23894. */
  23895. serialize(): any;
  23896. /**
  23897. * Dispose the texture and release its associated resources.
  23898. */
  23899. dispose(): void;
  23900. }
  23901. }
  23902. declare module BABYLON {
  23903. /**
  23904. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23905. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23906. */
  23907. export class Texture extends BaseTexture {
  23908. /**
  23909. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23910. */
  23911. static SerializeBuffers: boolean;
  23912. /**
  23913. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23914. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23915. */
  23916. static ForceSerializeBuffers: boolean;
  23917. /** @hidden */
  23918. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23919. /** @hidden */
  23920. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23921. /** @hidden */
  23922. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23923. /** nearest is mag = nearest and min = nearest and mip = linear */
  23924. static readonly NEAREST_SAMPLINGMODE: number;
  23925. /** nearest is mag = nearest and min = nearest and mip = linear */
  23926. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23928. static readonly BILINEAR_SAMPLINGMODE: number;
  23929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23930. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23931. /** Trilinear is mag = linear and min = linear and mip = linear */
  23932. static readonly TRILINEAR_SAMPLINGMODE: number;
  23933. /** Trilinear is mag = linear and min = linear and mip = linear */
  23934. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23935. /** mag = nearest and min = nearest and mip = nearest */
  23936. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23937. /** mag = nearest and min = linear and mip = nearest */
  23938. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23939. /** mag = nearest and min = linear and mip = linear */
  23940. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23941. /** mag = nearest and min = linear and mip = none */
  23942. static readonly NEAREST_LINEAR: number;
  23943. /** mag = nearest and min = nearest and mip = none */
  23944. static readonly NEAREST_NEAREST: number;
  23945. /** mag = linear and min = nearest and mip = nearest */
  23946. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23947. /** mag = linear and min = nearest and mip = linear */
  23948. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23949. /** mag = linear and min = linear and mip = none */
  23950. static readonly LINEAR_LINEAR: number;
  23951. /** mag = linear and min = nearest and mip = none */
  23952. static readonly LINEAR_NEAREST: number;
  23953. /** Explicit coordinates mode */
  23954. static readonly EXPLICIT_MODE: number;
  23955. /** Spherical coordinates mode */
  23956. static readonly SPHERICAL_MODE: number;
  23957. /** Planar coordinates mode */
  23958. static readonly PLANAR_MODE: number;
  23959. /** Cubic coordinates mode */
  23960. static readonly CUBIC_MODE: number;
  23961. /** Projection coordinates mode */
  23962. static readonly PROJECTION_MODE: number;
  23963. /** Inverse Cubic coordinates mode */
  23964. static readonly SKYBOX_MODE: number;
  23965. /** Inverse Cubic coordinates mode */
  23966. static readonly INVCUBIC_MODE: number;
  23967. /** Equirectangular coordinates mode */
  23968. static readonly EQUIRECTANGULAR_MODE: number;
  23969. /** Equirectangular Fixed coordinates mode */
  23970. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23971. /** Equirectangular Fixed Mirrored coordinates mode */
  23972. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23973. /** Texture is not repeating outside of 0..1 UVs */
  23974. static readonly CLAMP_ADDRESSMODE: number;
  23975. /** Texture is repeating outside of 0..1 UVs */
  23976. static readonly WRAP_ADDRESSMODE: number;
  23977. /** Texture is repeating and mirrored */
  23978. static readonly MIRROR_ADDRESSMODE: number;
  23979. /**
  23980. * 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
  23981. */
  23982. static UseSerializedUrlIfAny: boolean;
  23983. /**
  23984. * Define the url of the texture.
  23985. */
  23986. url: Nullable<string>;
  23987. /**
  23988. * Define an offset on the texture to offset the u coordinates of the UVs
  23989. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23990. */
  23991. uOffset: number;
  23992. /**
  23993. * Define an offset on the texture to offset the v coordinates of the UVs
  23994. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23995. */
  23996. vOffset: number;
  23997. /**
  23998. * Define an offset on the texture to scale the u coordinates of the UVs
  23999. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24000. */
  24001. uScale: number;
  24002. /**
  24003. * Define an offset on the texture to scale the v coordinates of the UVs
  24004. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24005. */
  24006. vScale: number;
  24007. /**
  24008. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24009. * @see https://doc.babylonjs.com/how_to/more_materials
  24010. */
  24011. uAng: number;
  24012. /**
  24013. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24014. * @see https://doc.babylonjs.com/how_to/more_materials
  24015. */
  24016. vAng: number;
  24017. /**
  24018. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24019. * @see https://doc.babylonjs.com/how_to/more_materials
  24020. */
  24021. wAng: number;
  24022. /**
  24023. * Defines the center of rotation (U)
  24024. */
  24025. uRotationCenter: number;
  24026. /**
  24027. * Defines the center of rotation (V)
  24028. */
  24029. vRotationCenter: number;
  24030. /**
  24031. * Defines the center of rotation (W)
  24032. */
  24033. wRotationCenter: number;
  24034. /**
  24035. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24036. */
  24037. homogeneousRotationInUVTransform: boolean;
  24038. /**
  24039. * Are mip maps generated for this texture or not.
  24040. */
  24041. get noMipmap(): boolean;
  24042. /**
  24043. * List of inspectable custom properties (used by the Inspector)
  24044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24045. */
  24046. inspectableCustomProperties: Nullable<IInspectable[]>;
  24047. private _noMipmap;
  24048. /** @hidden */
  24049. _invertY: boolean;
  24050. private _rowGenerationMatrix;
  24051. private _cachedTextureMatrix;
  24052. private _projectionModeMatrix;
  24053. private _t0;
  24054. private _t1;
  24055. private _t2;
  24056. private _cachedUOffset;
  24057. private _cachedVOffset;
  24058. private _cachedUScale;
  24059. private _cachedVScale;
  24060. private _cachedUAng;
  24061. private _cachedVAng;
  24062. private _cachedWAng;
  24063. private _cachedProjectionMatrixId;
  24064. private _cachedURotationCenter;
  24065. private _cachedVRotationCenter;
  24066. private _cachedWRotationCenter;
  24067. private _cachedHomogeneousRotationInUVTransform;
  24068. private _cachedCoordinatesMode;
  24069. /** @hidden */
  24070. protected _initialSamplingMode: number;
  24071. /** @hidden */
  24072. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24073. private _deleteBuffer;
  24074. protected _format: Nullable<number>;
  24075. private _delayedOnLoad;
  24076. private _delayedOnError;
  24077. private _mimeType?;
  24078. private _loaderOptions?;
  24079. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24080. get mimeType(): string | undefined;
  24081. /**
  24082. * Observable triggered once the texture has been loaded.
  24083. */
  24084. onLoadObservable: Observable<Texture>;
  24085. protected _isBlocking: boolean;
  24086. /**
  24087. * Is the texture preventing material to render while loading.
  24088. * If false, a default texture will be used instead of the loading one during the preparation step.
  24089. */
  24090. set isBlocking(value: boolean);
  24091. get isBlocking(): boolean;
  24092. /**
  24093. * Get the current sampling mode associated with the texture.
  24094. */
  24095. get samplingMode(): number;
  24096. /**
  24097. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24098. */
  24099. get invertY(): boolean;
  24100. /**
  24101. * Instantiates a new texture.
  24102. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24103. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24104. * @param url defines the url of the picture to load as a texture
  24105. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24106. * @param noMipmap defines if the texture will require mip maps or not
  24107. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24108. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24109. * @param onLoad defines a callback triggered when the texture has been loaded
  24110. * @param onError defines a callback triggered when an error occurred during the loading session
  24111. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24112. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24113. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24114. * @param mimeType defines an optional mime type information
  24115. * @param loaderOptions options to be passed to the loader
  24116. */
  24117. 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);
  24118. /**
  24119. * Update the url (and optional buffer) of this texture if url was null during construction.
  24120. * @param url the url of the texture
  24121. * @param buffer the buffer of the texture (defaults to null)
  24122. * @param onLoad callback called when the texture is loaded (defaults to null)
  24123. */
  24124. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24125. /**
  24126. * Finish the loading sequence of a texture flagged as delayed load.
  24127. * @hidden
  24128. */
  24129. delayLoad(): void;
  24130. private _prepareRowForTextureGeneration;
  24131. /**
  24132. * Checks if the texture has the same transform matrix than another texture
  24133. * @param texture texture to check against
  24134. * @returns true if the transforms are the same, else false
  24135. */
  24136. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24137. /**
  24138. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24139. * @returns the transform matrix of the texture.
  24140. */
  24141. getTextureMatrix(uBase?: number): Matrix;
  24142. /**
  24143. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24144. * @returns The reflection texture transform
  24145. */
  24146. getReflectionTextureMatrix(): Matrix;
  24147. /**
  24148. * Clones the texture.
  24149. * @returns the cloned texture
  24150. */
  24151. clone(): Texture;
  24152. /**
  24153. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24154. * @returns The JSON representation of the texture
  24155. */
  24156. serialize(): any;
  24157. /**
  24158. * Get the current class name of the texture useful for serialization or dynamic coding.
  24159. * @returns "Texture"
  24160. */
  24161. getClassName(): string;
  24162. /**
  24163. * Dispose the texture and release its associated resources.
  24164. */
  24165. dispose(): void;
  24166. /**
  24167. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24168. * @param parsedTexture Define the JSON representation of the texture
  24169. * @param scene Define the scene the parsed texture should be instantiated in
  24170. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24171. * @returns The parsed texture if successful
  24172. */
  24173. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24174. /**
  24175. * Creates a texture from its base 64 representation.
  24176. * @param data Define the base64 payload without the data: prefix
  24177. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24178. * @param scene Define the scene the texture should belong to
  24179. * @param noMipmap Forces the texture to not create mip map information if true
  24180. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24181. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24182. * @param onLoad define a callback triggered when the texture has been loaded
  24183. * @param onError define a callback triggered when an error occurred during the loading session
  24184. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24185. * @returns the created texture
  24186. */
  24187. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24188. /**
  24189. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24190. * @param data Define the base64 payload without the data: prefix
  24191. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24192. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24193. * @param scene Define the scene the texture should belong to
  24194. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24195. * @param noMipmap Forces the texture to not create mip map information if true
  24196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24197. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24198. * @param onLoad define a callback triggered when the texture has been loaded
  24199. * @param onError define a callback triggered when an error occurred during the loading session
  24200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24201. * @returns the created texture
  24202. */
  24203. 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;
  24204. }
  24205. }
  24206. declare module BABYLON {
  24207. /**
  24208. * ThinSprite Class used to represent a thin sprite
  24209. * This is the base class for sprites but can also directly be used with ThinEngine
  24210. * @see https://doc.babylonjs.com/babylon101/sprites
  24211. */
  24212. export class ThinSprite {
  24213. /** Gets or sets the cell index in the sprite sheet */
  24214. cellIndex: number;
  24215. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24216. cellRef: string;
  24217. /** Gets or sets the current world position */
  24218. position: IVector3Like;
  24219. /** Gets or sets the main color */
  24220. color: IColor4Like;
  24221. /** Gets or sets the width */
  24222. width: number;
  24223. /** Gets or sets the height */
  24224. height: number;
  24225. /** Gets or sets rotation angle */
  24226. angle: number;
  24227. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24228. invertU: boolean;
  24229. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24230. invertV: boolean;
  24231. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24232. isVisible: boolean;
  24233. /**
  24234. * Returns a boolean indicating if the animation is started
  24235. */
  24236. get animationStarted(): boolean;
  24237. /** Gets the initial key for the animation (setting it will restart the animation) */
  24238. get fromIndex(): number;
  24239. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24240. get toIndex(): number;
  24241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24242. get loopAnimation(): boolean;
  24243. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24244. get delay(): number;
  24245. /** @hidden */
  24246. _xOffset: number;
  24247. /** @hidden */
  24248. _yOffset: number;
  24249. /** @hidden */
  24250. _xSize: number;
  24251. /** @hidden */
  24252. _ySize: number;
  24253. private _animationStarted;
  24254. protected _loopAnimation: boolean;
  24255. protected _fromIndex: number;
  24256. protected _toIndex: number;
  24257. protected _delay: number;
  24258. private _direction;
  24259. private _time;
  24260. private _onBaseAnimationEnd;
  24261. /**
  24262. * Creates a new Thin Sprite
  24263. */
  24264. constructor();
  24265. /**
  24266. * Starts an animation
  24267. * @param from defines the initial key
  24268. * @param to defines the end key
  24269. * @param loop defines if the animation must loop
  24270. * @param delay defines the start delay (in ms)
  24271. * @param onAnimationEnd defines a callback for when the animation ends
  24272. */
  24273. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24274. /** Stops current animation (if any) */
  24275. stopAnimation(): void;
  24276. /** @hidden */
  24277. _animate(deltaTime: number): void;
  24278. }
  24279. }
  24280. declare module BABYLON {
  24281. /** @hidden */
  24282. export var imageProcessingCompatibility: {
  24283. name: string;
  24284. shader: string;
  24285. };
  24286. }
  24287. declare module BABYLON {
  24288. /** @hidden */
  24289. export var spritesPixelShader: {
  24290. name: string;
  24291. shader: string;
  24292. };
  24293. }
  24294. declare module BABYLON {
  24295. /** @hidden */
  24296. export var spritesVertexShader: {
  24297. name: string;
  24298. shader: string;
  24299. };
  24300. }
  24301. declare module BABYLON {
  24302. /**
  24303. * Class used to render sprites.
  24304. *
  24305. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24306. */
  24307. export class SpriteRenderer {
  24308. /**
  24309. * Defines the texture of the spritesheet
  24310. */
  24311. texture: Nullable<ThinTexture>;
  24312. /**
  24313. * Defines the default width of a cell in the spritesheet
  24314. */
  24315. cellWidth: number;
  24316. /**
  24317. * Defines the default height of a cell in the spritesheet
  24318. */
  24319. cellHeight: number;
  24320. /**
  24321. * Blend mode use to render the particle, it can be any of
  24322. * the static Constants.ALPHA_x properties provided in this class.
  24323. * Default value is Constants.ALPHA_COMBINE
  24324. */
  24325. blendMode: number;
  24326. /**
  24327. * Gets or sets a boolean indicating if alpha mode is automatically
  24328. * reset.
  24329. */
  24330. autoResetAlpha: boolean;
  24331. /**
  24332. * Disables writing to the depth buffer when rendering the sprites.
  24333. * It can be handy to disable depth writing when using textures without alpha channel
  24334. * and setting some specific blend modes.
  24335. */
  24336. disableDepthWrite: boolean;
  24337. /**
  24338. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24339. */
  24340. fogEnabled: boolean;
  24341. /**
  24342. * Gets the capacity of the manager
  24343. */
  24344. get capacity(): number;
  24345. private readonly _engine;
  24346. private readonly _useVAO;
  24347. private readonly _useInstancing;
  24348. private readonly _scene;
  24349. private readonly _capacity;
  24350. private readonly _epsilon;
  24351. private _vertexBufferSize;
  24352. private _vertexData;
  24353. private _buffer;
  24354. private _vertexBuffers;
  24355. private _spriteBuffer;
  24356. private _indexBuffer;
  24357. private _effectBase;
  24358. private _effectFog;
  24359. private _vertexArrayObject;
  24360. /**
  24361. * Creates a new sprite Renderer
  24362. * @param engine defines the engine the renderer works with
  24363. * @param capacity defines the maximum allowed number of sprites
  24364. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24365. * @param scene defines the hosting scene
  24366. */
  24367. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24368. /**
  24369. * Render all child sprites
  24370. * @param sprites defines the list of sprites to render
  24371. * @param deltaTime defines the time since last frame
  24372. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24373. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24374. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24375. */
  24376. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24377. private _appendSpriteVertex;
  24378. /**
  24379. * Release associated resources
  24380. */
  24381. dispose(): void;
  24382. }
  24383. }
  24384. declare module BABYLON {
  24385. /**
  24386. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24387. */
  24388. export interface ISpriteManager extends IDisposable {
  24389. /**
  24390. * Gets manager's name
  24391. */
  24392. name: string;
  24393. /**
  24394. * Restricts the camera to viewing objects with the same layerMask.
  24395. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24396. */
  24397. layerMask: number;
  24398. /**
  24399. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24400. */
  24401. isPickable: boolean;
  24402. /**
  24403. * Gets the hosting scene
  24404. */
  24405. scene: Scene;
  24406. /**
  24407. * Specifies the rendering group id for this mesh (0 by default)
  24408. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24409. */
  24410. renderingGroupId: number;
  24411. /**
  24412. * Defines the list of sprites managed by the manager.
  24413. */
  24414. sprites: Array<Sprite>;
  24415. /**
  24416. * Gets or sets the spritesheet texture
  24417. */
  24418. texture: Texture;
  24419. /** Defines the default width of a cell in the spritesheet */
  24420. cellWidth: number;
  24421. /** Defines the default height of a cell in the spritesheet */
  24422. cellHeight: number;
  24423. /**
  24424. * Tests the intersection of a sprite with a specific ray.
  24425. * @param ray The ray we are sending to test the collision
  24426. * @param camera The camera space we are sending rays in
  24427. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24428. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24429. * @returns picking info or null.
  24430. */
  24431. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24432. /**
  24433. * Intersects the sprites with a ray
  24434. * @param ray defines the ray to intersect with
  24435. * @param camera defines the current active camera
  24436. * @param predicate defines a predicate used to select candidate sprites
  24437. * @returns null if no hit or a PickingInfo array
  24438. */
  24439. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24440. /**
  24441. * Renders the list of sprites on screen.
  24442. */
  24443. render(): void;
  24444. }
  24445. /**
  24446. * Class used to manage multiple sprites on the same spritesheet
  24447. * @see https://doc.babylonjs.com/babylon101/sprites
  24448. */
  24449. export class SpriteManager implements ISpriteManager {
  24450. /** defines the manager's name */
  24451. name: string;
  24452. /** Define the Url to load snippets */
  24453. static SnippetUrl: string;
  24454. /** Snippet ID if the manager was created from the snippet server */
  24455. snippetId: string;
  24456. /** Gets the list of sprites */
  24457. sprites: Sprite[];
  24458. /** Gets or sets the rendering group id (0 by default) */
  24459. renderingGroupId: number;
  24460. /** Gets or sets camera layer mask */
  24461. layerMask: number;
  24462. /** Gets or sets a boolean indicating if the sprites are pickable */
  24463. isPickable: boolean;
  24464. /**
  24465. * An event triggered when the manager is disposed.
  24466. */
  24467. onDisposeObservable: Observable<SpriteManager>;
  24468. /**
  24469. * Callback called when the manager is disposed
  24470. */
  24471. set onDispose(callback: () => void);
  24472. /**
  24473. * Gets or sets the unique id of the sprite
  24474. */
  24475. uniqueId: number;
  24476. /**
  24477. * Gets the array of sprites
  24478. */
  24479. get children(): Sprite[];
  24480. /**
  24481. * Gets the hosting scene
  24482. */
  24483. get scene(): Scene;
  24484. /**
  24485. * Gets the capacity of the manager
  24486. */
  24487. get capacity(): number;
  24488. /**
  24489. * Gets or sets the spritesheet texture
  24490. */
  24491. get texture(): Texture;
  24492. set texture(value: Texture);
  24493. /** Defines the default width of a cell in the spritesheet */
  24494. get cellWidth(): number;
  24495. set cellWidth(value: number);
  24496. /** Defines the default height of a cell in the spritesheet */
  24497. get cellHeight(): number;
  24498. set cellHeight(value: number);
  24499. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24500. get fogEnabled(): boolean;
  24501. set fogEnabled(value: boolean);
  24502. /**
  24503. * Blend mode use to render the particle, it can be any of
  24504. * the static Constants.ALPHA_x properties provided in this class.
  24505. * Default value is Constants.ALPHA_COMBINE
  24506. */
  24507. get blendMode(): number;
  24508. set blendMode(blendMode: number);
  24509. /** Disables writing to the depth buffer when rendering the sprites.
  24510. * It can be handy to disable depth writing when using textures without alpha channel
  24511. * and setting some specific blend modes.
  24512. */
  24513. disableDepthWrite: boolean;
  24514. private _spriteRenderer;
  24515. /** Associative array from JSON sprite data file */
  24516. private _cellData;
  24517. /** Array of sprite names from JSON sprite data file */
  24518. private _spriteMap;
  24519. /** True when packed cell data from JSON file is ready*/
  24520. private _packedAndReady;
  24521. private _textureContent;
  24522. private _onDisposeObserver;
  24523. private _fromPacked;
  24524. private _scene;
  24525. /**
  24526. * Creates a new sprite manager
  24527. * @param name defines the manager's name
  24528. * @param imgUrl defines the sprite sheet url
  24529. * @param capacity defines the maximum allowed number of sprites
  24530. * @param cellSize defines the size of a sprite cell
  24531. * @param scene defines the hosting scene
  24532. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24533. * @param samplingMode defines the sampling mode to use with spritesheet
  24534. * @param fromPacked set to false; do not alter
  24535. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24536. */
  24537. constructor(
  24538. /** defines the manager's name */
  24539. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24540. /**
  24541. * Returns the string "SpriteManager"
  24542. * @returns "SpriteManager"
  24543. */
  24544. getClassName(): string;
  24545. private _makePacked;
  24546. private _checkTextureAlpha;
  24547. /**
  24548. * Intersects the sprites with a ray
  24549. * @param ray defines the ray to intersect with
  24550. * @param camera defines the current active camera
  24551. * @param predicate defines a predicate used to select candidate sprites
  24552. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24553. * @returns null if no hit or a PickingInfo
  24554. */
  24555. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24556. /**
  24557. * Intersects the sprites with a ray
  24558. * @param ray defines the ray to intersect with
  24559. * @param camera defines the current active camera
  24560. * @param predicate defines a predicate used to select candidate sprites
  24561. * @returns null if no hit or a PickingInfo array
  24562. */
  24563. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24564. /**
  24565. * Render all child sprites
  24566. */
  24567. render(): void;
  24568. private _customUpdate;
  24569. /**
  24570. * Release associated resources
  24571. */
  24572. dispose(): void;
  24573. /**
  24574. * Serializes the sprite manager to a JSON object
  24575. * @param serializeTexture defines if the texture must be serialized as well
  24576. * @returns the JSON object
  24577. */
  24578. serialize(serializeTexture?: boolean): any;
  24579. /**
  24580. * Parses a JSON object to create a new sprite manager.
  24581. * @param parsedManager The JSON object to parse
  24582. * @param scene The scene to create the sprite manager
  24583. * @param rootUrl The root url to use to load external dependencies like texture
  24584. * @returns the new sprite manager
  24585. */
  24586. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24587. /**
  24588. * Creates a sprite manager from a snippet saved in a remote file
  24589. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24590. * @param url defines the url to load from
  24591. * @param scene defines the hosting scene
  24592. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24593. * @returns a promise that will resolve to the new sprite manager
  24594. */
  24595. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24596. /**
  24597. * Creates a sprite manager from a snippet saved by the sprite editor
  24598. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24599. * @param scene defines the hosting scene
  24600. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24601. * @returns a promise that will resolve to the new sprite manager
  24602. */
  24603. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24604. }
  24605. }
  24606. declare module BABYLON {
  24607. /**
  24608. * Class used to represent a sprite
  24609. * @see https://doc.babylonjs.com/babylon101/sprites
  24610. */
  24611. export class Sprite extends ThinSprite implements IAnimatable {
  24612. /** defines the name */
  24613. name: string;
  24614. /** Gets or sets the current world position */
  24615. position: Vector3;
  24616. /** Gets or sets the main color */
  24617. color: Color4;
  24618. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24619. disposeWhenFinishedAnimating: boolean;
  24620. /** Gets the list of attached animations */
  24621. animations: Nullable<Array<Animation>>;
  24622. /** Gets or sets a boolean indicating if the sprite can be picked */
  24623. isPickable: boolean;
  24624. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24625. useAlphaForPicking: boolean;
  24626. /**
  24627. * Gets or sets the associated action manager
  24628. */
  24629. actionManager: Nullable<ActionManager>;
  24630. /**
  24631. * An event triggered when the control has been disposed
  24632. */
  24633. onDisposeObservable: Observable<Sprite>;
  24634. private _manager;
  24635. private _onAnimationEnd;
  24636. /**
  24637. * Gets or sets the sprite size
  24638. */
  24639. get size(): number;
  24640. set size(value: number);
  24641. /**
  24642. * Gets or sets the unique id of the sprite
  24643. */
  24644. uniqueId: number;
  24645. /**
  24646. * Gets the manager of this sprite
  24647. */
  24648. get manager(): ISpriteManager;
  24649. /**
  24650. * Creates a new Sprite
  24651. * @param name defines the name
  24652. * @param manager defines the manager
  24653. */
  24654. constructor(
  24655. /** defines the name */
  24656. name: string, manager: ISpriteManager);
  24657. /**
  24658. * Returns the string "Sprite"
  24659. * @returns "Sprite"
  24660. */
  24661. getClassName(): string;
  24662. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24663. get fromIndex(): number;
  24664. set fromIndex(value: number);
  24665. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24666. get toIndex(): number;
  24667. set toIndex(value: number);
  24668. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24669. get loopAnimation(): boolean;
  24670. set loopAnimation(value: boolean);
  24671. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24672. get delay(): number;
  24673. set delay(value: number);
  24674. /**
  24675. * Starts an animation
  24676. * @param from defines the initial key
  24677. * @param to defines the end key
  24678. * @param loop defines if the animation must loop
  24679. * @param delay defines the start delay (in ms)
  24680. * @param onAnimationEnd defines a callback to call when animation ends
  24681. */
  24682. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24683. private _endAnimation;
  24684. /** Release associated resources */
  24685. dispose(): void;
  24686. /**
  24687. * Serializes the sprite to a JSON object
  24688. * @returns the JSON object
  24689. */
  24690. serialize(): any;
  24691. /**
  24692. * Parses a JSON object to create a new sprite
  24693. * @param parsedSprite The JSON object to parse
  24694. * @param manager defines the hosting manager
  24695. * @returns the new sprite
  24696. */
  24697. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24698. }
  24699. }
  24700. declare module BABYLON {
  24701. /**
  24702. * Information about the result of picking within a scene
  24703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24704. */
  24705. export class PickingInfo {
  24706. /** @hidden */
  24707. _pickingUnavailable: boolean;
  24708. /**
  24709. * If the pick collided with an object
  24710. */
  24711. hit: boolean;
  24712. /**
  24713. * Distance away where the pick collided
  24714. */
  24715. distance: number;
  24716. /**
  24717. * The location of pick collision
  24718. */
  24719. pickedPoint: Nullable<Vector3>;
  24720. /**
  24721. * The mesh corresponding the the pick collision
  24722. */
  24723. pickedMesh: Nullable<AbstractMesh>;
  24724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24725. bu: number;
  24726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24727. bv: number;
  24728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24729. faceId: number;
  24730. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24731. subMeshFaceId: number;
  24732. /** Id of the the submesh that was picked */
  24733. subMeshId: number;
  24734. /** If a sprite was picked, this will be the sprite the pick collided with */
  24735. pickedSprite: Nullable<Sprite>;
  24736. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24737. thinInstanceIndex: number;
  24738. /**
  24739. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24740. */
  24741. originMesh: Nullable<AbstractMesh>;
  24742. /**
  24743. * The ray that was used to perform the picking.
  24744. */
  24745. ray: Nullable<Ray>;
  24746. /**
  24747. * Gets the normal corresponding to the face the pick collided with
  24748. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24749. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24750. * @returns The normal corresponding to the face the pick collided with
  24751. */
  24752. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24753. /**
  24754. * Gets the texture coordinates of where the pick occurred
  24755. * @returns the vector containing the coordinates of the texture
  24756. */
  24757. getTextureCoordinates(): Nullable<Vector2>;
  24758. }
  24759. }
  24760. declare module BABYLON {
  24761. /**
  24762. * Gather the list of pointer event types as constants.
  24763. */
  24764. export class PointerEventTypes {
  24765. /**
  24766. * 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.
  24767. */
  24768. static readonly POINTERDOWN: number;
  24769. /**
  24770. * The pointerup event is fired when a pointer is no longer active.
  24771. */
  24772. static readonly POINTERUP: number;
  24773. /**
  24774. * The pointermove event is fired when a pointer changes coordinates.
  24775. */
  24776. static readonly POINTERMOVE: number;
  24777. /**
  24778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24779. */
  24780. static readonly POINTERWHEEL: number;
  24781. /**
  24782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24783. */
  24784. static readonly POINTERPICK: number;
  24785. /**
  24786. * The pointertap event is fired when a the object has been touched and released without drag.
  24787. */
  24788. static readonly POINTERTAP: number;
  24789. /**
  24790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24791. */
  24792. static readonly POINTERDOUBLETAP: number;
  24793. }
  24794. /**
  24795. * Base class of pointer info types.
  24796. */
  24797. export class PointerInfoBase {
  24798. /**
  24799. * Defines the type of event (PointerEventTypes)
  24800. */
  24801. type: number;
  24802. /**
  24803. * Defines the related dom event
  24804. */
  24805. event: PointerEvent | MouseWheelEvent;
  24806. /**
  24807. * Instantiates the base class of pointers info.
  24808. * @param type Defines the type of event (PointerEventTypes)
  24809. * @param event Defines the related dom event
  24810. */
  24811. constructor(
  24812. /**
  24813. * Defines the type of event (PointerEventTypes)
  24814. */
  24815. type: number,
  24816. /**
  24817. * Defines the related dom event
  24818. */
  24819. event: PointerEvent | MouseWheelEvent);
  24820. }
  24821. /**
  24822. * This class is used to store pointer related info for the onPrePointerObservable event.
  24823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24824. */
  24825. export class PointerInfoPre extends PointerInfoBase {
  24826. /**
  24827. * Ray from a pointer if availible (eg. 6dof controller)
  24828. */
  24829. ray: Nullable<Ray>;
  24830. /**
  24831. * Defines the local position of the pointer on the canvas.
  24832. */
  24833. localPosition: Vector2;
  24834. /**
  24835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24836. */
  24837. skipOnPointerObservable: boolean;
  24838. /**
  24839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24840. * @param type Defines the type of event (PointerEventTypes)
  24841. * @param event Defines the related dom event
  24842. * @param localX Defines the local x coordinates of the pointer when the event occured
  24843. * @param localY Defines the local y coordinates of the pointer when the event occured
  24844. */
  24845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24846. }
  24847. /**
  24848. * This type contains all the data related to a pointer event in Babylon.js.
  24849. * 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.
  24850. */
  24851. export class PointerInfo extends PointerInfoBase {
  24852. /**
  24853. * Defines the picking info associated to the info (if any)\
  24854. */
  24855. pickInfo: Nullable<PickingInfo>;
  24856. /**
  24857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24858. * @param type Defines the type of event (PointerEventTypes)
  24859. * @param event Defines the related dom event
  24860. * @param pickInfo Defines the picking info associated to the info (if any)\
  24861. */
  24862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24863. /**
  24864. * Defines the picking info associated to the info (if any)\
  24865. */
  24866. pickInfo: Nullable<PickingInfo>);
  24867. }
  24868. /**
  24869. * Data relating to a touch event on the screen.
  24870. */
  24871. export interface PointerTouch {
  24872. /**
  24873. * X coordinate of touch.
  24874. */
  24875. x: number;
  24876. /**
  24877. * Y coordinate of touch.
  24878. */
  24879. y: number;
  24880. /**
  24881. * Id of touch. Unique for each finger.
  24882. */
  24883. pointerId: number;
  24884. /**
  24885. * Event type passed from DOM.
  24886. */
  24887. type: any;
  24888. }
  24889. }
  24890. declare module BABYLON {
  24891. /**
  24892. * Manage the mouse inputs to control the movement of a free camera.
  24893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24894. */
  24895. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24896. /**
  24897. * Define if touch is enabled in the mouse input
  24898. */
  24899. touchEnabled: boolean;
  24900. /**
  24901. * Defines the camera the input is attached to.
  24902. */
  24903. camera: FreeCamera;
  24904. /**
  24905. * Defines the buttons associated with the input to handle camera move.
  24906. */
  24907. buttons: number[];
  24908. /**
  24909. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24910. */
  24911. angularSensibility: number;
  24912. private _pointerInput;
  24913. private _onMouseMove;
  24914. private _observer;
  24915. private previousPosition;
  24916. /**
  24917. * Observable for when a pointer move event occurs containing the move offset
  24918. */
  24919. onPointerMovedObservable: Observable<{
  24920. offsetX: number;
  24921. offsetY: number;
  24922. }>;
  24923. /**
  24924. * @hidden
  24925. * If the camera should be rotated automatically based on pointer movement
  24926. */
  24927. _allowCameraRotation: boolean;
  24928. /**
  24929. * Manage the mouse inputs to control the movement of a free camera.
  24930. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24931. * @param touchEnabled Defines if touch is enabled or not
  24932. */
  24933. constructor(
  24934. /**
  24935. * Define if touch is enabled in the mouse input
  24936. */
  24937. touchEnabled?: boolean);
  24938. /**
  24939. * Attach the input controls to a specific dom element to get the input from.
  24940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24941. */
  24942. attachControl(noPreventDefault?: boolean): void;
  24943. /**
  24944. * Called on JS contextmenu event.
  24945. * Override this method to provide functionality.
  24946. */
  24947. protected onContextMenu(evt: PointerEvent): void;
  24948. /**
  24949. * Detach the current controls from the specified dom element.
  24950. */
  24951. detachControl(): void;
  24952. /**
  24953. * Gets the class name of the current input.
  24954. * @returns the class name
  24955. */
  24956. getClassName(): string;
  24957. /**
  24958. * Get the friendly name associated with the input class.
  24959. * @returns the input friendly name
  24960. */
  24961. getSimpleName(): string;
  24962. }
  24963. }
  24964. declare module BABYLON {
  24965. /**
  24966. * Base class for mouse wheel input..
  24967. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24968. * for example usage.
  24969. */
  24970. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24971. /**
  24972. * Defines the camera the input is attached to.
  24973. */
  24974. abstract camera: Camera;
  24975. /**
  24976. * How fast is the camera moves in relation to X axis mouseWheel events.
  24977. * Use negative value to reverse direction.
  24978. */
  24979. wheelPrecisionX: number;
  24980. /**
  24981. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24982. * Use negative value to reverse direction.
  24983. */
  24984. wheelPrecisionY: number;
  24985. /**
  24986. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24987. * Use negative value to reverse direction.
  24988. */
  24989. wheelPrecisionZ: number;
  24990. /**
  24991. * Observable for when a mouse wheel move event occurs.
  24992. */
  24993. onChangedObservable: Observable<{
  24994. wheelDeltaX: number;
  24995. wheelDeltaY: number;
  24996. wheelDeltaZ: number;
  24997. }>;
  24998. private _wheel;
  24999. private _observer;
  25000. /**
  25001. * Attach the input controls to a specific dom element to get the input from.
  25002. * @param noPreventDefault Defines whether event caught by the controls
  25003. * should call preventdefault().
  25004. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25005. */
  25006. attachControl(noPreventDefault?: boolean): void;
  25007. /**
  25008. * Detach the current controls from the specified dom element.
  25009. */
  25010. detachControl(): void;
  25011. /**
  25012. * Called for each rendered frame.
  25013. */
  25014. checkInputs(): void;
  25015. /**
  25016. * Gets the class name of the current input.
  25017. * @returns the class name
  25018. */
  25019. getClassName(): string;
  25020. /**
  25021. * Get the friendly name associated with the input class.
  25022. * @returns the input friendly name
  25023. */
  25024. getSimpleName(): string;
  25025. /**
  25026. * Incremental value of multiple mouse wheel movements of the X axis.
  25027. * Should be zero-ed when read.
  25028. */
  25029. protected _wheelDeltaX: number;
  25030. /**
  25031. * Incremental value of multiple mouse wheel movements of the Y axis.
  25032. * Should be zero-ed when read.
  25033. */
  25034. protected _wheelDeltaY: number;
  25035. /**
  25036. * Incremental value of multiple mouse wheel movements of the Z axis.
  25037. * Should be zero-ed when read.
  25038. */
  25039. protected _wheelDeltaZ: number;
  25040. /**
  25041. * Firefox uses a different scheme to report scroll distances to other
  25042. * browsers. Rather than use complicated methods to calculate the exact
  25043. * multiple we need to apply, let's just cheat and use a constant.
  25044. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25045. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25046. */
  25047. private readonly _ffMultiplier;
  25048. /**
  25049. * Different event attributes for wheel data fall into a few set ranges.
  25050. * Some relevant but dated date here:
  25051. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25052. */
  25053. private readonly _normalize;
  25054. }
  25055. }
  25056. declare module BABYLON {
  25057. /**
  25058. * Manage the mouse wheel inputs to control a free camera.
  25059. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25060. */
  25061. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25062. /**
  25063. * Defines the camera the input is attached to.
  25064. */
  25065. camera: FreeCamera;
  25066. /**
  25067. * Gets the class name of the current input.
  25068. * @returns the class name
  25069. */
  25070. getClassName(): string;
  25071. /**
  25072. * Set which movement axis (relative to camera's orientation) the mouse
  25073. * wheel's X axis controls.
  25074. * @param axis The axis to be moved. Set null to clear.
  25075. */
  25076. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25077. /**
  25078. * Get the configured movement axis (relative to camera's orientation) the
  25079. * mouse wheel's X axis controls.
  25080. * @returns The configured axis or null if none.
  25081. */
  25082. get wheelXMoveRelative(): Nullable<Coordinate>;
  25083. /**
  25084. * Set which movement axis (relative to camera's orientation) the mouse
  25085. * wheel's Y axis controls.
  25086. * @param axis The axis to be moved. Set null to clear.
  25087. */
  25088. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25089. /**
  25090. * Get the configured movement axis (relative to camera's orientation) the
  25091. * mouse wheel's Y axis controls.
  25092. * @returns The configured axis or null if none.
  25093. */
  25094. get wheelYMoveRelative(): Nullable<Coordinate>;
  25095. /**
  25096. * Set which movement axis (relative to camera's orientation) the mouse
  25097. * wheel's Z axis controls.
  25098. * @param axis The axis to be moved. Set null to clear.
  25099. */
  25100. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25101. /**
  25102. * Get the configured movement axis (relative to camera's orientation) the
  25103. * mouse wheel's Z axis controls.
  25104. * @returns The configured axis or null if none.
  25105. */
  25106. get wheelZMoveRelative(): Nullable<Coordinate>;
  25107. /**
  25108. * Set which rotation axis (relative to camera's orientation) the mouse
  25109. * wheel's X axis controls.
  25110. * @param axis The axis to be moved. Set null to clear.
  25111. */
  25112. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25113. /**
  25114. * Get the configured rotation axis (relative to camera's orientation) the
  25115. * mouse wheel's X axis controls.
  25116. * @returns The configured axis or null if none.
  25117. */
  25118. get wheelXRotateRelative(): Nullable<Coordinate>;
  25119. /**
  25120. * Set which rotation axis (relative to camera's orientation) the mouse
  25121. * wheel's Y axis controls.
  25122. * @param axis The axis to be moved. Set null to clear.
  25123. */
  25124. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25125. /**
  25126. * Get the configured rotation axis (relative to camera's orientation) the
  25127. * mouse wheel's Y axis controls.
  25128. * @returns The configured axis or null if none.
  25129. */
  25130. get wheelYRotateRelative(): Nullable<Coordinate>;
  25131. /**
  25132. * Set which rotation axis (relative to camera's orientation) the mouse
  25133. * wheel's Z axis controls.
  25134. * @param axis The axis to be moved. Set null to clear.
  25135. */
  25136. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25137. /**
  25138. * Get the configured rotation axis (relative to camera's orientation) the
  25139. * mouse wheel's Z axis controls.
  25140. * @returns The configured axis or null if none.
  25141. */
  25142. get wheelZRotateRelative(): Nullable<Coordinate>;
  25143. /**
  25144. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25145. * controls.
  25146. * @param axis The axis to be moved. Set null to clear.
  25147. */
  25148. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25149. /**
  25150. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25151. * X axis controls.
  25152. * @returns The configured axis or null if none.
  25153. */
  25154. get wheelXMoveScene(): Nullable<Coordinate>;
  25155. /**
  25156. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25157. * controls.
  25158. * @param axis The axis to be moved. Set null to clear.
  25159. */
  25160. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25161. /**
  25162. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25163. * Y axis controls.
  25164. * @returns The configured axis or null if none.
  25165. */
  25166. get wheelYMoveScene(): Nullable<Coordinate>;
  25167. /**
  25168. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25169. * controls.
  25170. * @param axis The axis to be moved. Set null to clear.
  25171. */
  25172. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25173. /**
  25174. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25175. * Z axis controls.
  25176. * @returns The configured axis or null if none.
  25177. */
  25178. get wheelZMoveScene(): Nullable<Coordinate>;
  25179. /**
  25180. * Called for each rendered frame.
  25181. */
  25182. checkInputs(): void;
  25183. private _moveRelative;
  25184. private _rotateRelative;
  25185. private _moveScene;
  25186. /**
  25187. * These are set to the desired default behaviour.
  25188. */
  25189. private _wheelXAction;
  25190. private _wheelXActionCoordinate;
  25191. private _wheelYAction;
  25192. private _wheelYActionCoordinate;
  25193. private _wheelZAction;
  25194. private _wheelZActionCoordinate;
  25195. /**
  25196. * Update the camera according to any configured properties for the 3
  25197. * mouse-wheel axis.
  25198. */
  25199. private _updateCamera;
  25200. /**
  25201. * Update one property of the camera.
  25202. */
  25203. private _updateCameraProperty;
  25204. }
  25205. }
  25206. declare module BABYLON {
  25207. /**
  25208. * Manage the touch inputs to control the movement of a free camera.
  25209. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25210. */
  25211. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25212. /**
  25213. * Define if mouse events can be treated as touch events
  25214. */
  25215. allowMouse: boolean;
  25216. /**
  25217. * Defines the camera the input is attached to.
  25218. */
  25219. camera: FreeCamera;
  25220. /**
  25221. * Defines the touch sensibility for rotation.
  25222. * The higher the faster.
  25223. */
  25224. touchAngularSensibility: number;
  25225. /**
  25226. * Defines the touch sensibility for move.
  25227. * The higher the faster.
  25228. */
  25229. touchMoveSensibility: number;
  25230. private _offsetX;
  25231. private _offsetY;
  25232. private _pointerPressed;
  25233. private _pointerInput?;
  25234. private _observer;
  25235. private _onLostFocus;
  25236. /**
  25237. * Manage the touch inputs to control the movement of a free camera.
  25238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25239. * @param allowMouse Defines if mouse events can be treated as touch events
  25240. */
  25241. constructor(
  25242. /**
  25243. * Define if mouse events can be treated as touch events
  25244. */
  25245. allowMouse?: boolean);
  25246. /**
  25247. * Attach the input controls to a specific dom element to get the input from.
  25248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25249. */
  25250. attachControl(noPreventDefault?: boolean): void;
  25251. /**
  25252. * Detach the current controls from the specified dom element.
  25253. */
  25254. detachControl(): void;
  25255. /**
  25256. * Update the current camera state depending on the inputs that have been used this frame.
  25257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25258. */
  25259. checkInputs(): void;
  25260. /**
  25261. * Gets the class name of the current input.
  25262. * @returns the class name
  25263. */
  25264. getClassName(): string;
  25265. /**
  25266. * Get the friendly name associated with the input class.
  25267. * @returns the input friendly name
  25268. */
  25269. getSimpleName(): string;
  25270. }
  25271. }
  25272. declare module BABYLON {
  25273. /**
  25274. * Default Inputs manager for the FreeCamera.
  25275. * It groups all the default supported inputs for ease of use.
  25276. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25277. */
  25278. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25279. /**
  25280. * @hidden
  25281. */
  25282. _mouseInput: Nullable<FreeCameraMouseInput>;
  25283. /**
  25284. * @hidden
  25285. */
  25286. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25287. /**
  25288. * Instantiates a new FreeCameraInputsManager.
  25289. * @param camera Defines the camera the inputs belong to
  25290. */
  25291. constructor(camera: FreeCamera);
  25292. /**
  25293. * Add keyboard input support to the input manager.
  25294. * @returns the current input manager
  25295. */
  25296. addKeyboard(): FreeCameraInputsManager;
  25297. /**
  25298. * Add mouse input support to the input manager.
  25299. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25300. * @returns the current input manager
  25301. */
  25302. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25303. /**
  25304. * Removes the mouse input support from the manager
  25305. * @returns the current input manager
  25306. */
  25307. removeMouse(): FreeCameraInputsManager;
  25308. /**
  25309. * Add mouse wheel input support to the input manager.
  25310. * @returns the current input manager
  25311. */
  25312. addMouseWheel(): FreeCameraInputsManager;
  25313. /**
  25314. * Removes the mouse wheel input support from the manager
  25315. * @returns the current input manager
  25316. */
  25317. removeMouseWheel(): FreeCameraInputsManager;
  25318. /**
  25319. * Add touch input support to the input manager.
  25320. * @returns the current input manager
  25321. */
  25322. addTouch(): FreeCameraInputsManager;
  25323. /**
  25324. * Remove all attached input methods from a camera
  25325. */
  25326. clear(): void;
  25327. }
  25328. }
  25329. declare module BABYLON {
  25330. /**
  25331. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25332. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25333. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25334. */
  25335. export class FreeCamera extends TargetCamera {
  25336. /**
  25337. * Define the collision ellipsoid of the camera.
  25338. * This is helpful to simulate a camera body like the player body around the camera
  25339. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25340. */
  25341. ellipsoid: Vector3;
  25342. /**
  25343. * Define an offset for the position of the ellipsoid around the camera.
  25344. * This can be helpful to determine the center of the body near the gravity center of the body
  25345. * instead of its head.
  25346. */
  25347. ellipsoidOffset: Vector3;
  25348. /**
  25349. * Enable or disable collisions of the camera with the rest of the scene objects.
  25350. */
  25351. checkCollisions: boolean;
  25352. /**
  25353. * Enable or disable gravity on the camera.
  25354. */
  25355. applyGravity: boolean;
  25356. /**
  25357. * Define the input manager associated to the camera.
  25358. */
  25359. inputs: FreeCameraInputsManager;
  25360. /**
  25361. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25362. * Higher values reduce sensitivity.
  25363. */
  25364. get angularSensibility(): number;
  25365. /**
  25366. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25367. * Higher values reduce sensitivity.
  25368. */
  25369. set angularSensibility(value: number);
  25370. /**
  25371. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25372. */
  25373. get keysUp(): number[];
  25374. set keysUp(value: number[]);
  25375. /**
  25376. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25377. */
  25378. get keysUpward(): number[];
  25379. set keysUpward(value: number[]);
  25380. /**
  25381. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25382. */
  25383. get keysDown(): number[];
  25384. set keysDown(value: number[]);
  25385. /**
  25386. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25387. */
  25388. get keysDownward(): number[];
  25389. set keysDownward(value: number[]);
  25390. /**
  25391. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25392. */
  25393. get keysLeft(): number[];
  25394. set keysLeft(value: number[]);
  25395. /**
  25396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25397. */
  25398. get keysRight(): number[];
  25399. set keysRight(value: number[]);
  25400. /**
  25401. * Event raised when the camera collide with a mesh in the scene.
  25402. */
  25403. onCollide: (collidedMesh: AbstractMesh) => void;
  25404. private _collider;
  25405. private _needMoveForGravity;
  25406. private _oldPosition;
  25407. private _diffPosition;
  25408. private _newPosition;
  25409. /** @hidden */
  25410. _localDirection: Vector3;
  25411. /** @hidden */
  25412. _transformedDirection: Vector3;
  25413. /**
  25414. * Instantiates a Free Camera.
  25415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25417. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25418. * @param name Define the name of the camera in the scene
  25419. * @param position Define the start position of the camera in the scene
  25420. * @param scene Define the scene the camera belongs to
  25421. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25422. */
  25423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25424. /**
  25425. * Attach the input controls to a specific dom element to get the input from.
  25426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25427. */
  25428. attachControl(noPreventDefault?: boolean): void;
  25429. /**
  25430. * Attach the input controls to a specific dom element to get the input from.
  25431. * @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
  25432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25433. * BACK COMPAT SIGNATURE ONLY.
  25434. */
  25435. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25436. /**
  25437. * Detach the current controls from the specified dom element.
  25438. */
  25439. detachControl(): void;
  25440. /**
  25441. * Detach the current controls from the specified dom element.
  25442. * @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
  25443. */
  25444. detachControl(ignored: any): void;
  25445. private _collisionMask;
  25446. /**
  25447. * Define a collision mask to limit the list of object the camera can collide with
  25448. */
  25449. get collisionMask(): number;
  25450. set collisionMask(mask: number);
  25451. /** @hidden */
  25452. _collideWithWorld(displacement: Vector3): void;
  25453. private _onCollisionPositionChange;
  25454. /** @hidden */
  25455. _checkInputs(): void;
  25456. /** @hidden */
  25457. _decideIfNeedsToMove(): boolean;
  25458. /** @hidden */
  25459. _updatePosition(): void;
  25460. /**
  25461. * Destroy the camera and release the current resources hold by it.
  25462. */
  25463. dispose(): void;
  25464. /**
  25465. * Gets the current object class name.
  25466. * @return the class name
  25467. */
  25468. getClassName(): string;
  25469. }
  25470. }
  25471. declare module BABYLON {
  25472. /**
  25473. * Represents a gamepad control stick position
  25474. */
  25475. export class StickValues {
  25476. /**
  25477. * The x component of the control stick
  25478. */
  25479. x: number;
  25480. /**
  25481. * The y component of the control stick
  25482. */
  25483. y: number;
  25484. /**
  25485. * Initializes the gamepad x and y control stick values
  25486. * @param x The x component of the gamepad control stick value
  25487. * @param y The y component of the gamepad control stick value
  25488. */
  25489. constructor(
  25490. /**
  25491. * The x component of the control stick
  25492. */
  25493. x: number,
  25494. /**
  25495. * The y component of the control stick
  25496. */
  25497. y: number);
  25498. }
  25499. /**
  25500. * An interface which manages callbacks for gamepad button changes
  25501. */
  25502. export interface GamepadButtonChanges {
  25503. /**
  25504. * Called when a gamepad has been changed
  25505. */
  25506. changed: boolean;
  25507. /**
  25508. * Called when a gamepad press event has been triggered
  25509. */
  25510. pressChanged: boolean;
  25511. /**
  25512. * Called when a touch event has been triggered
  25513. */
  25514. touchChanged: boolean;
  25515. /**
  25516. * Called when a value has changed
  25517. */
  25518. valueChanged: boolean;
  25519. }
  25520. /**
  25521. * Represents a gamepad
  25522. */
  25523. export class Gamepad {
  25524. /**
  25525. * The id of the gamepad
  25526. */
  25527. id: string;
  25528. /**
  25529. * The index of the gamepad
  25530. */
  25531. index: number;
  25532. /**
  25533. * The browser gamepad
  25534. */
  25535. browserGamepad: any;
  25536. /**
  25537. * Specifies what type of gamepad this represents
  25538. */
  25539. type: number;
  25540. private _leftStick;
  25541. private _rightStick;
  25542. /** @hidden */
  25543. _isConnected: boolean;
  25544. private _leftStickAxisX;
  25545. private _leftStickAxisY;
  25546. private _rightStickAxisX;
  25547. private _rightStickAxisY;
  25548. /**
  25549. * Triggered when the left control stick has been changed
  25550. */
  25551. private _onleftstickchanged;
  25552. /**
  25553. * Triggered when the right control stick has been changed
  25554. */
  25555. private _onrightstickchanged;
  25556. /**
  25557. * Represents a gamepad controller
  25558. */
  25559. static GAMEPAD: number;
  25560. /**
  25561. * Represents a generic controller
  25562. */
  25563. static GENERIC: number;
  25564. /**
  25565. * Represents an XBox controller
  25566. */
  25567. static XBOX: number;
  25568. /**
  25569. * Represents a pose-enabled controller
  25570. */
  25571. static POSE_ENABLED: number;
  25572. /**
  25573. * Represents an Dual Shock controller
  25574. */
  25575. static DUALSHOCK: number;
  25576. /**
  25577. * Specifies whether the left control stick should be Y-inverted
  25578. */
  25579. protected _invertLeftStickY: boolean;
  25580. /**
  25581. * Specifies if the gamepad has been connected
  25582. */
  25583. get isConnected(): boolean;
  25584. /**
  25585. * Initializes the gamepad
  25586. * @param id The id of the gamepad
  25587. * @param index The index of the gamepad
  25588. * @param browserGamepad The browser gamepad
  25589. * @param leftStickX The x component of the left joystick
  25590. * @param leftStickY The y component of the left joystick
  25591. * @param rightStickX The x component of the right joystick
  25592. * @param rightStickY The y component of the right joystick
  25593. */
  25594. constructor(
  25595. /**
  25596. * The id of the gamepad
  25597. */
  25598. id: string,
  25599. /**
  25600. * The index of the gamepad
  25601. */
  25602. index: number,
  25603. /**
  25604. * The browser gamepad
  25605. */
  25606. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25607. /**
  25608. * Callback triggered when the left joystick has changed
  25609. * @param callback
  25610. */
  25611. onleftstickchanged(callback: (values: StickValues) => void): void;
  25612. /**
  25613. * Callback triggered when the right joystick has changed
  25614. * @param callback
  25615. */
  25616. onrightstickchanged(callback: (values: StickValues) => void): void;
  25617. /**
  25618. * Gets the left joystick
  25619. */
  25620. get leftStick(): StickValues;
  25621. /**
  25622. * Sets the left joystick values
  25623. */
  25624. set leftStick(newValues: StickValues);
  25625. /**
  25626. * Gets the right joystick
  25627. */
  25628. get rightStick(): StickValues;
  25629. /**
  25630. * Sets the right joystick value
  25631. */
  25632. set rightStick(newValues: StickValues);
  25633. /**
  25634. * Updates the gamepad joystick positions
  25635. */
  25636. update(): void;
  25637. /**
  25638. * Disposes the gamepad
  25639. */
  25640. dispose(): void;
  25641. }
  25642. /**
  25643. * Represents a generic gamepad
  25644. */
  25645. export class GenericPad extends Gamepad {
  25646. private _buttons;
  25647. private _onbuttondown;
  25648. private _onbuttonup;
  25649. /**
  25650. * Observable triggered when a button has been pressed
  25651. */
  25652. onButtonDownObservable: Observable<number>;
  25653. /**
  25654. * Observable triggered when a button has been released
  25655. */
  25656. onButtonUpObservable: Observable<number>;
  25657. /**
  25658. * Callback triggered when a button has been pressed
  25659. * @param callback Called when a button has been pressed
  25660. */
  25661. onbuttondown(callback: (buttonPressed: number) => void): void;
  25662. /**
  25663. * Callback triggered when a button has been released
  25664. * @param callback Called when a button has been released
  25665. */
  25666. onbuttonup(callback: (buttonReleased: number) => void): void;
  25667. /**
  25668. * Initializes the generic gamepad
  25669. * @param id The id of the generic gamepad
  25670. * @param index The index of the generic gamepad
  25671. * @param browserGamepad The browser gamepad
  25672. */
  25673. constructor(id: string, index: number, browserGamepad: any);
  25674. private _setButtonValue;
  25675. /**
  25676. * Updates the generic gamepad
  25677. */
  25678. update(): void;
  25679. /**
  25680. * Disposes the generic gamepad
  25681. */
  25682. dispose(): void;
  25683. }
  25684. }
  25685. declare module BABYLON {
  25686. /**
  25687. * Defines a runtime animation
  25688. */
  25689. export class RuntimeAnimation {
  25690. private _events;
  25691. /**
  25692. * The current frame of the runtime animation
  25693. */
  25694. private _currentFrame;
  25695. /**
  25696. * The animation used by the runtime animation
  25697. */
  25698. private _animation;
  25699. /**
  25700. * The target of the runtime animation
  25701. */
  25702. private _target;
  25703. /**
  25704. * The initiating animatable
  25705. */
  25706. private _host;
  25707. /**
  25708. * The original value of the runtime animation
  25709. */
  25710. private _originalValue;
  25711. /**
  25712. * The original blend value of the runtime animation
  25713. */
  25714. private _originalBlendValue;
  25715. /**
  25716. * The offsets cache of the runtime animation
  25717. */
  25718. private _offsetsCache;
  25719. /**
  25720. * The high limits cache of the runtime animation
  25721. */
  25722. private _highLimitsCache;
  25723. /**
  25724. * Specifies if the runtime animation has been stopped
  25725. */
  25726. private _stopped;
  25727. /**
  25728. * The blending factor of the runtime animation
  25729. */
  25730. private _blendingFactor;
  25731. /**
  25732. * The BabylonJS scene
  25733. */
  25734. private _scene;
  25735. /**
  25736. * The current value of the runtime animation
  25737. */
  25738. private _currentValue;
  25739. /** @hidden */
  25740. _animationState: _IAnimationState;
  25741. /**
  25742. * The active target of the runtime animation
  25743. */
  25744. private _activeTargets;
  25745. private _currentActiveTarget;
  25746. private _directTarget;
  25747. /**
  25748. * The target path of the runtime animation
  25749. */
  25750. private _targetPath;
  25751. /**
  25752. * The weight of the runtime animation
  25753. */
  25754. private _weight;
  25755. /**
  25756. * The ratio offset of the runtime animation
  25757. */
  25758. private _ratioOffset;
  25759. /**
  25760. * The previous delay of the runtime animation
  25761. */
  25762. private _previousDelay;
  25763. /**
  25764. * The previous ratio of the runtime animation
  25765. */
  25766. private _previousRatio;
  25767. private _enableBlending;
  25768. private _keys;
  25769. private _minFrame;
  25770. private _maxFrame;
  25771. private _minValue;
  25772. private _maxValue;
  25773. private _targetIsArray;
  25774. /**
  25775. * Gets the current frame of the runtime animation
  25776. */
  25777. get currentFrame(): number;
  25778. /**
  25779. * Gets the weight of the runtime animation
  25780. */
  25781. get weight(): number;
  25782. /**
  25783. * Gets the current value of the runtime animation
  25784. */
  25785. get currentValue(): any;
  25786. /**
  25787. * Gets the target path of the runtime animation
  25788. */
  25789. get targetPath(): string;
  25790. /**
  25791. * Gets the actual target of the runtime animation
  25792. */
  25793. get target(): any;
  25794. /**
  25795. * Gets the additive state of the runtime animation
  25796. */
  25797. get isAdditive(): boolean;
  25798. /** @hidden */
  25799. _onLoop: () => void;
  25800. /**
  25801. * Create a new RuntimeAnimation object
  25802. * @param target defines the target of the animation
  25803. * @param animation defines the source animation object
  25804. * @param scene defines the hosting scene
  25805. * @param host defines the initiating Animatable
  25806. */
  25807. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25808. private _preparePath;
  25809. /**
  25810. * Gets the animation from the runtime animation
  25811. */
  25812. get animation(): Animation;
  25813. /**
  25814. * Resets the runtime animation to the beginning
  25815. * @param restoreOriginal defines whether to restore the target property to the original value
  25816. */
  25817. reset(restoreOriginal?: boolean): void;
  25818. /**
  25819. * Specifies if the runtime animation is stopped
  25820. * @returns Boolean specifying if the runtime animation is stopped
  25821. */
  25822. isStopped(): boolean;
  25823. /**
  25824. * Disposes of the runtime animation
  25825. */
  25826. dispose(): void;
  25827. /**
  25828. * Apply the interpolated value to the target
  25829. * @param currentValue defines the value computed by the animation
  25830. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25831. */
  25832. setValue(currentValue: any, weight: number): void;
  25833. private _getOriginalValues;
  25834. private _setValue;
  25835. /**
  25836. * Gets the loop pmode of the runtime animation
  25837. * @returns Loop Mode
  25838. */
  25839. private _getCorrectLoopMode;
  25840. /**
  25841. * Move the current animation to a given frame
  25842. * @param frame defines the frame to move to
  25843. */
  25844. goToFrame(frame: number): void;
  25845. /**
  25846. * @hidden Internal use only
  25847. */
  25848. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25849. /**
  25850. * Execute the current animation
  25851. * @param delay defines the delay to add to the current frame
  25852. * @param from defines the lower bound of the animation range
  25853. * @param to defines the upper bound of the animation range
  25854. * @param loop defines if the current animation must loop
  25855. * @param speedRatio defines the current speed ratio
  25856. * @param weight defines the weight of the animation (default is -1 so no weight)
  25857. * @param onLoop optional callback called when animation loops
  25858. * @returns a boolean indicating if the animation is running
  25859. */
  25860. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25861. }
  25862. }
  25863. declare module BABYLON {
  25864. /**
  25865. * Class used to store an actual running animation
  25866. */
  25867. export class Animatable {
  25868. /** defines the target object */
  25869. target: any;
  25870. /** defines the starting frame number (default is 0) */
  25871. fromFrame: number;
  25872. /** defines the ending frame number (default is 100) */
  25873. toFrame: number;
  25874. /** defines if the animation must loop (default is false) */
  25875. loopAnimation: boolean;
  25876. /** defines a callback to call when animation ends if it is not looping */
  25877. onAnimationEnd?: (() => void) | null | undefined;
  25878. /** defines a callback to call when animation loops */
  25879. onAnimationLoop?: (() => void) | null | undefined;
  25880. /** defines whether the animation should be evaluated additively */
  25881. isAdditive: boolean;
  25882. private _localDelayOffset;
  25883. private _pausedDelay;
  25884. private _runtimeAnimations;
  25885. private _paused;
  25886. private _scene;
  25887. private _speedRatio;
  25888. private _weight;
  25889. private _syncRoot;
  25890. /**
  25891. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25892. * This will only apply for non looping animation (default is true)
  25893. */
  25894. disposeOnEnd: boolean;
  25895. /**
  25896. * Gets a boolean indicating if the animation has started
  25897. */
  25898. animationStarted: boolean;
  25899. /**
  25900. * Observer raised when the animation ends
  25901. */
  25902. onAnimationEndObservable: Observable<Animatable>;
  25903. /**
  25904. * Observer raised when the animation loops
  25905. */
  25906. onAnimationLoopObservable: Observable<Animatable>;
  25907. /**
  25908. * Gets the root Animatable used to synchronize and normalize animations
  25909. */
  25910. get syncRoot(): Nullable<Animatable>;
  25911. /**
  25912. * Gets the current frame of the first RuntimeAnimation
  25913. * Used to synchronize Animatables
  25914. */
  25915. get masterFrame(): number;
  25916. /**
  25917. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25918. */
  25919. get weight(): number;
  25920. set weight(value: number);
  25921. /**
  25922. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25923. */
  25924. get speedRatio(): number;
  25925. set speedRatio(value: number);
  25926. /**
  25927. * Creates a new Animatable
  25928. * @param scene defines the hosting scene
  25929. * @param target defines the target object
  25930. * @param fromFrame defines the starting frame number (default is 0)
  25931. * @param toFrame defines the ending frame number (default is 100)
  25932. * @param loopAnimation defines if the animation must loop (default is false)
  25933. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25934. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25935. * @param animations defines a group of animation to add to the new Animatable
  25936. * @param onAnimationLoop defines a callback to call when animation loops
  25937. * @param isAdditive defines whether the animation should be evaluated additively
  25938. */
  25939. constructor(scene: Scene,
  25940. /** defines the target object */
  25941. target: any,
  25942. /** defines the starting frame number (default is 0) */
  25943. fromFrame?: number,
  25944. /** defines the ending frame number (default is 100) */
  25945. toFrame?: number,
  25946. /** defines if the animation must loop (default is false) */
  25947. loopAnimation?: boolean, speedRatio?: number,
  25948. /** defines a callback to call when animation ends if it is not looping */
  25949. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25950. /** defines a callback to call when animation loops */
  25951. onAnimationLoop?: (() => void) | null | undefined,
  25952. /** defines whether the animation should be evaluated additively */
  25953. isAdditive?: boolean);
  25954. /**
  25955. * Synchronize and normalize current Animatable with a source Animatable
  25956. * This is useful when using animation weights and when animations are not of the same length
  25957. * @param root defines the root Animatable to synchronize with
  25958. * @returns the current Animatable
  25959. */
  25960. syncWith(root: Animatable): Animatable;
  25961. /**
  25962. * Gets the list of runtime animations
  25963. * @returns an array of RuntimeAnimation
  25964. */
  25965. getAnimations(): RuntimeAnimation[];
  25966. /**
  25967. * Adds more animations to the current animatable
  25968. * @param target defines the target of the animations
  25969. * @param animations defines the new animations to add
  25970. */
  25971. appendAnimations(target: any, animations: Animation[]): void;
  25972. /**
  25973. * Gets the source animation for a specific property
  25974. * @param property defines the property to look for
  25975. * @returns null or the source animation for the given property
  25976. */
  25977. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25978. /**
  25979. * Gets the runtime animation for a specific property
  25980. * @param property defines the property to look for
  25981. * @returns null or the runtime animation for the given property
  25982. */
  25983. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25984. /**
  25985. * Resets the animatable to its original state
  25986. */
  25987. reset(): void;
  25988. /**
  25989. * Allows the animatable to blend with current running animations
  25990. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25991. * @param blendingSpeed defines the blending speed to use
  25992. */
  25993. enableBlending(blendingSpeed: number): void;
  25994. /**
  25995. * Disable animation blending
  25996. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25997. */
  25998. disableBlending(): void;
  25999. /**
  26000. * Jump directly to a given frame
  26001. * @param frame defines the frame to jump to
  26002. */
  26003. goToFrame(frame: number): void;
  26004. /**
  26005. * Pause the animation
  26006. */
  26007. pause(): void;
  26008. /**
  26009. * Restart the animation
  26010. */
  26011. restart(): void;
  26012. private _raiseOnAnimationEnd;
  26013. /**
  26014. * Stop and delete the current animation
  26015. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26016. * @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)
  26017. */
  26018. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26019. /**
  26020. * Wait asynchronously for the animation to end
  26021. * @returns a promise which will be fulfilled when the animation ends
  26022. */
  26023. waitAsync(): Promise<Animatable>;
  26024. /** @hidden */
  26025. _animate(delay: number): boolean;
  26026. }
  26027. interface Scene {
  26028. /** @hidden */
  26029. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26030. /** @hidden */
  26031. _processLateAnimationBindingsForMatrices(holder: {
  26032. totalWeight: number;
  26033. totalAdditiveWeight: number;
  26034. animations: RuntimeAnimation[];
  26035. additiveAnimations: RuntimeAnimation[];
  26036. originalValue: Matrix;
  26037. }): any;
  26038. /** @hidden */
  26039. _processLateAnimationBindingsForQuaternions(holder: {
  26040. totalWeight: number;
  26041. totalAdditiveWeight: number;
  26042. animations: RuntimeAnimation[];
  26043. additiveAnimations: RuntimeAnimation[];
  26044. originalValue: Quaternion;
  26045. }, refQuaternion: Quaternion): Quaternion;
  26046. /** @hidden */
  26047. _processLateAnimationBindings(): void;
  26048. /**
  26049. * Will start the animation sequence of a given target
  26050. * @param target defines the target
  26051. * @param from defines from which frame should animation start
  26052. * @param to defines until which frame should animation run.
  26053. * @param weight defines the weight to apply to the animation (1.0 by default)
  26054. * @param loop defines if the animation loops
  26055. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26056. * @param onAnimationEnd defines the function to be executed when the animation ends
  26057. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26058. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26059. * @param onAnimationLoop defines the callback to call when an animation loops
  26060. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26061. * @returns the animatable object created for this animation
  26062. */
  26063. 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;
  26064. /**
  26065. * Will start the animation sequence of a given target
  26066. * @param target defines the target
  26067. * @param from defines from which frame should animation start
  26068. * @param to defines until which frame should animation run.
  26069. * @param loop defines if the animation loops
  26070. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26071. * @param onAnimationEnd defines the function to be executed when the animation ends
  26072. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26073. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26074. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26075. * @param onAnimationLoop defines the callback to call when an animation loops
  26076. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26077. * @returns the animatable object created for this animation
  26078. */
  26079. 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;
  26080. /**
  26081. * Will start the animation sequence of a given target and its hierarchy
  26082. * @param target defines the target
  26083. * @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.
  26084. * @param from defines from which frame should animation start
  26085. * @param to defines until which frame should animation run.
  26086. * @param loop defines if the animation loops
  26087. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26088. * @param onAnimationEnd defines the function to be executed when the animation ends
  26089. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26090. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26091. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26092. * @param onAnimationLoop defines the callback to call when an animation loops
  26093. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26094. * @returns the list of created animatables
  26095. */
  26096. 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[];
  26097. /**
  26098. * Begin a new animation on a given node
  26099. * @param target defines the target where the animation will take place
  26100. * @param animations defines the list of animations to start
  26101. * @param from defines the initial value
  26102. * @param to defines the final value
  26103. * @param loop defines if you want animation to loop (off by default)
  26104. * @param speedRatio defines the speed ratio to apply to all animations
  26105. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26106. * @param onAnimationLoop defines the callback to call when an animation loops
  26107. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26108. * @returns the list of created animatables
  26109. */
  26110. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26111. /**
  26112. * Begin a new animation on a given node and its hierarchy
  26113. * @param target defines the root node where the animation will take place
  26114. * @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.
  26115. * @param animations defines the list of animations to start
  26116. * @param from defines the initial value
  26117. * @param to defines the final value
  26118. * @param loop defines if you want animation to loop (off by default)
  26119. * @param speedRatio defines the speed ratio to apply to all animations
  26120. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26121. * @param onAnimationLoop defines the callback to call when an animation loops
  26122. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26123. * @returns the list of animatables created for all nodes
  26124. */
  26125. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26126. /**
  26127. * Gets the animatable associated with a specific target
  26128. * @param target defines the target of the animatable
  26129. * @returns the required animatable if found
  26130. */
  26131. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26132. /**
  26133. * Gets all animatables associated with a given target
  26134. * @param target defines the target to look animatables for
  26135. * @returns an array of Animatables
  26136. */
  26137. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26138. /**
  26139. * Stops and removes all animations that have been applied to the scene
  26140. */
  26141. stopAllAnimations(): void;
  26142. /**
  26143. * Gets the current delta time used by animation engine
  26144. */
  26145. deltaTime: number;
  26146. }
  26147. interface Bone {
  26148. /**
  26149. * Copy an animation range from another bone
  26150. * @param source defines the source bone
  26151. * @param rangeName defines the range name to copy
  26152. * @param frameOffset defines the frame offset
  26153. * @param rescaleAsRequired defines if rescaling must be applied if required
  26154. * @param skelDimensionsRatio defines the scaling ratio
  26155. * @returns true if operation was successful
  26156. */
  26157. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26158. }
  26159. }
  26160. declare module BABYLON {
  26161. /**
  26162. * Class used to override all child animations of a given target
  26163. */
  26164. export class AnimationPropertiesOverride {
  26165. /**
  26166. * Gets or sets a value indicating if animation blending must be used
  26167. */
  26168. enableBlending: boolean;
  26169. /**
  26170. * Gets or sets the blending speed to use when enableBlending is true
  26171. */
  26172. blendingSpeed: number;
  26173. /**
  26174. * Gets or sets the default loop mode to use
  26175. */
  26176. loopMode: number;
  26177. }
  26178. }
  26179. declare module BABYLON {
  26180. /**
  26181. * Class used to handle skinning animations
  26182. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26183. */
  26184. export class Skeleton implements IAnimatable {
  26185. /** defines the skeleton name */
  26186. name: string;
  26187. /** defines the skeleton Id */
  26188. id: string;
  26189. /**
  26190. * Defines the list of child bones
  26191. */
  26192. bones: Bone[];
  26193. /**
  26194. * Defines an estimate of the dimension of the skeleton at rest
  26195. */
  26196. dimensionsAtRest: Vector3;
  26197. /**
  26198. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26199. */
  26200. needInitialSkinMatrix: boolean;
  26201. /**
  26202. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26203. */
  26204. overrideMesh: Nullable<AbstractMesh>;
  26205. /**
  26206. * Gets the list of animations attached to this skeleton
  26207. */
  26208. animations: Array<Animation>;
  26209. private _scene;
  26210. private _isDirty;
  26211. private _transformMatrices;
  26212. private _transformMatrixTexture;
  26213. private _meshesWithPoseMatrix;
  26214. private _animatables;
  26215. private _identity;
  26216. private _synchronizedWithMesh;
  26217. private _ranges;
  26218. private _lastAbsoluteTransformsUpdateId;
  26219. private _canUseTextureForBones;
  26220. private _uniqueId;
  26221. /** @hidden */
  26222. _numBonesWithLinkedTransformNode: number;
  26223. /** @hidden */
  26224. _hasWaitingData: Nullable<boolean>;
  26225. /** @hidden */
  26226. _waitingOverrideMeshId: Nullable<string>;
  26227. /**
  26228. * Specifies if the skeleton should be serialized
  26229. */
  26230. doNotSerialize: boolean;
  26231. private _useTextureToStoreBoneMatrices;
  26232. /**
  26233. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26234. * Please note that this option is not available if the hardware does not support it
  26235. */
  26236. get useTextureToStoreBoneMatrices(): boolean;
  26237. set useTextureToStoreBoneMatrices(value: boolean);
  26238. private _animationPropertiesOverride;
  26239. /**
  26240. * Gets or sets the animation properties override
  26241. */
  26242. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26243. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26244. /**
  26245. * List of inspectable custom properties (used by the Inspector)
  26246. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26247. */
  26248. inspectableCustomProperties: IInspectable[];
  26249. /**
  26250. * An observable triggered before computing the skeleton's matrices
  26251. */
  26252. onBeforeComputeObservable: Observable<Skeleton>;
  26253. /**
  26254. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26255. */
  26256. get isUsingTextureForMatrices(): boolean;
  26257. /**
  26258. * Gets the unique ID of this skeleton
  26259. */
  26260. get uniqueId(): number;
  26261. /**
  26262. * Creates a new skeleton
  26263. * @param name defines the skeleton name
  26264. * @param id defines the skeleton Id
  26265. * @param scene defines the hosting scene
  26266. */
  26267. constructor(
  26268. /** defines the skeleton name */
  26269. name: string,
  26270. /** defines the skeleton Id */
  26271. id: string, scene: Scene);
  26272. /**
  26273. * Gets the current object class name.
  26274. * @return the class name
  26275. */
  26276. getClassName(): string;
  26277. /**
  26278. * Returns an array containing the root bones
  26279. * @returns an array containing the root bones
  26280. */
  26281. getChildren(): Array<Bone>;
  26282. /**
  26283. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26284. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26285. * @returns a Float32Array containing matrices data
  26286. */
  26287. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26288. /**
  26289. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26290. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26291. * @returns a raw texture containing the data
  26292. */
  26293. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26294. /**
  26295. * Gets the current hosting scene
  26296. * @returns a scene object
  26297. */
  26298. getScene(): Scene;
  26299. /**
  26300. * Gets a string representing the current skeleton data
  26301. * @param fullDetails defines a boolean indicating if we want a verbose version
  26302. * @returns a string representing the current skeleton data
  26303. */
  26304. toString(fullDetails?: boolean): string;
  26305. /**
  26306. * Get bone's index searching by name
  26307. * @param name defines bone's name to search for
  26308. * @return the indice of the bone. Returns -1 if not found
  26309. */
  26310. getBoneIndexByName(name: string): number;
  26311. /**
  26312. * Create a new animation range
  26313. * @param name defines the name of the range
  26314. * @param from defines the start key
  26315. * @param to defines the end key
  26316. */
  26317. createAnimationRange(name: string, from: number, to: number): void;
  26318. /**
  26319. * Delete a specific animation range
  26320. * @param name defines the name of the range
  26321. * @param deleteFrames defines if frames must be removed as well
  26322. */
  26323. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26324. /**
  26325. * Gets a specific animation range
  26326. * @param name defines the name of the range to look for
  26327. * @returns the requested animation range or null if not found
  26328. */
  26329. getAnimationRange(name: string): Nullable<AnimationRange>;
  26330. /**
  26331. * Gets the list of all animation ranges defined on this skeleton
  26332. * @returns an array
  26333. */
  26334. getAnimationRanges(): Nullable<AnimationRange>[];
  26335. /**
  26336. * Copy animation range from a source skeleton.
  26337. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26338. * @param source defines the source skeleton
  26339. * @param name defines the name of the range to copy
  26340. * @param rescaleAsRequired defines if rescaling must be applied if required
  26341. * @returns true if operation was successful
  26342. */
  26343. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26344. /**
  26345. * Forces the skeleton to go to rest pose
  26346. */
  26347. returnToRest(): void;
  26348. private _getHighestAnimationFrame;
  26349. /**
  26350. * Begin a specific animation range
  26351. * @param name defines the name of the range to start
  26352. * @param loop defines if looping must be turned on (false by default)
  26353. * @param speedRatio defines the speed ratio to apply (1 by default)
  26354. * @param onAnimationEnd defines a callback which will be called when animation will end
  26355. * @returns a new animatable
  26356. */
  26357. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26358. /**
  26359. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26360. * @param skeleton defines the Skeleton containing the animation range to convert
  26361. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26362. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26363. * @returns the original skeleton
  26364. */
  26365. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26366. /** @hidden */
  26367. _markAsDirty(): void;
  26368. /** @hidden */
  26369. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26370. /** @hidden */
  26371. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26372. private _computeTransformMatrices;
  26373. /**
  26374. * Build all resources required to render a skeleton
  26375. */
  26376. prepare(): void;
  26377. /**
  26378. * Gets the list of animatables currently running for this skeleton
  26379. * @returns an array of animatables
  26380. */
  26381. getAnimatables(): IAnimatable[];
  26382. /**
  26383. * Clone the current skeleton
  26384. * @param name defines the name of the new skeleton
  26385. * @param id defines the id of the new skeleton
  26386. * @returns the new skeleton
  26387. */
  26388. clone(name: string, id?: string): Skeleton;
  26389. /**
  26390. * Enable animation blending for this skeleton
  26391. * @param blendingSpeed defines the blending speed to apply
  26392. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26393. */
  26394. enableBlending(blendingSpeed?: number): void;
  26395. /**
  26396. * Releases all resources associated with the current skeleton
  26397. */
  26398. dispose(): void;
  26399. /**
  26400. * Serialize the skeleton in a JSON object
  26401. * @returns a JSON object
  26402. */
  26403. serialize(): any;
  26404. /**
  26405. * Creates a new skeleton from serialized data
  26406. * @param parsedSkeleton defines the serialized data
  26407. * @param scene defines the hosting scene
  26408. * @returns a new skeleton
  26409. */
  26410. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26411. /**
  26412. * Compute all node absolute transforms
  26413. * @param forceUpdate defines if computation must be done even if cache is up to date
  26414. */
  26415. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26416. /**
  26417. * Gets the root pose matrix
  26418. * @returns a matrix
  26419. */
  26420. getPoseMatrix(): Nullable<Matrix>;
  26421. /**
  26422. * Sorts bones per internal index
  26423. */
  26424. sortBones(): void;
  26425. private _sortBones;
  26426. /**
  26427. * Set the current local matrix as the restPose for all bones in the skeleton.
  26428. */
  26429. setCurrentPoseAsRest(): void;
  26430. }
  26431. }
  26432. declare module BABYLON {
  26433. /**
  26434. * Class used to store bone information
  26435. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26436. */
  26437. export class Bone extends Node {
  26438. /**
  26439. * defines the bone name
  26440. */
  26441. name: string;
  26442. private static _tmpVecs;
  26443. private static _tmpQuat;
  26444. private static _tmpMats;
  26445. /**
  26446. * Gets the list of child bones
  26447. */
  26448. children: Bone[];
  26449. /** Gets the animations associated with this bone */
  26450. animations: Animation[];
  26451. /**
  26452. * Gets or sets bone length
  26453. */
  26454. length: number;
  26455. /**
  26456. * @hidden Internal only
  26457. * Set this value to map this bone to a different index in the transform matrices
  26458. * Set this value to -1 to exclude the bone from the transform matrices
  26459. */
  26460. _index: Nullable<number>;
  26461. private _skeleton;
  26462. private _localMatrix;
  26463. private _restPose;
  26464. private _bindPose;
  26465. private _baseMatrix;
  26466. private _absoluteTransform;
  26467. private _invertedAbsoluteTransform;
  26468. private _parent;
  26469. private _scalingDeterminant;
  26470. private _worldTransform;
  26471. private _localScaling;
  26472. private _localRotation;
  26473. private _localPosition;
  26474. private _needToDecompose;
  26475. private _needToCompose;
  26476. /** @hidden */
  26477. _linkedTransformNode: Nullable<TransformNode>;
  26478. /** @hidden */
  26479. _waitingTransformNodeId: Nullable<string>;
  26480. /** @hidden */
  26481. get _matrix(): Matrix;
  26482. /** @hidden */
  26483. set _matrix(value: Matrix);
  26484. /**
  26485. * Create a new bone
  26486. * @param name defines the bone name
  26487. * @param skeleton defines the parent skeleton
  26488. * @param parentBone defines the parent (can be null if the bone is the root)
  26489. * @param localMatrix defines the local matrix
  26490. * @param restPose defines the rest pose matrix
  26491. * @param baseMatrix defines the base matrix
  26492. * @param index defines index of the bone in the hierarchy
  26493. */
  26494. constructor(
  26495. /**
  26496. * defines the bone name
  26497. */
  26498. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26499. /**
  26500. * Gets the current object class name.
  26501. * @return the class name
  26502. */
  26503. getClassName(): string;
  26504. /**
  26505. * Gets the parent skeleton
  26506. * @returns a skeleton
  26507. */
  26508. getSkeleton(): Skeleton;
  26509. /**
  26510. * Gets parent bone
  26511. * @returns a bone or null if the bone is the root of the bone hierarchy
  26512. */
  26513. getParent(): Nullable<Bone>;
  26514. /**
  26515. * Returns an array containing the root bones
  26516. * @returns an array containing the root bones
  26517. */
  26518. getChildren(): Array<Bone>;
  26519. /**
  26520. * Gets the node index in matrix array generated for rendering
  26521. * @returns the node index
  26522. */
  26523. getIndex(): number;
  26524. /**
  26525. * Sets the parent bone
  26526. * @param parent defines the parent (can be null if the bone is the root)
  26527. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26528. */
  26529. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26530. /**
  26531. * Gets the local matrix
  26532. * @returns a matrix
  26533. */
  26534. getLocalMatrix(): Matrix;
  26535. /**
  26536. * Gets the base matrix (initial matrix which remains unchanged)
  26537. * @returns a matrix
  26538. */
  26539. getBaseMatrix(): Matrix;
  26540. /**
  26541. * Gets the rest pose matrix
  26542. * @returns a matrix
  26543. */
  26544. getRestPose(): Matrix;
  26545. /**
  26546. * Sets the rest pose matrix
  26547. * @param matrix the local-space rest pose to set for this bone
  26548. */
  26549. setRestPose(matrix: Matrix): void;
  26550. /**
  26551. * Gets the bind pose matrix
  26552. * @returns the bind pose matrix
  26553. */
  26554. getBindPose(): Matrix;
  26555. /**
  26556. * Sets the bind pose matrix
  26557. * @param matrix the local-space bind pose to set for this bone
  26558. */
  26559. setBindPose(matrix: Matrix): void;
  26560. /**
  26561. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26562. */
  26563. getWorldMatrix(): Matrix;
  26564. /**
  26565. * Sets the local matrix to rest pose matrix
  26566. */
  26567. returnToRest(): void;
  26568. /**
  26569. * Gets the inverse of the absolute transform matrix.
  26570. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26571. * @returns a matrix
  26572. */
  26573. getInvertedAbsoluteTransform(): Matrix;
  26574. /**
  26575. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26576. * @returns a matrix
  26577. */
  26578. getAbsoluteTransform(): Matrix;
  26579. /**
  26580. * Links with the given transform node.
  26581. * The local matrix of this bone is copied from the transform node every frame.
  26582. * @param transformNode defines the transform node to link to
  26583. */
  26584. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26585. /**
  26586. * Gets the node used to drive the bone's transformation
  26587. * @returns a transform node or null
  26588. */
  26589. getTransformNode(): Nullable<TransformNode>;
  26590. /** Gets or sets current position (in local space) */
  26591. get position(): Vector3;
  26592. set position(newPosition: Vector3);
  26593. /** Gets or sets current rotation (in local space) */
  26594. get rotation(): Vector3;
  26595. set rotation(newRotation: Vector3);
  26596. /** Gets or sets current rotation quaternion (in local space) */
  26597. get rotationQuaternion(): Quaternion;
  26598. set rotationQuaternion(newRotation: Quaternion);
  26599. /** Gets or sets current scaling (in local space) */
  26600. get scaling(): Vector3;
  26601. set scaling(newScaling: Vector3);
  26602. /**
  26603. * Gets the animation properties override
  26604. */
  26605. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26606. private _decompose;
  26607. private _compose;
  26608. /**
  26609. * Update the base and local matrices
  26610. * @param matrix defines the new base or local matrix
  26611. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26612. * @param updateLocalMatrix defines if the local matrix should be updated
  26613. */
  26614. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26615. /** @hidden */
  26616. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26617. /**
  26618. * Flag the bone as dirty (Forcing it to update everything)
  26619. */
  26620. markAsDirty(): void;
  26621. /** @hidden */
  26622. _markAsDirtyAndCompose(): void;
  26623. private _markAsDirtyAndDecompose;
  26624. /**
  26625. * Translate the bone in local or world space
  26626. * @param vec The amount to translate the bone
  26627. * @param space The space that the translation is in
  26628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26629. */
  26630. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26631. /**
  26632. * Set the position of the bone in local or world space
  26633. * @param position The position to set the bone
  26634. * @param space The space that the position is in
  26635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26636. */
  26637. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26638. /**
  26639. * Set the absolute position of the bone (world space)
  26640. * @param position The position to set the bone
  26641. * @param mesh The mesh that this bone is attached to
  26642. */
  26643. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26644. /**
  26645. * Scale the bone on the x, y and z axes (in local space)
  26646. * @param x The amount to scale the bone on the x axis
  26647. * @param y The amount to scale the bone on the y axis
  26648. * @param z The amount to scale the bone on the z axis
  26649. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26650. */
  26651. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26652. /**
  26653. * Set the bone scaling in local space
  26654. * @param scale defines the scaling vector
  26655. */
  26656. setScale(scale: Vector3): void;
  26657. /**
  26658. * Gets the current scaling in local space
  26659. * @returns the current scaling vector
  26660. */
  26661. getScale(): Vector3;
  26662. /**
  26663. * Gets the current scaling in local space and stores it in a target vector
  26664. * @param result defines the target vector
  26665. */
  26666. getScaleToRef(result: Vector3): void;
  26667. /**
  26668. * Set the yaw, pitch, and roll of the bone in local or world space
  26669. * @param yaw The rotation of the bone on the y axis
  26670. * @param pitch The rotation of the bone on the x axis
  26671. * @param roll The rotation of the bone on the z axis
  26672. * @param space The space that the axes of rotation are in
  26673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26674. */
  26675. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26676. /**
  26677. * Add a rotation to the bone on an axis in local or world space
  26678. * @param axis The axis to rotate the bone on
  26679. * @param amount The amount to rotate the bone
  26680. * @param space The space that the axis is in
  26681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26682. */
  26683. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26684. /**
  26685. * Set the rotation of the bone to a particular axis angle in local or world space
  26686. * @param axis The axis to rotate the bone on
  26687. * @param angle The angle that the bone should be rotated to
  26688. * @param space The space that the axis is in
  26689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26690. */
  26691. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26692. /**
  26693. * Set the euler rotation of the bone in local or world space
  26694. * @param rotation The euler rotation that the bone should be set to
  26695. * @param space The space that the rotation is in
  26696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26697. */
  26698. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26699. /**
  26700. * Set the quaternion rotation of the bone in local or world space
  26701. * @param quat The quaternion rotation that the bone should be set to
  26702. * @param space The space that the rotation is in
  26703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26704. */
  26705. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26706. /**
  26707. * Set the rotation matrix of the bone in local or world space
  26708. * @param rotMat The rotation matrix that the bone should be set to
  26709. * @param space The space that the rotation is in
  26710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26711. */
  26712. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26713. private _rotateWithMatrix;
  26714. private _getNegativeRotationToRef;
  26715. /**
  26716. * Get the position of the bone in local or world space
  26717. * @param space The space that the returned position is in
  26718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26719. * @returns The position of the bone
  26720. */
  26721. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26722. /**
  26723. * Copy the position of the bone to a vector3 in local or world space
  26724. * @param space The space that the returned position is in
  26725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26726. * @param result The vector3 to copy the position to
  26727. */
  26728. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26729. /**
  26730. * Get the absolute position of the bone (world space)
  26731. * @param mesh The mesh that this bone is attached to
  26732. * @returns The absolute position of the bone
  26733. */
  26734. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26735. /**
  26736. * Copy the absolute position of the bone (world space) to the result param
  26737. * @param mesh The mesh that this bone is attached to
  26738. * @param result The vector3 to copy the absolute position to
  26739. */
  26740. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26741. /**
  26742. * Compute the absolute transforms of this bone and its children
  26743. */
  26744. computeAbsoluteTransforms(): void;
  26745. /**
  26746. * Get the world direction from an axis that is in the local space of the bone
  26747. * @param localAxis The local direction that is used to compute the world direction
  26748. * @param mesh The mesh that this bone is attached to
  26749. * @returns The world direction
  26750. */
  26751. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26752. /**
  26753. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26754. * @param localAxis The local direction that is used to compute the world direction
  26755. * @param mesh The mesh that this bone is attached to
  26756. * @param result The vector3 that the world direction will be copied to
  26757. */
  26758. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26759. /**
  26760. * Get the euler rotation of the bone in local or world space
  26761. * @param space The space that the rotation should be in
  26762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26763. * @returns The euler rotation
  26764. */
  26765. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26766. /**
  26767. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26768. * @param space The space that the rotation should be in
  26769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26770. * @param result The vector3 that the rotation should be copied to
  26771. */
  26772. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26773. /**
  26774. * Get the quaternion rotation of the bone in either local or world space
  26775. * @param space The space that the rotation should be in
  26776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26777. * @returns The quaternion rotation
  26778. */
  26779. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26780. /**
  26781. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26782. * @param space The space that the rotation should be in
  26783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26784. * @param result The quaternion that the rotation should be copied to
  26785. */
  26786. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26787. /**
  26788. * Get the rotation matrix of the bone in local or world space
  26789. * @param space The space that the rotation should be in
  26790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26791. * @returns The rotation matrix
  26792. */
  26793. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26794. /**
  26795. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26796. * @param space The space that the rotation should be in
  26797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26798. * @param result The quaternion that the rotation should be copied to
  26799. */
  26800. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26801. /**
  26802. * Get the world position of a point that is in the local space of the bone
  26803. * @param position The local position
  26804. * @param mesh The mesh that this bone is attached to
  26805. * @returns The world position
  26806. */
  26807. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26808. /**
  26809. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26810. * @param position The local position
  26811. * @param mesh The mesh that this bone is attached to
  26812. * @param result The vector3 that the world position should be copied to
  26813. */
  26814. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26815. /**
  26816. * Get the local position of a point that is in world space
  26817. * @param position The world position
  26818. * @param mesh The mesh that this bone is attached to
  26819. * @returns The local position
  26820. */
  26821. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26822. /**
  26823. * Get the local position of a point that is in world space and copy it to the result param
  26824. * @param position The world position
  26825. * @param mesh The mesh that this bone is attached to
  26826. * @param result The vector3 that the local position should be copied to
  26827. */
  26828. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26829. /**
  26830. * Set the current local matrix as the restPose for this bone.
  26831. */
  26832. setCurrentPoseAsRest(): void;
  26833. }
  26834. }
  26835. declare module BABYLON {
  26836. /**
  26837. * 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.
  26838. * @see https://doc.babylonjs.com/how_to/transformnode
  26839. */
  26840. export class TransformNode extends Node {
  26841. /**
  26842. * Object will not rotate to face the camera
  26843. */
  26844. static BILLBOARDMODE_NONE: number;
  26845. /**
  26846. * Object will rotate to face the camera but only on the x axis
  26847. */
  26848. static BILLBOARDMODE_X: number;
  26849. /**
  26850. * Object will rotate to face the camera but only on the y axis
  26851. */
  26852. static BILLBOARDMODE_Y: number;
  26853. /**
  26854. * Object will rotate to face the camera but only on the z axis
  26855. */
  26856. static BILLBOARDMODE_Z: number;
  26857. /**
  26858. * Object will rotate to face the camera
  26859. */
  26860. static BILLBOARDMODE_ALL: number;
  26861. /**
  26862. * Object will rotate to face the camera's position instead of orientation
  26863. */
  26864. static BILLBOARDMODE_USE_POSITION: number;
  26865. private static _TmpRotation;
  26866. private static _TmpScaling;
  26867. private static _TmpTranslation;
  26868. private _forward;
  26869. private _forwardInverted;
  26870. private _up;
  26871. private _right;
  26872. private _rightInverted;
  26873. private _position;
  26874. private _rotation;
  26875. private _rotationQuaternion;
  26876. protected _scaling: Vector3;
  26877. protected _isDirty: boolean;
  26878. private _transformToBoneReferal;
  26879. private _isAbsoluteSynced;
  26880. private _billboardMode;
  26881. /**
  26882. * Gets or sets the billboard mode. Default is 0.
  26883. *
  26884. * | Value | Type | Description |
  26885. * | --- | --- | --- |
  26886. * | 0 | BILLBOARDMODE_NONE | |
  26887. * | 1 | BILLBOARDMODE_X | |
  26888. * | 2 | BILLBOARDMODE_Y | |
  26889. * | 4 | BILLBOARDMODE_Z | |
  26890. * | 7 | BILLBOARDMODE_ALL | |
  26891. *
  26892. */
  26893. get billboardMode(): number;
  26894. set billboardMode(value: number);
  26895. private _preserveParentRotationForBillboard;
  26896. /**
  26897. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26898. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26899. */
  26900. get preserveParentRotationForBillboard(): boolean;
  26901. set preserveParentRotationForBillboard(value: boolean);
  26902. /**
  26903. * 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
  26904. */
  26905. scalingDeterminant: number;
  26906. private _infiniteDistance;
  26907. /**
  26908. * Gets or sets the distance of the object to max, often used by skybox
  26909. */
  26910. get infiniteDistance(): boolean;
  26911. set infiniteDistance(value: boolean);
  26912. /**
  26913. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26914. * By default the system will update normals to compensate
  26915. */
  26916. ignoreNonUniformScaling: boolean;
  26917. /**
  26918. * 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
  26919. */
  26920. reIntegrateRotationIntoRotationQuaternion: boolean;
  26921. /** @hidden */
  26922. _poseMatrix: Nullable<Matrix>;
  26923. /** @hidden */
  26924. _localMatrix: Matrix;
  26925. private _usePivotMatrix;
  26926. private _absolutePosition;
  26927. private _absoluteScaling;
  26928. private _absoluteRotationQuaternion;
  26929. private _pivotMatrix;
  26930. private _pivotMatrixInverse;
  26931. /** @hidden */
  26932. _postMultiplyPivotMatrix: boolean;
  26933. protected _isWorldMatrixFrozen: boolean;
  26934. /** @hidden */
  26935. _indexInSceneTransformNodesArray: number;
  26936. /**
  26937. * An event triggered after the world matrix is updated
  26938. */
  26939. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26940. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26941. /**
  26942. * Gets a string identifying the name of the class
  26943. * @returns "TransformNode" string
  26944. */
  26945. getClassName(): string;
  26946. /**
  26947. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26948. */
  26949. get position(): Vector3;
  26950. set position(newPosition: Vector3);
  26951. /**
  26952. * 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)).
  26953. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26954. */
  26955. get rotation(): Vector3;
  26956. set rotation(newRotation: Vector3);
  26957. /**
  26958. * 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)).
  26959. */
  26960. get scaling(): Vector3;
  26961. set scaling(newScaling: Vector3);
  26962. /**
  26963. * 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).
  26964. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26965. */
  26966. get rotationQuaternion(): Nullable<Quaternion>;
  26967. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26968. /**
  26969. * The forward direction of that transform in world space.
  26970. */
  26971. get forward(): Vector3;
  26972. /**
  26973. * The up direction of that transform in world space.
  26974. */
  26975. get up(): Vector3;
  26976. /**
  26977. * The right direction of that transform in world space.
  26978. */
  26979. get right(): Vector3;
  26980. /**
  26981. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26982. * @param matrix the matrix to copy the pose from
  26983. * @returns this TransformNode.
  26984. */
  26985. updatePoseMatrix(matrix: Matrix): TransformNode;
  26986. /**
  26987. * Returns the mesh Pose matrix.
  26988. * @returns the pose matrix
  26989. */
  26990. getPoseMatrix(): Matrix;
  26991. /** @hidden */
  26992. _isSynchronized(): boolean;
  26993. /** @hidden */
  26994. _initCache(): void;
  26995. /**
  26996. * Flag the transform node as dirty (Forcing it to update everything)
  26997. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26998. * @returns this transform node
  26999. */
  27000. markAsDirty(property: string): TransformNode;
  27001. /**
  27002. * Returns the current mesh absolute position.
  27003. * Returns a Vector3.
  27004. */
  27005. get absolutePosition(): Vector3;
  27006. /**
  27007. * Returns the current mesh absolute scaling.
  27008. * Returns a Vector3.
  27009. */
  27010. get absoluteScaling(): Vector3;
  27011. /**
  27012. * Returns the current mesh absolute rotation.
  27013. * Returns a Quaternion.
  27014. */
  27015. get absoluteRotationQuaternion(): Quaternion;
  27016. /**
  27017. * Sets a new matrix to apply before all other transformation
  27018. * @param matrix defines the transform matrix
  27019. * @returns the current TransformNode
  27020. */
  27021. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27022. /**
  27023. * Sets a new pivot matrix to the current node
  27024. * @param matrix defines the new pivot matrix to use
  27025. * @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
  27026. * @returns the current TransformNode
  27027. */
  27028. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27029. /**
  27030. * Returns the mesh pivot matrix.
  27031. * Default : Identity.
  27032. * @returns the matrix
  27033. */
  27034. getPivotMatrix(): Matrix;
  27035. /**
  27036. * Instantiate (when possible) or clone that node with its hierarchy
  27037. * @param newParent defines the new parent to use for the instance (or clone)
  27038. * @param options defines options to configure how copy is done
  27039. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27040. * @returns an instance (or a clone) of the current node with its hiearchy
  27041. */
  27042. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27043. doNotInstantiate: boolean;
  27044. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27045. /**
  27046. * Prevents the World matrix to be computed any longer
  27047. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27048. * @returns the TransformNode.
  27049. */
  27050. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27051. /**
  27052. * Allows back the World matrix computation.
  27053. * @returns the TransformNode.
  27054. */
  27055. unfreezeWorldMatrix(): this;
  27056. /**
  27057. * True if the World matrix has been frozen.
  27058. */
  27059. get isWorldMatrixFrozen(): boolean;
  27060. /**
  27061. * Returns the mesh absolute position in the World.
  27062. * @returns a Vector3.
  27063. */
  27064. getAbsolutePosition(): Vector3;
  27065. /**
  27066. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27067. * @param absolutePosition the absolute position to set
  27068. * @returns the TransformNode.
  27069. */
  27070. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27071. /**
  27072. * Sets the mesh position in its local space.
  27073. * @param vector3 the position to set in localspace
  27074. * @returns the TransformNode.
  27075. */
  27076. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27077. /**
  27078. * Returns the mesh position in the local space from the current World matrix values.
  27079. * @returns a new Vector3.
  27080. */
  27081. getPositionExpressedInLocalSpace(): Vector3;
  27082. /**
  27083. * Translates the mesh along the passed Vector3 in its local space.
  27084. * @param vector3 the distance to translate in localspace
  27085. * @returns the TransformNode.
  27086. */
  27087. locallyTranslate(vector3: Vector3): TransformNode;
  27088. private static _lookAtVectorCache;
  27089. /**
  27090. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27091. * @param targetPoint the position (must be in same space as current mesh) to look at
  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. * @param space the chosen space of the target
  27096. * @returns the TransformNode.
  27097. */
  27098. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27099. /**
  27100. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27101. * This Vector3 is expressed in the World space.
  27102. * @param localAxis axis to rotate
  27103. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27104. */
  27105. getDirection(localAxis: Vector3): Vector3;
  27106. /**
  27107. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27108. * localAxis is expressed in the mesh local space.
  27109. * result is computed in the Wordl space from the mesh World matrix.
  27110. * @param localAxis axis to rotate
  27111. * @param result the resulting transformnode
  27112. * @returns this TransformNode.
  27113. */
  27114. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27115. /**
  27116. * Sets this transform node rotation to the given local axis.
  27117. * @param localAxis the axis in local space
  27118. * @param yawCor optional yaw (y-axis) correction in radians
  27119. * @param pitchCor optional pitch (x-axis) correction in radians
  27120. * @param rollCor optional roll (z-axis) correction in radians
  27121. * @returns this TransformNode
  27122. */
  27123. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27124. /**
  27125. * Sets a new pivot point to the current node
  27126. * @param point defines the new pivot point to use
  27127. * @param space defines if the point is in world or local space (local by default)
  27128. * @returns the current TransformNode
  27129. */
  27130. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27131. /**
  27132. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27133. * @returns the pivot point
  27134. */
  27135. getPivotPoint(): Vector3;
  27136. /**
  27137. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27138. * @param result the vector3 to store the result
  27139. * @returns this TransformNode.
  27140. */
  27141. getPivotPointToRef(result: Vector3): TransformNode;
  27142. /**
  27143. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27144. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27145. */
  27146. getAbsolutePivotPoint(): Vector3;
  27147. /**
  27148. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27149. * @param result vector3 to store the result
  27150. * @returns this TransformNode.
  27151. */
  27152. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27153. /**
  27154. * Defines the passed node as the parent of the current node.
  27155. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27156. * @see https://doc.babylonjs.com/how_to/parenting
  27157. * @param node the node ot set as the parent
  27158. * @returns this TransformNode.
  27159. */
  27160. setParent(node: Nullable<Node>): TransformNode;
  27161. private _nonUniformScaling;
  27162. /**
  27163. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27164. */
  27165. get nonUniformScaling(): boolean;
  27166. /** @hidden */
  27167. _updateNonUniformScalingState(value: boolean): boolean;
  27168. /**
  27169. * Attach the current TransformNode to another TransformNode associated with a bone
  27170. * @param bone Bone affecting the TransformNode
  27171. * @param affectedTransformNode TransformNode associated with the bone
  27172. * @returns this object
  27173. */
  27174. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27175. /**
  27176. * Detach the transform node if its associated with a bone
  27177. * @returns this object
  27178. */
  27179. detachFromBone(): TransformNode;
  27180. private static _rotationAxisCache;
  27181. /**
  27182. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27183. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27184. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27185. * The passed axis is also normalized.
  27186. * @param axis the axis to rotate around
  27187. * @param amount the amount to rotate in radians
  27188. * @param space Space to rotate in (Default: local)
  27189. * @returns the TransformNode.
  27190. */
  27191. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27192. /**
  27193. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27194. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27195. * The passed axis is also normalized. .
  27196. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27197. * @param point the point to rotate around
  27198. * @param axis the axis to rotate around
  27199. * @param amount the amount to rotate in radians
  27200. * @returns the TransformNode
  27201. */
  27202. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27203. /**
  27204. * Translates the mesh along the axis vector for the passed distance in the given space.
  27205. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27206. * @param axis the axis to translate in
  27207. * @param distance the distance to translate
  27208. * @param space Space to rotate in (Default: local)
  27209. * @returns the TransformNode.
  27210. */
  27211. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27212. /**
  27213. * Adds a rotation step to the mesh current rotation.
  27214. * x, y, z are Euler angles expressed in radians.
  27215. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27216. * This means this rotation is made in the mesh local space only.
  27217. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27218. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27219. * ```javascript
  27220. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27221. * ```
  27222. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27223. * 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.
  27224. * @param x Rotation to add
  27225. * @param y Rotation to add
  27226. * @param z Rotation to add
  27227. * @returns the TransformNode.
  27228. */
  27229. addRotation(x: number, y: number, z: number): TransformNode;
  27230. /**
  27231. * @hidden
  27232. */
  27233. protected _getEffectiveParent(): Nullable<Node>;
  27234. /**
  27235. * Computes the world matrix of the node
  27236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27237. * @returns the world matrix
  27238. */
  27239. computeWorldMatrix(force?: boolean): Matrix;
  27240. /**
  27241. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27242. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27243. */
  27244. resetLocalMatrix(independentOfChildren?: boolean): void;
  27245. protected _afterComputeWorldMatrix(): void;
  27246. /**
  27247. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27248. * @param func callback function to add
  27249. *
  27250. * @returns the TransformNode.
  27251. */
  27252. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27253. /**
  27254. * Removes a registered callback function.
  27255. * @param func callback function to remove
  27256. * @returns the TransformNode.
  27257. */
  27258. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27259. /**
  27260. * Gets the position of the current mesh in camera space
  27261. * @param camera defines the camera to use
  27262. * @returns a position
  27263. */
  27264. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27265. /**
  27266. * Returns the distance from the mesh to the active camera
  27267. * @param camera defines the camera to use
  27268. * @returns the distance
  27269. */
  27270. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27271. /**
  27272. * Clone the current transform node
  27273. * @param name Name of the new clone
  27274. * @param newParent New parent for the clone
  27275. * @param doNotCloneChildren Do not clone children hierarchy
  27276. * @returns the new transform node
  27277. */
  27278. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27279. /**
  27280. * Serializes the objects information.
  27281. * @param currentSerializationObject defines the object to serialize in
  27282. * @returns the serialized object
  27283. */
  27284. serialize(currentSerializationObject?: any): any;
  27285. /**
  27286. * Returns a new TransformNode object parsed from the source provided.
  27287. * @param parsedTransformNode is the source.
  27288. * @param scene the scene the object belongs to
  27289. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27290. * @returns a new TransformNode object parsed from the source provided.
  27291. */
  27292. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27293. /**
  27294. * Get all child-transformNodes of this node
  27295. * @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
  27296. * @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
  27297. * @returns an array of TransformNode
  27298. */
  27299. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27300. /**
  27301. * Releases resources associated with this transform node.
  27302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27304. */
  27305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27306. /**
  27307. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27308. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27309. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27310. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27311. * @returns the current mesh
  27312. */
  27313. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27314. private _syncAbsoluteScalingAndRotation;
  27315. }
  27316. }
  27317. declare module BABYLON {
  27318. /**
  27319. * Defines the types of pose enabled controllers that are supported
  27320. */
  27321. export enum PoseEnabledControllerType {
  27322. /**
  27323. * HTC Vive
  27324. */
  27325. VIVE = 0,
  27326. /**
  27327. * Oculus Rift
  27328. */
  27329. OCULUS = 1,
  27330. /**
  27331. * Windows mixed reality
  27332. */
  27333. WINDOWS = 2,
  27334. /**
  27335. * Samsung gear VR
  27336. */
  27337. GEAR_VR = 3,
  27338. /**
  27339. * Google Daydream
  27340. */
  27341. DAYDREAM = 4,
  27342. /**
  27343. * Generic
  27344. */
  27345. GENERIC = 5
  27346. }
  27347. /**
  27348. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27349. */
  27350. export interface MutableGamepadButton {
  27351. /**
  27352. * Value of the button/trigger
  27353. */
  27354. value: number;
  27355. /**
  27356. * If the button/trigger is currently touched
  27357. */
  27358. touched: boolean;
  27359. /**
  27360. * If the button/trigger is currently pressed
  27361. */
  27362. pressed: boolean;
  27363. }
  27364. /**
  27365. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27366. * @hidden
  27367. */
  27368. export interface ExtendedGamepadButton extends GamepadButton {
  27369. /**
  27370. * If the button/trigger is currently pressed
  27371. */
  27372. readonly pressed: boolean;
  27373. /**
  27374. * If the button/trigger is currently touched
  27375. */
  27376. readonly touched: boolean;
  27377. /**
  27378. * Value of the button/trigger
  27379. */
  27380. readonly value: number;
  27381. }
  27382. /** @hidden */
  27383. export interface _GamePadFactory {
  27384. /**
  27385. * Returns whether or not the current gamepad can be created for this type of controller.
  27386. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27387. * @returns true if it can be created, otherwise false
  27388. */
  27389. canCreate(gamepadInfo: any): boolean;
  27390. /**
  27391. * Creates a new instance of the Gamepad.
  27392. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27393. * @returns the new gamepad instance
  27394. */
  27395. create(gamepadInfo: any): Gamepad;
  27396. }
  27397. /**
  27398. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27399. */
  27400. export class PoseEnabledControllerHelper {
  27401. /** @hidden */
  27402. static _ControllerFactories: _GamePadFactory[];
  27403. /** @hidden */
  27404. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27405. /**
  27406. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27407. * @param vrGamepad the gamepad to initialized
  27408. * @returns a vr controller of the type the gamepad identified as
  27409. */
  27410. static InitiateController(vrGamepad: any): Gamepad;
  27411. }
  27412. /**
  27413. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27414. */
  27415. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27416. /**
  27417. * If the controller is used in a webXR session
  27418. */
  27419. isXR: boolean;
  27420. private _deviceRoomPosition;
  27421. private _deviceRoomRotationQuaternion;
  27422. /**
  27423. * The device position in babylon space
  27424. */
  27425. devicePosition: Vector3;
  27426. /**
  27427. * The device rotation in babylon space
  27428. */
  27429. deviceRotationQuaternion: Quaternion;
  27430. /**
  27431. * The scale factor of the device in babylon space
  27432. */
  27433. deviceScaleFactor: number;
  27434. /**
  27435. * (Likely devicePosition should be used instead) The device position in its room space
  27436. */
  27437. position: Vector3;
  27438. /**
  27439. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27440. */
  27441. rotationQuaternion: Quaternion;
  27442. /**
  27443. * The type of controller (Eg. Windows mixed reality)
  27444. */
  27445. controllerType: PoseEnabledControllerType;
  27446. protected _calculatedPosition: Vector3;
  27447. private _calculatedRotation;
  27448. /**
  27449. * The raw pose from the device
  27450. */
  27451. rawPose: DevicePose;
  27452. private _trackPosition;
  27453. private _maxRotationDistFromHeadset;
  27454. private _draggedRoomRotation;
  27455. /**
  27456. * @hidden
  27457. */
  27458. _disableTrackPosition(fixedPosition: Vector3): void;
  27459. /**
  27460. * Internal, the mesh attached to the controller
  27461. * @hidden
  27462. */
  27463. _mesh: Nullable<AbstractMesh>;
  27464. private _poseControlledCamera;
  27465. private _leftHandSystemQuaternion;
  27466. /**
  27467. * Internal, matrix used to convert room space to babylon space
  27468. * @hidden
  27469. */
  27470. _deviceToWorld: Matrix;
  27471. /**
  27472. * Node to be used when casting a ray from the controller
  27473. * @hidden
  27474. */
  27475. _pointingPoseNode: Nullable<TransformNode>;
  27476. /**
  27477. * Name of the child mesh that can be used to cast a ray from the controller
  27478. */
  27479. static readonly POINTING_POSE: string;
  27480. /**
  27481. * Creates a new PoseEnabledController from a gamepad
  27482. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27483. */
  27484. constructor(browserGamepad: any);
  27485. private _workingMatrix;
  27486. /**
  27487. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27488. */
  27489. update(): void;
  27490. /**
  27491. * Updates only the pose device and mesh without doing any button event checking
  27492. */
  27493. protected _updatePoseAndMesh(): void;
  27494. /**
  27495. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27496. * @param poseData raw pose fromthe device
  27497. */
  27498. updateFromDevice(poseData: DevicePose): void;
  27499. /**
  27500. * @hidden
  27501. */
  27502. _meshAttachedObservable: Observable<AbstractMesh>;
  27503. /**
  27504. * Attaches a mesh to the controller
  27505. * @param mesh the mesh to be attached
  27506. */
  27507. attachToMesh(mesh: AbstractMesh): void;
  27508. /**
  27509. * Attaches the controllers mesh to a camera
  27510. * @param camera the camera the mesh should be attached to
  27511. */
  27512. attachToPoseControlledCamera(camera: TargetCamera): void;
  27513. /**
  27514. * Disposes of the controller
  27515. */
  27516. dispose(): void;
  27517. /**
  27518. * The mesh that is attached to the controller
  27519. */
  27520. get mesh(): Nullable<AbstractMesh>;
  27521. /**
  27522. * Gets the ray of the controller in the direction the controller is pointing
  27523. * @param length the length the resulting ray should be
  27524. * @returns a ray in the direction the controller is pointing
  27525. */
  27526. getForwardRay(length?: number): Ray;
  27527. }
  27528. }
  27529. declare module BABYLON {
  27530. /**
  27531. * Defines the WebVRController object that represents controllers tracked in 3D space
  27532. */
  27533. export abstract class WebVRController extends PoseEnabledController {
  27534. /**
  27535. * Internal, the default controller model for the controller
  27536. */
  27537. protected _defaultModel: Nullable<AbstractMesh>;
  27538. /**
  27539. * Fired when the trigger state has changed
  27540. */
  27541. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27542. /**
  27543. * Fired when the main button state has changed
  27544. */
  27545. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27546. /**
  27547. * Fired when the secondary button state has changed
  27548. */
  27549. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27550. /**
  27551. * Fired when the pad state has changed
  27552. */
  27553. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27554. /**
  27555. * Fired when controllers stick values have changed
  27556. */
  27557. onPadValuesChangedObservable: Observable<StickValues>;
  27558. /**
  27559. * Array of button availible on the controller
  27560. */
  27561. protected _buttons: Array<MutableGamepadButton>;
  27562. private _onButtonStateChange;
  27563. /**
  27564. * Fired when a controller button's state has changed
  27565. * @param callback the callback containing the button that was modified
  27566. */
  27567. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27568. /**
  27569. * X and Y axis corresponding to the controllers joystick
  27570. */
  27571. pad: StickValues;
  27572. /**
  27573. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27574. */
  27575. hand: string;
  27576. /**
  27577. * The default controller model for the controller
  27578. */
  27579. get defaultModel(): Nullable<AbstractMesh>;
  27580. /**
  27581. * Creates a new WebVRController from a gamepad
  27582. * @param vrGamepad the gamepad that the WebVRController should be created from
  27583. */
  27584. constructor(vrGamepad: any);
  27585. /**
  27586. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27587. */
  27588. update(): void;
  27589. /**
  27590. * Function to be called when a button is modified
  27591. */
  27592. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27593. /**
  27594. * Loads a mesh and attaches it to the controller
  27595. * @param scene the scene the mesh should be added to
  27596. * @param meshLoaded callback for when the mesh has been loaded
  27597. */
  27598. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27599. private _setButtonValue;
  27600. private _changes;
  27601. private _checkChanges;
  27602. /**
  27603. * Disposes of th webVRCOntroller
  27604. */
  27605. dispose(): void;
  27606. }
  27607. }
  27608. declare module BABYLON {
  27609. /**
  27610. * The HemisphericLight simulates the ambient environment light,
  27611. * so the passed direction is the light reflection direction, not the incoming direction.
  27612. */
  27613. export class HemisphericLight extends Light {
  27614. /**
  27615. * The groundColor is the light in the opposite direction to the one specified during creation.
  27616. * 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.
  27617. */
  27618. groundColor: Color3;
  27619. /**
  27620. * The light reflection direction, not the incoming direction.
  27621. */
  27622. direction: Vector3;
  27623. /**
  27624. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27625. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27626. * The HemisphericLight can't cast shadows.
  27627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27628. * @param name The friendly name of the light
  27629. * @param direction The direction of the light reflection
  27630. * @param scene The scene the light belongs to
  27631. */
  27632. constructor(name: string, direction: Vector3, scene: Scene);
  27633. protected _buildUniformLayout(): void;
  27634. /**
  27635. * Returns the string "HemisphericLight".
  27636. * @return The class name
  27637. */
  27638. getClassName(): string;
  27639. /**
  27640. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27641. * Returns the updated direction.
  27642. * @param target The target the direction should point to
  27643. * @return The computed direction
  27644. */
  27645. setDirectionToTarget(target: Vector3): Vector3;
  27646. /**
  27647. * Returns the shadow generator associated to the light.
  27648. * @returns Always null for hemispheric lights because it does not support shadows.
  27649. */
  27650. getShadowGenerator(): Nullable<IShadowGenerator>;
  27651. /**
  27652. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27653. * @param effect The effect to update
  27654. * @param lightIndex The index of the light in the effect to update
  27655. * @returns The hemispheric light
  27656. */
  27657. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27658. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27659. /**
  27660. * Computes the world matrix of the node
  27661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27662. * @param useWasUpdatedFlag defines a reserved property
  27663. * @returns the world matrix
  27664. */
  27665. computeWorldMatrix(): Matrix;
  27666. /**
  27667. * Returns the integer 3.
  27668. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27669. */
  27670. getTypeID(): number;
  27671. /**
  27672. * Prepares the list of defines specific to the light type.
  27673. * @param defines the list of defines
  27674. * @param lightIndex defines the index of the light for the effect
  27675. */
  27676. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27677. }
  27678. }
  27679. declare module BABYLON {
  27680. /** @hidden */
  27681. export var vrMultiviewToSingleviewPixelShader: {
  27682. name: string;
  27683. shader: string;
  27684. };
  27685. }
  27686. declare module BABYLON {
  27687. /**
  27688. * Renders to multiple views with a single draw call
  27689. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27690. */
  27691. export class MultiviewRenderTarget extends RenderTargetTexture {
  27692. /**
  27693. * Creates a multiview render target
  27694. * @param scene scene used with the render target
  27695. * @param size the size of the render target (used for each view)
  27696. */
  27697. constructor(scene: Scene, size?: number | {
  27698. width: number;
  27699. height: number;
  27700. } | {
  27701. ratio: number;
  27702. });
  27703. /**
  27704. * @hidden
  27705. * @param faceIndex the face index, if its a cube texture
  27706. */
  27707. _bindFrameBuffer(faceIndex?: number): void;
  27708. /**
  27709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27710. * @returns the view count
  27711. */
  27712. getViewCount(): number;
  27713. }
  27714. }
  27715. declare module BABYLON {
  27716. interface Engine {
  27717. /**
  27718. * Creates a new multiview render target
  27719. * @param width defines the width of the texture
  27720. * @param height defines the height of the texture
  27721. * @returns the created multiview texture
  27722. */
  27723. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27724. /**
  27725. * Binds a multiview framebuffer to be drawn to
  27726. * @param multiviewTexture texture to bind
  27727. */
  27728. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27729. }
  27730. interface Camera {
  27731. /**
  27732. * @hidden
  27733. * 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)
  27734. */
  27735. _useMultiviewToSingleView: boolean;
  27736. /**
  27737. * @hidden
  27738. * 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)
  27739. */
  27740. _multiviewTexture: Nullable<RenderTargetTexture>;
  27741. /**
  27742. * @hidden
  27743. * ensures the multiview texture of the camera exists and has the specified width/height
  27744. * @param width height to set on the multiview texture
  27745. * @param height width to set on the multiview texture
  27746. */
  27747. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27748. }
  27749. interface Scene {
  27750. /** @hidden */
  27751. _transformMatrixR: Matrix;
  27752. /** @hidden */
  27753. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27754. /** @hidden */
  27755. _createMultiviewUbo(): void;
  27756. /** @hidden */
  27757. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27758. /** @hidden */
  27759. _renderMultiviewToSingleView(camera: Camera): void;
  27760. }
  27761. }
  27762. declare module BABYLON {
  27763. /**
  27764. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27765. * This will not be used for webXR as it supports displaying texture arrays directly
  27766. */
  27767. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27768. /**
  27769. * Gets a string identifying the name of the class
  27770. * @returns "VRMultiviewToSingleviewPostProcess" string
  27771. */
  27772. getClassName(): string;
  27773. /**
  27774. * Initializes a VRMultiviewToSingleview
  27775. * @param name name of the post process
  27776. * @param camera camera to be applied to
  27777. * @param scaleFactor scaling factor to the size of the output texture
  27778. */
  27779. constructor(name: string, camera: Camera, scaleFactor: number);
  27780. }
  27781. }
  27782. declare module BABYLON {
  27783. /**
  27784. * Interface used to define additional presentation attributes
  27785. */
  27786. export interface IVRPresentationAttributes {
  27787. /**
  27788. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27789. */
  27790. highRefreshRate: boolean;
  27791. /**
  27792. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27793. */
  27794. foveationLevel: number;
  27795. }
  27796. interface Engine {
  27797. /** @hidden */
  27798. _vrDisplay: any;
  27799. /** @hidden */
  27800. _vrSupported: boolean;
  27801. /** @hidden */
  27802. _oldSize: Size;
  27803. /** @hidden */
  27804. _oldHardwareScaleFactor: number;
  27805. /** @hidden */
  27806. _vrExclusivePointerMode: boolean;
  27807. /** @hidden */
  27808. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27809. /** @hidden */
  27810. _onVRDisplayPointerRestricted: () => void;
  27811. /** @hidden */
  27812. _onVRDisplayPointerUnrestricted: () => void;
  27813. /** @hidden */
  27814. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27815. /** @hidden */
  27816. _onVrDisplayDisconnect: Nullable<() => void>;
  27817. /** @hidden */
  27818. _onVrDisplayPresentChange: Nullable<() => void>;
  27819. /**
  27820. * Observable signaled when VR display mode changes
  27821. */
  27822. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27823. /**
  27824. * Observable signaled when VR request present is complete
  27825. */
  27826. onVRRequestPresentComplete: Observable<boolean>;
  27827. /**
  27828. * Observable signaled when VR request present starts
  27829. */
  27830. onVRRequestPresentStart: Observable<Engine>;
  27831. /**
  27832. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27833. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27834. */
  27835. isInVRExclusivePointerMode: boolean;
  27836. /**
  27837. * Gets a boolean indicating if a webVR device was detected
  27838. * @returns true if a webVR device was detected
  27839. */
  27840. isVRDevicePresent(): boolean;
  27841. /**
  27842. * Gets the current webVR device
  27843. * @returns the current webVR device (or null)
  27844. */
  27845. getVRDevice(): any;
  27846. /**
  27847. * Initializes a webVR display and starts listening to display change events
  27848. * The onVRDisplayChangedObservable will be notified upon these changes
  27849. * @returns A promise containing a VRDisplay and if vr is supported
  27850. */
  27851. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27852. /** @hidden */
  27853. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27854. /**
  27855. * Gets or sets the presentation attributes used to configure VR rendering
  27856. */
  27857. vrPresentationAttributes?: IVRPresentationAttributes;
  27858. /**
  27859. * Call this function to switch to webVR mode
  27860. * Will do nothing if webVR is not supported or if there is no webVR device
  27861. * @param options the webvr options provided to the camera. mainly used for multiview
  27862. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27863. */
  27864. enableVR(options: WebVROptions): void;
  27865. /** @hidden */
  27866. _onVRFullScreenTriggered(): void;
  27867. }
  27868. }
  27869. declare module BABYLON {
  27870. /**
  27871. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27872. * IMPORTANT!! The data is right-hand data.
  27873. * @export
  27874. * @interface DevicePose
  27875. */
  27876. export interface DevicePose {
  27877. /**
  27878. * The position of the device, values in array are [x,y,z].
  27879. */
  27880. readonly position: Nullable<Float32Array>;
  27881. /**
  27882. * The linearVelocity of the device, values in array are [x,y,z].
  27883. */
  27884. readonly linearVelocity: Nullable<Float32Array>;
  27885. /**
  27886. * The linearAcceleration of the device, values in array are [x,y,z].
  27887. */
  27888. readonly linearAcceleration: Nullable<Float32Array>;
  27889. /**
  27890. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27891. */
  27892. readonly orientation: Nullable<Float32Array>;
  27893. /**
  27894. * The angularVelocity of the device, values in array are [x,y,z].
  27895. */
  27896. readonly angularVelocity: Nullable<Float32Array>;
  27897. /**
  27898. * The angularAcceleration of the device, values in array are [x,y,z].
  27899. */
  27900. readonly angularAcceleration: Nullable<Float32Array>;
  27901. }
  27902. /**
  27903. * Interface representing a pose controlled object in Babylon.
  27904. * A pose controlled object has both regular pose values as well as pose values
  27905. * from an external device such as a VR head mounted display
  27906. */
  27907. export interface PoseControlled {
  27908. /**
  27909. * The position of the object in babylon space.
  27910. */
  27911. position: Vector3;
  27912. /**
  27913. * The rotation quaternion of the object in babylon space.
  27914. */
  27915. rotationQuaternion: Quaternion;
  27916. /**
  27917. * The position of the device in babylon space.
  27918. */
  27919. devicePosition?: Vector3;
  27920. /**
  27921. * The rotation quaternion of the device in babylon space.
  27922. */
  27923. deviceRotationQuaternion: Quaternion;
  27924. /**
  27925. * The raw pose coming from the device.
  27926. */
  27927. rawPose: Nullable<DevicePose>;
  27928. /**
  27929. * The scale of the device to be used when translating from device space to babylon space.
  27930. */
  27931. deviceScaleFactor: number;
  27932. /**
  27933. * Updates the poseControlled values based on the input device pose.
  27934. * @param poseData the pose data to update the object with
  27935. */
  27936. updateFromDevice(poseData: DevicePose): void;
  27937. }
  27938. /**
  27939. * Set of options to customize the webVRCamera
  27940. */
  27941. export interface WebVROptions {
  27942. /**
  27943. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27944. */
  27945. trackPosition?: boolean;
  27946. /**
  27947. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27948. */
  27949. positionScale?: number;
  27950. /**
  27951. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27952. */
  27953. displayName?: string;
  27954. /**
  27955. * Should the native controller meshes be initialized. (default: true)
  27956. */
  27957. controllerMeshes?: boolean;
  27958. /**
  27959. * Creating a default HemiLight only on controllers. (default: true)
  27960. */
  27961. defaultLightingOnControllers?: boolean;
  27962. /**
  27963. * If you don't want to use the default VR button of the helper. (default: false)
  27964. */
  27965. useCustomVRButton?: boolean;
  27966. /**
  27967. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27968. */
  27969. customVRButton?: HTMLButtonElement;
  27970. /**
  27971. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27972. */
  27973. rayLength?: number;
  27974. /**
  27975. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27976. */
  27977. defaultHeight?: number;
  27978. /**
  27979. * If multiview should be used if available (default: false)
  27980. */
  27981. useMultiview?: boolean;
  27982. }
  27983. /**
  27984. * This represents a WebVR camera.
  27985. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27986. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27987. */
  27988. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27989. private webVROptions;
  27990. /**
  27991. * @hidden
  27992. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27993. */
  27994. _vrDevice: any;
  27995. /**
  27996. * The rawPose of the vrDevice.
  27997. */
  27998. rawPose: Nullable<DevicePose>;
  27999. private _onVREnabled;
  28000. private _specsVersion;
  28001. private _attached;
  28002. private _frameData;
  28003. protected _descendants: Array<Node>;
  28004. private _deviceRoomPosition;
  28005. /** @hidden */
  28006. _deviceRoomRotationQuaternion: Quaternion;
  28007. private _standingMatrix;
  28008. /**
  28009. * Represents device position in babylon space.
  28010. */
  28011. devicePosition: Vector3;
  28012. /**
  28013. * Represents device rotation in babylon space.
  28014. */
  28015. deviceRotationQuaternion: Quaternion;
  28016. /**
  28017. * The scale of the device to be used when translating from device space to babylon space.
  28018. */
  28019. deviceScaleFactor: number;
  28020. private _deviceToWorld;
  28021. private _worldToDevice;
  28022. /**
  28023. * References to the webVR controllers for the vrDevice.
  28024. */
  28025. controllers: Array<WebVRController>;
  28026. /**
  28027. * Emits an event when a controller is attached.
  28028. */
  28029. onControllersAttachedObservable: Observable<WebVRController[]>;
  28030. /**
  28031. * Emits an event when a controller's mesh has been loaded;
  28032. */
  28033. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28034. /**
  28035. * Emits an event when the HMD's pose has been updated.
  28036. */
  28037. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28038. private _poseSet;
  28039. /**
  28040. * If the rig cameras be used as parent instead of this camera.
  28041. */
  28042. rigParenting: boolean;
  28043. private _lightOnControllers;
  28044. private _defaultHeight?;
  28045. /**
  28046. * Instantiates a WebVRFreeCamera.
  28047. * @param name The name of the WebVRFreeCamera
  28048. * @param position The starting anchor position for the camera
  28049. * @param scene The scene the camera belongs to
  28050. * @param webVROptions a set of customizable options for the webVRCamera
  28051. */
  28052. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28053. /**
  28054. * Gets the device distance from the ground in meters.
  28055. * @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.
  28056. */
  28057. deviceDistanceToRoomGround(): number;
  28058. /**
  28059. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28060. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28061. */
  28062. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28063. /**
  28064. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28065. * @returns A promise with a boolean set to if the standing matrix is supported.
  28066. */
  28067. useStandingMatrixAsync(): Promise<boolean>;
  28068. /**
  28069. * Disposes the camera
  28070. */
  28071. dispose(): void;
  28072. /**
  28073. * Gets a vrController by name.
  28074. * @param name The name of the controller to retreive
  28075. * @returns the controller matching the name specified or null if not found
  28076. */
  28077. getControllerByName(name: string): Nullable<WebVRController>;
  28078. private _leftController;
  28079. /**
  28080. * The controller corresponding to the users left hand.
  28081. */
  28082. get leftController(): Nullable<WebVRController>;
  28083. private _rightController;
  28084. /**
  28085. * The controller corresponding to the users right hand.
  28086. */
  28087. get rightController(): Nullable<WebVRController>;
  28088. /**
  28089. * Casts a ray forward from the vrCamera's gaze.
  28090. * @param length Length of the ray (default: 100)
  28091. * @returns the ray corresponding to the gaze
  28092. */
  28093. getForwardRay(length?: number): Ray;
  28094. /**
  28095. * @hidden
  28096. * Updates the camera based on device's frame data
  28097. */
  28098. _checkInputs(): void;
  28099. /**
  28100. * Updates the poseControlled values based on the input device pose.
  28101. * @param poseData Pose coming from the device
  28102. */
  28103. updateFromDevice(poseData: DevicePose): void;
  28104. private _detachIfAttached;
  28105. /**
  28106. * WebVR's attach control will start broadcasting frames to the device.
  28107. * Note that in certain browsers (chrome for example) this function must be called
  28108. * within a user-interaction callback. Example:
  28109. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28110. *
  28111. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28112. */
  28113. attachControl(noPreventDefault?: boolean): void;
  28114. /**
  28115. * Detach the current controls from the specified dom element.
  28116. */
  28117. detachControl(): void;
  28118. /**
  28119. * @returns the name of this class
  28120. */
  28121. getClassName(): string;
  28122. /**
  28123. * Calls resetPose on the vrDisplay
  28124. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28125. */
  28126. resetToCurrentRotation(): void;
  28127. /**
  28128. * @hidden
  28129. * Updates the rig cameras (left and right eye)
  28130. */
  28131. _updateRigCameras(): void;
  28132. private _workingVector;
  28133. private _oneVector;
  28134. private _workingMatrix;
  28135. private updateCacheCalled;
  28136. private _correctPositionIfNotTrackPosition;
  28137. /**
  28138. * @hidden
  28139. * Updates the cached values of the camera
  28140. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28141. */
  28142. _updateCache(ignoreParentClass?: boolean): void;
  28143. /**
  28144. * @hidden
  28145. * Get current device position in babylon world
  28146. */
  28147. _computeDevicePosition(): void;
  28148. /**
  28149. * Updates the current device position and rotation in the babylon world
  28150. */
  28151. update(): void;
  28152. /**
  28153. * @hidden
  28154. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28155. * @returns an identity matrix
  28156. */
  28157. _getViewMatrix(): Matrix;
  28158. private _tmpMatrix;
  28159. /**
  28160. * This function is called by the two RIG cameras.
  28161. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28162. * @hidden
  28163. */
  28164. _getWebVRViewMatrix(): Matrix;
  28165. /** @hidden */
  28166. _getWebVRProjectionMatrix(): Matrix;
  28167. private _onGamepadConnectedObserver;
  28168. private _onGamepadDisconnectedObserver;
  28169. private _updateCacheWhenTrackingDisabledObserver;
  28170. /**
  28171. * Initializes the controllers and their meshes
  28172. */
  28173. initControllers(): void;
  28174. }
  28175. }
  28176. declare module BABYLON {
  28177. /**
  28178. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28179. *
  28180. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28181. *
  28182. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28183. */
  28184. export class MaterialHelper {
  28185. /**
  28186. * Bind the current view position to an effect.
  28187. * @param effect The effect to be bound
  28188. * @param scene The scene the eyes position is used from
  28189. * @param variableName name of the shader variable that will hold the eye position
  28190. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28191. * @return the computed eye position
  28192. */
  28193. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28194. /**
  28195. * Update the scene ubo before it can be used in rendering processing
  28196. * @param scene the scene to retrieve the ubo from
  28197. * @returns the scene UniformBuffer
  28198. */
  28199. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28200. /**
  28201. * Binds the scene's uniform buffer to the effect.
  28202. * @param effect defines the effect to bind to the scene uniform buffer
  28203. * @param sceneUbo defines the uniform buffer storing scene data
  28204. */
  28205. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28206. /**
  28207. * Helps preparing the defines values about the UVs in used in the effect.
  28208. * UVs are shared as much as we can across channels in the shaders.
  28209. * @param texture The texture we are preparing the UVs for
  28210. * @param defines The defines to update
  28211. * @param key The channel key "diffuse", "specular"... used in the shader
  28212. */
  28213. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28214. /**
  28215. * Binds a texture matrix value to its corresponding uniform
  28216. * @param texture The texture to bind the matrix for
  28217. * @param uniformBuffer The uniform buffer receiving the data
  28218. * @param key The channel key "diffuse", "specular"... used in the shader
  28219. */
  28220. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28221. /**
  28222. * Gets the current status of the fog (should it be enabled?)
  28223. * @param mesh defines the mesh to evaluate for fog support
  28224. * @param scene defines the hosting scene
  28225. * @returns true if fog must be enabled
  28226. */
  28227. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28228. /**
  28229. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28230. * @param mesh defines the current mesh
  28231. * @param scene defines the current scene
  28232. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28233. * @param pointsCloud defines if point cloud rendering has to be turned on
  28234. * @param fogEnabled defines if fog has to be turned on
  28235. * @param alphaTest defines if alpha testing has to be turned on
  28236. * @param defines defines the current list of defines
  28237. */
  28238. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28239. /**
  28240. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28241. * @param scene defines the current scene
  28242. * @param engine defines the current engine
  28243. * @param defines specifies the list of active defines
  28244. * @param useInstances defines if instances have to be turned on
  28245. * @param useClipPlane defines if clip plane have to be turned on
  28246. * @param useInstances defines if instances have to be turned on
  28247. * @param useThinInstances defines if thin instances have to be turned on
  28248. */
  28249. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28250. /**
  28251. * Prepares the defines for bones
  28252. * @param mesh The mesh containing the geometry data we will draw
  28253. * @param defines The defines to update
  28254. */
  28255. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28256. /**
  28257. * Prepares the defines for morph targets
  28258. * @param mesh The mesh containing the geometry data we will draw
  28259. * @param defines The defines to update
  28260. */
  28261. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28262. /**
  28263. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28264. * @param mesh The mesh containing the geometry data we will draw
  28265. * @param defines The defines to update
  28266. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28267. * @param useBones Precise whether bones should be used or not (override mesh info)
  28268. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28269. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28270. * @returns false if defines are considered not dirty and have not been checked
  28271. */
  28272. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28273. /**
  28274. * Prepares the defines related to multiview
  28275. * @param scene The scene we are intending to draw
  28276. * @param defines The defines to update
  28277. */
  28278. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28279. /**
  28280. * Prepares the defines related to the prepass
  28281. * @param scene The scene we are intending to draw
  28282. * @param defines The defines to update
  28283. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28284. */
  28285. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28286. /**
  28287. * Prepares the defines related to the light information passed in parameter
  28288. * @param scene The scene we are intending to draw
  28289. * @param mesh The mesh the effect is compiling for
  28290. * @param light The light the effect is compiling for
  28291. * @param lightIndex The index of the light
  28292. * @param defines The defines to update
  28293. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28294. * @param state Defines the current state regarding what is needed (normals, etc...)
  28295. */
  28296. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28297. needNormals: boolean;
  28298. needRebuild: boolean;
  28299. shadowEnabled: boolean;
  28300. specularEnabled: boolean;
  28301. lightmapMode: boolean;
  28302. }): void;
  28303. /**
  28304. * Prepares the defines related to the light information passed in parameter
  28305. * @param scene The scene we are intending to draw
  28306. * @param mesh The mesh the effect is compiling for
  28307. * @param defines The defines to update
  28308. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28309. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28310. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28311. * @returns true if normals will be required for the rest of the effect
  28312. */
  28313. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28314. /**
  28315. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28316. * @param lightIndex defines the light index
  28317. * @param uniformsList The uniform list
  28318. * @param samplersList The sampler list
  28319. * @param projectedLightTexture defines if projected texture must be used
  28320. * @param uniformBuffersList defines an optional list of uniform buffers
  28321. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28322. */
  28323. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28324. /**
  28325. * Prepares the uniforms and samplers list to be used in the effect
  28326. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28327. * @param samplersList The sampler list
  28328. * @param defines The defines helping in the list generation
  28329. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28330. */
  28331. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28332. /**
  28333. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28334. * @param defines The defines to update while falling back
  28335. * @param fallbacks The authorized effect fallbacks
  28336. * @param maxSimultaneousLights The maximum number of lights allowed
  28337. * @param rank the current rank of the Effect
  28338. * @returns The newly affected rank
  28339. */
  28340. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28341. private static _TmpMorphInfluencers;
  28342. /**
  28343. * Prepares the list of attributes required for morph targets according to the effect defines.
  28344. * @param attribs The current list of supported attribs
  28345. * @param mesh The mesh to prepare the morph targets attributes for
  28346. * @param influencers The number of influencers
  28347. */
  28348. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28349. /**
  28350. * Prepares the list of attributes required for morph targets according to the effect defines.
  28351. * @param attribs The current list of supported attribs
  28352. * @param mesh The mesh to prepare the morph targets attributes for
  28353. * @param defines The current Defines of the effect
  28354. */
  28355. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28356. /**
  28357. * Prepares the list of attributes required for bones according to the effect defines.
  28358. * @param attribs The current list of supported attribs
  28359. * @param mesh The mesh to prepare the bones attributes for
  28360. * @param defines The current Defines of the effect
  28361. * @param fallbacks The current effect fallback strategy
  28362. */
  28363. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28364. /**
  28365. * Check and prepare the list of attributes required for instances according to the effect defines.
  28366. * @param attribs The current list of supported attribs
  28367. * @param defines The current MaterialDefines of the effect
  28368. */
  28369. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28370. /**
  28371. * Add the list of attributes required for instances to the attribs array.
  28372. * @param attribs The current list of supported attribs
  28373. */
  28374. static PushAttributesForInstances(attribs: string[]): void;
  28375. /**
  28376. * Binds the light information to the effect.
  28377. * @param light The light containing the generator
  28378. * @param effect The effect we are binding the data to
  28379. * @param lightIndex The light index in the effect used to render
  28380. */
  28381. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28382. /**
  28383. * Binds the lights information from the scene to the effect for the given mesh.
  28384. * @param light Light to bind
  28385. * @param lightIndex Light index
  28386. * @param scene The scene where the light belongs to
  28387. * @param effect The effect we are binding the data to
  28388. * @param useSpecular Defines if specular is supported
  28389. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28390. */
  28391. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28392. /**
  28393. * Binds the lights information from the scene to the effect for the given mesh.
  28394. * @param scene The scene the lights belongs to
  28395. * @param mesh The mesh we are binding the information to render
  28396. * @param effect The effect we are binding the data to
  28397. * @param defines The generated defines for the effect
  28398. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28399. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28400. */
  28401. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28402. private static _tempFogColor;
  28403. /**
  28404. * Binds the fog information from the scene to the effect for the given mesh.
  28405. * @param scene The scene the lights belongs to
  28406. * @param mesh The mesh we are binding the information to render
  28407. * @param effect The effect we are binding the data to
  28408. * @param linearSpace Defines if the fog effect is applied in linear space
  28409. */
  28410. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28411. /**
  28412. * Binds the bones information from the mesh to the effect.
  28413. * @param mesh The mesh we are binding the information to render
  28414. * @param effect The effect we are binding the data to
  28415. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28416. */
  28417. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28418. private static _CopyBonesTransformationMatrices;
  28419. /**
  28420. * Binds the morph targets information from the mesh to the effect.
  28421. * @param abstractMesh The mesh we are binding the information to render
  28422. * @param effect The effect we are binding the data to
  28423. */
  28424. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28425. /**
  28426. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28427. * @param defines The generated defines used in the effect
  28428. * @param effect The effect we are binding the data to
  28429. * @param scene The scene we are willing to render with logarithmic scale for
  28430. */
  28431. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28432. /**
  28433. * Binds the clip plane information from the scene to the effect.
  28434. * @param scene The scene the clip plane information are extracted from
  28435. * @param effect The effect we are binding the data to
  28436. */
  28437. static BindClipPlane(effect: Effect, scene: Scene): void;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. /** @hidden */
  28442. export var bayerDitherFunctions: {
  28443. name: string;
  28444. shader: string;
  28445. };
  28446. }
  28447. declare module BABYLON {
  28448. /** @hidden */
  28449. export var shadowMapFragmentDeclaration: {
  28450. name: string;
  28451. shader: string;
  28452. };
  28453. }
  28454. declare module BABYLON {
  28455. /** @hidden */
  28456. export var shadowMapFragment: {
  28457. name: string;
  28458. shader: string;
  28459. };
  28460. }
  28461. declare module BABYLON {
  28462. /** @hidden */
  28463. export var shadowMapPixelShader: {
  28464. name: string;
  28465. shader: string;
  28466. };
  28467. }
  28468. declare module BABYLON {
  28469. /** @hidden */
  28470. export var shadowMapVertexDeclaration: {
  28471. name: string;
  28472. shader: string;
  28473. };
  28474. }
  28475. declare module BABYLON {
  28476. /** @hidden */
  28477. export var shadowMapVertexNormalBias: {
  28478. name: string;
  28479. shader: string;
  28480. };
  28481. }
  28482. declare module BABYLON {
  28483. /** @hidden */
  28484. export var shadowMapVertexMetric: {
  28485. name: string;
  28486. shader: string;
  28487. };
  28488. }
  28489. declare module BABYLON {
  28490. /** @hidden */
  28491. export var shadowMapVertexShader: {
  28492. name: string;
  28493. shader: string;
  28494. };
  28495. }
  28496. declare module BABYLON {
  28497. /** @hidden */
  28498. export var depthBoxBlurPixelShader: {
  28499. name: string;
  28500. shader: string;
  28501. };
  28502. }
  28503. declare module BABYLON {
  28504. /** @hidden */
  28505. export var shadowMapFragmentSoftTransparentShadow: {
  28506. name: string;
  28507. shader: string;
  28508. };
  28509. }
  28510. declare module BABYLON {
  28511. /**
  28512. * Creates an instance based on a source mesh.
  28513. */
  28514. export class InstancedMesh extends AbstractMesh {
  28515. private _sourceMesh;
  28516. private _currentLOD;
  28517. /** @hidden */
  28518. _indexInSourceMeshInstanceArray: number;
  28519. constructor(name: string, source: Mesh);
  28520. /**
  28521. * Returns the string "InstancedMesh".
  28522. */
  28523. getClassName(): string;
  28524. /** Gets the list of lights affecting that mesh */
  28525. get lightSources(): Light[];
  28526. _resyncLightSources(): void;
  28527. _resyncLightSource(light: Light): void;
  28528. _removeLightSource(light: Light, dispose: boolean): void;
  28529. /**
  28530. * If the source mesh receives shadows
  28531. */
  28532. get receiveShadows(): boolean;
  28533. /**
  28534. * The material of the source mesh
  28535. */
  28536. get material(): Nullable<Material>;
  28537. /**
  28538. * Visibility of the source mesh
  28539. */
  28540. get visibility(): number;
  28541. /**
  28542. * Skeleton of the source mesh
  28543. */
  28544. get skeleton(): Nullable<Skeleton>;
  28545. /**
  28546. * Rendering ground id of the source mesh
  28547. */
  28548. get renderingGroupId(): number;
  28549. set renderingGroupId(value: number);
  28550. /**
  28551. * Returns the total number of vertices (integer).
  28552. */
  28553. getTotalVertices(): number;
  28554. /**
  28555. * Returns a positive integer : the total number of indices in this mesh geometry.
  28556. * @returns the numner of indices or zero if the mesh has no geometry.
  28557. */
  28558. getTotalIndices(): number;
  28559. /**
  28560. * The source mesh of the instance
  28561. */
  28562. get sourceMesh(): Mesh;
  28563. /**
  28564. * Creates a new InstancedMesh object from the mesh model.
  28565. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28566. * @param name defines the name of the new instance
  28567. * @returns a new InstancedMesh
  28568. */
  28569. createInstance(name: string): InstancedMesh;
  28570. /**
  28571. * Is this node ready to be used/rendered
  28572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28573. * @return {boolean} is it ready
  28574. */
  28575. isReady(completeCheck?: boolean): boolean;
  28576. /**
  28577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28578. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28579. * @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.
  28580. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28581. */
  28582. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28583. /**
  28584. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28585. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28586. * The `data` are either a numeric array either a Float32Array.
  28587. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28588. * 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).
  28589. * Note that a new underlying VertexBuffer object is created each call.
  28590. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28591. *
  28592. * Possible `kind` values :
  28593. * - VertexBuffer.PositionKind
  28594. * - VertexBuffer.UVKind
  28595. * - VertexBuffer.UV2Kind
  28596. * - VertexBuffer.UV3Kind
  28597. * - VertexBuffer.UV4Kind
  28598. * - VertexBuffer.UV5Kind
  28599. * - VertexBuffer.UV6Kind
  28600. * - VertexBuffer.ColorKind
  28601. * - VertexBuffer.MatricesIndicesKind
  28602. * - VertexBuffer.MatricesIndicesExtraKind
  28603. * - VertexBuffer.MatricesWeightsKind
  28604. * - VertexBuffer.MatricesWeightsExtraKind
  28605. *
  28606. * Returns the Mesh.
  28607. */
  28608. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28609. /**
  28610. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28611. * If the mesh has no geometry, it is simply returned as it is.
  28612. * The `data` are either a numeric array either a Float32Array.
  28613. * No new underlying VertexBuffer object is created.
  28614. * 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.
  28615. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28616. *
  28617. * Possible `kind` values :
  28618. * - VertexBuffer.PositionKind
  28619. * - VertexBuffer.UVKind
  28620. * - VertexBuffer.UV2Kind
  28621. * - VertexBuffer.UV3Kind
  28622. * - VertexBuffer.UV4Kind
  28623. * - VertexBuffer.UV5Kind
  28624. * - VertexBuffer.UV6Kind
  28625. * - VertexBuffer.ColorKind
  28626. * - VertexBuffer.MatricesIndicesKind
  28627. * - VertexBuffer.MatricesIndicesExtraKind
  28628. * - VertexBuffer.MatricesWeightsKind
  28629. * - VertexBuffer.MatricesWeightsExtraKind
  28630. *
  28631. * Returns the Mesh.
  28632. */
  28633. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28634. /**
  28635. * Sets the mesh indices.
  28636. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28637. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28638. * This method creates a new index buffer each call.
  28639. * Returns the Mesh.
  28640. */
  28641. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28642. /**
  28643. * Boolean : True if the mesh owns the requested kind of data.
  28644. */
  28645. isVerticesDataPresent(kind: string): boolean;
  28646. /**
  28647. * Returns an array of indices (IndicesArray).
  28648. */
  28649. getIndices(): Nullable<IndicesArray>;
  28650. get _positions(): Nullable<Vector3[]>;
  28651. /**
  28652. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28653. * This means the mesh underlying bounding box and sphere are recomputed.
  28654. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28655. * @returns the current mesh
  28656. */
  28657. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28658. /** @hidden */
  28659. _preActivate(): InstancedMesh;
  28660. /** @hidden */
  28661. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28662. /** @hidden */
  28663. _postActivate(): void;
  28664. getWorldMatrix(): Matrix;
  28665. get isAnInstance(): boolean;
  28666. /**
  28667. * Returns the current associated LOD AbstractMesh.
  28668. */
  28669. getLOD(camera: Camera): AbstractMesh;
  28670. /** @hidden */
  28671. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28672. /** @hidden */
  28673. _syncSubMeshes(): InstancedMesh;
  28674. /** @hidden */
  28675. _generatePointsArray(): boolean;
  28676. /** @hidden */
  28677. _updateBoundingInfo(): AbstractMesh;
  28678. /**
  28679. * Creates a new InstancedMesh from the current mesh.
  28680. * - name (string) : the cloned mesh name
  28681. * - newParent (optional Node) : the optional Node to parent the clone to.
  28682. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28683. *
  28684. * Returns the clone.
  28685. */
  28686. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28687. /**
  28688. * Disposes the InstancedMesh.
  28689. * Returns nothing.
  28690. */
  28691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28692. }
  28693. interface Mesh {
  28694. /**
  28695. * Register a custom buffer that will be instanced
  28696. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28697. * @param kind defines the buffer kind
  28698. * @param stride defines the stride in floats
  28699. */
  28700. registerInstancedBuffer(kind: string, stride: number): void;
  28701. /**
  28702. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28703. */
  28704. _invalidateInstanceVertexArrayObject(): void;
  28705. /**
  28706. * true to use the edge renderer for all instances of this mesh
  28707. */
  28708. edgesShareWithInstances: boolean;
  28709. /** @hidden */
  28710. _userInstancedBuffersStorage: {
  28711. data: {
  28712. [key: string]: Float32Array;
  28713. };
  28714. sizes: {
  28715. [key: string]: number;
  28716. };
  28717. vertexBuffers: {
  28718. [key: string]: Nullable<VertexBuffer>;
  28719. };
  28720. strides: {
  28721. [key: string]: number;
  28722. };
  28723. vertexArrayObjects?: {
  28724. [key: string]: WebGLVertexArrayObject;
  28725. };
  28726. };
  28727. }
  28728. interface AbstractMesh {
  28729. /**
  28730. * Object used to store instanced buffers defined by user
  28731. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28732. */
  28733. instancedBuffers: {
  28734. [key: string]: any;
  28735. };
  28736. }
  28737. }
  28738. declare module BABYLON {
  28739. /**
  28740. * Defines the options associated with the creation of a shader material.
  28741. */
  28742. export interface IShaderMaterialOptions {
  28743. /**
  28744. * Does the material work in alpha blend mode
  28745. */
  28746. needAlphaBlending: boolean;
  28747. /**
  28748. * Does the material work in alpha test mode
  28749. */
  28750. needAlphaTesting: boolean;
  28751. /**
  28752. * The list of attribute names used in the shader
  28753. */
  28754. attributes: string[];
  28755. /**
  28756. * The list of uniform names used in the shader
  28757. */
  28758. uniforms: string[];
  28759. /**
  28760. * The list of UBO names used in the shader
  28761. */
  28762. uniformBuffers: string[];
  28763. /**
  28764. * The list of sampler names used in the shader
  28765. */
  28766. samplers: string[];
  28767. /**
  28768. * The list of defines used in the shader
  28769. */
  28770. defines: string[];
  28771. }
  28772. /**
  28773. * 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.
  28774. *
  28775. * This returned material effects how the mesh will look based on the code in the shaders.
  28776. *
  28777. * @see https://doc.babylonjs.com/how_to/shader_material
  28778. */
  28779. export class ShaderMaterial extends Material {
  28780. private _shaderPath;
  28781. private _options;
  28782. private _textures;
  28783. private _textureArrays;
  28784. private _floats;
  28785. private _ints;
  28786. private _floatsArrays;
  28787. private _colors3;
  28788. private _colors3Arrays;
  28789. private _colors4;
  28790. private _colors4Arrays;
  28791. private _vectors2;
  28792. private _vectors3;
  28793. private _vectors4;
  28794. private _matrices;
  28795. private _matrixArrays;
  28796. private _matrices3x3;
  28797. private _matrices2x2;
  28798. private _vectors2Arrays;
  28799. private _vectors3Arrays;
  28800. private _vectors4Arrays;
  28801. private _cachedWorldViewMatrix;
  28802. private _cachedWorldViewProjectionMatrix;
  28803. private _renderId;
  28804. private _multiview;
  28805. private _cachedDefines;
  28806. /** Define the Url to load snippets */
  28807. static SnippetUrl: string;
  28808. /** Snippet ID if the material was created from the snippet server */
  28809. snippetId: string;
  28810. /**
  28811. * Instantiate a new shader material.
  28812. * 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.
  28813. * This returned material effects how the mesh will look based on the code in the shaders.
  28814. * @see https://doc.babylonjs.com/how_to/shader_material
  28815. * @param name Define the name of the material in the scene
  28816. * @param scene Define the scene the material belongs to
  28817. * @param shaderPath Defines the route to the shader code in one of three ways:
  28818. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28819. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28820. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28821. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28822. * @param options Define the options used to create the shader
  28823. */
  28824. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28825. /**
  28826. * Gets the shader path used to define the shader code
  28827. * It can be modified to trigger a new compilation
  28828. */
  28829. get shaderPath(): any;
  28830. /**
  28831. * Sets the shader path used to define the shader code
  28832. * It can be modified to trigger a new compilation
  28833. */
  28834. set shaderPath(shaderPath: any);
  28835. /**
  28836. * Gets the options used to compile the shader.
  28837. * They can be modified to trigger a new compilation
  28838. */
  28839. get options(): IShaderMaterialOptions;
  28840. /**
  28841. * Gets the current class name of the material e.g. "ShaderMaterial"
  28842. * Mainly use in serialization.
  28843. * @returns the class name
  28844. */
  28845. getClassName(): string;
  28846. /**
  28847. * Specifies if the material will require alpha blending
  28848. * @returns a boolean specifying if alpha blending is needed
  28849. */
  28850. needAlphaBlending(): boolean;
  28851. /**
  28852. * Specifies if this material should be rendered in alpha test mode
  28853. * @returns a boolean specifying if an alpha test is needed.
  28854. */
  28855. needAlphaTesting(): boolean;
  28856. private _checkUniform;
  28857. /**
  28858. * Set a texture in the shader.
  28859. * @param name Define the name of the uniform samplers as defined in the shader
  28860. * @param texture Define the texture to bind to this sampler
  28861. * @return the material itself allowing "fluent" like uniform updates
  28862. */
  28863. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28864. /**
  28865. * Set a texture array in the shader.
  28866. * @param name Define the name of the uniform sampler array as defined in the shader
  28867. * @param textures Define the list of textures to bind to this sampler
  28868. * @return the material itself allowing "fluent" like uniform updates
  28869. */
  28870. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28871. /**
  28872. * Set a float in the shader.
  28873. * @param name Define the name of the uniform as defined in the shader
  28874. * @param value Define the value to give to the uniform
  28875. * @return the material itself allowing "fluent" like uniform updates
  28876. */
  28877. setFloat(name: string, value: number): ShaderMaterial;
  28878. /**
  28879. * Set a int in the shader.
  28880. * @param name Define the name of the uniform as defined in the shader
  28881. * @param value Define the value to give to the uniform
  28882. * @return the material itself allowing "fluent" like uniform updates
  28883. */
  28884. setInt(name: string, value: number): ShaderMaterial;
  28885. /**
  28886. * Set an array of floats in the shader.
  28887. * @param name Define the name of the uniform as defined in the shader
  28888. * @param value Define the value to give to the uniform
  28889. * @return the material itself allowing "fluent" like uniform updates
  28890. */
  28891. setFloats(name: string, value: number[]): ShaderMaterial;
  28892. /**
  28893. * Set a vec3 in the shader from a Color3.
  28894. * @param name Define the name of the uniform as defined in the shader
  28895. * @param value Define the value to give to the uniform
  28896. * @return the material itself allowing "fluent" like uniform updates
  28897. */
  28898. setColor3(name: string, value: Color3): ShaderMaterial;
  28899. /**
  28900. * Set a vec3 array in the shader from a Color3 array.
  28901. * @param name Define the name of the uniform as defined in the shader
  28902. * @param value Define the value to give to the uniform
  28903. * @return the material itself allowing "fluent" like uniform updates
  28904. */
  28905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28906. /**
  28907. * Set a vec4 in the shader from a Color4.
  28908. * @param name Define the name of the uniform as defined in the shader
  28909. * @param value Define the value to give to the uniform
  28910. * @return the material itself allowing "fluent" like uniform updates
  28911. */
  28912. setColor4(name: string, value: Color4): ShaderMaterial;
  28913. /**
  28914. * Set a vec4 array in the shader from a Color4 array.
  28915. * @param name Define the name of the uniform as defined in the shader
  28916. * @param value Define the value to give to the uniform
  28917. * @return the material itself allowing "fluent" like uniform updates
  28918. */
  28919. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28920. /**
  28921. * Set a vec2 in the shader from a Vector2.
  28922. * @param name Define the name of the uniform as defined in the shader
  28923. * @param value Define the value to give to the uniform
  28924. * @return the material itself allowing "fluent" like uniform updates
  28925. */
  28926. setVector2(name: string, value: Vector2): ShaderMaterial;
  28927. /**
  28928. * Set a vec3 in the shader from a Vector3.
  28929. * @param name Define the name of the uniform as defined in the shader
  28930. * @param value Define the value to give to the uniform
  28931. * @return the material itself allowing "fluent" like uniform updates
  28932. */
  28933. setVector3(name: string, value: Vector3): ShaderMaterial;
  28934. /**
  28935. * Set a vec4 in the shader from a Vector4.
  28936. * @param name Define the name of the uniform as defined in the shader
  28937. * @param value Define the value to give to the uniform
  28938. * @return the material itself allowing "fluent" like uniform updates
  28939. */
  28940. setVector4(name: string, value: Vector4): ShaderMaterial;
  28941. /**
  28942. * Set a mat4 in the shader from a Matrix.
  28943. * @param name Define the name of the uniform as defined in the shader
  28944. * @param value Define the value to give to the uniform
  28945. * @return the material itself allowing "fluent" like uniform updates
  28946. */
  28947. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28948. /**
  28949. * Set a float32Array in the shader from a matrix array.
  28950. * @param name Define the name of the uniform as defined in the shader
  28951. * @param value Define the value to give to the uniform
  28952. * @return the material itself allowing "fluent" like uniform updates
  28953. */
  28954. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28955. /**
  28956. * Set a mat3 in the shader from a Float32Array.
  28957. * @param name Define the name of the uniform as defined in the shader
  28958. * @param value Define the value to give to the uniform
  28959. * @return the material itself allowing "fluent" like uniform updates
  28960. */
  28961. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28962. /**
  28963. * Set a mat2 in the shader from a Float32Array.
  28964. * @param name Define the name of the uniform as defined in the shader
  28965. * @param value Define the value to give to the uniform
  28966. * @return the material itself allowing "fluent" like uniform updates
  28967. */
  28968. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28969. /**
  28970. * Set a vec2 array in the shader from a number array.
  28971. * @param name Define the name of the uniform as defined in the shader
  28972. * @param value Define the value to give to the uniform
  28973. * @return the material itself allowing "fluent" like uniform updates
  28974. */
  28975. setArray2(name: string, value: number[]): ShaderMaterial;
  28976. /**
  28977. * Set a vec3 array in the shader from a number array.
  28978. * @param name Define the name of the uniform as defined in the shader
  28979. * @param value Define the value to give to the uniform
  28980. * @return the material itself allowing "fluent" like uniform updates
  28981. */
  28982. setArray3(name: string, value: number[]): ShaderMaterial;
  28983. /**
  28984. * Set a vec4 array in the shader from a number array.
  28985. * @param name Define the name of the uniform as defined in the shader
  28986. * @param value Define the value to give to the uniform
  28987. * @return the material itself allowing "fluent" like uniform updates
  28988. */
  28989. setArray4(name: string, value: number[]): ShaderMaterial;
  28990. private _checkCache;
  28991. /**
  28992. * Specifies that the submesh is ready to be used
  28993. * @param mesh defines the mesh to check
  28994. * @param subMesh defines which submesh to check
  28995. * @param useInstances specifies that instances should be used
  28996. * @returns a boolean indicating that the submesh is ready or not
  28997. */
  28998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28999. /**
  29000. * Checks if the material is ready to render the requested mesh
  29001. * @param mesh Define the mesh to render
  29002. * @param useInstances Define whether or not the material is used with instances
  29003. * @returns true if ready, otherwise false
  29004. */
  29005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29006. /**
  29007. * Binds the world matrix to the material
  29008. * @param world defines the world transformation matrix
  29009. * @param effectOverride - If provided, use this effect instead of internal effect
  29010. */
  29011. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29012. /**
  29013. * Binds the submesh to this material by preparing the effect and shader to draw
  29014. * @param world defines the world transformation matrix
  29015. * @param mesh defines the mesh containing the submesh
  29016. * @param subMesh defines the submesh to bind the material to
  29017. */
  29018. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29019. /**
  29020. * Binds the material to the mesh
  29021. * @param world defines the world transformation matrix
  29022. * @param mesh defines the mesh to bind the material to
  29023. * @param effectOverride - If provided, use this effect instead of internal effect
  29024. */
  29025. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29026. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29027. /**
  29028. * Gets the active textures from the material
  29029. * @returns an array of textures
  29030. */
  29031. getActiveTextures(): BaseTexture[];
  29032. /**
  29033. * Specifies if the material uses a texture
  29034. * @param texture defines the texture to check against the material
  29035. * @returns a boolean specifying if the material uses the texture
  29036. */
  29037. hasTexture(texture: BaseTexture): boolean;
  29038. /**
  29039. * Makes a duplicate of the material, and gives it a new name
  29040. * @param name defines the new name for the duplicated material
  29041. * @returns the cloned material
  29042. */
  29043. clone(name: string): ShaderMaterial;
  29044. /**
  29045. * Disposes the material
  29046. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29047. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29048. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29049. */
  29050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29051. /**
  29052. * Serializes this material in a JSON representation
  29053. * @returns the serialized material object
  29054. */
  29055. serialize(): any;
  29056. /**
  29057. * Creates a shader material from parsed shader material data
  29058. * @param source defines the JSON representation of the material
  29059. * @param scene defines the hosting scene
  29060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29061. * @returns a new material
  29062. */
  29063. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29064. /**
  29065. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29066. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29067. * @param url defines the url to load from
  29068. * @param scene defines the hosting scene
  29069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29070. * @returns a promise that will resolve to the new ShaderMaterial
  29071. */
  29072. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29073. /**
  29074. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29075. * @param snippetId defines the snippet to load
  29076. * @param scene defines the hosting scene
  29077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29078. * @returns a promise that will resolve to the new ShaderMaterial
  29079. */
  29080. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29081. }
  29082. }
  29083. declare module BABYLON {
  29084. /** @hidden */
  29085. export var colorPixelShader: {
  29086. name: string;
  29087. shader: string;
  29088. };
  29089. }
  29090. declare module BABYLON {
  29091. /** @hidden */
  29092. export var colorVertexShader: {
  29093. name: string;
  29094. shader: string;
  29095. };
  29096. }
  29097. declare module BABYLON {
  29098. /**
  29099. * Line mesh
  29100. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29101. */
  29102. export class LinesMesh extends Mesh {
  29103. /**
  29104. * If vertex color should be applied to the mesh
  29105. */
  29106. readonly useVertexColor?: boolean | undefined;
  29107. /**
  29108. * If vertex alpha should be applied to the mesh
  29109. */
  29110. readonly useVertexAlpha?: boolean | undefined;
  29111. /**
  29112. * Color of the line (Default: White)
  29113. */
  29114. color: Color3;
  29115. /**
  29116. * Alpha of the line (Default: 1)
  29117. */
  29118. alpha: number;
  29119. /**
  29120. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29121. * This margin is expressed in world space coordinates, so its value may vary.
  29122. * Default value is 0.1
  29123. */
  29124. intersectionThreshold: number;
  29125. private _colorShader;
  29126. private color4;
  29127. /**
  29128. * Creates a new LinesMesh
  29129. * @param name defines the name
  29130. * @param scene defines the hosting scene
  29131. * @param parent defines the parent mesh if any
  29132. * @param source defines the optional source LinesMesh used to clone data from
  29133. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29134. * When false, achieved by calling a clone(), also passing False.
  29135. * This will make creation of children, recursive.
  29136. * @param useVertexColor defines if this LinesMesh supports vertex color
  29137. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29138. */
  29139. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29140. /**
  29141. * If vertex color should be applied to the mesh
  29142. */
  29143. useVertexColor?: boolean | undefined,
  29144. /**
  29145. * If vertex alpha should be applied to the mesh
  29146. */
  29147. useVertexAlpha?: boolean | undefined);
  29148. private _addClipPlaneDefine;
  29149. private _removeClipPlaneDefine;
  29150. isReady(): boolean;
  29151. /**
  29152. * Returns the string "LineMesh"
  29153. */
  29154. getClassName(): string;
  29155. /**
  29156. * @hidden
  29157. */
  29158. get material(): Material;
  29159. /**
  29160. * @hidden
  29161. */
  29162. set material(value: Material);
  29163. /**
  29164. * @hidden
  29165. */
  29166. get checkCollisions(): boolean;
  29167. set checkCollisions(value: boolean);
  29168. /** @hidden */
  29169. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29170. /** @hidden */
  29171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29172. /**
  29173. * Disposes of the line mesh
  29174. * @param doNotRecurse If children should be disposed
  29175. */
  29176. dispose(doNotRecurse?: boolean): void;
  29177. /**
  29178. * Returns a new LineMesh object cloned from the current one.
  29179. */
  29180. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29181. /**
  29182. * Creates a new InstancedLinesMesh object from the mesh model.
  29183. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29184. * @param name defines the name of the new instance
  29185. * @returns a new InstancedLinesMesh
  29186. */
  29187. createInstance(name: string): InstancedLinesMesh;
  29188. }
  29189. /**
  29190. * Creates an instance based on a source LinesMesh
  29191. */
  29192. export class InstancedLinesMesh extends InstancedMesh {
  29193. /**
  29194. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29195. * This margin is expressed in world space coordinates, so its value may vary.
  29196. * Initialized with the intersectionThreshold value of the source LinesMesh
  29197. */
  29198. intersectionThreshold: number;
  29199. constructor(name: string, source: LinesMesh);
  29200. /**
  29201. * Returns the string "InstancedLinesMesh".
  29202. */
  29203. getClassName(): string;
  29204. }
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var linePixelShader: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var lineVertexShader: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. interface Scene {
  29222. /** @hidden */
  29223. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29224. }
  29225. interface AbstractMesh {
  29226. /**
  29227. * Gets the edgesRenderer associated with the mesh
  29228. */
  29229. edgesRenderer: Nullable<EdgesRenderer>;
  29230. }
  29231. interface LinesMesh {
  29232. /**
  29233. * Enables the edge rendering mode on the mesh.
  29234. * This mode makes the mesh edges visible
  29235. * @param epsilon defines the maximal distance between two angles to detect a face
  29236. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29237. * @returns the currentAbstractMesh
  29238. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29239. */
  29240. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29241. }
  29242. interface InstancedLinesMesh {
  29243. /**
  29244. * Enables the edge rendering mode on the mesh.
  29245. * This mode makes the mesh edges visible
  29246. * @param epsilon defines the maximal distance between two angles to detect a face
  29247. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29248. * @returns the current InstancedLinesMesh
  29249. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29250. */
  29251. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29252. }
  29253. /**
  29254. * Defines the minimum contract an Edges renderer should follow.
  29255. */
  29256. export interface IEdgesRenderer extends IDisposable {
  29257. /**
  29258. * Gets or sets a boolean indicating if the edgesRenderer is active
  29259. */
  29260. isEnabled: boolean;
  29261. /**
  29262. * Renders the edges of the attached mesh,
  29263. */
  29264. render(): void;
  29265. /**
  29266. * Checks whether or not the edges renderer is ready to render.
  29267. * @return true if ready, otherwise false.
  29268. */
  29269. isReady(): boolean;
  29270. /**
  29271. * List of instances to render in case the source mesh has instances
  29272. */
  29273. customInstances: SmartArray<Matrix>;
  29274. }
  29275. /**
  29276. * Defines the additional options of the edges renderer
  29277. */
  29278. export interface IEdgesRendererOptions {
  29279. /**
  29280. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29281. * If not defined, the default value is true
  29282. */
  29283. useAlternateEdgeFinder?: boolean;
  29284. /**
  29285. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29286. * If not defined, the default value is true.
  29287. * 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)
  29288. * This option is used only if useAlternateEdgeFinder = true
  29289. */
  29290. useFastVertexMerger?: boolean;
  29291. /**
  29292. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29293. * The default value is 1e-6
  29294. * This option is used only if useAlternateEdgeFinder = true
  29295. */
  29296. epsilonVertexMerge?: number;
  29297. /**
  29298. * 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
  29299. * 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.
  29300. * This option is used only if useAlternateEdgeFinder = true
  29301. */
  29302. applyTessellation?: boolean;
  29303. /**
  29304. * 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
  29305. * The default value is 1e-6
  29306. * This option is used only if useAlternateEdgeFinder = true
  29307. */
  29308. epsilonVertexAligned?: number;
  29309. }
  29310. /**
  29311. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29312. */
  29313. export class EdgesRenderer implements IEdgesRenderer {
  29314. /**
  29315. * Define the size of the edges with an orthographic camera
  29316. */
  29317. edgesWidthScalerForOrthographic: number;
  29318. /**
  29319. * Define the size of the edges with a perspective camera
  29320. */
  29321. edgesWidthScalerForPerspective: number;
  29322. protected _source: AbstractMesh;
  29323. protected _linesPositions: number[];
  29324. protected _linesNormals: number[];
  29325. protected _linesIndices: number[];
  29326. protected _epsilon: number;
  29327. protected _indicesCount: number;
  29328. protected _lineShader: ShaderMaterial;
  29329. protected _ib: DataBuffer;
  29330. protected _buffers: {
  29331. [key: string]: Nullable<VertexBuffer>;
  29332. };
  29333. protected _buffersForInstances: {
  29334. [key: string]: Nullable<VertexBuffer>;
  29335. };
  29336. protected _checkVerticesInsteadOfIndices: boolean;
  29337. protected _options: Nullable<IEdgesRendererOptions>;
  29338. private _meshRebuildObserver;
  29339. private _meshDisposeObserver;
  29340. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29341. isEnabled: boolean;
  29342. /** Gets the vertices generated by the edge renderer */
  29343. get linesPositions(): Immutable<Array<number>>;
  29344. /** Gets the normals generated by the edge renderer */
  29345. get linesNormals(): Immutable<Array<number>>;
  29346. /** Gets the indices generated by the edge renderer */
  29347. get linesIndices(): Immutable<Array<number>>;
  29348. /**
  29349. * List of instances to render in case the source mesh has instances
  29350. */
  29351. customInstances: SmartArray<Matrix>;
  29352. private static GetShader;
  29353. /**
  29354. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29355. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29356. * @param source Mesh used to create edges
  29357. * @param epsilon sum of angles in adjacency to check for edge
  29358. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29359. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29360. * @param options The options to apply when generating the edges
  29361. */
  29362. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29363. protected _prepareRessources(): void;
  29364. /** @hidden */
  29365. _rebuild(): void;
  29366. /**
  29367. * Releases the required resources for the edges renderer
  29368. */
  29369. dispose(): void;
  29370. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29371. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29372. /**
  29373. * Checks if the pair of p0 and p1 is en edge
  29374. * @param faceIndex
  29375. * @param edge
  29376. * @param faceNormals
  29377. * @param p0
  29378. * @param p1
  29379. * @private
  29380. */
  29381. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29382. /**
  29383. * push line into the position, normal and index buffer
  29384. * @protected
  29385. */
  29386. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29387. /**
  29388. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29389. */
  29390. private _tessellateTriangle;
  29391. private _generateEdgesLinesAlternate;
  29392. /**
  29393. * Generates lines edges from adjacencjes
  29394. * @private
  29395. */
  29396. _generateEdgesLines(): void;
  29397. /**
  29398. * Checks whether or not the edges renderer is ready to render.
  29399. * @return true if ready, otherwise false.
  29400. */
  29401. isReady(): boolean;
  29402. /**
  29403. * Renders the edges of the attached mesh,
  29404. */
  29405. render(): void;
  29406. }
  29407. /**
  29408. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29409. */
  29410. export class LineEdgesRenderer extends EdgesRenderer {
  29411. /**
  29412. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29413. * @param source LineMesh used to generate edges
  29414. * @param epsilon not important (specified angle for edge detection)
  29415. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29416. */
  29417. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29418. /**
  29419. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29420. */
  29421. _generateEdgesLines(): void;
  29422. }
  29423. }
  29424. declare module BABYLON {
  29425. /**
  29426. * This represents the object necessary to create a rendering group.
  29427. * This is exclusively used and created by the rendering manager.
  29428. * To modify the behavior, you use the available helpers in your scene or meshes.
  29429. * @hidden
  29430. */
  29431. export class RenderingGroup {
  29432. index: number;
  29433. private static _zeroVector;
  29434. private _scene;
  29435. private _opaqueSubMeshes;
  29436. private _transparentSubMeshes;
  29437. private _alphaTestSubMeshes;
  29438. private _depthOnlySubMeshes;
  29439. private _particleSystems;
  29440. private _spriteManagers;
  29441. private _opaqueSortCompareFn;
  29442. private _alphaTestSortCompareFn;
  29443. private _transparentSortCompareFn;
  29444. private _renderOpaque;
  29445. private _renderAlphaTest;
  29446. private _renderTransparent;
  29447. /** @hidden */
  29448. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29449. onBeforeTransparentRendering: () => void;
  29450. /**
  29451. * Set the opaque sort comparison function.
  29452. * If null the sub meshes will be render in the order they were created
  29453. */
  29454. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29455. /**
  29456. * Set the alpha test sort comparison function.
  29457. * If null the sub meshes will be render in the order they were created
  29458. */
  29459. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29460. /**
  29461. * Set the transparent sort comparison function.
  29462. * If null the sub meshes will be render in the order they were created
  29463. */
  29464. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29465. /**
  29466. * Creates a new rendering group.
  29467. * @param index The rendering group index
  29468. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29469. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29470. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29471. */
  29472. 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>);
  29473. /**
  29474. * Render all the sub meshes contained in the group.
  29475. * @param customRenderFunction Used to override the default render behaviour of the group.
  29476. * @returns true if rendered some submeshes.
  29477. */
  29478. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29479. /**
  29480. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29481. * @param subMeshes The submeshes to render
  29482. */
  29483. private renderOpaqueSorted;
  29484. /**
  29485. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29486. * @param subMeshes The submeshes to render
  29487. */
  29488. private renderAlphaTestSorted;
  29489. /**
  29490. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29491. * @param subMeshes The submeshes to render
  29492. */
  29493. private renderTransparentSorted;
  29494. /**
  29495. * Renders the submeshes in a specified order.
  29496. * @param subMeshes The submeshes to sort before render
  29497. * @param sortCompareFn The comparison function use to sort
  29498. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29499. * @param transparent Specifies to activate blending if true
  29500. */
  29501. private static renderSorted;
  29502. /**
  29503. * Renders the submeshes in the order they were dispatched (no sort applied).
  29504. * @param subMeshes The submeshes to render
  29505. */
  29506. private static renderUnsorted;
  29507. /**
  29508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29509. * are rendered back to front if in the same alpha index.
  29510. *
  29511. * @param a The first submesh
  29512. * @param b The second submesh
  29513. * @returns The result of the comparison
  29514. */
  29515. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29516. /**
  29517. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29518. * are rendered back to front.
  29519. *
  29520. * @param a The first submesh
  29521. * @param b The second submesh
  29522. * @returns The result of the comparison
  29523. */
  29524. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29525. /**
  29526. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29527. * are rendered front to back (prevent overdraw).
  29528. *
  29529. * @param a The first submesh
  29530. * @param b The second submesh
  29531. * @returns The result of the comparison
  29532. */
  29533. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29534. /**
  29535. * Resets the different lists of submeshes to prepare a new frame.
  29536. */
  29537. prepare(): void;
  29538. dispose(): void;
  29539. /**
  29540. * Inserts the submesh in its correct queue depending on its material.
  29541. * @param subMesh The submesh to dispatch
  29542. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29543. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29544. */
  29545. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29546. dispatchSprites(spriteManager: ISpriteManager): void;
  29547. dispatchParticles(particleSystem: IParticleSystem): void;
  29548. private _renderParticles;
  29549. private _renderSprites;
  29550. }
  29551. }
  29552. declare module BABYLON {
  29553. /**
  29554. * Interface describing the different options available in the rendering manager
  29555. * regarding Auto Clear between groups.
  29556. */
  29557. export interface IRenderingManagerAutoClearSetup {
  29558. /**
  29559. * Defines whether or not autoclear is enable.
  29560. */
  29561. autoClear: boolean;
  29562. /**
  29563. * Defines whether or not to autoclear the depth buffer.
  29564. */
  29565. depth: boolean;
  29566. /**
  29567. * Defines whether or not to autoclear the stencil buffer.
  29568. */
  29569. stencil: boolean;
  29570. }
  29571. /**
  29572. * This class is used by the onRenderingGroupObservable
  29573. */
  29574. export class RenderingGroupInfo {
  29575. /**
  29576. * The Scene that being rendered
  29577. */
  29578. scene: Scene;
  29579. /**
  29580. * The camera currently used for the rendering pass
  29581. */
  29582. camera: Nullable<Camera>;
  29583. /**
  29584. * The ID of the renderingGroup being processed
  29585. */
  29586. renderingGroupId: number;
  29587. }
  29588. /**
  29589. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29590. * It is enable to manage the different groups as well as the different necessary sort functions.
  29591. * This should not be used directly aside of the few static configurations
  29592. */
  29593. export class RenderingManager {
  29594. /**
  29595. * The max id used for rendering groups (not included)
  29596. */
  29597. static MAX_RENDERINGGROUPS: number;
  29598. /**
  29599. * The min id used for rendering groups (included)
  29600. */
  29601. static MIN_RENDERINGGROUPS: number;
  29602. /**
  29603. * Used to globally prevent autoclearing scenes.
  29604. */
  29605. static AUTOCLEAR: boolean;
  29606. /**
  29607. * @hidden
  29608. */
  29609. _useSceneAutoClearSetup: boolean;
  29610. private _scene;
  29611. private _renderingGroups;
  29612. private _depthStencilBufferAlreadyCleaned;
  29613. private _autoClearDepthStencil;
  29614. private _customOpaqueSortCompareFn;
  29615. private _customAlphaTestSortCompareFn;
  29616. private _customTransparentSortCompareFn;
  29617. private _renderingGroupInfo;
  29618. /**
  29619. * Instantiates a new rendering group for a particular scene
  29620. * @param scene Defines the scene the groups belongs to
  29621. */
  29622. constructor(scene: Scene);
  29623. private _clearDepthStencilBuffer;
  29624. /**
  29625. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29626. * @hidden
  29627. */
  29628. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29629. /**
  29630. * Resets the different information of the group to prepare a new frame
  29631. * @hidden
  29632. */
  29633. reset(): void;
  29634. /**
  29635. * Dispose and release the group and its associated resources.
  29636. * @hidden
  29637. */
  29638. dispose(): void;
  29639. /**
  29640. * Clear the info related to rendering groups preventing retention points during dispose.
  29641. */
  29642. freeRenderingGroups(): void;
  29643. private _prepareRenderingGroup;
  29644. /**
  29645. * Add a sprite manager to the rendering manager in order to render it this frame.
  29646. * @param spriteManager Define the sprite manager to render
  29647. */
  29648. dispatchSprites(spriteManager: ISpriteManager): void;
  29649. /**
  29650. * Add a particle system to the rendering manager in order to render it this frame.
  29651. * @param particleSystem Define the particle system to render
  29652. */
  29653. dispatchParticles(particleSystem: IParticleSystem): void;
  29654. /**
  29655. * Add a submesh to the manager in order to render it this frame
  29656. * @param subMesh The submesh to dispatch
  29657. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29658. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29659. */
  29660. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29661. /**
  29662. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29663. * This allowed control for front to back rendering or reversely depending of the special needs.
  29664. *
  29665. * @param renderingGroupId The rendering group id corresponding to its index
  29666. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29667. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29668. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29669. */
  29670. 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;
  29671. /**
  29672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29673. *
  29674. * @param renderingGroupId The rendering group id corresponding to its index
  29675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29676. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29677. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29678. */
  29679. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29680. /**
  29681. * Gets the current auto clear configuration for one rendering group of the rendering
  29682. * manager.
  29683. * @param index the rendering group index to get the information for
  29684. * @returns The auto clear setup for the requested rendering group
  29685. */
  29686. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29687. }
  29688. }
  29689. declare module BABYLON {
  29690. /**
  29691. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29692. */
  29693. export interface ICustomShaderOptions {
  29694. /**
  29695. * Gets or sets the custom shader name to use
  29696. */
  29697. shaderName: string;
  29698. /**
  29699. * The list of attribute names used in the shader
  29700. */
  29701. attributes?: string[];
  29702. /**
  29703. * The list of uniform names used in the shader
  29704. */
  29705. uniforms?: string[];
  29706. /**
  29707. * The list of sampler names used in the shader
  29708. */
  29709. samplers?: string[];
  29710. /**
  29711. * The list of defines used in the shader
  29712. */
  29713. defines?: string[];
  29714. }
  29715. /**
  29716. * Interface to implement to create a shadow generator compatible with BJS.
  29717. */
  29718. export interface IShadowGenerator {
  29719. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29720. id: string;
  29721. /**
  29722. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29723. * @returns The render target texture if present otherwise, null
  29724. */
  29725. getShadowMap(): Nullable<RenderTargetTexture>;
  29726. /**
  29727. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29728. * @param subMesh The submesh we want to render in the shadow map
  29729. * @param useInstances Defines whether will draw in the map using instances
  29730. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29731. * @returns true if ready otherwise, false
  29732. */
  29733. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29734. /**
  29735. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29736. * @param defines Defines of the material we want to update
  29737. * @param lightIndex Index of the light in the enabled light list of the material
  29738. */
  29739. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29740. /**
  29741. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29742. * defined in the generator but impacting the effect).
  29743. * It implies the uniforms available on the materials are the standard BJS ones.
  29744. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29745. * @param effect The effect we are binding the information for
  29746. */
  29747. bindShadowLight(lightIndex: string, effect: Effect): void;
  29748. /**
  29749. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29750. * (eq to shadow projection matrix * light transform matrix)
  29751. * @returns The transform matrix used to create the shadow map
  29752. */
  29753. getTransformMatrix(): Matrix;
  29754. /**
  29755. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29756. * Cube and 2D textures for instance.
  29757. */
  29758. recreateShadowMap(): void;
  29759. /**
  29760. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29761. * @param onCompiled Callback triggered at the and of the effects compilation
  29762. * @param options Sets of optional options forcing the compilation with different modes
  29763. */
  29764. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29765. useInstances: boolean;
  29766. }>): void;
  29767. /**
  29768. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29769. * @param options Sets of optional options forcing the compilation with different modes
  29770. * @returns A promise that resolves when the compilation completes
  29771. */
  29772. forceCompilationAsync(options?: Partial<{
  29773. useInstances: boolean;
  29774. }>): Promise<void>;
  29775. /**
  29776. * Serializes the shadow generator setup to a json object.
  29777. * @returns The serialized JSON object
  29778. */
  29779. serialize(): any;
  29780. /**
  29781. * Disposes the Shadow map and related Textures and effects.
  29782. */
  29783. dispose(): void;
  29784. }
  29785. /**
  29786. * Default implementation IShadowGenerator.
  29787. * This is the main object responsible of generating shadows in the framework.
  29788. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29789. */
  29790. export class ShadowGenerator implements IShadowGenerator {
  29791. private static _Counter;
  29792. /**
  29793. * Name of the shadow generator class
  29794. */
  29795. static CLASSNAME: string;
  29796. /**
  29797. * Shadow generator mode None: no filtering applied.
  29798. */
  29799. static readonly FILTER_NONE: number;
  29800. /**
  29801. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29802. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29803. */
  29804. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29805. /**
  29806. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29807. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29808. */
  29809. static readonly FILTER_POISSONSAMPLING: number;
  29810. /**
  29811. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29812. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29813. */
  29814. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29815. /**
  29816. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29817. * edge artifacts on steep falloff.
  29818. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29819. */
  29820. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29821. /**
  29822. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29823. * edge artifacts on steep falloff.
  29824. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29825. */
  29826. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29827. /**
  29828. * Shadow generator mode PCF: Percentage Closer Filtering
  29829. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29830. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29831. */
  29832. static readonly FILTER_PCF: number;
  29833. /**
  29834. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29835. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29836. * Contact Hardening
  29837. */
  29838. static readonly FILTER_PCSS: number;
  29839. /**
  29840. * Reserved for PCF and PCSS
  29841. * Highest Quality.
  29842. *
  29843. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29844. *
  29845. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29846. */
  29847. static readonly QUALITY_HIGH: number;
  29848. /**
  29849. * Reserved for PCF and PCSS
  29850. * Good tradeoff for quality/perf cross devices
  29851. *
  29852. * Execute PCF on a 3*3 kernel.
  29853. *
  29854. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29855. */
  29856. static readonly QUALITY_MEDIUM: number;
  29857. /**
  29858. * Reserved for PCF and PCSS
  29859. * The lowest quality but the fastest.
  29860. *
  29861. * Execute PCF on a 1*1 kernel.
  29862. *
  29863. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29864. */
  29865. static readonly QUALITY_LOW: number;
  29866. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29867. id: string;
  29868. /** Gets or sets the custom shader name to use */
  29869. customShaderOptions: ICustomShaderOptions;
  29870. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29871. customAllowRendering: (subMesh: SubMesh) => boolean;
  29872. /**
  29873. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29874. */
  29875. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29876. /**
  29877. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29878. */
  29879. onAfterShadowMapRenderObservable: Observable<Effect>;
  29880. /**
  29881. * Observable triggered before a mesh is rendered in the shadow map.
  29882. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29883. */
  29884. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29885. /**
  29886. * Observable triggered after a mesh is rendered in the shadow map.
  29887. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29888. */
  29889. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29890. protected _bias: number;
  29891. /**
  29892. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29893. */
  29894. get bias(): number;
  29895. /**
  29896. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29897. */
  29898. set bias(bias: number);
  29899. protected _normalBias: number;
  29900. /**
  29901. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29902. */
  29903. get normalBias(): number;
  29904. /**
  29905. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29906. */
  29907. set normalBias(normalBias: number);
  29908. protected _blurBoxOffset: number;
  29909. /**
  29910. * Gets the blur box offset: offset applied during the blur pass.
  29911. * Only useful if useKernelBlur = false
  29912. */
  29913. get blurBoxOffset(): number;
  29914. /**
  29915. * Sets the blur box offset: offset applied during the blur pass.
  29916. * Only useful if useKernelBlur = false
  29917. */
  29918. set blurBoxOffset(value: number);
  29919. protected _blurScale: number;
  29920. /**
  29921. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29922. * 2 means half of the size.
  29923. */
  29924. get blurScale(): number;
  29925. /**
  29926. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29927. * 2 means half of the size.
  29928. */
  29929. set blurScale(value: number);
  29930. protected _blurKernel: number;
  29931. /**
  29932. * Gets the blur kernel: kernel size of the blur pass.
  29933. * Only useful if useKernelBlur = true
  29934. */
  29935. get blurKernel(): number;
  29936. /**
  29937. * Sets the blur kernel: kernel size of the blur pass.
  29938. * Only useful if useKernelBlur = true
  29939. */
  29940. set blurKernel(value: number);
  29941. protected _useKernelBlur: boolean;
  29942. /**
  29943. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29944. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29945. */
  29946. get useKernelBlur(): boolean;
  29947. /**
  29948. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29949. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29950. */
  29951. set useKernelBlur(value: boolean);
  29952. protected _depthScale: number;
  29953. /**
  29954. * Gets the depth scale used in ESM mode.
  29955. */
  29956. get depthScale(): number;
  29957. /**
  29958. * Sets the depth scale used in ESM mode.
  29959. * This can override the scale stored on the light.
  29960. */
  29961. set depthScale(value: number);
  29962. protected _validateFilter(filter: number): number;
  29963. protected _filter: number;
  29964. /**
  29965. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29966. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29967. */
  29968. get filter(): number;
  29969. /**
  29970. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29971. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29972. */
  29973. set filter(value: number);
  29974. /**
  29975. * Gets if the current filter is set to Poisson Sampling.
  29976. */
  29977. get usePoissonSampling(): boolean;
  29978. /**
  29979. * Sets the current filter to Poisson Sampling.
  29980. */
  29981. set usePoissonSampling(value: boolean);
  29982. /**
  29983. * Gets if the current filter is set to ESM.
  29984. */
  29985. get useExponentialShadowMap(): boolean;
  29986. /**
  29987. * Sets the current filter is to ESM.
  29988. */
  29989. set useExponentialShadowMap(value: boolean);
  29990. /**
  29991. * Gets if the current filter is set to filtered ESM.
  29992. */
  29993. get useBlurExponentialShadowMap(): boolean;
  29994. /**
  29995. * Gets if the current filter is set to filtered ESM.
  29996. */
  29997. set useBlurExponentialShadowMap(value: boolean);
  29998. /**
  29999. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30000. * exponential to prevent steep falloff artifacts).
  30001. */
  30002. get useCloseExponentialShadowMap(): boolean;
  30003. /**
  30004. * Sets the current filter to "close ESM" (using the inverse of the
  30005. * exponential to prevent steep falloff artifacts).
  30006. */
  30007. set useCloseExponentialShadowMap(value: boolean);
  30008. /**
  30009. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30010. * exponential to prevent steep falloff artifacts).
  30011. */
  30012. get useBlurCloseExponentialShadowMap(): boolean;
  30013. /**
  30014. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30015. * exponential to prevent steep falloff artifacts).
  30016. */
  30017. set useBlurCloseExponentialShadowMap(value: boolean);
  30018. /**
  30019. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30020. */
  30021. get usePercentageCloserFiltering(): boolean;
  30022. /**
  30023. * Sets the current filter to "PCF" (percentage closer filtering).
  30024. */
  30025. set usePercentageCloserFiltering(value: boolean);
  30026. protected _filteringQuality: number;
  30027. /**
  30028. * Gets the PCF or PCSS Quality.
  30029. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30030. */
  30031. get filteringQuality(): number;
  30032. /**
  30033. * Sets the PCF or PCSS Quality.
  30034. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30035. */
  30036. set filteringQuality(filteringQuality: number);
  30037. /**
  30038. * Gets if the current filter is set to "PCSS" (contact hardening).
  30039. */
  30040. get useContactHardeningShadow(): boolean;
  30041. /**
  30042. * Sets the current filter to "PCSS" (contact hardening).
  30043. */
  30044. set useContactHardeningShadow(value: boolean);
  30045. protected _contactHardeningLightSizeUVRatio: number;
  30046. /**
  30047. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30048. * Using a ratio helps keeping shape stability independently of the map size.
  30049. *
  30050. * It does not account for the light projection as it was having too much
  30051. * instability during the light setup or during light position changes.
  30052. *
  30053. * Only valid if useContactHardeningShadow is true.
  30054. */
  30055. get contactHardeningLightSizeUVRatio(): number;
  30056. /**
  30057. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30058. * Using a ratio helps keeping shape stability independently of the map size.
  30059. *
  30060. * It does not account for the light projection as it was having too much
  30061. * instability during the light setup or during light position changes.
  30062. *
  30063. * Only valid if useContactHardeningShadow is true.
  30064. */
  30065. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30066. protected _darkness: number;
  30067. /** Gets or sets the actual darkness of a shadow */
  30068. get darkness(): number;
  30069. set darkness(value: number);
  30070. /**
  30071. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30072. * 0 means strongest and 1 would means no shadow.
  30073. * @returns the darkness.
  30074. */
  30075. getDarkness(): number;
  30076. /**
  30077. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30078. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30079. * @returns the shadow generator allowing fluent coding.
  30080. */
  30081. setDarkness(darkness: number): ShadowGenerator;
  30082. protected _transparencyShadow: boolean;
  30083. /** Gets or sets the ability to have transparent shadow */
  30084. get transparencyShadow(): boolean;
  30085. set transparencyShadow(value: boolean);
  30086. /**
  30087. * Sets the ability to have transparent shadow (boolean).
  30088. * @param transparent True if transparent else False
  30089. * @returns the shadow generator allowing fluent coding
  30090. */
  30091. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30092. /**
  30093. * Enables or disables shadows with varying strength based on the transparency
  30094. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30095. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30096. * mesh.visibility * alphaTexture.a
  30097. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30098. */
  30099. enableSoftTransparentShadow: boolean;
  30100. protected _shadowMap: Nullable<RenderTargetTexture>;
  30101. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30102. /**
  30103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30104. * @returns The render target texture if present otherwise, null
  30105. */
  30106. getShadowMap(): Nullable<RenderTargetTexture>;
  30107. /**
  30108. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30109. * @returns The render target texture if the shadow map is present otherwise, null
  30110. */
  30111. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30112. /**
  30113. * Gets the class name of that object
  30114. * @returns "ShadowGenerator"
  30115. */
  30116. getClassName(): string;
  30117. /**
  30118. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30119. * @param mesh Mesh to add
  30120. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30121. * @returns the Shadow Generator itself
  30122. */
  30123. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30124. /**
  30125. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30126. * @param mesh Mesh to remove
  30127. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30128. * @returns the Shadow Generator itself
  30129. */
  30130. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30131. /**
  30132. * Controls the extent to which the shadows fade out at the edge of the frustum
  30133. */
  30134. frustumEdgeFalloff: number;
  30135. protected _light: IShadowLight;
  30136. /**
  30137. * Returns the associated light object.
  30138. * @returns the light generating the shadow
  30139. */
  30140. getLight(): IShadowLight;
  30141. /**
  30142. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30143. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30144. * It might on the other hand introduce peter panning.
  30145. */
  30146. forceBackFacesOnly: boolean;
  30147. protected _scene: Scene;
  30148. protected _lightDirection: Vector3;
  30149. protected _viewMatrix: Matrix;
  30150. protected _projectionMatrix: Matrix;
  30151. protected _transformMatrix: Matrix;
  30152. protected _cachedPosition: Vector3;
  30153. protected _cachedDirection: Vector3;
  30154. protected _cachedDefines: string;
  30155. protected _currentRenderID: number;
  30156. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30157. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30158. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30159. protected _blurPostProcesses: PostProcess[];
  30160. protected _mapSize: number;
  30161. protected _currentFaceIndex: number;
  30162. protected _currentFaceIndexCache: number;
  30163. protected _textureType: number;
  30164. protected _defaultTextureMatrix: Matrix;
  30165. protected _storedUniqueId: Nullable<number>;
  30166. protected _nameForCustomEffect: string;
  30167. /** @hidden */
  30168. static _SceneComponentInitialization: (scene: Scene) => void;
  30169. /**
  30170. * Gets or sets the size of the texture what stores the shadows
  30171. */
  30172. get mapSize(): number;
  30173. set mapSize(size: number);
  30174. /**
  30175. * Creates a ShadowGenerator object.
  30176. * A ShadowGenerator is the required tool to use the shadows.
  30177. * Each light casting shadows needs to use its own ShadowGenerator.
  30178. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30179. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30180. * @param light The light object generating the shadows.
  30181. * @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.
  30182. */
  30183. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30184. protected _initializeGenerator(): void;
  30185. protected _createTargetRenderTexture(): void;
  30186. protected _initializeShadowMap(): void;
  30187. protected _initializeBlurRTTAndPostProcesses(): void;
  30188. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30189. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30190. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30191. protected _applyFilterValues(): void;
  30192. /**
  30193. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30194. * @param onCompiled Callback triggered at the and of the effects compilation
  30195. * @param options Sets of optional options forcing the compilation with different modes
  30196. */
  30197. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30198. useInstances: boolean;
  30199. }>): void;
  30200. /**
  30201. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30202. * @param options Sets of optional options forcing the compilation with different modes
  30203. * @returns A promise that resolves when the compilation completes
  30204. */
  30205. forceCompilationAsync(options?: Partial<{
  30206. useInstances: boolean;
  30207. }>): Promise<void>;
  30208. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30209. private _prepareShadowDefines;
  30210. /**
  30211. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30212. * @param subMesh The submesh we want to render in the shadow map
  30213. * @param useInstances Defines whether will draw in the map using instances
  30214. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30215. * @returns true if ready otherwise, false
  30216. */
  30217. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30218. /**
  30219. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30220. * @param defines Defines of the material we want to update
  30221. * @param lightIndex Index of the light in the enabled light list of the material
  30222. */
  30223. prepareDefines(defines: any, lightIndex: number): void;
  30224. /**
  30225. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30226. * defined in the generator but impacting the effect).
  30227. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30228. * @param effect The effect we are binding the information for
  30229. */
  30230. bindShadowLight(lightIndex: string, effect: Effect): void;
  30231. /**
  30232. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30233. * (eq to shadow projection matrix * light transform matrix)
  30234. * @returns The transform matrix used to create the shadow map
  30235. */
  30236. getTransformMatrix(): Matrix;
  30237. /**
  30238. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30239. * Cube and 2D textures for instance.
  30240. */
  30241. recreateShadowMap(): void;
  30242. protected _disposeBlurPostProcesses(): void;
  30243. protected _disposeRTTandPostProcesses(): void;
  30244. /**
  30245. * Disposes the ShadowGenerator.
  30246. * Returns nothing.
  30247. */
  30248. dispose(): void;
  30249. /**
  30250. * Serializes the shadow generator setup to a json object.
  30251. * @returns The serialized JSON object
  30252. */
  30253. serialize(): any;
  30254. /**
  30255. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30256. * @param parsedShadowGenerator The JSON object to parse
  30257. * @param scene The scene to create the shadow map for
  30258. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30259. * @returns The parsed shadow generator
  30260. */
  30261. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30262. }
  30263. }
  30264. declare module BABYLON {
  30265. /**
  30266. * Options to be used when creating a shadow depth material
  30267. */
  30268. export interface IIOptionShadowDepthMaterial {
  30269. /** Variables in the vertex shader code that need to have their names remapped.
  30270. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30271. * "var_name" should be either: worldPos or vNormalW
  30272. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30273. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30274. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30275. */
  30276. remappedVariables?: string[];
  30277. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30278. standalone?: boolean;
  30279. }
  30280. /**
  30281. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30282. */
  30283. export class ShadowDepthWrapper {
  30284. private _scene;
  30285. private _options?;
  30286. private _baseMaterial;
  30287. private _onEffectCreatedObserver;
  30288. private _subMeshToEffect;
  30289. private _subMeshToDepthEffect;
  30290. private _meshes;
  30291. /** @hidden */
  30292. _matriceNames: any;
  30293. /** Gets the standalone status of the wrapper */
  30294. get standalone(): boolean;
  30295. /** Gets the base material the wrapper is built upon */
  30296. get baseMaterial(): Material;
  30297. /**
  30298. * Instantiate a new shadow depth wrapper.
  30299. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30300. * generate the shadow depth map. For more information, please refer to the documentation:
  30301. * https://doc.babylonjs.com/babylon101/shadows
  30302. * @param baseMaterial Material to wrap
  30303. * @param scene Define the scene the material belongs to
  30304. * @param options Options used to create the wrapper
  30305. */
  30306. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30307. /**
  30308. * Gets the effect to use to generate the depth map
  30309. * @param subMesh subMesh to get the effect for
  30310. * @param shadowGenerator shadow generator to get the effect for
  30311. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30312. */
  30313. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30314. /**
  30315. * Specifies that the submesh is ready to be used for depth rendering
  30316. * @param subMesh submesh to check
  30317. * @param defines the list of defines to take into account when checking the effect
  30318. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30319. * @param useInstances specifies that instances should be used
  30320. * @returns a boolean indicating that the submesh is ready or not
  30321. */
  30322. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30323. /**
  30324. * Disposes the resources
  30325. */
  30326. dispose(): void;
  30327. private _makeEffect;
  30328. }
  30329. }
  30330. declare module BABYLON {
  30331. /**
  30332. * Options for compiling materials.
  30333. */
  30334. export interface IMaterialCompilationOptions {
  30335. /**
  30336. * Defines whether clip planes are enabled.
  30337. */
  30338. clipPlane: boolean;
  30339. /**
  30340. * Defines whether instances are enabled.
  30341. */
  30342. useInstances: boolean;
  30343. }
  30344. /**
  30345. * Options passed when calling customShaderNameResolve
  30346. */
  30347. export interface ICustomShaderNameResolveOptions {
  30348. /**
  30349. * 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
  30350. */
  30351. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30352. }
  30353. /**
  30354. * Base class for the main features of a material in Babylon.js
  30355. */
  30356. export class Material implements IAnimatable {
  30357. /**
  30358. * Returns the triangle fill mode
  30359. */
  30360. static readonly TriangleFillMode: number;
  30361. /**
  30362. * Returns the wireframe mode
  30363. */
  30364. static readonly WireFrameFillMode: number;
  30365. /**
  30366. * Returns the point fill mode
  30367. */
  30368. static readonly PointFillMode: number;
  30369. /**
  30370. * Returns the point list draw mode
  30371. */
  30372. static readonly PointListDrawMode: number;
  30373. /**
  30374. * Returns the line list draw mode
  30375. */
  30376. static readonly LineListDrawMode: number;
  30377. /**
  30378. * Returns the line loop draw mode
  30379. */
  30380. static readonly LineLoopDrawMode: number;
  30381. /**
  30382. * Returns the line strip draw mode
  30383. */
  30384. static readonly LineStripDrawMode: number;
  30385. /**
  30386. * Returns the triangle strip draw mode
  30387. */
  30388. static readonly TriangleStripDrawMode: number;
  30389. /**
  30390. * Returns the triangle fan draw mode
  30391. */
  30392. static readonly TriangleFanDrawMode: number;
  30393. /**
  30394. * Stores the clock-wise side orientation
  30395. */
  30396. static readonly ClockWiseSideOrientation: number;
  30397. /**
  30398. * Stores the counter clock-wise side orientation
  30399. */
  30400. static readonly CounterClockWiseSideOrientation: number;
  30401. /**
  30402. * The dirty texture flag value
  30403. */
  30404. static readonly TextureDirtyFlag: number;
  30405. /**
  30406. * The dirty light flag value
  30407. */
  30408. static readonly LightDirtyFlag: number;
  30409. /**
  30410. * The dirty fresnel flag value
  30411. */
  30412. static readonly FresnelDirtyFlag: number;
  30413. /**
  30414. * The dirty attribute flag value
  30415. */
  30416. static readonly AttributesDirtyFlag: number;
  30417. /**
  30418. * The dirty misc flag value
  30419. */
  30420. static readonly MiscDirtyFlag: number;
  30421. /**
  30422. * The dirty prepass flag value
  30423. */
  30424. static readonly PrePassDirtyFlag: number;
  30425. /**
  30426. * The all dirty flag value
  30427. */
  30428. static readonly AllDirtyFlag: number;
  30429. /**
  30430. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30431. */
  30432. static readonly MATERIAL_OPAQUE: number;
  30433. /**
  30434. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30435. */
  30436. static readonly MATERIAL_ALPHATEST: number;
  30437. /**
  30438. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30439. */
  30440. static readonly MATERIAL_ALPHABLEND: number;
  30441. /**
  30442. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30443. * They are also discarded below the alpha cutoff threshold to improve performances.
  30444. */
  30445. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30446. /**
  30447. * The Whiteout method is used to blend normals.
  30448. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30449. */
  30450. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30451. /**
  30452. * The Reoriented Normal Mapping method is used to blend normals.
  30453. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30454. */
  30455. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30456. /**
  30457. * Custom callback helping to override the default shader used in the material.
  30458. */
  30459. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30460. /**
  30461. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30462. */
  30463. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30464. /**
  30465. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30466. * This means that the material can keep using a previous shader while a new one is being compiled.
  30467. * This is mostly used when shader parallel compilation is supported (true by default)
  30468. */
  30469. allowShaderHotSwapping: boolean;
  30470. /**
  30471. * The ID of the material
  30472. */
  30473. id: string;
  30474. /**
  30475. * Gets or sets the unique id of the material
  30476. */
  30477. uniqueId: number;
  30478. /**
  30479. * The name of the material
  30480. */
  30481. name: string;
  30482. /**
  30483. * Gets or sets user defined metadata
  30484. */
  30485. metadata: any;
  30486. /**
  30487. * For internal use only. Please do not use.
  30488. */
  30489. reservedDataStore: any;
  30490. /**
  30491. * Specifies if the ready state should be checked on each call
  30492. */
  30493. checkReadyOnEveryCall: boolean;
  30494. /**
  30495. * Specifies if the ready state should be checked once
  30496. */
  30497. checkReadyOnlyOnce: boolean;
  30498. /**
  30499. * The state of the material
  30500. */
  30501. state: string;
  30502. /**
  30503. * If the material can be rendered to several textures with MRT extension
  30504. */
  30505. get canRenderToMRT(): boolean;
  30506. /**
  30507. * The alpha value of the material
  30508. */
  30509. protected _alpha: number;
  30510. /**
  30511. * List of inspectable custom properties (used by the Inspector)
  30512. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30513. */
  30514. inspectableCustomProperties: IInspectable[];
  30515. /**
  30516. * Sets the alpha value of the material
  30517. */
  30518. set alpha(value: number);
  30519. /**
  30520. * Gets the alpha value of the material
  30521. */
  30522. get alpha(): number;
  30523. /**
  30524. * Specifies if back face culling is enabled
  30525. */
  30526. protected _backFaceCulling: boolean;
  30527. /**
  30528. * Sets the back-face culling state
  30529. */
  30530. set backFaceCulling(value: boolean);
  30531. /**
  30532. * Gets the back-face culling state
  30533. */
  30534. get backFaceCulling(): boolean;
  30535. /**
  30536. * Stores the value for side orientation
  30537. */
  30538. sideOrientation: number;
  30539. /**
  30540. * Callback triggered when the material is compiled
  30541. */
  30542. onCompiled: Nullable<(effect: Effect) => void>;
  30543. /**
  30544. * Callback triggered when an error occurs
  30545. */
  30546. onError: Nullable<(effect: Effect, errors: string) => void>;
  30547. /**
  30548. * Callback triggered to get the render target textures
  30549. */
  30550. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30551. /**
  30552. * Gets a boolean indicating that current material needs to register RTT
  30553. */
  30554. get hasRenderTargetTextures(): boolean;
  30555. /**
  30556. * Specifies if the material should be serialized
  30557. */
  30558. doNotSerialize: boolean;
  30559. /**
  30560. * @hidden
  30561. */
  30562. _storeEffectOnSubMeshes: boolean;
  30563. /**
  30564. * Stores the animations for the material
  30565. */
  30566. animations: Nullable<Array<Animation>>;
  30567. /**
  30568. * An event triggered when the material is disposed
  30569. */
  30570. onDisposeObservable: Observable<Material>;
  30571. /**
  30572. * An observer which watches for dispose events
  30573. */
  30574. private _onDisposeObserver;
  30575. private _onUnBindObservable;
  30576. /**
  30577. * Called during a dispose event
  30578. */
  30579. set onDispose(callback: () => void);
  30580. private _onBindObservable;
  30581. /**
  30582. * An event triggered when the material is bound
  30583. */
  30584. get onBindObservable(): Observable<AbstractMesh>;
  30585. /**
  30586. * An observer which watches for bind events
  30587. */
  30588. private _onBindObserver;
  30589. /**
  30590. * Called during a bind event
  30591. */
  30592. set onBind(callback: (Mesh: AbstractMesh) => void);
  30593. /**
  30594. * An event triggered when the material is unbound
  30595. */
  30596. get onUnBindObservable(): Observable<Material>;
  30597. protected _onEffectCreatedObservable: Nullable<Observable<{
  30598. effect: Effect;
  30599. subMesh: Nullable<SubMesh>;
  30600. }>>;
  30601. /**
  30602. * An event triggered when the effect is (re)created
  30603. */
  30604. get onEffectCreatedObservable(): Observable<{
  30605. effect: Effect;
  30606. subMesh: Nullable<SubMesh>;
  30607. }>;
  30608. /**
  30609. * Stores the value of the alpha mode
  30610. */
  30611. private _alphaMode;
  30612. /**
  30613. * Sets the value of the alpha mode.
  30614. *
  30615. * | Value | Type | Description |
  30616. * | --- | --- | --- |
  30617. * | 0 | ALPHA_DISABLE | |
  30618. * | 1 | ALPHA_ADD | |
  30619. * | 2 | ALPHA_COMBINE | |
  30620. * | 3 | ALPHA_SUBTRACT | |
  30621. * | 4 | ALPHA_MULTIPLY | |
  30622. * | 5 | ALPHA_MAXIMIZED | |
  30623. * | 6 | ALPHA_ONEONE | |
  30624. * | 7 | ALPHA_PREMULTIPLIED | |
  30625. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30626. * | 9 | ALPHA_INTERPOLATE | |
  30627. * | 10 | ALPHA_SCREENMODE | |
  30628. *
  30629. */
  30630. set alphaMode(value: number);
  30631. /**
  30632. * Gets the value of the alpha mode
  30633. */
  30634. get alphaMode(): number;
  30635. /**
  30636. * Stores the state of the need depth pre-pass value
  30637. */
  30638. private _needDepthPrePass;
  30639. /**
  30640. * Sets the need depth pre-pass value
  30641. */
  30642. set needDepthPrePass(value: boolean);
  30643. /**
  30644. * Gets the depth pre-pass value
  30645. */
  30646. get needDepthPrePass(): boolean;
  30647. /**
  30648. * Can this material render to prepass
  30649. */
  30650. get isPrePassCapable(): boolean;
  30651. /**
  30652. * Specifies if depth writing should be disabled
  30653. */
  30654. disableDepthWrite: boolean;
  30655. /**
  30656. * Specifies if color writing should be disabled
  30657. */
  30658. disableColorWrite: boolean;
  30659. /**
  30660. * Specifies if depth writing should be forced
  30661. */
  30662. forceDepthWrite: boolean;
  30663. /**
  30664. * Specifies the depth function that should be used. 0 means the default engine function
  30665. */
  30666. depthFunction: number;
  30667. /**
  30668. * Specifies if there should be a separate pass for culling
  30669. */
  30670. separateCullingPass: boolean;
  30671. /**
  30672. * Stores the state specifying if fog should be enabled
  30673. */
  30674. private _fogEnabled;
  30675. /**
  30676. * Sets the state for enabling fog
  30677. */
  30678. set fogEnabled(value: boolean);
  30679. /**
  30680. * Gets the value of the fog enabled state
  30681. */
  30682. get fogEnabled(): boolean;
  30683. /**
  30684. * Stores the size of points
  30685. */
  30686. pointSize: number;
  30687. /**
  30688. * Stores the z offset value
  30689. */
  30690. zOffset: number;
  30691. get wireframe(): boolean;
  30692. /**
  30693. * Sets the state of wireframe mode
  30694. */
  30695. set wireframe(value: boolean);
  30696. /**
  30697. * Gets the value specifying if point clouds are enabled
  30698. */
  30699. get pointsCloud(): boolean;
  30700. /**
  30701. * Sets the state of point cloud mode
  30702. */
  30703. set pointsCloud(value: boolean);
  30704. /**
  30705. * Gets the material fill mode
  30706. */
  30707. get fillMode(): number;
  30708. /**
  30709. * Sets the material fill mode
  30710. */
  30711. set fillMode(value: number);
  30712. /**
  30713. * @hidden
  30714. * Stores the effects for the material
  30715. */
  30716. _effect: Nullable<Effect>;
  30717. /**
  30718. * Specifies if uniform buffers should be used
  30719. */
  30720. private _useUBO;
  30721. /**
  30722. * Stores a reference to the scene
  30723. */
  30724. private _scene;
  30725. private _needToBindSceneUbo;
  30726. /**
  30727. * Stores the fill mode state
  30728. */
  30729. private _fillMode;
  30730. /**
  30731. * Specifies if the depth write state should be cached
  30732. */
  30733. private _cachedDepthWriteState;
  30734. /**
  30735. * Specifies if the color write state should be cached
  30736. */
  30737. private _cachedColorWriteState;
  30738. /**
  30739. * Specifies if the depth function state should be cached
  30740. */
  30741. private _cachedDepthFunctionState;
  30742. /**
  30743. * Stores the uniform buffer
  30744. */
  30745. protected _uniformBuffer: UniformBuffer;
  30746. /** @hidden */
  30747. _indexInSceneMaterialArray: number;
  30748. /** @hidden */
  30749. meshMap: Nullable<{
  30750. [id: string]: AbstractMesh | undefined;
  30751. }>;
  30752. /**
  30753. * Creates a material instance
  30754. * @param name defines the name of the material
  30755. * @param scene defines the scene to reference
  30756. * @param doNotAdd specifies if the material should be added to the scene
  30757. */
  30758. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30759. /**
  30760. * Returns a string representation of the current material
  30761. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30762. * @returns a string with material information
  30763. */
  30764. toString(fullDetails?: boolean): string;
  30765. /**
  30766. * Gets the class name of the material
  30767. * @returns a string with the class name of the material
  30768. */
  30769. getClassName(): string;
  30770. /**
  30771. * Specifies if updates for the material been locked
  30772. */
  30773. get isFrozen(): boolean;
  30774. /**
  30775. * Locks updates for the material
  30776. */
  30777. freeze(): void;
  30778. /**
  30779. * Unlocks updates for the material
  30780. */
  30781. unfreeze(): void;
  30782. /**
  30783. * Specifies if the material is ready to be used
  30784. * @param mesh defines the mesh to check
  30785. * @param useInstances specifies if instances should be used
  30786. * @returns a boolean indicating if the material is ready to be used
  30787. */
  30788. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30789. /**
  30790. * Specifies that the submesh is ready to be used
  30791. * @param mesh defines the mesh to check
  30792. * @param subMesh defines which submesh to check
  30793. * @param useInstances specifies that instances should be used
  30794. * @returns a boolean indicating that the submesh is ready or not
  30795. */
  30796. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30797. /**
  30798. * Returns the material effect
  30799. * @returns the effect associated with the material
  30800. */
  30801. getEffect(): Nullable<Effect>;
  30802. /**
  30803. * Returns the current scene
  30804. * @returns a Scene
  30805. */
  30806. getScene(): Scene;
  30807. /**
  30808. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30809. */
  30810. protected _forceAlphaTest: boolean;
  30811. /**
  30812. * The transparency mode of the material.
  30813. */
  30814. protected _transparencyMode: Nullable<number>;
  30815. /**
  30816. * Gets the current transparency mode.
  30817. */
  30818. get transparencyMode(): Nullable<number>;
  30819. /**
  30820. * Sets the transparency mode of the material.
  30821. *
  30822. * | Value | Type | Description |
  30823. * | ----- | ----------------------------------- | ----------- |
  30824. * | 0 | OPAQUE | |
  30825. * | 1 | ALPHATEST | |
  30826. * | 2 | ALPHABLEND | |
  30827. * | 3 | ALPHATESTANDBLEND | |
  30828. *
  30829. */
  30830. set transparencyMode(value: Nullable<number>);
  30831. /**
  30832. * Returns true if alpha blending should be disabled.
  30833. */
  30834. protected get _disableAlphaBlending(): boolean;
  30835. /**
  30836. * Specifies whether or not this material should be rendered in alpha blend mode.
  30837. * @returns a boolean specifying if alpha blending is needed
  30838. */
  30839. needAlphaBlending(): boolean;
  30840. /**
  30841. * Specifies if the mesh will require alpha blending
  30842. * @param mesh defines the mesh to check
  30843. * @returns a boolean specifying if alpha blending is needed for the mesh
  30844. */
  30845. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30846. /**
  30847. * Specifies whether or not this material should be rendered in alpha test mode.
  30848. * @returns a boolean specifying if an alpha test is needed.
  30849. */
  30850. needAlphaTesting(): boolean;
  30851. /**
  30852. * Specifies if material alpha testing should be turned on for the mesh
  30853. * @param mesh defines the mesh to check
  30854. */
  30855. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30856. /**
  30857. * Gets the texture used for the alpha test
  30858. * @returns the texture to use for alpha testing
  30859. */
  30860. getAlphaTestTexture(): Nullable<BaseTexture>;
  30861. /**
  30862. * Marks the material to indicate that it needs to be re-calculated
  30863. */
  30864. markDirty(): void;
  30865. /** @hidden */
  30866. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30867. /**
  30868. * Binds the material to the mesh
  30869. * @param world defines the world transformation matrix
  30870. * @param mesh defines the mesh to bind the material to
  30871. */
  30872. bind(world: Matrix, mesh?: Mesh): void;
  30873. /**
  30874. * Binds the submesh to the material
  30875. * @param world defines the world transformation matrix
  30876. * @param mesh defines the mesh containing the submesh
  30877. * @param subMesh defines the submesh to bind the material to
  30878. */
  30879. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30880. /**
  30881. * Binds the world matrix to the material
  30882. * @param world defines the world transformation matrix
  30883. */
  30884. bindOnlyWorldMatrix(world: Matrix): void;
  30885. /**
  30886. * Binds the view matrix to the effect
  30887. * @param effect defines the effect to bind the view matrix to
  30888. */
  30889. bindView(effect: Effect): void;
  30890. /**
  30891. * Binds the view projection and projection matrices to the effect
  30892. * @param effect defines the effect to bind the view projection and projection matrices to
  30893. */
  30894. bindViewProjection(effect: Effect): void;
  30895. /**
  30896. * Binds the view matrix to the effect
  30897. * @param effect defines the effect to bind the view matrix to
  30898. * @param variableName name of the shader variable that will hold the eye position
  30899. */
  30900. bindEyePosition(effect: Effect, variableName?: string): void;
  30901. /**
  30902. * Processes to execute after binding the material to a mesh
  30903. * @param mesh defines the rendered mesh
  30904. */
  30905. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30906. /**
  30907. * Unbinds the material from the mesh
  30908. */
  30909. unbind(): void;
  30910. /**
  30911. * Gets the active textures from the material
  30912. * @returns an array of textures
  30913. */
  30914. getActiveTextures(): BaseTexture[];
  30915. /**
  30916. * Specifies if the material uses a texture
  30917. * @param texture defines the texture to check against the material
  30918. * @returns a boolean specifying if the material uses the texture
  30919. */
  30920. hasTexture(texture: BaseTexture): boolean;
  30921. /**
  30922. * Makes a duplicate of the material, and gives it a new name
  30923. * @param name defines the new name for the duplicated material
  30924. * @returns the cloned material
  30925. */
  30926. clone(name: string): Nullable<Material>;
  30927. /**
  30928. * Gets the meshes bound to the material
  30929. * @returns an array of meshes bound to the material
  30930. */
  30931. getBindedMeshes(): AbstractMesh[];
  30932. /**
  30933. * Force shader compilation
  30934. * @param mesh defines the mesh associated with this material
  30935. * @param onCompiled defines a function to execute once the material is compiled
  30936. * @param options defines the options to configure the compilation
  30937. * @param onError defines a function to execute if the material fails compiling
  30938. */
  30939. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30940. /**
  30941. * Force shader compilation
  30942. * @param mesh defines the mesh that will use this material
  30943. * @param options defines additional options for compiling the shaders
  30944. * @returns a promise that resolves when the compilation completes
  30945. */
  30946. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30947. private static readonly _AllDirtyCallBack;
  30948. private static readonly _ImageProcessingDirtyCallBack;
  30949. private static readonly _TextureDirtyCallBack;
  30950. private static readonly _FresnelDirtyCallBack;
  30951. private static readonly _MiscDirtyCallBack;
  30952. private static readonly _PrePassDirtyCallBack;
  30953. private static readonly _LightsDirtyCallBack;
  30954. private static readonly _AttributeDirtyCallBack;
  30955. private static _FresnelAndMiscDirtyCallBack;
  30956. private static _TextureAndMiscDirtyCallBack;
  30957. private static readonly _DirtyCallbackArray;
  30958. private static readonly _RunDirtyCallBacks;
  30959. /**
  30960. * Marks a define in the material to indicate that it needs to be re-computed
  30961. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30962. */
  30963. markAsDirty(flag: number): void;
  30964. /**
  30965. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30966. * @param func defines a function which checks material defines against the submeshes
  30967. */
  30968. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30969. /**
  30970. * Indicates that the scene should check if the rendering now needs a prepass
  30971. */
  30972. protected _markScenePrePassDirty(): void;
  30973. /**
  30974. * Indicates that we need to re-calculated for all submeshes
  30975. */
  30976. protected _markAllSubMeshesAsAllDirty(): void;
  30977. /**
  30978. * Indicates that image processing needs to be re-calculated for all submeshes
  30979. */
  30980. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30981. /**
  30982. * Indicates that textures need to be re-calculated for all submeshes
  30983. */
  30984. protected _markAllSubMeshesAsTexturesDirty(): void;
  30985. /**
  30986. * Indicates that fresnel needs to be re-calculated for all submeshes
  30987. */
  30988. protected _markAllSubMeshesAsFresnelDirty(): void;
  30989. /**
  30990. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30991. */
  30992. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30993. /**
  30994. * Indicates that lights need to be re-calculated for all submeshes
  30995. */
  30996. protected _markAllSubMeshesAsLightsDirty(): void;
  30997. /**
  30998. * Indicates that attributes need to be re-calculated for all submeshes
  30999. */
  31000. protected _markAllSubMeshesAsAttributesDirty(): void;
  31001. /**
  31002. * Indicates that misc needs to be re-calculated for all submeshes
  31003. */
  31004. protected _markAllSubMeshesAsMiscDirty(): void;
  31005. /**
  31006. * Indicates that prepass needs to be re-calculated for all submeshes
  31007. */
  31008. protected _markAllSubMeshesAsPrePassDirty(): void;
  31009. /**
  31010. * Indicates that textures and misc need to be re-calculated for all submeshes
  31011. */
  31012. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31013. /**
  31014. * Sets the required values to the prepass renderer.
  31015. * @param prePassRenderer defines the prepass renderer to setup.
  31016. * @returns true if the pre pass is needed.
  31017. */
  31018. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31019. /**
  31020. * Disposes the material
  31021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31024. */
  31025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31026. /** @hidden */
  31027. private releaseVertexArrayObject;
  31028. /**
  31029. * Serializes this material
  31030. * @returns the serialized material object
  31031. */
  31032. serialize(): any;
  31033. /**
  31034. * Creates a material from parsed material data
  31035. * @param parsedMaterial defines parsed material data
  31036. * @param scene defines the hosting scene
  31037. * @param rootUrl defines the root URL to use to load textures
  31038. * @returns a new material
  31039. */
  31040. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31041. }
  31042. }
  31043. declare module BABYLON {
  31044. /**
  31045. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31046. * separate meshes. This can be use to improve performances.
  31047. * @see https://doc.babylonjs.com/how_to/multi_materials
  31048. */
  31049. export class MultiMaterial extends Material {
  31050. private _subMaterials;
  31051. /**
  31052. * Gets or Sets the list of Materials used within the multi material.
  31053. * They need to be ordered according to the submeshes order in the associated mesh
  31054. */
  31055. get subMaterials(): Nullable<Material>[];
  31056. set subMaterials(value: Nullable<Material>[]);
  31057. /**
  31058. * Function used to align with Node.getChildren()
  31059. * @returns the list of Materials used within the multi material
  31060. */
  31061. getChildren(): Nullable<Material>[];
  31062. /**
  31063. * Instantiates a new Multi Material
  31064. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31065. * separate meshes. This can be use to improve performances.
  31066. * @see https://doc.babylonjs.com/how_to/multi_materials
  31067. * @param name Define the name in the scene
  31068. * @param scene Define the scene the material belongs to
  31069. */
  31070. constructor(name: string, scene: Scene);
  31071. private _hookArray;
  31072. /**
  31073. * Get one of the submaterial by its index in the submaterials array
  31074. * @param index The index to look the sub material at
  31075. * @returns The Material if the index has been defined
  31076. */
  31077. getSubMaterial(index: number): Nullable<Material>;
  31078. /**
  31079. * Get the list of active textures for the whole sub materials list.
  31080. * @returns All the textures that will be used during the rendering
  31081. */
  31082. getActiveTextures(): BaseTexture[];
  31083. /**
  31084. * Specifies if any sub-materials of this multi-material use a given texture.
  31085. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31086. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31087. */
  31088. hasTexture(texture: BaseTexture): boolean;
  31089. /**
  31090. * Gets the current class name of the material e.g. "MultiMaterial"
  31091. * Mainly use in serialization.
  31092. * @returns the class name
  31093. */
  31094. getClassName(): string;
  31095. /**
  31096. * Checks if the material is ready to render the requested sub mesh
  31097. * @param mesh Define the mesh the submesh belongs to
  31098. * @param subMesh Define the sub mesh to look readiness for
  31099. * @param useInstances Define whether or not the material is used with instances
  31100. * @returns true if ready, otherwise false
  31101. */
  31102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31103. /**
  31104. * Clones the current material and its related sub materials
  31105. * @param name Define the name of the newly cloned material
  31106. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31107. * @returns the cloned material
  31108. */
  31109. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31110. /**
  31111. * Serializes the materials into a JSON representation.
  31112. * @returns the JSON representation
  31113. */
  31114. serialize(): any;
  31115. /**
  31116. * Dispose the material and release its associated resources
  31117. * @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)
  31118. * @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)
  31119. * @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)
  31120. */
  31121. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31122. /**
  31123. * Creates a MultiMaterial from parsed MultiMaterial data.
  31124. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31125. * @param scene defines the hosting scene
  31126. * @returns a new MultiMaterial
  31127. */
  31128. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31129. }
  31130. }
  31131. declare module BABYLON {
  31132. /** @hidden */
  31133. export interface ICustomEffect {
  31134. effect: Effect;
  31135. defines: string;
  31136. }
  31137. /**
  31138. * Defines a subdivision inside a mesh
  31139. */
  31140. export class SubMesh implements ICullable {
  31141. /** the material index to use */
  31142. materialIndex: number;
  31143. /** vertex index start */
  31144. verticesStart: number;
  31145. /** vertices count */
  31146. verticesCount: number;
  31147. /** index start */
  31148. indexStart: number;
  31149. /** indices count */
  31150. indexCount: number;
  31151. /** @hidden */
  31152. _materialDefines: Nullable<MaterialDefines>;
  31153. /** @hidden */
  31154. _materialEffect: Nullable<Effect>;
  31155. /** @hidden */
  31156. _effectOverride: Nullable<Effect>;
  31157. private _customEffects;
  31158. /**
  31159. * Gets material defines used by the effect associated to the sub mesh
  31160. */
  31161. get materialDefines(): Nullable<MaterialDefines>;
  31162. /**
  31163. * Sets material defines used by the effect associated to the sub mesh
  31164. */
  31165. set materialDefines(defines: Nullable<MaterialDefines>);
  31166. /** @hidden */
  31167. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31168. /** @hidden */
  31169. _removeCustomEffect(name: string): void;
  31170. /**
  31171. * Gets associated effect
  31172. */
  31173. get effect(): Nullable<Effect>;
  31174. /**
  31175. * Sets associated effect (effect used to render this submesh)
  31176. * @param effect defines the effect to associate with
  31177. * @param defines defines the set of defines used to compile this effect
  31178. */
  31179. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31180. /** @hidden */
  31181. _linesIndexCount: number;
  31182. private _mesh;
  31183. private _renderingMesh;
  31184. private _boundingInfo;
  31185. private _linesIndexBuffer;
  31186. /** @hidden */
  31187. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31188. /** @hidden */
  31189. _trianglePlanes: Plane[];
  31190. /** @hidden */
  31191. _lastColliderTransformMatrix: Nullable<Matrix>;
  31192. /** @hidden */
  31193. _renderId: number;
  31194. /** @hidden */
  31195. _alphaIndex: number;
  31196. /** @hidden */
  31197. _distanceToCamera: number;
  31198. /** @hidden */
  31199. _id: number;
  31200. private _currentMaterial;
  31201. /**
  31202. * Add a new submesh to a mesh
  31203. * @param materialIndex defines the material index to use
  31204. * @param verticesStart defines vertex index start
  31205. * @param verticesCount defines vertices count
  31206. * @param indexStart defines index start
  31207. * @param indexCount defines indices count
  31208. * @param mesh defines the parent mesh
  31209. * @param renderingMesh defines an optional rendering mesh
  31210. * @param createBoundingBox defines if bounding box should be created for this submesh
  31211. * @returns the new submesh
  31212. */
  31213. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31214. /**
  31215. * Creates a new submesh
  31216. * @param materialIndex defines the material index to use
  31217. * @param verticesStart defines vertex index start
  31218. * @param verticesCount defines vertices count
  31219. * @param indexStart defines index start
  31220. * @param indexCount defines indices count
  31221. * @param mesh defines the parent mesh
  31222. * @param renderingMesh defines an optional rendering mesh
  31223. * @param createBoundingBox defines if bounding box should be created for this submesh
  31224. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31225. */
  31226. constructor(
  31227. /** the material index to use */
  31228. materialIndex: number,
  31229. /** vertex index start */
  31230. verticesStart: number,
  31231. /** vertices count */
  31232. verticesCount: number,
  31233. /** index start */
  31234. indexStart: number,
  31235. /** indices count */
  31236. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31237. /**
  31238. * Returns true if this submesh covers the entire parent mesh
  31239. * @ignorenaming
  31240. */
  31241. get IsGlobal(): boolean;
  31242. /**
  31243. * Returns the submesh BoundingInfo object
  31244. * @returns current bounding info (or mesh's one if the submesh is global)
  31245. */
  31246. getBoundingInfo(): BoundingInfo;
  31247. /**
  31248. * Sets the submesh BoundingInfo
  31249. * @param boundingInfo defines the new bounding info to use
  31250. * @returns the SubMesh
  31251. */
  31252. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31253. /**
  31254. * Returns the mesh of the current submesh
  31255. * @return the parent mesh
  31256. */
  31257. getMesh(): AbstractMesh;
  31258. /**
  31259. * Returns the rendering mesh of the submesh
  31260. * @returns the rendering mesh (could be different from parent mesh)
  31261. */
  31262. getRenderingMesh(): Mesh;
  31263. /**
  31264. * Returns the replacement mesh of the submesh
  31265. * @returns the replacement mesh (could be different from parent mesh)
  31266. */
  31267. getReplacementMesh(): Nullable<AbstractMesh>;
  31268. /**
  31269. * Returns the effective mesh of the submesh
  31270. * @returns the effective mesh (could be different from parent mesh)
  31271. */
  31272. getEffectiveMesh(): AbstractMesh;
  31273. /**
  31274. * Returns the submesh material
  31275. * @returns null or the current material
  31276. */
  31277. getMaterial(): Nullable<Material>;
  31278. private _IsMultiMaterial;
  31279. /**
  31280. * Sets a new updated BoundingInfo object to the submesh
  31281. * @param data defines an optional position array to use to determine the bounding info
  31282. * @returns the SubMesh
  31283. */
  31284. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31285. /** @hidden */
  31286. _checkCollision(collider: Collider): boolean;
  31287. /**
  31288. * Updates the submesh BoundingInfo
  31289. * @param world defines the world matrix to use to update the bounding info
  31290. * @returns the submesh
  31291. */
  31292. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31293. /**
  31294. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31295. * @param frustumPlanes defines the frustum planes
  31296. * @returns true if the submesh is intersecting with the frustum
  31297. */
  31298. isInFrustum(frustumPlanes: Plane[]): boolean;
  31299. /**
  31300. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31301. * @param frustumPlanes defines the frustum planes
  31302. * @returns true if the submesh is inside the frustum
  31303. */
  31304. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31305. /**
  31306. * Renders the submesh
  31307. * @param enableAlphaMode defines if alpha needs to be used
  31308. * @returns the submesh
  31309. */
  31310. render(enableAlphaMode: boolean): SubMesh;
  31311. /**
  31312. * @hidden
  31313. */
  31314. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31315. /**
  31316. * Checks if the submesh intersects with a ray
  31317. * @param ray defines the ray to test
  31318. * @returns true is the passed ray intersects the submesh bounding box
  31319. */
  31320. canIntersects(ray: Ray): boolean;
  31321. /**
  31322. * Intersects current submesh with a ray
  31323. * @param ray defines the ray to test
  31324. * @param positions defines mesh's positions array
  31325. * @param indices defines mesh's indices array
  31326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31327. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31328. * @returns intersection info or null if no intersection
  31329. */
  31330. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31331. /** @hidden */
  31332. private _intersectLines;
  31333. /** @hidden */
  31334. private _intersectUnIndexedLines;
  31335. /** @hidden */
  31336. private _intersectTriangles;
  31337. /** @hidden */
  31338. private _intersectUnIndexedTriangles;
  31339. /** @hidden */
  31340. _rebuild(): void;
  31341. /**
  31342. * Creates a new submesh from the passed mesh
  31343. * @param newMesh defines the new hosting mesh
  31344. * @param newRenderingMesh defines an optional rendering mesh
  31345. * @returns the new submesh
  31346. */
  31347. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31348. /**
  31349. * Release associated resources
  31350. */
  31351. dispose(): void;
  31352. /**
  31353. * Gets the class name
  31354. * @returns the string "SubMesh".
  31355. */
  31356. getClassName(): string;
  31357. /**
  31358. * Creates a new submesh from indices data
  31359. * @param materialIndex the index of the main mesh material
  31360. * @param startIndex the index where to start the copy in the mesh indices array
  31361. * @param indexCount the number of indices to copy then from the startIndex
  31362. * @param mesh the main mesh to create the submesh from
  31363. * @param renderingMesh the optional rendering mesh
  31364. * @returns a new submesh
  31365. */
  31366. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31367. }
  31368. }
  31369. declare module BABYLON {
  31370. /**
  31371. * Class used to represent data loading progression
  31372. */
  31373. export class SceneLoaderFlags {
  31374. private static _ForceFullSceneLoadingForIncremental;
  31375. private static _ShowLoadingScreen;
  31376. private static _CleanBoneMatrixWeights;
  31377. private static _loggingLevel;
  31378. /**
  31379. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31380. */
  31381. static get ForceFullSceneLoadingForIncremental(): boolean;
  31382. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31383. /**
  31384. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31385. */
  31386. static get ShowLoadingScreen(): boolean;
  31387. static set ShowLoadingScreen(value: boolean);
  31388. /**
  31389. * Defines the current logging level (while loading the scene)
  31390. * @ignorenaming
  31391. */
  31392. static get loggingLevel(): number;
  31393. static set loggingLevel(value: number);
  31394. /**
  31395. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31396. */
  31397. static get CleanBoneMatrixWeights(): boolean;
  31398. static set CleanBoneMatrixWeights(value: boolean);
  31399. }
  31400. }
  31401. declare module BABYLON {
  31402. /**
  31403. * Class used to store geometry data (vertex buffers + index buffer)
  31404. */
  31405. export class Geometry implements IGetSetVerticesData {
  31406. /**
  31407. * Gets or sets the ID of the geometry
  31408. */
  31409. id: string;
  31410. /**
  31411. * Gets or sets the unique ID of the geometry
  31412. */
  31413. uniqueId: number;
  31414. /**
  31415. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31416. */
  31417. delayLoadState: number;
  31418. /**
  31419. * Gets the file containing the data to load when running in delay load state
  31420. */
  31421. delayLoadingFile: Nullable<string>;
  31422. /**
  31423. * Callback called when the geometry is updated
  31424. */
  31425. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31426. private _scene;
  31427. private _engine;
  31428. private _meshes;
  31429. private _totalVertices;
  31430. /** @hidden */
  31431. _indices: IndicesArray;
  31432. /** @hidden */
  31433. _vertexBuffers: {
  31434. [key: string]: VertexBuffer;
  31435. };
  31436. private _isDisposed;
  31437. private _extend;
  31438. private _boundingBias;
  31439. /** @hidden */
  31440. _delayInfo: Array<string>;
  31441. private _indexBuffer;
  31442. private _indexBufferIsUpdatable;
  31443. /** @hidden */
  31444. _boundingInfo: Nullable<BoundingInfo>;
  31445. /** @hidden */
  31446. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31447. /** @hidden */
  31448. _softwareSkinningFrameId: number;
  31449. private _vertexArrayObjects;
  31450. private _updatable;
  31451. /** @hidden */
  31452. _positions: Nullable<Vector3[]>;
  31453. private _positionsCache;
  31454. /**
  31455. * 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
  31456. */
  31457. get boundingBias(): Vector2;
  31458. /**
  31459. * 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
  31460. */
  31461. set boundingBias(value: Vector2);
  31462. /**
  31463. * Static function used to attach a new empty geometry to a mesh
  31464. * @param mesh defines the mesh to attach the geometry to
  31465. * @returns the new Geometry
  31466. */
  31467. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31468. /** Get the list of meshes using this geometry */
  31469. get meshes(): Mesh[];
  31470. /**
  31471. * 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
  31472. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31473. */
  31474. useBoundingInfoFromGeometry: boolean;
  31475. /**
  31476. * Creates a new geometry
  31477. * @param id defines the unique ID
  31478. * @param scene defines the hosting scene
  31479. * @param vertexData defines the VertexData used to get geometry data
  31480. * @param updatable defines if geometry must be updatable (false by default)
  31481. * @param mesh defines the mesh that will be associated with the geometry
  31482. */
  31483. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31484. /**
  31485. * Gets the current extend of the geometry
  31486. */
  31487. get extend(): {
  31488. minimum: Vector3;
  31489. maximum: Vector3;
  31490. };
  31491. /**
  31492. * Gets the hosting scene
  31493. * @returns the hosting Scene
  31494. */
  31495. getScene(): Scene;
  31496. /**
  31497. * Gets the hosting engine
  31498. * @returns the hosting Engine
  31499. */
  31500. getEngine(): Engine;
  31501. /**
  31502. * Defines if the geometry is ready to use
  31503. * @returns true if the geometry is ready to be used
  31504. */
  31505. isReady(): boolean;
  31506. /**
  31507. * Gets a value indicating that the geometry should not be serialized
  31508. */
  31509. get doNotSerialize(): boolean;
  31510. /** @hidden */
  31511. _rebuild(): void;
  31512. /**
  31513. * Affects all geometry data in one call
  31514. * @param vertexData defines the geometry data
  31515. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31516. */
  31517. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31518. /**
  31519. * Set specific vertex data
  31520. * @param kind defines the data kind (Position, normal, etc...)
  31521. * @param data defines the vertex data to use
  31522. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31523. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31524. */
  31525. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31526. /**
  31527. * Removes a specific vertex data
  31528. * @param kind defines the data kind (Position, normal, etc...)
  31529. */
  31530. removeVerticesData(kind: string): void;
  31531. /**
  31532. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31533. * @param buffer defines the vertex buffer to use
  31534. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31535. */
  31536. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31537. /**
  31538. * Update a specific vertex buffer
  31539. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31540. * It will do nothing if the buffer is not updatable
  31541. * @param kind defines the data kind (Position, normal, etc...)
  31542. * @param data defines the data to use
  31543. * @param offset defines the offset in the target buffer where to store the data
  31544. * @param useBytes set to true if the offset is in bytes
  31545. */
  31546. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31547. /**
  31548. * Update a specific vertex buffer
  31549. * This function will create a new buffer if the current one is not updatable
  31550. * @param kind defines the data kind (Position, normal, etc...)
  31551. * @param data defines the data to use
  31552. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31553. */
  31554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31555. private _updateBoundingInfo;
  31556. /** @hidden */
  31557. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31558. [kind: string]: Nullable<VertexBuffer>;
  31559. }, overrideVertexArrayObjects?: {
  31560. [key: string]: WebGLVertexArrayObject;
  31561. }): void;
  31562. /**
  31563. * Gets total number of vertices
  31564. * @returns the total number of vertices
  31565. */
  31566. getTotalVertices(): number;
  31567. /**
  31568. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31569. * @param kind defines the data kind (Position, normal, etc...)
  31570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31572. * @returns a float array containing vertex data
  31573. */
  31574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31575. /**
  31576. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31577. * @param kind defines the data kind (Position, normal, etc...)
  31578. * @returns true if the vertex buffer with the specified kind is updatable
  31579. */
  31580. isVertexBufferUpdatable(kind: string): boolean;
  31581. /**
  31582. * Gets a specific vertex buffer
  31583. * @param kind defines the data kind (Position, normal, etc...)
  31584. * @returns a VertexBuffer
  31585. */
  31586. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31587. /**
  31588. * Returns all vertex buffers
  31589. * @return an object holding all vertex buffers indexed by kind
  31590. */
  31591. getVertexBuffers(): Nullable<{
  31592. [key: string]: VertexBuffer;
  31593. }>;
  31594. /**
  31595. * Gets a boolean indicating if specific vertex buffer is present
  31596. * @param kind defines the data kind (Position, normal, etc...)
  31597. * @returns true if data is present
  31598. */
  31599. isVerticesDataPresent(kind: string): boolean;
  31600. /**
  31601. * Gets a list of all attached data kinds (Position, normal, etc...)
  31602. * @returns a list of string containing all kinds
  31603. */
  31604. getVerticesDataKinds(): string[];
  31605. /**
  31606. * Update index buffer
  31607. * @param indices defines the indices to store in the index buffer
  31608. * @param offset defines the offset in the target buffer where to store the data
  31609. * @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)
  31610. */
  31611. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31612. /**
  31613. * Creates a new index buffer
  31614. * @param indices defines the indices to store in the index buffer
  31615. * @param totalVertices defines the total number of vertices (could be null)
  31616. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31617. */
  31618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31619. /**
  31620. * Return the total number of indices
  31621. * @returns the total number of indices
  31622. */
  31623. getTotalIndices(): number;
  31624. /**
  31625. * Gets the index buffer array
  31626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31628. * @returns the index buffer array
  31629. */
  31630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31631. /**
  31632. * Gets the index buffer
  31633. * @return the index buffer
  31634. */
  31635. getIndexBuffer(): Nullable<DataBuffer>;
  31636. /** @hidden */
  31637. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31638. /**
  31639. * Release the associated resources for a specific mesh
  31640. * @param mesh defines the source mesh
  31641. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31642. */
  31643. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31644. /**
  31645. * Apply current geometry to a given mesh
  31646. * @param mesh defines the mesh to apply geometry to
  31647. */
  31648. applyToMesh(mesh: Mesh): void;
  31649. private _updateExtend;
  31650. private _applyToMesh;
  31651. private notifyUpdate;
  31652. /**
  31653. * Load the geometry if it was flagged as delay loaded
  31654. * @param scene defines the hosting scene
  31655. * @param onLoaded defines a callback called when the geometry is loaded
  31656. */
  31657. load(scene: Scene, onLoaded?: () => void): void;
  31658. private _queueLoad;
  31659. /**
  31660. * Invert the geometry to move from a right handed system to a left handed one.
  31661. */
  31662. toLeftHanded(): void;
  31663. /** @hidden */
  31664. _resetPointsArrayCache(): void;
  31665. /** @hidden */
  31666. _generatePointsArray(): boolean;
  31667. /**
  31668. * Gets a value indicating if the geometry is disposed
  31669. * @returns true if the geometry was disposed
  31670. */
  31671. isDisposed(): boolean;
  31672. private _disposeVertexArrayObjects;
  31673. /**
  31674. * Free all associated resources
  31675. */
  31676. dispose(): void;
  31677. /**
  31678. * Clone the current geometry into a new geometry
  31679. * @param id defines the unique ID of the new geometry
  31680. * @returns a new geometry object
  31681. */
  31682. copy(id: string): Geometry;
  31683. /**
  31684. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31685. * @return a JSON representation of the current geometry data (without the vertices data)
  31686. */
  31687. serialize(): any;
  31688. private toNumberArray;
  31689. /**
  31690. * Serialize all vertices data into a JSON object
  31691. * @returns a JSON representation of the current geometry data
  31692. */
  31693. serializeVerticeData(): any;
  31694. /**
  31695. * Extracts a clone of a mesh geometry
  31696. * @param mesh defines the source mesh
  31697. * @param id defines the unique ID of the new geometry object
  31698. * @returns the new geometry object
  31699. */
  31700. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31701. /**
  31702. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31703. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31704. * Be aware Math.random() could cause collisions, but:
  31705. * "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"
  31706. * @returns a string containing a new GUID
  31707. */
  31708. static RandomId(): string;
  31709. /** @hidden */
  31710. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31711. private static _CleanMatricesWeights;
  31712. /**
  31713. * Create a new geometry from persisted data (Using .babylon file format)
  31714. * @param parsedVertexData defines the persisted data
  31715. * @param scene defines the hosting scene
  31716. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31717. * @returns the new geometry object
  31718. */
  31719. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31720. }
  31721. }
  31722. declare module BABYLON {
  31723. /**
  31724. * Defines a target to use with MorphTargetManager
  31725. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31726. */
  31727. export class MorphTarget implements IAnimatable {
  31728. /** defines the name of the target */
  31729. name: string;
  31730. /**
  31731. * Gets or sets the list of animations
  31732. */
  31733. animations: Animation[];
  31734. private _scene;
  31735. private _positions;
  31736. private _normals;
  31737. private _tangents;
  31738. private _uvs;
  31739. private _influence;
  31740. private _uniqueId;
  31741. /**
  31742. * Observable raised when the influence changes
  31743. */
  31744. onInfluenceChanged: Observable<boolean>;
  31745. /** @hidden */
  31746. _onDataLayoutChanged: Observable<void>;
  31747. /**
  31748. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31749. */
  31750. get influence(): number;
  31751. set influence(influence: number);
  31752. /**
  31753. * Gets or sets the id of the morph Target
  31754. */
  31755. id: string;
  31756. private _animationPropertiesOverride;
  31757. /**
  31758. * Gets or sets the animation properties override
  31759. */
  31760. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31761. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31762. /**
  31763. * Creates a new MorphTarget
  31764. * @param name defines the name of the target
  31765. * @param influence defines the influence to use
  31766. * @param scene defines the scene the morphtarget belongs to
  31767. */
  31768. constructor(
  31769. /** defines the name of the target */
  31770. name: string, influence?: number, scene?: Nullable<Scene>);
  31771. /**
  31772. * Gets the unique ID of this manager
  31773. */
  31774. get uniqueId(): number;
  31775. /**
  31776. * Gets a boolean defining if the target contains position data
  31777. */
  31778. get hasPositions(): boolean;
  31779. /**
  31780. * Gets a boolean defining if the target contains normal data
  31781. */
  31782. get hasNormals(): boolean;
  31783. /**
  31784. * Gets a boolean defining if the target contains tangent data
  31785. */
  31786. get hasTangents(): boolean;
  31787. /**
  31788. * Gets a boolean defining if the target contains texture coordinates data
  31789. */
  31790. get hasUVs(): boolean;
  31791. /**
  31792. * Affects position data to this target
  31793. * @param data defines the position data to use
  31794. */
  31795. setPositions(data: Nullable<FloatArray>): void;
  31796. /**
  31797. * Gets the position data stored in this target
  31798. * @returns a FloatArray containing the position data (or null if not present)
  31799. */
  31800. getPositions(): Nullable<FloatArray>;
  31801. /**
  31802. * Affects normal data to this target
  31803. * @param data defines the normal data to use
  31804. */
  31805. setNormals(data: Nullable<FloatArray>): void;
  31806. /**
  31807. * Gets the normal data stored in this target
  31808. * @returns a FloatArray containing the normal data (or null if not present)
  31809. */
  31810. getNormals(): Nullable<FloatArray>;
  31811. /**
  31812. * Affects tangent data to this target
  31813. * @param data defines the tangent data to use
  31814. */
  31815. setTangents(data: Nullable<FloatArray>): void;
  31816. /**
  31817. * Gets the tangent data stored in this target
  31818. * @returns a FloatArray containing the tangent data (or null if not present)
  31819. */
  31820. getTangents(): Nullable<FloatArray>;
  31821. /**
  31822. * Affects texture coordinates data to this target
  31823. * @param data defines the texture coordinates data to use
  31824. */
  31825. setUVs(data: Nullable<FloatArray>): void;
  31826. /**
  31827. * Gets the texture coordinates data stored in this target
  31828. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31829. */
  31830. getUVs(): Nullable<FloatArray>;
  31831. /**
  31832. * Clone the current target
  31833. * @returns a new MorphTarget
  31834. */
  31835. clone(): MorphTarget;
  31836. /**
  31837. * Serializes the current target into a Serialization object
  31838. * @returns the serialized object
  31839. */
  31840. serialize(): any;
  31841. /**
  31842. * Returns the string "MorphTarget"
  31843. * @returns "MorphTarget"
  31844. */
  31845. getClassName(): string;
  31846. /**
  31847. * Creates a new target from serialized data
  31848. * @param serializationObject defines the serialized data to use
  31849. * @returns a new MorphTarget
  31850. */
  31851. static Parse(serializationObject: any): MorphTarget;
  31852. /**
  31853. * Creates a MorphTarget from mesh data
  31854. * @param mesh defines the source mesh
  31855. * @param name defines the name to use for the new target
  31856. * @param influence defines the influence to attach to the target
  31857. * @returns a new MorphTarget
  31858. */
  31859. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31860. }
  31861. }
  31862. declare module BABYLON {
  31863. /**
  31864. * Class used to store 2D array textures containing user data
  31865. */
  31866. export class RawTexture2DArray extends Texture {
  31867. /** Gets or sets the texture format to use */
  31868. format: number;
  31869. private _depth;
  31870. /**
  31871. * Gets the number of layers of the texture
  31872. */
  31873. get depth(): number;
  31874. /**
  31875. * Create a new RawTexture2DArray
  31876. * @param data defines the data of the texture
  31877. * @param width defines the width of the texture
  31878. * @param height defines the height of the texture
  31879. * @param depth defines the number of layers of the texture
  31880. * @param format defines the texture format to use
  31881. * @param scene defines the hosting scene
  31882. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  31883. * @param invertY defines if texture must be stored with Y axis inverted
  31884. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  31885. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31886. */
  31887. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  31888. /** Gets or sets the texture format to use */
  31889. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  31890. /**
  31891. * Update the texture with new data
  31892. * @param data defines the data to store in the texture
  31893. */
  31894. update(data: ArrayBufferView): void;
  31895. /**
  31896. * Creates a RGBA texture from some data.
  31897. * @param data Define the texture data
  31898. * @param width Define the width of the texture
  31899. * @param height Define the height of the texture
  31900. * @param depth defines the number of layers of the texture
  31901. * @param scene defines the scene the texture will belong to
  31902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  31903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  31904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  31905. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  31906. * @returns the RGBA texture
  31907. */
  31908. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  31909. }
  31910. }
  31911. declare module BABYLON {
  31912. /**
  31913. * This class is used to deform meshes using morphing between different targets
  31914. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31915. */
  31916. export class MorphTargetManager implements IDisposable {
  31917. private _targets;
  31918. private _targetInfluenceChangedObservers;
  31919. private _targetDataLayoutChangedObservers;
  31920. private _activeTargets;
  31921. private _scene;
  31922. private _influences;
  31923. private _supportsNormals;
  31924. private _supportsTangents;
  31925. private _supportsUVs;
  31926. private _vertexCount;
  31927. private _textureVertexStride;
  31928. private _textureWidth;
  31929. private _textureHeight;
  31930. private _uniqueId;
  31931. private _tempInfluences;
  31932. private _canUseTextureForTargets;
  31933. /** @hidden */
  31934. _targetStoreTexture: Nullable<RawTexture2DArray>;
  31935. /**
  31936. * Gets or sets a boolean indicating if normals must be morphed
  31937. */
  31938. enableNormalMorphing: boolean;
  31939. /**
  31940. * Gets or sets a boolean indicating if tangents must be morphed
  31941. */
  31942. enableTangentMorphing: boolean;
  31943. /**
  31944. * Gets or sets a boolean indicating if UV must be morphed
  31945. */
  31946. enableUVMorphing: boolean;
  31947. /**
  31948. * Creates a new MorphTargetManager
  31949. * @param scene defines the current scene
  31950. */
  31951. constructor(scene?: Nullable<Scene>);
  31952. /**
  31953. * Gets the unique ID of this manager
  31954. */
  31955. get uniqueId(): number;
  31956. /**
  31957. * Gets the number of vertices handled by this manager
  31958. */
  31959. get vertexCount(): number;
  31960. /**
  31961. * Gets a boolean indicating if this manager supports morphing of normals
  31962. */
  31963. get supportsNormals(): boolean;
  31964. /**
  31965. * Gets a boolean indicating if this manager supports morphing of tangents
  31966. */
  31967. get supportsTangents(): boolean;
  31968. /**
  31969. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31970. */
  31971. get supportsUVs(): boolean;
  31972. /**
  31973. * Gets the number of targets stored in this manager
  31974. */
  31975. get numTargets(): number;
  31976. /**
  31977. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31978. */
  31979. get numInfluencers(): number;
  31980. /**
  31981. * Gets the list of influences (one per target)
  31982. */
  31983. get influences(): Float32Array;
  31984. private _useTextureToStoreTargets;
  31985. /**
  31986. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  31987. * Please note that this option is not available if the hardware does not support it
  31988. */
  31989. get useTextureToStoreTargets(): boolean;
  31990. set useTextureToStoreTargets(value: boolean);
  31991. /**
  31992. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  31993. */
  31994. get isUsingTextureForTargets(): boolean;
  31995. /**
  31996. * Gets the active target at specified index. An active target is a target with an influence > 0
  31997. * @param index defines the index to check
  31998. * @returns the requested target
  31999. */
  32000. getActiveTarget(index: number): MorphTarget;
  32001. /**
  32002. * Gets the target at specified index
  32003. * @param index defines the index to check
  32004. * @returns the requested target
  32005. */
  32006. getTarget(index: number): MorphTarget;
  32007. /**
  32008. * Add a new target to this manager
  32009. * @param target defines the target to add
  32010. */
  32011. addTarget(target: MorphTarget): void;
  32012. /**
  32013. * Removes a target from the manager
  32014. * @param target defines the target to remove
  32015. */
  32016. removeTarget(target: MorphTarget): void;
  32017. /** @hidden */
  32018. _bind(effect: Effect): void;
  32019. /**
  32020. * Clone the current manager
  32021. * @returns a new MorphTargetManager
  32022. */
  32023. clone(): MorphTargetManager;
  32024. /**
  32025. * Serializes the current manager into a Serialization object
  32026. * @returns the serialized object
  32027. */
  32028. serialize(): any;
  32029. private _syncActiveTargets;
  32030. /**
  32031. * Synchronize the targets with all the meshes using this morph target manager
  32032. */
  32033. synchronize(): void;
  32034. /**
  32035. * Release all resources
  32036. */
  32037. dispose(): void;
  32038. /**
  32039. * Creates a new MorphTargetManager from serialized data
  32040. * @param serializationObject defines the serialized data
  32041. * @param scene defines the hosting scene
  32042. * @returns the new MorphTargetManager
  32043. */
  32044. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32045. }
  32046. }
  32047. declare module BABYLON {
  32048. /**
  32049. * Class used to represent a specific level of detail of a mesh
  32050. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32051. */
  32052. export class MeshLODLevel {
  32053. /** Defines the distance where this level should start being displayed */
  32054. distance: number;
  32055. /** Defines the mesh to use to render this level */
  32056. mesh: Nullable<Mesh>;
  32057. /**
  32058. * Creates a new LOD level
  32059. * @param distance defines the distance where this level should star being displayed
  32060. * @param mesh defines the mesh to use to render this level
  32061. */
  32062. constructor(
  32063. /** Defines the distance where this level should start being displayed */
  32064. distance: number,
  32065. /** Defines the mesh to use to render this level */
  32066. mesh: Nullable<Mesh>);
  32067. }
  32068. }
  32069. declare module BABYLON {
  32070. /**
  32071. * Helper class used to generate a canvas to manipulate images
  32072. */
  32073. export class CanvasGenerator {
  32074. /**
  32075. * Create a new canvas (or offscreen canvas depending on the context)
  32076. * @param width defines the expected width
  32077. * @param height defines the expected height
  32078. * @return a new canvas or offscreen canvas
  32079. */
  32080. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32081. }
  32082. }
  32083. declare module BABYLON {
  32084. /**
  32085. * Mesh representing the ground
  32086. */
  32087. export class GroundMesh extends Mesh {
  32088. /** If octree should be generated */
  32089. generateOctree: boolean;
  32090. private _heightQuads;
  32091. /** @hidden */
  32092. _subdivisionsX: number;
  32093. /** @hidden */
  32094. _subdivisionsY: number;
  32095. /** @hidden */
  32096. _width: number;
  32097. /** @hidden */
  32098. _height: number;
  32099. /** @hidden */
  32100. _minX: number;
  32101. /** @hidden */
  32102. _maxX: number;
  32103. /** @hidden */
  32104. _minZ: number;
  32105. /** @hidden */
  32106. _maxZ: number;
  32107. constructor(name: string, scene: Scene);
  32108. /**
  32109. * "GroundMesh"
  32110. * @returns "GroundMesh"
  32111. */
  32112. getClassName(): string;
  32113. /**
  32114. * The minimum of x and y subdivisions
  32115. */
  32116. get subdivisions(): number;
  32117. /**
  32118. * X subdivisions
  32119. */
  32120. get subdivisionsX(): number;
  32121. /**
  32122. * Y subdivisions
  32123. */
  32124. get subdivisionsY(): number;
  32125. /**
  32126. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32127. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32128. * @param chunksCount the number of subdivisions for x and y
  32129. * @param octreeBlocksSize (Default: 32)
  32130. */
  32131. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32132. /**
  32133. * Returns a height (y) value in the World system :
  32134. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32135. * @param x x coordinate
  32136. * @param z z coordinate
  32137. * @returns the ground y position if (x, z) are outside the ground surface.
  32138. */
  32139. getHeightAtCoordinates(x: number, z: number): number;
  32140. /**
  32141. * Returns a normalized vector (Vector3) orthogonal to the ground
  32142. * at the ground coordinates (x, z) expressed in the World system.
  32143. * @param x x coordinate
  32144. * @param z z coordinate
  32145. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32146. */
  32147. getNormalAtCoordinates(x: number, z: number): Vector3;
  32148. /**
  32149. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32150. * at the ground coordinates (x, z) expressed in the World system.
  32151. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32152. * @param x x coordinate
  32153. * @param z z coordinate
  32154. * @param ref vector to store the result
  32155. * @returns the GroundMesh.
  32156. */
  32157. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32158. /**
  32159. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32160. * if the ground has been updated.
  32161. * This can be used in the render loop.
  32162. * @returns the GroundMesh.
  32163. */
  32164. updateCoordinateHeights(): GroundMesh;
  32165. private _getFacetAt;
  32166. private _initHeightQuads;
  32167. private _computeHeightQuads;
  32168. /**
  32169. * Serializes this ground mesh
  32170. * @param serializationObject object to write serialization to
  32171. */
  32172. serialize(serializationObject: any): void;
  32173. /**
  32174. * Parses a serialized ground mesh
  32175. * @param parsedMesh the serialized mesh
  32176. * @param scene the scene to create the ground mesh in
  32177. * @returns the created ground mesh
  32178. */
  32179. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32180. }
  32181. }
  32182. declare module BABYLON {
  32183. /**
  32184. * Interface for Physics-Joint data
  32185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32186. */
  32187. export interface PhysicsJointData {
  32188. /**
  32189. * The main pivot of the joint
  32190. */
  32191. mainPivot?: Vector3;
  32192. /**
  32193. * The connected pivot of the joint
  32194. */
  32195. connectedPivot?: Vector3;
  32196. /**
  32197. * The main axis of the joint
  32198. */
  32199. mainAxis?: Vector3;
  32200. /**
  32201. * The connected axis of the joint
  32202. */
  32203. connectedAxis?: Vector3;
  32204. /**
  32205. * The collision of the joint
  32206. */
  32207. collision?: boolean;
  32208. /**
  32209. * Native Oimo/Cannon/Energy data
  32210. */
  32211. nativeParams?: any;
  32212. }
  32213. /**
  32214. * This is a holder class for the physics joint created by the physics plugin
  32215. * It holds a set of functions to control the underlying joint
  32216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32217. */
  32218. export class PhysicsJoint {
  32219. /**
  32220. * The type of the physics joint
  32221. */
  32222. type: number;
  32223. /**
  32224. * The data for the physics joint
  32225. */
  32226. jointData: PhysicsJointData;
  32227. private _physicsJoint;
  32228. protected _physicsPlugin: IPhysicsEnginePlugin;
  32229. /**
  32230. * Initializes the physics joint
  32231. * @param type The type of the physics joint
  32232. * @param jointData The data for the physics joint
  32233. */
  32234. constructor(
  32235. /**
  32236. * The type of the physics joint
  32237. */
  32238. type: number,
  32239. /**
  32240. * The data for the physics joint
  32241. */
  32242. jointData: PhysicsJointData);
  32243. /**
  32244. * Gets the physics joint
  32245. */
  32246. get physicsJoint(): any;
  32247. /**
  32248. * Sets the physics joint
  32249. */
  32250. set physicsJoint(newJoint: any);
  32251. /**
  32252. * Sets the physics plugin
  32253. */
  32254. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32255. /**
  32256. * Execute a function that is physics-plugin specific.
  32257. * @param {Function} func the function that will be executed.
  32258. * It accepts two parameters: the physics world and the physics joint
  32259. */
  32260. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32261. /**
  32262. * Distance-Joint type
  32263. */
  32264. static DistanceJoint: number;
  32265. /**
  32266. * Hinge-Joint type
  32267. */
  32268. static HingeJoint: number;
  32269. /**
  32270. * Ball-and-Socket joint type
  32271. */
  32272. static BallAndSocketJoint: number;
  32273. /**
  32274. * Wheel-Joint type
  32275. */
  32276. static WheelJoint: number;
  32277. /**
  32278. * Slider-Joint type
  32279. */
  32280. static SliderJoint: number;
  32281. /**
  32282. * Prismatic-Joint type
  32283. */
  32284. static PrismaticJoint: number;
  32285. /**
  32286. * Universal-Joint type
  32287. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32288. */
  32289. static UniversalJoint: number;
  32290. /**
  32291. * Hinge-Joint 2 type
  32292. */
  32293. static Hinge2Joint: number;
  32294. /**
  32295. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32296. */
  32297. static PointToPointJoint: number;
  32298. /**
  32299. * Spring-Joint type
  32300. */
  32301. static SpringJoint: number;
  32302. /**
  32303. * Lock-Joint type
  32304. */
  32305. static LockJoint: number;
  32306. }
  32307. /**
  32308. * A class representing a physics distance joint
  32309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32310. */
  32311. export class DistanceJoint extends PhysicsJoint {
  32312. /**
  32313. *
  32314. * @param jointData The data for the Distance-Joint
  32315. */
  32316. constructor(jointData: DistanceJointData);
  32317. /**
  32318. * Update the predefined distance.
  32319. * @param maxDistance The maximum preferred distance
  32320. * @param minDistance The minimum preferred distance
  32321. */
  32322. updateDistance(maxDistance: number, minDistance?: number): void;
  32323. }
  32324. /**
  32325. * Represents a Motor-Enabled Joint
  32326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32327. */
  32328. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32329. /**
  32330. * Initializes the Motor-Enabled Joint
  32331. * @param type The type of the joint
  32332. * @param jointData The physical joint data for the joint
  32333. */
  32334. constructor(type: number, jointData: PhysicsJointData);
  32335. /**
  32336. * Set the motor values.
  32337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32338. * @param force the force to apply
  32339. * @param maxForce max force for this motor.
  32340. */
  32341. setMotor(force?: number, maxForce?: number): void;
  32342. /**
  32343. * Set the motor's limits.
  32344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32345. * @param upperLimit The upper limit of the motor
  32346. * @param lowerLimit The lower limit of the motor
  32347. */
  32348. setLimit(upperLimit: number, lowerLimit?: number): void;
  32349. }
  32350. /**
  32351. * This class represents a single physics Hinge-Joint
  32352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32353. */
  32354. export class HingeJoint extends MotorEnabledJoint {
  32355. /**
  32356. * Initializes the Hinge-Joint
  32357. * @param jointData The joint data for the Hinge-Joint
  32358. */
  32359. constructor(jointData: PhysicsJointData);
  32360. /**
  32361. * Set the motor values.
  32362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32363. * @param {number} force the force to apply
  32364. * @param {number} maxForce max force for this motor.
  32365. */
  32366. setMotor(force?: number, maxForce?: number): void;
  32367. /**
  32368. * Set the motor's limits.
  32369. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32370. * @param upperLimit The upper limit of the motor
  32371. * @param lowerLimit The lower limit of the motor
  32372. */
  32373. setLimit(upperLimit: number, lowerLimit?: number): void;
  32374. }
  32375. /**
  32376. * This class represents a dual hinge physics joint (same as wheel joint)
  32377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32378. */
  32379. export class Hinge2Joint extends MotorEnabledJoint {
  32380. /**
  32381. * Initializes the Hinge2-Joint
  32382. * @param jointData The joint data for the Hinge2-Joint
  32383. */
  32384. constructor(jointData: PhysicsJointData);
  32385. /**
  32386. * Set the motor values.
  32387. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32388. * @param {number} targetSpeed the speed the motor is to reach
  32389. * @param {number} maxForce max force for this motor.
  32390. * @param {motorIndex} the motor's index, 0 or 1.
  32391. */
  32392. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32393. /**
  32394. * Set the motor limits.
  32395. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32396. * @param {number} upperLimit the upper limit
  32397. * @param {number} lowerLimit lower limit
  32398. * @param {motorIndex} the motor's index, 0 or 1.
  32399. */
  32400. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32401. }
  32402. /**
  32403. * Interface for a motor enabled joint
  32404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32405. */
  32406. export interface IMotorEnabledJoint {
  32407. /**
  32408. * Physics joint
  32409. */
  32410. physicsJoint: any;
  32411. /**
  32412. * Sets the motor of the motor-enabled joint
  32413. * @param force The force of the motor
  32414. * @param maxForce The maximum force of the motor
  32415. * @param motorIndex The index of the motor
  32416. */
  32417. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32418. /**
  32419. * Sets the limit of the motor
  32420. * @param upperLimit The upper limit of the motor
  32421. * @param lowerLimit The lower limit of the motor
  32422. * @param motorIndex The index of the motor
  32423. */
  32424. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32425. }
  32426. /**
  32427. * Joint data for a Distance-Joint
  32428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32429. */
  32430. export interface DistanceJointData extends PhysicsJointData {
  32431. /**
  32432. * Max distance the 2 joint objects can be apart
  32433. */
  32434. maxDistance: number;
  32435. }
  32436. /**
  32437. * Joint data from a spring joint
  32438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32439. */
  32440. export interface SpringJointData extends PhysicsJointData {
  32441. /**
  32442. * Length of the spring
  32443. */
  32444. length: number;
  32445. /**
  32446. * Stiffness of the spring
  32447. */
  32448. stiffness: number;
  32449. /**
  32450. * Damping of the spring
  32451. */
  32452. damping: number;
  32453. /** this callback will be called when applying the force to the impostors. */
  32454. forceApplicationCallback: () => void;
  32455. }
  32456. }
  32457. declare module BABYLON {
  32458. /**
  32459. * Holds the data for the raycast result
  32460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32461. */
  32462. export class PhysicsRaycastResult {
  32463. private _hasHit;
  32464. private _hitDistance;
  32465. private _hitNormalWorld;
  32466. private _hitPointWorld;
  32467. private _rayFromWorld;
  32468. private _rayToWorld;
  32469. /**
  32470. * Gets if there was a hit
  32471. */
  32472. get hasHit(): boolean;
  32473. /**
  32474. * Gets the distance from the hit
  32475. */
  32476. get hitDistance(): number;
  32477. /**
  32478. * Gets the hit normal/direction in the world
  32479. */
  32480. get hitNormalWorld(): Vector3;
  32481. /**
  32482. * Gets the hit point in the world
  32483. */
  32484. get hitPointWorld(): Vector3;
  32485. /**
  32486. * Gets the ray "start point" of the ray in the world
  32487. */
  32488. get rayFromWorld(): Vector3;
  32489. /**
  32490. * Gets the ray "end point" of the ray in the world
  32491. */
  32492. get rayToWorld(): Vector3;
  32493. /**
  32494. * Sets the hit data (normal & point in world space)
  32495. * @param hitNormalWorld defines the normal in world space
  32496. * @param hitPointWorld defines the point in world space
  32497. */
  32498. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32499. /**
  32500. * Sets the distance from the start point to the hit point
  32501. * @param distance
  32502. */
  32503. setHitDistance(distance: number): void;
  32504. /**
  32505. * Calculates the distance manually
  32506. */
  32507. calculateHitDistance(): void;
  32508. /**
  32509. * Resets all the values to default
  32510. * @param from The from point on world space
  32511. * @param to The to point on world space
  32512. */
  32513. reset(from?: Vector3, to?: Vector3): void;
  32514. }
  32515. /**
  32516. * Interface for the size containing width and height
  32517. */
  32518. interface IXYZ {
  32519. /**
  32520. * X
  32521. */
  32522. x: number;
  32523. /**
  32524. * Y
  32525. */
  32526. y: number;
  32527. /**
  32528. * Z
  32529. */
  32530. z: number;
  32531. }
  32532. }
  32533. declare module BABYLON {
  32534. /**
  32535. * Interface used to describe a physics joint
  32536. */
  32537. export interface PhysicsImpostorJoint {
  32538. /** Defines the main impostor to which the joint is linked */
  32539. mainImpostor: PhysicsImpostor;
  32540. /** Defines the impostor that is connected to the main impostor using this joint */
  32541. connectedImpostor: PhysicsImpostor;
  32542. /** Defines the joint itself */
  32543. joint: PhysicsJoint;
  32544. }
  32545. /** @hidden */
  32546. export interface IPhysicsEnginePlugin {
  32547. world: any;
  32548. name: string;
  32549. setGravity(gravity: Vector3): void;
  32550. setTimeStep(timeStep: number): void;
  32551. getTimeStep(): number;
  32552. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32554. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32555. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32556. removePhysicsBody(impostor: PhysicsImpostor): void;
  32557. generateJoint(joint: PhysicsImpostorJoint): void;
  32558. removeJoint(joint: PhysicsImpostorJoint): void;
  32559. isSupported(): boolean;
  32560. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32562. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32563. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32564. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32565. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32566. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32567. getBodyMass(impostor: PhysicsImpostor): number;
  32568. getBodyFriction(impostor: PhysicsImpostor): number;
  32569. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32570. getBodyRestitution(impostor: PhysicsImpostor): number;
  32571. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32572. getBodyPressure?(impostor: PhysicsImpostor): number;
  32573. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32574. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32575. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32576. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32577. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32578. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32579. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32580. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32581. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32582. sleepBody(impostor: PhysicsImpostor): void;
  32583. wakeUpBody(impostor: PhysicsImpostor): void;
  32584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32585. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32586. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32587. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32588. getRadius(impostor: PhysicsImpostor): number;
  32589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32591. dispose(): void;
  32592. }
  32593. /**
  32594. * Interface used to define a physics engine
  32595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32596. */
  32597. export interface IPhysicsEngine {
  32598. /**
  32599. * Gets the gravity vector used by the simulation
  32600. */
  32601. gravity: Vector3;
  32602. /**
  32603. * Sets the gravity vector used by the simulation
  32604. * @param gravity defines the gravity vector to use
  32605. */
  32606. setGravity(gravity: Vector3): void;
  32607. /**
  32608. * Set the time step of the physics engine.
  32609. * Default is 1/60.
  32610. * To slow it down, enter 1/600 for example.
  32611. * To speed it up, 1/30
  32612. * @param newTimeStep the new timestep to apply to this world.
  32613. */
  32614. setTimeStep(newTimeStep: number): void;
  32615. /**
  32616. * Get the time step of the physics engine.
  32617. * @returns the current time step
  32618. */
  32619. getTimeStep(): number;
  32620. /**
  32621. * Set the sub time step of the physics engine.
  32622. * Default is 0 meaning there is no sub steps
  32623. * To increase physics resolution precision, set a small value (like 1 ms)
  32624. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32625. */
  32626. setSubTimeStep(subTimeStep: number): void;
  32627. /**
  32628. * Get the sub time step of the physics engine.
  32629. * @returns the current sub time step
  32630. */
  32631. getSubTimeStep(): number;
  32632. /**
  32633. * Release all resources
  32634. */
  32635. dispose(): void;
  32636. /**
  32637. * Gets the name of the current physics plugin
  32638. * @returns the name of the plugin
  32639. */
  32640. getPhysicsPluginName(): string;
  32641. /**
  32642. * Adding a new impostor for the impostor tracking.
  32643. * This will be done by the impostor itself.
  32644. * @param impostor the impostor to add
  32645. */
  32646. addImpostor(impostor: PhysicsImpostor): void;
  32647. /**
  32648. * Remove an impostor from the engine.
  32649. * This impostor and its mesh will not longer be updated by the physics engine.
  32650. * @param impostor the impostor to remove
  32651. */
  32652. removeImpostor(impostor: PhysicsImpostor): void;
  32653. /**
  32654. * Add a joint to the physics engine
  32655. * @param mainImpostor defines the main impostor to which the joint is added.
  32656. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32657. * @param joint defines the joint that will connect both impostors.
  32658. */
  32659. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32660. /**
  32661. * Removes a joint from the simulation
  32662. * @param mainImpostor defines the impostor used with the joint
  32663. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32664. * @param joint defines the joint to remove
  32665. */
  32666. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32667. /**
  32668. * Gets the current plugin used to run the simulation
  32669. * @returns current plugin
  32670. */
  32671. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32672. /**
  32673. * Gets the list of physic impostors
  32674. * @returns an array of PhysicsImpostor
  32675. */
  32676. getImpostors(): Array<PhysicsImpostor>;
  32677. /**
  32678. * Gets the impostor for a physics enabled object
  32679. * @param object defines the object impersonated by the impostor
  32680. * @returns the PhysicsImpostor or null if not found
  32681. */
  32682. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32683. /**
  32684. * Gets the impostor for a physics body object
  32685. * @param body defines physics body used by the impostor
  32686. * @returns the PhysicsImpostor or null if not found
  32687. */
  32688. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32689. /**
  32690. * Does a raycast in the physics world
  32691. * @param from when should the ray start?
  32692. * @param to when should the ray end?
  32693. * @returns PhysicsRaycastResult
  32694. */
  32695. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32696. /**
  32697. * Called by the scene. No need to call it.
  32698. * @param delta defines the timespan between frames
  32699. */
  32700. _step(delta: number): void;
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. /**
  32705. * The interface for the physics imposter parameters
  32706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32707. */
  32708. export interface PhysicsImpostorParameters {
  32709. /**
  32710. * The mass of the physics imposter
  32711. */
  32712. mass: number;
  32713. /**
  32714. * The friction of the physics imposter
  32715. */
  32716. friction?: number;
  32717. /**
  32718. * The coefficient of restitution of the physics imposter
  32719. */
  32720. restitution?: number;
  32721. /**
  32722. * The native options of the physics imposter
  32723. */
  32724. nativeOptions?: any;
  32725. /**
  32726. * Specifies if the parent should be ignored
  32727. */
  32728. ignoreParent?: boolean;
  32729. /**
  32730. * Specifies if bi-directional transformations should be disabled
  32731. */
  32732. disableBidirectionalTransformation?: boolean;
  32733. /**
  32734. * The pressure inside the physics imposter, soft object only
  32735. */
  32736. pressure?: number;
  32737. /**
  32738. * The stiffness the physics imposter, soft object only
  32739. */
  32740. stiffness?: number;
  32741. /**
  32742. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32743. */
  32744. velocityIterations?: number;
  32745. /**
  32746. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32747. */
  32748. positionIterations?: number;
  32749. /**
  32750. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32751. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32752. * Add to fix multiple points
  32753. */
  32754. fixedPoints?: number;
  32755. /**
  32756. * The collision margin around a soft object
  32757. */
  32758. margin?: number;
  32759. /**
  32760. * The collision margin around a soft object
  32761. */
  32762. damping?: number;
  32763. /**
  32764. * The path for a rope based on an extrusion
  32765. */
  32766. path?: any;
  32767. /**
  32768. * The shape of an extrusion used for a rope based on an extrusion
  32769. */
  32770. shape?: any;
  32771. }
  32772. /**
  32773. * Interface for a physics-enabled object
  32774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32775. */
  32776. export interface IPhysicsEnabledObject {
  32777. /**
  32778. * The position of the physics-enabled object
  32779. */
  32780. position: Vector3;
  32781. /**
  32782. * The rotation of the physics-enabled object
  32783. */
  32784. rotationQuaternion: Nullable<Quaternion>;
  32785. /**
  32786. * The scale of the physics-enabled object
  32787. */
  32788. scaling: Vector3;
  32789. /**
  32790. * The rotation of the physics-enabled object
  32791. */
  32792. rotation?: Vector3;
  32793. /**
  32794. * The parent of the physics-enabled object
  32795. */
  32796. parent?: any;
  32797. /**
  32798. * The bounding info of the physics-enabled object
  32799. * @returns The bounding info of the physics-enabled object
  32800. */
  32801. getBoundingInfo(): BoundingInfo;
  32802. /**
  32803. * Computes the world matrix
  32804. * @param force Specifies if the world matrix should be computed by force
  32805. * @returns A world matrix
  32806. */
  32807. computeWorldMatrix(force: boolean): Matrix;
  32808. /**
  32809. * Gets the world matrix
  32810. * @returns A world matrix
  32811. */
  32812. getWorldMatrix?(): Matrix;
  32813. /**
  32814. * Gets the child meshes
  32815. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32816. * @returns An array of abstract meshes
  32817. */
  32818. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32819. /**
  32820. * Gets the vertex data
  32821. * @param kind The type of vertex data
  32822. * @returns A nullable array of numbers, or a float32 array
  32823. */
  32824. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32825. /**
  32826. * Gets the indices from the mesh
  32827. * @returns A nullable array of index arrays
  32828. */
  32829. getIndices?(): Nullable<IndicesArray>;
  32830. /**
  32831. * Gets the scene from the mesh
  32832. * @returns the indices array or null
  32833. */
  32834. getScene?(): Scene;
  32835. /**
  32836. * Gets the absolute position from the mesh
  32837. * @returns the absolute position
  32838. */
  32839. getAbsolutePosition(): Vector3;
  32840. /**
  32841. * Gets the absolute pivot point from the mesh
  32842. * @returns the absolute pivot point
  32843. */
  32844. getAbsolutePivotPoint(): Vector3;
  32845. /**
  32846. * Rotates the mesh
  32847. * @param axis The axis of rotation
  32848. * @param amount The amount of rotation
  32849. * @param space The space of the rotation
  32850. * @returns The rotation transform node
  32851. */
  32852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32853. /**
  32854. * Translates the mesh
  32855. * @param axis The axis of translation
  32856. * @param distance The distance of translation
  32857. * @param space The space of the translation
  32858. * @returns The transform node
  32859. */
  32860. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32861. /**
  32862. * Sets the absolute position of the mesh
  32863. * @param absolutePosition The absolute position of the mesh
  32864. * @returns The transform node
  32865. */
  32866. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32867. /**
  32868. * Gets the class name of the mesh
  32869. * @returns The class name
  32870. */
  32871. getClassName(): string;
  32872. }
  32873. /**
  32874. * Represents a physics imposter
  32875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32876. */
  32877. export class PhysicsImpostor {
  32878. /**
  32879. * The physics-enabled object used as the physics imposter
  32880. */
  32881. object: IPhysicsEnabledObject;
  32882. /**
  32883. * The type of the physics imposter
  32884. */
  32885. type: number;
  32886. private _options;
  32887. private _scene?;
  32888. /**
  32889. * The default object size of the imposter
  32890. */
  32891. static DEFAULT_OBJECT_SIZE: Vector3;
  32892. /**
  32893. * The identity quaternion of the imposter
  32894. */
  32895. static IDENTITY_QUATERNION: Quaternion;
  32896. /** @hidden */
  32897. _pluginData: any;
  32898. private _physicsEngine;
  32899. private _physicsBody;
  32900. private _bodyUpdateRequired;
  32901. private _onBeforePhysicsStepCallbacks;
  32902. private _onAfterPhysicsStepCallbacks;
  32903. /** @hidden */
  32904. _onPhysicsCollideCallbacks: Array<{
  32905. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32906. otherImpostors: Array<PhysicsImpostor>;
  32907. }>;
  32908. private _deltaPosition;
  32909. private _deltaRotation;
  32910. private _deltaRotationConjugated;
  32911. /** @hidden */
  32912. _isFromLine: boolean;
  32913. private _parent;
  32914. private _isDisposed;
  32915. private static _tmpVecs;
  32916. private static _tmpQuat;
  32917. /**
  32918. * Specifies if the physics imposter is disposed
  32919. */
  32920. get isDisposed(): boolean;
  32921. /**
  32922. * Gets the mass of the physics imposter
  32923. */
  32924. get mass(): number;
  32925. set mass(value: number);
  32926. /**
  32927. * Gets the coefficient of friction
  32928. */
  32929. get friction(): number;
  32930. /**
  32931. * Sets the coefficient of friction
  32932. */
  32933. set friction(value: number);
  32934. /**
  32935. * Gets the coefficient of restitution
  32936. */
  32937. get restitution(): number;
  32938. /**
  32939. * Sets the coefficient of restitution
  32940. */
  32941. set restitution(value: number);
  32942. /**
  32943. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32944. */
  32945. get pressure(): number;
  32946. /**
  32947. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32948. */
  32949. set pressure(value: number);
  32950. /**
  32951. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32952. */
  32953. get stiffness(): number;
  32954. /**
  32955. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32956. */
  32957. set stiffness(value: number);
  32958. /**
  32959. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32960. */
  32961. get velocityIterations(): number;
  32962. /**
  32963. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32964. */
  32965. set velocityIterations(value: number);
  32966. /**
  32967. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32968. */
  32969. get positionIterations(): number;
  32970. /**
  32971. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32972. */
  32973. set positionIterations(value: number);
  32974. /**
  32975. * The unique id of the physics imposter
  32976. * set by the physics engine when adding this impostor to the array
  32977. */
  32978. uniqueId: number;
  32979. /**
  32980. * @hidden
  32981. */
  32982. soft: boolean;
  32983. /**
  32984. * @hidden
  32985. */
  32986. segments: number;
  32987. private _joints;
  32988. /**
  32989. * Initializes the physics imposter
  32990. * @param object The physics-enabled object used as the physics imposter
  32991. * @param type The type of the physics imposter
  32992. * @param _options The options for the physics imposter
  32993. * @param _scene The Babylon scene
  32994. */
  32995. constructor(
  32996. /**
  32997. * The physics-enabled object used as the physics imposter
  32998. */
  32999. object: IPhysicsEnabledObject,
  33000. /**
  33001. * The type of the physics imposter
  33002. */
  33003. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33004. /**
  33005. * This function will completely initialize this impostor.
  33006. * It will create a new body - but only if this mesh has no parent.
  33007. * If it has, this impostor will not be used other than to define the impostor
  33008. * of the child mesh.
  33009. * @hidden
  33010. */
  33011. _init(): void;
  33012. private _getPhysicsParent;
  33013. /**
  33014. * Should a new body be generated.
  33015. * @returns boolean specifying if body initialization is required
  33016. */
  33017. isBodyInitRequired(): boolean;
  33018. /**
  33019. * Sets the updated scaling
  33020. * @param updated Specifies if the scaling is updated
  33021. */
  33022. setScalingUpdated(): void;
  33023. /**
  33024. * Force a regeneration of this or the parent's impostor's body.
  33025. * Use under cautious - This will remove all joints already implemented.
  33026. */
  33027. forceUpdate(): void;
  33028. /**
  33029. * Gets the body that holds this impostor. Either its own, or its parent.
  33030. */
  33031. get physicsBody(): any;
  33032. /**
  33033. * Get the parent of the physics imposter
  33034. * @returns Physics imposter or null
  33035. */
  33036. get parent(): Nullable<PhysicsImpostor>;
  33037. /**
  33038. * Sets the parent of the physics imposter
  33039. */
  33040. set parent(value: Nullable<PhysicsImpostor>);
  33041. /**
  33042. * Set the physics body. Used mainly by the physics engine/plugin
  33043. */
  33044. set physicsBody(physicsBody: any);
  33045. /**
  33046. * Resets the update flags
  33047. */
  33048. resetUpdateFlags(): void;
  33049. /**
  33050. * Gets the object extend size
  33051. * @returns the object extend size
  33052. */
  33053. getObjectExtendSize(): Vector3;
  33054. /**
  33055. * Gets the object center
  33056. * @returns The object center
  33057. */
  33058. getObjectCenter(): Vector3;
  33059. /**
  33060. * Get a specific parameter from the options parameters
  33061. * @param paramName The object parameter name
  33062. * @returns The object parameter
  33063. */
  33064. getParam(paramName: string): any;
  33065. /**
  33066. * Sets a specific parameter in the options given to the physics plugin
  33067. * @param paramName The parameter name
  33068. * @param value The value of the parameter
  33069. */
  33070. setParam(paramName: string, value: number): void;
  33071. /**
  33072. * Specifically change the body's mass option. Won't recreate the physics body object
  33073. * @param mass The mass of the physics imposter
  33074. */
  33075. setMass(mass: number): void;
  33076. /**
  33077. * Gets the linear velocity
  33078. * @returns linear velocity or null
  33079. */
  33080. getLinearVelocity(): Nullable<Vector3>;
  33081. /**
  33082. * Sets the linear velocity
  33083. * @param velocity linear velocity or null
  33084. */
  33085. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33086. /**
  33087. * Gets the angular velocity
  33088. * @returns angular velocity or null
  33089. */
  33090. getAngularVelocity(): Nullable<Vector3>;
  33091. /**
  33092. * Sets the angular velocity
  33093. * @param velocity The velocity or null
  33094. */
  33095. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33096. /**
  33097. * Execute a function with the physics plugin native code
  33098. * Provide a function the will have two variables - the world object and the physics body object
  33099. * @param func The function to execute with the physics plugin native code
  33100. */
  33101. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33102. /**
  33103. * Register a function that will be executed before the physics world is stepping forward
  33104. * @param func The function to execute before the physics world is stepped forward
  33105. */
  33106. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33107. /**
  33108. * Unregister a function that will be executed before the physics world is stepping forward
  33109. * @param func The function to execute before the physics world is stepped forward
  33110. */
  33111. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33112. /**
  33113. * Register a function that will be executed after the physics step
  33114. * @param func The function to execute after physics step
  33115. */
  33116. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33117. /**
  33118. * Unregisters a function that will be executed after the physics step
  33119. * @param func The function to execute after physics step
  33120. */
  33121. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33122. /**
  33123. * register a function that will be executed when this impostor collides against a different body
  33124. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33125. * @param func Callback that is executed on collision
  33126. */
  33127. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33128. /**
  33129. * Unregisters the physics imposter on contact
  33130. * @param collideAgainst The physics object to collide against
  33131. * @param func Callback to execute on collision
  33132. */
  33133. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33134. private _tmpQuat;
  33135. private _tmpQuat2;
  33136. /**
  33137. * Get the parent rotation
  33138. * @returns The parent rotation
  33139. */
  33140. getParentsRotation(): Quaternion;
  33141. /**
  33142. * this function is executed by the physics engine.
  33143. */
  33144. beforeStep: () => void;
  33145. /**
  33146. * this function is executed by the physics engine
  33147. */
  33148. afterStep: () => void;
  33149. /**
  33150. * Legacy collision detection event support
  33151. */
  33152. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33153. /**
  33154. * event and body object due to cannon's event-based architecture.
  33155. */
  33156. onCollide: (e: {
  33157. body: any;
  33158. point: Nullable<Vector3>;
  33159. }) => void;
  33160. /**
  33161. * Apply a force
  33162. * @param force The force to apply
  33163. * @param contactPoint The contact point for the force
  33164. * @returns The physics imposter
  33165. */
  33166. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33167. /**
  33168. * Apply an impulse
  33169. * @param force The impulse force
  33170. * @param contactPoint The contact point for the impulse force
  33171. * @returns The physics imposter
  33172. */
  33173. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33174. /**
  33175. * A help function to create a joint
  33176. * @param otherImpostor A physics imposter used to create a joint
  33177. * @param jointType The type of joint
  33178. * @param jointData The data for the joint
  33179. * @returns The physics imposter
  33180. */
  33181. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33182. /**
  33183. * Add a joint to this impostor with a different impostor
  33184. * @param otherImpostor A physics imposter used to add a joint
  33185. * @param joint The joint to add
  33186. * @returns The physics imposter
  33187. */
  33188. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33189. /**
  33190. * Add an anchor to a cloth impostor
  33191. * @param otherImpostor rigid impostor to anchor to
  33192. * @param width ratio across width from 0 to 1
  33193. * @param height ratio up height from 0 to 1
  33194. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33195. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33196. * @returns impostor the soft imposter
  33197. */
  33198. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33199. /**
  33200. * Add a hook to a rope impostor
  33201. * @param otherImpostor rigid impostor to anchor to
  33202. * @param length ratio across rope from 0 to 1
  33203. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33204. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33205. * @returns impostor the rope imposter
  33206. */
  33207. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33208. /**
  33209. * Will keep this body still, in a sleep mode.
  33210. * @returns the physics imposter
  33211. */
  33212. sleep(): PhysicsImpostor;
  33213. /**
  33214. * Wake the body up.
  33215. * @returns The physics imposter
  33216. */
  33217. wakeUp(): PhysicsImpostor;
  33218. /**
  33219. * Clones the physics imposter
  33220. * @param newObject The physics imposter clones to this physics-enabled object
  33221. * @returns A nullable physics imposter
  33222. */
  33223. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33224. /**
  33225. * Disposes the physics imposter
  33226. */
  33227. dispose(): void;
  33228. /**
  33229. * Sets the delta position
  33230. * @param position The delta position amount
  33231. */
  33232. setDeltaPosition(position: Vector3): void;
  33233. /**
  33234. * Sets the delta rotation
  33235. * @param rotation The delta rotation amount
  33236. */
  33237. setDeltaRotation(rotation: Quaternion): void;
  33238. /**
  33239. * Gets the box size of the physics imposter and stores the result in the input parameter
  33240. * @param result Stores the box size
  33241. * @returns The physics imposter
  33242. */
  33243. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33244. /**
  33245. * Gets the radius of the physics imposter
  33246. * @returns Radius of the physics imposter
  33247. */
  33248. getRadius(): number;
  33249. /**
  33250. * Sync a bone with this impostor
  33251. * @param bone The bone to sync to the impostor.
  33252. * @param boneMesh The mesh that the bone is influencing.
  33253. * @param jointPivot The pivot of the joint / bone in local space.
  33254. * @param distToJoint Optional distance from the impostor to the joint.
  33255. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33256. */
  33257. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33258. /**
  33259. * Sync impostor to a bone
  33260. * @param bone The bone that the impostor will be synced to.
  33261. * @param boneMesh The mesh that the bone is influencing.
  33262. * @param jointPivot The pivot of the joint / bone in local space.
  33263. * @param distToJoint Optional distance from the impostor to the joint.
  33264. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33265. * @param boneAxis Optional vector3 axis the bone is aligned with
  33266. */
  33267. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33268. /**
  33269. * No-Imposter type
  33270. */
  33271. static NoImpostor: number;
  33272. /**
  33273. * Sphere-Imposter type
  33274. */
  33275. static SphereImpostor: number;
  33276. /**
  33277. * Box-Imposter type
  33278. */
  33279. static BoxImpostor: number;
  33280. /**
  33281. * Plane-Imposter type
  33282. */
  33283. static PlaneImpostor: number;
  33284. /**
  33285. * Mesh-imposter type
  33286. */
  33287. static MeshImpostor: number;
  33288. /**
  33289. * Capsule-Impostor type (Ammo.js plugin only)
  33290. */
  33291. static CapsuleImpostor: number;
  33292. /**
  33293. * Cylinder-Imposter type
  33294. */
  33295. static CylinderImpostor: number;
  33296. /**
  33297. * Particle-Imposter type
  33298. */
  33299. static ParticleImpostor: number;
  33300. /**
  33301. * Heightmap-Imposter type
  33302. */
  33303. static HeightmapImpostor: number;
  33304. /**
  33305. * ConvexHull-Impostor type (Ammo.js plugin only)
  33306. */
  33307. static ConvexHullImpostor: number;
  33308. /**
  33309. * Custom-Imposter type (Ammo.js plugin only)
  33310. */
  33311. static CustomImpostor: number;
  33312. /**
  33313. * Rope-Imposter type
  33314. */
  33315. static RopeImpostor: number;
  33316. /**
  33317. * Cloth-Imposter type
  33318. */
  33319. static ClothImpostor: number;
  33320. /**
  33321. * Softbody-Imposter type
  33322. */
  33323. static SoftbodyImpostor: number;
  33324. }
  33325. }
  33326. declare module BABYLON {
  33327. /**
  33328. * @hidden
  33329. **/
  33330. export class _CreationDataStorage {
  33331. closePath?: boolean;
  33332. closeArray?: boolean;
  33333. idx: number[];
  33334. dashSize: number;
  33335. gapSize: number;
  33336. path3D: Path3D;
  33337. pathArray: Vector3[][];
  33338. arc: number;
  33339. radius: number;
  33340. cap: number;
  33341. tessellation: number;
  33342. }
  33343. /**
  33344. * @hidden
  33345. **/
  33346. class _InstanceDataStorage {
  33347. visibleInstances: any;
  33348. batchCache: _InstancesBatch;
  33349. instancesBufferSize: number;
  33350. instancesBuffer: Nullable<Buffer>;
  33351. instancesData: Float32Array;
  33352. overridenInstanceCount: number;
  33353. isFrozen: boolean;
  33354. previousBatch: Nullable<_InstancesBatch>;
  33355. hardwareInstancedRendering: boolean;
  33356. sideOrientation: number;
  33357. manualUpdate: boolean;
  33358. previousRenderId: number;
  33359. }
  33360. /**
  33361. * @hidden
  33362. **/
  33363. export class _InstancesBatch {
  33364. mustReturn: boolean;
  33365. visibleInstances: Nullable<InstancedMesh[]>[];
  33366. renderSelf: boolean[];
  33367. hardwareInstancedRendering: boolean[];
  33368. }
  33369. /**
  33370. * @hidden
  33371. **/
  33372. class _ThinInstanceDataStorage {
  33373. instancesCount: number;
  33374. matrixBuffer: Nullable<Buffer>;
  33375. matrixBufferSize: number;
  33376. matrixData: Nullable<Float32Array>;
  33377. boundingVectors: Array<Vector3>;
  33378. worldMatrices: Nullable<Matrix[]>;
  33379. }
  33380. /**
  33381. * Class used to represent renderable models
  33382. */
  33383. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33384. /**
  33385. * Mesh side orientation : usually the external or front surface
  33386. */
  33387. static readonly FRONTSIDE: number;
  33388. /**
  33389. * Mesh side orientation : usually the internal or back surface
  33390. */
  33391. static readonly BACKSIDE: number;
  33392. /**
  33393. * Mesh side orientation : both internal and external or front and back surfaces
  33394. */
  33395. static readonly DOUBLESIDE: number;
  33396. /**
  33397. * Mesh side orientation : by default, `FRONTSIDE`
  33398. */
  33399. static readonly DEFAULTSIDE: number;
  33400. /**
  33401. * Mesh cap setting : no cap
  33402. */
  33403. static readonly NO_CAP: number;
  33404. /**
  33405. * Mesh cap setting : one cap at the beginning of the mesh
  33406. */
  33407. static readonly CAP_START: number;
  33408. /**
  33409. * Mesh cap setting : one cap at the end of the mesh
  33410. */
  33411. static readonly CAP_END: number;
  33412. /**
  33413. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33414. */
  33415. static readonly CAP_ALL: number;
  33416. /**
  33417. * Mesh pattern setting : no flip or rotate
  33418. */
  33419. static readonly NO_FLIP: number;
  33420. /**
  33421. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33422. */
  33423. static readonly FLIP_TILE: number;
  33424. /**
  33425. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33426. */
  33427. static readonly ROTATE_TILE: number;
  33428. /**
  33429. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33430. */
  33431. static readonly FLIP_ROW: number;
  33432. /**
  33433. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33434. */
  33435. static readonly ROTATE_ROW: number;
  33436. /**
  33437. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33438. */
  33439. static readonly FLIP_N_ROTATE_TILE: number;
  33440. /**
  33441. * Mesh pattern setting : rotate pattern and rotate
  33442. */
  33443. static readonly FLIP_N_ROTATE_ROW: number;
  33444. /**
  33445. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33446. */
  33447. static readonly CENTER: number;
  33448. /**
  33449. * Mesh tile positioning : part tiles on left
  33450. */
  33451. static readonly LEFT: number;
  33452. /**
  33453. * Mesh tile positioning : part tiles on right
  33454. */
  33455. static readonly RIGHT: number;
  33456. /**
  33457. * Mesh tile positioning : part tiles on top
  33458. */
  33459. static readonly TOP: number;
  33460. /**
  33461. * Mesh tile positioning : part tiles on bottom
  33462. */
  33463. static readonly BOTTOM: number;
  33464. /**
  33465. * Gets the default side orientation.
  33466. * @param orientation the orientation to value to attempt to get
  33467. * @returns the default orientation
  33468. * @hidden
  33469. */
  33470. static _GetDefaultSideOrientation(orientation?: number): number;
  33471. private _internalMeshDataInfo;
  33472. get computeBonesUsingShaders(): boolean;
  33473. set computeBonesUsingShaders(value: boolean);
  33474. /**
  33475. * An event triggered before rendering the mesh
  33476. */
  33477. get onBeforeRenderObservable(): Observable<Mesh>;
  33478. /**
  33479. * An event triggered before binding the mesh
  33480. */
  33481. get onBeforeBindObservable(): Observable<Mesh>;
  33482. /**
  33483. * An event triggered after rendering the mesh
  33484. */
  33485. get onAfterRenderObservable(): Observable<Mesh>;
  33486. /**
  33487. * An event triggered before drawing the mesh
  33488. */
  33489. get onBeforeDrawObservable(): Observable<Mesh>;
  33490. private _onBeforeDrawObserver;
  33491. /**
  33492. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33493. */
  33494. set onBeforeDraw(callback: () => void);
  33495. get hasInstances(): boolean;
  33496. get hasThinInstances(): boolean;
  33497. /**
  33498. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33499. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33500. */
  33501. delayLoadState: number;
  33502. /**
  33503. * Gets the list of instances created from this mesh
  33504. * it is not supposed to be modified manually.
  33505. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33506. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33507. */
  33508. instances: InstancedMesh[];
  33509. /**
  33510. * Gets the file containing delay loading data for this mesh
  33511. */
  33512. delayLoadingFile: string;
  33513. /** @hidden */
  33514. _binaryInfo: any;
  33515. /**
  33516. * User defined function used to change how LOD level selection is done
  33517. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33518. */
  33519. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33520. /**
  33521. * Gets or sets the morph target manager
  33522. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33523. */
  33524. get morphTargetManager(): Nullable<MorphTargetManager>;
  33525. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33526. /** @hidden */
  33527. _creationDataStorage: Nullable<_CreationDataStorage>;
  33528. /** @hidden */
  33529. _geometry: Nullable<Geometry>;
  33530. /** @hidden */
  33531. _delayInfo: Array<string>;
  33532. /** @hidden */
  33533. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33534. /** @hidden */
  33535. _instanceDataStorage: _InstanceDataStorage;
  33536. /** @hidden */
  33537. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33538. private _effectiveMaterial;
  33539. /** @hidden */
  33540. _shouldGenerateFlatShading: boolean;
  33541. /** @hidden */
  33542. _originalBuilderSideOrientation: number;
  33543. /**
  33544. * Use this property to change the original side orientation defined at construction time
  33545. */
  33546. overrideMaterialSideOrientation: Nullable<number>;
  33547. /**
  33548. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33549. * Note this will reduce performance when set to true.
  33550. */
  33551. ignoreCameraMaxZ: boolean;
  33552. /**
  33553. * Gets the source mesh (the one used to clone this one from)
  33554. */
  33555. get source(): Nullable<Mesh>;
  33556. /**
  33557. * Gets the list of clones of this mesh
  33558. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33559. * Note that useClonedMeshMap=true is the default setting
  33560. */
  33561. get cloneMeshMap(): Nullable<{
  33562. [id: string]: Mesh | undefined;
  33563. }>;
  33564. /**
  33565. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33566. */
  33567. get isUnIndexed(): boolean;
  33568. set isUnIndexed(value: boolean);
  33569. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33570. get worldMatrixInstancedBuffer(): Float32Array;
  33571. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33572. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33573. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33574. /**
  33575. * @constructor
  33576. * @param name The value used by scene.getMeshByName() to do a lookup.
  33577. * @param scene The scene to add this mesh to.
  33578. * @param parent The parent of this mesh, if it has one
  33579. * @param source An optional Mesh from which geometry is shared, cloned.
  33580. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33581. * When false, achieved by calling a clone(), also passing False.
  33582. * This will make creation of children, recursive.
  33583. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33584. */
  33585. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33586. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33587. doNotInstantiate: boolean;
  33588. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33589. /**
  33590. * Gets the class name
  33591. * @returns the string "Mesh".
  33592. */
  33593. getClassName(): string;
  33594. /** @hidden */
  33595. get _isMesh(): boolean;
  33596. /**
  33597. * Returns a description of this mesh
  33598. * @param fullDetails define if full details about this mesh must be used
  33599. * @returns a descriptive string representing this mesh
  33600. */
  33601. toString(fullDetails?: boolean): string;
  33602. /** @hidden */
  33603. _unBindEffect(): void;
  33604. /**
  33605. * Gets a boolean indicating if this mesh has LOD
  33606. */
  33607. get hasLODLevels(): boolean;
  33608. /**
  33609. * Gets the list of MeshLODLevel associated with the current mesh
  33610. * @returns an array of MeshLODLevel
  33611. */
  33612. getLODLevels(): MeshLODLevel[];
  33613. private _sortLODLevels;
  33614. /**
  33615. * Add a mesh as LOD level triggered at the given distance.
  33616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33617. * @param distance The distance from the center of the object to show this level
  33618. * @param mesh The mesh to be added as LOD level (can be null)
  33619. * @return This mesh (for chaining)
  33620. */
  33621. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33622. /**
  33623. * Returns the LOD level mesh at the passed distance or null if not found.
  33624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33625. * @param distance The distance from the center of the object to show this level
  33626. * @returns a Mesh or `null`
  33627. */
  33628. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33629. /**
  33630. * Remove a mesh from the LOD array
  33631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33632. * @param mesh defines the mesh to be removed
  33633. * @return This mesh (for chaining)
  33634. */
  33635. removeLODLevel(mesh: Mesh): Mesh;
  33636. /**
  33637. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33639. * @param camera defines the camera to use to compute distance
  33640. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33641. * @return This mesh (for chaining)
  33642. */
  33643. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33644. /**
  33645. * Gets the mesh internal Geometry object
  33646. */
  33647. get geometry(): Nullable<Geometry>;
  33648. /**
  33649. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33650. * @returns the total number of vertices
  33651. */
  33652. getTotalVertices(): number;
  33653. /**
  33654. * Returns the content of an associated vertex buffer
  33655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33656. * - VertexBuffer.PositionKind
  33657. * - VertexBuffer.UVKind
  33658. * - VertexBuffer.UV2Kind
  33659. * - VertexBuffer.UV3Kind
  33660. * - VertexBuffer.UV4Kind
  33661. * - VertexBuffer.UV5Kind
  33662. * - VertexBuffer.UV6Kind
  33663. * - VertexBuffer.ColorKind
  33664. * - VertexBuffer.MatricesIndicesKind
  33665. * - VertexBuffer.MatricesIndicesExtraKind
  33666. * - VertexBuffer.MatricesWeightsKind
  33667. * - VertexBuffer.MatricesWeightsExtraKind
  33668. * @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
  33669. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33670. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33671. */
  33672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33673. /**
  33674. * Returns the mesh VertexBuffer object from the requested `kind`
  33675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33676. * - VertexBuffer.PositionKind
  33677. * - VertexBuffer.NormalKind
  33678. * - VertexBuffer.UVKind
  33679. * - VertexBuffer.UV2Kind
  33680. * - VertexBuffer.UV3Kind
  33681. * - VertexBuffer.UV4Kind
  33682. * - VertexBuffer.UV5Kind
  33683. * - VertexBuffer.UV6Kind
  33684. * - VertexBuffer.ColorKind
  33685. * - VertexBuffer.MatricesIndicesKind
  33686. * - VertexBuffer.MatricesIndicesExtraKind
  33687. * - VertexBuffer.MatricesWeightsKind
  33688. * - VertexBuffer.MatricesWeightsExtraKind
  33689. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33690. */
  33691. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33692. /**
  33693. * Tests if a specific vertex buffer is associated with this mesh
  33694. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33695. * - VertexBuffer.PositionKind
  33696. * - VertexBuffer.NormalKind
  33697. * - VertexBuffer.UVKind
  33698. * - VertexBuffer.UV2Kind
  33699. * - VertexBuffer.UV3Kind
  33700. * - VertexBuffer.UV4Kind
  33701. * - VertexBuffer.UV5Kind
  33702. * - VertexBuffer.UV6Kind
  33703. * - VertexBuffer.ColorKind
  33704. * - VertexBuffer.MatricesIndicesKind
  33705. * - VertexBuffer.MatricesIndicesExtraKind
  33706. * - VertexBuffer.MatricesWeightsKind
  33707. * - VertexBuffer.MatricesWeightsExtraKind
  33708. * @returns a boolean
  33709. */
  33710. isVerticesDataPresent(kind: string): boolean;
  33711. /**
  33712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33713. * @param kind defines which buffer to check (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. * @returns a boolean
  33727. */
  33728. isVertexBufferUpdatable(kind: string): boolean;
  33729. /**
  33730. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33731. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33732. * - VertexBuffer.PositionKind
  33733. * - VertexBuffer.NormalKind
  33734. * - VertexBuffer.UVKind
  33735. * - VertexBuffer.UV2Kind
  33736. * - VertexBuffer.UV3Kind
  33737. * - VertexBuffer.UV4Kind
  33738. * - VertexBuffer.UV5Kind
  33739. * - VertexBuffer.UV6Kind
  33740. * - VertexBuffer.ColorKind
  33741. * - VertexBuffer.MatricesIndicesKind
  33742. * - VertexBuffer.MatricesIndicesExtraKind
  33743. * - VertexBuffer.MatricesWeightsKind
  33744. * - VertexBuffer.MatricesWeightsExtraKind
  33745. * @returns an array of strings
  33746. */
  33747. getVerticesDataKinds(): string[];
  33748. /**
  33749. * Returns a positive integer : the total number of indices in this mesh geometry.
  33750. * @returns the numner of indices or zero if the mesh has no geometry.
  33751. */
  33752. getTotalIndices(): number;
  33753. /**
  33754. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33755. * @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.
  33756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33757. * @returns the indices array or an empty array if the mesh has no geometry
  33758. */
  33759. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33760. get isBlocked(): boolean;
  33761. /**
  33762. * Determine if the current mesh is ready to be rendered
  33763. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33764. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33765. * @returns true if all associated assets are ready (material, textures, shaders)
  33766. */
  33767. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33768. /**
  33769. * 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.
  33770. */
  33771. get areNormalsFrozen(): boolean;
  33772. /**
  33773. * 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.
  33774. * @returns the current mesh
  33775. */
  33776. freezeNormals(): Mesh;
  33777. /**
  33778. * 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
  33779. * @returns the current mesh
  33780. */
  33781. unfreezeNormals(): Mesh;
  33782. /**
  33783. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33784. */
  33785. set overridenInstanceCount(count: number);
  33786. /** @hidden */
  33787. _preActivate(): Mesh;
  33788. /** @hidden */
  33789. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33790. /** @hidden */
  33791. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33792. protected _afterComputeWorldMatrix(): void;
  33793. /** @hidden */
  33794. _postActivate(): void;
  33795. /**
  33796. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33797. * This means the mesh underlying bounding box and sphere are recomputed.
  33798. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33799. * @returns the current mesh
  33800. */
  33801. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33802. /** @hidden */
  33803. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33804. /**
  33805. * This function will subdivide the mesh into multiple submeshes
  33806. * @param count defines the expected number of submeshes
  33807. */
  33808. subdivide(count: number): void;
  33809. /**
  33810. * Copy a FloatArray into a specific associated vertex buffer
  33811. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33812. * - VertexBuffer.PositionKind
  33813. * - VertexBuffer.UVKind
  33814. * - VertexBuffer.UV2Kind
  33815. * - VertexBuffer.UV3Kind
  33816. * - VertexBuffer.UV4Kind
  33817. * - VertexBuffer.UV5Kind
  33818. * - VertexBuffer.UV6Kind
  33819. * - VertexBuffer.ColorKind
  33820. * - VertexBuffer.MatricesIndicesKind
  33821. * - VertexBuffer.MatricesIndicesExtraKind
  33822. * - VertexBuffer.MatricesWeightsKind
  33823. * - VertexBuffer.MatricesWeightsExtraKind
  33824. * @param data defines the data source
  33825. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33826. * @param stride defines the data stride size (can be null)
  33827. * @returns the current mesh
  33828. */
  33829. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33830. /**
  33831. * Delete a vertex buffer associated with this mesh
  33832. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33833. * - VertexBuffer.PositionKind
  33834. * - VertexBuffer.UVKind
  33835. * - VertexBuffer.UV2Kind
  33836. * - VertexBuffer.UV3Kind
  33837. * - VertexBuffer.UV4Kind
  33838. * - VertexBuffer.UV5Kind
  33839. * - VertexBuffer.UV6Kind
  33840. * - VertexBuffer.ColorKind
  33841. * - VertexBuffer.MatricesIndicesKind
  33842. * - VertexBuffer.MatricesIndicesExtraKind
  33843. * - VertexBuffer.MatricesWeightsKind
  33844. * - VertexBuffer.MatricesWeightsExtraKind
  33845. */
  33846. removeVerticesData(kind: string): void;
  33847. /**
  33848. * Flags an associated vertex buffer as updatable
  33849. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33850. * - VertexBuffer.PositionKind
  33851. * - VertexBuffer.UVKind
  33852. * - VertexBuffer.UV2Kind
  33853. * - VertexBuffer.UV3Kind
  33854. * - VertexBuffer.UV4Kind
  33855. * - VertexBuffer.UV5Kind
  33856. * - VertexBuffer.UV6Kind
  33857. * - VertexBuffer.ColorKind
  33858. * - VertexBuffer.MatricesIndicesKind
  33859. * - VertexBuffer.MatricesIndicesExtraKind
  33860. * - VertexBuffer.MatricesWeightsKind
  33861. * - VertexBuffer.MatricesWeightsExtraKind
  33862. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33863. */
  33864. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33865. /**
  33866. * Sets the mesh global Vertex Buffer
  33867. * @param buffer defines the buffer to use
  33868. * @returns the current mesh
  33869. */
  33870. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33871. /**
  33872. * Update a specific associated vertex buffer
  33873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33874. * - VertexBuffer.PositionKind
  33875. * - VertexBuffer.UVKind
  33876. * - VertexBuffer.UV2Kind
  33877. * - VertexBuffer.UV3Kind
  33878. * - VertexBuffer.UV4Kind
  33879. * - VertexBuffer.UV5Kind
  33880. * - VertexBuffer.UV6Kind
  33881. * - VertexBuffer.ColorKind
  33882. * - VertexBuffer.MatricesIndicesKind
  33883. * - VertexBuffer.MatricesIndicesExtraKind
  33884. * - VertexBuffer.MatricesWeightsKind
  33885. * - VertexBuffer.MatricesWeightsExtraKind
  33886. * @param data defines the data source
  33887. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33888. * @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)
  33889. * @returns the current mesh
  33890. */
  33891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33892. /**
  33893. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33894. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33895. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33896. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33897. * @returns the current mesh
  33898. */
  33899. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33900. /**
  33901. * Creates a un-shared specific occurence of the geometry for the mesh.
  33902. * @returns the current mesh
  33903. */
  33904. makeGeometryUnique(): Mesh;
  33905. /**
  33906. * Set the index buffer of this mesh
  33907. * @param indices defines the source data
  33908. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33909. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33910. * @returns the current mesh
  33911. */
  33912. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33913. /**
  33914. * Update the current index buffer
  33915. * @param indices defines the source data
  33916. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33917. * @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)
  33918. * @returns the current mesh
  33919. */
  33920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33921. /**
  33922. * Invert the geometry to move from a right handed system to a left handed one.
  33923. * @returns the current mesh
  33924. */
  33925. toLeftHanded(): Mesh;
  33926. /** @hidden */
  33927. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33928. /** @hidden */
  33929. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33930. /**
  33931. * Registers for this mesh a javascript function called just before the rendering process
  33932. * @param func defines the function to call before rendering this mesh
  33933. * @returns the current mesh
  33934. */
  33935. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33936. /**
  33937. * Disposes a previously registered javascript function called before the rendering
  33938. * @param func defines the function to remove
  33939. * @returns the current mesh
  33940. */
  33941. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33942. /**
  33943. * Registers for this mesh a javascript function called just after the rendering is complete
  33944. * @param func defines the function to call after rendering this mesh
  33945. * @returns the current mesh
  33946. */
  33947. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33948. /**
  33949. * Disposes a previously registered javascript function called after the rendering.
  33950. * @param func defines the function to remove
  33951. * @returns the current mesh
  33952. */
  33953. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33954. /** @hidden */
  33955. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33956. /** @hidden */
  33957. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33958. /** @hidden */
  33959. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33960. /** @hidden */
  33961. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33962. /** @hidden */
  33963. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33964. /** @hidden */
  33965. _rebuild(): void;
  33966. /** @hidden */
  33967. _freeze(): void;
  33968. /** @hidden */
  33969. _unFreeze(): void;
  33970. /**
  33971. * 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
  33972. * @param subMesh defines the subMesh to render
  33973. * @param enableAlphaMode defines if alpha mode can be changed
  33974. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33975. * @returns the current mesh
  33976. */
  33977. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33978. private _onBeforeDraw;
  33979. /**
  33980. * Renormalize the mesh and patch it up if there are no weights
  33981. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33982. * However in the case of zero weights then we set just a single influence to 1.
  33983. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33984. */
  33985. cleanMatrixWeights(): void;
  33986. private normalizeSkinFourWeights;
  33987. private normalizeSkinWeightsAndExtra;
  33988. /**
  33989. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33990. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33991. * the user know there was an issue with importing the mesh
  33992. * @returns a validation object with skinned, valid and report string
  33993. */
  33994. validateSkinning(): {
  33995. skinned: boolean;
  33996. valid: boolean;
  33997. report: string;
  33998. };
  33999. /** @hidden */
  34000. _checkDelayState(): Mesh;
  34001. private _queueLoad;
  34002. /**
  34003. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34004. * A mesh is in the frustum if its bounding box intersects the frustum
  34005. * @param frustumPlanes defines the frustum to test
  34006. * @returns true if the mesh is in the frustum planes
  34007. */
  34008. isInFrustum(frustumPlanes: Plane[]): boolean;
  34009. /**
  34010. * Sets the mesh material by the material or multiMaterial `id` property
  34011. * @param id is a string identifying the material or the multiMaterial
  34012. * @returns the current mesh
  34013. */
  34014. setMaterialByID(id: string): Mesh;
  34015. /**
  34016. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34017. * @returns an array of IAnimatable
  34018. */
  34019. getAnimatables(): IAnimatable[];
  34020. /**
  34021. * Modifies the mesh geometry according to the passed transformation matrix.
  34022. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34023. * The mesh normals are modified using the same transformation.
  34024. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34025. * @param transform defines the transform matrix to use
  34026. * @see https://doc.babylonjs.com/resources/baking_transformations
  34027. * @returns the current mesh
  34028. */
  34029. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34030. /**
  34031. * Modifies the mesh geometry according to its own current World Matrix.
  34032. * The mesh World Matrix is then reset.
  34033. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34034. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34035. * @see https://doc.babylonjs.com/resources/baking_transformations
  34036. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34037. * @returns the current mesh
  34038. */
  34039. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34040. /** @hidden */
  34041. get _positions(): Nullable<Vector3[]>;
  34042. /** @hidden */
  34043. _resetPointsArrayCache(): Mesh;
  34044. /** @hidden */
  34045. _generatePointsArray(): boolean;
  34046. /**
  34047. * Returns a new Mesh object generated from the current mesh properties.
  34048. * This method must not get confused with createInstance()
  34049. * @param name is a string, the name given to the new mesh
  34050. * @param newParent can be any Node object (default `null`)
  34051. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34052. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34053. * @returns a new mesh
  34054. */
  34055. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34056. /**
  34057. * Releases resources associated with this mesh.
  34058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34060. */
  34061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34062. /** @hidden */
  34063. _disposeInstanceSpecificData(): void;
  34064. /** @hidden */
  34065. _disposeThinInstanceSpecificData(): void;
  34066. /**
  34067. * Modifies the mesh geometry according to a displacement map.
  34068. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  34069. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34070. * @param url is a string, the URL from the image file is to be downloaded.
  34071. * @param minHeight is the lower limit of the displacement.
  34072. * @param maxHeight is the upper limit of the displacement.
  34073. * @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.
  34074. * @param uvOffset is an optional vector2 used to offset UV.
  34075. * @param uvScale is an optional vector2 used to scale UV.
  34076. * @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.
  34077. * @returns the Mesh.
  34078. */
  34079. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34080. /**
  34081. * Modifies the mesh geometry according to a displacementMap buffer.
  34082. * 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.
  34083. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34084. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34085. * @param heightMapWidth is the width of the buffer image.
  34086. * @param heightMapHeight is the height of the buffer image.
  34087. * @param minHeight is the lower limit of the displacement.
  34088. * @param maxHeight is the upper limit of the displacement.
  34089. * @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.
  34090. * @param uvOffset is an optional vector2 used to offset UV.
  34091. * @param uvScale is an optional vector2 used to scale UV.
  34092. * @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.
  34093. * @returns the Mesh.
  34094. */
  34095. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34096. /**
  34097. * Modify the mesh to get a flat shading rendering.
  34098. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34099. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34100. * @returns current mesh
  34101. */
  34102. convertToFlatShadedMesh(): Mesh;
  34103. /**
  34104. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34105. * In other words, more vertices, no more indices and a single bigger VBO.
  34106. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34107. * @returns current mesh
  34108. */
  34109. convertToUnIndexedMesh(): Mesh;
  34110. /**
  34111. * Inverses facet orientations.
  34112. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34113. * @param flipNormals will also inverts the normals
  34114. * @returns current mesh
  34115. */
  34116. flipFaces(flipNormals?: boolean): Mesh;
  34117. /**
  34118. * Increase the number of facets and hence vertices in a mesh
  34119. * Vertex normals are interpolated from existing vertex normals
  34120. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34121. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34122. */
  34123. increaseVertices(numberPerEdge: number): void;
  34124. /**
  34125. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34126. * This will undo any application of covertToFlatShadedMesh
  34127. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34128. */
  34129. forceSharedVertices(): void;
  34130. /** @hidden */
  34131. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34132. /** @hidden */
  34133. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34134. /**
  34135. * Creates a new InstancedMesh object from the mesh model.
  34136. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34137. * @param name defines the name of the new instance
  34138. * @returns a new InstancedMesh
  34139. */
  34140. createInstance(name: string): InstancedMesh;
  34141. /**
  34142. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34143. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34144. * @returns the current mesh
  34145. */
  34146. synchronizeInstances(): Mesh;
  34147. /**
  34148. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34149. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34150. * This should be used together with the simplification to avoid disappearing triangles.
  34151. * @param successCallback an optional success callback to be called after the optimization finished.
  34152. * @returns the current mesh
  34153. */
  34154. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34155. /**
  34156. * Serialize current mesh
  34157. * @param serializationObject defines the object which will receive the serialization data
  34158. */
  34159. serialize(serializationObject: any): void;
  34160. /** @hidden */
  34161. _syncGeometryWithMorphTargetManager(): void;
  34162. /** @hidden */
  34163. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34164. /**
  34165. * Returns a new Mesh object parsed from the source provided.
  34166. * @param parsedMesh is the source
  34167. * @param scene defines the hosting scene
  34168. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34169. * @returns a new Mesh
  34170. */
  34171. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34172. /**
  34173. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34175. * @param name defines the name of the mesh to create
  34176. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34177. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34178. * @param closePath creates a seam between the first and the last points of each path of the path array
  34179. * @param offset is taken in account only if the `pathArray` is containing a single path
  34180. * @param scene defines the hosting scene
  34181. * @param updatable defines if the mesh must be flagged as updatable
  34182. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34183. * @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)
  34184. * @returns a new Mesh
  34185. */
  34186. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34187. /**
  34188. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34189. * @param name defines the name of the mesh to create
  34190. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34191. * @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
  34192. * @param scene defines the hosting scene
  34193. * @param updatable defines if the mesh must be flagged as updatable
  34194. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34195. * @returns a new Mesh
  34196. */
  34197. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34198. /**
  34199. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34200. * @param name defines the name of the mesh to create
  34201. * @param size sets the size (float) of each box side (default 1)
  34202. * @param scene defines the hosting scene
  34203. * @param updatable defines if the mesh must be flagged as updatable
  34204. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34205. * @returns a new Mesh
  34206. */
  34207. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34208. /**
  34209. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34210. * @param name defines the name of the mesh to create
  34211. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34212. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34213. * @param scene defines the hosting scene
  34214. * @param updatable defines if the mesh must be flagged as updatable
  34215. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34216. * @returns a new Mesh
  34217. */
  34218. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34219. /**
  34220. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34221. * @param name defines the name of the mesh to create
  34222. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34223. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34224. * @param scene defines the hosting scene
  34225. * @returns a new Mesh
  34226. */
  34227. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34228. /**
  34229. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34230. * @param name defines the name of the mesh to create
  34231. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34232. * @param diameterTop set the top cap diameter (floats, default 1)
  34233. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34234. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34235. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34236. * @param scene defines the hosting scene
  34237. * @param updatable defines if the mesh must be flagged as updatable
  34238. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34239. * @returns a new Mesh
  34240. */
  34241. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34242. /**
  34243. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34244. * @param name defines the name of the mesh to create
  34245. * @param diameter sets the diameter size (float) of the torus (default 1)
  34246. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34247. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34248. * @param scene defines the hosting scene
  34249. * @param updatable defines if the mesh must be flagged as updatable
  34250. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34251. * @returns a new Mesh
  34252. */
  34253. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34254. /**
  34255. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34256. * @param name defines the name of the mesh to create
  34257. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34258. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34259. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34260. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34261. * @param p the number of windings on X axis (positive integers, default 2)
  34262. * @param q the number of windings on Y axis (positive integers, default 3)
  34263. * @param scene defines the hosting scene
  34264. * @param updatable defines if the mesh must be flagged as updatable
  34265. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34266. * @returns a new Mesh
  34267. */
  34268. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34269. /**
  34270. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34271. * @param name defines the name of the mesh to create
  34272. * @param points is an array successive Vector3
  34273. * @param scene defines the hosting scene
  34274. * @param updatable defines if the mesh must be flagged as updatable
  34275. * @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).
  34276. * @returns a new Mesh
  34277. */
  34278. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34279. /**
  34280. * Creates a dashed line 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 points is an array successive Vector3
  34283. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34284. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34285. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34286. * @param scene defines the hosting scene
  34287. * @param updatable defines if the mesh must be flagged as updatable
  34288. * @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)
  34289. * @returns a new Mesh
  34290. */
  34291. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34292. /**
  34293. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34294. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34295. * 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.
  34296. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34297. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34298. * Remember you can only change the shape positions, not their number when updating a polygon.
  34299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34300. * @param name defines the name of the mesh to create
  34301. * @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
  34302. * @param scene defines the hosting scene
  34303. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34304. * @param updatable defines if the mesh must be flagged as updatable
  34305. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34306. * @param earcutInjection can be used to inject your own earcut reference
  34307. * @returns a new Mesh
  34308. */
  34309. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34310. /**
  34311. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34313. * @param name defines the name of the mesh to create
  34314. * @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
  34315. * @param depth defines the height of extrusion
  34316. * @param scene defines the hosting scene
  34317. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34318. * @param updatable defines if the mesh must be flagged as updatable
  34319. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34320. * @param earcutInjection can be used to inject your own earcut reference
  34321. * @returns a new Mesh
  34322. */
  34323. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34324. /**
  34325. * Creates an extruded shape mesh.
  34326. * 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
  34327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34329. * @param name defines the name of the mesh to create
  34330. * @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
  34331. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34332. * @param scale is the value to scale the shape
  34333. * @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
  34334. * @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
  34335. * @param scene defines the hosting scene
  34336. * @param updatable defines if the mesh must be flagged as updatable
  34337. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34338. * @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)
  34339. * @returns a new Mesh
  34340. */
  34341. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34342. /**
  34343. * Creates an custom extruded shape mesh.
  34344. * The custom extrusion is a parametric shape.
  34345. * It has no predefined shape. Its final shape will depend on the input parameters.
  34346. * Please consider using the same method from the MeshBuilder class instead
  34347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34348. * @param name defines the name of the mesh to create
  34349. * @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
  34350. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34351. * @param scaleFunction is a custom Javascript function called on each path point
  34352. * @param rotationFunction is a custom Javascript function called on each path point
  34353. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34354. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34355. * @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
  34356. * @param scene defines the hosting scene
  34357. * @param updatable defines if the mesh must be flagged as updatable
  34358. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34359. * @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)
  34360. * @returns a new Mesh
  34361. */
  34362. 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;
  34363. /**
  34364. * Creates lathe mesh.
  34365. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34366. * Please consider using the same method from the MeshBuilder class instead
  34367. * @param name defines the name of the mesh to create
  34368. * @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
  34369. * @param radius is the radius value of the lathe
  34370. * @param tessellation is the side number of the lathe.
  34371. * @param scene defines the hosting scene
  34372. * @param updatable defines if the mesh must be flagged as updatable
  34373. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34374. * @returns a new Mesh
  34375. */
  34376. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34377. /**
  34378. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34379. * @param name defines the name of the mesh to create
  34380. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34381. * @param scene defines the hosting scene
  34382. * @param updatable defines if the mesh must be flagged as updatable
  34383. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34384. * @returns a new Mesh
  34385. */
  34386. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34387. /**
  34388. * Creates a ground mesh.
  34389. * Please consider using the same method from the MeshBuilder class instead
  34390. * @param name defines the name of the mesh to create
  34391. * @param width set the width of the ground
  34392. * @param height set the height of the ground
  34393. * @param subdivisions sets the number of subdivisions per side
  34394. * @param scene defines the hosting scene
  34395. * @param updatable defines if the mesh must be flagged as updatable
  34396. * @returns a new Mesh
  34397. */
  34398. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34399. /**
  34400. * Creates a tiled ground mesh.
  34401. * Please consider using the same method from the MeshBuilder class instead
  34402. * @param name defines the name of the mesh to create
  34403. * @param xmin set the ground minimum X coordinate
  34404. * @param zmin set the ground minimum Y coordinate
  34405. * @param xmax set the ground maximum X coordinate
  34406. * @param zmax set the ground maximum Z coordinate
  34407. * @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
  34408. * @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
  34409. * @param scene defines the hosting scene
  34410. * @param updatable defines if the mesh must be flagged as updatable
  34411. * @returns a new Mesh
  34412. */
  34413. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34414. w: number;
  34415. h: number;
  34416. }, precision: {
  34417. w: number;
  34418. h: number;
  34419. }, scene: Scene, updatable?: boolean): Mesh;
  34420. /**
  34421. * Creates a ground mesh from a height map.
  34422. * Please consider using the same method from the MeshBuilder class instead
  34423. * @see https://doc.babylonjs.com/babylon101/height_map
  34424. * @param name defines the name of the mesh to create
  34425. * @param url sets the URL of the height map image resource
  34426. * @param width set the ground width size
  34427. * @param height set the ground height size
  34428. * @param subdivisions sets the number of subdivision per side
  34429. * @param minHeight is the minimum altitude on the ground
  34430. * @param maxHeight is the maximum altitude on the ground
  34431. * @param scene defines the hosting scene
  34432. * @param updatable defines if the mesh must be flagged as updatable
  34433. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34434. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34435. * @returns a new Mesh
  34436. */
  34437. 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;
  34438. /**
  34439. * Creates a tube mesh.
  34440. * The tube is a parametric shape.
  34441. * It has no predefined shape. Its final shape will depend on the input parameters.
  34442. * Please consider using the same method from the MeshBuilder class instead
  34443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34444. * @param name defines the name of the mesh to create
  34445. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34446. * @param radius sets the tube radius size
  34447. * @param tessellation is the number of sides on the tubular surface
  34448. * @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
  34449. * @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
  34450. * @param scene defines the hosting scene
  34451. * @param updatable defines if the mesh must be flagged as updatable
  34452. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34453. * @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)
  34454. * @returns a new Mesh
  34455. */
  34456. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34457. (i: number, distance: number): number;
  34458. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34459. /**
  34460. * Creates a polyhedron mesh.
  34461. * Please consider using the same method from the MeshBuilder class instead.
  34462. * * 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
  34463. * * The parameter `size` (positive float, default 1) sets the polygon size
  34464. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34465. * * 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`
  34466. * * 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
  34467. * * 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)`)
  34468. * * 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
  34469. * * 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
  34470. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34471. * * 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
  34472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34473. * @param name defines the name of the mesh to create
  34474. * @param options defines the options used to create the mesh
  34475. * @param scene defines the hosting scene
  34476. * @returns a new Mesh
  34477. */
  34478. static CreatePolyhedron(name: string, options: {
  34479. type?: number;
  34480. size?: number;
  34481. sizeX?: number;
  34482. sizeY?: number;
  34483. sizeZ?: number;
  34484. custom?: any;
  34485. faceUV?: Vector4[];
  34486. faceColors?: Color4[];
  34487. updatable?: boolean;
  34488. sideOrientation?: number;
  34489. }, scene: Scene): Mesh;
  34490. /**
  34491. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34492. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34493. * * 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`)
  34494. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34495. * * 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
  34496. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34497. * * 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
  34498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34499. * @param name defines the name of the mesh
  34500. * @param options defines the options used to create the mesh
  34501. * @param scene defines the hosting scene
  34502. * @returns a new Mesh
  34503. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34504. */
  34505. static CreateIcoSphere(name: string, options: {
  34506. radius?: number;
  34507. flat?: boolean;
  34508. subdivisions?: number;
  34509. sideOrientation?: number;
  34510. updatable?: boolean;
  34511. }, scene: Scene): Mesh;
  34512. /**
  34513. * Creates a decal mesh.
  34514. * Please consider using the same method from the MeshBuilder class instead.
  34515. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34516. * @param name defines the name of the mesh
  34517. * @param sourceMesh defines the mesh receiving the decal
  34518. * @param position sets the position of the decal in world coordinates
  34519. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34520. * @param size sets the decal scaling
  34521. * @param angle sets the angle to rotate the decal
  34522. * @returns a new Mesh
  34523. */
  34524. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34525. /** Creates a Capsule Mesh
  34526. * @param name defines the name of the mesh.
  34527. * @param options the constructors options used to shape the mesh.
  34528. * @param scene defines the scene the mesh is scoped to.
  34529. * @returns the capsule mesh
  34530. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34531. */
  34532. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34533. /**
  34534. * Prepare internal position array for software CPU skinning
  34535. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34536. */
  34537. setPositionsForCPUSkinning(): Float32Array;
  34538. /**
  34539. * Prepare internal normal array for software CPU skinning
  34540. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34541. */
  34542. setNormalsForCPUSkinning(): Float32Array;
  34543. /**
  34544. * Updates the vertex buffer by applying transformation from the bones
  34545. * @param skeleton defines the skeleton to apply to current mesh
  34546. * @returns the current mesh
  34547. */
  34548. applySkeleton(skeleton: Skeleton): Mesh;
  34549. /**
  34550. * 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
  34551. * @param meshes defines the list of meshes to scan
  34552. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34553. */
  34554. static MinMax(meshes: AbstractMesh[]): {
  34555. min: Vector3;
  34556. max: Vector3;
  34557. };
  34558. /**
  34559. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34560. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34561. * @returns a vector3
  34562. */
  34563. static Center(meshesOrMinMaxVector: {
  34564. min: Vector3;
  34565. max: Vector3;
  34566. } | AbstractMesh[]): Vector3;
  34567. /**
  34568. * Merge the array of meshes into a single mesh for performance reasons.
  34569. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34570. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34571. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34572. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34573. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34574. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34575. * @returns a new mesh
  34576. */
  34577. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34578. /** @hidden */
  34579. addInstance(instance: InstancedMesh): void;
  34580. /** @hidden */
  34581. removeInstance(instance: InstancedMesh): void;
  34582. }
  34583. }
  34584. declare module BABYLON {
  34585. /**
  34586. * The options Interface for creating a Capsule Mesh
  34587. */
  34588. export interface ICreateCapsuleOptions {
  34589. /** The Orientation of the capsule. Default : Vector3.Up() */
  34590. orientation?: Vector3;
  34591. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34592. subdivisions: number;
  34593. /** Number of cylindrical segments on the capsule. */
  34594. tessellation: number;
  34595. /** Height or Length of the capsule. */
  34596. height: number;
  34597. /** Radius of the capsule. */
  34598. radius: number;
  34599. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34600. capSubdivisions: number;
  34601. /** Overwrite for the top radius. */
  34602. radiusTop?: number;
  34603. /** Overwrite for the bottom radius. */
  34604. radiusBottom?: number;
  34605. /** Overwrite for the top capSubdivisions. */
  34606. topCapSubdivisions?: number;
  34607. /** Overwrite for the bottom capSubdivisions. */
  34608. bottomCapSubdivisions?: number;
  34609. /** Internal geometry is supposed to change once created. */
  34610. updatable?: boolean;
  34611. }
  34612. /**
  34613. * Class containing static functions to help procedurally build meshes
  34614. */
  34615. export class CapsuleBuilder {
  34616. /**
  34617. * Creates a capsule or a pill mesh
  34618. * @param name defines the name of the mesh
  34619. * @param options The constructors options.
  34620. * @param scene The scene the mesh is scoped to.
  34621. * @returns Capsule Mesh
  34622. */
  34623. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34624. }
  34625. }
  34626. declare module BABYLON {
  34627. /**
  34628. * Define an interface for all classes that will get and set the data on vertices
  34629. */
  34630. export interface IGetSetVerticesData {
  34631. /**
  34632. * Gets a boolean indicating if specific vertex data is present
  34633. * @param kind defines the vertex data kind to use
  34634. * @returns true is data kind is present
  34635. */
  34636. isVerticesDataPresent(kind: string): boolean;
  34637. /**
  34638. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34639. * @param kind defines the data kind (Position, normal, etc...)
  34640. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34641. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34642. * @returns a float array containing vertex data
  34643. */
  34644. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34645. /**
  34646. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34647. * @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.
  34648. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34649. * @returns the indices array or an empty array if the mesh has no geometry
  34650. */
  34651. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34652. /**
  34653. * Set specific vertex data
  34654. * @param kind defines the data kind (Position, normal, etc...)
  34655. * @param data defines the vertex data to use
  34656. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34657. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34658. */
  34659. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34660. /**
  34661. * Update a specific associated vertex buffer
  34662. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34663. * - VertexBuffer.PositionKind
  34664. * - VertexBuffer.UVKind
  34665. * - VertexBuffer.UV2Kind
  34666. * - VertexBuffer.UV3Kind
  34667. * - VertexBuffer.UV4Kind
  34668. * - VertexBuffer.UV5Kind
  34669. * - VertexBuffer.UV6Kind
  34670. * - VertexBuffer.ColorKind
  34671. * - VertexBuffer.MatricesIndicesKind
  34672. * - VertexBuffer.MatricesIndicesExtraKind
  34673. * - VertexBuffer.MatricesWeightsKind
  34674. * - VertexBuffer.MatricesWeightsExtraKind
  34675. * @param data defines the data source
  34676. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34677. * @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)
  34678. */
  34679. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34680. /**
  34681. * Creates a new index buffer
  34682. * @param indices defines the indices to store in the index buffer
  34683. * @param totalVertices defines the total number of vertices (could be null)
  34684. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34685. */
  34686. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34687. }
  34688. /**
  34689. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34690. */
  34691. export class VertexData {
  34692. /**
  34693. * Mesh side orientation : usually the external or front surface
  34694. */
  34695. static readonly FRONTSIDE: number;
  34696. /**
  34697. * Mesh side orientation : usually the internal or back surface
  34698. */
  34699. static readonly BACKSIDE: number;
  34700. /**
  34701. * Mesh side orientation : both internal and external or front and back surfaces
  34702. */
  34703. static readonly DOUBLESIDE: number;
  34704. /**
  34705. * Mesh side orientation : by default, `FRONTSIDE`
  34706. */
  34707. static readonly DEFAULTSIDE: number;
  34708. /**
  34709. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34710. */
  34711. positions: Nullable<FloatArray>;
  34712. /**
  34713. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34714. */
  34715. normals: Nullable<FloatArray>;
  34716. /**
  34717. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34718. */
  34719. tangents: Nullable<FloatArray>;
  34720. /**
  34721. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34722. */
  34723. uvs: Nullable<FloatArray>;
  34724. /**
  34725. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34726. */
  34727. uvs2: Nullable<FloatArray>;
  34728. /**
  34729. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34730. */
  34731. uvs3: Nullable<FloatArray>;
  34732. /**
  34733. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34734. */
  34735. uvs4: Nullable<FloatArray>;
  34736. /**
  34737. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34738. */
  34739. uvs5: Nullable<FloatArray>;
  34740. /**
  34741. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34742. */
  34743. uvs6: Nullable<FloatArray>;
  34744. /**
  34745. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34746. */
  34747. colors: Nullable<FloatArray>;
  34748. /**
  34749. * 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).
  34750. */
  34751. matricesIndices: Nullable<FloatArray>;
  34752. /**
  34753. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34754. */
  34755. matricesWeights: Nullable<FloatArray>;
  34756. /**
  34757. * An array extending the number of possible indices
  34758. */
  34759. matricesIndicesExtra: Nullable<FloatArray>;
  34760. /**
  34761. * An array extending the number of possible weights when the number of indices is extended
  34762. */
  34763. matricesWeightsExtra: Nullable<FloatArray>;
  34764. /**
  34765. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34766. */
  34767. indices: Nullable<IndicesArray>;
  34768. /**
  34769. * Uses the passed data array to set the set the values for the specified kind of data
  34770. * @param data a linear array of floating numbers
  34771. * @param kind the type of data that is being set, eg positions, colors etc
  34772. */
  34773. set(data: FloatArray, kind: string): void;
  34774. /**
  34775. * Associates the vertexData to the passed Mesh.
  34776. * Sets it as updatable or not (default `false`)
  34777. * @param mesh the mesh the vertexData is applied to
  34778. * @param updatable when used and having the value true allows new data to update the vertexData
  34779. * @returns the VertexData
  34780. */
  34781. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34782. /**
  34783. * Associates the vertexData to the passed Geometry.
  34784. * Sets it as updatable or not (default `false`)
  34785. * @param geometry the geometry the vertexData is applied to
  34786. * @param updatable when used and having the value true allows new data to update the vertexData
  34787. * @returns VertexData
  34788. */
  34789. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34790. /**
  34791. * Updates the associated mesh
  34792. * @param mesh the mesh to be updated
  34793. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34794. * @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
  34795. * @returns VertexData
  34796. */
  34797. updateMesh(mesh: Mesh): VertexData;
  34798. /**
  34799. * Updates the associated geometry
  34800. * @param geometry the geometry to be updated
  34801. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34802. * @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
  34803. * @returns VertexData.
  34804. */
  34805. updateGeometry(geometry: Geometry): VertexData;
  34806. private _applyTo;
  34807. private _update;
  34808. /**
  34809. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34810. * @param matrix the transforming matrix
  34811. * @returns the VertexData
  34812. */
  34813. transform(matrix: Matrix): VertexData;
  34814. /**
  34815. * Merges the passed VertexData into the current one
  34816. * @param other the VertexData to be merged into the current one
  34817. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34818. * @returns the modified VertexData
  34819. */
  34820. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34821. private _mergeElement;
  34822. private _validate;
  34823. /**
  34824. * Serializes the VertexData
  34825. * @returns a serialized object
  34826. */
  34827. serialize(): any;
  34828. /**
  34829. * Extracts the vertexData from a mesh
  34830. * @param mesh the mesh from which to extract the VertexData
  34831. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34832. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34833. * @returns the object VertexData associated to the passed mesh
  34834. */
  34835. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34836. /**
  34837. * Extracts the vertexData from the geometry
  34838. * @param geometry the geometry from which to extract the VertexData
  34839. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34840. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34841. * @returns the object VertexData associated to the passed mesh
  34842. */
  34843. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34844. private static _ExtractFrom;
  34845. /**
  34846. * Creates the VertexData for a Ribbon
  34847. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34848. * * pathArray array of paths, each of which an array of successive Vector3
  34849. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34850. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34851. * * 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
  34852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34853. * * 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)
  34854. * * 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)
  34855. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34856. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34857. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34858. * @returns the VertexData of the ribbon
  34859. */
  34860. static CreateRibbon(options: {
  34861. pathArray: Vector3[][];
  34862. closeArray?: boolean;
  34863. closePath?: boolean;
  34864. offset?: number;
  34865. sideOrientation?: number;
  34866. frontUVs?: Vector4;
  34867. backUVs?: Vector4;
  34868. invertUV?: boolean;
  34869. uvs?: Vector2[];
  34870. colors?: Color4[];
  34871. }): VertexData;
  34872. /**
  34873. * Creates the VertexData for a box
  34874. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34875. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34876. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34877. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34878. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34879. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34880. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34881. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34882. * * 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)
  34883. * * 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)
  34884. * @returns the VertexData of the box
  34885. */
  34886. static CreateBox(options: {
  34887. size?: number;
  34888. width?: number;
  34889. height?: number;
  34890. depth?: number;
  34891. faceUV?: Vector4[];
  34892. faceColors?: Color4[];
  34893. sideOrientation?: number;
  34894. frontUVs?: Vector4;
  34895. backUVs?: Vector4;
  34896. }): VertexData;
  34897. /**
  34898. * Creates the VertexData for a tiled box
  34899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34900. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34901. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34902. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34904. * @returns the VertexData of the box
  34905. */
  34906. static CreateTiledBox(options: {
  34907. pattern?: number;
  34908. width?: number;
  34909. height?: number;
  34910. depth?: number;
  34911. tileSize?: number;
  34912. tileWidth?: number;
  34913. tileHeight?: number;
  34914. alignHorizontal?: number;
  34915. alignVertical?: number;
  34916. faceUV?: Vector4[];
  34917. faceColors?: Color4[];
  34918. sideOrientation?: number;
  34919. }): VertexData;
  34920. /**
  34921. * Creates the VertexData for a tiled plane
  34922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34923. * * pattern a limited pattern arrangement depending on the number
  34924. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34925. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34926. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34928. * * 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)
  34929. * * 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)
  34930. * @returns the VertexData of the tiled plane
  34931. */
  34932. static CreateTiledPlane(options: {
  34933. pattern?: number;
  34934. tileSize?: number;
  34935. tileWidth?: number;
  34936. tileHeight?: number;
  34937. size?: number;
  34938. width?: number;
  34939. height?: number;
  34940. alignHorizontal?: number;
  34941. alignVertical?: number;
  34942. sideOrientation?: number;
  34943. frontUVs?: Vector4;
  34944. backUVs?: Vector4;
  34945. }): VertexData;
  34946. /**
  34947. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34948. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34949. * * segments sets the number of horizontal strips optional, default 32
  34950. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34951. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34952. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34953. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34954. * * 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
  34955. * * 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
  34956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34957. * * 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)
  34958. * * 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)
  34959. * @returns the VertexData of the ellipsoid
  34960. */
  34961. static CreateSphere(options: {
  34962. segments?: number;
  34963. diameter?: number;
  34964. diameterX?: number;
  34965. diameterY?: number;
  34966. diameterZ?: number;
  34967. arc?: number;
  34968. slice?: number;
  34969. sideOrientation?: number;
  34970. frontUVs?: Vector4;
  34971. backUVs?: Vector4;
  34972. }): VertexData;
  34973. /**
  34974. * Creates the VertexData for a cylinder, cone or prism
  34975. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34976. * * height sets the height (y direction) of the cylinder, optional, default 2
  34977. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34978. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34979. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34980. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34981. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34982. * * 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
  34983. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34984. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34985. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34986. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34988. * * 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)
  34989. * * 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)
  34990. * @returns the VertexData of the cylinder, cone or prism
  34991. */
  34992. static CreateCylinder(options: {
  34993. height?: number;
  34994. diameterTop?: number;
  34995. diameterBottom?: number;
  34996. diameter?: number;
  34997. tessellation?: number;
  34998. subdivisions?: number;
  34999. arc?: number;
  35000. faceColors?: Color4[];
  35001. faceUV?: Vector4[];
  35002. hasRings?: boolean;
  35003. enclose?: boolean;
  35004. sideOrientation?: number;
  35005. frontUVs?: Vector4;
  35006. backUVs?: Vector4;
  35007. }): VertexData;
  35008. /**
  35009. * Creates the VertexData for a torus
  35010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35011. * * diameter the diameter of the torus, optional default 1
  35012. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35013. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35015. * * 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)
  35016. * * 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)
  35017. * @returns the VertexData of the torus
  35018. */
  35019. static CreateTorus(options: {
  35020. diameter?: number;
  35021. thickness?: number;
  35022. tessellation?: number;
  35023. sideOrientation?: number;
  35024. frontUVs?: Vector4;
  35025. backUVs?: Vector4;
  35026. }): VertexData;
  35027. /**
  35028. * Creates the VertexData of the LineSystem
  35029. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35030. * - lines an array of lines, each line being an array of successive Vector3
  35031. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35032. * @returns the VertexData of the LineSystem
  35033. */
  35034. static CreateLineSystem(options: {
  35035. lines: Vector3[][];
  35036. colors?: Nullable<Color4[][]>;
  35037. }): VertexData;
  35038. /**
  35039. * Create the VertexData for a DashedLines
  35040. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35041. * - points an array successive Vector3
  35042. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35043. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35044. * - dashNb the intended total number of dashes, optional, default 200
  35045. * @returns the VertexData for the DashedLines
  35046. */
  35047. static CreateDashedLines(options: {
  35048. points: Vector3[];
  35049. dashSize?: number;
  35050. gapSize?: number;
  35051. dashNb?: number;
  35052. }): VertexData;
  35053. /**
  35054. * Creates the VertexData for a Ground
  35055. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35056. * - width the width (x direction) of the ground, optional, default 1
  35057. * - height the height (z direction) of the ground, optional, default 1
  35058. * - subdivisions the number of subdivisions per side, optional, default 1
  35059. * @returns the VertexData of the Ground
  35060. */
  35061. static CreateGround(options: {
  35062. width?: number;
  35063. height?: number;
  35064. subdivisions?: number;
  35065. subdivisionsX?: number;
  35066. subdivisionsY?: number;
  35067. }): VertexData;
  35068. /**
  35069. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35070. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35071. * * xmin the ground minimum X coordinate, optional, default -1
  35072. * * zmin the ground minimum Z coordinate, optional, default -1
  35073. * * xmax the ground maximum X coordinate, optional, default 1
  35074. * * zmax the ground maximum Z coordinate, optional, default 1
  35075. * * 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}
  35076. * * 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}
  35077. * @returns the VertexData of the TiledGround
  35078. */
  35079. static CreateTiledGround(options: {
  35080. xmin: number;
  35081. zmin: number;
  35082. xmax: number;
  35083. zmax: number;
  35084. subdivisions?: {
  35085. w: number;
  35086. h: number;
  35087. };
  35088. precision?: {
  35089. w: number;
  35090. h: number;
  35091. };
  35092. }): VertexData;
  35093. /**
  35094. * Creates the VertexData of the Ground designed from a heightmap
  35095. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35096. * * width the width (x direction) of the ground
  35097. * * height the height (z direction) of the ground
  35098. * * subdivisions the number of subdivisions per side
  35099. * * minHeight the minimum altitude on the ground, optional, default 0
  35100. * * maxHeight the maximum altitude on the ground, optional default 1
  35101. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35102. * * buffer the array holding the image color data
  35103. * * bufferWidth the width of image
  35104. * * bufferHeight the height of image
  35105. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35106. * @returns the VertexData of the Ground designed from a heightmap
  35107. */
  35108. static CreateGroundFromHeightMap(options: {
  35109. width: number;
  35110. height: number;
  35111. subdivisions: number;
  35112. minHeight: number;
  35113. maxHeight: number;
  35114. colorFilter: Color3;
  35115. buffer: Uint8Array;
  35116. bufferWidth: number;
  35117. bufferHeight: number;
  35118. alphaFilter: number;
  35119. }): VertexData;
  35120. /**
  35121. * Creates the VertexData for a Plane
  35122. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35123. * * size sets the width and height of the plane to the value of size, optional default 1
  35124. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35125. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35127. * * 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)
  35128. * * 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)
  35129. * @returns the VertexData of the box
  35130. */
  35131. static CreatePlane(options: {
  35132. size?: number;
  35133. width?: number;
  35134. height?: number;
  35135. sideOrientation?: number;
  35136. frontUVs?: Vector4;
  35137. backUVs?: Vector4;
  35138. }): VertexData;
  35139. /**
  35140. * Creates the VertexData of the Disc or regular Polygon
  35141. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35142. * * radius the radius of the disc, optional default 0.5
  35143. * * tessellation the number of polygon sides, optional, default 64
  35144. * * 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
  35145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35146. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35147. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35148. * @returns the VertexData of the box
  35149. */
  35150. static CreateDisc(options: {
  35151. radius?: number;
  35152. tessellation?: number;
  35153. arc?: number;
  35154. sideOrientation?: number;
  35155. frontUVs?: Vector4;
  35156. backUVs?: Vector4;
  35157. }): VertexData;
  35158. /**
  35159. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35160. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35161. * @param polygon a mesh built from polygonTriangulation.build()
  35162. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35163. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35164. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35165. * @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)
  35166. * @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)
  35167. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35168. * @returns the VertexData of the Polygon
  35169. */
  35170. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35171. /**
  35172. * Creates the VertexData of the IcoSphere
  35173. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35174. * * radius the radius of the IcoSphere, optional default 1
  35175. * * radiusX allows stretching in the x direction, optional, default radius
  35176. * * radiusY allows stretching in the y direction, optional, default radius
  35177. * * radiusZ allows stretching in the z direction, optional, default radius
  35178. * * flat when true creates a flat shaded mesh, optional, default true
  35179. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35181. * * 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)
  35182. * * 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)
  35183. * @returns the VertexData of the IcoSphere
  35184. */
  35185. static CreateIcoSphere(options: {
  35186. radius?: number;
  35187. radiusX?: number;
  35188. radiusY?: number;
  35189. radiusZ?: number;
  35190. flat?: boolean;
  35191. subdivisions?: number;
  35192. sideOrientation?: number;
  35193. frontUVs?: Vector4;
  35194. backUVs?: Vector4;
  35195. }): VertexData;
  35196. /**
  35197. * Creates the VertexData for a Polyhedron
  35198. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35199. * * type provided types are:
  35200. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35201. * * 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)
  35202. * * size the size of the IcoSphere, optional default 1
  35203. * * sizeX allows stretching in the x direction, optional, default size
  35204. * * sizeY allows stretching in the y direction, optional, default size
  35205. * * sizeZ allows stretching in the z direction, optional, default size
  35206. * * 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
  35207. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35208. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35209. * * flat when true creates a flat shaded mesh, optional, default true
  35210. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35212. * * 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)
  35213. * * 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)
  35214. * @returns the VertexData of the Polyhedron
  35215. */
  35216. static CreatePolyhedron(options: {
  35217. type?: number;
  35218. size?: number;
  35219. sizeX?: number;
  35220. sizeY?: number;
  35221. sizeZ?: number;
  35222. custom?: any;
  35223. faceUV?: Vector4[];
  35224. faceColors?: Color4[];
  35225. flat?: boolean;
  35226. sideOrientation?: number;
  35227. frontUVs?: Vector4;
  35228. backUVs?: Vector4;
  35229. }): VertexData;
  35230. /**
  35231. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35232. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35233. * @returns the VertexData of the Capsule
  35234. */
  35235. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35236. /**
  35237. * Creates the VertexData for a TorusKnot
  35238. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35239. * * radius the radius of the torus knot, optional, default 2
  35240. * * tube the thickness of the tube, optional, default 0.5
  35241. * * radialSegments the number of sides on each tube segments, optional, default 32
  35242. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35243. * * p the number of windings around the z axis, optional, default 2
  35244. * * q the number of windings around the x axis, optional, default 3
  35245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35246. * * 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)
  35247. * * 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)
  35248. * @returns the VertexData of the Torus Knot
  35249. */
  35250. static CreateTorusKnot(options: {
  35251. radius?: number;
  35252. tube?: number;
  35253. radialSegments?: number;
  35254. tubularSegments?: number;
  35255. p?: number;
  35256. q?: number;
  35257. sideOrientation?: number;
  35258. frontUVs?: Vector4;
  35259. backUVs?: Vector4;
  35260. }): VertexData;
  35261. /**
  35262. * Compute normals for given positions and indices
  35263. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35264. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35265. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35266. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35267. * * facetNormals : optional array of facet normals (vector3)
  35268. * * facetPositions : optional array of facet positions (vector3)
  35269. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35270. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35271. * * bInfo : optional bounding info, required for facetPartitioning computation
  35272. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35273. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35274. * * useRightHandedSystem: optional boolean to for right handed system computation
  35275. * * depthSort : optional boolean to enable the facet depth sort computation
  35276. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35277. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35278. */
  35279. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35280. facetNormals?: any;
  35281. facetPositions?: any;
  35282. facetPartitioning?: any;
  35283. ratio?: number;
  35284. bInfo?: any;
  35285. bbSize?: Vector3;
  35286. subDiv?: any;
  35287. useRightHandedSystem?: boolean;
  35288. depthSort?: boolean;
  35289. distanceTo?: Vector3;
  35290. depthSortedFacets?: any;
  35291. }): void;
  35292. /** @hidden */
  35293. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35294. /**
  35295. * Applies VertexData created from the imported parameters to the geometry
  35296. * @param parsedVertexData the parsed data from an imported file
  35297. * @param geometry the geometry to apply the VertexData to
  35298. */
  35299. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35300. }
  35301. }
  35302. declare module BABYLON {
  35303. /**
  35304. * Class containing static functions to help procedurally build meshes
  35305. */
  35306. export class DiscBuilder {
  35307. /**
  35308. * Creates a plane polygonal mesh. By default, this is a disc
  35309. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35310. * * 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
  35311. * * 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
  35312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35313. * * 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
  35314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35315. * @param name defines the name of the mesh
  35316. * @param options defines the options used to create the mesh
  35317. * @param scene defines the hosting scene
  35318. * @returns the plane polygonal mesh
  35319. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35320. */
  35321. static CreateDisc(name: string, options: {
  35322. radius?: number;
  35323. tessellation?: number;
  35324. arc?: number;
  35325. updatable?: boolean;
  35326. sideOrientation?: number;
  35327. frontUVs?: Vector4;
  35328. backUVs?: Vector4;
  35329. }, scene?: Nullable<Scene>): Mesh;
  35330. }
  35331. }
  35332. declare module BABYLON {
  35333. /**
  35334. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35335. *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.
  35336. * The SPS is also a particle system. It provides some methods to manage the particles.
  35337. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35338. *
  35339. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35340. */
  35341. export class SolidParticleSystem implements IDisposable {
  35342. /**
  35343. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35344. * Example : var p = SPS.particles[i];
  35345. */
  35346. particles: SolidParticle[];
  35347. /**
  35348. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35349. */
  35350. nbParticles: number;
  35351. /**
  35352. * If the particles must ever face the camera (default false). Useful for planar particles.
  35353. */
  35354. billboard: boolean;
  35355. /**
  35356. * Recompute normals when adding a shape
  35357. */
  35358. recomputeNormals: boolean;
  35359. /**
  35360. * This a counter ofr your own usage. It's not set by any SPS functions.
  35361. */
  35362. counter: number;
  35363. /**
  35364. * The SPS name. This name is also given to the underlying mesh.
  35365. */
  35366. name: string;
  35367. /**
  35368. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35369. */
  35370. mesh: Mesh;
  35371. /**
  35372. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35373. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35374. */
  35375. vars: any;
  35376. /**
  35377. * This array is populated when the SPS is set as 'pickable'.
  35378. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35379. * Each element of this array is an object `{idx: int, faceId: int}`.
  35380. * `idx` is the picked particle index in the `SPS.particles` array
  35381. * `faceId` is the picked face index counted within this particle.
  35382. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35383. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35384. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35385. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35386. */
  35387. pickedParticles: {
  35388. idx: number;
  35389. faceId: number;
  35390. }[];
  35391. /**
  35392. * This array is populated when the SPS is set as 'pickable'
  35393. * Each key of this array is a submesh index.
  35394. * Each element of this array is a second array defined like this :
  35395. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35396. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35397. * `idx` is the picked particle index in the `SPS.particles` array
  35398. * `faceId` is the picked face index counted within this particle.
  35399. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35400. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35401. */
  35402. pickedBySubMesh: {
  35403. idx: number;
  35404. faceId: number;
  35405. }[][];
  35406. /**
  35407. * This array is populated when `enableDepthSort` is set to true.
  35408. * Each element of this array is an instance of the class DepthSortedParticle.
  35409. */
  35410. depthSortedParticles: DepthSortedParticle[];
  35411. /**
  35412. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35413. * @hidden
  35414. */
  35415. _bSphereOnly: boolean;
  35416. /**
  35417. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35418. * @hidden
  35419. */
  35420. _bSphereRadiusFactor: number;
  35421. private _scene;
  35422. private _positions;
  35423. private _indices;
  35424. private _normals;
  35425. private _colors;
  35426. private _uvs;
  35427. private _indices32;
  35428. private _positions32;
  35429. private _normals32;
  35430. private _fixedNormal32;
  35431. private _colors32;
  35432. private _uvs32;
  35433. private _index;
  35434. private _updatable;
  35435. private _pickable;
  35436. private _isVisibilityBoxLocked;
  35437. private _alwaysVisible;
  35438. private _depthSort;
  35439. private _expandable;
  35440. private _shapeCounter;
  35441. private _copy;
  35442. private _color;
  35443. private _computeParticleColor;
  35444. private _computeParticleTexture;
  35445. private _computeParticleRotation;
  35446. private _computeParticleVertex;
  35447. private _computeBoundingBox;
  35448. private _depthSortParticles;
  35449. private _camera;
  35450. private _mustUnrotateFixedNormals;
  35451. private _particlesIntersect;
  35452. private _needs32Bits;
  35453. private _isNotBuilt;
  35454. private _lastParticleId;
  35455. private _idxOfId;
  35456. private _multimaterialEnabled;
  35457. private _useModelMaterial;
  35458. private _indicesByMaterial;
  35459. private _materialIndexes;
  35460. private _depthSortFunction;
  35461. private _materialSortFunction;
  35462. private _materials;
  35463. private _multimaterial;
  35464. private _materialIndexesById;
  35465. private _defaultMaterial;
  35466. private _autoUpdateSubMeshes;
  35467. private _tmpVertex;
  35468. /**
  35469. * Creates a SPS (Solid Particle System) object.
  35470. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35471. * @param scene (Scene) is the scene in which the SPS is added.
  35472. * @param options defines the options of the sps e.g.
  35473. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35474. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35475. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35476. * * 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.
  35477. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35478. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35479. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35480. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35481. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35482. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35483. */
  35484. constructor(name: string, scene: Scene, options?: {
  35485. updatable?: boolean;
  35486. isPickable?: boolean;
  35487. enableDepthSort?: boolean;
  35488. particleIntersection?: boolean;
  35489. boundingSphereOnly?: boolean;
  35490. bSphereRadiusFactor?: number;
  35491. expandable?: boolean;
  35492. useModelMaterial?: boolean;
  35493. enableMultiMaterial?: boolean;
  35494. });
  35495. /**
  35496. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35497. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35498. * @returns the created mesh
  35499. */
  35500. buildMesh(): Mesh;
  35501. /**
  35502. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35503. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35504. * Thus the particles generated from `digest()` have their property `position` set yet.
  35505. * @param mesh ( Mesh ) is the mesh to be digested
  35506. * @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
  35507. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35508. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35509. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35510. * @returns the current SPS
  35511. */
  35512. digest(mesh: Mesh, options?: {
  35513. facetNb?: number;
  35514. number?: number;
  35515. delta?: number;
  35516. storage?: [];
  35517. }): SolidParticleSystem;
  35518. /**
  35519. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35520. * @hidden
  35521. */
  35522. private _unrotateFixedNormals;
  35523. /**
  35524. * Resets the temporary working copy particle
  35525. * @hidden
  35526. */
  35527. private _resetCopy;
  35528. /**
  35529. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35530. * @param p the current index in the positions array to be updated
  35531. * @param ind the current index in the indices array
  35532. * @param shape a Vector3 array, the shape geometry
  35533. * @param positions the positions array to be updated
  35534. * @param meshInd the shape indices array
  35535. * @param indices the indices array to be updated
  35536. * @param meshUV the shape uv array
  35537. * @param uvs the uv array to be updated
  35538. * @param meshCol the shape color array
  35539. * @param colors the color array to be updated
  35540. * @param meshNor the shape normals array
  35541. * @param normals the normals array to be updated
  35542. * @param idx the particle index
  35543. * @param idxInShape the particle index in its shape
  35544. * @param options the addShape() method passed options
  35545. * @model the particle model
  35546. * @hidden
  35547. */
  35548. private _meshBuilder;
  35549. /**
  35550. * Returns a shape Vector3 array from positions float array
  35551. * @param positions float array
  35552. * @returns a vector3 array
  35553. * @hidden
  35554. */
  35555. private _posToShape;
  35556. /**
  35557. * Returns a shapeUV array from a float uvs (array deep copy)
  35558. * @param uvs as a float array
  35559. * @returns a shapeUV array
  35560. * @hidden
  35561. */
  35562. private _uvsToShapeUV;
  35563. /**
  35564. * Adds a new particle object in the particles array
  35565. * @param idx particle index in particles array
  35566. * @param id particle id
  35567. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35568. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35569. * @param model particle ModelShape object
  35570. * @param shapeId model shape identifier
  35571. * @param idxInShape index of the particle in the current model
  35572. * @param bInfo model bounding info object
  35573. * @param storage target storage array, if any
  35574. * @hidden
  35575. */
  35576. private _addParticle;
  35577. /**
  35578. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35579. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35580. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35581. * @param nb (positive integer) the number of particles to be created from this model
  35582. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35583. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35584. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35585. * @returns the number of shapes in the system
  35586. */
  35587. addShape(mesh: Mesh, nb: number, options?: {
  35588. positionFunction?: any;
  35589. vertexFunction?: any;
  35590. storage?: [];
  35591. }): number;
  35592. /**
  35593. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35594. * @hidden
  35595. */
  35596. private _rebuildParticle;
  35597. /**
  35598. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35599. * @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.
  35600. * @returns the SPS.
  35601. */
  35602. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35603. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35604. * Returns an array with the removed particles.
  35605. * 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.
  35606. * The SPS can't be empty so at least one particle needs to remain in place.
  35607. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35608. * @param start index of the first particle to remove
  35609. * @param end index of the last particle to remove (included)
  35610. * @returns an array populated with the removed particles
  35611. */
  35612. removeParticles(start: number, end: number): SolidParticle[];
  35613. /**
  35614. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35615. * @param solidParticleArray an array populated with Solid Particles objects
  35616. * @returns the SPS
  35617. */
  35618. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35619. /**
  35620. * Creates a new particle and modifies the SPS mesh geometry :
  35621. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35622. * - calls _addParticle() to populate the particle array
  35623. * factorized code from addShape() and insertParticlesFromArray()
  35624. * @param idx particle index in the particles array
  35625. * @param i particle index in its shape
  35626. * @param modelShape particle ModelShape object
  35627. * @param shape shape vertex array
  35628. * @param meshInd shape indices array
  35629. * @param meshUV shape uv array
  35630. * @param meshCol shape color array
  35631. * @param meshNor shape normals array
  35632. * @param bbInfo shape bounding info
  35633. * @param storage target particle storage
  35634. * @options addShape() passed options
  35635. * @hidden
  35636. */
  35637. private _insertNewParticle;
  35638. /**
  35639. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35640. * This method calls `updateParticle()` for each particle of the SPS.
  35641. * For an animated SPS, it is usually called within the render loop.
  35642. * 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.
  35643. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35644. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35645. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35646. * @returns the SPS.
  35647. */
  35648. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35649. /**
  35650. * Disposes the SPS.
  35651. */
  35652. dispose(): void;
  35653. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35654. * idx is the particle index in the SPS
  35655. * faceId is the picked face index counted within this particle.
  35656. * Returns null if the pickInfo can't identify a picked particle.
  35657. * @param pickingInfo (PickingInfo object)
  35658. * @returns {idx: number, faceId: number} or null
  35659. */
  35660. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35661. idx: number;
  35662. faceId: number;
  35663. }>;
  35664. /**
  35665. * Returns a SolidParticle object from its identifier : particle.id
  35666. * @param id (integer) the particle Id
  35667. * @returns the searched particle or null if not found in the SPS.
  35668. */
  35669. getParticleById(id: number): Nullable<SolidParticle>;
  35670. /**
  35671. * Returns a new array populated with the particles having the passed shapeId.
  35672. * @param shapeId (integer) the shape identifier
  35673. * @returns a new solid particle array
  35674. */
  35675. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35676. /**
  35677. * Populates the passed array "ref" with the particles having the passed shapeId.
  35678. * @param shapeId the shape identifier
  35679. * @returns the SPS
  35680. * @param ref
  35681. */
  35682. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35683. /**
  35684. * Computes the required SubMeshes according the materials assigned to the particles.
  35685. * @returns the solid particle system.
  35686. * Does nothing if called before the SPS mesh is built.
  35687. */
  35688. computeSubMeshes(): SolidParticleSystem;
  35689. /**
  35690. * Sorts the solid particles by material when MultiMaterial is enabled.
  35691. * Updates the indices32 array.
  35692. * Updates the indicesByMaterial array.
  35693. * Updates the mesh indices array.
  35694. * @returns the SPS
  35695. * @hidden
  35696. */
  35697. private _sortParticlesByMaterial;
  35698. /**
  35699. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35700. * @hidden
  35701. */
  35702. private _setMaterialIndexesById;
  35703. /**
  35704. * Returns an array with unique values of Materials from the passed array
  35705. * @param array the material array to be checked and filtered
  35706. * @hidden
  35707. */
  35708. private _filterUniqueMaterialId;
  35709. /**
  35710. * Sets a new Standard Material as _defaultMaterial if not already set.
  35711. * @hidden
  35712. */
  35713. private _setDefaultMaterial;
  35714. /**
  35715. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35716. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35717. * @returns the SPS.
  35718. */
  35719. refreshVisibleSize(): SolidParticleSystem;
  35720. /**
  35721. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35722. * @param size the size (float) of the visibility box
  35723. * note : this doesn't lock the SPS mesh bounding box.
  35724. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35725. */
  35726. setVisibilityBox(size: number): void;
  35727. /**
  35728. * Gets whether the SPS as always visible or not
  35729. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35730. */
  35731. get isAlwaysVisible(): boolean;
  35732. /**
  35733. * Sets the SPS as always visible or not
  35734. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35735. */
  35736. set isAlwaysVisible(val: boolean);
  35737. /**
  35738. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35739. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35740. */
  35741. set isVisibilityBoxLocked(val: boolean);
  35742. /**
  35743. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35744. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35745. */
  35746. get isVisibilityBoxLocked(): boolean;
  35747. /**
  35748. * Tells to `setParticles()` to compute the particle rotations or not.
  35749. * Default value : true. The SPS is faster when it's set to false.
  35750. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35751. */
  35752. set computeParticleRotation(val: boolean);
  35753. /**
  35754. * Tells to `setParticles()` to compute the particle colors or not.
  35755. * Default value : true. The SPS is faster when it's set to false.
  35756. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35757. */
  35758. set computeParticleColor(val: boolean);
  35759. set computeParticleTexture(val: boolean);
  35760. /**
  35761. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35762. * Default value : false. The SPS is faster when it's set to false.
  35763. * Note : the particle custom vertex positions aren't stored values.
  35764. */
  35765. set computeParticleVertex(val: boolean);
  35766. /**
  35767. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35768. */
  35769. set computeBoundingBox(val: boolean);
  35770. /**
  35771. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35772. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35773. * Default : `true`
  35774. */
  35775. set depthSortParticles(val: boolean);
  35776. /**
  35777. * Gets if `setParticles()` computes the particle rotations or not.
  35778. * Default value : true. The SPS is faster when it's set to false.
  35779. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35780. */
  35781. get computeParticleRotation(): boolean;
  35782. /**
  35783. * Gets if `setParticles()` computes the particle colors or not.
  35784. * Default value : true. The SPS is faster when it's set to false.
  35785. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35786. */
  35787. get computeParticleColor(): boolean;
  35788. /**
  35789. * Gets if `setParticles()` computes the particle textures or not.
  35790. * Default value : true. The SPS is faster when it's set to false.
  35791. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35792. */
  35793. get computeParticleTexture(): boolean;
  35794. /**
  35795. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35796. * Default value : false. The SPS is faster when it's set to false.
  35797. * Note : the particle custom vertex positions aren't stored values.
  35798. */
  35799. get computeParticleVertex(): boolean;
  35800. /**
  35801. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35802. */
  35803. get computeBoundingBox(): boolean;
  35804. /**
  35805. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35807. * Default : `true`
  35808. */
  35809. get depthSortParticles(): boolean;
  35810. /**
  35811. * Gets if the SPS is created as expandable at construction time.
  35812. * Default : `false`
  35813. */
  35814. get expandable(): boolean;
  35815. /**
  35816. * Gets if the SPS supports the Multi Materials
  35817. */
  35818. get multimaterialEnabled(): boolean;
  35819. /**
  35820. * Gets if the SPS uses the model materials for its own multimaterial.
  35821. */
  35822. get useModelMaterial(): boolean;
  35823. /**
  35824. * The SPS used material array.
  35825. */
  35826. get materials(): Material[];
  35827. /**
  35828. * Sets the SPS MultiMaterial from the passed materials.
  35829. * Note : the passed array is internally copied and not used then by reference.
  35830. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35831. */
  35832. setMultiMaterial(materials: Material[]): void;
  35833. /**
  35834. * The SPS computed multimaterial object
  35835. */
  35836. get multimaterial(): MultiMaterial;
  35837. set multimaterial(mm: MultiMaterial);
  35838. /**
  35839. * If the subMeshes must be updated on the next call to setParticles()
  35840. */
  35841. get autoUpdateSubMeshes(): boolean;
  35842. set autoUpdateSubMeshes(val: boolean);
  35843. /**
  35844. * This function does nothing. It may be overwritten to set all the particle first values.
  35845. * The SPS doesn't call this function, you may have to call it by your own.
  35846. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35847. */
  35848. initParticles(): void;
  35849. /**
  35850. * This function does nothing. It may be overwritten to recycle a particle.
  35851. * The SPS doesn't call this function, you may have to call it by your own.
  35852. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35853. * @param particle The particle to recycle
  35854. * @returns the recycled particle
  35855. */
  35856. recycleParticle(particle: SolidParticle): SolidParticle;
  35857. /**
  35858. * Updates a particle : this function should be overwritten by the user.
  35859. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35860. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35861. * @example : just set a particle position or velocity and recycle conditions
  35862. * @param particle The particle to update
  35863. * @returns the updated particle
  35864. */
  35865. updateParticle(particle: SolidParticle): SolidParticle;
  35866. /**
  35867. * Updates a vertex of a particle : it can be overwritten by the user.
  35868. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35869. * @param particle the current particle
  35870. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35871. * @param pt the index of the current vertex in the particle shape
  35872. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35873. * @example : just set a vertex particle position or color
  35874. * @returns the sps
  35875. */
  35876. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35877. /**
  35878. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35879. * This does nothing and may be overwritten by the user.
  35880. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35881. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35882. * @param update the boolean update value actually passed to setParticles()
  35883. */
  35884. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35885. /**
  35886. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35887. * This will be passed three parameters.
  35888. * This does nothing and may be overwritten by the user.
  35889. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35890. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35891. * @param update the boolean update value actually passed to setParticles()
  35892. */
  35893. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35894. }
  35895. }
  35896. declare module BABYLON {
  35897. /**
  35898. * Represents one particle of a solid particle system.
  35899. */
  35900. export class SolidParticle {
  35901. /**
  35902. * particle global index
  35903. */
  35904. idx: number;
  35905. /**
  35906. * particle identifier
  35907. */
  35908. id: number;
  35909. /**
  35910. * The color of the particle
  35911. */
  35912. color: Nullable<Color4>;
  35913. /**
  35914. * The world space position of the particle.
  35915. */
  35916. position: Vector3;
  35917. /**
  35918. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35919. */
  35920. rotation: Vector3;
  35921. /**
  35922. * The world space rotation quaternion of the particle.
  35923. */
  35924. rotationQuaternion: Nullable<Quaternion>;
  35925. /**
  35926. * The scaling of the particle.
  35927. */
  35928. scaling: Vector3;
  35929. /**
  35930. * The uvs of the particle.
  35931. */
  35932. uvs: Vector4;
  35933. /**
  35934. * The current speed of the particle.
  35935. */
  35936. velocity: Vector3;
  35937. /**
  35938. * The pivot point in the particle local space.
  35939. */
  35940. pivot: Vector3;
  35941. /**
  35942. * Must the particle be translated from its pivot point in its local space ?
  35943. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35944. * Default : false
  35945. */
  35946. translateFromPivot: boolean;
  35947. /**
  35948. * Is the particle active or not ?
  35949. */
  35950. alive: boolean;
  35951. /**
  35952. * Is the particle visible or not ?
  35953. */
  35954. isVisible: boolean;
  35955. /**
  35956. * Index of this particle in the global "positions" array (Internal use)
  35957. * @hidden
  35958. */
  35959. _pos: number;
  35960. /**
  35961. * @hidden Index of this particle in the global "indices" array (Internal use)
  35962. */
  35963. _ind: number;
  35964. /**
  35965. * @hidden ModelShape of this particle (Internal use)
  35966. */
  35967. _model: ModelShape;
  35968. /**
  35969. * ModelShape id of this particle
  35970. */
  35971. shapeId: number;
  35972. /**
  35973. * Index of the particle in its shape id
  35974. */
  35975. idxInShape: number;
  35976. /**
  35977. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35978. */
  35979. _modelBoundingInfo: BoundingInfo;
  35980. /**
  35981. * @hidden Particle BoundingInfo object (Internal use)
  35982. */
  35983. _boundingInfo: BoundingInfo;
  35984. /**
  35985. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35986. */
  35987. _sps: SolidParticleSystem;
  35988. /**
  35989. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35990. */
  35991. _stillInvisible: boolean;
  35992. /**
  35993. * @hidden Last computed particle rotation matrix
  35994. */
  35995. _rotationMatrix: number[];
  35996. /**
  35997. * Parent particle Id, if any.
  35998. * Default null.
  35999. */
  36000. parentId: Nullable<number>;
  36001. /**
  36002. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36003. */
  36004. materialIndex: Nullable<number>;
  36005. /**
  36006. * Custom object or properties.
  36007. */
  36008. props: Nullable<any>;
  36009. /**
  36010. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36011. * The possible values are :
  36012. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36013. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36014. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36015. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36016. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36017. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36018. * */
  36019. cullingStrategy: number;
  36020. /**
  36021. * @hidden Internal global position in the SPS.
  36022. */
  36023. _globalPosition: Vector3;
  36024. /**
  36025. * Creates a Solid Particle object.
  36026. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36027. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36028. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36029. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36030. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36031. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36032. * @param shapeId (integer) is the model shape identifier in the SPS.
  36033. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36034. * @param sps defines the sps it is associated to
  36035. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36036. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36037. */
  36038. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36039. /**
  36040. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36041. * @param target the particle target
  36042. * @returns the current particle
  36043. */
  36044. copyToRef(target: SolidParticle): SolidParticle;
  36045. /**
  36046. * Legacy support, changed scale to scaling
  36047. */
  36048. get scale(): Vector3;
  36049. /**
  36050. * Legacy support, changed scale to scaling
  36051. */
  36052. set scale(scale: Vector3);
  36053. /**
  36054. * Legacy support, changed quaternion to rotationQuaternion
  36055. */
  36056. get quaternion(): Nullable<Quaternion>;
  36057. /**
  36058. * Legacy support, changed quaternion to rotationQuaternion
  36059. */
  36060. set quaternion(q: Nullable<Quaternion>);
  36061. /**
  36062. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36063. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36064. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36065. * @returns true if it intersects
  36066. */
  36067. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36068. /**
  36069. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36070. * A particle is in the frustum if its bounding box intersects the frustum
  36071. * @param frustumPlanes defines the frustum to test
  36072. * @returns true if the particle is in the frustum planes
  36073. */
  36074. isInFrustum(frustumPlanes: Plane[]): boolean;
  36075. /**
  36076. * get the rotation matrix of the particle
  36077. * @hidden
  36078. */
  36079. getRotationMatrix(m: Matrix): void;
  36080. }
  36081. /**
  36082. * Represents the shape of the model used by one particle of a solid particle system.
  36083. * SPS internal tool, don't use it manually.
  36084. */
  36085. export class ModelShape {
  36086. /**
  36087. * The shape id
  36088. * @hidden
  36089. */
  36090. shapeID: number;
  36091. /**
  36092. * flat array of model positions (internal use)
  36093. * @hidden
  36094. */
  36095. _shape: Vector3[];
  36096. /**
  36097. * flat array of model UVs (internal use)
  36098. * @hidden
  36099. */
  36100. _shapeUV: number[];
  36101. /**
  36102. * color array of the model
  36103. * @hidden
  36104. */
  36105. _shapeColors: number[];
  36106. /**
  36107. * indices array of the model
  36108. * @hidden
  36109. */
  36110. _indices: number[];
  36111. /**
  36112. * normals array of the model
  36113. * @hidden
  36114. */
  36115. _normals: number[];
  36116. /**
  36117. * length of the shape in the model indices array (internal use)
  36118. * @hidden
  36119. */
  36120. _indicesLength: number;
  36121. /**
  36122. * Custom position function (internal use)
  36123. * @hidden
  36124. */
  36125. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36126. /**
  36127. * Custom vertex function (internal use)
  36128. * @hidden
  36129. */
  36130. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36131. /**
  36132. * Model material (internal use)
  36133. * @hidden
  36134. */
  36135. _material: Nullable<Material>;
  36136. /**
  36137. * 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.
  36138. * SPS internal tool, don't use it manually.
  36139. * @hidden
  36140. */
  36141. 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>);
  36142. }
  36143. /**
  36144. * Represents a Depth Sorted Particle in the solid particle system.
  36145. * @hidden
  36146. */
  36147. export class DepthSortedParticle {
  36148. /**
  36149. * Particle index
  36150. */
  36151. idx: number;
  36152. /**
  36153. * Index of the particle in the "indices" array
  36154. */
  36155. ind: number;
  36156. /**
  36157. * Length of the particle shape in the "indices" array
  36158. */
  36159. indicesLength: number;
  36160. /**
  36161. * Squared distance from the particle to the camera
  36162. */
  36163. sqDistance: number;
  36164. /**
  36165. * Material index when used with MultiMaterials
  36166. */
  36167. materialIndex: number;
  36168. /**
  36169. * Creates a new sorted particle
  36170. * @param materialIndex
  36171. */
  36172. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36173. }
  36174. /**
  36175. * Represents a solid particle vertex
  36176. */
  36177. export class SolidParticleVertex {
  36178. /**
  36179. * Vertex position
  36180. */
  36181. position: Vector3;
  36182. /**
  36183. * Vertex color
  36184. */
  36185. color: Color4;
  36186. /**
  36187. * Vertex UV
  36188. */
  36189. uv: Vector2;
  36190. /**
  36191. * Creates a new solid particle vertex
  36192. */
  36193. constructor();
  36194. /** Vertex x coordinate */
  36195. get x(): number;
  36196. set x(val: number);
  36197. /** Vertex y coordinate */
  36198. get y(): number;
  36199. set y(val: number);
  36200. /** Vertex z coordinate */
  36201. get z(): number;
  36202. set z(val: number);
  36203. }
  36204. }
  36205. declare module BABYLON {
  36206. /**
  36207. * @hidden
  36208. */
  36209. export class _MeshCollisionData {
  36210. _checkCollisions: boolean;
  36211. _collisionMask: number;
  36212. _collisionGroup: number;
  36213. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36214. _collider: Nullable<Collider>;
  36215. _oldPositionForCollisions: Vector3;
  36216. _diffPositionForCollisions: Vector3;
  36217. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36218. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36219. _collisionResponse: boolean;
  36220. }
  36221. }
  36222. declare module BABYLON {
  36223. /** @hidden */
  36224. class _FacetDataStorage {
  36225. facetPositions: Vector3[];
  36226. facetNormals: Vector3[];
  36227. facetPartitioning: number[][];
  36228. facetNb: number;
  36229. partitioningSubdivisions: number;
  36230. partitioningBBoxRatio: number;
  36231. facetDataEnabled: boolean;
  36232. facetParameters: any;
  36233. bbSize: Vector3;
  36234. subDiv: {
  36235. max: number;
  36236. X: number;
  36237. Y: number;
  36238. Z: number;
  36239. };
  36240. facetDepthSort: boolean;
  36241. facetDepthSortEnabled: boolean;
  36242. depthSortedIndices: IndicesArray;
  36243. depthSortedFacets: {
  36244. ind: number;
  36245. sqDistance: number;
  36246. }[];
  36247. facetDepthSortFunction: (f1: {
  36248. ind: number;
  36249. sqDistance: number;
  36250. }, f2: {
  36251. ind: number;
  36252. sqDistance: number;
  36253. }) => number;
  36254. facetDepthSortFrom: Vector3;
  36255. facetDepthSortOrigin: Vector3;
  36256. invertedMatrix: Matrix;
  36257. }
  36258. /**
  36259. * @hidden
  36260. **/
  36261. class _InternalAbstractMeshDataInfo {
  36262. _hasVertexAlpha: boolean;
  36263. _useVertexColors: boolean;
  36264. _numBoneInfluencers: number;
  36265. _applyFog: boolean;
  36266. _receiveShadows: boolean;
  36267. _facetData: _FacetDataStorage;
  36268. _visibility: number;
  36269. _skeleton: Nullable<Skeleton>;
  36270. _layerMask: number;
  36271. _computeBonesUsingShaders: boolean;
  36272. _isActive: boolean;
  36273. _onlyForInstances: boolean;
  36274. _isActiveIntermediate: boolean;
  36275. _onlyForInstancesIntermediate: boolean;
  36276. _actAsRegularMesh: boolean;
  36277. _currentLOD: Nullable<AbstractMesh>;
  36278. _currentLODIsUpToDate: boolean;
  36279. }
  36280. /**
  36281. * Class used to store all common mesh properties
  36282. */
  36283. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36284. /** No occlusion */
  36285. static OCCLUSION_TYPE_NONE: number;
  36286. /** Occlusion set to optimistic */
  36287. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36288. /** Occlusion set to strict */
  36289. static OCCLUSION_TYPE_STRICT: number;
  36290. /** Use an accurate occlusion algorithm */
  36291. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36292. /** Use a conservative occlusion algorithm */
  36293. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36294. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36295. * Test order :
  36296. * Is the bounding sphere outside the frustum ?
  36297. * If not, are the bounding box vertices outside the frustum ?
  36298. * It not, then the cullable object is in the frustum.
  36299. */
  36300. static readonly CULLINGSTRATEGY_STANDARD: number;
  36301. /** Culling strategy : Bounding Sphere Only.
  36302. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36303. * It's also less accurate than the standard because some not visible objects can still be selected.
  36304. * Test : is the bounding sphere outside the frustum ?
  36305. * If not, then the cullable object is in the frustum.
  36306. */
  36307. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36308. /** Culling strategy : Optimistic Inclusion.
  36309. * This in an inclusion test first, then the standard exclusion test.
  36310. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36311. * 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.
  36312. * Anyway, it's as accurate as the standard strategy.
  36313. * Test :
  36314. * Is the cullable object bounding sphere center in the frustum ?
  36315. * If not, apply the default culling strategy.
  36316. */
  36317. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36318. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36319. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36320. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36321. * 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.
  36322. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36323. * Test :
  36324. * Is the cullable object bounding sphere center in the frustum ?
  36325. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36326. */
  36327. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36328. /**
  36329. * No billboard
  36330. */
  36331. static get BILLBOARDMODE_NONE(): number;
  36332. /** Billboard on X axis */
  36333. static get BILLBOARDMODE_X(): number;
  36334. /** Billboard on Y axis */
  36335. static get BILLBOARDMODE_Y(): number;
  36336. /** Billboard on Z axis */
  36337. static get BILLBOARDMODE_Z(): number;
  36338. /** Billboard on all axes */
  36339. static get BILLBOARDMODE_ALL(): number;
  36340. /** Billboard on using position instead of orientation */
  36341. static get BILLBOARDMODE_USE_POSITION(): number;
  36342. /** @hidden */
  36343. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36344. /**
  36345. * The culling strategy to use to check whether the mesh must be rendered or not.
  36346. * This value can be changed at any time and will be used on the next render mesh selection.
  36347. * The possible values are :
  36348. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36349. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36350. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36352. * Please read each static variable documentation to get details about the culling process.
  36353. * */
  36354. cullingStrategy: number;
  36355. /**
  36356. * Gets the number of facets in the mesh
  36357. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36358. */
  36359. get facetNb(): number;
  36360. /**
  36361. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36362. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36363. */
  36364. get partitioningSubdivisions(): number;
  36365. set partitioningSubdivisions(nb: number);
  36366. /**
  36367. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36368. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36369. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36370. */
  36371. get partitioningBBoxRatio(): number;
  36372. set partitioningBBoxRatio(ratio: number);
  36373. /**
  36374. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36375. * Works only for updatable meshes.
  36376. * Doesn't work with multi-materials
  36377. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36378. */
  36379. get mustDepthSortFacets(): boolean;
  36380. set mustDepthSortFacets(sort: boolean);
  36381. /**
  36382. * The location (Vector3) where the facet depth sort must be computed from.
  36383. * By default, the active camera position.
  36384. * Used only when facet depth sort is enabled
  36385. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36386. */
  36387. get facetDepthSortFrom(): Vector3;
  36388. set facetDepthSortFrom(location: Vector3);
  36389. /**
  36390. * gets a boolean indicating if facetData is enabled
  36391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36392. */
  36393. get isFacetDataEnabled(): boolean;
  36394. /** @hidden */
  36395. _updateNonUniformScalingState(value: boolean): boolean;
  36396. /**
  36397. * An event triggered when this mesh collides with another one
  36398. */
  36399. onCollideObservable: Observable<AbstractMesh>;
  36400. /** Set a function to call when this mesh collides with another one */
  36401. set onCollide(callback: () => void);
  36402. /**
  36403. * An event triggered when the collision's position changes
  36404. */
  36405. onCollisionPositionChangeObservable: Observable<Vector3>;
  36406. /** Set a function to call when the collision's position changes */
  36407. set onCollisionPositionChange(callback: () => void);
  36408. /**
  36409. * An event triggered when material is changed
  36410. */
  36411. onMaterialChangedObservable: Observable<AbstractMesh>;
  36412. /**
  36413. * Gets or sets the orientation for POV movement & rotation
  36414. */
  36415. definedFacingForward: boolean;
  36416. /** @hidden */
  36417. _occlusionQuery: Nullable<WebGLQuery>;
  36418. /** @hidden */
  36419. _renderingGroup: Nullable<RenderingGroup>;
  36420. /**
  36421. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36422. */
  36423. get visibility(): number;
  36424. /**
  36425. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36426. */
  36427. set visibility(value: number);
  36428. /** Gets or sets the alpha index used to sort transparent meshes
  36429. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36430. */
  36431. alphaIndex: number;
  36432. /**
  36433. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36434. */
  36435. isVisible: boolean;
  36436. /**
  36437. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36438. */
  36439. isPickable: boolean;
  36440. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36441. showSubMeshesBoundingBox: boolean;
  36442. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36444. */
  36445. isBlocker: boolean;
  36446. /**
  36447. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36448. */
  36449. enablePointerMoveEvents: boolean;
  36450. private _renderingGroupId;
  36451. /**
  36452. * Specifies the rendering group id for this mesh (0 by default)
  36453. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36454. */
  36455. get renderingGroupId(): number;
  36456. set renderingGroupId(value: number);
  36457. private _material;
  36458. /** Gets or sets current material */
  36459. get material(): Nullable<Material>;
  36460. set material(value: Nullable<Material>);
  36461. /**
  36462. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36463. * @see https://doc.babylonjs.com/babylon101/shadows
  36464. */
  36465. get receiveShadows(): boolean;
  36466. set receiveShadows(value: boolean);
  36467. /** Defines color to use when rendering outline */
  36468. outlineColor: Color3;
  36469. /** Define width to use when rendering outline */
  36470. outlineWidth: number;
  36471. /** Defines color to use when rendering overlay */
  36472. overlayColor: Color3;
  36473. /** Defines alpha to use when rendering overlay */
  36474. overlayAlpha: number;
  36475. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36476. get hasVertexAlpha(): boolean;
  36477. set hasVertexAlpha(value: boolean);
  36478. /** 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) */
  36479. get useVertexColors(): boolean;
  36480. set useVertexColors(value: boolean);
  36481. /**
  36482. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36483. */
  36484. get computeBonesUsingShaders(): boolean;
  36485. set computeBonesUsingShaders(value: boolean);
  36486. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36487. get numBoneInfluencers(): number;
  36488. set numBoneInfluencers(value: number);
  36489. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36490. get applyFog(): boolean;
  36491. set applyFog(value: boolean);
  36492. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36493. useOctreeForRenderingSelection: boolean;
  36494. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36495. useOctreeForPicking: boolean;
  36496. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36497. useOctreeForCollisions: boolean;
  36498. /**
  36499. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36500. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36501. */
  36502. get layerMask(): number;
  36503. set layerMask(value: number);
  36504. /**
  36505. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36506. */
  36507. alwaysSelectAsActiveMesh: boolean;
  36508. /**
  36509. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36510. */
  36511. doNotSyncBoundingInfo: boolean;
  36512. /**
  36513. * Gets or sets the current action manager
  36514. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36515. */
  36516. actionManager: Nullable<AbstractActionManager>;
  36517. private _meshCollisionData;
  36518. /**
  36519. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36520. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36521. */
  36522. ellipsoid: Vector3;
  36523. /**
  36524. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36525. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36526. */
  36527. ellipsoidOffset: Vector3;
  36528. /**
  36529. * Gets or sets a collision mask used to mask collisions (default is -1).
  36530. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36531. */
  36532. get collisionMask(): number;
  36533. set collisionMask(mask: number);
  36534. /**
  36535. * Gets or sets a collision response flag (default is true).
  36536. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36537. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36538. * to respond to the collision.
  36539. */
  36540. get collisionResponse(): boolean;
  36541. set collisionResponse(response: boolean);
  36542. /**
  36543. * Gets or sets the current collision group mask (-1 by default).
  36544. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36545. */
  36546. get collisionGroup(): number;
  36547. set collisionGroup(mask: number);
  36548. /**
  36549. * Gets or sets current surrounding meshes (null by default).
  36550. *
  36551. * By default collision detection is tested against every mesh in the scene.
  36552. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36553. * meshes will be tested for the collision.
  36554. *
  36555. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36556. */
  36557. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36558. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36559. /**
  36560. * Defines edge width used when edgesRenderer is enabled
  36561. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36562. */
  36563. edgesWidth: number;
  36564. /**
  36565. * Defines edge color used when edgesRenderer is enabled
  36566. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36567. */
  36568. edgesColor: Color4;
  36569. /** @hidden */
  36570. _edgesRenderer: Nullable<IEdgesRenderer>;
  36571. /** @hidden */
  36572. _masterMesh: Nullable<AbstractMesh>;
  36573. /** @hidden */
  36574. _boundingInfo: Nullable<BoundingInfo>;
  36575. /** @hidden */
  36576. _renderId: number;
  36577. /**
  36578. * Gets or sets the list of subMeshes
  36579. * @see https://doc.babylonjs.com/how_to/multi_materials
  36580. */
  36581. subMeshes: SubMesh[];
  36582. /** @hidden */
  36583. _intersectionsInProgress: AbstractMesh[];
  36584. /** @hidden */
  36585. _unIndexed: boolean;
  36586. /** @hidden */
  36587. _lightSources: Light[];
  36588. /** Gets the list of lights affecting that mesh */
  36589. get lightSources(): Light[];
  36590. /** @hidden */
  36591. get _positions(): Nullable<Vector3[]>;
  36592. /** @hidden */
  36593. _waitingData: {
  36594. lods: Nullable<any>;
  36595. actions: Nullable<any>;
  36596. freezeWorldMatrix: Nullable<boolean>;
  36597. };
  36598. /** @hidden */
  36599. _bonesTransformMatrices: Nullable<Float32Array>;
  36600. /** @hidden */
  36601. _transformMatrixTexture: Nullable<RawTexture>;
  36602. /**
  36603. * Gets or sets a skeleton to apply skinning transformations
  36604. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36605. */
  36606. set skeleton(value: Nullable<Skeleton>);
  36607. get skeleton(): Nullable<Skeleton>;
  36608. /**
  36609. * An event triggered when the mesh is rebuilt.
  36610. */
  36611. onRebuildObservable: Observable<AbstractMesh>;
  36612. /**
  36613. * The current mesh uniform buffer.
  36614. * @hidden Internal use only.
  36615. */
  36616. _uniformBuffer: UniformBuffer;
  36617. /**
  36618. * Creates a new AbstractMesh
  36619. * @param name defines the name of the mesh
  36620. * @param scene defines the hosting scene
  36621. */
  36622. constructor(name: string, scene?: Nullable<Scene>);
  36623. protected _buildUniformLayout(): void;
  36624. /**
  36625. * Transfer the mesh values to its UBO.
  36626. * @param world The world matrix associated with the mesh
  36627. */
  36628. transferToEffect(world: Matrix): void;
  36629. /**
  36630. * Gets the mesh uniform buffer.
  36631. * @return the uniform buffer of the mesh.
  36632. */
  36633. getMeshUniformBuffer(): UniformBuffer;
  36634. /**
  36635. * Returns the string "AbstractMesh"
  36636. * @returns "AbstractMesh"
  36637. */
  36638. getClassName(): string;
  36639. /**
  36640. * Gets a string representation of the current mesh
  36641. * @param fullDetails defines a boolean indicating if full details must be included
  36642. * @returns a string representation of the current mesh
  36643. */
  36644. toString(fullDetails?: boolean): string;
  36645. /**
  36646. * @hidden
  36647. */
  36648. protected _getEffectiveParent(): Nullable<Node>;
  36649. /** @hidden */
  36650. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36651. /** @hidden */
  36652. _rebuild(): void;
  36653. /** @hidden */
  36654. _resyncLightSources(): void;
  36655. /** @hidden */
  36656. _resyncLightSource(light: Light): void;
  36657. /** @hidden */
  36658. _unBindEffect(): void;
  36659. /** @hidden */
  36660. _removeLightSource(light: Light, dispose: boolean): void;
  36661. private _markSubMeshesAsDirty;
  36662. /** @hidden */
  36663. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36664. /** @hidden */
  36665. _markSubMeshesAsAttributesDirty(): void;
  36666. /** @hidden */
  36667. _markSubMeshesAsMiscDirty(): void;
  36668. /**
  36669. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36670. */
  36671. get scaling(): Vector3;
  36672. set scaling(newScaling: Vector3);
  36673. /**
  36674. * Returns true if the mesh is blocked. Implemented by child classes
  36675. */
  36676. get isBlocked(): boolean;
  36677. /**
  36678. * Returns the mesh itself by default. Implemented by child classes
  36679. * @param camera defines the camera to use to pick the right LOD level
  36680. * @returns the currentAbstractMesh
  36681. */
  36682. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36683. /**
  36684. * Returns 0 by default. Implemented by child classes
  36685. * @returns an integer
  36686. */
  36687. getTotalVertices(): number;
  36688. /**
  36689. * Returns a positive integer : the total number of indices in this mesh geometry.
  36690. * @returns the number of indices or zero if the mesh has no geometry.
  36691. */
  36692. getTotalIndices(): number;
  36693. /**
  36694. * Returns null by default. Implemented by child classes
  36695. * @returns null
  36696. */
  36697. getIndices(): Nullable<IndicesArray>;
  36698. /**
  36699. * Returns the array of the requested vertex data kind. Implemented by child classes
  36700. * @param kind defines the vertex data kind to use
  36701. * @returns null
  36702. */
  36703. getVerticesData(kind: string): Nullable<FloatArray>;
  36704. /**
  36705. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36706. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36707. * Note that a new underlying VertexBuffer object is created each call.
  36708. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36709. * @param kind defines vertex data kind:
  36710. * * VertexBuffer.PositionKind
  36711. * * VertexBuffer.UVKind
  36712. * * VertexBuffer.UV2Kind
  36713. * * VertexBuffer.UV3Kind
  36714. * * VertexBuffer.UV4Kind
  36715. * * VertexBuffer.UV5Kind
  36716. * * VertexBuffer.UV6Kind
  36717. * * VertexBuffer.ColorKind
  36718. * * VertexBuffer.MatricesIndicesKind
  36719. * * VertexBuffer.MatricesIndicesExtraKind
  36720. * * VertexBuffer.MatricesWeightsKind
  36721. * * VertexBuffer.MatricesWeightsExtraKind
  36722. * @param data defines the data source
  36723. * @param updatable defines if the data must be flagged as updatable (or static)
  36724. * @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
  36725. * @returns the current mesh
  36726. */
  36727. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36728. /**
  36729. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36730. * If the mesh has no geometry, it is simply returned as it is.
  36731. * @param kind defines vertex data kind:
  36732. * * VertexBuffer.PositionKind
  36733. * * VertexBuffer.UVKind
  36734. * * VertexBuffer.UV2Kind
  36735. * * VertexBuffer.UV3Kind
  36736. * * VertexBuffer.UV4Kind
  36737. * * VertexBuffer.UV5Kind
  36738. * * VertexBuffer.UV6Kind
  36739. * * VertexBuffer.ColorKind
  36740. * * VertexBuffer.MatricesIndicesKind
  36741. * * VertexBuffer.MatricesIndicesExtraKind
  36742. * * VertexBuffer.MatricesWeightsKind
  36743. * * VertexBuffer.MatricesWeightsExtraKind
  36744. * @param data defines the data source
  36745. * @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
  36746. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36747. * @returns the current mesh
  36748. */
  36749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36750. /**
  36751. * Sets the mesh indices,
  36752. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36753. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36754. * @param totalVertices Defines the total number of vertices
  36755. * @returns the current mesh
  36756. */
  36757. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36758. /**
  36759. * Gets a boolean indicating if specific vertex data is present
  36760. * @param kind defines the vertex data kind to use
  36761. * @returns true is data kind is present
  36762. */
  36763. isVerticesDataPresent(kind: string): boolean;
  36764. /**
  36765. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36766. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36767. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36768. * @returns a BoundingInfo
  36769. */
  36770. getBoundingInfo(): BoundingInfo;
  36771. /**
  36772. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36773. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36774. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36775. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36776. * @returns the current mesh
  36777. */
  36778. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36779. /**
  36780. * Overwrite the current bounding info
  36781. * @param boundingInfo defines the new bounding info
  36782. * @returns the current mesh
  36783. */
  36784. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36785. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36786. get useBones(): boolean;
  36787. /** @hidden */
  36788. _preActivate(): void;
  36789. /** @hidden */
  36790. _preActivateForIntermediateRendering(renderId: number): void;
  36791. /** @hidden */
  36792. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36793. /** @hidden */
  36794. _postActivate(): void;
  36795. /** @hidden */
  36796. _freeze(): void;
  36797. /** @hidden */
  36798. _unFreeze(): void;
  36799. /**
  36800. * Gets the current world matrix
  36801. * @returns a Matrix
  36802. */
  36803. getWorldMatrix(): Matrix;
  36804. /** @hidden */
  36805. _getWorldMatrixDeterminant(): number;
  36806. /**
  36807. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36808. */
  36809. get isAnInstance(): boolean;
  36810. /**
  36811. * Gets a boolean indicating if this mesh has instances
  36812. */
  36813. get hasInstances(): boolean;
  36814. /**
  36815. * Gets a boolean indicating if this mesh has thin instances
  36816. */
  36817. get hasThinInstances(): boolean;
  36818. /**
  36819. * Perform relative position change from the point of view of behind the front of the mesh.
  36820. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36821. * Supports definition of mesh facing forward or backward
  36822. * @param amountRight defines the distance on the right axis
  36823. * @param amountUp defines the distance on the up axis
  36824. * @param amountForward defines the distance on the forward axis
  36825. * @returns the current mesh
  36826. */
  36827. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36828. /**
  36829. * Calculate relative position change from the point of view of behind the front of the mesh.
  36830. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36831. * Supports definition of mesh facing forward or backward
  36832. * @param amountRight defines the distance on the right axis
  36833. * @param amountUp defines the distance on the up axis
  36834. * @param amountForward defines the distance on the forward axis
  36835. * @returns the new displacement vector
  36836. */
  36837. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36838. /**
  36839. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36840. * Supports definition of mesh facing forward or backward
  36841. * @param flipBack defines the flip
  36842. * @param twirlClockwise defines the twirl
  36843. * @param tiltRight defines the tilt
  36844. * @returns the current mesh
  36845. */
  36846. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36847. /**
  36848. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36849. * Supports definition of mesh facing forward or backward.
  36850. * @param flipBack defines the flip
  36851. * @param twirlClockwise defines the twirl
  36852. * @param tiltRight defines the tilt
  36853. * @returns the new rotation vector
  36854. */
  36855. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36856. /**
  36857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36858. * This means the mesh underlying bounding box and sphere are recomputed.
  36859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36860. * @returns the current mesh
  36861. */
  36862. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36863. /** @hidden */
  36864. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36865. /** @hidden */
  36866. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36867. /** @hidden */
  36868. _updateBoundingInfo(): AbstractMesh;
  36869. /** @hidden */
  36870. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36871. /** @hidden */
  36872. protected _afterComputeWorldMatrix(): void;
  36873. /** @hidden */
  36874. get _effectiveMesh(): AbstractMesh;
  36875. /**
  36876. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36877. * A mesh is in the frustum if its bounding box intersects the frustum
  36878. * @param frustumPlanes defines the frustum to test
  36879. * @returns true if the mesh is in the frustum planes
  36880. */
  36881. isInFrustum(frustumPlanes: Plane[]): boolean;
  36882. /**
  36883. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36884. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36885. * @param frustumPlanes defines the frustum to test
  36886. * @returns true if the mesh is completely in the frustum planes
  36887. */
  36888. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36889. /**
  36890. * True if the mesh intersects another mesh or a SolidParticle object
  36891. * @param mesh defines a target mesh or SolidParticle to test
  36892. * @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)
  36893. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36894. * @returns true if there is an intersection
  36895. */
  36896. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36897. /**
  36898. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36899. * @param point defines the point to test
  36900. * @returns true if there is an intersection
  36901. */
  36902. intersectsPoint(point: Vector3): boolean;
  36903. /**
  36904. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36905. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36906. */
  36907. get checkCollisions(): boolean;
  36908. set checkCollisions(collisionEnabled: boolean);
  36909. /**
  36910. * Gets Collider object used to compute collisions (not physics)
  36911. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36912. */
  36913. get collider(): Nullable<Collider>;
  36914. /**
  36915. * Move the mesh using collision engine
  36916. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36917. * @param displacement defines the requested displacement vector
  36918. * @returns the current mesh
  36919. */
  36920. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36921. private _onCollisionPositionChange;
  36922. /** @hidden */
  36923. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36924. /** @hidden */
  36925. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36926. /** @hidden */
  36927. _checkCollision(collider: Collider): AbstractMesh;
  36928. /** @hidden */
  36929. _generatePointsArray(): boolean;
  36930. /**
  36931. * Checks if the passed Ray intersects with the mesh
  36932. * @param ray defines the ray to use
  36933. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36934. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36935. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36936. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36937. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36938. * @returns the picking info
  36939. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36940. */
  36941. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36942. /**
  36943. * Clones the current mesh
  36944. * @param name defines the mesh name
  36945. * @param newParent defines the new mesh parent
  36946. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36947. * @returns the new mesh
  36948. */
  36949. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36950. /**
  36951. * Disposes all the submeshes of the current meshnp
  36952. * @returns the current mesh
  36953. */
  36954. releaseSubMeshes(): AbstractMesh;
  36955. /**
  36956. * Releases resources associated with this abstract mesh.
  36957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36959. */
  36960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36961. /**
  36962. * Adds the passed mesh as a child to the current mesh
  36963. * @param mesh defines the child mesh
  36964. * @returns the current mesh
  36965. */
  36966. addChild(mesh: AbstractMesh): AbstractMesh;
  36967. /**
  36968. * Removes the passed mesh from the current mesh children list
  36969. * @param mesh defines the child mesh
  36970. * @returns the current mesh
  36971. */
  36972. removeChild(mesh: AbstractMesh): AbstractMesh;
  36973. /** @hidden */
  36974. private _initFacetData;
  36975. /**
  36976. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36977. * This method can be called within the render loop.
  36978. * 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
  36979. * @returns the current mesh
  36980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36981. */
  36982. updateFacetData(): AbstractMesh;
  36983. /**
  36984. * Returns the facetLocalNormals array.
  36985. * The normals are expressed in the mesh local spac
  36986. * @returns an array of Vector3
  36987. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36988. */
  36989. getFacetLocalNormals(): Vector3[];
  36990. /**
  36991. * Returns the facetLocalPositions array.
  36992. * The facet positions are expressed in the mesh local space
  36993. * @returns an array of Vector3
  36994. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36995. */
  36996. getFacetLocalPositions(): Vector3[];
  36997. /**
  36998. * Returns the facetLocalPartitioning array
  36999. * @returns an array of array of numbers
  37000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37001. */
  37002. getFacetLocalPartitioning(): number[][];
  37003. /**
  37004. * Returns the i-th facet position in the world system.
  37005. * This method allocates a new Vector3 per call
  37006. * @param i defines the facet index
  37007. * @returns a new Vector3
  37008. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37009. */
  37010. getFacetPosition(i: number): Vector3;
  37011. /**
  37012. * Sets the reference Vector3 with the i-th facet position in the world system
  37013. * @param i defines the facet index
  37014. * @param ref defines the target vector
  37015. * @returns the current mesh
  37016. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37017. */
  37018. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37019. /**
  37020. * Returns the i-th facet normal in the world system.
  37021. * This method allocates a new Vector3 per call
  37022. * @param i defines the facet index
  37023. * @returns a new Vector3
  37024. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37025. */
  37026. getFacetNormal(i: number): Vector3;
  37027. /**
  37028. * Sets the reference Vector3 with the i-th facet normal in the world system
  37029. * @param i defines the facet index
  37030. * @param ref defines the target vector
  37031. * @returns the current mesh
  37032. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37033. */
  37034. getFacetNormalToRef(i: number, ref: Vector3): this;
  37035. /**
  37036. * 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)
  37037. * @param x defines x coordinate
  37038. * @param y defines y coordinate
  37039. * @param z defines z coordinate
  37040. * @returns the array of facet indexes
  37041. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37042. */
  37043. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37044. /**
  37045. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37046. * @param projected sets as the (x,y,z) world projection on the facet
  37047. * @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
  37048. * @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
  37049. * @param x defines x coordinate
  37050. * @param y defines y coordinate
  37051. * @param z defines z coordinate
  37052. * @returns the face index if found (or null instead)
  37053. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37054. */
  37055. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37056. /**
  37057. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37058. * @param projected sets as the (x,y,z) local projection on the facet
  37059. * @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
  37060. * @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
  37061. * @param x defines x coordinate
  37062. * @param y defines y coordinate
  37063. * @param z defines z coordinate
  37064. * @returns the face index if found (or null instead)
  37065. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37066. */
  37067. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37068. /**
  37069. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37070. * @returns the parameters
  37071. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37072. */
  37073. getFacetDataParameters(): any;
  37074. /**
  37075. * Disables the feature FacetData and frees the related memory
  37076. * @returns the current mesh
  37077. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37078. */
  37079. disableFacetData(): AbstractMesh;
  37080. /**
  37081. * Updates the AbstractMesh indices array
  37082. * @param indices defines the data source
  37083. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37084. * @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)
  37085. * @returns the current mesh
  37086. */
  37087. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37088. /**
  37089. * Creates new normals data for the mesh
  37090. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37091. * @returns the current mesh
  37092. */
  37093. createNormals(updatable: boolean): AbstractMesh;
  37094. /**
  37095. * Align the mesh with a normal
  37096. * @param normal defines the normal to use
  37097. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37098. * @returns the current mesh
  37099. */
  37100. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37101. /** @hidden */
  37102. _checkOcclusionQuery(): boolean;
  37103. /**
  37104. * Disables the mesh edge rendering mode
  37105. * @returns the currentAbstractMesh
  37106. */
  37107. disableEdgesRendering(): AbstractMesh;
  37108. /**
  37109. * Enables the edge rendering mode on the mesh.
  37110. * This mode makes the mesh edges visible
  37111. * @param epsilon defines the maximal distance between two angles to detect a face
  37112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37113. * @param options options to the edge renderer
  37114. * @returns the currentAbstractMesh
  37115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37116. */
  37117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37118. /**
  37119. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37120. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37121. */
  37122. getConnectedParticleSystems(): IParticleSystem[];
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. /**
  37127. * Interface used to define ActionEvent
  37128. */
  37129. export interface IActionEvent {
  37130. /** The mesh or sprite that triggered the action */
  37131. source: any;
  37132. /** The X mouse cursor position at the time of the event */
  37133. pointerX: number;
  37134. /** The Y mouse cursor position at the time of the event */
  37135. pointerY: number;
  37136. /** The mesh that is currently pointed at (can be null) */
  37137. meshUnderPointer: Nullable<AbstractMesh>;
  37138. /** the original (browser) event that triggered the ActionEvent */
  37139. sourceEvent?: any;
  37140. /** additional data for the event */
  37141. additionalData?: any;
  37142. }
  37143. /**
  37144. * ActionEvent is the event being sent when an action is triggered.
  37145. */
  37146. export class ActionEvent implements IActionEvent {
  37147. /** The mesh or sprite that triggered the action */
  37148. source: any;
  37149. /** The X mouse cursor position at the time of the event */
  37150. pointerX: number;
  37151. /** The Y mouse cursor position at the time of the event */
  37152. pointerY: number;
  37153. /** The mesh that is currently pointed at (can be null) */
  37154. meshUnderPointer: Nullable<AbstractMesh>;
  37155. /** the original (browser) event that triggered the ActionEvent */
  37156. sourceEvent?: any;
  37157. /** additional data for the event */
  37158. additionalData?: any;
  37159. /**
  37160. * Creates a new ActionEvent
  37161. * @param source The mesh or sprite that triggered the action
  37162. * @param pointerX The X mouse cursor position at the time of the event
  37163. * @param pointerY The Y mouse cursor position at the time of the event
  37164. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37165. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37166. * @param additionalData additional data for the event
  37167. */
  37168. constructor(
  37169. /** The mesh or sprite that triggered the action */
  37170. source: any,
  37171. /** The X mouse cursor position at the time of the event */
  37172. pointerX: number,
  37173. /** The Y mouse cursor position at the time of the event */
  37174. pointerY: number,
  37175. /** The mesh that is currently pointed at (can be null) */
  37176. meshUnderPointer: Nullable<AbstractMesh>,
  37177. /** the original (browser) event that triggered the ActionEvent */
  37178. sourceEvent?: any,
  37179. /** additional data for the event */
  37180. additionalData?: any);
  37181. /**
  37182. * Helper function to auto-create an ActionEvent from a source mesh.
  37183. * @param source The source mesh that triggered the event
  37184. * @param evt The original (browser) event
  37185. * @param additionalData additional data for the event
  37186. * @returns the new ActionEvent
  37187. */
  37188. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37189. /**
  37190. * Helper function to auto-create an ActionEvent from a source sprite
  37191. * @param source The source sprite that triggered the event
  37192. * @param scene Scene associated with the sprite
  37193. * @param evt The original (browser) event
  37194. * @param additionalData additional data for the event
  37195. * @returns the new ActionEvent
  37196. */
  37197. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37198. /**
  37199. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37200. * @param scene the scene where the event occurred
  37201. * @param evt The original (browser) event
  37202. * @returns the new ActionEvent
  37203. */
  37204. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37205. /**
  37206. * Helper function to auto-create an ActionEvent from a primitive
  37207. * @param prim defines the target primitive
  37208. * @param pointerPos defines the pointer position
  37209. * @param evt The original (browser) event
  37210. * @param additionalData additional data for the event
  37211. * @returns the new ActionEvent
  37212. */
  37213. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37214. }
  37215. }
  37216. declare module BABYLON {
  37217. /**
  37218. * Abstract class used to decouple action Manager from scene and meshes.
  37219. * Do not instantiate.
  37220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37221. */
  37222. export abstract class AbstractActionManager implements IDisposable {
  37223. /** Gets the list of active triggers */
  37224. static Triggers: {
  37225. [key: string]: number;
  37226. };
  37227. /** Gets the cursor to use when hovering items */
  37228. hoverCursor: string;
  37229. /** Gets the list of actions */
  37230. actions: IAction[];
  37231. /**
  37232. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37233. */
  37234. isRecursive: boolean;
  37235. /**
  37236. * Releases all associated resources
  37237. */
  37238. abstract dispose(): void;
  37239. /**
  37240. * Does this action manager has pointer triggers
  37241. */
  37242. abstract get hasPointerTriggers(): boolean;
  37243. /**
  37244. * Does this action manager has pick triggers
  37245. */
  37246. abstract get hasPickTriggers(): boolean;
  37247. /**
  37248. * Process a specific trigger
  37249. * @param trigger defines the trigger to process
  37250. * @param evt defines the event details to be processed
  37251. */
  37252. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37253. /**
  37254. * Does this action manager handles actions of any of the given triggers
  37255. * @param triggers defines the triggers to be tested
  37256. * @return a boolean indicating whether one (or more) of the triggers is handled
  37257. */
  37258. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37259. /**
  37260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37261. * speed.
  37262. * @param triggerA defines the trigger to be tested
  37263. * @param triggerB defines the trigger to be tested
  37264. * @return a boolean indicating whether one (or more) of the triggers is handled
  37265. */
  37266. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37267. /**
  37268. * Does this action manager handles actions of a given trigger
  37269. * @param trigger defines the trigger to be tested
  37270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37271. * @return whether the trigger is handled
  37272. */
  37273. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37274. /**
  37275. * Serialize this manager to a JSON object
  37276. * @param name defines the property name to store this manager
  37277. * @returns a JSON representation of this manager
  37278. */
  37279. abstract serialize(name: string): any;
  37280. /**
  37281. * Registers an action to this action manager
  37282. * @param action defines the action to be registered
  37283. * @return the action amended (prepared) after registration
  37284. */
  37285. abstract registerAction(action: IAction): Nullable<IAction>;
  37286. /**
  37287. * Unregisters an action to this action manager
  37288. * @param action defines the action to be unregistered
  37289. * @return a boolean indicating whether the action has been unregistered
  37290. */
  37291. abstract unregisterAction(action: IAction): Boolean;
  37292. /**
  37293. * Does exist one action manager with at least one trigger
  37294. **/
  37295. static get HasTriggers(): boolean;
  37296. /**
  37297. * Does exist one action manager with at least one pick trigger
  37298. **/
  37299. static get HasPickTriggers(): boolean;
  37300. /**
  37301. * Does exist one action manager that handles actions of a given trigger
  37302. * @param trigger defines the trigger to be tested
  37303. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37304. **/
  37305. static HasSpecificTrigger(trigger: number): boolean;
  37306. }
  37307. }
  37308. declare module BABYLON {
  37309. /**
  37310. * Defines how a node can be built from a string name.
  37311. */
  37312. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37313. /**
  37314. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37315. */
  37316. export class Node implements IBehaviorAware<Node> {
  37317. /** @hidden */
  37318. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37319. private static _NodeConstructors;
  37320. /**
  37321. * Add a new node constructor
  37322. * @param type defines the type name of the node to construct
  37323. * @param constructorFunc defines the constructor function
  37324. */
  37325. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37326. /**
  37327. * Returns a node constructor based on type name
  37328. * @param type defines the type name
  37329. * @param name defines the new node name
  37330. * @param scene defines the hosting scene
  37331. * @param options defines optional options to transmit to constructors
  37332. * @returns the new constructor or null
  37333. */
  37334. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37335. /**
  37336. * Gets or sets the name of the node
  37337. */
  37338. name: string;
  37339. /**
  37340. * Gets or sets the id of the node
  37341. */
  37342. id: string;
  37343. /**
  37344. * Gets or sets the unique id of the node
  37345. */
  37346. uniqueId: number;
  37347. /**
  37348. * Gets or sets a string used to store user defined state for the node
  37349. */
  37350. state: string;
  37351. /**
  37352. * Gets or sets an object used to store user defined information for the node
  37353. */
  37354. metadata: any;
  37355. /**
  37356. * For internal use only. Please do not use.
  37357. */
  37358. reservedDataStore: any;
  37359. /**
  37360. * List of inspectable custom properties (used by the Inspector)
  37361. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37362. */
  37363. inspectableCustomProperties: IInspectable[];
  37364. private _doNotSerialize;
  37365. /**
  37366. * Gets or sets a boolean used to define if the node must be serialized
  37367. */
  37368. get doNotSerialize(): boolean;
  37369. set doNotSerialize(value: boolean);
  37370. /** @hidden */
  37371. _isDisposed: boolean;
  37372. /**
  37373. * Gets a list of Animations associated with the node
  37374. */
  37375. animations: Animation[];
  37376. protected _ranges: {
  37377. [name: string]: Nullable<AnimationRange>;
  37378. };
  37379. /**
  37380. * Callback raised when the node is ready to be used
  37381. */
  37382. onReady: Nullable<(node: Node) => void>;
  37383. private _isEnabled;
  37384. private _isParentEnabled;
  37385. private _isReady;
  37386. /** @hidden */
  37387. _currentRenderId: number;
  37388. private _parentUpdateId;
  37389. /** @hidden */
  37390. _childUpdateId: number;
  37391. /** @hidden */
  37392. _waitingParentId: Nullable<string>;
  37393. /** @hidden */
  37394. _scene: Scene;
  37395. /** @hidden */
  37396. _cache: any;
  37397. private _parentNode;
  37398. private _children;
  37399. /** @hidden */
  37400. _worldMatrix: Matrix;
  37401. /** @hidden */
  37402. _worldMatrixDeterminant: number;
  37403. /** @hidden */
  37404. _worldMatrixDeterminantIsDirty: boolean;
  37405. /** @hidden */
  37406. private _sceneRootNodesIndex;
  37407. /**
  37408. * Gets a boolean indicating if the node has been disposed
  37409. * @returns true if the node was disposed
  37410. */
  37411. isDisposed(): boolean;
  37412. /**
  37413. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37414. * @see https://doc.babylonjs.com/how_to/parenting
  37415. */
  37416. set parent(parent: Nullable<Node>);
  37417. get parent(): Nullable<Node>;
  37418. /** @hidden */
  37419. _addToSceneRootNodes(): void;
  37420. /** @hidden */
  37421. _removeFromSceneRootNodes(): void;
  37422. private _animationPropertiesOverride;
  37423. /**
  37424. * Gets or sets the animation properties override
  37425. */
  37426. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37427. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37428. /**
  37429. * Gets a string identifying the name of the class
  37430. * @returns "Node" string
  37431. */
  37432. getClassName(): string;
  37433. /** @hidden */
  37434. readonly _isNode: boolean;
  37435. /**
  37436. * An event triggered when the mesh is disposed
  37437. */
  37438. onDisposeObservable: Observable<Node>;
  37439. private _onDisposeObserver;
  37440. /**
  37441. * Sets a callback that will be raised when the node will be disposed
  37442. */
  37443. set onDispose(callback: () => void);
  37444. /**
  37445. * Creates a new Node
  37446. * @param name the name and id to be given to this node
  37447. * @param scene the scene this node will be added to
  37448. */
  37449. constructor(name: string, scene?: Nullable<Scene>);
  37450. /**
  37451. * Gets the scene of the node
  37452. * @returns a scene
  37453. */
  37454. getScene(): Scene;
  37455. /**
  37456. * Gets the engine of the node
  37457. * @returns a Engine
  37458. */
  37459. getEngine(): Engine;
  37460. private _behaviors;
  37461. /**
  37462. * Attach a behavior to the node
  37463. * @see https://doc.babylonjs.com/features/behaviour
  37464. * @param behavior defines the behavior to attach
  37465. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37466. * @returns the current Node
  37467. */
  37468. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37469. /**
  37470. * Remove an attached behavior
  37471. * @see https://doc.babylonjs.com/features/behaviour
  37472. * @param behavior defines the behavior to attach
  37473. * @returns the current Node
  37474. */
  37475. removeBehavior(behavior: Behavior<Node>): Node;
  37476. /**
  37477. * Gets the list of attached behaviors
  37478. * @see https://doc.babylonjs.com/features/behaviour
  37479. */
  37480. get behaviors(): Behavior<Node>[];
  37481. /**
  37482. * Gets an attached behavior by name
  37483. * @param name defines the name of the behavior to look for
  37484. * @see https://doc.babylonjs.com/features/behaviour
  37485. * @returns null if behavior was not found else the requested behavior
  37486. */
  37487. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37488. /**
  37489. * Returns the latest update of the World matrix
  37490. * @returns a Matrix
  37491. */
  37492. getWorldMatrix(): Matrix;
  37493. /** @hidden */
  37494. _getWorldMatrixDeterminant(): number;
  37495. /**
  37496. * Returns directly the latest state of the mesh World matrix.
  37497. * A Matrix is returned.
  37498. */
  37499. get worldMatrixFromCache(): Matrix;
  37500. /** @hidden */
  37501. _initCache(): void;
  37502. /** @hidden */
  37503. updateCache(force?: boolean): void;
  37504. /** @hidden */
  37505. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37506. /** @hidden */
  37507. _updateCache(ignoreParentClass?: boolean): void;
  37508. /** @hidden */
  37509. _isSynchronized(): boolean;
  37510. /** @hidden */
  37511. _markSyncedWithParent(): void;
  37512. /** @hidden */
  37513. isSynchronizedWithParent(): boolean;
  37514. /** @hidden */
  37515. isSynchronized(): boolean;
  37516. /**
  37517. * Is this node ready to be used/rendered
  37518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37519. * @return true if the node is ready
  37520. */
  37521. isReady(completeCheck?: boolean): boolean;
  37522. /**
  37523. * Is this node enabled?
  37524. * 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
  37525. * @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
  37526. * @return whether this node (and its parent) is enabled
  37527. */
  37528. isEnabled(checkAncestors?: boolean): boolean;
  37529. /** @hidden */
  37530. protected _syncParentEnabledState(): void;
  37531. /**
  37532. * Set the enabled state of this node
  37533. * @param value defines the new enabled state
  37534. */
  37535. setEnabled(value: boolean): void;
  37536. /**
  37537. * Is this node a descendant of the given node?
  37538. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37539. * @param ancestor defines the parent node to inspect
  37540. * @returns a boolean indicating if this node is a descendant of the given node
  37541. */
  37542. isDescendantOf(ancestor: Node): boolean;
  37543. /** @hidden */
  37544. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37545. /**
  37546. * Will return all nodes that have this node as ascendant
  37547. * @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
  37548. * @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
  37549. * @return all children nodes of all types
  37550. */
  37551. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37552. /**
  37553. * Get all child-meshes of this node
  37554. * @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)
  37555. * @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
  37556. * @returns an array of AbstractMesh
  37557. */
  37558. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37559. /**
  37560. * Get all direct children of this node
  37561. * @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
  37562. * @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)
  37563. * @returns an array of Node
  37564. */
  37565. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37566. /** @hidden */
  37567. _setReady(state: boolean): void;
  37568. /**
  37569. * Get an animation by name
  37570. * @param name defines the name of the animation to look for
  37571. * @returns null if not found else the requested animation
  37572. */
  37573. getAnimationByName(name: string): Nullable<Animation>;
  37574. /**
  37575. * Creates an animation range for this node
  37576. * @param name defines the name of the range
  37577. * @param from defines the starting key
  37578. * @param to defines the end key
  37579. */
  37580. createAnimationRange(name: string, from: number, to: number): void;
  37581. /**
  37582. * Delete a specific animation range
  37583. * @param name defines the name of the range to delete
  37584. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37585. */
  37586. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37587. /**
  37588. * Get an animation range by name
  37589. * @param name defines the name of the animation range to look for
  37590. * @returns null if not found else the requested animation range
  37591. */
  37592. getAnimationRange(name: string): Nullable<AnimationRange>;
  37593. /**
  37594. * Gets the list of all animation ranges defined on this node
  37595. * @returns an array
  37596. */
  37597. getAnimationRanges(): Nullable<AnimationRange>[];
  37598. /**
  37599. * Will start the animation sequence
  37600. * @param name defines the range frames for animation sequence
  37601. * @param loop defines if the animation should loop (false by default)
  37602. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37603. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37604. * @returns the object created for this animation. If range does not exist, it will return null
  37605. */
  37606. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37607. /**
  37608. * Serialize animation ranges into a JSON compatible object
  37609. * @returns serialization object
  37610. */
  37611. serializeAnimationRanges(): any;
  37612. /**
  37613. * Computes the world matrix of the node
  37614. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37615. * @returns the world matrix
  37616. */
  37617. computeWorldMatrix(force?: boolean): Matrix;
  37618. /**
  37619. * Releases resources associated with this node.
  37620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37622. */
  37623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37624. /**
  37625. * Parse animation range data from a serialization object and store them into a given node
  37626. * @param node defines where to store the animation ranges
  37627. * @param parsedNode defines the serialization object to read data from
  37628. * @param scene defines the hosting scene
  37629. */
  37630. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37631. /**
  37632. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37633. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37634. * @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
  37635. * @returns the new bounding vectors
  37636. */
  37637. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37638. min: Vector3;
  37639. max: Vector3;
  37640. };
  37641. }
  37642. }
  37643. declare module BABYLON {
  37644. /**
  37645. * @hidden
  37646. */
  37647. export class _IAnimationState {
  37648. key: number;
  37649. repeatCount: number;
  37650. workValue?: any;
  37651. loopMode?: number;
  37652. offsetValue?: any;
  37653. highLimitValue?: any;
  37654. }
  37655. /**
  37656. * Class used to store any kind of animation
  37657. */
  37658. export class Animation {
  37659. /**Name of the animation */
  37660. name: string;
  37661. /**Property to animate */
  37662. targetProperty: string;
  37663. /**The frames per second of the animation */
  37664. framePerSecond: number;
  37665. /**The data type of the animation */
  37666. dataType: number;
  37667. /**The loop mode of the animation */
  37668. loopMode?: number | undefined;
  37669. /**Specifies if blending should be enabled */
  37670. enableBlending?: boolean | undefined;
  37671. /**
  37672. * Use matrix interpolation instead of using direct key value when animating matrices
  37673. */
  37674. static AllowMatricesInterpolation: boolean;
  37675. /**
  37676. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37677. */
  37678. static AllowMatrixDecomposeForInterpolation: boolean;
  37679. /** Define the Url to load snippets */
  37680. static SnippetUrl: string;
  37681. /** Snippet ID if the animation was created from the snippet server */
  37682. snippetId: string;
  37683. /**
  37684. * Stores the key frames of the animation
  37685. */
  37686. private _keys;
  37687. /**
  37688. * Stores the easing function of the animation
  37689. */
  37690. private _easingFunction;
  37691. /**
  37692. * @hidden Internal use only
  37693. */
  37694. _runtimeAnimations: RuntimeAnimation[];
  37695. /**
  37696. * The set of event that will be linked to this animation
  37697. */
  37698. private _events;
  37699. /**
  37700. * Stores an array of target property paths
  37701. */
  37702. targetPropertyPath: string[];
  37703. /**
  37704. * Stores the blending speed of the animation
  37705. */
  37706. blendingSpeed: number;
  37707. /**
  37708. * Stores the animation ranges for the animation
  37709. */
  37710. private _ranges;
  37711. /**
  37712. * @hidden Internal use
  37713. */
  37714. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37715. /**
  37716. * Sets up an animation
  37717. * @param property The property to animate
  37718. * @param animationType The animation type to apply
  37719. * @param framePerSecond The frames per second of the animation
  37720. * @param easingFunction The easing function used in the animation
  37721. * @returns The created animation
  37722. */
  37723. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37724. /**
  37725. * Create and start an animation on a node
  37726. * @param name defines the name of the global animation that will be run on all nodes
  37727. * @param node defines the root node where the animation will take place
  37728. * @param targetProperty defines property to animate
  37729. * @param framePerSecond defines the number of frame per second yo use
  37730. * @param totalFrame defines the number of frames in total
  37731. * @param from defines the initial value
  37732. * @param to defines the final value
  37733. * @param loopMode defines which loop mode you want to use (off by default)
  37734. * @param easingFunction defines the easing function to use (linear by default)
  37735. * @param onAnimationEnd defines the callback to call when animation end
  37736. * @returns the animatable created for this animation
  37737. */
  37738. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37739. /**
  37740. * Create and start an animation on a node and its descendants
  37741. * @param name defines the name of the global animation that will be run on all nodes
  37742. * @param node defines the root node where the animation will take place
  37743. * @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
  37744. * @param targetProperty defines property to animate
  37745. * @param framePerSecond defines the number of frame per second to use
  37746. * @param totalFrame defines the number of frames in total
  37747. * @param from defines the initial value
  37748. * @param to defines the final value
  37749. * @param loopMode defines which loop mode you want to use (off by default)
  37750. * @param easingFunction defines the easing function to use (linear by default)
  37751. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37752. * @returns the list of animatables created for all nodes
  37753. * @example https://www.babylonjs-playground.com/#MH0VLI
  37754. */
  37755. 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[]>;
  37756. /**
  37757. * Creates a new animation, merges it with the existing animations and starts it
  37758. * @param name Name of the animation
  37759. * @param node Node which contains the scene that begins the animations
  37760. * @param targetProperty Specifies which property to animate
  37761. * @param framePerSecond The frames per second of the animation
  37762. * @param totalFrame The total number of frames
  37763. * @param from The frame at the beginning of the animation
  37764. * @param to The frame at the end of the animation
  37765. * @param loopMode Specifies the loop mode of the animation
  37766. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37767. * @param onAnimationEnd Callback to run once the animation is complete
  37768. * @returns Nullable animation
  37769. */
  37770. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37771. /**
  37772. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37773. * @param sourceAnimation defines the Animation containing keyframes to convert
  37774. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37775. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37776. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37777. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37778. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37779. */
  37780. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37781. /**
  37782. * Transition property of an host to the target Value
  37783. * @param property The property to transition
  37784. * @param targetValue The target Value of the property
  37785. * @param host The object where the property to animate belongs
  37786. * @param scene Scene used to run the animation
  37787. * @param frameRate Framerate (in frame/s) to use
  37788. * @param transition The transition type we want to use
  37789. * @param duration The duration of the animation, in milliseconds
  37790. * @param onAnimationEnd Callback trigger at the end of the animation
  37791. * @returns Nullable animation
  37792. */
  37793. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37794. /**
  37795. * Return the array of runtime animations currently using this animation
  37796. */
  37797. get runtimeAnimations(): RuntimeAnimation[];
  37798. /**
  37799. * Specifies if any of the runtime animations are currently running
  37800. */
  37801. get hasRunningRuntimeAnimations(): boolean;
  37802. /**
  37803. * Initializes the animation
  37804. * @param name Name of the animation
  37805. * @param targetProperty Property to animate
  37806. * @param framePerSecond The frames per second of the animation
  37807. * @param dataType The data type of the animation
  37808. * @param loopMode The loop mode of the animation
  37809. * @param enableBlending Specifies if blending should be enabled
  37810. */
  37811. constructor(
  37812. /**Name of the animation */
  37813. name: string,
  37814. /**Property to animate */
  37815. targetProperty: string,
  37816. /**The frames per second of the animation */
  37817. framePerSecond: number,
  37818. /**The data type of the animation */
  37819. dataType: number,
  37820. /**The loop mode of the animation */
  37821. loopMode?: number | undefined,
  37822. /**Specifies if blending should be enabled */
  37823. enableBlending?: boolean | undefined);
  37824. /**
  37825. * Converts the animation to a string
  37826. * @param fullDetails support for multiple levels of logging within scene loading
  37827. * @returns String form of the animation
  37828. */
  37829. toString(fullDetails?: boolean): string;
  37830. /**
  37831. * Add an event to this animation
  37832. * @param event Event to add
  37833. */
  37834. addEvent(event: AnimationEvent): void;
  37835. /**
  37836. * Remove all events found at the given frame
  37837. * @param frame The frame to remove events from
  37838. */
  37839. removeEvents(frame: number): void;
  37840. /**
  37841. * Retrieves all the events from the animation
  37842. * @returns Events from the animation
  37843. */
  37844. getEvents(): AnimationEvent[];
  37845. /**
  37846. * Creates an animation range
  37847. * @param name Name of the animation range
  37848. * @param from Starting frame of the animation range
  37849. * @param to Ending frame of the animation
  37850. */
  37851. createRange(name: string, from: number, to: number): void;
  37852. /**
  37853. * Deletes an animation range by name
  37854. * @param name Name of the animation range to delete
  37855. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37856. */
  37857. deleteRange(name: string, deleteFrames?: boolean): void;
  37858. /**
  37859. * Gets the animation range by name, or null if not defined
  37860. * @param name Name of the animation range
  37861. * @returns Nullable animation range
  37862. */
  37863. getRange(name: string): Nullable<AnimationRange>;
  37864. /**
  37865. * Gets the key frames from the animation
  37866. * @returns The key frames of the animation
  37867. */
  37868. getKeys(): Array<IAnimationKey>;
  37869. /**
  37870. * Gets the highest frame rate of the animation
  37871. * @returns Highest frame rate of the animation
  37872. */
  37873. getHighestFrame(): number;
  37874. /**
  37875. * Gets the easing function of the animation
  37876. * @returns Easing function of the animation
  37877. */
  37878. getEasingFunction(): IEasingFunction;
  37879. /**
  37880. * Sets the easing function of the animation
  37881. * @param easingFunction A custom mathematical formula for animation
  37882. */
  37883. setEasingFunction(easingFunction: EasingFunction): void;
  37884. /**
  37885. * Interpolates a scalar linearly
  37886. * @param startValue Start value of the animation curve
  37887. * @param endValue End value of the animation curve
  37888. * @param gradient Scalar amount to interpolate
  37889. * @returns Interpolated scalar value
  37890. */
  37891. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37892. /**
  37893. * Interpolates a scalar cubically
  37894. * @param startValue Start value of the animation curve
  37895. * @param outTangent End tangent of the animation
  37896. * @param endValue End value of the animation curve
  37897. * @param inTangent Start tangent of the animation curve
  37898. * @param gradient Scalar amount to interpolate
  37899. * @returns Interpolated scalar value
  37900. */
  37901. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37902. /**
  37903. * Interpolates a quaternion using a spherical linear interpolation
  37904. * @param startValue Start value of the animation curve
  37905. * @param endValue End value of the animation curve
  37906. * @param gradient Scalar amount to interpolate
  37907. * @returns Interpolated quaternion value
  37908. */
  37909. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37910. /**
  37911. * Interpolates a quaternion cubically
  37912. * @param startValue Start value of the animation curve
  37913. * @param outTangent End tangent of the animation curve
  37914. * @param endValue End value of the animation curve
  37915. * @param inTangent Start tangent of the animation curve
  37916. * @param gradient Scalar amount to interpolate
  37917. * @returns Interpolated quaternion value
  37918. */
  37919. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37920. /**
  37921. * Interpolates a Vector3 linearly
  37922. * @param startValue Start value of the animation curve
  37923. * @param endValue End value of the animation curve
  37924. * @param gradient Scalar amount to interpolate
  37925. * @returns Interpolated scalar value
  37926. */
  37927. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37928. /**
  37929. * Interpolates a Vector3 cubically
  37930. * @param startValue Start value of the animation curve
  37931. * @param outTangent End tangent of the animation
  37932. * @param endValue End value of the animation curve
  37933. * @param inTangent Start tangent of the animation curve
  37934. * @param gradient Scalar amount to interpolate
  37935. * @returns InterpolatedVector3 value
  37936. */
  37937. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37938. /**
  37939. * Interpolates a Vector2 linearly
  37940. * @param startValue Start value of the animation curve
  37941. * @param endValue End value of the animation curve
  37942. * @param gradient Scalar amount to interpolate
  37943. * @returns Interpolated Vector2 value
  37944. */
  37945. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37946. /**
  37947. * Interpolates a Vector2 cubically
  37948. * @param startValue Start value of the animation curve
  37949. * @param outTangent End tangent of the animation
  37950. * @param endValue End value of the animation curve
  37951. * @param inTangent Start tangent of the animation curve
  37952. * @param gradient Scalar amount to interpolate
  37953. * @returns Interpolated Vector2 value
  37954. */
  37955. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37956. /**
  37957. * Interpolates a size linearly
  37958. * @param startValue Start value of the animation curve
  37959. * @param endValue End value of the animation curve
  37960. * @param gradient Scalar amount to interpolate
  37961. * @returns Interpolated Size value
  37962. */
  37963. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37964. /**
  37965. * Interpolates a Color3 linearly
  37966. * @param startValue Start value of the animation curve
  37967. * @param endValue End value of the animation curve
  37968. * @param gradient Scalar amount to interpolate
  37969. * @returns Interpolated Color3 value
  37970. */
  37971. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37972. /**
  37973. * Interpolates a Color4 linearly
  37974. * @param startValue Start value of the animation curve
  37975. * @param endValue End value of the animation curve
  37976. * @param gradient Scalar amount to interpolate
  37977. * @returns Interpolated Color3 value
  37978. */
  37979. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37980. /**
  37981. * @hidden Internal use only
  37982. */
  37983. _getKeyValue(value: any): any;
  37984. /**
  37985. * @hidden Internal use only
  37986. */
  37987. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37988. /**
  37989. * Defines the function to use to interpolate matrices
  37990. * @param startValue defines the start matrix
  37991. * @param endValue defines the end matrix
  37992. * @param gradient defines the gradient between both matrices
  37993. * @param result defines an optional target matrix where to store the interpolation
  37994. * @returns the interpolated matrix
  37995. */
  37996. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37997. /**
  37998. * Makes a copy of the animation
  37999. * @returns Cloned animation
  38000. */
  38001. clone(): Animation;
  38002. /**
  38003. * Sets the key frames of the animation
  38004. * @param values The animation key frames to set
  38005. */
  38006. setKeys(values: Array<IAnimationKey>): void;
  38007. /**
  38008. * Serializes the animation to an object
  38009. * @returns Serialized object
  38010. */
  38011. serialize(): any;
  38012. /**
  38013. * Float animation type
  38014. */
  38015. static readonly ANIMATIONTYPE_FLOAT: number;
  38016. /**
  38017. * Vector3 animation type
  38018. */
  38019. static readonly ANIMATIONTYPE_VECTOR3: number;
  38020. /**
  38021. * Quaternion animation type
  38022. */
  38023. static readonly ANIMATIONTYPE_QUATERNION: number;
  38024. /**
  38025. * Matrix animation type
  38026. */
  38027. static readonly ANIMATIONTYPE_MATRIX: number;
  38028. /**
  38029. * Color3 animation type
  38030. */
  38031. static readonly ANIMATIONTYPE_COLOR3: number;
  38032. /**
  38033. * Color3 animation type
  38034. */
  38035. static readonly ANIMATIONTYPE_COLOR4: number;
  38036. /**
  38037. * Vector2 animation type
  38038. */
  38039. static readonly ANIMATIONTYPE_VECTOR2: number;
  38040. /**
  38041. * Size animation type
  38042. */
  38043. static readonly ANIMATIONTYPE_SIZE: number;
  38044. /**
  38045. * Relative Loop Mode
  38046. */
  38047. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38048. /**
  38049. * Cycle Loop Mode
  38050. */
  38051. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38052. /**
  38053. * Constant Loop Mode
  38054. */
  38055. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38056. /** @hidden */
  38057. static _UniversalLerp(left: any, right: any, amount: number): any;
  38058. /**
  38059. * Parses an animation object and creates an animation
  38060. * @param parsedAnimation Parsed animation object
  38061. * @returns Animation object
  38062. */
  38063. static Parse(parsedAnimation: any): Animation;
  38064. /**
  38065. * Appends the serialized animations from the source animations
  38066. * @param source Source containing the animations
  38067. * @param destination Target to store the animations
  38068. */
  38069. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38070. /**
  38071. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38072. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38073. * @param url defines the url to load from
  38074. * @returns a promise that will resolve to the new animation or an array of animations
  38075. */
  38076. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38077. /**
  38078. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38079. * @param snippetId defines the snippet to load
  38080. * @returns a promise that will resolve to the new animation or a new array of animations
  38081. */
  38082. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Interface containing an array of animations
  38088. */
  38089. export interface IAnimatable {
  38090. /**
  38091. * Array of animations
  38092. */
  38093. animations: Nullable<Array<Animation>>;
  38094. }
  38095. }
  38096. declare module BABYLON {
  38097. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38098. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38099. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38100. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38101. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38102. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38103. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38104. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38105. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38106. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38107. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38108. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38109. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38110. /**
  38111. * Decorator used to define property that can be serialized as reference to a camera
  38112. * @param sourceName defines the name of the property to decorate
  38113. */
  38114. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38115. /**
  38116. * Class used to help serialization objects
  38117. */
  38118. export class SerializationHelper {
  38119. /** @hidden */
  38120. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38121. /** @hidden */
  38122. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38123. /** @hidden */
  38124. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38125. /** @hidden */
  38126. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38127. /**
  38128. * Appends the serialized animations from the source animations
  38129. * @param source Source containing the animations
  38130. * @param destination Target to store the animations
  38131. */
  38132. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38133. /**
  38134. * Static function used to serialized a specific entity
  38135. * @param entity defines the entity to serialize
  38136. * @param serializationObject defines the optional target object where serialization data will be stored
  38137. * @returns a JSON compatible object representing the serialization of the entity
  38138. */
  38139. static Serialize<T>(entity: T, serializationObject?: any): any;
  38140. /**
  38141. * Creates a new entity from a serialization data object
  38142. * @param creationFunction defines a function used to instanciated the new entity
  38143. * @param source defines the source serialization data
  38144. * @param scene defines the hosting scene
  38145. * @param rootUrl defines the root url for resources
  38146. * @returns a new entity
  38147. */
  38148. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38149. /**
  38150. * Clones an object
  38151. * @param creationFunction defines the function used to instanciate the new object
  38152. * @param source defines the source object
  38153. * @returns the cloned object
  38154. */
  38155. static Clone<T>(creationFunction: () => T, source: T): T;
  38156. /**
  38157. * Instanciates a new object based on a source one (some data will be shared between both object)
  38158. * @param creationFunction defines the function used to instanciate the new object
  38159. * @param source defines the source object
  38160. * @returns the new object
  38161. */
  38162. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * This is the base class of all the camera used in the application.
  38168. * @see https://doc.babylonjs.com/features/cameras
  38169. */
  38170. export class Camera extends Node {
  38171. /** @hidden */
  38172. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38173. /**
  38174. * This is the default projection mode used by the cameras.
  38175. * It helps recreating a feeling of perspective and better appreciate depth.
  38176. * This is the best way to simulate real life cameras.
  38177. */
  38178. static readonly PERSPECTIVE_CAMERA: number;
  38179. /**
  38180. * This helps creating camera with an orthographic mode.
  38181. * 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.
  38182. */
  38183. static readonly ORTHOGRAPHIC_CAMERA: number;
  38184. /**
  38185. * This is the default FOV mode for perspective cameras.
  38186. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38187. */
  38188. static readonly FOVMODE_VERTICAL_FIXED: number;
  38189. /**
  38190. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38191. */
  38192. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38193. /**
  38194. * This specifies there is no need for a camera rig.
  38195. * Basically only one eye is rendered corresponding to the camera.
  38196. */
  38197. static readonly RIG_MODE_NONE: number;
  38198. /**
  38199. * Simulates a camera Rig with one blue eye and one red eye.
  38200. * This can be use with 3d blue and red glasses.
  38201. */
  38202. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38203. /**
  38204. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38205. */
  38206. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38207. /**
  38208. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38209. */
  38210. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38211. /**
  38212. * Defines that both eyes of the camera will be rendered over under each other.
  38213. */
  38214. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38215. /**
  38216. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38217. */
  38218. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38219. /**
  38220. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38221. */
  38222. static readonly RIG_MODE_VR: number;
  38223. /**
  38224. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38225. */
  38226. static readonly RIG_MODE_WEBVR: number;
  38227. /**
  38228. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38229. */
  38230. static readonly RIG_MODE_CUSTOM: number;
  38231. /**
  38232. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38233. */
  38234. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38235. /**
  38236. * Define the input manager associated with the camera.
  38237. */
  38238. inputs: CameraInputsManager<Camera>;
  38239. /** @hidden */
  38240. _position: Vector3;
  38241. /**
  38242. * Define the current local position of the camera in the scene
  38243. */
  38244. get position(): Vector3;
  38245. set position(newPosition: Vector3);
  38246. protected _upVector: Vector3;
  38247. /**
  38248. * The vector the camera should consider as up.
  38249. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38250. */
  38251. set upVector(vec: Vector3);
  38252. get upVector(): Vector3;
  38253. /**
  38254. * Define the current limit on the left side for an orthographic camera
  38255. * In scene unit
  38256. */
  38257. orthoLeft: Nullable<number>;
  38258. /**
  38259. * Define the current limit on the right side for an orthographic camera
  38260. * In scene unit
  38261. */
  38262. orthoRight: Nullable<number>;
  38263. /**
  38264. * Define the current limit on the bottom side for an orthographic camera
  38265. * In scene unit
  38266. */
  38267. orthoBottom: Nullable<number>;
  38268. /**
  38269. * Define the current limit on the top side for an orthographic camera
  38270. * In scene unit
  38271. */
  38272. orthoTop: Nullable<number>;
  38273. /**
  38274. * Field Of View is set in Radians. (default is 0.8)
  38275. */
  38276. fov: number;
  38277. /**
  38278. * Define the minimum distance the camera can see from.
  38279. * This is important to note that the depth buffer are not infinite and the closer it starts
  38280. * the more your scene might encounter depth fighting issue.
  38281. */
  38282. minZ: number;
  38283. /**
  38284. * Define the maximum distance the camera can see to.
  38285. * This is important to note that the depth buffer are not infinite and the further it end
  38286. * the more your scene might encounter depth fighting issue.
  38287. */
  38288. maxZ: number;
  38289. /**
  38290. * Define the default inertia of the camera.
  38291. * This helps giving a smooth feeling to the camera movement.
  38292. */
  38293. inertia: number;
  38294. /**
  38295. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38296. */
  38297. mode: number;
  38298. /**
  38299. * Define whether the camera is intermediate.
  38300. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38301. */
  38302. isIntermediate: boolean;
  38303. /**
  38304. * Define the viewport of the camera.
  38305. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38306. */
  38307. viewport: Viewport;
  38308. /**
  38309. * Restricts the camera to viewing objects with the same layerMask.
  38310. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38311. */
  38312. layerMask: number;
  38313. /**
  38314. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38315. */
  38316. fovMode: number;
  38317. /**
  38318. * Rig mode of the camera.
  38319. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38320. * This is normally controlled byt the camera themselves as internal use.
  38321. */
  38322. cameraRigMode: number;
  38323. /**
  38324. * Defines the distance between both "eyes" in case of a RIG
  38325. */
  38326. interaxialDistance: number;
  38327. /**
  38328. * Defines if stereoscopic rendering is done side by side or over under.
  38329. */
  38330. isStereoscopicSideBySide: boolean;
  38331. /**
  38332. * 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
  38333. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38334. * else in the scene. (Eg. security camera)
  38335. *
  38336. * 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)
  38337. */
  38338. customRenderTargets: RenderTargetTexture[];
  38339. /**
  38340. * When set, the camera will render to this render target instead of the default canvas
  38341. *
  38342. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38343. */
  38344. outputRenderTarget: Nullable<RenderTargetTexture>;
  38345. /**
  38346. * Observable triggered when the camera view matrix has changed.
  38347. */
  38348. onViewMatrixChangedObservable: Observable<Camera>;
  38349. /**
  38350. * Observable triggered when the camera Projection matrix has changed.
  38351. */
  38352. onProjectionMatrixChangedObservable: Observable<Camera>;
  38353. /**
  38354. * Observable triggered when the inputs have been processed.
  38355. */
  38356. onAfterCheckInputsObservable: Observable<Camera>;
  38357. /**
  38358. * Observable triggered when reset has been called and applied to the camera.
  38359. */
  38360. onRestoreStateObservable: Observable<Camera>;
  38361. /**
  38362. * Is this camera a part of a rig system?
  38363. */
  38364. isRigCamera: boolean;
  38365. /**
  38366. * If isRigCamera set to true this will be set with the parent camera.
  38367. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38368. */
  38369. rigParent?: Camera;
  38370. /** @hidden */
  38371. _cameraRigParams: any;
  38372. /** @hidden */
  38373. _rigCameras: Camera[];
  38374. /** @hidden */
  38375. _rigPostProcess: Nullable<PostProcess>;
  38376. protected _webvrViewMatrix: Matrix;
  38377. /** @hidden */
  38378. _skipRendering: boolean;
  38379. /** @hidden */
  38380. _projectionMatrix: Matrix;
  38381. /** @hidden */
  38382. _postProcesses: Nullable<PostProcess>[];
  38383. /** @hidden */
  38384. _activeMeshes: SmartArray<AbstractMesh>;
  38385. protected _globalPosition: Vector3;
  38386. /** @hidden */
  38387. _computedViewMatrix: Matrix;
  38388. private _doNotComputeProjectionMatrix;
  38389. private _transformMatrix;
  38390. private _frustumPlanes;
  38391. private _refreshFrustumPlanes;
  38392. private _storedFov;
  38393. private _stateStored;
  38394. /**
  38395. * Instantiates a new camera object.
  38396. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38397. * @see https://doc.babylonjs.com/features/cameras
  38398. * @param name Defines the name of the camera in the scene
  38399. * @param position Defines the position of the camera
  38400. * @param scene Defines the scene the camera belongs too
  38401. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38402. */
  38403. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38404. /**
  38405. * Store current camera state (fov, position, etc..)
  38406. * @returns the camera
  38407. */
  38408. storeState(): Camera;
  38409. /**
  38410. * Restores the camera state values if it has been stored. You must call storeState() first
  38411. */
  38412. protected _restoreStateValues(): boolean;
  38413. /**
  38414. * Restored camera state. You must call storeState() first.
  38415. * @returns true if restored and false otherwise
  38416. */
  38417. restoreState(): boolean;
  38418. /**
  38419. * Gets the class name of the camera.
  38420. * @returns the class name
  38421. */
  38422. getClassName(): string;
  38423. /** @hidden */
  38424. readonly _isCamera: boolean;
  38425. /**
  38426. * Gets a string representation of the camera useful for debug purpose.
  38427. * @param fullDetails Defines that a more verboe level of logging is required
  38428. * @returns the string representation
  38429. */
  38430. toString(fullDetails?: boolean): string;
  38431. /**
  38432. * Gets the current world space position of the camera.
  38433. */
  38434. get globalPosition(): Vector3;
  38435. /**
  38436. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38437. * @returns the active meshe list
  38438. */
  38439. getActiveMeshes(): SmartArray<AbstractMesh>;
  38440. /**
  38441. * Check whether a mesh is part of the current active mesh list of the camera
  38442. * @param mesh Defines the mesh to check
  38443. * @returns true if active, false otherwise
  38444. */
  38445. isActiveMesh(mesh: Mesh): boolean;
  38446. /**
  38447. * Is this camera ready to be used/rendered
  38448. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38449. * @return true if the camera is ready
  38450. */
  38451. isReady(completeCheck?: boolean): boolean;
  38452. /** @hidden */
  38453. _initCache(): void;
  38454. /** @hidden */
  38455. _updateCache(ignoreParentClass?: boolean): void;
  38456. /** @hidden */
  38457. _isSynchronized(): boolean;
  38458. /** @hidden */
  38459. _isSynchronizedViewMatrix(): boolean;
  38460. /** @hidden */
  38461. _isSynchronizedProjectionMatrix(): boolean;
  38462. /**
  38463. * Attach the input controls to a specific dom element to get the input from.
  38464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38465. */
  38466. attachControl(noPreventDefault?: boolean): void;
  38467. /**
  38468. * Attach the input controls to a specific dom element to get the input from.
  38469. * @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
  38470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38471. * BACK COMPAT SIGNATURE ONLY.
  38472. */
  38473. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38474. /**
  38475. * Detach the current controls from the specified dom element.
  38476. */
  38477. detachControl(): void;
  38478. /**
  38479. * Detach the current controls from the specified dom element.
  38480. * @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
  38481. */
  38482. detachControl(ignored: any): void;
  38483. /**
  38484. * Update the camera state according to the different inputs gathered during the frame.
  38485. */
  38486. update(): void;
  38487. /** @hidden */
  38488. _checkInputs(): void;
  38489. /** @hidden */
  38490. get rigCameras(): Camera[];
  38491. /**
  38492. * Gets the post process used by the rig cameras
  38493. */
  38494. get rigPostProcess(): Nullable<PostProcess>;
  38495. /**
  38496. * Internal, gets the first post process.
  38497. * @returns the first post process to be run on this camera.
  38498. */
  38499. _getFirstPostProcess(): Nullable<PostProcess>;
  38500. private _cascadePostProcessesToRigCams;
  38501. /**
  38502. * Attach a post process to the camera.
  38503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38504. * @param postProcess The post process to attach to the camera
  38505. * @param insertAt The position of the post process in case several of them are in use in the scene
  38506. * @returns the position the post process has been inserted at
  38507. */
  38508. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38509. /**
  38510. * Detach a post process to the camera.
  38511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38512. * @param postProcess The post process to detach from the camera
  38513. */
  38514. detachPostProcess(postProcess: PostProcess): void;
  38515. /**
  38516. * Gets the current world matrix of the camera
  38517. */
  38518. getWorldMatrix(): Matrix;
  38519. /** @hidden */
  38520. _getViewMatrix(): Matrix;
  38521. /**
  38522. * Gets the current view matrix of the camera.
  38523. * @param force forces the camera to recompute the matrix without looking at the cached state
  38524. * @returns the view matrix
  38525. */
  38526. getViewMatrix(force?: boolean): Matrix;
  38527. /**
  38528. * Freeze the projection matrix.
  38529. * It will prevent the cache check of the camera projection compute and can speed up perf
  38530. * if no parameter of the camera are meant to change
  38531. * @param projection Defines manually a projection if necessary
  38532. */
  38533. freezeProjectionMatrix(projection?: Matrix): void;
  38534. /**
  38535. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38536. */
  38537. unfreezeProjectionMatrix(): void;
  38538. /**
  38539. * Gets the current projection matrix of the camera.
  38540. * @param force forces the camera to recompute the matrix without looking at the cached state
  38541. * @returns the projection matrix
  38542. */
  38543. getProjectionMatrix(force?: boolean): Matrix;
  38544. /**
  38545. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38546. * @returns a Matrix
  38547. */
  38548. getTransformationMatrix(): Matrix;
  38549. private _updateFrustumPlanes;
  38550. /**
  38551. * Checks if a cullable object (mesh...) is in the camera frustum
  38552. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38553. * @param target The object to check
  38554. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38555. * @returns true if the object is in frustum otherwise false
  38556. */
  38557. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38558. /**
  38559. * Checks if a cullable object (mesh...) is in the camera frustum
  38560. * Unlike isInFrustum this checks the full bounding box
  38561. * @param target The object to check
  38562. * @returns true if the object is in frustum otherwise false
  38563. */
  38564. isCompletelyInFrustum(target: ICullable): boolean;
  38565. /**
  38566. * Gets a ray in the forward direction from the camera.
  38567. * @param length Defines the length of the ray to create
  38568. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38569. * @param origin Defines the start point of the ray which defaults to the camera position
  38570. * @returns the forward ray
  38571. */
  38572. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38573. /**
  38574. * Gets a ray in the forward direction from the camera.
  38575. * @param refRay the ray to (re)use when setting the values
  38576. * @param length Defines the length of the ray to create
  38577. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38578. * @param origin Defines the start point of the ray which defaults to the camera position
  38579. * @returns the forward ray
  38580. */
  38581. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38582. /**
  38583. * Releases resources associated with this node.
  38584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38586. */
  38587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38588. /** @hidden */
  38589. _isLeftCamera: boolean;
  38590. /**
  38591. * Gets the left camera of a rig setup in case of Rigged Camera
  38592. */
  38593. get isLeftCamera(): boolean;
  38594. /** @hidden */
  38595. _isRightCamera: boolean;
  38596. /**
  38597. * Gets the right camera of a rig setup in case of Rigged Camera
  38598. */
  38599. get isRightCamera(): boolean;
  38600. /**
  38601. * Gets the left camera of a rig setup in case of Rigged Camera
  38602. */
  38603. get leftCamera(): Nullable<FreeCamera>;
  38604. /**
  38605. * Gets the right camera of a rig setup in case of Rigged Camera
  38606. */
  38607. get rightCamera(): Nullable<FreeCamera>;
  38608. /**
  38609. * Gets the left camera target of a rig setup in case of Rigged Camera
  38610. * @returns the target position
  38611. */
  38612. getLeftTarget(): Nullable<Vector3>;
  38613. /**
  38614. * Gets the right camera target of a rig setup in case of Rigged Camera
  38615. * @returns the target position
  38616. */
  38617. getRightTarget(): Nullable<Vector3>;
  38618. /**
  38619. * @hidden
  38620. */
  38621. setCameraRigMode(mode: number, rigParams: any): void;
  38622. /** @hidden */
  38623. static _setStereoscopicRigMode(camera: Camera): void;
  38624. /** @hidden */
  38625. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38626. /** @hidden */
  38627. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38628. /** @hidden */
  38629. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38630. /** @hidden */
  38631. _getVRProjectionMatrix(): Matrix;
  38632. protected _updateCameraRotationMatrix(): void;
  38633. protected _updateWebVRCameraRotationMatrix(): void;
  38634. /**
  38635. * This function MUST be overwritten by the different WebVR cameras available.
  38636. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38637. * @hidden
  38638. */
  38639. _getWebVRProjectionMatrix(): Matrix;
  38640. /**
  38641. * This function MUST be overwritten by the different WebVR cameras available.
  38642. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38643. * @hidden
  38644. */
  38645. _getWebVRViewMatrix(): Matrix;
  38646. /** @hidden */
  38647. setCameraRigParameter(name: string, value: any): void;
  38648. /**
  38649. * needs to be overridden by children so sub has required properties to be copied
  38650. * @hidden
  38651. */
  38652. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38653. /**
  38654. * May need to be overridden by children
  38655. * @hidden
  38656. */
  38657. _updateRigCameras(): void;
  38658. /** @hidden */
  38659. _setupInputs(): void;
  38660. /**
  38661. * Serialiaze the camera setup to a json representation
  38662. * @returns the JSON representation
  38663. */
  38664. serialize(): any;
  38665. /**
  38666. * Clones the current camera.
  38667. * @param name The cloned camera name
  38668. * @returns the cloned camera
  38669. */
  38670. clone(name: string): Camera;
  38671. /**
  38672. * Gets the direction of the camera relative to a given local axis.
  38673. * @param localAxis Defines the reference axis to provide a relative direction.
  38674. * @return the direction
  38675. */
  38676. getDirection(localAxis: Vector3): Vector3;
  38677. /**
  38678. * Returns the current camera absolute rotation
  38679. */
  38680. get absoluteRotation(): Quaternion;
  38681. /**
  38682. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38683. * @param localAxis Defines the reference axis to provide a relative direction.
  38684. * @param result Defines the vector to store the result in
  38685. */
  38686. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38687. /**
  38688. * Gets a camera constructor for a given camera type
  38689. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38690. * @param name The name of the camera the result will be able to instantiate
  38691. * @param scene The scene the result will construct the camera in
  38692. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38693. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38694. * @returns a factory method to construct the camera
  38695. */
  38696. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38697. /**
  38698. * Compute the world matrix of the camera.
  38699. * @returns the camera world matrix
  38700. */
  38701. computeWorldMatrix(): Matrix;
  38702. /**
  38703. * Parse a JSON and creates the camera from the parsed information
  38704. * @param parsedCamera The JSON to parse
  38705. * @param scene The scene to instantiate the camera in
  38706. * @returns the newly constructed camera
  38707. */
  38708. static Parse(parsedCamera: any, scene: Scene): Camera;
  38709. }
  38710. }
  38711. declare module BABYLON {
  38712. /**
  38713. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38714. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38715. */
  38716. export class PostProcessManager {
  38717. private _scene;
  38718. private _indexBuffer;
  38719. private _vertexBuffers;
  38720. /**
  38721. * Creates a new instance PostProcess
  38722. * @param scene The scene that the post process is associated with.
  38723. */
  38724. constructor(scene: Scene);
  38725. private _prepareBuffers;
  38726. private _buildIndexBuffer;
  38727. /**
  38728. * Rebuilds the vertex buffers of the manager.
  38729. * @hidden
  38730. */
  38731. _rebuild(): void;
  38732. /**
  38733. * Prepares a frame to be run through a post process.
  38734. * @param sourceTexture The input texture to the post processes. (default: null)
  38735. * @param postProcesses An array of post processes to be run. (default: null)
  38736. * @returns True if the post processes were able to be run.
  38737. * @hidden
  38738. */
  38739. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38740. /**
  38741. * Manually render a set of post processes to a texture.
  38742. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38743. * @param postProcesses An array of post processes to be run.
  38744. * @param targetTexture The target texture to render to.
  38745. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38746. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38747. * @param lodLevel defines which lod of the texture to render to
  38748. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38749. */
  38750. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38751. /**
  38752. * Finalize the result of the output of the postprocesses.
  38753. * @param doNotPresent If true the result will not be displayed to the screen.
  38754. * @param targetTexture The target texture to render to.
  38755. * @param faceIndex The index of the face to bind the target texture to.
  38756. * @param postProcesses The array of post processes to render.
  38757. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38758. * @hidden
  38759. */
  38760. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38761. /**
  38762. * Disposes of the post process manager.
  38763. */
  38764. dispose(): void;
  38765. }
  38766. }
  38767. declare module BABYLON {
  38768. /**
  38769. * This Helps creating a texture that will be created from a camera in your scene.
  38770. * It is basically a dynamic texture that could be used to create special effects for instance.
  38771. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38772. */
  38773. export class RenderTargetTexture extends Texture {
  38774. /**
  38775. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38776. */
  38777. static readonly REFRESHRATE_RENDER_ONCE: number;
  38778. /**
  38779. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38780. */
  38781. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38782. /**
  38783. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38784. * the central point of your effect and can save a lot of performances.
  38785. */
  38786. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38787. /**
  38788. * Use this predicate to dynamically define the list of mesh you want to render.
  38789. * If set, the renderList property will be overwritten.
  38790. */
  38791. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38792. private _renderList;
  38793. /**
  38794. * Use this list to define the list of mesh you want to render.
  38795. */
  38796. get renderList(): Nullable<Array<AbstractMesh>>;
  38797. set renderList(value: Nullable<Array<AbstractMesh>>);
  38798. /**
  38799. * Use this function to overload the renderList array at rendering time.
  38800. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38801. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38802. * the cube (if the RTT is a cube, else layerOrFace=0).
  38803. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38804. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38805. * hold dummy elements!
  38806. */
  38807. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38808. private _hookArray;
  38809. /**
  38810. * Define if particles should be rendered in your texture.
  38811. */
  38812. renderParticles: boolean;
  38813. /**
  38814. * Define if sprites should be rendered in your texture.
  38815. */
  38816. renderSprites: boolean;
  38817. /**
  38818. * Define the camera used to render the texture.
  38819. */
  38820. activeCamera: Nullable<Camera>;
  38821. /**
  38822. * Override the mesh isReady function with your own one.
  38823. */
  38824. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38825. /**
  38826. * Override the render function of the texture with your own one.
  38827. */
  38828. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38829. /**
  38830. * Define if camera post processes should be use while rendering the texture.
  38831. */
  38832. useCameraPostProcesses: boolean;
  38833. /**
  38834. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38835. */
  38836. ignoreCameraViewport: boolean;
  38837. private _postProcessManager;
  38838. /**
  38839. * Post-processes for this render target
  38840. */
  38841. get postProcesses(): PostProcess[];
  38842. private _postProcesses;
  38843. private _resizeObserver;
  38844. private get _prePassEnabled();
  38845. /**
  38846. * An event triggered when the texture is unbind.
  38847. */
  38848. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38849. /**
  38850. * An event triggered when the texture is unbind.
  38851. */
  38852. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38853. private _onAfterUnbindObserver;
  38854. /**
  38855. * Set a after unbind callback in the texture.
  38856. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38857. */
  38858. set onAfterUnbind(callback: () => void);
  38859. /**
  38860. * An event triggered before rendering the texture
  38861. */
  38862. onBeforeRenderObservable: Observable<number>;
  38863. private _onBeforeRenderObserver;
  38864. /**
  38865. * Set a before render callback in the texture.
  38866. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38867. */
  38868. set onBeforeRender(callback: (faceIndex: number) => void);
  38869. /**
  38870. * An event triggered after rendering the texture
  38871. */
  38872. onAfterRenderObservable: Observable<number>;
  38873. private _onAfterRenderObserver;
  38874. /**
  38875. * Set a after render callback in the texture.
  38876. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38877. */
  38878. set onAfterRender(callback: (faceIndex: number) => void);
  38879. /**
  38880. * An event triggered after the texture clear
  38881. */
  38882. onClearObservable: Observable<Engine>;
  38883. private _onClearObserver;
  38884. /**
  38885. * Set a clear callback in the texture.
  38886. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38887. */
  38888. set onClear(callback: (Engine: Engine) => void);
  38889. /**
  38890. * An event triggered when the texture is resized.
  38891. */
  38892. onResizeObservable: Observable<RenderTargetTexture>;
  38893. /**
  38894. * Define the clear color of the Render Target if it should be different from the scene.
  38895. */
  38896. clearColor: Color4;
  38897. protected _size: number | {
  38898. width: number;
  38899. height: number;
  38900. layers?: number;
  38901. };
  38902. protected _initialSizeParameter: number | {
  38903. width: number;
  38904. height: number;
  38905. } | {
  38906. ratio: number;
  38907. };
  38908. protected _sizeRatio: Nullable<number>;
  38909. /** @hidden */
  38910. _generateMipMaps: boolean;
  38911. protected _renderingManager: RenderingManager;
  38912. /** @hidden */
  38913. _waitingRenderList?: string[];
  38914. protected _doNotChangeAspectRatio: boolean;
  38915. protected _currentRefreshId: number;
  38916. protected _refreshRate: number;
  38917. protected _textureMatrix: Matrix;
  38918. protected _samples: number;
  38919. protected _renderTargetOptions: RenderTargetCreationOptions;
  38920. /**
  38921. * Gets render target creation options that were used.
  38922. */
  38923. get renderTargetOptions(): RenderTargetCreationOptions;
  38924. protected _onRatioRescale(): void;
  38925. /**
  38926. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38927. * It must define where the camera used to render the texture is set
  38928. */
  38929. boundingBoxPosition: Vector3;
  38930. private _boundingBoxSize;
  38931. /**
  38932. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38933. * When defined, the cubemap will switch to local mode
  38934. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38935. * @example https://www.babylonjs-playground.com/#RNASML
  38936. */
  38937. set boundingBoxSize(value: Vector3);
  38938. get boundingBoxSize(): Vector3;
  38939. /**
  38940. * In case the RTT has been created with a depth texture, get the associated
  38941. * depth texture.
  38942. * Otherwise, return null.
  38943. */
  38944. get depthStencilTexture(): Nullable<InternalTexture>;
  38945. /**
  38946. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38947. * or used a shadow, depth texture...
  38948. * @param name The friendly name of the texture
  38949. * @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)
  38950. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38951. * @param generateMipMaps True if mip maps need to be generated after render.
  38952. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38953. * @param type The type of the buffer in the RTT (int, half float, float...)
  38954. * @param isCube True if a cube texture needs to be created
  38955. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38956. * @param generateDepthBuffer True to generate a depth buffer
  38957. * @param generateStencilBuffer True to generate a stencil buffer
  38958. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38959. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38960. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38961. * @param samples sample count to use when creating the RTT
  38962. */
  38963. constructor(name: string, size: number | {
  38964. width: number;
  38965. height: number;
  38966. layers?: number;
  38967. } | {
  38968. ratio: number;
  38969. }, 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);
  38970. /**
  38971. * Creates a depth stencil texture.
  38972. * This is only available in WebGL 2 or with the depth texture extension available.
  38973. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38974. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38975. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38976. * @param samples sample count of the depth/stencil texture
  38977. */
  38978. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38979. private _processSizeParameter;
  38980. /**
  38981. * Define the number of samples to use in case of MSAA.
  38982. * It defaults to one meaning no MSAA has been enabled.
  38983. */
  38984. get samples(): number;
  38985. set samples(value: number);
  38986. /**
  38987. * Resets the refresh counter of the texture and start bak from scratch.
  38988. * Could be useful to regenerate the texture if it is setup to render only once.
  38989. */
  38990. resetRefreshCounter(): void;
  38991. /**
  38992. * Define the refresh rate of the texture or the rendering frequency.
  38993. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38994. */
  38995. get refreshRate(): number;
  38996. set refreshRate(value: number);
  38997. /**
  38998. * Adds a post process to the render target rendering passes.
  38999. * @param postProcess define the post process to add
  39000. */
  39001. addPostProcess(postProcess: PostProcess): void;
  39002. /**
  39003. * Clear all the post processes attached to the render target
  39004. * @param dispose define if the cleared post processes should also be disposed (false by default)
  39005. */
  39006. clearPostProcesses(dispose?: boolean): void;
  39007. /**
  39008. * Remove one of the post process from the list of attached post processes to the texture
  39009. * @param postProcess define the post process to remove from the list
  39010. */
  39011. removePostProcess(postProcess: PostProcess): void;
  39012. /** @hidden */
  39013. _shouldRender(): boolean;
  39014. /**
  39015. * Gets the actual render size of the texture.
  39016. * @returns the width of the render size
  39017. */
  39018. getRenderSize(): number;
  39019. /**
  39020. * Gets the actual render width of the texture.
  39021. * @returns the width of the render size
  39022. */
  39023. getRenderWidth(): number;
  39024. /**
  39025. * Gets the actual render height of the texture.
  39026. * @returns the height of the render size
  39027. */
  39028. getRenderHeight(): number;
  39029. /**
  39030. * Gets the actual number of layers of the texture.
  39031. * @returns the number of layers
  39032. */
  39033. getRenderLayers(): number;
  39034. /**
  39035. * Get if the texture can be rescaled or not.
  39036. */
  39037. get canRescale(): boolean;
  39038. /**
  39039. * Resize the texture using a ratio.
  39040. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39041. */
  39042. scale(ratio: number): void;
  39043. /**
  39044. * Get the texture reflection matrix used to rotate/transform the reflection.
  39045. * @returns the reflection matrix
  39046. */
  39047. getReflectionTextureMatrix(): Matrix;
  39048. /**
  39049. * Resize the texture to a new desired size.
  39050. * Be careful as it will recreate all the data in the new texture.
  39051. * @param size Define the new size. It can be:
  39052. * - a number for squared texture,
  39053. * - an object containing { width: number, height: number }
  39054. * - or an object containing a ratio { ratio: number }
  39055. */
  39056. resize(size: number | {
  39057. width: number;
  39058. height: number;
  39059. } | {
  39060. ratio: number;
  39061. }): void;
  39062. private _defaultRenderListPrepared;
  39063. /**
  39064. * Renders all the objects from the render list into the texture.
  39065. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39066. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39067. */
  39068. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39069. private _bestReflectionRenderTargetDimension;
  39070. private _prepareRenderingManager;
  39071. /**
  39072. * @hidden
  39073. * @param faceIndex face index to bind to if this is a cubetexture
  39074. * @param layer defines the index of the texture to bind in the array
  39075. */
  39076. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39077. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39078. /**
  39079. * @hidden
  39080. */
  39081. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39082. private renderToTarget;
  39083. /**
  39084. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39085. * This allowed control for front to back rendering or reversely depending of the special needs.
  39086. *
  39087. * @param renderingGroupId The rendering group id corresponding to its index
  39088. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39089. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39090. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39091. */
  39092. 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;
  39093. /**
  39094. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39095. *
  39096. * @param renderingGroupId The rendering group id corresponding to its index
  39097. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39098. */
  39099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39100. /**
  39101. * Clones the texture.
  39102. * @returns the cloned texture
  39103. */
  39104. clone(): RenderTargetTexture;
  39105. /**
  39106. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39107. * @returns The JSON representation of the texture
  39108. */
  39109. serialize(): any;
  39110. /**
  39111. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39112. */
  39113. disposeFramebufferObjects(): void;
  39114. /**
  39115. * Dispose the texture and release its associated resources.
  39116. */
  39117. dispose(): void;
  39118. /** @hidden */
  39119. _rebuild(): void;
  39120. /**
  39121. * Clear the info related to rendering groups preventing retention point in material dispose.
  39122. */
  39123. freeRenderingGroups(): void;
  39124. /**
  39125. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39126. * @returns the view count
  39127. */
  39128. getViewCount(): number;
  39129. }
  39130. }
  39131. declare module BABYLON {
  39132. /**
  39133. * Options to be used when creating an effect.
  39134. */
  39135. export interface IEffectCreationOptions {
  39136. /**
  39137. * Attributes that will be used in the shader.
  39138. */
  39139. attributes: string[];
  39140. /**
  39141. * Uniform variable names that will be set in the shader.
  39142. */
  39143. uniformsNames: string[];
  39144. /**
  39145. * Uniform buffer variable names that will be set in the shader.
  39146. */
  39147. uniformBuffersNames: string[];
  39148. /**
  39149. * Sampler texture variable names that will be set in the shader.
  39150. */
  39151. samplers: string[];
  39152. /**
  39153. * Define statements that will be set in the shader.
  39154. */
  39155. defines: any;
  39156. /**
  39157. * Possible fallbacks for this effect to improve performance when needed.
  39158. */
  39159. fallbacks: Nullable<IEffectFallbacks>;
  39160. /**
  39161. * Callback that will be called when the shader is compiled.
  39162. */
  39163. onCompiled: Nullable<(effect: Effect) => void>;
  39164. /**
  39165. * Callback that will be called if an error occurs during shader compilation.
  39166. */
  39167. onError: Nullable<(effect: Effect, errors: string) => void>;
  39168. /**
  39169. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39170. */
  39171. indexParameters?: any;
  39172. /**
  39173. * Max number of lights that can be used in the shader.
  39174. */
  39175. maxSimultaneousLights?: number;
  39176. /**
  39177. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39178. */
  39179. transformFeedbackVaryings?: Nullable<string[]>;
  39180. /**
  39181. * 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
  39182. */
  39183. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39184. /**
  39185. * Is this effect rendering to several color attachments ?
  39186. */
  39187. multiTarget?: boolean;
  39188. }
  39189. /**
  39190. * Effect containing vertex and fragment shader that can be executed on an object.
  39191. */
  39192. export class Effect implements IDisposable {
  39193. /**
  39194. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39195. */
  39196. static ShadersRepository: string;
  39197. /**
  39198. * Enable logging of the shader code when a compilation error occurs
  39199. */
  39200. static LogShaderCodeOnCompilationError: boolean;
  39201. /**
  39202. * Name of the effect.
  39203. */
  39204. name: any;
  39205. /**
  39206. * String container all the define statements that should be set on the shader.
  39207. */
  39208. defines: string;
  39209. /**
  39210. * Callback that will be called when the shader is compiled.
  39211. */
  39212. onCompiled: Nullable<(effect: Effect) => void>;
  39213. /**
  39214. * Callback that will be called if an error occurs during shader compilation.
  39215. */
  39216. onError: Nullable<(effect: Effect, errors: string) => void>;
  39217. /**
  39218. * Callback that will be called when effect is bound.
  39219. */
  39220. onBind: Nullable<(effect: Effect) => void>;
  39221. /**
  39222. * Unique ID of the effect.
  39223. */
  39224. uniqueId: number;
  39225. /**
  39226. * Observable that will be called when the shader is compiled.
  39227. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39228. */
  39229. onCompileObservable: Observable<Effect>;
  39230. /**
  39231. * Observable that will be called if an error occurs during shader compilation.
  39232. */
  39233. onErrorObservable: Observable<Effect>;
  39234. /** @hidden */
  39235. _onBindObservable: Nullable<Observable<Effect>>;
  39236. /**
  39237. * @hidden
  39238. * Specifies if the effect was previously ready
  39239. */
  39240. _wasPreviouslyReady: boolean;
  39241. /**
  39242. * Observable that will be called when effect is bound.
  39243. */
  39244. get onBindObservable(): Observable<Effect>;
  39245. /** @hidden */
  39246. _bonesComputationForcedToCPU: boolean;
  39247. /** @hidden */
  39248. _uniformBuffersNames: {
  39249. [key: string]: number;
  39250. };
  39251. /** @hidden */
  39252. _samplerList: string[];
  39253. /** @hidden */
  39254. _multiTarget: boolean;
  39255. private static _uniqueIdSeed;
  39256. private _engine;
  39257. private _uniformBuffersNamesList;
  39258. private _uniformsNames;
  39259. private _samplers;
  39260. private _isReady;
  39261. private _compilationError;
  39262. private _allFallbacksProcessed;
  39263. private _attributesNames;
  39264. private _attributes;
  39265. private _attributeLocationByName;
  39266. private _uniforms;
  39267. /**
  39268. * Key for the effect.
  39269. * @hidden
  39270. */
  39271. _key: string;
  39272. private _indexParameters;
  39273. private _fallbacks;
  39274. private _vertexSourceCodeOverride;
  39275. private _fragmentSourceCodeOverride;
  39276. private _transformFeedbackVaryings;
  39277. /**
  39278. * Compiled shader to webGL program.
  39279. * @hidden
  39280. */
  39281. _pipelineContext: Nullable<IPipelineContext>;
  39282. /** @hidden */
  39283. _vertexSourceCode: string;
  39284. /** @hidden */
  39285. _fragmentSourceCode: string;
  39286. /** @hidden */
  39287. private _rawVertexSourceCode;
  39288. /** @hidden */
  39289. private _rawFragmentSourceCode;
  39290. private static _baseCache;
  39291. private _processingContext;
  39292. /**
  39293. * Instantiates an effect.
  39294. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39295. * @param baseName Name of the effect.
  39296. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39297. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39298. * @param samplers List of sampler variables that will be passed to the shader.
  39299. * @param engine Engine to be used to render the effect
  39300. * @param defines Define statements to be added to the shader.
  39301. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39302. * @param onCompiled Callback that will be called when the shader is compiled.
  39303. * @param onError Callback that will be called if an error occurs during shader compilation.
  39304. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39305. * @param key Effect Key identifying uniquely compiled shader variants
  39306. */
  39307. 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);
  39308. private _useFinalCode;
  39309. /**
  39310. * Unique key for this effect
  39311. */
  39312. get key(): string;
  39313. /**
  39314. * If the effect has been compiled and prepared.
  39315. * @returns if the effect is compiled and prepared.
  39316. */
  39317. isReady(): boolean;
  39318. private _isReadyInternal;
  39319. /**
  39320. * The engine the effect was initialized with.
  39321. * @returns the engine.
  39322. */
  39323. getEngine(): Engine;
  39324. /**
  39325. * The pipeline context for this effect
  39326. * @returns the associated pipeline context
  39327. */
  39328. getPipelineContext(): Nullable<IPipelineContext>;
  39329. /**
  39330. * The set of names of attribute variables for the shader.
  39331. * @returns An array of attribute names.
  39332. */
  39333. getAttributesNames(): string[];
  39334. /**
  39335. * Returns the attribute at the given index.
  39336. * @param index The index of the attribute.
  39337. * @returns The location of the attribute.
  39338. */
  39339. getAttributeLocation(index: number): number;
  39340. /**
  39341. * Returns the attribute based on the name of the variable.
  39342. * @param name of the attribute to look up.
  39343. * @returns the attribute location.
  39344. */
  39345. getAttributeLocationByName(name: string): number;
  39346. /**
  39347. * The number of attributes.
  39348. * @returns the number of attributes.
  39349. */
  39350. getAttributesCount(): number;
  39351. /**
  39352. * Gets the index of a uniform variable.
  39353. * @param uniformName of the uniform to look up.
  39354. * @returns the index.
  39355. */
  39356. getUniformIndex(uniformName: string): number;
  39357. /**
  39358. * Returns the attribute based on the name of the variable.
  39359. * @param uniformName of the uniform to look up.
  39360. * @returns the location of the uniform.
  39361. */
  39362. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39363. /**
  39364. * Returns an array of sampler variable names
  39365. * @returns The array of sampler variable names.
  39366. */
  39367. getSamplers(): string[];
  39368. /**
  39369. * Returns an array of uniform variable names
  39370. * @returns The array of uniform variable names.
  39371. */
  39372. getUniformNames(): string[];
  39373. /**
  39374. * Returns an array of uniform buffer variable names
  39375. * @returns The array of uniform buffer variable names.
  39376. */
  39377. getUniformBuffersNames(): string[];
  39378. /**
  39379. * Returns the index parameters used to create the effect
  39380. * @returns The index parameters object
  39381. */
  39382. getIndexParameters(): any;
  39383. /**
  39384. * The error from the last compilation.
  39385. * @returns the error string.
  39386. */
  39387. getCompilationError(): string;
  39388. /**
  39389. * Gets a boolean indicating that all fallbacks were used during compilation
  39390. * @returns true if all fallbacks were used
  39391. */
  39392. allFallbacksProcessed(): boolean;
  39393. /**
  39394. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39395. * @param func The callback to be used.
  39396. */
  39397. executeWhenCompiled(func: (effect: Effect) => void): void;
  39398. private _checkIsReady;
  39399. private _loadShader;
  39400. /**
  39401. * Gets the vertex shader source code of this effect
  39402. */
  39403. get vertexSourceCode(): string;
  39404. /**
  39405. * Gets the fragment shader source code of this effect
  39406. */
  39407. get fragmentSourceCode(): string;
  39408. /**
  39409. * Gets the vertex shader source code before it has been processed by the preprocessor
  39410. */
  39411. get rawVertexSourceCode(): string;
  39412. /**
  39413. * Gets the fragment shader source code before it has been processed by the preprocessor
  39414. */
  39415. get rawFragmentSourceCode(): string;
  39416. /**
  39417. * Recompiles the webGL program
  39418. * @param vertexSourceCode The source code for the vertex shader.
  39419. * @param fragmentSourceCode The source code for the fragment shader.
  39420. * @param onCompiled Callback called when completed.
  39421. * @param onError Callback called on error.
  39422. * @hidden
  39423. */
  39424. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39425. /**
  39426. * Prepares the effect
  39427. * @hidden
  39428. */
  39429. _prepareEffect(): void;
  39430. private _getShaderCodeAndErrorLine;
  39431. private _processCompilationErrors;
  39432. /**
  39433. * Checks if the effect is supported. (Must be called after compilation)
  39434. */
  39435. get isSupported(): boolean;
  39436. /**
  39437. * Binds a texture to the engine to be used as output of the shader.
  39438. * @param channel Name of the output variable.
  39439. * @param texture Texture to bind.
  39440. * @hidden
  39441. */
  39442. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39443. /**
  39444. * Sets a texture on the engine to be used in the shader.
  39445. * @param channel Name of the sampler variable.
  39446. * @param texture Texture to set.
  39447. */
  39448. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39449. /**
  39450. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39451. * @param channel Name of the sampler variable.
  39452. * @param texture Texture to set.
  39453. */
  39454. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39455. /**
  39456. * Sets an array of textures on the engine to be used in the shader.
  39457. * @param channel Name of the variable.
  39458. * @param textures Textures to set.
  39459. */
  39460. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39461. /**
  39462. * 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)
  39463. * @param channel Name of the sampler variable.
  39464. * @param postProcess Post process to get the input texture from.
  39465. */
  39466. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39467. /**
  39468. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39469. * 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)
  39470. * @param channel Name of the sampler variable.
  39471. * @param postProcess Post process to get the output texture from.
  39472. */
  39473. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39474. /**
  39475. * Binds a buffer to a uniform.
  39476. * @param buffer Buffer to bind.
  39477. * @param name Name of the uniform variable to bind to.
  39478. */
  39479. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39480. /**
  39481. * Binds block to a uniform.
  39482. * @param blockName Name of the block to bind.
  39483. * @param index Index to bind.
  39484. */
  39485. bindUniformBlock(blockName: string, index: number): void;
  39486. /**
  39487. * Sets an integer value on a uniform variable.
  39488. * @param uniformName Name of the variable.
  39489. * @param value Value to be set.
  39490. * @returns this effect.
  39491. */
  39492. setInt(uniformName: string, value: number): Effect;
  39493. /**
  39494. * Sets an int2 value on a uniform variable.
  39495. * @param uniformName Name of the variable.
  39496. * @param x First int in int2.
  39497. * @param y Second int in int2.
  39498. * @returns this effect.
  39499. */
  39500. setInt2(uniformName: string, x: number, y: number): Effect;
  39501. /**
  39502. * Sets an int3 value on a uniform variable.
  39503. * @param uniformName Name of the variable.
  39504. * @param x First int in int3.
  39505. * @param y Second int in int3.
  39506. * @param z Third int in int3.
  39507. * @returns this effect.
  39508. */
  39509. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39510. /**
  39511. * Sets an int4 value on a uniform variable.
  39512. * @param uniformName Name of the variable.
  39513. * @param x First int in int4.
  39514. * @param y Second int in int4.
  39515. * @param z Third int in int4.
  39516. * @param w Fourth int in int4.
  39517. * @returns this effect.
  39518. */
  39519. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39520. /**
  39521. * Sets an int array on a uniform variable.
  39522. * @param uniformName Name of the variable.
  39523. * @param array array to be set.
  39524. * @returns this effect.
  39525. */
  39526. setIntArray(uniformName: string, array: Int32Array): Effect;
  39527. /**
  39528. * 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)
  39529. * @param uniformName Name of the variable.
  39530. * @param array array to be set.
  39531. * @returns this effect.
  39532. */
  39533. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39534. /**
  39535. * 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)
  39536. * @param uniformName Name of the variable.
  39537. * @param array array to be set.
  39538. * @returns this effect.
  39539. */
  39540. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39541. /**
  39542. * 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)
  39543. * @param uniformName Name of the variable.
  39544. * @param array array to be set.
  39545. * @returns this effect.
  39546. */
  39547. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39548. /**
  39549. * Sets an float array on a uniform variable.
  39550. * @param uniformName Name of the variable.
  39551. * @param array array to be set.
  39552. * @returns this effect.
  39553. */
  39554. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39555. /**
  39556. * 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)
  39557. * @param uniformName Name of the variable.
  39558. * @param array array to be set.
  39559. * @returns this effect.
  39560. */
  39561. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39562. /**
  39563. * 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)
  39564. * @param uniformName Name of the variable.
  39565. * @param array array to be set.
  39566. * @returns this effect.
  39567. */
  39568. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39569. /**
  39570. * 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)
  39571. * @param uniformName Name of the variable.
  39572. * @param array array to be set.
  39573. * @returns this effect.
  39574. */
  39575. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39576. /**
  39577. * Sets an array on a uniform variable.
  39578. * @param uniformName Name of the variable.
  39579. * @param array array to be set.
  39580. * @returns this effect.
  39581. */
  39582. setArray(uniformName: string, array: number[]): Effect;
  39583. /**
  39584. * 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)
  39585. * @param uniformName Name of the variable.
  39586. * @param array array to be set.
  39587. * @returns this effect.
  39588. */
  39589. setArray2(uniformName: string, array: number[]): Effect;
  39590. /**
  39591. * 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)
  39592. * @param uniformName Name of the variable.
  39593. * @param array array to be set.
  39594. * @returns this effect.
  39595. */
  39596. setArray3(uniformName: string, array: number[]): Effect;
  39597. /**
  39598. * 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)
  39599. * @param uniformName Name of the variable.
  39600. * @param array array to be set.
  39601. * @returns this effect.
  39602. */
  39603. setArray4(uniformName: string, array: number[]): Effect;
  39604. /**
  39605. * Sets matrices on a uniform variable.
  39606. * @param uniformName Name of the variable.
  39607. * @param matrices matrices to be set.
  39608. * @returns this effect.
  39609. */
  39610. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39611. /**
  39612. * Sets matrix on a uniform variable.
  39613. * @param uniformName Name of the variable.
  39614. * @param matrix matrix to be set.
  39615. * @returns this effect.
  39616. */
  39617. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39618. /**
  39619. * 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)
  39620. * @param uniformName Name of the variable.
  39621. * @param matrix matrix to be set.
  39622. * @returns this effect.
  39623. */
  39624. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39625. /**
  39626. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39627. * @param uniformName Name of the variable.
  39628. * @param matrix matrix to be set.
  39629. * @returns this effect.
  39630. */
  39631. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39632. /**
  39633. * Sets a float on a uniform variable.
  39634. * @param uniformName Name of the variable.
  39635. * @param value value to be set.
  39636. * @returns this effect.
  39637. */
  39638. setFloat(uniformName: string, value: number): Effect;
  39639. /**
  39640. * Sets a boolean on a uniform variable.
  39641. * @param uniformName Name of the variable.
  39642. * @param bool value to be set.
  39643. * @returns this effect.
  39644. */
  39645. setBool(uniformName: string, bool: boolean): Effect;
  39646. /**
  39647. * Sets a Vector2 on a uniform variable.
  39648. * @param uniformName Name of the variable.
  39649. * @param vector2 vector2 to be set.
  39650. * @returns this effect.
  39651. */
  39652. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39653. /**
  39654. * Sets a float2 on a uniform variable.
  39655. * @param uniformName Name of the variable.
  39656. * @param x First float in float2.
  39657. * @param y Second float in float2.
  39658. * @returns this effect.
  39659. */
  39660. setFloat2(uniformName: string, x: number, y: number): Effect;
  39661. /**
  39662. * Sets a Vector3 on a uniform variable.
  39663. * @param uniformName Name of the variable.
  39664. * @param vector3 Value to be set.
  39665. * @returns this effect.
  39666. */
  39667. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39668. /**
  39669. * Sets a float3 on a uniform variable.
  39670. * @param uniformName Name of the variable.
  39671. * @param x First float in float3.
  39672. * @param y Second float in float3.
  39673. * @param z Third float in float3.
  39674. * @returns this effect.
  39675. */
  39676. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39677. /**
  39678. * Sets a Vector4 on a uniform variable.
  39679. * @param uniformName Name of the variable.
  39680. * @param vector4 Value to be set.
  39681. * @returns this effect.
  39682. */
  39683. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39684. /**
  39685. * Sets a float4 on a uniform variable.
  39686. * @param uniformName Name of the variable.
  39687. * @param x First float in float4.
  39688. * @param y Second float in float4.
  39689. * @param z Third float in float4.
  39690. * @param w Fourth float in float4.
  39691. * @returns this effect.
  39692. */
  39693. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39694. /**
  39695. * Sets a Color3 on a uniform variable.
  39696. * @param uniformName Name of the variable.
  39697. * @param color3 Value to be set.
  39698. * @returns this effect.
  39699. */
  39700. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39701. /**
  39702. * Sets a Color4 on a uniform variable.
  39703. * @param uniformName Name of the variable.
  39704. * @param color3 Value to be set.
  39705. * @param alpha Alpha value to be set.
  39706. * @returns this effect.
  39707. */
  39708. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39709. /**
  39710. * Sets a Color4 on a uniform variable
  39711. * @param uniformName defines the name of the variable
  39712. * @param color4 defines the value to be set
  39713. * @returns this effect.
  39714. */
  39715. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39716. /**
  39717. * Release all associated resources.
  39718. **/
  39719. dispose(): void;
  39720. /**
  39721. * This function will add a new shader to the shader store
  39722. * @param name the name of the shader
  39723. * @param pixelShader optional pixel shader content
  39724. * @param vertexShader optional vertex shader content
  39725. */
  39726. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39727. /**
  39728. * Store of each shader (The can be looked up using effect.key)
  39729. */
  39730. static ShadersStore: {
  39731. [key: string]: string;
  39732. };
  39733. /**
  39734. * Store of each included file for a shader (The can be looked up using effect.key)
  39735. */
  39736. static IncludesShadersStore: {
  39737. [key: string]: string;
  39738. };
  39739. /**
  39740. * Resets the cache of effects.
  39741. */
  39742. static ResetCache(): void;
  39743. }
  39744. }
  39745. declare module BABYLON {
  39746. /**
  39747. * Interface used to describe the capabilities of the engine relatively to the current browser
  39748. */
  39749. export interface EngineCapabilities {
  39750. /** Maximum textures units per fragment shader */
  39751. maxTexturesImageUnits: number;
  39752. /** Maximum texture units per vertex shader */
  39753. maxVertexTextureImageUnits: number;
  39754. /** Maximum textures units in the entire pipeline */
  39755. maxCombinedTexturesImageUnits: number;
  39756. /** Maximum texture size */
  39757. maxTextureSize: number;
  39758. /** Maximum texture samples */
  39759. maxSamples?: number;
  39760. /** Maximum cube texture size */
  39761. maxCubemapTextureSize: number;
  39762. /** Maximum render texture size */
  39763. maxRenderTextureSize: number;
  39764. /** Maximum number of vertex attributes */
  39765. maxVertexAttribs: number;
  39766. /** Maximum number of varyings */
  39767. maxVaryingVectors: number;
  39768. /** Maximum number of uniforms per vertex shader */
  39769. maxVertexUniformVectors: number;
  39770. /** Maximum number of uniforms per fragment shader */
  39771. maxFragmentUniformVectors: number;
  39772. /** Defines if standard derivatives (dx/dy) are supported */
  39773. standardDerivatives: boolean;
  39774. /** Defines if s3tc texture compression is supported */
  39775. s3tc?: WEBGL_compressed_texture_s3tc;
  39776. /** Defines if pvrtc texture compression is supported */
  39777. pvrtc: any;
  39778. /** Defines if etc1 texture compression is supported */
  39779. etc1: any;
  39780. /** Defines if etc2 texture compression is supported */
  39781. etc2: any;
  39782. /** Defines if astc texture compression is supported */
  39783. astc: any;
  39784. /** Defines if bptc texture compression is supported */
  39785. bptc: any;
  39786. /** Defines if float textures are supported */
  39787. textureFloat: boolean;
  39788. /** Defines if vertex array objects are supported */
  39789. vertexArrayObject: boolean;
  39790. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39791. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39792. /** Gets the maximum level of anisotropy supported */
  39793. maxAnisotropy: number;
  39794. /** Defines if instancing is supported */
  39795. instancedArrays: boolean;
  39796. /** Defines if 32 bits indices are supported */
  39797. uintIndices: boolean;
  39798. /** Defines if high precision shaders are supported */
  39799. highPrecisionShaderSupported: boolean;
  39800. /** Defines if depth reading in the fragment shader is supported */
  39801. fragmentDepthSupported: boolean;
  39802. /** Defines if float texture linear filtering is supported*/
  39803. textureFloatLinearFiltering: boolean;
  39804. /** Defines if rendering to float textures is supported */
  39805. textureFloatRender: boolean;
  39806. /** Defines if half float textures are supported*/
  39807. textureHalfFloat: boolean;
  39808. /** Defines if half float texture linear filtering is supported*/
  39809. textureHalfFloatLinearFiltering: boolean;
  39810. /** Defines if rendering to half float textures is supported */
  39811. textureHalfFloatRender: boolean;
  39812. /** Defines if textureLOD shader command is supported */
  39813. textureLOD: boolean;
  39814. /** Defines if draw buffers extension is supported */
  39815. drawBuffersExtension: boolean;
  39816. /** Defines if depth textures are supported */
  39817. depthTextureExtension: boolean;
  39818. /** Defines if float color buffer are supported */
  39819. colorBufferFloat: boolean;
  39820. /** Gets disjoint timer query extension (null if not supported) */
  39821. timerQuery?: EXT_disjoint_timer_query;
  39822. /** Defines if timestamp can be used with timer query */
  39823. canUseTimestampForTimerQuery: boolean;
  39824. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39825. multiview?: any;
  39826. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39827. oculusMultiview?: any;
  39828. /** Function used to let the system compiles shaders in background */
  39829. parallelShaderCompile?: {
  39830. COMPLETION_STATUS_KHR: number;
  39831. };
  39832. /** Max number of texture samples for MSAA */
  39833. maxMSAASamples: number;
  39834. /** Defines if the blend min max extension is supported */
  39835. blendMinMax: boolean;
  39836. /** 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 */
  39837. canUseGLInstanceID: boolean;
  39838. /** Defines if gl_vertexID is available */
  39839. canUseGLVertexID: boolean;
  39840. }
  39841. }
  39842. declare module BABYLON {
  39843. /**
  39844. * @hidden
  39845. **/
  39846. export class DepthCullingState {
  39847. protected _isDepthTestDirty: boolean;
  39848. protected _isDepthMaskDirty: boolean;
  39849. protected _isDepthFuncDirty: boolean;
  39850. protected _isCullFaceDirty: boolean;
  39851. protected _isCullDirty: boolean;
  39852. protected _isZOffsetDirty: boolean;
  39853. protected _isFrontFaceDirty: boolean;
  39854. protected _depthTest: boolean;
  39855. protected _depthMask: boolean;
  39856. protected _depthFunc: Nullable<number>;
  39857. protected _cull: Nullable<boolean>;
  39858. protected _cullFace: Nullable<number>;
  39859. protected _zOffset: number;
  39860. protected _frontFace: Nullable<number>;
  39861. /**
  39862. * Initializes the state.
  39863. */
  39864. constructor(reset?: boolean);
  39865. get isDirty(): boolean;
  39866. get zOffset(): number;
  39867. set zOffset(value: number);
  39868. get cullFace(): Nullable<number>;
  39869. set cullFace(value: Nullable<number>);
  39870. get cull(): Nullable<boolean>;
  39871. set cull(value: Nullable<boolean>);
  39872. get depthFunc(): Nullable<number>;
  39873. set depthFunc(value: Nullable<number>);
  39874. get depthMask(): boolean;
  39875. set depthMask(value: boolean);
  39876. get depthTest(): boolean;
  39877. set depthTest(value: boolean);
  39878. get frontFace(): Nullable<number>;
  39879. set frontFace(value: Nullable<number>);
  39880. reset(): void;
  39881. apply(gl: WebGLRenderingContext): void;
  39882. }
  39883. }
  39884. declare module BABYLON {
  39885. /**
  39886. * @hidden
  39887. **/
  39888. export class StencilState {
  39889. /** 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 */
  39890. static readonly ALWAYS: number;
  39891. /** Passed to stencilOperation to specify that stencil value must be kept */
  39892. static readonly KEEP: number;
  39893. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39894. static readonly REPLACE: number;
  39895. protected _isStencilTestDirty: boolean;
  39896. protected _isStencilMaskDirty: boolean;
  39897. protected _isStencilFuncDirty: boolean;
  39898. protected _isStencilOpDirty: boolean;
  39899. protected _stencilTest: boolean;
  39900. protected _stencilMask: number;
  39901. protected _stencilFunc: number;
  39902. protected _stencilFuncRef: number;
  39903. protected _stencilFuncMask: number;
  39904. protected _stencilOpStencilFail: number;
  39905. protected _stencilOpDepthFail: number;
  39906. protected _stencilOpStencilDepthPass: number;
  39907. get isDirty(): boolean;
  39908. get stencilFunc(): number;
  39909. set stencilFunc(value: number);
  39910. get stencilFuncRef(): number;
  39911. set stencilFuncRef(value: number);
  39912. get stencilFuncMask(): number;
  39913. set stencilFuncMask(value: number);
  39914. get stencilOpStencilFail(): number;
  39915. set stencilOpStencilFail(value: number);
  39916. get stencilOpDepthFail(): number;
  39917. set stencilOpDepthFail(value: number);
  39918. get stencilOpStencilDepthPass(): number;
  39919. set stencilOpStencilDepthPass(value: number);
  39920. get stencilMask(): number;
  39921. set stencilMask(value: number);
  39922. get stencilTest(): boolean;
  39923. set stencilTest(value: boolean);
  39924. constructor(reset?: boolean);
  39925. reset(): void;
  39926. apply(gl: WebGLRenderingContext): void;
  39927. }
  39928. }
  39929. declare module BABYLON {
  39930. /**
  39931. * @hidden
  39932. **/
  39933. export class AlphaState {
  39934. _blendFunctionParameters: Nullable<number>[];
  39935. _blendEquationParameters: Nullable<number>[];
  39936. _blendConstants: Nullable<number>[];
  39937. _isBlendConstantsDirty: boolean;
  39938. private _alphaBlend;
  39939. private _isAlphaBlendDirty;
  39940. private _isBlendFunctionParametersDirty;
  39941. private _isBlendEquationParametersDirty;
  39942. /**
  39943. * Initializes the state.
  39944. */
  39945. constructor();
  39946. get isDirty(): boolean;
  39947. get alphaBlend(): boolean;
  39948. set alphaBlend(value: boolean);
  39949. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39950. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39951. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39952. reset(): void;
  39953. apply(gl: WebGLRenderingContext): void;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /** @hidden */
  39958. export class WebGLShaderProcessor implements IShaderProcessor {
  39959. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39960. }
  39961. }
  39962. declare module BABYLON {
  39963. /** @hidden */
  39964. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39965. attributeProcessor(attribute: string): string;
  39966. varyingProcessor(varying: string, isFragment: boolean): string;
  39967. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39968. }
  39969. }
  39970. declare module BABYLON {
  39971. /**
  39972. * Interface for attribute information associated with buffer instantiation
  39973. */
  39974. export interface InstancingAttributeInfo {
  39975. /**
  39976. * Name of the GLSL attribute
  39977. * if attribute index is not specified, this is used to retrieve the index from the effect
  39978. */
  39979. attributeName: string;
  39980. /**
  39981. * Index/offset of the attribute in the vertex shader
  39982. * if not specified, this will be computes from the name.
  39983. */
  39984. index?: number;
  39985. /**
  39986. * size of the attribute, 1, 2, 3 or 4
  39987. */
  39988. attributeSize: number;
  39989. /**
  39990. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39991. */
  39992. offset: number;
  39993. /**
  39994. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39995. * default to 1
  39996. */
  39997. divisor?: number;
  39998. /**
  39999. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40000. * default is FLOAT
  40001. */
  40002. attributeType?: number;
  40003. /**
  40004. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40005. */
  40006. normalized?: boolean;
  40007. }
  40008. }
  40009. declare module BABYLON {
  40010. /** @hidden */
  40011. export interface EngineFeatures {
  40012. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  40013. forceBitmapOverHTMLImageElement: boolean;
  40014. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  40015. supportRenderAndCopyToLodForFloatTextures: boolean;
  40016. /** Indicates that the engine support handling depth/stencil textures */
  40017. supportDepthStencilTexture: boolean;
  40018. /** Indicates that the engine support shadow samplers */
  40019. supportShadowSamplers: boolean;
  40020. /** 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 */
  40021. uniformBufferHardCheckMatrix: boolean;
  40022. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40023. allowTexturePrefiltering: boolean;
  40024. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40025. trackUbosInFrame: boolean;
  40026. /** Indicates that the Cascaded Shadow Map technic is supported */
  40027. supportCSM: boolean;
  40028. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40029. basisNeedsPOT: boolean;
  40030. /** Indicates that the engine supports 3D textures */
  40031. support3DTextures: boolean;
  40032. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40033. needTypeSuffixInShaderConstants: boolean;
  40034. /** Indicates that MSAA is supported */
  40035. supportMSAA: boolean;
  40036. /** Indicates that SSAO2 is supported */
  40037. supportSSAO2: boolean;
  40038. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40039. supportExtendedTextureFormats: boolean;
  40040. /** Indicates that the switch/case construct is supported in shaders */
  40041. supportSwitchCaseInShader: boolean;
  40042. /** Indicates that synchronous texture reading is supported */
  40043. supportSyncTextureRead: boolean;
  40044. /** @hidden */
  40045. _collectUbosUpdatedInFrame: boolean;
  40046. }
  40047. }
  40048. declare module BABYLON {
  40049. /** @hidden */
  40050. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40051. private _webGLTexture;
  40052. private _context;
  40053. get underlyingResource(): Nullable<WebGLTexture>;
  40054. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40055. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40056. set(hardwareTexture: WebGLTexture): void;
  40057. reset(): void;
  40058. release(): void;
  40059. }
  40060. }
  40061. declare module BABYLON {
  40062. interface ThinEngine {
  40063. /**
  40064. * Update a video texture
  40065. * @param texture defines the texture to update
  40066. * @param video defines the video element to use
  40067. * @param invertY defines if data must be stored with Y axis inverted
  40068. */
  40069. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40070. }
  40071. }
  40072. declare module BABYLON {
  40073. interface ThinEngine {
  40074. /**
  40075. * Creates a dynamic texture
  40076. * @param width defines the width of the texture
  40077. * @param height defines the height of the texture
  40078. * @param generateMipMaps defines if the engine should generate the mip levels
  40079. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40080. * @returns the dynamic texture inside an InternalTexture
  40081. */
  40082. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40083. /**
  40084. * Update the content of a dynamic texture
  40085. * @param texture defines the texture to update
  40086. * @param source defines the source containing the data
  40087. * @param invertY defines if data must be stored with Y axis inverted
  40088. * @param premulAlpha defines if alpha is stored as premultiplied
  40089. * @param format defines the format of the data
  40090. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40091. */
  40092. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40093. }
  40094. }
  40095. declare module BABYLON {
  40096. /**
  40097. * Settings for finer control over video usage
  40098. */
  40099. export interface VideoTextureSettings {
  40100. /**
  40101. * Applies `autoplay` to video, if specified
  40102. */
  40103. autoPlay?: boolean;
  40104. /**
  40105. * Applies `muted` to video, if specified
  40106. */
  40107. muted?: boolean;
  40108. /**
  40109. * Applies `loop` to video, if specified
  40110. */
  40111. loop?: boolean;
  40112. /**
  40113. * Automatically updates internal texture from video at every frame in the render loop
  40114. */
  40115. autoUpdateTexture: boolean;
  40116. /**
  40117. * Image src displayed during the video loading or until the user interacts with the video.
  40118. */
  40119. poster?: string;
  40120. }
  40121. /**
  40122. * If you want to display a video in your scene, this is the special texture for that.
  40123. * This special texture works similar to other textures, with the exception of a few parameters.
  40124. * @see https://doc.babylonjs.com/how_to/video_texture
  40125. */
  40126. export class VideoTexture extends Texture {
  40127. /**
  40128. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40129. */
  40130. readonly autoUpdateTexture: boolean;
  40131. /**
  40132. * The video instance used by the texture internally
  40133. */
  40134. readonly video: HTMLVideoElement;
  40135. private _onUserActionRequestedObservable;
  40136. /**
  40137. * Event triggered when a dom action is required by the user to play the video.
  40138. * This happens due to recent changes in browser policies preventing video to auto start.
  40139. */
  40140. get onUserActionRequestedObservable(): Observable<Texture>;
  40141. private _generateMipMaps;
  40142. private _stillImageCaptured;
  40143. private _displayingPosterTexture;
  40144. private _settings;
  40145. private _createInternalTextureOnEvent;
  40146. private _frameId;
  40147. private _currentSrc;
  40148. /**
  40149. * Creates a video texture.
  40150. * If you want to display a video in your scene, this is the special texture for that.
  40151. * This special texture works similar to other textures, with the exception of a few parameters.
  40152. * @see https://doc.babylonjs.com/how_to/video_texture
  40153. * @param name optional name, will detect from video source, if not defined
  40154. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40155. * @param scene is obviously the current scene.
  40156. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40157. * @param invertY is false by default but can be used to invert video on Y axis
  40158. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40159. * @param settings allows finer control over video usage
  40160. */
  40161. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40162. private _getName;
  40163. private _getVideo;
  40164. private _createInternalTexture;
  40165. private reset;
  40166. /**
  40167. * @hidden Internal method to initiate `update`.
  40168. */
  40169. _rebuild(): void;
  40170. /**
  40171. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40172. */
  40173. update(): void;
  40174. /**
  40175. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40176. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40177. */
  40178. updateTexture(isVisible: boolean): void;
  40179. protected _updateInternalTexture: () => void;
  40180. /**
  40181. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40182. * @param url New url.
  40183. */
  40184. updateURL(url: string): void;
  40185. /**
  40186. * Clones the texture.
  40187. * @returns the cloned texture
  40188. */
  40189. clone(): VideoTexture;
  40190. /**
  40191. * Dispose the texture and release its associated resources.
  40192. */
  40193. dispose(): void;
  40194. /**
  40195. * Creates a video texture straight from a stream.
  40196. * @param scene Define the scene the texture should be created in
  40197. * @param stream Define the stream the texture should be created from
  40198. * @returns The created video texture as a promise
  40199. */
  40200. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40201. /**
  40202. * Creates a video texture straight from your WebCam video feed.
  40203. * @param scene Define the scene the texture should be created in
  40204. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40205. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40206. * @returns The created video texture as a promise
  40207. */
  40208. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40209. minWidth: number;
  40210. maxWidth: number;
  40211. minHeight: number;
  40212. maxHeight: number;
  40213. deviceId: string;
  40214. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40215. /**
  40216. * Creates a video texture straight from your WebCam video feed.
  40217. * @param scene Define the scene the texture should be created in
  40218. * @param onReady Define a callback to triggered once the texture will be ready
  40219. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40220. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40221. */
  40222. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40223. minWidth: number;
  40224. maxWidth: number;
  40225. minHeight: number;
  40226. maxHeight: number;
  40227. deviceId: string;
  40228. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40229. }
  40230. }
  40231. declare module BABYLON {
  40232. /**
  40233. * Defines the interface used by objects working like Scene
  40234. * @hidden
  40235. */
  40236. export interface ISceneLike {
  40237. _addPendingData(data: any): void;
  40238. _removePendingData(data: any): void;
  40239. offlineProvider: IOfflineProvider;
  40240. }
  40241. /**
  40242. * Information about the current host
  40243. */
  40244. export interface HostInformation {
  40245. /**
  40246. * Defines if the current host is a mobile
  40247. */
  40248. isMobile: boolean;
  40249. }
  40250. /** Interface defining initialization parameters for Engine class */
  40251. export interface EngineOptions extends WebGLContextAttributes {
  40252. /**
  40253. * Defines if the engine should no exceed a specified device ratio
  40254. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40255. */
  40256. limitDeviceRatio?: number;
  40257. /**
  40258. * Defines if webvr should be enabled automatically
  40259. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40260. */
  40261. autoEnableWebVR?: boolean;
  40262. /**
  40263. * Defines if webgl2 should be turned off even if supported
  40264. * @see https://doc.babylonjs.com/features/webgl2
  40265. */
  40266. disableWebGL2Support?: boolean;
  40267. /**
  40268. * Defines if webaudio should be initialized as well
  40269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40270. */
  40271. audioEngine?: boolean;
  40272. /**
  40273. * Defines if animations should run using a deterministic lock step
  40274. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40275. */
  40276. deterministicLockstep?: boolean;
  40277. /** Defines the maximum steps to use with deterministic lock step mode */
  40278. lockstepMaxSteps?: number;
  40279. /** Defines the seconds between each deterministic lock step */
  40280. timeStep?: number;
  40281. /**
  40282. * Defines that engine should ignore context lost events
  40283. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40284. */
  40285. doNotHandleContextLost?: boolean;
  40286. /**
  40287. * Defines that engine should ignore modifying touch action attribute and style
  40288. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40289. */
  40290. doNotHandleTouchAction?: boolean;
  40291. /**
  40292. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40293. */
  40294. useHighPrecisionFloats?: boolean;
  40295. /**
  40296. * Make the canvas XR Compatible for XR sessions
  40297. */
  40298. xrCompatible?: boolean;
  40299. /**
  40300. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40301. */
  40302. useHighPrecisionMatrix?: boolean;
  40303. /**
  40304. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40305. */
  40306. failIfMajorPerformanceCaveat?: boolean;
  40307. /**
  40308. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40309. */
  40310. adaptToDeviceRatio?: boolean;
  40311. }
  40312. /**
  40313. * The base engine class (root of all engines)
  40314. */
  40315. export class ThinEngine {
  40316. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40317. static ExceptionList: ({
  40318. key: string;
  40319. capture: string;
  40320. captureConstraint: number;
  40321. targets: string[];
  40322. } | {
  40323. key: string;
  40324. capture: null;
  40325. captureConstraint: null;
  40326. targets: string[];
  40327. })[];
  40328. /** @hidden */
  40329. static _TextureLoaders: IInternalTextureLoader[];
  40330. /**
  40331. * Returns the current npm package of the sdk
  40332. */
  40333. static get NpmPackage(): string;
  40334. /**
  40335. * Returns the current version of the framework
  40336. */
  40337. static get Version(): string;
  40338. /**
  40339. * Returns a string describing the current engine
  40340. */
  40341. get description(): string;
  40342. /**
  40343. * Returns the name of the engine
  40344. */
  40345. get name(): string;
  40346. /**
  40347. * Returns the version of the engine
  40348. */
  40349. get version(): number;
  40350. /**
  40351. * Gets or sets the epsilon value used by collision engine
  40352. */
  40353. static CollisionsEpsilon: number;
  40354. /**
  40355. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40356. */
  40357. static get ShadersRepository(): string;
  40358. static set ShadersRepository(value: string);
  40359. /** @hidden */
  40360. _shaderProcessor: Nullable<IShaderProcessor>;
  40361. /**
  40362. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40363. */
  40364. forcePOTTextures: boolean;
  40365. /**
  40366. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40367. */
  40368. isFullscreen: boolean;
  40369. /**
  40370. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40371. */
  40372. cullBackFaces: boolean;
  40373. /**
  40374. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40375. */
  40376. renderEvenInBackground: boolean;
  40377. /**
  40378. * Gets or sets a boolean indicating that cache can be kept between frames
  40379. */
  40380. preventCacheWipeBetweenFrames: boolean;
  40381. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40382. validateShaderPrograms: boolean;
  40383. /**
  40384. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40385. * This can provide greater z depth for distant objects.
  40386. */
  40387. useReverseDepthBuffer: boolean;
  40388. /**
  40389. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40390. */
  40391. disableUniformBuffers: boolean;
  40392. private _frameId;
  40393. /**
  40394. * Gets the current frame id
  40395. */
  40396. get frameId(): number;
  40397. /** @hidden */
  40398. _uniformBuffers: UniformBuffer[];
  40399. /**
  40400. * Gets a boolean indicating that the engine supports uniform buffers
  40401. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40402. */
  40403. get supportsUniformBuffers(): boolean;
  40404. /** @hidden */
  40405. _gl: WebGLRenderingContext;
  40406. /** @hidden */
  40407. _webGLVersion: number;
  40408. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40409. protected _windowIsBackground: boolean;
  40410. protected _creationOptions: EngineOptions;
  40411. protected _highPrecisionShadersAllowed: boolean;
  40412. /** @hidden */
  40413. get _shouldUseHighPrecisionShader(): boolean;
  40414. /**
  40415. * Gets a boolean indicating that only power of 2 textures are supported
  40416. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40417. */
  40418. get needPOTTextures(): boolean;
  40419. /** @hidden */
  40420. _badOS: boolean;
  40421. /** @hidden */
  40422. _badDesktopOS: boolean;
  40423. protected _hardwareScalingLevel: number;
  40424. /** @hidden */
  40425. _caps: EngineCapabilities;
  40426. /** @hidden */
  40427. _features: EngineFeatures;
  40428. protected _isStencilEnable: boolean;
  40429. private _glVersion;
  40430. private _glRenderer;
  40431. private _glVendor;
  40432. /** @hidden */
  40433. _videoTextureSupported: boolean;
  40434. protected _renderingQueueLaunched: boolean;
  40435. protected _activeRenderLoops: (() => void)[];
  40436. /**
  40437. * Observable signaled when a context lost event is raised
  40438. */
  40439. onContextLostObservable: Observable<ThinEngine>;
  40440. /**
  40441. * Observable signaled when a context restored event is raised
  40442. */
  40443. onContextRestoredObservable: Observable<ThinEngine>;
  40444. private _onContextLost;
  40445. private _onContextRestored;
  40446. protected _contextWasLost: boolean;
  40447. /** @hidden */
  40448. _doNotHandleContextLost: boolean;
  40449. /**
  40450. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40452. */
  40453. get doNotHandleContextLost(): boolean;
  40454. set doNotHandleContextLost(value: boolean);
  40455. /**
  40456. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40457. */
  40458. disableVertexArrayObjects: boolean;
  40459. /** @hidden */
  40460. protected _colorWrite: boolean;
  40461. /** @hidden */
  40462. protected _colorWriteChanged: boolean;
  40463. /** @hidden */
  40464. protected _depthCullingState: DepthCullingState;
  40465. /** @hidden */
  40466. protected _stencilState: StencilState;
  40467. /** @hidden */
  40468. _alphaState: AlphaState;
  40469. /** @hidden */
  40470. _alphaMode: number;
  40471. /** @hidden */
  40472. _alphaEquation: number;
  40473. /** @hidden */
  40474. _internalTexturesCache: InternalTexture[];
  40475. /** @hidden */
  40476. protected _activeChannel: number;
  40477. private _currentTextureChannel;
  40478. /** @hidden */
  40479. protected _boundTexturesCache: {
  40480. [key: string]: Nullable<InternalTexture>;
  40481. };
  40482. /** @hidden */
  40483. protected _currentEffect: Nullable<Effect>;
  40484. /** @hidden */
  40485. protected _currentProgram: Nullable<WebGLProgram>;
  40486. protected _compiledEffects: {
  40487. [key: string]: Effect;
  40488. };
  40489. private _vertexAttribArraysEnabled;
  40490. /** @hidden */
  40491. protected _cachedViewport: Nullable<IViewportLike>;
  40492. private _cachedVertexArrayObject;
  40493. /** @hidden */
  40494. protected _cachedVertexBuffers: any;
  40495. /** @hidden */
  40496. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40497. /** @hidden */
  40498. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40499. /** @hidden */
  40500. _currentRenderTarget: Nullable<InternalTexture>;
  40501. private _uintIndicesCurrentlySet;
  40502. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40503. /** @hidden */
  40504. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40505. /** @hidden */
  40506. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40507. private _currentBufferPointers;
  40508. private _currentInstanceLocations;
  40509. private _currentInstanceBuffers;
  40510. private _textureUnits;
  40511. /** @hidden */
  40512. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40513. /** @hidden */
  40514. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40515. /** @hidden */
  40516. _boundRenderFunction: any;
  40517. private _vaoRecordInProgress;
  40518. private _mustWipeVertexAttributes;
  40519. private _emptyTexture;
  40520. private _emptyCubeTexture;
  40521. private _emptyTexture3D;
  40522. private _emptyTexture2DArray;
  40523. /** @hidden */
  40524. _frameHandler: number;
  40525. private _nextFreeTextureSlots;
  40526. private _maxSimultaneousTextures;
  40527. private _activeRequests;
  40528. /** @hidden */
  40529. _transformTextureUrl: Nullable<(url: string) => string>;
  40530. /**
  40531. * Gets information about the current host
  40532. */
  40533. hostInformation: HostInformation;
  40534. protected get _supportsHardwareTextureRescaling(): boolean;
  40535. private _framebufferDimensionsObject;
  40536. /**
  40537. * sets the object from which width and height will be taken from when getting render width and height
  40538. * Will fallback to the gl object
  40539. * @param dimensions the framebuffer width and height that will be used.
  40540. */
  40541. set framebufferDimensionsObject(dimensions: Nullable<{
  40542. framebufferWidth: number;
  40543. framebufferHeight: number;
  40544. }>);
  40545. /**
  40546. * Gets the current viewport
  40547. */
  40548. get currentViewport(): Nullable<IViewportLike>;
  40549. /**
  40550. * Gets the default empty texture
  40551. */
  40552. get emptyTexture(): InternalTexture;
  40553. /**
  40554. * Gets the default empty 3D texture
  40555. */
  40556. get emptyTexture3D(): InternalTexture;
  40557. /**
  40558. * Gets the default empty 2D array texture
  40559. */
  40560. get emptyTexture2DArray(): InternalTexture;
  40561. /**
  40562. * Gets the default empty cube texture
  40563. */
  40564. get emptyCubeTexture(): InternalTexture;
  40565. /**
  40566. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40567. */
  40568. premultipliedAlpha: boolean;
  40569. /**
  40570. * Observable event triggered before each texture is initialized
  40571. */
  40572. onBeforeTextureInitObservable: Observable<Texture>;
  40573. /** @hidden */
  40574. protected _isWebGPU: boolean;
  40575. /**
  40576. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40577. */
  40578. get isWebGPU(): boolean;
  40579. /** @hidden */
  40580. protected _shaderPlatformName: string;
  40581. /**
  40582. * Gets the shader platfrom name used by the effects.
  40583. */
  40584. get shaderPlatformName(): string;
  40585. /**
  40586. * Creates a new engine
  40587. * @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
  40588. * @param antialias defines enable antialiasing (default: false)
  40589. * @param options defines further options to be sent to the getContext() function
  40590. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40591. */
  40592. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40593. /**
  40594. * @hidden
  40595. */
  40596. _debugPushGroup(groupName: string, targetObject?: number): void;
  40597. /**
  40598. * @hidden
  40599. */
  40600. _debugPopGroup(targetObject?: number): void;
  40601. /**
  40602. * @hidden
  40603. */
  40604. _debugInsertMarker(text: string, targetObject?: number): void;
  40605. /**
  40606. * Shared initialization across engines types.
  40607. * @param canvas The canvas associated with this instance of the engine.
  40608. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40609. * @param audioEngine Defines if an audio engine should be created by default
  40610. */
  40611. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40612. /**
  40613. * Gets a shader processor implementation fitting with the current engine type.
  40614. * @returns The shader processor implementation.
  40615. */
  40616. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40617. /** @hidden */
  40618. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40619. private _rebuildInternalTextures;
  40620. private _rebuildEffects;
  40621. /**
  40622. * Gets a boolean indicating if all created effects are ready
  40623. * @returns true if all effects are ready
  40624. */
  40625. areAllEffectsReady(): boolean;
  40626. protected _rebuildBuffers(): void;
  40627. protected _initGLContext(): void;
  40628. protected _initFeatures(): void;
  40629. /**
  40630. * Gets version of the current webGL context
  40631. * Keep it for back compat - use version instead
  40632. */
  40633. get webGLVersion(): number;
  40634. /**
  40635. * Gets a string identifying the name of the class
  40636. * @returns "Engine" string
  40637. */
  40638. getClassName(): string;
  40639. /**
  40640. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40641. */
  40642. get isStencilEnable(): boolean;
  40643. /** @hidden */
  40644. _prepareWorkingCanvas(): void;
  40645. /**
  40646. * Reset the texture cache to empty state
  40647. */
  40648. resetTextureCache(): void;
  40649. /**
  40650. * Gets an object containing information about the current webGL context
  40651. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40652. */
  40653. getGlInfo(): {
  40654. vendor: string;
  40655. renderer: string;
  40656. version: string;
  40657. };
  40658. /**
  40659. * Defines the hardware scaling level.
  40660. * By default the hardware scaling level is computed from the window device ratio.
  40661. * 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.
  40662. * @param level defines the level to use
  40663. */
  40664. setHardwareScalingLevel(level: number): void;
  40665. /**
  40666. * Gets the current hardware scaling level.
  40667. * By default the hardware scaling level is computed from the window device ratio.
  40668. * 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.
  40669. * @returns a number indicating the current hardware scaling level
  40670. */
  40671. getHardwareScalingLevel(): number;
  40672. /**
  40673. * Gets the list of loaded textures
  40674. * @returns an array containing all loaded textures
  40675. */
  40676. getLoadedTexturesCache(): InternalTexture[];
  40677. /**
  40678. * Gets the object containing all engine capabilities
  40679. * @returns the EngineCapabilities object
  40680. */
  40681. getCaps(): EngineCapabilities;
  40682. /**
  40683. * stop executing a render loop function and remove it from the execution array
  40684. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40685. */
  40686. stopRenderLoop(renderFunction?: () => void): void;
  40687. /** @hidden */
  40688. _renderLoop(): void;
  40689. /**
  40690. * Gets the HTML canvas attached with the current webGL context
  40691. * @returns a HTML canvas
  40692. */
  40693. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40694. /**
  40695. * Gets host window
  40696. * @returns the host window object
  40697. */
  40698. getHostWindow(): Nullable<Window>;
  40699. /**
  40700. * Gets the current render width
  40701. * @param useScreen defines if screen size must be used (or the current render target if any)
  40702. * @returns a number defining the current render width
  40703. */
  40704. getRenderWidth(useScreen?: boolean): number;
  40705. /**
  40706. * Gets the current render height
  40707. * @param useScreen defines if screen size must be used (or the current render target if any)
  40708. * @returns a number defining the current render height
  40709. */
  40710. getRenderHeight(useScreen?: boolean): number;
  40711. /**
  40712. * Can be used to override the current requestAnimationFrame requester.
  40713. * @hidden
  40714. */
  40715. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40716. /**
  40717. * Register and execute a render loop. The engine can have more than one render function
  40718. * @param renderFunction defines the function to continuously execute
  40719. */
  40720. runRenderLoop(renderFunction: () => void): void;
  40721. /**
  40722. * Clear the current render buffer or the current render target (if any is set up)
  40723. * @param color defines the color to use
  40724. * @param backBuffer defines if the back buffer must be cleared
  40725. * @param depth defines if the depth buffer must be cleared
  40726. * @param stencil defines if the stencil buffer must be cleared
  40727. */
  40728. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40729. protected _viewportCached: {
  40730. x: number;
  40731. y: number;
  40732. z: number;
  40733. w: number;
  40734. };
  40735. /** @hidden */
  40736. _viewport(x: number, y: number, width: number, height: number): void;
  40737. /**
  40738. * Set the WebGL's viewport
  40739. * @param viewport defines the viewport element to be used
  40740. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40741. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40742. */
  40743. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40744. /**
  40745. * Begin a new frame
  40746. */
  40747. beginFrame(): void;
  40748. /**
  40749. * Enf the current frame
  40750. */
  40751. endFrame(): void;
  40752. /**
  40753. * Resize the view according to the canvas' size
  40754. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40755. */
  40756. resize(forceSetSize?: boolean): void;
  40757. /**
  40758. * Force a specific size of the canvas
  40759. * @param width defines the new canvas' width
  40760. * @param height defines the new canvas' height
  40761. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40762. * @returns true if the size was changed
  40763. */
  40764. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40765. /**
  40766. * Binds the frame buffer to the specified texture.
  40767. * @param texture The texture to render to or null for the default canvas
  40768. * @param faceIndex The face of the texture to render to in case of cube texture
  40769. * @param requiredWidth The width of the target to render to
  40770. * @param requiredHeight The height of the target to render to
  40771. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40772. * @param lodLevel defines the lod level to bind to the frame buffer
  40773. * @param layer defines the 2d array index to bind to frame buffer to
  40774. */
  40775. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40776. /** @hidden */
  40777. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40778. /**
  40779. * Unbind the current render target texture from the webGL context
  40780. * @param texture defines the render target texture to unbind
  40781. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40782. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40783. */
  40784. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40785. /**
  40786. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40787. */
  40788. flushFramebuffer(): void;
  40789. /**
  40790. * Unbind the current render target and bind the default framebuffer
  40791. */
  40792. restoreDefaultFramebuffer(): void;
  40793. /** @hidden */
  40794. protected _resetVertexBufferBinding(): void;
  40795. /**
  40796. * Creates a vertex buffer
  40797. * @param data the data for the vertex buffer
  40798. * @returns the new WebGL static buffer
  40799. */
  40800. createVertexBuffer(data: DataArray): DataBuffer;
  40801. private _createVertexBuffer;
  40802. /**
  40803. * Creates a dynamic vertex buffer
  40804. * @param data the data for the dynamic vertex buffer
  40805. * @returns the new WebGL dynamic buffer
  40806. */
  40807. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40808. protected _resetIndexBufferBinding(): void;
  40809. /**
  40810. * Creates a new index buffer
  40811. * @param indices defines the content of the index buffer
  40812. * @param updatable defines if the index buffer must be updatable
  40813. * @returns a new webGL buffer
  40814. */
  40815. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40816. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40817. /**
  40818. * Bind a webGL buffer to the webGL context
  40819. * @param buffer defines the buffer to bind
  40820. */
  40821. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40822. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40823. private bindBuffer;
  40824. /**
  40825. * update the bound buffer with the given data
  40826. * @param data defines the data to update
  40827. */
  40828. updateArrayBuffer(data: Float32Array): void;
  40829. private _vertexAttribPointer;
  40830. /** @hidden */
  40831. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40832. private _bindVertexBuffersAttributes;
  40833. /**
  40834. * Records a vertex array object
  40835. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40836. * @param vertexBuffers defines the list of vertex buffers to store
  40837. * @param indexBuffer defines the index buffer to store
  40838. * @param effect defines the effect to store
  40839. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40840. * @returns the new vertex array object
  40841. */
  40842. recordVertexArrayObject(vertexBuffers: {
  40843. [key: string]: VertexBuffer;
  40844. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40845. [kind: string]: Nullable<VertexBuffer>;
  40846. }): WebGLVertexArrayObject;
  40847. /**
  40848. * Bind a specific vertex array object
  40849. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40850. * @param vertexArrayObject defines the vertex array object to bind
  40851. * @param indexBuffer defines the index buffer to bind
  40852. */
  40853. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40854. /**
  40855. * Bind webGl buffers directly to the webGL context
  40856. * @param vertexBuffer defines the vertex buffer to bind
  40857. * @param indexBuffer defines the index buffer to bind
  40858. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40859. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40860. * @param effect defines the effect associated with the vertex buffer
  40861. */
  40862. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40863. private _unbindVertexArrayObject;
  40864. /**
  40865. * Bind a list of vertex buffers to the webGL context
  40866. * @param vertexBuffers defines the list of vertex buffers to bind
  40867. * @param indexBuffer defines the index buffer to bind
  40868. * @param effect defines the effect associated with the vertex buffers
  40869. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40870. */
  40871. bindBuffers(vertexBuffers: {
  40872. [key: string]: Nullable<VertexBuffer>;
  40873. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40874. [kind: string]: Nullable<VertexBuffer>;
  40875. }): void;
  40876. /**
  40877. * Unbind all instance attributes
  40878. */
  40879. unbindInstanceAttributes(): void;
  40880. /**
  40881. * Release and free the memory of a vertex array object
  40882. * @param vao defines the vertex array object to delete
  40883. */
  40884. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40885. /** @hidden */
  40886. _releaseBuffer(buffer: DataBuffer): boolean;
  40887. protected _deleteBuffer(buffer: DataBuffer): void;
  40888. /**
  40889. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40890. * @param instancesBuffer defines the webGL buffer to update and bind
  40891. * @param data defines the data to store in the buffer
  40892. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40893. */
  40894. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40895. /**
  40896. * Bind the content of a webGL buffer used with instantiation
  40897. * @param instancesBuffer defines the webGL buffer to bind
  40898. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40899. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40900. */
  40901. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40902. /**
  40903. * Disable the instance attribute corresponding to the name in parameter
  40904. * @param name defines the name of the attribute to disable
  40905. */
  40906. disableInstanceAttributeByName(name: string): void;
  40907. /**
  40908. * Disable the instance attribute corresponding to the location in parameter
  40909. * @param attributeLocation defines the attribute location of the attribute to disable
  40910. */
  40911. disableInstanceAttribute(attributeLocation: number): void;
  40912. /**
  40913. * Disable the attribute corresponding to the location in parameter
  40914. * @param attributeLocation defines the attribute location of the attribute to disable
  40915. */
  40916. disableAttributeByIndex(attributeLocation: number): void;
  40917. /**
  40918. * Send a draw order
  40919. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40920. * @param indexStart defines the starting index
  40921. * @param indexCount defines the number of index to draw
  40922. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40923. */
  40924. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40925. /**
  40926. * Draw a list of points
  40927. * @param verticesStart defines the index of first vertex to draw
  40928. * @param verticesCount defines the count of vertices to draw
  40929. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40930. */
  40931. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40932. /**
  40933. * Draw a list of unindexed primitives
  40934. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40935. * @param verticesStart defines the index of first vertex to draw
  40936. * @param verticesCount defines the count of vertices to draw
  40937. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40938. */
  40939. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40940. /**
  40941. * Draw a list of indexed primitives
  40942. * @param fillMode defines the primitive to use
  40943. * @param indexStart defines the starting index
  40944. * @param indexCount defines the number of index to draw
  40945. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40946. */
  40947. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40948. /**
  40949. * Draw a list of unindexed primitives
  40950. * @param fillMode defines the primitive to use
  40951. * @param verticesStart defines the index of first vertex to draw
  40952. * @param verticesCount defines the count of vertices to draw
  40953. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40954. */
  40955. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40956. private _drawMode;
  40957. /** @hidden */
  40958. protected _reportDrawCall(): void;
  40959. /** @hidden */
  40960. _releaseEffect(effect: Effect): void;
  40961. /** @hidden */
  40962. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40963. /**
  40964. * Create a new effect (used to store vertex/fragment shaders)
  40965. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40966. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40967. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40968. * @param samplers defines an array of string used to represent textures
  40969. * @param defines defines the string containing the defines to use to compile the shaders
  40970. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40971. * @param onCompiled defines a function to call when the effect creation is successful
  40972. * @param onError defines a function to call when the effect creation has failed
  40973. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40974. * @returns the new Effect
  40975. */
  40976. 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;
  40977. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40978. private _compileShader;
  40979. private _compileRawShader;
  40980. /** @hidden */
  40981. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40982. /**
  40983. * Directly creates a webGL program
  40984. * @param pipelineContext defines the pipeline context to attach to
  40985. * @param vertexCode defines the vertex shader code to use
  40986. * @param fragmentCode defines the fragment shader code to use
  40987. * @param context defines the webGL context to use (if not set, the current one will be used)
  40988. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40989. * @returns the new webGL program
  40990. */
  40991. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40992. /**
  40993. * Creates a webGL program
  40994. * @param pipelineContext defines the pipeline context to attach to
  40995. * @param vertexCode defines the vertex shader code to use
  40996. * @param fragmentCode defines the fragment shader code to use
  40997. * @param defines defines the string containing the defines to use to compile the shaders
  40998. * @param context defines the webGL context to use (if not set, the current one will be used)
  40999. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41000. * @returns the new webGL program
  41001. */
  41002. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41003. /**
  41004. * Creates a new pipeline context
  41005. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  41006. * @returns the new pipeline
  41007. */
  41008. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  41009. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41010. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41011. /** @hidden */
  41012. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  41013. /** @hidden */
  41014. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41015. /** @hidden */
  41016. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41017. /**
  41018. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41019. * @param pipelineContext defines the pipeline context to use
  41020. * @param uniformsNames defines the list of uniform names
  41021. * @returns an array of webGL uniform locations
  41022. */
  41023. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41024. /**
  41025. * Gets the list of active attributes for a given webGL program
  41026. * @param pipelineContext defines the pipeline context to use
  41027. * @param attributesNames defines the list of attribute names to get
  41028. * @returns an array of indices indicating the offset of each attribute
  41029. */
  41030. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41031. /**
  41032. * Activates an effect, making it the current one (ie. the one used for rendering)
  41033. * @param effect defines the effect to activate
  41034. */
  41035. enableEffect(effect: Nullable<Effect>): void;
  41036. /**
  41037. * Set the value of an uniform to a number (int)
  41038. * @param uniform defines the webGL uniform location where to store the value
  41039. * @param value defines the int number to store
  41040. * @returns true if the value was set
  41041. */
  41042. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41043. /**
  41044. * Set the value of an uniform to a int2
  41045. * @param uniform defines the webGL uniform location where to store the value
  41046. * @param x defines the 1st component of the value
  41047. * @param y defines the 2nd component of the value
  41048. * @returns true if the value was set
  41049. */
  41050. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41051. /**
  41052. * Set the value of an uniform to a int3
  41053. * @param uniform defines the webGL uniform location where to store the value
  41054. * @param x defines the 1st component of the value
  41055. * @param y defines the 2nd component of the value
  41056. * @param z defines the 3rd component of the value
  41057. * @returns true if the value was set
  41058. */
  41059. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41060. /**
  41061. * Set the value of an uniform to a int4
  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. * @param w defines the 4th component of the value
  41067. * @returns true if the value was set
  41068. */
  41069. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41070. /**
  41071. * Set the value of an uniform to an array of int32
  41072. * @param uniform defines the webGL uniform location where to store the value
  41073. * @param array defines the array of int32 to store
  41074. * @returns true if the value was set
  41075. */
  41076. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41077. /**
  41078. * Set the value of an uniform to an array of int32 (stored as vec2)
  41079. * @param uniform defines the webGL uniform location where to store the value
  41080. * @param array defines the array of int32 to store
  41081. * @returns true if the value was set
  41082. */
  41083. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41084. /**
  41085. * Set the value of an uniform to an array of int32 (stored as vec3)
  41086. * @param uniform defines the webGL uniform location where to store the value
  41087. * @param array defines the array of int32 to store
  41088. * @returns true if the value was set
  41089. */
  41090. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41091. /**
  41092. * Set the value of an uniform to an array of int32 (stored as vec4)
  41093. * @param uniform defines the webGL uniform location where to store the value
  41094. * @param array defines the array of int32 to store
  41095. * @returns true if the value was set
  41096. */
  41097. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41098. /**
  41099. * Set the value of an uniform to an array of number
  41100. * @param uniform defines the webGL uniform location where to store the value
  41101. * @param array defines the array of number to store
  41102. * @returns true if the value was set
  41103. */
  41104. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41105. /**
  41106. * Set the value of an uniform to an array of number (stored as vec2)
  41107. * @param uniform defines the webGL uniform location where to store the value
  41108. * @param array defines the array of number to store
  41109. * @returns true if the value was set
  41110. */
  41111. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41112. /**
  41113. * Set the value of an uniform to an array of number (stored as vec3)
  41114. * @param uniform defines the webGL uniform location where to store the value
  41115. * @param array defines the array of number to store
  41116. * @returns true if the value was set
  41117. */
  41118. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41119. /**
  41120. * Set the value of an uniform to an array of number (stored as vec4)
  41121. * @param uniform defines the webGL uniform location where to store the value
  41122. * @param array defines the array of number to store
  41123. * @returns true if the value was set
  41124. */
  41125. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41126. /**
  41127. * Set the value of an uniform to an array of float32 (stored as matrices)
  41128. * @param uniform defines the webGL uniform location where to store the value
  41129. * @param matrices defines the array of float32 to store
  41130. * @returns true if the value was set
  41131. */
  41132. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41133. /**
  41134. * Set the value of an uniform to a matrix (3x3)
  41135. * @param uniform defines the webGL uniform location where to store the value
  41136. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41137. * @returns true if the value was set
  41138. */
  41139. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41140. /**
  41141. * Set the value of an uniform to a matrix (2x2)
  41142. * @param uniform defines the webGL uniform location where to store the value
  41143. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41144. * @returns true if the value was set
  41145. */
  41146. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41147. /**
  41148. * Set the value of an uniform to a number (float)
  41149. * @param uniform defines the webGL uniform location where to store the value
  41150. * @param value defines the float number to store
  41151. * @returns true if the value was transferred
  41152. */
  41153. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41154. /**
  41155. * Set the value of an uniform to a vec2
  41156. * @param uniform defines the webGL uniform location where to store the value
  41157. * @param x defines the 1st component of the value
  41158. * @param y defines the 2nd component of the value
  41159. * @returns true if the value was set
  41160. */
  41161. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41162. /**
  41163. * Set the value of an uniform to a vec3
  41164. * @param uniform defines the webGL uniform location where to store the value
  41165. * @param x defines the 1st component of the value
  41166. * @param y defines the 2nd component of the value
  41167. * @param z defines the 3rd component of the value
  41168. * @returns true if the value was set
  41169. */
  41170. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41171. /**
  41172. * Set the value of an uniform to a vec4
  41173. * @param uniform defines the webGL uniform location where to store the value
  41174. * @param x defines the 1st component of the value
  41175. * @param y defines the 2nd component of the value
  41176. * @param z defines the 3rd component of the value
  41177. * @param w defines the 4th component of the value
  41178. * @returns true if the value was set
  41179. */
  41180. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41181. /**
  41182. * Apply all cached states (depth, culling, stencil and alpha)
  41183. */
  41184. applyStates(): void;
  41185. /**
  41186. * Enable or disable color writing
  41187. * @param enable defines the state to set
  41188. */
  41189. setColorWrite(enable: boolean): void;
  41190. /**
  41191. * Gets a boolean indicating if color writing is enabled
  41192. * @returns the current color writing state
  41193. */
  41194. getColorWrite(): boolean;
  41195. /**
  41196. * Gets the depth culling state manager
  41197. */
  41198. get depthCullingState(): DepthCullingState;
  41199. /**
  41200. * Gets the alpha state manager
  41201. */
  41202. get alphaState(): AlphaState;
  41203. /**
  41204. * Gets the stencil state manager
  41205. */
  41206. get stencilState(): StencilState;
  41207. /**
  41208. * Clears the list of texture accessible through engine.
  41209. * This can help preventing texture load conflict due to name collision.
  41210. */
  41211. clearInternalTexturesCache(): void;
  41212. /**
  41213. * Force the entire cache to be cleared
  41214. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41215. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41216. */
  41217. wipeCaches(bruteForce?: boolean): void;
  41218. /** @hidden */
  41219. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41220. min: number;
  41221. mag: number;
  41222. };
  41223. /** @hidden */
  41224. protected _createTexture(): WebGLTexture;
  41225. /** @hidden */
  41226. _createHardwareTexture(): HardwareTextureWrapper;
  41227. 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 | {
  41228. width: number;
  41229. height: number;
  41230. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41231. width: number;
  41232. height: number;
  41233. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41234. width: number;
  41235. height: number;
  41236. }, 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;
  41237. /**
  41238. * Usually called from Texture.ts.
  41239. * Passed information to create a WebGLTexture
  41240. * @param url defines a value which contains one of the following:
  41241. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41242. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41243. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41245. * @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)
  41246. * @param scene needed for loading to the correct scene
  41247. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41248. * @param onLoad optional callback to be called upon successful completion
  41249. * @param onError optional callback to be called upon failure
  41250. * @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
  41251. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41252. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41253. * @param forcedExtension defines the extension to use to pick the right loader
  41254. * @param mimeType defines an optional mime type
  41255. * @param loaderOptions options to be passed to the loader
  41256. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41257. */
  41258. 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;
  41259. /**
  41260. * Loads an image as an HTMLImageElement.
  41261. * @param input url string, ArrayBuffer, or Blob to load
  41262. * @param onLoad callback called when the image successfully loads
  41263. * @param onError callback called when the image fails to load
  41264. * @param offlineProvider offline provider for caching
  41265. * @param mimeType optional mime type
  41266. * @returns the HTMLImageElement of the loaded image
  41267. * @hidden
  41268. */
  41269. 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>;
  41270. /**
  41271. * @hidden
  41272. */
  41273. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41274. private _unpackFlipYCached;
  41275. /**
  41276. * In case you are sharing the context with other applications, it might
  41277. * be interested to not cache the unpack flip y state to ensure a consistent
  41278. * value would be set.
  41279. */
  41280. enableUnpackFlipYCached: boolean;
  41281. /** @hidden */
  41282. _unpackFlipY(value: boolean): void;
  41283. /** @hidden */
  41284. _getUnpackAlignement(): number;
  41285. private _getTextureTarget;
  41286. /**
  41287. * Update the sampling mode of a given texture
  41288. * @param samplingMode defines the required sampling mode
  41289. * @param texture defines the texture to update
  41290. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41291. */
  41292. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41293. /**
  41294. * Update the dimensions of a texture
  41295. * @param texture texture to update
  41296. * @param width new width of the texture
  41297. * @param height new height of the texture
  41298. * @param depth new depth of the texture
  41299. */
  41300. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41301. /**
  41302. * Update the sampling mode of a given texture
  41303. * @param texture defines the texture to update
  41304. * @param wrapU defines the texture wrap mode of the u coordinates
  41305. * @param wrapV defines the texture wrap mode of the v coordinates
  41306. * @param wrapR defines the texture wrap mode of the r coordinates
  41307. */
  41308. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41309. /** @hidden */
  41310. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41311. width: number;
  41312. height: number;
  41313. layers?: number;
  41314. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41315. /** @hidden */
  41316. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41317. /** @hidden */
  41318. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41319. /**
  41320. * Update a portion of an internal texture
  41321. * @param texture defines the texture to update
  41322. * @param imageData defines the data to store into the texture
  41323. * @param xOffset defines the x coordinates of the update rectangle
  41324. * @param yOffset defines the y coordinates of the update rectangle
  41325. * @param width defines the width of the update rectangle
  41326. * @param height defines the height of the update rectangle
  41327. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41328. * @param lod defines the lod level to update (0 by default)
  41329. */
  41330. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41331. /** @hidden */
  41332. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41333. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41334. private _prepareWebGLTexture;
  41335. /** @hidden */
  41336. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41337. private _getDepthStencilBuffer;
  41338. /** @hidden */
  41339. _releaseFramebufferObjects(texture: InternalTexture): void;
  41340. /** @hidden */
  41341. _releaseTexture(texture: InternalTexture): void;
  41342. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41343. protected _setProgram(program: WebGLProgram): void;
  41344. protected _boundUniforms: {
  41345. [key: number]: WebGLUniformLocation;
  41346. };
  41347. /**
  41348. * Binds an effect to the webGL context
  41349. * @param effect defines the effect to bind
  41350. */
  41351. bindSamplers(effect: Effect): void;
  41352. private _activateCurrentTexture;
  41353. /** @hidden */
  41354. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41355. /** @hidden */
  41356. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41357. /**
  41358. * Unbind all textures from the webGL context
  41359. */
  41360. unbindAllTextures(): void;
  41361. /**
  41362. * Sets a texture to the according uniform.
  41363. * @param channel The texture channel
  41364. * @param uniform The uniform to set
  41365. * @param texture The texture to apply
  41366. * @param name The name of the uniform in the effect
  41367. */
  41368. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41369. private _bindSamplerUniformToChannel;
  41370. private _getTextureWrapMode;
  41371. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41372. /**
  41373. * Sets an array of texture to the webGL context
  41374. * @param channel defines the channel where the texture array must be set
  41375. * @param uniform defines the associated uniform location
  41376. * @param textures defines the array of textures to bind
  41377. * @param name name of the channel
  41378. */
  41379. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41380. /** @hidden */
  41381. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41382. private _setTextureParameterFloat;
  41383. private _setTextureParameterInteger;
  41384. /**
  41385. * Unbind all vertex attributes from the webGL context
  41386. */
  41387. unbindAllAttributes(): void;
  41388. /**
  41389. * 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
  41390. */
  41391. releaseEffects(): void;
  41392. /**
  41393. * Dispose and release all associated resources
  41394. */
  41395. dispose(): void;
  41396. /**
  41397. * Attach a new callback raised when context lost event is fired
  41398. * @param callback defines the callback to call
  41399. */
  41400. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41401. /**
  41402. * Attach a new callback raised when context restored event is fired
  41403. * @param callback defines the callback to call
  41404. */
  41405. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41406. /**
  41407. * Get the current error code of the webGL context
  41408. * @returns the error code
  41409. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41410. */
  41411. getError(): number;
  41412. private _canRenderToFloatFramebuffer;
  41413. private _canRenderToHalfFloatFramebuffer;
  41414. private _canRenderToFramebuffer;
  41415. /** @hidden */
  41416. _getWebGLTextureType(type: number): number;
  41417. /** @hidden */
  41418. _getInternalFormat(format: number): number;
  41419. /** @hidden */
  41420. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41421. /** @hidden */
  41422. _getRGBAMultiSampleBufferFormat(type: number): number;
  41423. /** @hidden */
  41424. _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;
  41425. /**
  41426. * Loads a file from a url
  41427. * @param url url to load
  41428. * @param onSuccess callback called when the file successfully loads
  41429. * @param onProgress callback called while file is loading (if the server supports this mode)
  41430. * @param offlineProvider defines the offline provider for caching
  41431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41432. * @param onError callback called when the file fails to load
  41433. * @returns a file request object
  41434. * @hidden
  41435. */
  41436. 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;
  41437. /**
  41438. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41439. * @param x defines the x coordinate of the rectangle where pixels must be read
  41440. * @param y defines the y coordinate of the rectangle where pixels must be read
  41441. * @param width defines the width of the rectangle where pixels must be read
  41442. * @param height defines the height of the rectangle where pixels must be read
  41443. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41444. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41445. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41446. */
  41447. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41448. private static _IsSupported;
  41449. private static _HasMajorPerformanceCaveat;
  41450. /**
  41451. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41452. */
  41453. static get IsSupported(): boolean;
  41454. /**
  41455. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41456. * @returns true if the engine can be created
  41457. * @ignorenaming
  41458. */
  41459. static isSupported(): boolean;
  41460. /**
  41461. * 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)
  41462. */
  41463. static get HasMajorPerformanceCaveat(): boolean;
  41464. /**
  41465. * Find the next highest power of two.
  41466. * @param x Number to start search from.
  41467. * @return Next highest power of two.
  41468. */
  41469. static CeilingPOT(x: number): number;
  41470. /**
  41471. * Find the next lowest power of two.
  41472. * @param x Number to start search from.
  41473. * @return Next lowest power of two.
  41474. */
  41475. static FloorPOT(x: number): number;
  41476. /**
  41477. * Find the nearest power of two.
  41478. * @param x Number to start search from.
  41479. * @return Next nearest power of two.
  41480. */
  41481. static NearestPOT(x: number): number;
  41482. /**
  41483. * Get the closest exponent of two
  41484. * @param value defines the value to approximate
  41485. * @param max defines the maximum value to return
  41486. * @param mode defines how to define the closest value
  41487. * @returns closest exponent of two of the given value
  41488. */
  41489. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41490. /**
  41491. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41492. * @param func - the function to be called
  41493. * @param requester - the object that will request the next frame. Falls back to window.
  41494. * @returns frame number
  41495. */
  41496. static QueueNewFrame(func: () => void, requester?: any): number;
  41497. /**
  41498. * Gets host document
  41499. * @returns the host document object
  41500. */
  41501. getHostDocument(): Nullable<Document>;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Defines the source of the internal texture
  41507. */
  41508. export enum InternalTextureSource {
  41509. /**
  41510. * The source of the texture data is unknown
  41511. */
  41512. Unknown = 0,
  41513. /**
  41514. * Texture data comes from an URL
  41515. */
  41516. Url = 1,
  41517. /**
  41518. * Texture data is only used for temporary storage
  41519. */
  41520. Temp = 2,
  41521. /**
  41522. * Texture data comes from raw data (ArrayBuffer)
  41523. */
  41524. Raw = 3,
  41525. /**
  41526. * Texture content is dynamic (video or dynamic texture)
  41527. */
  41528. Dynamic = 4,
  41529. /**
  41530. * Texture content is generated by rendering to it
  41531. */
  41532. RenderTarget = 5,
  41533. /**
  41534. * Texture content is part of a multi render target process
  41535. */
  41536. MultiRenderTarget = 6,
  41537. /**
  41538. * Texture data comes from a cube data file
  41539. */
  41540. Cube = 7,
  41541. /**
  41542. * Texture data comes from a raw cube data
  41543. */
  41544. CubeRaw = 8,
  41545. /**
  41546. * Texture data come from a prefiltered cube data file
  41547. */
  41548. CubePrefiltered = 9,
  41549. /**
  41550. * Texture content is raw 3D data
  41551. */
  41552. Raw3D = 10,
  41553. /**
  41554. * Texture content is raw 2D array data
  41555. */
  41556. Raw2DArray = 11,
  41557. /**
  41558. * Texture content is a depth texture
  41559. */
  41560. Depth = 12,
  41561. /**
  41562. * Texture data comes from a raw cube data encoded with RGBD
  41563. */
  41564. CubeRawRGBD = 13
  41565. }
  41566. /**
  41567. * Class used to store data associated with WebGL texture data for the engine
  41568. * This class should not be used directly
  41569. */
  41570. export class InternalTexture {
  41571. /** @hidden */
  41572. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41573. /**
  41574. * Defines if the texture is ready
  41575. */
  41576. isReady: boolean;
  41577. /**
  41578. * Defines if the texture is a cube texture
  41579. */
  41580. isCube: boolean;
  41581. /**
  41582. * Defines if the texture contains 3D data
  41583. */
  41584. is3D: boolean;
  41585. /**
  41586. * Defines if the texture contains 2D array data
  41587. */
  41588. is2DArray: boolean;
  41589. /**
  41590. * Defines if the texture contains multiview data
  41591. */
  41592. isMultiview: boolean;
  41593. /**
  41594. * Gets the URL used to load this texture
  41595. */
  41596. url: string;
  41597. /** @hidden */
  41598. _originalUrl: string;
  41599. /**
  41600. * Gets the sampling mode of the texture
  41601. */
  41602. samplingMode: number;
  41603. /**
  41604. * Gets a boolean indicating if the texture needs mipmaps generation
  41605. */
  41606. generateMipMaps: boolean;
  41607. /**
  41608. * Gets the number of samples used by the texture (WebGL2+ only)
  41609. */
  41610. samples: number;
  41611. /**
  41612. * Gets the type of the texture (int, float...)
  41613. */
  41614. type: number;
  41615. /**
  41616. * Gets the format of the texture (RGB, RGBA...)
  41617. */
  41618. format: number;
  41619. /**
  41620. * Observable called when the texture is loaded
  41621. */
  41622. onLoadedObservable: Observable<InternalTexture>;
  41623. /**
  41624. * Gets the width of the texture
  41625. */
  41626. width: number;
  41627. /**
  41628. * Gets the height of the texture
  41629. */
  41630. height: number;
  41631. /**
  41632. * Gets the depth of the texture
  41633. */
  41634. depth: number;
  41635. /**
  41636. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41637. */
  41638. baseWidth: number;
  41639. /**
  41640. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41641. */
  41642. baseHeight: number;
  41643. /**
  41644. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41645. */
  41646. baseDepth: number;
  41647. /**
  41648. * Gets a boolean indicating if the texture is inverted on Y axis
  41649. */
  41650. invertY: boolean;
  41651. /** @hidden */
  41652. _invertVScale: boolean;
  41653. /** @hidden */
  41654. _associatedChannel: number;
  41655. /** @hidden */
  41656. _source: InternalTextureSource;
  41657. /** @hidden */
  41658. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41659. /** @hidden */
  41660. _bufferView: Nullable<ArrayBufferView>;
  41661. /** @hidden */
  41662. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41663. /** @hidden */
  41664. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41665. /** @hidden */
  41666. _size: number;
  41667. /** @hidden */
  41668. _extension: string;
  41669. /** @hidden */
  41670. _files: Nullable<string[]>;
  41671. /** @hidden */
  41672. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41673. /** @hidden */
  41674. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41675. /** @hidden */
  41676. _framebuffer: Nullable<WebGLFramebuffer>;
  41677. /** @hidden */
  41678. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41679. /** @hidden */
  41680. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41681. /** @hidden */
  41682. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41683. /** @hidden */
  41684. _attachments: Nullable<number[]>;
  41685. /** @hidden */
  41686. _textureArray: Nullable<InternalTexture[]>;
  41687. /** @hidden */
  41688. _cachedCoordinatesMode: Nullable<number>;
  41689. /** @hidden */
  41690. _cachedWrapU: Nullable<number>;
  41691. /** @hidden */
  41692. _cachedWrapV: Nullable<number>;
  41693. /** @hidden */
  41694. _cachedWrapR: Nullable<number>;
  41695. /** @hidden */
  41696. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41697. /** @hidden */
  41698. _isDisabled: boolean;
  41699. /** @hidden */
  41700. _compression: Nullable<string>;
  41701. /** @hidden */
  41702. _generateStencilBuffer: boolean;
  41703. /** @hidden */
  41704. _generateDepthBuffer: boolean;
  41705. /** @hidden */
  41706. _comparisonFunction: number;
  41707. /** @hidden */
  41708. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41709. /** @hidden */
  41710. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41711. /** @hidden */
  41712. _sphericalPolynomialComputed: boolean;
  41713. /** @hidden */
  41714. _lodGenerationScale: number;
  41715. /** @hidden */
  41716. _lodGenerationOffset: number;
  41717. /** @hidden */
  41718. _depthStencilTexture: Nullable<InternalTexture>;
  41719. /** @hidden */
  41720. _colorTextureArray: Nullable<WebGLTexture>;
  41721. /** @hidden */
  41722. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41723. /** @hidden */
  41724. _lodTextureHigh: Nullable<BaseTexture>;
  41725. /** @hidden */
  41726. _lodTextureMid: Nullable<BaseTexture>;
  41727. /** @hidden */
  41728. _lodTextureLow: Nullable<BaseTexture>;
  41729. /** @hidden */
  41730. _isRGBD: boolean;
  41731. /** @hidden */
  41732. _linearSpecularLOD: boolean;
  41733. /** @hidden */
  41734. _irradianceTexture: Nullable<BaseTexture>;
  41735. /** @hidden */
  41736. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41737. /** @hidden */
  41738. _references: number;
  41739. /** @hidden */
  41740. _gammaSpace: Nullable<boolean>;
  41741. private _engine;
  41742. private _uniqueId;
  41743. private static _Counter;
  41744. /** Gets the unique id of the internal texture */
  41745. get uniqueId(): number;
  41746. /**
  41747. * Gets the Engine the texture belongs to.
  41748. * @returns The babylon engine
  41749. */
  41750. getEngine(): ThinEngine;
  41751. /**
  41752. * Gets the data source type of the texture
  41753. */
  41754. get source(): InternalTextureSource;
  41755. /**
  41756. * Creates a new InternalTexture
  41757. * @param engine defines the engine to use
  41758. * @param source defines the type of data that will be used
  41759. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41760. */
  41761. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41762. /**
  41763. * Increments the number of references (ie. the number of Texture that point to it)
  41764. */
  41765. incrementReferences(): void;
  41766. /**
  41767. * Change the size of the texture (not the size of the content)
  41768. * @param width defines the new width
  41769. * @param height defines the new height
  41770. * @param depth defines the new depth (1 by default)
  41771. */
  41772. updateSize(width: int, height: int, depth?: int): void;
  41773. /** @hidden */
  41774. _rebuild(): void;
  41775. /** @hidden */
  41776. _swapAndDie(target: InternalTexture): void;
  41777. /**
  41778. * Dispose the current allocated resources
  41779. */
  41780. dispose(): void;
  41781. }
  41782. }
  41783. declare module BABYLON {
  41784. /**
  41785. * Interface used to present a loading screen while loading a scene
  41786. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41787. */
  41788. export interface ILoadingScreen {
  41789. /**
  41790. * Function called to display the loading screen
  41791. */
  41792. displayLoadingUI: () => void;
  41793. /**
  41794. * Function called to hide the loading screen
  41795. */
  41796. hideLoadingUI: () => void;
  41797. /**
  41798. * Gets or sets the color to use for the background
  41799. */
  41800. loadingUIBackgroundColor: string;
  41801. /**
  41802. * Gets or sets the text to display while loading
  41803. */
  41804. loadingUIText: string;
  41805. }
  41806. /**
  41807. * Class used for the default loading screen
  41808. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41809. */
  41810. export class DefaultLoadingScreen implements ILoadingScreen {
  41811. private _renderingCanvas;
  41812. private _loadingText;
  41813. private _loadingDivBackgroundColor;
  41814. private _loadingDiv;
  41815. private _loadingTextDiv;
  41816. /** Gets or sets the logo url to use for the default loading screen */
  41817. static DefaultLogoUrl: string;
  41818. /** Gets or sets the spinner url to use for the default loading screen */
  41819. static DefaultSpinnerUrl: string;
  41820. /**
  41821. * Creates a new default loading screen
  41822. * @param _renderingCanvas defines the canvas used to render the scene
  41823. * @param _loadingText defines the default text to display
  41824. * @param _loadingDivBackgroundColor defines the default background color
  41825. */
  41826. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41827. /**
  41828. * Function called to display the loading screen
  41829. */
  41830. displayLoadingUI(): void;
  41831. /**
  41832. * Function called to hide the loading screen
  41833. */
  41834. hideLoadingUI(): void;
  41835. /**
  41836. * Gets or sets the text to display while loading
  41837. */
  41838. set loadingUIText(text: string);
  41839. get loadingUIText(): string;
  41840. /**
  41841. * Gets or sets the color to use for the background
  41842. */
  41843. get loadingUIBackgroundColor(): string;
  41844. set loadingUIBackgroundColor(color: string);
  41845. private _resizeLoadingUI;
  41846. }
  41847. }
  41848. declare module BABYLON {
  41849. /**
  41850. * Interface for any object that can request an animation frame
  41851. */
  41852. export interface ICustomAnimationFrameRequester {
  41853. /**
  41854. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41855. */
  41856. renderFunction?: Function;
  41857. /**
  41858. * Called to request the next frame to render to
  41859. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41860. */
  41861. requestAnimationFrame: Function;
  41862. /**
  41863. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41864. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41865. */
  41866. requestID?: number;
  41867. }
  41868. }
  41869. declare module BABYLON {
  41870. /**
  41871. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41872. */
  41873. export class PerformanceMonitor {
  41874. private _enabled;
  41875. private _rollingFrameTime;
  41876. private _lastFrameTimeMs;
  41877. /**
  41878. * constructor
  41879. * @param frameSampleSize The number of samples required to saturate the sliding window
  41880. */
  41881. constructor(frameSampleSize?: number);
  41882. /**
  41883. * Samples current frame
  41884. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41885. */
  41886. sampleFrame(timeMs?: number): void;
  41887. /**
  41888. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41889. */
  41890. get averageFrameTime(): number;
  41891. /**
  41892. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41893. */
  41894. get averageFrameTimeVariance(): number;
  41895. /**
  41896. * Returns the frame time of the most recent frame
  41897. */
  41898. get instantaneousFrameTime(): number;
  41899. /**
  41900. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41901. */
  41902. get averageFPS(): number;
  41903. /**
  41904. * Returns the average framerate in frames per second using the most recent frame time
  41905. */
  41906. get instantaneousFPS(): number;
  41907. /**
  41908. * Returns true if enough samples have been taken to completely fill the sliding window
  41909. */
  41910. get isSaturated(): boolean;
  41911. /**
  41912. * Enables contributions to the sliding window sample set
  41913. */
  41914. enable(): void;
  41915. /**
  41916. * Disables contributions to the sliding window sample set
  41917. * Samples will not be interpolated over the disabled period
  41918. */
  41919. disable(): void;
  41920. /**
  41921. * Returns true if sampling is enabled
  41922. */
  41923. get isEnabled(): boolean;
  41924. /**
  41925. * Resets performance monitor
  41926. */
  41927. reset(): void;
  41928. }
  41929. /**
  41930. * RollingAverage
  41931. *
  41932. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41933. */
  41934. export class RollingAverage {
  41935. /**
  41936. * Current average
  41937. */
  41938. average: number;
  41939. /**
  41940. * Current variance
  41941. */
  41942. variance: number;
  41943. protected _samples: Array<number>;
  41944. protected _sampleCount: number;
  41945. protected _pos: number;
  41946. protected _m2: number;
  41947. /**
  41948. * constructor
  41949. * @param length The number of samples required to saturate the sliding window
  41950. */
  41951. constructor(length: number);
  41952. /**
  41953. * Adds a sample to the sample set
  41954. * @param v The sample value
  41955. */
  41956. add(v: number): void;
  41957. /**
  41958. * Returns previously added values or null if outside of history or outside the sliding window domain
  41959. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41960. * @return Value previously recorded with add() or null if outside of range
  41961. */
  41962. history(i: number): number;
  41963. /**
  41964. * Returns true if enough samples have been taken to completely fill the sliding window
  41965. * @return true if sample-set saturated
  41966. */
  41967. isSaturated(): boolean;
  41968. /**
  41969. * Resets the rolling average (equivalent to 0 samples taken so far)
  41970. */
  41971. reset(): void;
  41972. /**
  41973. * Wraps a value around the sample range boundaries
  41974. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41975. * @return Wrapped position in sample range
  41976. */
  41977. protected _wrapPosition(i: number): number;
  41978. }
  41979. }
  41980. declare module BABYLON {
  41981. /**
  41982. * This class is used to track a performance counter which is number based.
  41983. * The user has access to many properties which give statistics of different nature.
  41984. *
  41985. * The implementer can track two kinds of Performance Counter: time and count.
  41986. * 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.
  41987. * 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.
  41988. */
  41989. export class PerfCounter {
  41990. /**
  41991. * Gets or sets a global boolean to turn on and off all the counters
  41992. */
  41993. static Enabled: boolean;
  41994. /**
  41995. * Returns the smallest value ever
  41996. */
  41997. get min(): number;
  41998. /**
  41999. * Returns the biggest value ever
  42000. */
  42001. get max(): number;
  42002. /**
  42003. * Returns the average value since the performance counter is running
  42004. */
  42005. get average(): number;
  42006. /**
  42007. * Returns the average value of the last second the counter was monitored
  42008. */
  42009. get lastSecAverage(): number;
  42010. /**
  42011. * Returns the current value
  42012. */
  42013. get current(): number;
  42014. /**
  42015. * Gets the accumulated total
  42016. */
  42017. get total(): number;
  42018. /**
  42019. * Gets the total value count
  42020. */
  42021. get count(): number;
  42022. /**
  42023. * Creates a new counter
  42024. */
  42025. constructor();
  42026. /**
  42027. * Call this method to start monitoring a new frame.
  42028. * 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.
  42029. */
  42030. fetchNewFrame(): void;
  42031. /**
  42032. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42033. * @param newCount the count value to add to the monitored count
  42034. * @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.
  42035. */
  42036. addCount(newCount: number, fetchResult: boolean): void;
  42037. /**
  42038. * Start monitoring this performance counter
  42039. */
  42040. beginMonitoring(): void;
  42041. /**
  42042. * Compute the time lapsed since the previous beginMonitoring() call.
  42043. * @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
  42044. */
  42045. endMonitoring(newFrame?: boolean): void;
  42046. private _fetchResult;
  42047. private _startMonitoringTime;
  42048. private _min;
  42049. private _max;
  42050. private _average;
  42051. private _current;
  42052. private _totalValueCount;
  42053. private _totalAccumulated;
  42054. private _lastSecAverage;
  42055. private _lastSecAccumulated;
  42056. private _lastSecTime;
  42057. private _lastSecValueCount;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. interface ThinEngine {
  42062. /** @hidden */
  42063. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42064. /** @hidden */
  42065. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42066. }
  42067. }
  42068. declare module BABYLON {
  42069. /**
  42070. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42072. */
  42073. export class Analyser {
  42074. /**
  42075. * Gets or sets the smoothing
  42076. * @ignorenaming
  42077. */
  42078. SMOOTHING: number;
  42079. /**
  42080. * Gets or sets the FFT table size
  42081. * @ignorenaming
  42082. */
  42083. FFT_SIZE: number;
  42084. /**
  42085. * Gets or sets the bar graph amplitude
  42086. * @ignorenaming
  42087. */
  42088. BARGRAPHAMPLITUDE: number;
  42089. /**
  42090. * Gets or sets the position of the debug canvas
  42091. * @ignorenaming
  42092. */
  42093. DEBUGCANVASPOS: {
  42094. x: number;
  42095. y: number;
  42096. };
  42097. /**
  42098. * Gets or sets the debug canvas size
  42099. * @ignorenaming
  42100. */
  42101. DEBUGCANVASSIZE: {
  42102. width: number;
  42103. height: number;
  42104. };
  42105. private _byteFreqs;
  42106. private _byteTime;
  42107. private _floatFreqs;
  42108. private _webAudioAnalyser;
  42109. private _debugCanvas;
  42110. private _debugCanvasContext;
  42111. private _scene;
  42112. private _registerFunc;
  42113. private _audioEngine;
  42114. /**
  42115. * Creates a new analyser
  42116. * @param scene defines hosting scene
  42117. */
  42118. constructor(scene: Scene);
  42119. /**
  42120. * Get the number of data values you will have to play with for the visualization
  42121. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42122. * @returns a number
  42123. */
  42124. getFrequencyBinCount(): number;
  42125. /**
  42126. * Gets the current frequency data as a byte array
  42127. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42128. * @returns a Uint8Array
  42129. */
  42130. getByteFrequencyData(): Uint8Array;
  42131. /**
  42132. * Gets the current waveform as a byte array
  42133. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42134. * @returns a Uint8Array
  42135. */
  42136. getByteTimeDomainData(): Uint8Array;
  42137. /**
  42138. * Gets the current frequency data as a float array
  42139. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42140. * @returns a Float32Array
  42141. */
  42142. getFloatFrequencyData(): Float32Array;
  42143. /**
  42144. * Renders the debug canvas
  42145. */
  42146. drawDebugCanvas(): void;
  42147. /**
  42148. * Stops rendering the debug canvas and removes it
  42149. */
  42150. stopDebugCanvas(): void;
  42151. /**
  42152. * Connects two audio nodes
  42153. * @param inputAudioNode defines first node to connect
  42154. * @param outputAudioNode defines second node to connect
  42155. */
  42156. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42157. /**
  42158. * Releases all associated resources
  42159. */
  42160. dispose(): void;
  42161. }
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * This represents an audio engine and it is responsible
  42166. * to play, synchronize and analyse sounds throughout the application.
  42167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42168. */
  42169. export interface IAudioEngine extends IDisposable {
  42170. /**
  42171. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42172. */
  42173. readonly canUseWebAudio: boolean;
  42174. /**
  42175. * Gets the current AudioContext if available.
  42176. */
  42177. readonly audioContext: Nullable<AudioContext>;
  42178. /**
  42179. * The master gain node defines the global audio volume of your audio engine.
  42180. */
  42181. readonly masterGain: GainNode;
  42182. /**
  42183. * Gets whether or not mp3 are supported by your browser.
  42184. */
  42185. readonly isMP3supported: boolean;
  42186. /**
  42187. * Gets whether or not ogg are supported by your browser.
  42188. */
  42189. readonly isOGGsupported: boolean;
  42190. /**
  42191. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42192. * @ignoreNaming
  42193. */
  42194. WarnedWebAudioUnsupported: boolean;
  42195. /**
  42196. * Defines if the audio engine relies on a custom unlocked button.
  42197. * In this case, the embedded button will not be displayed.
  42198. */
  42199. useCustomUnlockedButton: boolean;
  42200. /**
  42201. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42202. */
  42203. readonly unlocked: boolean;
  42204. /**
  42205. * Event raised when audio has been unlocked on the browser.
  42206. */
  42207. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42208. /**
  42209. * Event raised when audio has been locked on the browser.
  42210. */
  42211. onAudioLockedObservable: Observable<IAudioEngine>;
  42212. /**
  42213. * Flags the audio engine in Locked state.
  42214. * This happens due to new browser policies preventing audio to autoplay.
  42215. */
  42216. lock(): void;
  42217. /**
  42218. * Unlocks the audio engine once a user action has been done on the dom.
  42219. * This is helpful to resume play once browser policies have been satisfied.
  42220. */
  42221. unlock(): void;
  42222. /**
  42223. * Gets the global volume sets on the master gain.
  42224. * @returns the global volume if set or -1 otherwise
  42225. */
  42226. getGlobalVolume(): number;
  42227. /**
  42228. * Sets the global volume of your experience (sets on the master gain).
  42229. * @param newVolume Defines the new global volume of the application
  42230. */
  42231. setGlobalVolume(newVolume: number): void;
  42232. /**
  42233. * Connect the audio engine to an audio analyser allowing some amazing
  42234. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42236. * @param analyser The analyser to connect to the engine
  42237. */
  42238. connectToAnalyser(analyser: Analyser): void;
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * Defines the interface used by display changed events
  42244. */
  42245. export interface IDisplayChangedEventArgs {
  42246. /** Gets the vrDisplay object (if any) */
  42247. vrDisplay: Nullable<any>;
  42248. /** Gets a boolean indicating if webVR is supported */
  42249. vrSupported: boolean;
  42250. }
  42251. /**
  42252. * Defines the interface used by objects containing a viewport (like a camera)
  42253. */
  42254. interface IViewportOwnerLike {
  42255. /**
  42256. * Gets or sets the viewport
  42257. */
  42258. viewport: IViewportLike;
  42259. }
  42260. /**
  42261. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42262. */
  42263. export class Engine extends ThinEngine {
  42264. /** Defines that alpha blending is disabled */
  42265. static readonly ALPHA_DISABLE: number;
  42266. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42267. static readonly ALPHA_ADD: number;
  42268. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42269. static readonly ALPHA_COMBINE: number;
  42270. /** Defines that alpha blending to DEST - SRC * DEST */
  42271. static readonly ALPHA_SUBTRACT: number;
  42272. /** Defines that alpha blending to SRC * DEST */
  42273. static readonly ALPHA_MULTIPLY: number;
  42274. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42275. static readonly ALPHA_MAXIMIZED: number;
  42276. /** Defines that alpha blending to SRC + DEST */
  42277. static readonly ALPHA_ONEONE: number;
  42278. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42279. static readonly ALPHA_PREMULTIPLIED: number;
  42280. /**
  42281. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42282. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42283. */
  42284. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42285. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42286. static readonly ALPHA_INTERPOLATE: number;
  42287. /**
  42288. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42289. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42290. */
  42291. static readonly ALPHA_SCREENMODE: number;
  42292. /** Defines that the resource is not delayed*/
  42293. static readonly DELAYLOADSTATE_NONE: number;
  42294. /** Defines that the resource was successfully delay loaded */
  42295. static readonly DELAYLOADSTATE_LOADED: number;
  42296. /** Defines that the resource is currently delay loading */
  42297. static readonly DELAYLOADSTATE_LOADING: number;
  42298. /** Defines that the resource is delayed and has not started loading */
  42299. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42301. static readonly NEVER: number;
  42302. /** 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 */
  42303. static readonly ALWAYS: number;
  42304. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42305. static readonly LESS: number;
  42306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42307. static readonly EQUAL: number;
  42308. /** 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 */
  42309. static readonly LEQUAL: number;
  42310. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42311. static readonly GREATER: number;
  42312. /** 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 */
  42313. static readonly GEQUAL: number;
  42314. /** 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 */
  42315. static readonly NOTEQUAL: number;
  42316. /** Passed to stencilOperation to specify that stencil value must be kept */
  42317. static readonly KEEP: number;
  42318. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42319. static readonly REPLACE: number;
  42320. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42321. static readonly INCR: number;
  42322. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42323. static readonly DECR: number;
  42324. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42325. static readonly INVERT: number;
  42326. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42327. static readonly INCR_WRAP: number;
  42328. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42329. static readonly DECR_WRAP: number;
  42330. /** Texture is not repeating outside of 0..1 UVs */
  42331. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42332. /** Texture is repeating outside of 0..1 UVs */
  42333. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42334. /** Texture is repeating and mirrored */
  42335. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42336. /** ALPHA */
  42337. static readonly TEXTUREFORMAT_ALPHA: number;
  42338. /** LUMINANCE */
  42339. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42340. /** LUMINANCE_ALPHA */
  42341. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42342. /** RGB */
  42343. static readonly TEXTUREFORMAT_RGB: number;
  42344. /** RGBA */
  42345. static readonly TEXTUREFORMAT_RGBA: number;
  42346. /** RED */
  42347. static readonly TEXTUREFORMAT_RED: number;
  42348. /** RED (2nd reference) */
  42349. static readonly TEXTUREFORMAT_R: number;
  42350. /** RG */
  42351. static readonly TEXTUREFORMAT_RG: number;
  42352. /** RED_INTEGER */
  42353. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42354. /** RED_INTEGER (2nd reference) */
  42355. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42356. /** RG_INTEGER */
  42357. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42358. /** RGB_INTEGER */
  42359. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42360. /** RGBA_INTEGER */
  42361. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42362. /** UNSIGNED_BYTE */
  42363. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42364. /** UNSIGNED_BYTE (2nd reference) */
  42365. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42366. /** FLOAT */
  42367. static readonly TEXTURETYPE_FLOAT: number;
  42368. /** HALF_FLOAT */
  42369. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42370. /** BYTE */
  42371. static readonly TEXTURETYPE_BYTE: number;
  42372. /** SHORT */
  42373. static readonly TEXTURETYPE_SHORT: number;
  42374. /** UNSIGNED_SHORT */
  42375. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42376. /** INT */
  42377. static readonly TEXTURETYPE_INT: number;
  42378. /** UNSIGNED_INT */
  42379. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42380. /** UNSIGNED_SHORT_4_4_4_4 */
  42381. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42382. /** UNSIGNED_SHORT_5_5_5_1 */
  42383. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42384. /** UNSIGNED_SHORT_5_6_5 */
  42385. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42386. /** UNSIGNED_INT_2_10_10_10_REV */
  42387. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42388. /** UNSIGNED_INT_24_8 */
  42389. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42390. /** UNSIGNED_INT_10F_11F_11F_REV */
  42391. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42392. /** UNSIGNED_INT_5_9_9_9_REV */
  42393. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42394. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42395. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42396. /** nearest is mag = nearest and min = nearest and mip = none */
  42397. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42399. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42400. /** Trilinear is mag = linear and min = linear and mip = linear */
  42401. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42402. /** nearest is mag = nearest and min = nearest and mip = linear */
  42403. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42405. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42406. /** Trilinear is mag = linear and min = linear and mip = linear */
  42407. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42408. /** mag = nearest and min = nearest and mip = nearest */
  42409. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42410. /** mag = nearest and min = linear and mip = nearest */
  42411. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42412. /** mag = nearest and min = linear and mip = linear */
  42413. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42414. /** mag = nearest and min = linear and mip = none */
  42415. static readonly TEXTURE_NEAREST_LINEAR: number;
  42416. /** mag = nearest and min = nearest and mip = none */
  42417. static readonly TEXTURE_NEAREST_NEAREST: number;
  42418. /** mag = linear and min = nearest and mip = nearest */
  42419. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42420. /** mag = linear and min = nearest and mip = linear */
  42421. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42422. /** mag = linear and min = linear and mip = none */
  42423. static readonly TEXTURE_LINEAR_LINEAR: number;
  42424. /** mag = linear and min = nearest and mip = none */
  42425. static readonly TEXTURE_LINEAR_NEAREST: number;
  42426. /** Explicit coordinates mode */
  42427. static readonly TEXTURE_EXPLICIT_MODE: number;
  42428. /** Spherical coordinates mode */
  42429. static readonly TEXTURE_SPHERICAL_MODE: number;
  42430. /** Planar coordinates mode */
  42431. static readonly TEXTURE_PLANAR_MODE: number;
  42432. /** Cubic coordinates mode */
  42433. static readonly TEXTURE_CUBIC_MODE: number;
  42434. /** Projection coordinates mode */
  42435. static readonly TEXTURE_PROJECTION_MODE: number;
  42436. /** Skybox coordinates mode */
  42437. static readonly TEXTURE_SKYBOX_MODE: number;
  42438. /** Inverse Cubic coordinates mode */
  42439. static readonly TEXTURE_INVCUBIC_MODE: number;
  42440. /** Equirectangular coordinates mode */
  42441. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42442. /** Equirectangular Fixed coordinates mode */
  42443. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42444. /** Equirectangular Fixed Mirrored coordinates mode */
  42445. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42446. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42447. static readonly SCALEMODE_FLOOR: number;
  42448. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42449. static readonly SCALEMODE_NEAREST: number;
  42450. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42451. static readonly SCALEMODE_CEILING: number;
  42452. /**
  42453. * Returns the current npm package of the sdk
  42454. */
  42455. static get NpmPackage(): string;
  42456. /**
  42457. * Returns the current version of the framework
  42458. */
  42459. static get Version(): string;
  42460. /** Gets the list of created engines */
  42461. static get Instances(): Engine[];
  42462. /**
  42463. * Gets the latest created engine
  42464. */
  42465. static get LastCreatedEngine(): Nullable<Engine>;
  42466. /**
  42467. * Gets the latest created scene
  42468. */
  42469. static get LastCreatedScene(): Nullable<Scene>;
  42470. /**
  42471. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42472. * @param flag defines which part of the materials must be marked as dirty
  42473. * @param predicate defines a predicate used to filter which materials should be affected
  42474. */
  42475. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42476. /**
  42477. * Method called to create the default loading screen.
  42478. * This can be overridden in your own app.
  42479. * @param canvas The rendering canvas element
  42480. * @returns The loading screen
  42481. */
  42482. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42483. /**
  42484. * Method called to create the default rescale post process on each engine.
  42485. */
  42486. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42487. /**
  42488. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42489. **/
  42490. enableOfflineSupport: boolean;
  42491. /**
  42492. * 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)
  42493. **/
  42494. disableManifestCheck: boolean;
  42495. /**
  42496. * Gets the list of created scenes
  42497. */
  42498. scenes: Scene[];
  42499. /**
  42500. * Event raised when a new scene is created
  42501. */
  42502. onNewSceneAddedObservable: Observable<Scene>;
  42503. /**
  42504. * Gets the list of created postprocesses
  42505. */
  42506. postProcesses: PostProcess[];
  42507. /**
  42508. * Gets a boolean indicating if the pointer is currently locked
  42509. */
  42510. isPointerLock: boolean;
  42511. /**
  42512. * Observable event triggered each time the rendering canvas is resized
  42513. */
  42514. onResizeObservable: Observable<Engine>;
  42515. /**
  42516. * Observable event triggered each time the canvas loses focus
  42517. */
  42518. onCanvasBlurObservable: Observable<Engine>;
  42519. /**
  42520. * Observable event triggered each time the canvas gains focus
  42521. */
  42522. onCanvasFocusObservable: Observable<Engine>;
  42523. /**
  42524. * Observable event triggered each time the canvas receives pointerout event
  42525. */
  42526. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42527. /**
  42528. * Observable raised when the engine begins a new frame
  42529. */
  42530. onBeginFrameObservable: Observable<Engine>;
  42531. /**
  42532. * If set, will be used to request the next animation frame for the render loop
  42533. */
  42534. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42535. /**
  42536. * Observable raised when the engine ends the current frame
  42537. */
  42538. onEndFrameObservable: Observable<Engine>;
  42539. /**
  42540. * Observable raised when the engine is about to compile a shader
  42541. */
  42542. onBeforeShaderCompilationObservable: Observable<Engine>;
  42543. /**
  42544. * Observable raised when the engine has just compiled a shader
  42545. */
  42546. onAfterShaderCompilationObservable: Observable<Engine>;
  42547. /**
  42548. * Gets the audio engine
  42549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42550. * @ignorenaming
  42551. */
  42552. static audioEngine: IAudioEngine;
  42553. /**
  42554. * Default AudioEngine factory responsible of creating the Audio Engine.
  42555. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42556. */
  42557. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42558. /**
  42559. * Default offline support factory responsible of creating a tool used to store data locally.
  42560. * By default, this will create a Database object if the workload has been embedded.
  42561. */
  42562. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42563. private _loadingScreen;
  42564. private _pointerLockRequested;
  42565. private _rescalePostProcess;
  42566. protected _deterministicLockstep: boolean;
  42567. protected _lockstepMaxSteps: number;
  42568. protected _timeStep: number;
  42569. protected get _supportsHardwareTextureRescaling(): boolean;
  42570. private _fps;
  42571. private _deltaTime;
  42572. /** @hidden */
  42573. _drawCalls: PerfCounter;
  42574. /** 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 */
  42575. canvasTabIndex: number;
  42576. /**
  42577. * Turn this value on if you want to pause FPS computation when in background
  42578. */
  42579. disablePerformanceMonitorInBackground: boolean;
  42580. private _performanceMonitor;
  42581. /**
  42582. * Gets the performance monitor attached to this engine
  42583. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42584. */
  42585. get performanceMonitor(): PerformanceMonitor;
  42586. private _onFocus;
  42587. private _onBlur;
  42588. private _onCanvasPointerOut;
  42589. private _onCanvasBlur;
  42590. private _onCanvasFocus;
  42591. private _onFullscreenChange;
  42592. private _onPointerLockChange;
  42593. /**
  42594. * Gets the HTML element used to attach event listeners
  42595. * @returns a HTML element
  42596. */
  42597. getInputElement(): Nullable<HTMLElement>;
  42598. /**
  42599. * Creates a new engine
  42600. * @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
  42601. * @param antialias defines enable antialiasing (default: false)
  42602. * @param options defines further options to be sent to the getContext() function
  42603. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42604. */
  42605. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42606. /**
  42607. * Shared initialization across engines types.
  42608. * @param canvas The canvas associated with this instance of the engine.
  42609. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42610. * @param audioEngine Defines if an audio engine should be created by default
  42611. */
  42612. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42613. /**
  42614. * Gets current aspect ratio
  42615. * @param viewportOwner defines the camera to use to get the aspect ratio
  42616. * @param useScreen defines if screen size must be used (or the current render target if any)
  42617. * @returns a number defining the aspect ratio
  42618. */
  42619. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42620. /**
  42621. * Gets current screen aspect ratio
  42622. * @returns a number defining the aspect ratio
  42623. */
  42624. getScreenAspectRatio(): number;
  42625. /**
  42626. * Gets the client rect of the HTML canvas attached with the current webGL context
  42627. * @returns a client rectangle
  42628. */
  42629. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42630. /**
  42631. * Gets the client rect of the HTML element used for events
  42632. * @returns a client rectangle
  42633. */
  42634. getInputElementClientRect(): Nullable<ClientRect>;
  42635. /**
  42636. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42637. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42638. * @returns true if engine is in deterministic lock step mode
  42639. */
  42640. isDeterministicLockStep(): boolean;
  42641. /**
  42642. * Gets the max steps when engine is running in deterministic lock step
  42643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42644. * @returns the max steps
  42645. */
  42646. getLockstepMaxSteps(): number;
  42647. /**
  42648. * Returns the time in ms between steps when using deterministic lock step.
  42649. * @returns time step in (ms)
  42650. */
  42651. getTimeStep(): number;
  42652. /**
  42653. * Force the mipmap generation for the given render target texture
  42654. * @param texture defines the render target texture to use
  42655. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42656. */
  42657. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42658. /** States */
  42659. /**
  42660. * Set various states to the webGL context
  42661. * @param culling defines backface culling state
  42662. * @param zOffset defines the value to apply to zOffset (0 by default)
  42663. * @param force defines if states must be applied even if cache is up to date
  42664. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42665. */
  42666. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42667. /**
  42668. * Set the z offset to apply to current rendering
  42669. * @param value defines the offset to apply
  42670. */
  42671. setZOffset(value: number): void;
  42672. /**
  42673. * Gets the current value of the zOffset
  42674. * @returns the current zOffset state
  42675. */
  42676. getZOffset(): number;
  42677. /**
  42678. * Gets a boolean indicating if depth testing is enabled
  42679. * @returns the current state
  42680. */
  42681. getDepthBuffer(): boolean;
  42682. /**
  42683. * Enable or disable depth buffering
  42684. * @param enable defines the state to set
  42685. */
  42686. setDepthBuffer(enable: boolean): void;
  42687. /**
  42688. * Gets a boolean indicating if depth writing is enabled
  42689. * @returns the current depth writing state
  42690. */
  42691. getDepthWrite(): boolean;
  42692. /**
  42693. * Enable or disable depth writing
  42694. * @param enable defines the state to set
  42695. */
  42696. setDepthWrite(enable: boolean): void;
  42697. /**
  42698. * Gets a boolean indicating if stencil buffer is enabled
  42699. * @returns the current stencil buffer state
  42700. */
  42701. getStencilBuffer(): boolean;
  42702. /**
  42703. * Enable or disable the stencil buffer
  42704. * @param enable defines if the stencil buffer must be enabled or disabled
  42705. */
  42706. setStencilBuffer(enable: boolean): void;
  42707. /**
  42708. * Gets the current stencil mask
  42709. * @returns a number defining the new stencil mask to use
  42710. */
  42711. getStencilMask(): number;
  42712. /**
  42713. * Sets the current stencil mask
  42714. * @param mask defines the new stencil mask to use
  42715. */
  42716. setStencilMask(mask: number): void;
  42717. /**
  42718. * Gets the current stencil function
  42719. * @returns a number defining the stencil function to use
  42720. */
  42721. getStencilFunction(): number;
  42722. /**
  42723. * Gets the current stencil reference value
  42724. * @returns a number defining the stencil reference value to use
  42725. */
  42726. getStencilFunctionReference(): number;
  42727. /**
  42728. * Gets the current stencil mask
  42729. * @returns a number defining the stencil mask to use
  42730. */
  42731. getStencilFunctionMask(): number;
  42732. /**
  42733. * Sets the current stencil function
  42734. * @param stencilFunc defines the new stencil function to use
  42735. */
  42736. setStencilFunction(stencilFunc: number): void;
  42737. /**
  42738. * Sets the current stencil reference
  42739. * @param reference defines the new stencil reference to use
  42740. */
  42741. setStencilFunctionReference(reference: number): void;
  42742. /**
  42743. * Sets the current stencil mask
  42744. * @param mask defines the new stencil mask to use
  42745. */
  42746. setStencilFunctionMask(mask: number): void;
  42747. /**
  42748. * Gets the current stencil operation when stencil fails
  42749. * @returns a number defining stencil operation to use when stencil fails
  42750. */
  42751. getStencilOperationFail(): number;
  42752. /**
  42753. * Gets the current stencil operation when depth fails
  42754. * @returns a number defining stencil operation to use when depth fails
  42755. */
  42756. getStencilOperationDepthFail(): number;
  42757. /**
  42758. * Gets the current stencil operation when stencil passes
  42759. * @returns a number defining stencil operation to use when stencil passes
  42760. */
  42761. getStencilOperationPass(): number;
  42762. /**
  42763. * Sets the stencil operation to use when stencil fails
  42764. * @param operation defines the stencil operation to use when stencil fails
  42765. */
  42766. setStencilOperationFail(operation: number): void;
  42767. /**
  42768. * Sets the stencil operation to use when depth fails
  42769. * @param operation defines the stencil operation to use when depth fails
  42770. */
  42771. setStencilOperationDepthFail(operation: number): void;
  42772. /**
  42773. * Sets the stencil operation to use when stencil passes
  42774. * @param operation defines the stencil operation to use when stencil passes
  42775. */
  42776. setStencilOperationPass(operation: number): void;
  42777. /**
  42778. * Sets a boolean indicating if the dithering state is enabled or disabled
  42779. * @param value defines the dithering state
  42780. */
  42781. setDitheringState(value: boolean): void;
  42782. /**
  42783. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42784. * @param value defines the rasterizer state
  42785. */
  42786. setRasterizerState(value: boolean): void;
  42787. /**
  42788. * Gets the current depth function
  42789. * @returns a number defining the depth function
  42790. */
  42791. getDepthFunction(): Nullable<number>;
  42792. /**
  42793. * Sets the current depth function
  42794. * @param depthFunc defines the function to use
  42795. */
  42796. setDepthFunction(depthFunc: number): void;
  42797. /**
  42798. * Sets the current depth function to GREATER
  42799. */
  42800. setDepthFunctionToGreater(): void;
  42801. /**
  42802. * Sets the current depth function to GEQUAL
  42803. */
  42804. setDepthFunctionToGreaterOrEqual(): void;
  42805. /**
  42806. * Sets the current depth function to LESS
  42807. */
  42808. setDepthFunctionToLess(): void;
  42809. /**
  42810. * Sets the current depth function to LEQUAL
  42811. */
  42812. setDepthFunctionToLessOrEqual(): void;
  42813. private _cachedStencilBuffer;
  42814. private _cachedStencilFunction;
  42815. private _cachedStencilMask;
  42816. private _cachedStencilOperationPass;
  42817. private _cachedStencilOperationFail;
  42818. private _cachedStencilOperationDepthFail;
  42819. private _cachedStencilReference;
  42820. /**
  42821. * Caches the the state of the stencil buffer
  42822. */
  42823. cacheStencilState(): void;
  42824. /**
  42825. * Restores the state of the stencil buffer
  42826. */
  42827. restoreStencilState(): void;
  42828. /**
  42829. * Directly set the WebGL Viewport
  42830. * @param x defines the x coordinate of the viewport (in screen space)
  42831. * @param y defines the y coordinate of the viewport (in screen space)
  42832. * @param width defines the width of the viewport (in screen space)
  42833. * @param height defines the height of the viewport (in screen space)
  42834. * @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
  42835. */
  42836. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42837. /**
  42838. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42839. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42840. * @param y defines the y-coordinate of the corner of the clear rectangle
  42841. * @param width defines the width of the clear rectangle
  42842. * @param height defines the height of the clear rectangle
  42843. * @param clearColor defines the clear color
  42844. */
  42845. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42846. /**
  42847. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42848. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42849. * @param y defines the y-coordinate of the corner of the clear rectangle
  42850. * @param width defines the width of the clear rectangle
  42851. * @param height defines the height of the clear rectangle
  42852. */
  42853. enableScissor(x: number, y: number, width: number, height: number): void;
  42854. /**
  42855. * Disable previously set scissor test rectangle
  42856. */
  42857. disableScissor(): void;
  42858. protected _reportDrawCall(): void;
  42859. /**
  42860. * Initializes a webVR display and starts listening to display change events
  42861. * The onVRDisplayChangedObservable will be notified upon these changes
  42862. * @returns The onVRDisplayChangedObservable
  42863. */
  42864. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42865. /** @hidden */
  42866. _prepareVRComponent(): void;
  42867. /** @hidden */
  42868. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42869. /** @hidden */
  42870. _submitVRFrame(): void;
  42871. /**
  42872. * Call this function to leave webVR mode
  42873. * Will do nothing if webVR is not supported or if there is no webVR device
  42874. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42875. */
  42876. disableVR(): void;
  42877. /**
  42878. * Gets a boolean indicating that the system is in VR mode and is presenting
  42879. * @returns true if VR mode is engaged
  42880. */
  42881. isVRPresenting(): boolean;
  42882. /** @hidden */
  42883. _requestVRFrame(): void;
  42884. /** @hidden */
  42885. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42886. /**
  42887. * Gets the source code of the vertex shader associated with a specific webGL program
  42888. * @param program defines the program to use
  42889. * @returns a string containing the source code of the vertex shader associated with the program
  42890. */
  42891. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42892. /**
  42893. * Gets the source code of the fragment shader associated with a specific webGL program
  42894. * @param program defines the program to use
  42895. * @returns a string containing the source code of the fragment shader associated with the program
  42896. */
  42897. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42898. /**
  42899. * Sets a depth stencil texture from a render target to the according uniform.
  42900. * @param channel The texture channel
  42901. * @param uniform The uniform to set
  42902. * @param texture The render target texture containing the depth stencil texture to apply
  42903. * @param name The texture name
  42904. */
  42905. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42906. /**
  42907. * Sets a texture to the webGL context from a postprocess
  42908. * @param channel defines the channel to use
  42909. * @param postProcess defines the source postprocess
  42910. * @param name name of the channel
  42911. */
  42912. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42913. /**
  42914. * Binds the output of the passed in post process to the texture channel specified
  42915. * @param channel The channel the texture should be bound to
  42916. * @param postProcess The post process which's output should be bound
  42917. * @param name name of the channel
  42918. */
  42919. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42920. protected _rebuildBuffers(): void;
  42921. /** @hidden */
  42922. _renderFrame(): void;
  42923. _renderLoop(): void;
  42924. /** @hidden */
  42925. _renderViews(): boolean;
  42926. /**
  42927. * Toggle full screen mode
  42928. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42929. */
  42930. switchFullscreen(requestPointerLock: boolean): void;
  42931. /**
  42932. * Enters full screen mode
  42933. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42934. */
  42935. enterFullscreen(requestPointerLock: boolean): void;
  42936. /**
  42937. * Exits full screen mode
  42938. */
  42939. exitFullscreen(): void;
  42940. /**
  42941. * Enters Pointerlock mode
  42942. */
  42943. enterPointerlock(): void;
  42944. /**
  42945. * Exits Pointerlock mode
  42946. */
  42947. exitPointerlock(): void;
  42948. /**
  42949. * Begin a new frame
  42950. */
  42951. beginFrame(): void;
  42952. /**
  42953. * End the current frame
  42954. */
  42955. endFrame(): void;
  42956. /**
  42957. * Resize the view according to the canvas' size
  42958. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42959. */
  42960. resize(forceSetSize?: boolean): void;
  42961. /**
  42962. * Force a specific size of the canvas
  42963. * @param width defines the new canvas' width
  42964. * @param height defines the new canvas' height
  42965. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42966. * @returns true if the size was changed
  42967. */
  42968. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42969. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42971. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42972. _releaseTexture(texture: InternalTexture): void;
  42973. /**
  42974. * @hidden
  42975. * Rescales a texture
  42976. * @param source input texture
  42977. * @param destination destination texture
  42978. * @param scene scene to use to render the resize
  42979. * @param internalFormat format to use when resizing
  42980. * @param onComplete callback to be called when resize has completed
  42981. */
  42982. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42983. /**
  42984. * Gets the current framerate
  42985. * @returns a number representing the framerate
  42986. */
  42987. getFps(): number;
  42988. /**
  42989. * Gets the time spent between current and previous frame
  42990. * @returns a number representing the delta time in ms
  42991. */
  42992. getDeltaTime(): number;
  42993. private _measureFps;
  42994. /** @hidden */
  42995. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42996. /**
  42997. * Updates the sample count of a render target texture
  42998. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42999. * @param texture defines the texture to update
  43000. * @param samples defines the sample count to set
  43001. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43002. */
  43003. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43004. /**
  43005. * Updates a depth texture Comparison Mode and Function.
  43006. * If the comparison Function is equal to 0, the mode will be set to none.
  43007. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43008. * @param texture The texture to set the comparison function for
  43009. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43010. */
  43011. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43012. /**
  43013. * Creates a webGL buffer to use with instantiation
  43014. * @param capacity defines the size of the buffer
  43015. * @returns the webGL buffer
  43016. */
  43017. createInstancesBuffer(capacity: number): DataBuffer;
  43018. /**
  43019. * Delete a webGL buffer used with instantiation
  43020. * @param buffer defines the webGL buffer to delete
  43021. */
  43022. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43023. private _clientWaitAsync;
  43024. /** @hidden */
  43025. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43026. dispose(): void;
  43027. private _disableTouchAction;
  43028. /**
  43029. * Display the loading screen
  43030. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43031. */
  43032. displayLoadingUI(): void;
  43033. /**
  43034. * Hide the loading screen
  43035. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43036. */
  43037. hideLoadingUI(): void;
  43038. /**
  43039. * Gets the current loading screen object
  43040. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43041. */
  43042. get loadingScreen(): ILoadingScreen;
  43043. /**
  43044. * Sets the current loading screen object
  43045. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43046. */
  43047. set loadingScreen(loadingScreen: ILoadingScreen);
  43048. /**
  43049. * Sets the current loading screen text
  43050. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43051. */
  43052. set loadingUIText(text: string);
  43053. /**
  43054. * Sets the current loading screen background color
  43055. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43056. */
  43057. set loadingUIBackgroundColor(color: string);
  43058. /** Pointerlock and fullscreen */
  43059. /**
  43060. * Ask the browser to promote the current element to pointerlock mode
  43061. * @param element defines the DOM element to promote
  43062. */
  43063. static _RequestPointerlock(element: HTMLElement): void;
  43064. /**
  43065. * Asks the browser to exit pointerlock mode
  43066. */
  43067. static _ExitPointerlock(): void;
  43068. /**
  43069. * Ask the browser to promote the current element to fullscreen rendering mode
  43070. * @param element defines the DOM element to promote
  43071. */
  43072. static _RequestFullscreen(element: HTMLElement): void;
  43073. /**
  43074. * Asks the browser to exit fullscreen mode
  43075. */
  43076. static _ExitFullscreen(): void;
  43077. }
  43078. }
  43079. declare module BABYLON {
  43080. /**
  43081. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43082. * during the life time of the application.
  43083. */
  43084. export class EngineStore {
  43085. /** Gets the list of created engines */
  43086. static Instances: Engine[];
  43087. /** @hidden */
  43088. static _LastCreatedScene: Nullable<Scene>;
  43089. /**
  43090. * Gets the latest created engine
  43091. */
  43092. static get LastCreatedEngine(): Nullable<Engine>;
  43093. /**
  43094. * Gets the latest created scene
  43095. */
  43096. static get LastCreatedScene(): Nullable<Scene>;
  43097. /**
  43098. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43099. * @ignorenaming
  43100. */
  43101. static UseFallbackTexture: boolean;
  43102. /**
  43103. * Texture content used if a texture cannot loaded
  43104. * @ignorenaming
  43105. */
  43106. static FallbackTexture: string;
  43107. }
  43108. }
  43109. declare module BABYLON {
  43110. /**
  43111. * Helper class that provides a small promise polyfill
  43112. */
  43113. export class PromisePolyfill {
  43114. /**
  43115. * Static function used to check if the polyfill is required
  43116. * If this is the case then the function will inject the polyfill to window.Promise
  43117. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43118. */
  43119. static Apply(force?: boolean): void;
  43120. }
  43121. }
  43122. declare module BABYLON {
  43123. /**
  43124. * Interface for screenshot methods with describe argument called `size` as object with options
  43125. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43126. */
  43127. export interface IScreenshotSize {
  43128. /**
  43129. * number in pixels for canvas height
  43130. */
  43131. height?: number;
  43132. /**
  43133. * multiplier allowing render at a higher or lower resolution
  43134. * If value is defined then height and width will be ignored and taken from camera
  43135. */
  43136. precision?: number;
  43137. /**
  43138. * number in pixels for canvas width
  43139. */
  43140. width?: number;
  43141. }
  43142. }
  43143. declare module BABYLON {
  43144. interface IColor4Like {
  43145. r: float;
  43146. g: float;
  43147. b: float;
  43148. a: float;
  43149. }
  43150. /**
  43151. * Class containing a set of static utilities functions
  43152. */
  43153. export class Tools {
  43154. /**
  43155. * Gets or sets the base URL to use to load assets
  43156. */
  43157. static get BaseUrl(): string;
  43158. static set BaseUrl(value: string);
  43159. /**
  43160. * Enable/Disable Custom HTTP Request Headers globally.
  43161. * default = false
  43162. * @see CustomRequestHeaders
  43163. */
  43164. static UseCustomRequestHeaders: boolean;
  43165. /**
  43166. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43167. * i.e. when loading files, where the server/service expects an Authorization header
  43168. */
  43169. static CustomRequestHeaders: {
  43170. [key: string]: string;
  43171. };
  43172. /**
  43173. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43174. */
  43175. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43176. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43177. /**
  43178. * Default behaviour for cors in the application.
  43179. * It can be a string if the expected behavior is identical in the entire app.
  43180. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43181. */
  43182. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43183. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43184. /**
  43185. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43186. * @ignorenaming
  43187. */
  43188. static get UseFallbackTexture(): boolean;
  43189. static set UseFallbackTexture(value: boolean);
  43190. /**
  43191. * Use this object to register external classes like custom textures or material
  43192. * to allow the loaders to instantiate them
  43193. */
  43194. static get RegisteredExternalClasses(): {
  43195. [key: string]: Object;
  43196. };
  43197. static set RegisteredExternalClasses(classes: {
  43198. [key: string]: Object;
  43199. });
  43200. /**
  43201. * Texture content used if a texture cannot loaded
  43202. * @ignorenaming
  43203. */
  43204. static get fallbackTexture(): string;
  43205. static set fallbackTexture(value: string);
  43206. /**
  43207. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43208. * @param u defines the coordinate on X axis
  43209. * @param v defines the coordinate on Y axis
  43210. * @param width defines the width of the source data
  43211. * @param height defines the height of the source data
  43212. * @param pixels defines the source byte array
  43213. * @param color defines the output color
  43214. */
  43215. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43216. /**
  43217. * Interpolates between a and b via alpha
  43218. * @param a The lower value (returned when alpha = 0)
  43219. * @param b The upper value (returned when alpha = 1)
  43220. * @param alpha The interpolation-factor
  43221. * @return The mixed value
  43222. */
  43223. static Mix(a: number, b: number, alpha: number): number;
  43224. /**
  43225. * Tries to instantiate a new object from a given class name
  43226. * @param className defines the class name to instantiate
  43227. * @returns the new object or null if the system was not able to do the instantiation
  43228. */
  43229. static Instantiate(className: string): any;
  43230. /**
  43231. * Provides a slice function that will work even on IE
  43232. * @param data defines the array to slice
  43233. * @param start defines the start of the data (optional)
  43234. * @param end defines the end of the data (optional)
  43235. * @returns the new sliced array
  43236. */
  43237. static Slice<T>(data: T, start?: number, end?: number): T;
  43238. /**
  43239. * Provides a slice function that will work even on IE
  43240. * The difference between this and Slice is that this will force-convert to array
  43241. * @param data defines the array to slice
  43242. * @param start defines the start of the data (optional)
  43243. * @param end defines the end of the data (optional)
  43244. * @returns the new sliced array
  43245. */
  43246. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43247. /**
  43248. * Polyfill for setImmediate
  43249. * @param action defines the action to execute after the current execution block
  43250. */
  43251. static SetImmediate(action: () => void): void;
  43252. /**
  43253. * Function indicating if a number is an exponent of 2
  43254. * @param value defines the value to test
  43255. * @returns true if the value is an exponent of 2
  43256. */
  43257. static IsExponentOfTwo(value: number): boolean;
  43258. private static _tmpFloatArray;
  43259. /**
  43260. * Returns the nearest 32-bit single precision float representation of a Number
  43261. * @param value A Number. If the parameter is of a different type, it will get converted
  43262. * to a number or to NaN if it cannot be converted
  43263. * @returns number
  43264. */
  43265. static FloatRound(value: number): number;
  43266. /**
  43267. * Extracts the filename from a path
  43268. * @param path defines the path to use
  43269. * @returns the filename
  43270. */
  43271. static GetFilename(path: string): string;
  43272. /**
  43273. * Extracts the "folder" part of a path (everything before the filename).
  43274. * @param uri The URI to extract the info from
  43275. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43276. * @returns The "folder" part of the path
  43277. */
  43278. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43279. /**
  43280. * Extracts text content from a DOM element hierarchy
  43281. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43282. */
  43283. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43284. /**
  43285. * Convert an angle in radians to degrees
  43286. * @param angle defines the angle to convert
  43287. * @returns the angle in degrees
  43288. */
  43289. static ToDegrees(angle: number): number;
  43290. /**
  43291. * Convert an angle in degrees to radians
  43292. * @param angle defines the angle to convert
  43293. * @returns the angle in radians
  43294. */
  43295. static ToRadians(angle: number): number;
  43296. /**
  43297. * Returns an array if obj is not an array
  43298. * @param obj defines the object to evaluate as an array
  43299. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43300. * @returns either obj directly if obj is an array or a new array containing obj
  43301. */
  43302. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43303. /**
  43304. * Gets the pointer prefix to use
  43305. * @param engine defines the engine we are finding the prefix for
  43306. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43307. */
  43308. static GetPointerPrefix(engine: Engine): string;
  43309. /**
  43310. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43311. * @param url define the url we are trying
  43312. * @param element define the dom element where to configure the cors policy
  43313. */
  43314. static SetCorsBehavior(url: string | string[], element: {
  43315. crossOrigin: string | null;
  43316. }): void;
  43317. /**
  43318. * Removes unwanted characters from an url
  43319. * @param url defines the url to clean
  43320. * @returns the cleaned url
  43321. */
  43322. static CleanUrl(url: string): string;
  43323. /**
  43324. * Gets or sets a function used to pre-process url before using them to load assets
  43325. */
  43326. static get PreprocessUrl(): (url: string) => string;
  43327. static set PreprocessUrl(processor: (url: string) => string);
  43328. /**
  43329. * Loads an image as an HTMLImageElement.
  43330. * @param input url string, ArrayBuffer, or Blob to load
  43331. * @param onLoad callback called when the image successfully loads
  43332. * @param onError callback called when the image fails to load
  43333. * @param offlineProvider offline provider for caching
  43334. * @param mimeType optional mime type
  43335. * @returns the HTMLImageElement of the loaded image
  43336. */
  43337. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43338. /**
  43339. * Loads a file from a url
  43340. * @param url url string, ArrayBuffer, or Blob to load
  43341. * @param onSuccess callback called when the file successfully loads
  43342. * @param onProgress callback called while file is loading (if the server supports this mode)
  43343. * @param offlineProvider defines the offline provider for caching
  43344. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43345. * @param onError callback called when the file fails to load
  43346. * @returns a file request object
  43347. */
  43348. 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;
  43349. /**
  43350. * Loads a file from a url
  43351. * @param url the file url to load
  43352. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43353. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43354. */
  43355. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43356. /**
  43357. * Load a script (identified by an url). When the url returns, the
  43358. * content of this file is added into a new script element, attached to the DOM (body element)
  43359. * @param scriptUrl defines the url of the script to laod
  43360. * @param onSuccess defines the callback called when the script is loaded
  43361. * @param onError defines the callback to call if an error occurs
  43362. * @param scriptId defines the id of the script element
  43363. */
  43364. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43365. /**
  43366. * Load an asynchronous script (identified by an url). When the url returns, the
  43367. * content of this file is added into a new script element, attached to the DOM (body element)
  43368. * @param scriptUrl defines the url of the script to laod
  43369. * @param scriptId defines the id of the script element
  43370. * @returns a promise request object
  43371. */
  43372. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43373. /**
  43374. * Loads a file from a blob
  43375. * @param fileToLoad defines the blob to use
  43376. * @param callback defines the callback to call when data is loaded
  43377. * @param progressCallback defines the callback to call during loading process
  43378. * @returns a file request object
  43379. */
  43380. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43381. /**
  43382. * Reads a file from a File object
  43383. * @param file defines the file to load
  43384. * @param onSuccess defines the callback to call when data is loaded
  43385. * @param onProgress defines the callback to call during loading process
  43386. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43387. * @param onError defines the callback to call when an error occurs
  43388. * @returns a file request object
  43389. */
  43390. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43391. /**
  43392. * Creates a data url from a given string content
  43393. * @param content defines the content to convert
  43394. * @returns the new data url link
  43395. */
  43396. static FileAsURL(content: string): string;
  43397. /**
  43398. * Format the given number to a specific decimal format
  43399. * @param value defines the number to format
  43400. * @param decimals defines the number of decimals to use
  43401. * @returns the formatted string
  43402. */
  43403. static Format(value: number, decimals?: number): string;
  43404. /**
  43405. * Tries to copy an object by duplicating every property
  43406. * @param source defines the source object
  43407. * @param destination defines the target object
  43408. * @param doNotCopyList defines a list of properties to avoid
  43409. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43410. */
  43411. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43412. /**
  43413. * Gets a boolean indicating if the given object has no own property
  43414. * @param obj defines the object to test
  43415. * @returns true if object has no own property
  43416. */
  43417. static IsEmpty(obj: any): boolean;
  43418. /**
  43419. * Function used to register events at window level
  43420. * @param windowElement defines the Window object to use
  43421. * @param events defines the events to register
  43422. */
  43423. static RegisterTopRootEvents(windowElement: Window, events: {
  43424. name: string;
  43425. handler: Nullable<(e: FocusEvent) => any>;
  43426. }[]): void;
  43427. /**
  43428. * Function used to unregister events from window level
  43429. * @param windowElement defines the Window object to use
  43430. * @param events defines the events to unregister
  43431. */
  43432. static UnregisterTopRootEvents(windowElement: Window, events: {
  43433. name: string;
  43434. handler: Nullable<(e: FocusEvent) => any>;
  43435. }[]): void;
  43436. /**
  43437. * @ignore
  43438. */
  43439. static _ScreenshotCanvas: HTMLCanvasElement;
  43440. /**
  43441. * Dumps the current bound framebuffer
  43442. * @param width defines the rendering width
  43443. * @param height defines the rendering height
  43444. * @param engine defines the hosting engine
  43445. * @param successCallback defines the callback triggered once the data are available
  43446. * @param mimeType defines the mime type of the result
  43447. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43448. * @return a void promise
  43449. */
  43450. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43451. /**
  43452. * Dumps an array buffer
  43453. * @param width defines the rendering width
  43454. * @param height defines the rendering height
  43455. * @param data the data array
  43456. * @param successCallback defines the callback triggered once the data are available
  43457. * @param mimeType defines the mime type of the result
  43458. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43459. * @param invertY true to invert the picture in the Y dimension
  43460. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43461. */
  43462. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43463. /**
  43464. * Dumps an array buffer
  43465. * @param width defines the rendering width
  43466. * @param height defines the rendering height
  43467. * @param data the data array
  43468. * @param successCallback defines the callback triggered once the data are available
  43469. * @param mimeType defines the mime type of the result
  43470. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43471. * @param invertY true to invert the picture in the Y dimension
  43472. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43473. * @return a promise that resolve to the final data
  43474. */
  43475. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43476. /**
  43477. * Converts the canvas data to blob.
  43478. * This acts as a polyfill for browsers not supporting the to blob function.
  43479. * @param canvas Defines the canvas to extract the data from
  43480. * @param successCallback Defines the callback triggered once the data are available
  43481. * @param mimeType Defines the mime type of the result
  43482. */
  43483. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43484. /**
  43485. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43486. * @param successCallback defines the callback triggered once the data are available
  43487. * @param mimeType defines the mime type of the result
  43488. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43489. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43490. */
  43491. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43492. /**
  43493. * Downloads a blob in the browser
  43494. * @param blob defines the blob to download
  43495. * @param fileName defines the name of the downloaded file
  43496. */
  43497. static Download(blob: Blob, fileName: string): void;
  43498. /**
  43499. * Will return the right value of the noPreventDefault variable
  43500. * Needed to keep backwards compatibility to the old API.
  43501. *
  43502. * @param args arguments passed to the attachControl function
  43503. * @returns the correct value for noPreventDefault
  43504. */
  43505. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43506. /**
  43507. * Captures a screenshot of the current rendering
  43508. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43509. * @param engine defines the rendering engine
  43510. * @param camera defines the source camera
  43511. * @param size This parameter can be set to a single number or to an object with the
  43512. * following (optional) properties: precision, width, height. If a single number is passed,
  43513. * it will be used for both width and height. If an object is passed, the screenshot size
  43514. * will be derived from the parameters. The precision property is a multiplier allowing
  43515. * rendering at a higher or lower resolution
  43516. * @param successCallback defines the callback receives a single parameter which contains the
  43517. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43518. * src parameter of an <img> to display it
  43519. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43520. * Check your browser for supported MIME types
  43521. */
  43522. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43523. /**
  43524. * Captures a screenshot of the current rendering
  43525. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43526. * @param engine defines the rendering engine
  43527. * @param camera defines the source camera
  43528. * @param size This parameter can be set to a single number or to an object with the
  43529. * following (optional) properties: precision, width, height. If a single number is passed,
  43530. * it will be used for both width and height. If an object is passed, the screenshot size
  43531. * will be derived from the parameters. The precision property is a multiplier allowing
  43532. * rendering at a higher or lower resolution
  43533. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43534. * Check your browser for supported MIME types
  43535. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43536. * to the src parameter of an <img> to display it
  43537. */
  43538. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43539. /**
  43540. * Generates an image screenshot from the specified camera.
  43541. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43542. * @param engine The engine to use for rendering
  43543. * @param camera The camera to use for rendering
  43544. * @param size This parameter can be set to a single number or to an object with the
  43545. * following (optional) properties: precision, width, height. If a single number is passed,
  43546. * it will be used for both width and height. If an object is passed, the screenshot size
  43547. * will be derived from the parameters. The precision property is a multiplier allowing
  43548. * rendering at a higher or lower resolution
  43549. * @param successCallback The callback receives a single parameter which contains the
  43550. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43551. * src parameter of an <img> to display it
  43552. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43553. * Check your browser for supported MIME types
  43554. * @param samples Texture samples (default: 1)
  43555. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43556. * @param fileName A name for for the downloaded file.
  43557. */
  43558. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43559. /**
  43560. * Generates an image screenshot from the specified camera.
  43561. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43562. * @param engine The engine to use for rendering
  43563. * @param camera The camera to use for rendering
  43564. * @param size This parameter can be set to a single number or to an object with the
  43565. * following (optional) properties: precision, width, height. If a single number is passed,
  43566. * it will be used for both width and height. If an object is passed, the screenshot size
  43567. * will be derived from the parameters. The precision property is a multiplier allowing
  43568. * rendering at a higher or lower resolution
  43569. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43570. * Check your browser for supported MIME types
  43571. * @param samples Texture samples (default: 1)
  43572. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43573. * @param fileName A name for for the downloaded file.
  43574. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43575. * to the src parameter of an <img> to display it
  43576. */
  43577. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43578. /**
  43579. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43580. * Be aware Math.random() could cause collisions, but:
  43581. * "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"
  43582. * @returns a pseudo random id
  43583. */
  43584. static RandomId(): string;
  43585. /**
  43586. * Test if the given uri is a base64 string
  43587. * @param uri The uri to test
  43588. * @return True if the uri is a base64 string or false otherwise
  43589. */
  43590. static IsBase64(uri: string): boolean;
  43591. /**
  43592. * Decode the given base64 uri.
  43593. * @param uri The uri to decode
  43594. * @return The decoded base64 data.
  43595. */
  43596. static DecodeBase64(uri: string): ArrayBuffer;
  43597. /**
  43598. * Gets the absolute url.
  43599. * @param url the input url
  43600. * @return the absolute url
  43601. */
  43602. static GetAbsoluteUrl(url: string): string;
  43603. /**
  43604. * No log
  43605. */
  43606. static readonly NoneLogLevel: number;
  43607. /**
  43608. * Only message logs
  43609. */
  43610. static readonly MessageLogLevel: number;
  43611. /**
  43612. * Only warning logs
  43613. */
  43614. static readonly WarningLogLevel: number;
  43615. /**
  43616. * Only error logs
  43617. */
  43618. static readonly ErrorLogLevel: number;
  43619. /**
  43620. * All logs
  43621. */
  43622. static readonly AllLogLevel: number;
  43623. /**
  43624. * Gets a value indicating the number of loading errors
  43625. * @ignorenaming
  43626. */
  43627. static get errorsCount(): number;
  43628. /**
  43629. * Callback called when a new log is added
  43630. */
  43631. static OnNewCacheEntry: (entry: string) => void;
  43632. /**
  43633. * Log a message to the console
  43634. * @param message defines the message to log
  43635. */
  43636. static Log(message: string): void;
  43637. /**
  43638. * Write a warning message to the console
  43639. * @param message defines the message to log
  43640. */
  43641. static Warn(message: string): void;
  43642. /**
  43643. * Write an error message to the console
  43644. * @param message defines the message to log
  43645. */
  43646. static Error(message: string): void;
  43647. /**
  43648. * Gets current log cache (list of logs)
  43649. */
  43650. static get LogCache(): string;
  43651. /**
  43652. * Clears the log cache
  43653. */
  43654. static ClearLogCache(): void;
  43655. /**
  43656. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43657. */
  43658. static set LogLevels(level: number);
  43659. /**
  43660. * Checks if the window object exists
  43661. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43662. */
  43663. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43664. /**
  43665. * No performance log
  43666. */
  43667. static readonly PerformanceNoneLogLevel: number;
  43668. /**
  43669. * Use user marks to log performance
  43670. */
  43671. static readonly PerformanceUserMarkLogLevel: number;
  43672. /**
  43673. * Log performance to the console
  43674. */
  43675. static readonly PerformanceConsoleLogLevel: number;
  43676. private static _performance;
  43677. /**
  43678. * Sets the current performance log level
  43679. */
  43680. static set PerformanceLogLevel(level: number);
  43681. private static _StartPerformanceCounterDisabled;
  43682. private static _EndPerformanceCounterDisabled;
  43683. private static _StartUserMark;
  43684. private static _EndUserMark;
  43685. private static _StartPerformanceConsole;
  43686. private static _EndPerformanceConsole;
  43687. /**
  43688. * Starts a performance counter
  43689. */
  43690. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43691. /**
  43692. * Ends a specific performance counter
  43693. */
  43694. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43695. /**
  43696. * Gets either window.performance.now() if supported or Date.now() else
  43697. */
  43698. static get Now(): number;
  43699. /**
  43700. * This method will return the name of the class used to create the instance of the given object.
  43701. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43702. * @param object the object to get the class name from
  43703. * @param isType defines if the object is actually a type
  43704. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43705. */
  43706. static GetClassName(object: any, isType?: boolean): string;
  43707. /**
  43708. * Gets the first element of an array satisfying a given predicate
  43709. * @param array defines the array to browse
  43710. * @param predicate defines the predicate to use
  43711. * @returns null if not found or the element
  43712. */
  43713. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43714. /**
  43715. * This method will return the name of the full name of the class, including its owning module (if any).
  43716. * 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).
  43717. * @param object the object to get the class name from
  43718. * @param isType defines if the object is actually a type
  43719. * @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.
  43720. * @ignorenaming
  43721. */
  43722. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43723. /**
  43724. * Returns a promise that resolves after the given amount of time.
  43725. * @param delay Number of milliseconds to delay
  43726. * @returns Promise that resolves after the given amount of time
  43727. */
  43728. static DelayAsync(delay: number): Promise<void>;
  43729. /**
  43730. * Utility function to detect if the current user agent is Safari
  43731. * @returns whether or not the current user agent is safari
  43732. */
  43733. static IsSafari(): boolean;
  43734. }
  43735. /**
  43736. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43737. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43738. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43739. * @param name The name of the class, case should be preserved
  43740. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43741. */
  43742. export function className(name: string, module?: string): (target: Object) => void;
  43743. /**
  43744. * An implementation of a loop for asynchronous functions.
  43745. */
  43746. export class AsyncLoop {
  43747. /**
  43748. * Defines the number of iterations for the loop
  43749. */
  43750. iterations: number;
  43751. /**
  43752. * Defines the current index of the loop.
  43753. */
  43754. index: number;
  43755. private _done;
  43756. private _fn;
  43757. private _successCallback;
  43758. /**
  43759. * Constructor.
  43760. * @param iterations the number of iterations.
  43761. * @param func the function to run each iteration
  43762. * @param successCallback the callback that will be called upon successful execution
  43763. * @param offset starting offset.
  43764. */
  43765. constructor(
  43766. /**
  43767. * Defines the number of iterations for the loop
  43768. */
  43769. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43770. /**
  43771. * Execute the next iteration. Must be called after the last iteration was finished.
  43772. */
  43773. executeNext(): void;
  43774. /**
  43775. * Break the loop and run the success callback.
  43776. */
  43777. breakLoop(): void;
  43778. /**
  43779. * Create and run an async loop.
  43780. * @param iterations the number of iterations.
  43781. * @param fn the function to run each iteration
  43782. * @param successCallback the callback that will be called upon successful execution
  43783. * @param offset starting offset.
  43784. * @returns the created async loop object
  43785. */
  43786. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43787. /**
  43788. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43789. * @param iterations total number of iterations
  43790. * @param syncedIterations number of synchronous iterations in each async iteration.
  43791. * @param fn the function to call each iteration.
  43792. * @param callback a success call back that will be called when iterating stops.
  43793. * @param breakFunction a break condition (optional)
  43794. * @param timeout timeout settings for the setTimeout function. default - 0.
  43795. * @returns the created async loop object
  43796. */
  43797. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43798. }
  43799. }
  43800. declare module BABYLON {
  43801. /**
  43802. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43803. * The underlying implementation relies on an associative array to ensure the best performances.
  43804. * The value can be anything including 'null' but except 'undefined'
  43805. */
  43806. export class StringDictionary<T> {
  43807. /**
  43808. * This will clear this dictionary and copy the content from the 'source' one.
  43809. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43810. * @param source the dictionary to take the content from and copy to this dictionary
  43811. */
  43812. copyFrom(source: StringDictionary<T>): void;
  43813. /**
  43814. * Get a value based from its key
  43815. * @param key the given key to get the matching value from
  43816. * @return the value if found, otherwise undefined is returned
  43817. */
  43818. get(key: string): T | undefined;
  43819. /**
  43820. * Get a value from its key or add it if it doesn't exist.
  43821. * This method will ensure you that a given key/data will be present in the dictionary.
  43822. * @param key the given key to get the matching value from
  43823. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43824. * The factory will only be invoked if there's no data for the given key.
  43825. * @return the value corresponding to the key.
  43826. */
  43827. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43828. /**
  43829. * Get a value from its key if present in the dictionary otherwise add it
  43830. * @param key the key to get the value from
  43831. * @param val if there's no such key/value pair in the dictionary add it with this value
  43832. * @return the value corresponding to the key
  43833. */
  43834. getOrAdd(key: string, val: T): T;
  43835. /**
  43836. * Check if there's a given key in the dictionary
  43837. * @param key the key to check for
  43838. * @return true if the key is present, false otherwise
  43839. */
  43840. contains(key: string): boolean;
  43841. /**
  43842. * Add a new key and its corresponding value
  43843. * @param key the key to add
  43844. * @param value the value corresponding to the key
  43845. * @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
  43846. */
  43847. add(key: string, value: T): boolean;
  43848. /**
  43849. * Update a specific value associated to a key
  43850. * @param key defines the key to use
  43851. * @param value defines the value to store
  43852. * @returns true if the value was updated (or false if the key was not found)
  43853. */
  43854. set(key: string, value: T): boolean;
  43855. /**
  43856. * Get the element of the given key and remove it from the dictionary
  43857. * @param key defines the key to search
  43858. * @returns the value associated with the key or null if not found
  43859. */
  43860. getAndRemove(key: string): Nullable<T>;
  43861. /**
  43862. * Remove a key/value from the dictionary.
  43863. * @param key the key to remove
  43864. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43865. */
  43866. remove(key: string): boolean;
  43867. /**
  43868. * Clear the whole content of the dictionary
  43869. */
  43870. clear(): void;
  43871. /**
  43872. * Gets the current count
  43873. */
  43874. get count(): number;
  43875. /**
  43876. * Execute a callback on each key/val of the dictionary.
  43877. * Note that you can remove any element in this dictionary in the callback implementation
  43878. * @param callback the callback to execute on a given key/value pair
  43879. */
  43880. forEach(callback: (key: string, val: T) => void): void;
  43881. /**
  43882. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43883. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43884. * Note that you can remove any element in this dictionary in the callback implementation
  43885. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43886. * @returns the first item
  43887. */
  43888. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43889. private _count;
  43890. private _data;
  43891. }
  43892. }
  43893. declare module BABYLON {
  43894. /** @hidden */
  43895. export interface ICollisionCoordinator {
  43896. createCollider(): Collider;
  43897. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43898. init(scene: Scene): void;
  43899. }
  43900. /** @hidden */
  43901. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43902. private _scene;
  43903. private _scaledPosition;
  43904. private _scaledVelocity;
  43905. private _finalPosition;
  43906. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43907. createCollider(): Collider;
  43908. init(scene: Scene): void;
  43909. private _collideWithWorld;
  43910. }
  43911. }
  43912. declare module BABYLON {
  43913. /**
  43914. * Class used to manage all inputs for the scene.
  43915. */
  43916. export class InputManager {
  43917. /** The distance in pixel that you have to move to prevent some events */
  43918. static DragMovementThreshold: number;
  43919. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43920. static LongPressDelay: number;
  43921. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43922. static DoubleClickDelay: number;
  43923. /** If you need to check double click without raising a single click at first click, enable this flag */
  43924. static ExclusiveDoubleClickMode: boolean;
  43925. /** 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. */
  43926. private _alreadyAttached;
  43927. private _alreadyAttachedTo;
  43928. private _wheelEventName;
  43929. private _onPointerMove;
  43930. private _onPointerDown;
  43931. private _onPointerUp;
  43932. private _initClickEvent;
  43933. private _initActionManager;
  43934. private _delayedSimpleClick;
  43935. private _delayedSimpleClickTimeout;
  43936. private _previousDelayedSimpleClickTimeout;
  43937. private _meshPickProceed;
  43938. private _previousButtonPressed;
  43939. private _currentPickResult;
  43940. private _previousPickResult;
  43941. private _totalPointersPressed;
  43942. private _doubleClickOccured;
  43943. private _pointerOverMesh;
  43944. private _pickedDownMesh;
  43945. private _pickedUpMesh;
  43946. private _pointerX;
  43947. private _pointerY;
  43948. private _unTranslatedPointerX;
  43949. private _unTranslatedPointerY;
  43950. private _startingPointerPosition;
  43951. private _previousStartingPointerPosition;
  43952. private _startingPointerTime;
  43953. private _previousStartingPointerTime;
  43954. private _pointerCaptures;
  43955. private _meshUnderPointerId;
  43956. private _onKeyDown;
  43957. private _onKeyUp;
  43958. private _keyboardIsAttached;
  43959. private _onCanvasFocusObserver;
  43960. private _onCanvasBlurObserver;
  43961. private _scene;
  43962. /**
  43963. * Creates a new InputManager
  43964. * @param scene defines the hosting scene
  43965. */
  43966. constructor(scene: Scene);
  43967. /**
  43968. * Gets the mesh that is currently under the pointer
  43969. */
  43970. get meshUnderPointer(): Nullable<AbstractMesh>;
  43971. /**
  43972. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43973. * @param pointerId the pointer id to use
  43974. * @returns The mesh under this pointer id or null if not found
  43975. */
  43976. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43977. /**
  43978. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43979. */
  43980. get unTranslatedPointer(): Vector2;
  43981. /**
  43982. * Gets or sets the current on-screen X position of the pointer
  43983. */
  43984. get pointerX(): number;
  43985. set pointerX(value: number);
  43986. /**
  43987. * Gets or sets the current on-screen Y position of the pointer
  43988. */
  43989. get pointerY(): number;
  43990. set pointerY(value: number);
  43991. private _updatePointerPosition;
  43992. private _processPointerMove;
  43993. private _setRayOnPointerInfo;
  43994. private _checkPrePointerObservable;
  43995. /**
  43996. * Use this method to simulate a pointer move on a mesh
  43997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44000. */
  44001. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44002. /**
  44003. * Use this method to simulate a pointer down on a mesh
  44004. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44005. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44006. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44007. */
  44008. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44009. private _processPointerDown;
  44010. /** @hidden */
  44011. _isPointerSwiping(): boolean;
  44012. /**
  44013. * Use this method to simulate a pointer up on a mesh
  44014. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44015. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44016. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44017. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44018. */
  44019. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44020. private _processPointerUp;
  44021. /**
  44022. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44023. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44024. * @returns true if the pointer was captured
  44025. */
  44026. isPointerCaptured(pointerId?: number): boolean;
  44027. /**
  44028. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44029. * @param attachUp defines if you want to attach events to pointerup
  44030. * @param attachDown defines if you want to attach events to pointerdown
  44031. * @param attachMove defines if you want to attach events to pointermove
  44032. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44033. */
  44034. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44035. /**
  44036. * Detaches all event handlers
  44037. */
  44038. detachControl(): void;
  44039. /**
  44040. * Force the value of meshUnderPointer
  44041. * @param mesh defines the mesh to use
  44042. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44043. */
  44044. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44045. /**
  44046. * Gets the mesh under the pointer
  44047. * @returns a Mesh or null if no mesh is under the pointer
  44048. */
  44049. getPointerOverMesh(): Nullable<AbstractMesh>;
  44050. }
  44051. }
  44052. declare module BABYLON {
  44053. /**
  44054. * This class defines the direct association between an animation and a target
  44055. */
  44056. export class TargetedAnimation {
  44057. /**
  44058. * Animation to perform
  44059. */
  44060. animation: Animation;
  44061. /**
  44062. * Target to animate
  44063. */
  44064. target: any;
  44065. /**
  44066. * Returns the string "TargetedAnimation"
  44067. * @returns "TargetedAnimation"
  44068. */
  44069. getClassName(): string;
  44070. /**
  44071. * Serialize the object
  44072. * @returns the JSON object representing the current entity
  44073. */
  44074. serialize(): any;
  44075. }
  44076. /**
  44077. * Use this class to create coordinated animations on multiple targets
  44078. */
  44079. export class AnimationGroup implements IDisposable {
  44080. /** The name of the animation group */
  44081. name: string;
  44082. private _scene;
  44083. private _targetedAnimations;
  44084. private _animatables;
  44085. private _from;
  44086. private _to;
  44087. private _isStarted;
  44088. private _isPaused;
  44089. private _speedRatio;
  44090. private _loopAnimation;
  44091. private _isAdditive;
  44092. /**
  44093. * Gets or sets the unique id of the node
  44094. */
  44095. uniqueId: number;
  44096. /**
  44097. * This observable will notify when one animation have ended
  44098. */
  44099. onAnimationEndObservable: Observable<TargetedAnimation>;
  44100. /**
  44101. * Observer raised when one animation loops
  44102. */
  44103. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44104. /**
  44105. * Observer raised when all animations have looped
  44106. */
  44107. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44108. /**
  44109. * This observable will notify when all animations have ended.
  44110. */
  44111. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44112. /**
  44113. * This observable will notify when all animations have paused.
  44114. */
  44115. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44116. /**
  44117. * This observable will notify when all animations are playing.
  44118. */
  44119. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44120. /**
  44121. * Gets the first frame
  44122. */
  44123. get from(): number;
  44124. /**
  44125. * Gets the last frame
  44126. */
  44127. get to(): number;
  44128. /**
  44129. * Define if the animations are started
  44130. */
  44131. get isStarted(): boolean;
  44132. /**
  44133. * Gets a value indicating that the current group is playing
  44134. */
  44135. get isPlaying(): boolean;
  44136. /**
  44137. * Gets or sets the speed ratio to use for all animations
  44138. */
  44139. get speedRatio(): number;
  44140. /**
  44141. * Gets or sets the speed ratio to use for all animations
  44142. */
  44143. set speedRatio(value: number);
  44144. /**
  44145. * Gets or sets if all animations should loop or not
  44146. */
  44147. get loopAnimation(): boolean;
  44148. set loopAnimation(value: boolean);
  44149. /**
  44150. * Gets or sets if all animations should be evaluated additively
  44151. */
  44152. get isAdditive(): boolean;
  44153. set isAdditive(value: boolean);
  44154. /**
  44155. * Gets the targeted animations for this animation group
  44156. */
  44157. get targetedAnimations(): Array<TargetedAnimation>;
  44158. /**
  44159. * returning the list of animatables controlled by this animation group.
  44160. */
  44161. get animatables(): Array<Animatable>;
  44162. /**
  44163. * Gets the list of target animations
  44164. */
  44165. get children(): TargetedAnimation[];
  44166. /**
  44167. * Instantiates a new Animation Group.
  44168. * This helps managing several animations at once.
  44169. * @see https://doc.babylonjs.com/how_to/group
  44170. * @param name Defines the name of the group
  44171. * @param scene Defines the scene the group belongs to
  44172. */
  44173. constructor(
  44174. /** The name of the animation group */
  44175. name: string, scene?: Nullable<Scene>);
  44176. /**
  44177. * Add an animation (with its target) in the group
  44178. * @param animation defines the animation we want to add
  44179. * @param target defines the target of the animation
  44180. * @returns the TargetedAnimation object
  44181. */
  44182. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44183. /**
  44184. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44185. * It can add constant keys at begin or end
  44186. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44187. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44188. * @returns the animation group
  44189. */
  44190. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44191. private _animationLoopCount;
  44192. private _animationLoopFlags;
  44193. private _processLoop;
  44194. /**
  44195. * Start all animations on given targets
  44196. * @param loop defines if animations must loop
  44197. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44198. * @param from defines the from key (optional)
  44199. * @param to defines the to key (optional)
  44200. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44201. * @returns the current animation group
  44202. */
  44203. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44204. /**
  44205. * Pause all animations
  44206. * @returns the animation group
  44207. */
  44208. pause(): AnimationGroup;
  44209. /**
  44210. * Play all animations to initial state
  44211. * This function will start() the animations if they were not started or will restart() them if they were paused
  44212. * @param loop defines if animations must loop
  44213. * @returns the animation group
  44214. */
  44215. play(loop?: boolean): AnimationGroup;
  44216. /**
  44217. * Reset all animations to initial state
  44218. * @returns the animation group
  44219. */
  44220. reset(): AnimationGroup;
  44221. /**
  44222. * Restart animations from key 0
  44223. * @returns the animation group
  44224. */
  44225. restart(): AnimationGroup;
  44226. /**
  44227. * Stop all animations
  44228. * @returns the animation group
  44229. */
  44230. stop(): AnimationGroup;
  44231. /**
  44232. * Set animation weight for all animatables
  44233. * @param weight defines the weight to use
  44234. * @return the animationGroup
  44235. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44236. */
  44237. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44238. /**
  44239. * Synchronize and normalize all animatables with a source animatable
  44240. * @param root defines the root animatable to synchronize with
  44241. * @return the animationGroup
  44242. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44243. */
  44244. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44245. /**
  44246. * Goes to a specific frame in this animation group
  44247. * @param frame the frame number to go to
  44248. * @return the animationGroup
  44249. */
  44250. goToFrame(frame: number): AnimationGroup;
  44251. /**
  44252. * Dispose all associated resources
  44253. */
  44254. dispose(): void;
  44255. private _checkAnimationGroupEnded;
  44256. /**
  44257. * Clone the current animation group and returns a copy
  44258. * @param newName defines the name of the new group
  44259. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44260. * @returns the new animation group
  44261. */
  44262. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44263. /**
  44264. * Serializes the animationGroup to an object
  44265. * @returns Serialized object
  44266. */
  44267. serialize(): any;
  44268. /**
  44269. * Returns a new AnimationGroup object parsed from the source provided.
  44270. * @param parsedAnimationGroup defines the source
  44271. * @param scene defines the scene that will receive the animationGroup
  44272. * @returns a new AnimationGroup
  44273. */
  44274. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44275. /**
  44276. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44277. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44278. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44279. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44280. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44281. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44282. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44283. */
  44284. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44285. /**
  44286. * Returns the string "AnimationGroup"
  44287. * @returns "AnimationGroup"
  44288. */
  44289. getClassName(): string;
  44290. /**
  44291. * Creates a detailed string about the object
  44292. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44293. * @returns a string representing the object
  44294. */
  44295. toString(fullDetails?: boolean): string;
  44296. }
  44297. }
  44298. declare module BABYLON {
  44299. /**
  44300. * @hidden
  44301. **/
  44302. export class _TimeToken {
  44303. _startTimeQuery: Nullable<WebGLQuery>;
  44304. _endTimeQuery: Nullable<WebGLQuery>;
  44305. _timeElapsedQuery: Nullable<WebGLQuery>;
  44306. _timeElapsedQueryEnded: boolean;
  44307. }
  44308. }
  44309. declare module BABYLON {
  44310. /** @hidden */
  44311. export enum ExtensionName {
  44312. DepthClamping = "depth-clamping",
  44313. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44314. Depth32FloatStencil8 = "depth32float-stencil8",
  44315. PipelineStatisticsQuery = "pipeline-statistics-query",
  44316. TextureCompressionBC = "texture-compression-bc",
  44317. TimestampQuery = "timestamp-query"
  44318. }
  44319. /** @hidden */
  44320. export enum AddressMode {
  44321. ClampToEdge = "clamp-to-edge",
  44322. Repeat = "repeat",
  44323. MirrorRepeat = "mirror-repeat"
  44324. }
  44325. /** @hidden */
  44326. export enum BindingType {
  44327. UniformBuffer = "uniform-buffer",
  44328. StorageBuffer = "storage-buffer",
  44329. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44330. Sampler = "sampler",
  44331. ComparisonSampler = "comparison-sampler",
  44332. SampledTexture = "sampled-texture",
  44333. ReadonlyStorageTexture = "readonly-storage-texture",
  44334. WriteonlyStorageTexture = "writeonly-storage-texture"
  44335. }
  44336. /** @hidden */
  44337. export enum BlendFactor {
  44338. Zero = "zero",
  44339. One = "one",
  44340. SrcColor = "src-color",
  44341. OneMinusSrcColor = "one-minus-src-color",
  44342. SrcAlpha = "src-alpha",
  44343. OneMinusSrcAlpha = "one-minus-src-alpha",
  44344. DstColor = "dst-color",
  44345. OneMinusDstColor = "one-minus-dst-color",
  44346. DstAlpha = "dst-alpha",
  44347. OneMinusDstAlpha = "one-minus-dst-alpha",
  44348. SrcAlphaSaturated = "src-alpha-saturated",
  44349. BlendColor = "blend-color",
  44350. OneMinusBlendColor = "one-minus-blend-color"
  44351. }
  44352. /** @hidden */
  44353. export enum BlendOperation {
  44354. Add = "add",
  44355. Subtract = "subtract",
  44356. ReverseSubtract = "reverse-subtract",
  44357. Min = "min",
  44358. Max = "max"
  44359. }
  44360. /** @hidden */
  44361. export enum CompareFunction {
  44362. Never = "never",
  44363. Less = "less",
  44364. Equal = "equal",
  44365. LessEqual = "less-equal",
  44366. Greater = "greater",
  44367. NotEqual = "not-equal",
  44368. GreaterEqual = "greater-equal",
  44369. Always = "always"
  44370. }
  44371. /** @hidden */
  44372. export enum CullMode {
  44373. None = "none",
  44374. Front = "front",
  44375. Back = "back"
  44376. }
  44377. /** @hidden */
  44378. export enum FilterMode {
  44379. Nearest = "nearest",
  44380. Linear = "linear"
  44381. }
  44382. /** @hidden */
  44383. export enum FrontFace {
  44384. CCW = "ccw",
  44385. CW = "cw"
  44386. }
  44387. /** @hidden */
  44388. export enum IndexFormat {
  44389. Uint16 = "uint16",
  44390. Uint32 = "uint32"
  44391. }
  44392. /** @hidden */
  44393. export enum InputStepMode {
  44394. Vertex = "vertex",
  44395. Instance = "instance"
  44396. }
  44397. /** @hidden */
  44398. export enum LoadOp {
  44399. Load = "load"
  44400. }
  44401. /** @hidden */
  44402. export enum PrimitiveTopology {
  44403. PointList = "point-list",
  44404. LineList = "line-list",
  44405. LineStrip = "line-strip",
  44406. TriangleList = "triangle-list",
  44407. TriangleStrip = "triangle-strip"
  44408. }
  44409. /** @hidden */
  44410. export enum StencilOperation {
  44411. Keep = "keep",
  44412. Zero = "zero",
  44413. Replace = "replace",
  44414. Invert = "invert",
  44415. IncrementClamp = "increment-clamp",
  44416. DecrementClamp = "decrement-clamp",
  44417. IncrementWrap = "increment-wrap",
  44418. DecrementWrap = "decrement-wrap"
  44419. }
  44420. /** @hidden */
  44421. export enum StoreOp {
  44422. Store = "store",
  44423. Clear = "clear"
  44424. }
  44425. /** @hidden */
  44426. export enum TextureDimension {
  44427. E1d = "1d",
  44428. E2d = "2d",
  44429. E3d = "3d"
  44430. }
  44431. /** @hidden */
  44432. export enum TextureFormat {
  44433. R8Unorm = "r8unorm",
  44434. R8Snorm = "r8snorm",
  44435. R8Uint = "r8uint",
  44436. R8Sint = "r8sint",
  44437. R16Uint = "r16uint",
  44438. R16Sint = "r16sint",
  44439. R16Float = "r16float",
  44440. RG8Unorm = "rg8unorm",
  44441. RG8Snorm = "rg8snorm",
  44442. RG8Uint = "rg8uint",
  44443. RG8Sint = "rg8sint",
  44444. R32Uint = "r32uint",
  44445. R32Sint = "r32sint",
  44446. R32Float = "r32float",
  44447. RG16Uint = "rg16uint",
  44448. RG16Sint = "rg16sint",
  44449. RG16Float = "rg16float",
  44450. RGBA8Unorm = "rgba8unorm",
  44451. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44452. RGBA8Snorm = "rgba8snorm",
  44453. RGBA8Uint = "rgba8uint",
  44454. RGBA8Sint = "rgba8sint",
  44455. BGRA8Unorm = "bgra8unorm",
  44456. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44457. RGB9E5UFloat = "rgb9e5ufloat",
  44458. RGB10A2Unorm = "rgb10a2unorm",
  44459. RG11B10UFloat = "rg11b10ufloat",
  44460. RG32Uint = "rg32uint",
  44461. RG32Sint = "rg32sint",
  44462. RG32Float = "rg32float",
  44463. RGBA16Uint = "rgba16uint",
  44464. RGBA16Sint = "rgba16sint",
  44465. RGBA16Float = "rgba16float",
  44466. RGBA32Uint = "rgba32uint",
  44467. RGBA32Sint = "rgba32sint",
  44468. RGBA32Float = "rgba32float",
  44469. Stencil8 = "stencil8",
  44470. Depth16Unorm = "depth16unorm",
  44471. Depth24Plus = "depth24plus",
  44472. Depth24PlusStencil8 = "depth24plus-stencil8",
  44473. Depth32Float = "depth32float",
  44474. BC1RGBAUNorm = "bc1-rgba-unorm",
  44475. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44476. BC2RGBAUnorm = "bc2-rgba-unorm",
  44477. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44478. BC3RGBAUnorm = "bc3-rgba-unorm",
  44479. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44480. BC4RUnorm = "bc4-r-unorm",
  44481. BC4RSnorm = "bc4-r-snorm",
  44482. BC5RGUnorm = "bc5-rg-unorm",
  44483. BC5RGSnorm = "bc5-rg-snorm",
  44484. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44485. BC6HRGBFloat = "bc6h-rgb-float",
  44486. BC7RGBAUnorm = "bc7-rgba-unorm",
  44487. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44488. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44489. Depth32FloatStencil8 = "depth32float-stencil8"
  44490. }
  44491. /** @hidden */
  44492. export enum TextureComponentType {
  44493. Float = "float",
  44494. Sint = "sint",
  44495. Uint = "uint",
  44496. DepthComparison = "depth-comparison"
  44497. }
  44498. /** @hidden */
  44499. export enum TextureViewDimension {
  44500. E1d = "1d",
  44501. E2d = "2d",
  44502. E2dArray = "2d-array",
  44503. Cube = "cube",
  44504. CubeArray = "cube-array",
  44505. E3d = "3d"
  44506. }
  44507. /** @hidden */
  44508. export enum VertexFormat {
  44509. Uchar2 = "uchar2",
  44510. Uchar4 = "uchar4",
  44511. Char2 = "char2",
  44512. Char4 = "char4",
  44513. Uchar2Norm = "uchar2norm",
  44514. Uchar4Norm = "uchar4norm",
  44515. Char2Norm = "char2norm",
  44516. Char4Norm = "char4norm",
  44517. Ushort2 = "ushort2",
  44518. Ushort4 = "ushort4",
  44519. Short2 = "short2",
  44520. Short4 = "short4",
  44521. Ushort2Norm = "ushort2norm",
  44522. Ushort4Norm = "ushort4norm",
  44523. Short2Norm = "short2norm",
  44524. Short4Norm = "short4norm",
  44525. Half2 = "half2",
  44526. Half4 = "half4",
  44527. Float = "float",
  44528. Float2 = "float2",
  44529. Float3 = "float3",
  44530. Float4 = "float4",
  44531. Uint = "uint",
  44532. Uint2 = "uint2",
  44533. Uint3 = "uint3",
  44534. Uint4 = "uint4",
  44535. Int = "int",
  44536. Int2 = "int2",
  44537. Int3 = "int3",
  44538. Int4 = "int4"
  44539. }
  44540. /** @hidden */
  44541. export enum TextureAspect {
  44542. All = "all",
  44543. StencilOnly = "stencil-only",
  44544. DepthOnly = "depth-only"
  44545. }
  44546. /** @hidden */
  44547. export enum CompilationMessageType {
  44548. Error = "error",
  44549. Warning = "warning",
  44550. Info = "info"
  44551. }
  44552. /** @hidden */
  44553. export enum QueryType {
  44554. Occlusion = "occlusion"
  44555. }
  44556. /** @hidden */
  44557. export enum BufferUsage {
  44558. MapRead = 1,
  44559. MapWrite = 2,
  44560. CopySrc = 4,
  44561. CopyDst = 8,
  44562. Index = 16,
  44563. Vertex = 32,
  44564. Uniform = 64,
  44565. Storage = 128,
  44566. Indirect = 256,
  44567. QueryResolve = 512
  44568. }
  44569. /** @hidden */
  44570. export enum ColorWrite {
  44571. Red = 1,
  44572. Green = 2,
  44573. Blue = 4,
  44574. Alpha = 8,
  44575. All = 15
  44576. }
  44577. /** @hidden */
  44578. export enum ShaderStage {
  44579. Vertex = 1,
  44580. Fragment = 2,
  44581. Compute = 4
  44582. }
  44583. /** @hidden */
  44584. export enum TextureUsage {
  44585. CopySrc = 1,
  44586. CopyDst = 2,
  44587. Sampled = 4,
  44588. Storage = 8,
  44589. OutputAttachment = 16
  44590. }
  44591. /** @hidden */
  44592. export enum MapMode {
  44593. Read = 1,
  44594. Write = 2
  44595. }
  44596. }
  44597. declare module BABYLON {
  44598. /** @hidden */
  44599. export interface WebGPUBindingInfo {
  44600. setIndex: number;
  44601. bindingIndex: number;
  44602. }
  44603. /** @hidden */
  44604. export interface WebGPUTextureSamplerBindingDescription {
  44605. sampler: WebGPUBindingInfo;
  44606. isTextureArray: boolean;
  44607. textures: Array<WebGPUBindingInfo>;
  44608. }
  44609. /** @hidden
  44610. * If the binding is a UBO, isSampler=isTexture=false
  44611. */
  44612. export interface WebGPUBindingDescription {
  44613. name: string;
  44614. usedInVertex: boolean;
  44615. usedInFragment: boolean;
  44616. isSampler: boolean;
  44617. isComparisonSampler?: boolean;
  44618. isTexture: boolean;
  44619. componentType?: GPUTextureComponentType;
  44620. textureDimension?: GPUTextureViewDimension;
  44621. }
  44622. /**
  44623. * @hidden
  44624. */
  44625. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44626. uboNextBindingIndex: number;
  44627. freeSetIndex: number;
  44628. freeBindingIndex: number;
  44629. availableVaryings: {
  44630. [key: string]: number;
  44631. };
  44632. availableAttributes: {
  44633. [key: string]: number;
  44634. };
  44635. availableUBOs: {
  44636. [key: string]: {
  44637. setIndex: number;
  44638. bindingIndex: number;
  44639. };
  44640. };
  44641. availableSamplers: {
  44642. [key: string]: WebGPUTextureSamplerBindingDescription;
  44643. };
  44644. leftOverUniforms: {
  44645. name: string;
  44646. type: string;
  44647. length: number;
  44648. }[];
  44649. orderedAttributes: string[];
  44650. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44651. uniformBufferNames: string[];
  44652. attributeNamesFromEffect: string[];
  44653. attributeLocationsFromEffect: number[];
  44654. private _attributeNextLocation;
  44655. private _varyingNextLocation;
  44656. constructor();
  44657. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44658. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44659. getNextFreeUBOBinding(): {
  44660. setIndex: number;
  44661. bindingIndex: number;
  44662. };
  44663. private _getNextFreeBinding;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /** @hidden */
  44668. export interface IWebGPUPipelineContextSamplerCache {
  44669. samplerBinding: number;
  44670. firstTextureName: string;
  44671. }
  44672. /** @hidden */
  44673. export interface IWebGPUPipelineContextTextureCache {
  44674. textureBinding: number;
  44675. texture: InternalTexture;
  44676. }
  44677. /** @hidden */
  44678. export interface IWebGPUPipelineContextVertexInputsCache {
  44679. indexBuffer: Nullable<GPUBuffer>;
  44680. indexOffset: number;
  44681. vertexStartSlot: number;
  44682. vertexBuffers: GPUBuffer[];
  44683. vertexOffsets: number[];
  44684. }
  44685. /** @hidden */
  44686. export interface IWebGPURenderPipelineStageDescriptor {
  44687. vertexStage: GPUProgrammableStageDescriptor;
  44688. fragmentStage?: GPUProgrammableStageDescriptor;
  44689. }
  44690. /** @hidden */
  44691. export class WebGPUBindGroupCacheNode {
  44692. values: {
  44693. [id: number]: WebGPUBindGroupCacheNode;
  44694. };
  44695. bindGroups: GPUBindGroup[];
  44696. constructor();
  44697. }
  44698. /** @hidden */
  44699. export class WebGPUPipelineContext implements IPipelineContext {
  44700. engine: WebGPUEngine;
  44701. shaderProcessingContext: WebGPUShaderProcessingContext;
  44702. leftOverUniformsByName: {
  44703. [name: string]: string;
  44704. };
  44705. sources: {
  44706. vertex: string;
  44707. fragment: string;
  44708. rawVertex: string;
  44709. rawFragment: string;
  44710. };
  44711. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44712. samplers: {
  44713. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44714. };
  44715. textures: {
  44716. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44717. };
  44718. bindGroupLayouts: GPUBindGroupLayout[];
  44719. bindGroupsCache: WebGPUBindGroupCacheNode;
  44720. /**
  44721. * Stores the uniform buffer
  44722. */
  44723. uniformBuffer: Nullable<UniformBuffer>;
  44724. onCompiled?: () => void;
  44725. get isAsync(): boolean;
  44726. get isReady(): boolean;
  44727. /** @hidden */
  44728. _name: string;
  44729. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44730. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44731. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44732. [key: string]: number;
  44733. }, uniformsNames: string[], uniforms: {
  44734. [key: string]: Nullable<WebGLUniformLocation>;
  44735. }, samplerList: string[], samplers: {
  44736. [key: string]: number;
  44737. }, attributesNames: string[], attributes: number[]): void;
  44738. /** @hidden */
  44739. /**
  44740. * Build the uniform buffer used in the material.
  44741. */
  44742. buildUniformLayout(): void;
  44743. /**
  44744. * Release all associated resources.
  44745. **/
  44746. dispose(): void;
  44747. /**
  44748. * Sets an integer value on a uniform variable.
  44749. * @param uniformName Name of the variable.
  44750. * @param value Value to be set.
  44751. */
  44752. setInt(uniformName: string, value: number): void;
  44753. /**
  44754. * Sets an int2 value on a uniform variable.
  44755. * @param uniformName Name of the variable.
  44756. * @param x First int in int2.
  44757. * @param y Second int in int2.
  44758. */
  44759. setInt2(uniformName: string, x: number, y: number): void;
  44760. /**
  44761. * Sets an int3 value on a uniform variable.
  44762. * @param uniformName Name of the variable.
  44763. * @param x First int in int3.
  44764. * @param y Second int in int3.
  44765. * @param z Third int in int3.
  44766. */
  44767. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44768. /**
  44769. * Sets an int4 value on a uniform variable.
  44770. * @param uniformName Name of the variable.
  44771. * @param x First int in int4.
  44772. * @param y Second int in int4.
  44773. * @param z Third int in int4.
  44774. * @param w Fourth int in int4.
  44775. */
  44776. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44777. /**
  44778. * Sets an int array on a uniform variable.
  44779. * @param uniformName Name of the variable.
  44780. * @param array array to be set.
  44781. */
  44782. setIntArray(uniformName: string, array: Int32Array): void;
  44783. /**
  44784. * 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)
  44785. * @param uniformName Name of the variable.
  44786. * @param array array to be set.
  44787. */
  44788. setIntArray2(uniformName: string, array: Int32Array): void;
  44789. /**
  44790. * 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)
  44791. * @param uniformName Name of the variable.
  44792. * @param array array to be set.
  44793. */
  44794. setIntArray3(uniformName: string, array: Int32Array): void;
  44795. /**
  44796. * 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)
  44797. * @param uniformName Name of the variable.
  44798. * @param array array to be set.
  44799. */
  44800. setIntArray4(uniformName: string, array: Int32Array): void;
  44801. /**
  44802. * Sets an array on a uniform variable.
  44803. * @param uniformName Name of the variable.
  44804. * @param array array to be set.
  44805. */
  44806. setArray(uniformName: string, array: number[]): void;
  44807. /**
  44808. * 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)
  44809. * @param uniformName Name of the variable.
  44810. * @param array array to be set.
  44811. */
  44812. setArray2(uniformName: string, array: number[]): void;
  44813. /**
  44814. * 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)
  44815. * @param uniformName Name of the variable.
  44816. * @param array array to be set.
  44817. * @returns this effect.
  44818. */
  44819. setArray3(uniformName: string, array: number[]): void;
  44820. /**
  44821. * 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)
  44822. * @param uniformName Name of the variable.
  44823. * @param array array to be set.
  44824. */
  44825. setArray4(uniformName: string, array: number[]): void;
  44826. /**
  44827. * Sets matrices on a uniform variable.
  44828. * @param uniformName Name of the variable.
  44829. * @param matrices matrices to be set.
  44830. */
  44831. setMatrices(uniformName: string, matrices: Float32Array): void;
  44832. /**
  44833. * Sets matrix on a uniform variable.
  44834. * @param uniformName Name of the variable.
  44835. * @param matrix matrix to be set.
  44836. */
  44837. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44838. /**
  44839. * 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)
  44840. * @param uniformName Name of the variable.
  44841. * @param matrix matrix to be set.
  44842. */
  44843. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44844. /**
  44845. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44846. * @param uniformName Name of the variable.
  44847. * @param matrix matrix to be set.
  44848. */
  44849. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44850. /**
  44851. * Sets a float on a uniform variable.
  44852. * @param uniformName Name of the variable.
  44853. * @param value value to be set.
  44854. * @returns this effect.
  44855. */
  44856. setFloat(uniformName: string, value: number): void;
  44857. /**
  44858. * Sets a Vector2 on a uniform variable.
  44859. * @param uniformName Name of the variable.
  44860. * @param vector2 vector2 to be set.
  44861. */
  44862. setVector2(uniformName: string, vector2: IVector2Like): void;
  44863. /**
  44864. * Sets a float2 on a uniform variable.
  44865. * @param uniformName Name of the variable.
  44866. * @param x First float in float2.
  44867. * @param y Second float in float2.
  44868. */
  44869. setFloat2(uniformName: string, x: number, y: number): void;
  44870. /**
  44871. * Sets a Vector3 on a uniform variable.
  44872. * @param uniformName Name of the variable.
  44873. * @param vector3 Value to be set.
  44874. */
  44875. setVector3(uniformName: string, vector3: IVector3Like): void;
  44876. /**
  44877. * Sets a float3 on a uniform variable.
  44878. * @param uniformName Name of the variable.
  44879. * @param x First float in float3.
  44880. * @param y Second float in float3.
  44881. * @param z Third float in float3.
  44882. */
  44883. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44884. /**
  44885. * Sets a Vector4 on a uniform variable.
  44886. * @param uniformName Name of the variable.
  44887. * @param vector4 Value to be set.
  44888. */
  44889. setVector4(uniformName: string, vector4: IVector4Like): void;
  44890. /**
  44891. * Sets a float4 on a uniform variable.
  44892. * @param uniformName Name of the variable.
  44893. * @param x First float in float4.
  44894. * @param y Second float in float4.
  44895. * @param z Third float in float4.
  44896. * @param w Fourth float in float4.
  44897. * @returns this effect.
  44898. */
  44899. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44900. /**
  44901. * Sets a Color3 on a uniform variable.
  44902. * @param uniformName Name of the variable.
  44903. * @param color3 Value to be set.
  44904. */
  44905. setColor3(uniformName: string, color3: IColor3Like): void;
  44906. /**
  44907. * Sets a Color4 on a uniform variable.
  44908. * @param uniformName Name of the variable.
  44909. * @param color3 Value to be set.
  44910. * @param alpha Alpha value to be set.
  44911. */
  44912. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44913. /**
  44914. * Sets a Color4 on a uniform variable
  44915. * @param uniformName defines the name of the variable
  44916. * @param color4 defines the value to be set
  44917. */
  44918. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44919. _getVertexShaderCode(): string | null;
  44920. _getFragmentShaderCode(): string | null;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /** @hidden */
  44925. export class WebGPUDataBuffer extends DataBuffer {
  44926. private _buffer;
  44927. constructor(resource: GPUBuffer);
  44928. get underlyingResource(): any;
  44929. }
  44930. }
  44931. declare module BABYLON {
  44932. /**
  44933. * Class used to inline functions in shader code
  44934. */
  44935. export class ShaderCodeInliner {
  44936. private static readonly _RegexpFindFunctionNameAndType;
  44937. private _sourceCode;
  44938. private _functionDescr;
  44939. private _numMaxIterations;
  44940. /** Gets or sets the token used to mark the functions to inline */
  44941. inlineToken: string;
  44942. /** Gets or sets the debug mode */
  44943. debug: boolean;
  44944. /** Gets the code after the inlining process */
  44945. get code(): string;
  44946. /**
  44947. * Initializes the inliner
  44948. * @param sourceCode shader code source to inline
  44949. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44950. */
  44951. constructor(sourceCode: string, numMaxIterations?: number);
  44952. /**
  44953. * Start the processing of the shader code
  44954. */
  44955. processCode(): void;
  44956. private _collectFunctions;
  44957. private _processInlining;
  44958. private _extractBetweenMarkers;
  44959. private _skipWhitespaces;
  44960. private _isIdentifierChar;
  44961. private _removeComments;
  44962. private _replaceFunctionCallsByCode;
  44963. private _findBackward;
  44964. private _escapeRegExp;
  44965. private _replaceNames;
  44966. }
  44967. }
  44968. declare module BABYLON {
  44969. /** @hidden */
  44970. export class WebGPUShaderProcessor implements IShaderProcessor {
  44971. protected _missingVaryings: Array<string>;
  44972. protected _textureArrayProcessing: Array<string>;
  44973. protected _preProcessors: {
  44974. [key: string]: string;
  44975. };
  44976. private _getArraySize;
  44977. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44978. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44979. [key: string]: string;
  44980. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44981. attributeProcessor(attribute: string, preProcessors: {
  44982. [key: string]: string;
  44983. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44984. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44985. [key: string]: string;
  44986. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44987. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44988. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44989. private _applyTextureArrayProcessing;
  44990. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44991. vertexCode: string;
  44992. fragmentCode: string;
  44993. };
  44994. }
  44995. }
  44996. declare module BABYLON {
  44997. /** @hidden */
  44998. export class WebGPUBufferManager {
  44999. private _device;
  45000. private _deferredReleaseBuffers;
  45001. private static _IsGPUBuffer;
  45002. constructor(device: GPUDevice);
  45003. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  45004. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  45005. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  45006. private _FromHalfFloat;
  45007. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  45008. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  45009. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  45010. destroyDeferredBuffers(): void;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /** @hidden */
  45015. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  45016. private _webgpuTexture;
  45017. private _webgpuMSAATexture;
  45018. get underlyingResource(): Nullable<GPUTexture>;
  45019. get msaaTexture(): Nullable<GPUTexture>;
  45020. set msaaTexture(texture: Nullable<GPUTexture>);
  45021. view: Nullable<GPUTextureView>;
  45022. format: GPUTextureFormat;
  45023. textureUsages: number;
  45024. constructor(existingTexture?: Nullable<GPUTexture>);
  45025. set(hardwareTexture: GPUTexture): void;
  45026. setMSAATexture(hardwareTexture: GPUTexture): void;
  45027. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45028. createView(descriptor?: GPUTextureViewDescriptor): void;
  45029. reset(): void;
  45030. release(): void;
  45031. }
  45032. }
  45033. declare module BABYLON {
  45034. /** @hidden */
  45035. export class WebGPUTextureHelper {
  45036. private _device;
  45037. private _glslang;
  45038. private _bufferManager;
  45039. private _mipmapSampler;
  45040. private _invertYPreMultiplyAlphaSampler;
  45041. private _pipelines;
  45042. private _compiledShaders;
  45043. private _deferredReleaseTextures;
  45044. private _commandEncoderForCreation;
  45045. static ComputeNumMipmapLevels(width: number, height: number): number;
  45046. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45047. private _getPipeline;
  45048. private static _GetTextureTypeFromFormat;
  45049. private static _GetBlockInformationFromFormat;
  45050. private static _IsHardwareTexture;
  45051. private static _IsInternalTexture;
  45052. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45053. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45054. width: number;
  45055. height: number;
  45056. }): imageBitmap is ImageBitmap;
  45057. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45058. width: number;
  45059. height: number;
  45060. }): imageBitmap is ImageBitmap[];
  45061. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45062. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45063. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45064. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45065. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45066. createTexture(imageBitmap: ImageBitmap | {
  45067. width: number;
  45068. height: number;
  45069. layers: number;
  45070. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45071. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45072. width: number;
  45073. height: number;
  45074. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45075. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45076. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45077. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45078. createMSAATexture(texture: InternalTexture, samples: number): void;
  45079. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45080. 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;
  45081. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45082. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45083. destroyDeferredTextures(): void;
  45084. }
  45085. }
  45086. declare module BABYLON {
  45087. /** @hidden */
  45088. export class WebGPURenderPassWrapper {
  45089. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45090. renderPass: Nullable<GPURenderPassEncoder>;
  45091. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45092. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45093. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45094. depthTextureFormat: GPUTextureFormat | undefined;
  45095. constructor();
  45096. reset(fullReset?: boolean): void;
  45097. }
  45098. }
  45099. declare module BABYLON {
  45100. /** @hidden */
  45101. export class WebGPUCacheSampler {
  45102. private _samplers;
  45103. private _device;
  45104. disabled: boolean;
  45105. constructor(device: GPUDevice);
  45106. private static _GetSamplerHashCode;
  45107. private static _GetSamplerFilterDescriptor;
  45108. private static _GetWrappingMode;
  45109. private static _GetSamplerWrappingDescriptor;
  45110. private static _GetSamplerDescriptor;
  45111. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. /** @hidden */
  45116. export class WebGPUShaderManager {
  45117. private _shaders;
  45118. private _device;
  45119. constructor(device: GPUDevice);
  45120. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45121. }
  45122. }
  45123. declare module BABYLON {
  45124. /** @hidden */
  45125. export abstract class WebGPUCacheRenderPipeline {
  45126. static NumCacheHitWithoutHash: number;
  45127. static NumCacheHitWithHash: number;
  45128. static NumCacheMiss: number;
  45129. static NumPipelineCreationLastFrame: number;
  45130. disabled: boolean;
  45131. private static _NumPipelineCreationCurrentFrame;
  45132. protected _states: number[];
  45133. protected _stateDirtyLowestIndex: number;
  45134. lastStateDirtyLowestIndex: number;
  45135. private _device;
  45136. private _isDirty;
  45137. private _emptyVertexBuffer;
  45138. private _parameter;
  45139. private _shaderId;
  45140. private _alphaToCoverageEnabled;
  45141. private _frontFace;
  45142. private _cullEnabled;
  45143. private _cullFace;
  45144. private _clampDepth;
  45145. private _rasterizationState;
  45146. private _depthBias;
  45147. private _depthBiasClamp;
  45148. private _depthBiasSlopeScale;
  45149. private _colorFormat;
  45150. private _webgpuColorFormat;
  45151. private _mrtAttachments1;
  45152. private _mrtAttachments2;
  45153. private _mrtFormats;
  45154. private _alphaBlendEnabled;
  45155. private _alphaBlendFuncParams;
  45156. private _alphaBlendEqParams;
  45157. private _writeMask;
  45158. private _colorStates;
  45159. private _depthStencilFormat;
  45160. private _webgpuDepthStencilFormat;
  45161. private _depthTestEnabled;
  45162. private _depthWriteEnabled;
  45163. private _depthCompare;
  45164. private _stencilEnabled;
  45165. private _stencilFrontCompare;
  45166. private _stencilFrontDepthFailOp;
  45167. private _stencilFrontPassOp;
  45168. private _stencilFrontFailOp;
  45169. private _stencilReadMask;
  45170. private _stencilWriteMask;
  45171. private _depthStencilState;
  45172. private _vertexBuffers;
  45173. private _overrideVertexBuffers;
  45174. private _indexBuffer;
  45175. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45176. reset(): void;
  45177. protected abstract _getRenderPipeline(param: {
  45178. token: any;
  45179. pipeline: Nullable<GPURenderPipeline>;
  45180. }): void;
  45181. protected abstract _setRenderPipeline(param: {
  45182. token: any;
  45183. pipeline: Nullable<GPURenderPipeline>;
  45184. }): void;
  45185. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45186. endFrame(): void;
  45187. setAlphaToCoverage(enabled: boolean): void;
  45188. setFrontFace(frontFace: number): void;
  45189. setCullEnabled(enabled: boolean): void;
  45190. setCullFace(cullFace: number): void;
  45191. setClampDepth(clampDepth: boolean): void;
  45192. resetDepthCullingState(): void;
  45193. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45194. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45195. setColorFormat(format: GPUTextureFormat): void;
  45196. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45197. setAlphaBlendEnabled(enabled: boolean): void;
  45198. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45199. setWriteMask(mask: number): void;
  45200. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45201. setDepthTestEnabled(enabled: boolean): void;
  45202. setDepthWriteEnabled(enabled: boolean): void;
  45203. setDepthCompare(func: Nullable<number>): void;
  45204. setStencilEnabled(enabled: boolean): void;
  45205. setStencilCompare(func: Nullable<number>): void;
  45206. setStencilDepthFailOp(op: Nullable<number>): void;
  45207. setStencilPassOp(op: Nullable<number>): void;
  45208. setStencilFailOp(op: Nullable<number>): void;
  45209. setStencilReadMask(mask: number): void;
  45210. setStencilWriteMask(mask: number): void;
  45211. resetStencilState(): void;
  45212. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45213. setBuffers(vertexBuffers: Nullable<{
  45214. [key: string]: Nullable<VertexBuffer>;
  45215. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45216. [key: string]: Nullable<VertexBuffer>;
  45217. }>): void;
  45218. private static _GetTopology;
  45219. private static _GetAphaBlendOperation;
  45220. private static _GetAphaBlendFactor;
  45221. private static _GetCompareFunction;
  45222. private static _GetStencilOpFunction;
  45223. private static _GetVertexInputDescriptorFormat;
  45224. private _getAphaBlendState;
  45225. private _getColorBlendState;
  45226. private _setShaderStage;
  45227. private _setRasterizationState;
  45228. private _setColorStates;
  45229. private _setDepthStencilState;
  45230. private _setVertexState;
  45231. private _createPipelineLayout;
  45232. private _getVertexInputDescriptor;
  45233. private _createRenderPipeline;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /** @hidden */
  45238. class NodeState {
  45239. values: {
  45240. [name: number]: NodeState;
  45241. };
  45242. pipeline: GPURenderPipeline;
  45243. constructor();
  45244. count(): [number, number];
  45245. }
  45246. /** @hidden */
  45247. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45248. private static _Cache;
  45249. private _nodeStack;
  45250. static GetNodeCounts(): {
  45251. nodeCount: number;
  45252. pipelineCount: number;
  45253. };
  45254. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45255. protected _getRenderPipeline(param: {
  45256. token: any;
  45257. pipeline: Nullable<GPURenderPipeline>;
  45258. }): void;
  45259. protected _setRenderPipeline(param: {
  45260. token: NodeState;
  45261. pipeline: Nullable<GPURenderPipeline>;
  45262. }): void;
  45263. }
  45264. }
  45265. declare module BABYLON {
  45266. /**
  45267. * @hidden
  45268. **/
  45269. export class WebGPUStencilState extends StencilState {
  45270. private _cache;
  45271. constructor(cache: WebGPUCacheRenderPipeline);
  45272. get stencilFunc(): number;
  45273. set stencilFunc(value: number);
  45274. get stencilFuncRef(): number;
  45275. set stencilFuncRef(value: number);
  45276. get stencilFuncMask(): number;
  45277. set stencilFuncMask(value: number);
  45278. get stencilOpStencilFail(): number;
  45279. set stencilOpStencilFail(value: number);
  45280. get stencilOpDepthFail(): number;
  45281. set stencilOpDepthFail(value: number);
  45282. get stencilOpStencilDepthPass(): number;
  45283. set stencilOpStencilDepthPass(value: number);
  45284. get stencilMask(): number;
  45285. set stencilMask(value: number);
  45286. get stencilTest(): boolean;
  45287. set stencilTest(value: boolean);
  45288. reset(): void;
  45289. apply(gl: WebGLRenderingContext): void;
  45290. }
  45291. }
  45292. declare module BABYLON {
  45293. /**
  45294. * @hidden
  45295. **/
  45296. export class WebGPUDepthCullingState extends DepthCullingState {
  45297. private _cache;
  45298. /**
  45299. * Initializes the state.
  45300. */
  45301. constructor(cache: WebGPUCacheRenderPipeline);
  45302. get zOffset(): number;
  45303. set zOffset(value: number);
  45304. get cullFace(): Nullable<number>;
  45305. set cullFace(value: Nullable<number>);
  45306. get cull(): Nullable<boolean>;
  45307. set cull(value: Nullable<boolean>);
  45308. get depthFunc(): Nullable<number>;
  45309. set depthFunc(value: Nullable<number>);
  45310. get depthMask(): boolean;
  45311. set depthMask(value: boolean);
  45312. get depthTest(): boolean;
  45313. set depthTest(value: boolean);
  45314. get frontFace(): Nullable<number>;
  45315. set frontFace(value: Nullable<number>);
  45316. reset(): void;
  45317. apply(gl: WebGLRenderingContext): void;
  45318. }
  45319. }
  45320. declare module BABYLON {
  45321. /** @hidden */
  45322. export var clearQuadVertexShader: {
  45323. name: string;
  45324. shader: string;
  45325. };
  45326. }
  45327. declare module BABYLON {
  45328. /** @hidden */
  45329. export var clearQuadPixelShader: {
  45330. name: string;
  45331. shader: string;
  45332. };
  45333. }
  45334. declare module BABYLON {
  45335. /**
  45336. * Options to load the associated Glslang library
  45337. */
  45338. export interface GlslangOptions {
  45339. /**
  45340. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45341. */
  45342. glslang?: any;
  45343. /**
  45344. * Defines the URL of the glslang JS File.
  45345. */
  45346. jsPath?: string;
  45347. /**
  45348. * Defines the URL of the glslang WASM File.
  45349. */
  45350. wasmPath?: string;
  45351. }
  45352. /**
  45353. * Options to create the WebGPU engine
  45354. */
  45355. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45356. /**
  45357. * If delta time between frames should be constant
  45358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45359. */
  45360. deterministicLockstep?: boolean;
  45361. /**
  45362. * Maximum about of steps between frames (Default: 4)
  45363. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45364. */
  45365. lockstepMaxSteps?: number;
  45366. /**
  45367. * Defines the seconds between each deterministic lock step
  45368. */
  45369. timeStep?: number;
  45370. /**
  45371. * Defines that engine should ignore modifying touch action attribute and style
  45372. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45373. */
  45374. doNotHandleTouchAction?: boolean;
  45375. /**
  45376. * Defines if webaudio should be initialized as well
  45377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45378. */
  45379. audioEngine?: boolean;
  45380. /**
  45381. * Defines the category of adapter to use.
  45382. * Is it the discrete or integrated device.
  45383. */
  45384. powerPreference?: GPUPowerPreference;
  45385. /**
  45386. * Defines the device descriptor used to create a device.
  45387. */
  45388. deviceDescriptor?: GPUDeviceDescriptor;
  45389. /**
  45390. * Defines the requested Swap Chain Format.
  45391. */
  45392. swapChainFormat?: GPUTextureFormat;
  45393. /**
  45394. * Defines whether MSAA is enabled on the canvas.
  45395. */
  45396. antialiasing?: boolean;
  45397. /**
  45398. * Defines whether the stencil buffer should be enabled.
  45399. */
  45400. stencil?: boolean;
  45401. /**
  45402. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45403. */
  45404. enableGPUDebugMarkers?: boolean;
  45405. /**
  45406. * Options to load the associated Glslang library
  45407. */
  45408. glslangOptions?: GlslangOptions;
  45409. }
  45410. /**
  45411. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45412. */
  45413. export class WebGPUEngine extends Engine {
  45414. private static readonly _glslangDefaultOptions;
  45415. private readonly _uploadEncoderDescriptor;
  45416. private readonly _renderEncoderDescriptor;
  45417. private readonly _renderTargetEncoderDescriptor;
  45418. private readonly _clearDepthValue;
  45419. private readonly _clearReverseDepthValue;
  45420. private readonly _clearStencilValue;
  45421. private readonly _defaultSampleCount;
  45422. private _canvas;
  45423. private _options;
  45424. private _glslang;
  45425. private _adapter;
  45426. private _adapterSupportedExtensions;
  45427. private _device;
  45428. private _deviceEnabledExtensions;
  45429. private _context;
  45430. private _swapChain;
  45431. private _swapChainTexture;
  45432. private _mainPassSampleCount;
  45433. private _textureHelper;
  45434. private _bufferManager;
  45435. private _shaderManager;
  45436. private _cacheSampler;
  45437. private _cacheRenderPipeline;
  45438. private _emptyVertexBuffer;
  45439. private _lastCachedWrapU;
  45440. private _lastCachedWrapV;
  45441. private _lastCachedWrapR;
  45442. private _mrtAttachments;
  45443. private _counters;
  45444. private _mainTexture;
  45445. private _depthTexture;
  45446. private _mainTextureExtends;
  45447. private _depthTextureFormat;
  45448. private _colorFormat;
  45449. private _uploadEncoder;
  45450. private _renderEncoder;
  45451. private _renderTargetEncoder;
  45452. private _commandBuffers;
  45453. private _currentRenderPass;
  45454. private _mainRenderPassWrapper;
  45455. private _rttRenderPassWrapper;
  45456. private _pendingDebugCommands;
  45457. private _currentVertexBuffers;
  45458. private _currentOverrideVertexBuffers;
  45459. private _currentIndexBuffer;
  45460. private __colorWrite;
  45461. private _uniformsBuffers;
  45462. private _forceEnableEffect;
  45463. /** @hidden */
  45464. dbgShowShaderCode: boolean;
  45465. /** @hidden */
  45466. dbgSanityChecks: boolean;
  45467. /** @hidden */
  45468. dbgGenerateLogs: boolean;
  45469. /** @hidden */
  45470. dbgVerboseLogsForFirstFrames: boolean;
  45471. /** @hidden */
  45472. dbgVerboseLogsNumFrames: number;
  45473. /** @hidden */
  45474. dbgShowWarningsNotImplemented: boolean;
  45475. /**
  45476. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45477. */
  45478. get disableCacheSamplers(): boolean;
  45479. set disableCacheSamplers(disable: boolean);
  45480. /**
  45481. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45482. */
  45483. get disableCacheRenderPipelines(): boolean;
  45484. set disableCacheRenderPipelines(disable: boolean);
  45485. /**
  45486. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45487. * @returns true if the engine can be created
  45488. */
  45489. static get IsSupported(): boolean;
  45490. /**
  45491. * Gets a boolean indicating that the engine supports uniform buffers
  45492. */
  45493. get supportsUniformBuffers(): boolean;
  45494. /** Gets the supported extensions by the WebGPU adapter */
  45495. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45496. /** Gets the currently enabled extensions on the WebGPU device */
  45497. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45498. /**
  45499. * Returns the name of the engine
  45500. */
  45501. get name(): string;
  45502. /**
  45503. * Returns a string describing the current engine
  45504. */
  45505. get description(): string;
  45506. /**
  45507. * Returns the version of the engine
  45508. */
  45509. get version(): number;
  45510. /**
  45511. * Create a new instance of the gpu engine asynchronously
  45512. * @param canvas Defines the canvas to use to display the result
  45513. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45514. * @returns a promise that resolves with the created engine
  45515. */
  45516. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45517. /**
  45518. * Create a new instance of the gpu engine.
  45519. * @param canvas Defines the canvas to use to display the result
  45520. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45521. */
  45522. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45523. /**
  45524. * Initializes the WebGPU context and dependencies.
  45525. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45526. * @returns a promise notifying the readiness of the engine.
  45527. */
  45528. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45529. private _initGlslang;
  45530. private _initializeLimits;
  45531. private _initializeContextAndSwapChain;
  45532. private _initializeMainAttachments;
  45533. /**
  45534. * Force a specific size of the canvas
  45535. * @param width defines the new canvas' width
  45536. * @param height defines the new canvas' height
  45537. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45538. * @returns true if the size was changed
  45539. */
  45540. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45541. /**
  45542. * Gets a shader processor implementation fitting with the current engine type.
  45543. * @returns The shader processor implementation.
  45544. */
  45545. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45546. /** @hidden */
  45547. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45548. /**
  45549. * Force the entire cache to be cleared
  45550. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45551. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45552. */
  45553. wipeCaches(bruteForce?: boolean): void;
  45554. /**
  45555. * Enable or disable color writing
  45556. * @param enable defines the state to set
  45557. */
  45558. setColorWrite(enable: boolean): void;
  45559. /**
  45560. * Gets a boolean indicating if color writing is enabled
  45561. * @returns the current color writing state
  45562. */
  45563. getColorWrite(): boolean;
  45564. private _viewportsCurrent;
  45565. private _resetCurrentViewport;
  45566. private _applyViewport;
  45567. /** @hidden */
  45568. _viewport(x: number, y: number, width: number, height: number): void;
  45569. private _scissorsCurrent;
  45570. protected _scissorCached: {
  45571. x: number;
  45572. y: number;
  45573. z: number;
  45574. w: number;
  45575. };
  45576. private _resetCurrentScissor;
  45577. private _applyScissor;
  45578. private _scissorIsActive;
  45579. enableScissor(x: number, y: number, width: number, height: number): void;
  45580. disableScissor(): void;
  45581. /**
  45582. * Clear the current render buffer or the current render target (if any is set up)
  45583. * @param color defines the color to use
  45584. * @param backBuffer defines if the back buffer must be cleared
  45585. * @param depth defines if the depth buffer must be cleared
  45586. * @param stencil defines if the stencil buffer must be cleared
  45587. */
  45588. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45589. /**
  45590. * Clears a list of attachments
  45591. * @param attachments list of the attachments
  45592. * @param colorMain clear color for the main attachment (the first one)
  45593. * @param colorOthers clear color for the other attachments
  45594. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45595. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45596. */
  45597. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45598. /**
  45599. * Creates a vertex buffer
  45600. * @param data the data for the vertex buffer
  45601. * @returns the new buffer
  45602. */
  45603. createVertexBuffer(data: DataArray): DataBuffer;
  45604. /**
  45605. * Creates a vertex buffer
  45606. * @param data the data for the dynamic vertex buffer
  45607. * @returns the new buffer
  45608. */
  45609. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45610. /**
  45611. * Updates a vertex buffer.
  45612. * @param vertexBuffer the vertex buffer to update
  45613. * @param data the data used to update the vertex buffer
  45614. * @param byteOffset the byte offset of the data
  45615. * @param byteLength the byte length of the data
  45616. */
  45617. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45618. /**
  45619. * Creates a new index buffer
  45620. * @param indices defines the content of the index buffer
  45621. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45622. * @returns a new buffer
  45623. */
  45624. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45625. /**
  45626. * Update an index buffer
  45627. * @param indexBuffer defines the target index buffer
  45628. * @param indices defines the data to update
  45629. * @param offset defines the offset in the target index buffer where update should start
  45630. */
  45631. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45632. /** @hidden */
  45633. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45634. /** @hidden */
  45635. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45636. /**
  45637. * Bind a list of vertex buffers with the engine
  45638. * @param vertexBuffers defines the list of vertex buffers to bind
  45639. * @param indexBuffer defines the index buffer to bind
  45640. * @param effect defines the effect associated with the vertex buffers
  45641. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45642. */
  45643. bindBuffers(vertexBuffers: {
  45644. [key: string]: Nullable<VertexBuffer>;
  45645. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45646. [kind: string]: Nullable<VertexBuffer>;
  45647. }): void;
  45648. /** @hidden */
  45649. _releaseBuffer(buffer: DataBuffer): boolean;
  45650. createUniformBuffer(elements: FloatArray): DataBuffer;
  45651. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45652. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45653. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45654. /**
  45655. * Create a new effect (used to store vertex/fragment shaders)
  45656. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45657. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45658. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45659. * @param samplers defines an array of string used to represent textures
  45660. * @param defines defines the string containing the defines to use to compile the shaders
  45661. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45662. * @param onCompiled defines a function to call when the effect creation is successful
  45663. * @param onError defines a function to call when the effect creation has failed
  45664. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45665. * @returns the new Effect
  45666. */
  45667. 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;
  45668. private _compileRawShaderToSpirV;
  45669. private _compileShaderToSpirV;
  45670. private _createPipelineStageDescriptor;
  45671. private _compileRawPipelineStageDescriptor;
  45672. private _compilePipelineStageDescriptor;
  45673. /** @hidden */
  45674. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45675. /** @hidden */
  45676. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45677. /**
  45678. * Creates a new pipeline context
  45679. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45680. * @returns the new pipeline
  45681. */
  45682. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45683. /** @hidden */
  45684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45685. /**
  45686. * Gets the list of active attributes for a given WebGPU program
  45687. * @param pipelineContext defines the pipeline context to use
  45688. * @param attributesNames defines the list of attribute names to get
  45689. * @returns an array of indices indicating the offset of each attribute
  45690. */
  45691. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45692. /**
  45693. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45694. * @param effect defines the effect to activate
  45695. */
  45696. enableEffect(effect: Nullable<Effect>): void;
  45697. /** @hidden */
  45698. _releaseEffect(effect: Effect): void;
  45699. /**
  45700. * 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
  45701. */
  45702. releaseEffects(): void;
  45703. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45704. /**
  45705. * Gets a boolean indicating that only power of 2 textures are supported
  45706. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45707. */
  45708. get needPOTTextures(): boolean;
  45709. /** @hidden */
  45710. _createHardwareTexture(): HardwareTextureWrapper;
  45711. /** @hidden */
  45712. _releaseTexture(texture: InternalTexture): void;
  45713. /** @hidden */
  45714. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45715. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45716. /**
  45717. * Usually called from Texture.ts.
  45718. * Passed information to create a hardware texture
  45719. * @param url defines a value which contains one of the following:
  45720. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45721. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45722. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45723. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45724. * @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)
  45725. * @param scene needed for loading to the correct scene
  45726. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45727. * @param onLoad optional callback to be called upon successful completion
  45728. * @param onError optional callback to be called upon failure
  45729. * @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
  45730. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45731. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45732. * @param forcedExtension defines the extension to use to pick the right loader
  45733. * @param mimeType defines an optional mime type
  45734. * @param loaderOptions options to be passed to the loader
  45735. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45736. */
  45737. 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;
  45738. /** @hidden */
  45739. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45740. /**
  45741. * Creates a cube texture
  45742. * @param rootUrl defines the url where the files to load is located
  45743. * @param scene defines the current scene
  45744. * @param files defines the list of files to load (1 per face)
  45745. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45746. * @param onLoad defines an optional callback raised when the texture is loaded
  45747. * @param onError defines an optional callback raised if there is an issue to load the texture
  45748. * @param format defines the format of the data
  45749. * @param forcedExtension defines the extension to use to pick the right loader
  45750. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45751. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45752. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45753. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45754. * @param loaderOptions options to be passed to the loader
  45755. * @returns the cube texture as an InternalTexture
  45756. */
  45757. 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;
  45758. /**
  45759. * Creates a raw texture
  45760. * @param data defines the data to store in the texture
  45761. * @param width defines the width of the texture
  45762. * @param height defines the height of the texture
  45763. * @param format defines the format of the data
  45764. * @param generateMipMaps defines if the engine should generate the mip levels
  45765. * @param invertY defines if data must be stored with Y axis inverted
  45766. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45767. * @param compression defines the compression used (null by default)
  45768. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45769. * @returns the raw texture inside an InternalTexture
  45770. */
  45771. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45772. /**
  45773. * Creates a new raw cube texture
  45774. * @param data defines the array of data to use to create each face
  45775. * @param size defines the size of the textures
  45776. * @param format defines the format of the data
  45777. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45778. * @param generateMipMaps defines if the engine should generate the mip levels
  45779. * @param invertY defines if data must be stored with Y axis inverted
  45780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45781. * @param compression defines the compression used (null by default)
  45782. * @returns the cube texture as an InternalTexture
  45783. */
  45784. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45785. /**
  45786. * Creates a new raw cube texture from a specified url
  45787. * @param url defines the url where the data is located
  45788. * @param scene defines the current scene
  45789. * @param size defines the size of the textures
  45790. * @param format defines the format of the data
  45791. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45792. * @param noMipmap defines if the engine should avoid generating the mip levels
  45793. * @param callback defines a callback used to extract texture data from loaded data
  45794. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45795. * @param onLoad defines a callback called when texture is loaded
  45796. * @param onError defines a callback called if there is an error
  45797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45798. * @param invertY defines if data must be stored with Y axis inverted
  45799. * @returns the cube texture as an InternalTexture
  45800. */
  45801. 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;
  45802. /**
  45803. * Creates a new raw 2D array texture
  45804. * @param data defines the data used to create the texture
  45805. * @param width defines the width of the texture
  45806. * @param height defines the height of the texture
  45807. * @param depth defines the number of layers of the texture
  45808. * @param format defines the format of the texture
  45809. * @param generateMipMaps defines if the engine must generate mip levels
  45810. * @param invertY defines if data must be stored with Y axis inverted
  45811. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45812. * @param compression defines the compressed used (can be null)
  45813. * @param textureType defines the compressed used (can be null)
  45814. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45815. */
  45816. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45817. /**
  45818. * Creates a new raw 3D texture
  45819. * @param data defines the data used to create the texture
  45820. * @param width defines the width of the texture
  45821. * @param height defines the height of the texture
  45822. * @param depth defines the depth of the texture
  45823. * @param format defines the format of the texture
  45824. * @param generateMipMaps defines if the engine must generate mip levels
  45825. * @param invertY defines if data must be stored with Y axis inverted
  45826. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45827. * @param compression defines the compressed used (can be null)
  45828. * @param textureType defines the compressed used (can be null)
  45829. * @returns a new raw 3D texture (stored in an InternalTexture)
  45830. */
  45831. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45832. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45833. /**
  45834. * Update the sampling mode of a given texture
  45835. * @param samplingMode defines the required sampling mode
  45836. * @param texture defines the texture to update
  45837. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45838. */
  45839. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45840. /**
  45841. * Update the sampling mode of a given texture
  45842. * @param texture defines the texture to update
  45843. * @param wrapU defines the texture wrap mode of the u coordinates
  45844. * @param wrapV defines the texture wrap mode of the v coordinates
  45845. * @param wrapR defines the texture wrap mode of the r coordinates
  45846. */
  45847. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45848. /**
  45849. * Update the dimensions of a texture
  45850. * @param texture texture to update
  45851. * @param width new width of the texture
  45852. * @param height new height of the texture
  45853. * @param depth new depth of the texture
  45854. */
  45855. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45856. private _setInternalTexture;
  45857. /**
  45858. * Sets a texture to the according uniform.
  45859. * @param channel The texture channel
  45860. * @param unused unused parameter
  45861. * @param texture The texture to apply
  45862. * @param name The name of the uniform in the effect
  45863. */
  45864. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45865. /**
  45866. * Sets an array of texture to the WebGPU context
  45867. * @param channel defines the channel where the texture array must be set
  45868. * @param unused unused parameter
  45869. * @param textures defines the array of textures to bind
  45870. * @param name name of the channel
  45871. */
  45872. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45873. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45874. /** @hidden */
  45875. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45876. /** @hidden */
  45877. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45878. private _generateMipmaps;
  45879. /**
  45880. * Update the content of a texture
  45881. * @param texture defines the texture to update
  45882. * @param canvas defines the source containing the data
  45883. * @param invertY defines if data must be stored with Y axis inverted
  45884. * @param premulAlpha defines if alpha is stored as premultiplied
  45885. * @param format defines the format of the data
  45886. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45887. */
  45888. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45889. /**
  45890. * Update a portion of an internal texture
  45891. * @param texture defines the texture to update
  45892. * @param imageData defines the data to store into the texture
  45893. * @param xOffset defines the x coordinates of the update rectangle
  45894. * @param yOffset defines the y coordinates of the update rectangle
  45895. * @param width defines the width of the update rectangle
  45896. * @param height defines the height of the update rectangle
  45897. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45898. * @param lod defines the lod level to update (0 by default)
  45899. */
  45900. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45901. /**
  45902. * Update a video texture
  45903. * @param texture defines the texture to update
  45904. * @param video defines the video element to use
  45905. * @param invertY defines if data must be stored with Y axis inverted
  45906. */
  45907. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45908. /** @hidden */
  45909. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45910. /** @hidden */
  45911. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45912. /** @hidden */
  45913. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45914. /** @hidden */
  45915. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45916. /**
  45917. * Update a raw texture
  45918. * @param texture defines the texture to update
  45919. * @param bufferView defines the data to store in the texture
  45920. * @param format defines the format of the data
  45921. * @param invertY defines if data must be stored with Y axis inverted
  45922. * @param compression defines the compression used (null by default)
  45923. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45924. */
  45925. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45926. /**
  45927. * Update a raw cube texture
  45928. * @param texture defines the texture to update
  45929. * @param bufferView defines the data to store
  45930. * @param format defines the data format
  45931. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45932. * @param invertY defines if data must be stored with Y axis inverted
  45933. * @param compression defines the compression used (null by default)
  45934. * @param level defines which level of the texture to update
  45935. */
  45936. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45937. /**
  45938. * Update a raw 2D array texture
  45939. * @param texture defines the texture to update
  45940. * @param bufferView defines the data to store
  45941. * @param format defines the data format
  45942. * @param invertY defines if data must be stored with Y axis inverted
  45943. * @param compression defines the used compression (can be null)
  45944. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45945. */
  45946. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45947. /**
  45948. * Update a raw 3D texture
  45949. * @param texture defines the texture to update
  45950. * @param bufferView defines the data to store
  45951. * @param format defines the data format
  45952. * @param invertY defines if data must be stored with Y axis inverted
  45953. * @param compression defines the used compression (can be null)
  45954. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45955. */
  45956. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45957. /**
  45958. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45959. * @param x defines the x coordinate of the rectangle where pixels must be read
  45960. * @param y defines the y coordinate of the rectangle where pixels must be read
  45961. * @param width defines the width of the rectangle where pixels must be read
  45962. * @param height defines the height of the rectangle where pixels must be read
  45963. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45964. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45965. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45966. */
  45967. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45968. /** @hidden */
  45969. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45970. /** @hidden */
  45971. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45972. /**
  45973. * Creates a new render target texture
  45974. * @param size defines the size of the texture
  45975. * @param options defines the options used to create the texture
  45976. * @returns a new render target texture stored in an InternalTexture
  45977. */
  45978. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45979. /**
  45980. * Create a multi render target texture
  45981. * @param size defines the size of the texture
  45982. * @param options defines the creation options
  45983. * @returns the cube texture as an InternalTexture
  45984. */
  45985. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45986. /**
  45987. * Creates a new render target cube texture
  45988. * @param size defines the size of the texture
  45989. * @param options defines the options used to create the texture
  45990. * @returns a new render target cube texture stored in an InternalTexture
  45991. */
  45992. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45993. /** @hidden */
  45994. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45995. width: number;
  45996. height: number;
  45997. layers?: number;
  45998. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45999. /** @hidden */
  46000. _createDepthStencilTexture(size: number | {
  46001. width: number;
  46002. height: number;
  46003. layers?: number;
  46004. }, options: DepthTextureCreationOptions): InternalTexture;
  46005. /** @hidden */
  46006. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46007. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46008. /**
  46009. * Update the sample count for a given multiple render target texture
  46010. * @param textures defines the textures to update
  46011. * @param samples defines the sample count to set
  46012. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46013. */
  46014. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46015. /**
  46016. * Begin a new frame
  46017. */
  46018. beginFrame(): void;
  46019. /**
  46020. * End the current frame
  46021. */
  46022. endFrame(): void;
  46023. /**
  46024. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46025. */
  46026. flushFramebuffer(): void;
  46027. private _startRenderTargetRenderPass;
  46028. private _endRenderTargetRenderPass;
  46029. private _getCurrentRenderPass;
  46030. private _startMainRenderPass;
  46031. private _endMainRenderPass;
  46032. /**
  46033. * Restores the WebGPU state to only draw on the main color attachment
  46034. */
  46035. restoreSingleAttachment(): void;
  46036. /**
  46037. * Creates a layout object to draw/clear on specific textures in a MRT
  46038. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46039. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46040. */
  46041. buildTextureLayout(textureStatus: boolean[]): number[];
  46042. /**
  46043. * Select a subsets of attachments to draw to.
  46044. * @param attachments index of attachments
  46045. */
  46046. bindAttachments(attachments: number[]): void;
  46047. /**
  46048. * Binds the frame buffer to the specified texture.
  46049. * @param texture The texture to render to or null for the default canvas
  46050. * @param faceIndex The face of the texture to render to in case of cube texture
  46051. * @param requiredWidth The width of the target to render to
  46052. * @param requiredHeight The height of the target to render to
  46053. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46054. * @param lodLevel defines the lod level to bind to the frame buffer
  46055. * @param layer defines the 2d array index to bind to frame buffer to
  46056. */
  46057. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46058. /**
  46059. * Unbind the current render target texture from the WebGPU context
  46060. * @param texture defines the render target texture to unbind
  46061. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46062. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46063. */
  46064. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46065. /**
  46066. * Unbind a list of render target textures from the WebGPU context
  46067. * @param textures defines the render target textures to unbind
  46068. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46069. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46070. */
  46071. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46072. /**
  46073. * Unbind the current render target and bind the default framebuffer
  46074. */
  46075. restoreDefaultFramebuffer(): void;
  46076. private _setColorFormat;
  46077. private _setDepthTextureFormat;
  46078. setDitheringState(value: boolean): void;
  46079. setRasterizerState(value: boolean): void;
  46080. /**
  46081. * Set various states to the context
  46082. * @param culling defines backface culling state
  46083. * @param zOffset defines the value to apply to zOffset (0 by default)
  46084. * @param force defines if states must be applied even if cache is up to date
  46085. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46086. */
  46087. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46088. /**
  46089. * Sets the current alpha mode
  46090. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46091. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46092. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46093. */
  46094. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46095. /**
  46096. * Sets the current alpha equation
  46097. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46098. */
  46099. setAlphaEquation(equation: number): void;
  46100. private _getBindGroupsToRender;
  46101. private _bindVertexInputs;
  46102. private _setRenderBindGroups;
  46103. private _setRenderPipeline;
  46104. /**
  46105. * Draw a list of indexed primitives
  46106. * @param fillMode defines the primitive to use
  46107. * @param indexStart defines the starting index
  46108. * @param indexCount defines the number of index to draw
  46109. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46110. */
  46111. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46112. /**
  46113. * Draw a list of unindexed primitives
  46114. * @param fillMode defines the primitive to use
  46115. * @param verticesStart defines the index of first vertex to draw
  46116. * @param verticesCount defines the count of vertices to draw
  46117. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46118. */
  46119. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46120. private _bundleEncoder;
  46121. /**
  46122. * Start recording all the gpu calls into a bundle.
  46123. */
  46124. startRecordBundle(): void;
  46125. /**
  46126. * Stops recording the bundle.
  46127. * @returns the recorded bundle
  46128. */
  46129. stopRecordBundle(): GPURenderBundle;
  46130. /**
  46131. * Execute the previously recorded bundle.
  46132. * @param bundles defines the bundle to replay
  46133. */
  46134. executeBundles(bundles: GPURenderBundle[]): void;
  46135. /**
  46136. * Dispose and release all associated resources
  46137. */
  46138. dispose(): void;
  46139. /**
  46140. * Gets the current render width
  46141. * @param useScreen defines if screen size must be used (or the current render target if any)
  46142. * @returns a number defining the current render width
  46143. */
  46144. getRenderWidth(useScreen?: boolean): number;
  46145. /**
  46146. * Gets the current render height
  46147. * @param useScreen defines if screen size must be used (or the current render target if any)
  46148. * @returns a number defining the current render height
  46149. */
  46150. getRenderHeight(useScreen?: boolean): number;
  46151. /**
  46152. * Gets the HTML canvas attached with the current WebGPU context
  46153. * @returns a HTML canvas
  46154. */
  46155. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46156. /** @hidden */
  46157. _debugPushGroup(groupName: string, targetObject?: number): void;
  46158. /** @hidden */
  46159. _debugPopGroup(targetObject?: number): void;
  46160. /** @hidden */
  46161. _debugInsertMarker(text: string, targetObject?: number): void;
  46162. private _debugFlushPendingCommands;
  46163. /**
  46164. * Get the current error code of the WebGPU context
  46165. * @returns the error code
  46166. */
  46167. getError(): number;
  46168. /** @hidden */
  46169. bindSamplers(effect: Effect): void;
  46170. /** @hidden */
  46171. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46172. /** @hidden */
  46173. _releaseFramebufferObjects(texture: InternalTexture): void;
  46174. /** @hidden */
  46175. applyStates(): void;
  46176. /**
  46177. * Gets a boolean indicating if all created effects are ready
  46178. * @returns always true - No parallel shader compilation
  46179. */
  46180. areAllEffectsReady(): boolean;
  46181. /** @hidden */
  46182. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46183. /** @hidden */
  46184. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46185. /** @hidden */
  46186. _getUnpackAlignement(): number;
  46187. /** @hidden */
  46188. _unpackFlipY(value: boolean): void;
  46189. /** @hidden */
  46190. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46191. min: number;
  46192. mag: number;
  46193. };
  46194. /** @hidden */
  46195. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46196. /** @hidden */
  46197. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46198. /** @hidden */
  46199. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46200. /** @hidden */
  46201. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46202. /** @hidden */
  46203. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46204. /** @hidden */
  46205. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46206. /** @hidden */
  46207. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46208. /** @hidden */
  46209. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46210. /** @hidden */
  46211. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46212. /** @hidden */
  46213. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46214. /** @hidden */
  46215. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46216. /** @hidden */
  46217. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46218. /** @hidden */
  46219. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46220. /** @hidden */
  46221. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46222. /** @hidden */
  46223. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46224. /** @hidden */
  46225. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46226. /** @hidden */
  46227. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46228. }
  46229. }
  46230. declare module BABYLON {
  46231. /**
  46232. * Define an interface for all classes that will hold resources
  46233. */
  46234. export interface IDisposable {
  46235. /**
  46236. * Releases all held resources
  46237. */
  46238. dispose(): void;
  46239. }
  46240. /** Interface defining initialization parameters for Scene class */
  46241. export interface SceneOptions {
  46242. /**
  46243. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46244. * It will improve performance when the number of geometries becomes important.
  46245. */
  46246. useGeometryUniqueIdsMap?: boolean;
  46247. /**
  46248. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46249. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46250. */
  46251. useMaterialMeshMap?: boolean;
  46252. /**
  46253. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46254. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46255. */
  46256. useClonedMeshMap?: boolean;
  46257. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46258. virtual?: boolean;
  46259. }
  46260. /**
  46261. * Represents a scene to be rendered by the engine.
  46262. * @see https://doc.babylonjs.com/features/scene
  46263. */
  46264. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46265. /** The fog is deactivated */
  46266. static readonly FOGMODE_NONE: number;
  46267. /** The fog density is following an exponential function */
  46268. static readonly FOGMODE_EXP: number;
  46269. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46270. static readonly FOGMODE_EXP2: number;
  46271. /** The fog density is following a linear function. */
  46272. static readonly FOGMODE_LINEAR: number;
  46273. /**
  46274. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46276. */
  46277. static MinDeltaTime: number;
  46278. /**
  46279. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46281. */
  46282. static MaxDeltaTime: number;
  46283. /**
  46284. * Factory used to create the default material.
  46285. * @param name The name of the material to create
  46286. * @param scene The scene to create the material for
  46287. * @returns The default material
  46288. */
  46289. static DefaultMaterialFactory(scene: Scene): Material;
  46290. /**
  46291. * Factory used to create the a collision coordinator.
  46292. * @returns The collision coordinator
  46293. */
  46294. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46295. /** @hidden */
  46296. _inputManager: InputManager;
  46297. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46298. cameraToUseForPointers: Nullable<Camera>;
  46299. /** @hidden */
  46300. readonly _isScene: boolean;
  46301. /** @hidden */
  46302. _blockEntityCollection: boolean;
  46303. /**
  46304. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46305. */
  46306. autoClear: boolean;
  46307. /**
  46308. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46309. */
  46310. autoClearDepthAndStencil: boolean;
  46311. /**
  46312. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46313. */
  46314. clearColor: Color4;
  46315. /**
  46316. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46317. */
  46318. ambientColor: Color3;
  46319. /**
  46320. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46321. * It should only be one of the following (if not the default embedded one):
  46322. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46323. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46324. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46325. * The material properties need to be setup according to the type of texture in use.
  46326. */
  46327. environmentBRDFTexture: BaseTexture;
  46328. /**
  46329. * Texture used in all pbr material as the reflection texture.
  46330. * As in the majority of the scene they are the same (exception for multi room and so on),
  46331. * this is easier to reference from here than from all the materials.
  46332. */
  46333. get environmentTexture(): Nullable<BaseTexture>;
  46334. /**
  46335. * Texture used in all pbr material as the reflection texture.
  46336. * As in the majority of the scene they are the same (exception for multi room and so on),
  46337. * this is easier to set here than in all the materials.
  46338. */
  46339. set environmentTexture(value: Nullable<BaseTexture>);
  46340. /** @hidden */
  46341. protected _environmentIntensity: number;
  46342. /**
  46343. * Intensity of the environment in all pbr material.
  46344. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46345. * As in the majority of the scene they are the same (exception for multi room and so on),
  46346. * this is easier to reference from here than from all the materials.
  46347. */
  46348. get environmentIntensity(): number;
  46349. /**
  46350. * Intensity of the environment in all pbr material.
  46351. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46352. * As in the majority of the scene they are the same (exception for multi room and so on),
  46353. * this is easier to set here than in all the materials.
  46354. */
  46355. set environmentIntensity(value: number);
  46356. /** @hidden */
  46357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46358. /**
  46359. * Default image processing configuration used either in the rendering
  46360. * Forward main pass or through the imageProcessingPostProcess if present.
  46361. * As in the majority of the scene they are the same (exception for multi camera),
  46362. * this is easier to reference from here than from all the materials and post process.
  46363. *
  46364. * No setter as we it is a shared configuration, you can set the values instead.
  46365. */
  46366. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46367. private _forceWireframe;
  46368. /**
  46369. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46370. */
  46371. set forceWireframe(value: boolean);
  46372. get forceWireframe(): boolean;
  46373. private _skipFrustumClipping;
  46374. /**
  46375. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46376. */
  46377. set skipFrustumClipping(value: boolean);
  46378. get skipFrustumClipping(): boolean;
  46379. private _forcePointsCloud;
  46380. /**
  46381. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46382. */
  46383. set forcePointsCloud(value: boolean);
  46384. get forcePointsCloud(): boolean;
  46385. /**
  46386. * Gets or sets the active clipplane 1
  46387. */
  46388. clipPlane: Nullable<Plane>;
  46389. /**
  46390. * Gets or sets the active clipplane 2
  46391. */
  46392. clipPlane2: Nullable<Plane>;
  46393. /**
  46394. * Gets or sets the active clipplane 3
  46395. */
  46396. clipPlane3: Nullable<Plane>;
  46397. /**
  46398. * Gets or sets the active clipplane 4
  46399. */
  46400. clipPlane4: Nullable<Plane>;
  46401. /**
  46402. * Gets or sets the active clipplane 5
  46403. */
  46404. clipPlane5: Nullable<Plane>;
  46405. /**
  46406. * Gets or sets the active clipplane 6
  46407. */
  46408. clipPlane6: Nullable<Plane>;
  46409. /**
  46410. * Gets or sets a boolean indicating if animations are enabled
  46411. */
  46412. animationsEnabled: boolean;
  46413. private _animationPropertiesOverride;
  46414. /**
  46415. * Gets or sets the animation properties override
  46416. */
  46417. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46418. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46419. /**
  46420. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46421. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46422. */
  46423. useConstantAnimationDeltaTime: boolean;
  46424. /**
  46425. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46426. * Please note that it requires to run a ray cast through the scene on every frame
  46427. */
  46428. constantlyUpdateMeshUnderPointer: boolean;
  46429. /**
  46430. * Defines the HTML cursor to use when hovering over interactive elements
  46431. */
  46432. hoverCursor: string;
  46433. /**
  46434. * Defines the HTML default cursor to use (empty by default)
  46435. */
  46436. defaultCursor: string;
  46437. /**
  46438. * Defines whether cursors are handled by the scene.
  46439. */
  46440. doNotHandleCursors: boolean;
  46441. /**
  46442. * This is used to call preventDefault() on pointer down
  46443. * in order to block unwanted artifacts like system double clicks
  46444. */
  46445. preventDefaultOnPointerDown: boolean;
  46446. /**
  46447. * This is used to call preventDefault() on pointer up
  46448. * in order to block unwanted artifacts like system double clicks
  46449. */
  46450. preventDefaultOnPointerUp: boolean;
  46451. /**
  46452. * Gets or sets user defined metadata
  46453. */
  46454. metadata: any;
  46455. /**
  46456. * For internal use only. Please do not use.
  46457. */
  46458. reservedDataStore: any;
  46459. /**
  46460. * Gets the name of the plugin used to load this scene (null by default)
  46461. */
  46462. loadingPluginName: string;
  46463. /**
  46464. * Use this array to add regular expressions used to disable offline support for specific urls
  46465. */
  46466. disableOfflineSupportExceptionRules: RegExp[];
  46467. /**
  46468. * An event triggered when the scene is disposed.
  46469. */
  46470. onDisposeObservable: Observable<Scene>;
  46471. private _onDisposeObserver;
  46472. /** Sets a function to be executed when this scene is disposed. */
  46473. set onDispose(callback: () => void);
  46474. /**
  46475. * An event triggered before rendering the scene (right after animations and physics)
  46476. */
  46477. onBeforeRenderObservable: Observable<Scene>;
  46478. private _onBeforeRenderObserver;
  46479. /** Sets a function to be executed before rendering this scene */
  46480. set beforeRender(callback: Nullable<() => void>);
  46481. /**
  46482. * An event triggered after rendering the scene
  46483. */
  46484. onAfterRenderObservable: Observable<Scene>;
  46485. /**
  46486. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46487. */
  46488. onAfterRenderCameraObservable: Observable<Camera>;
  46489. private _onAfterRenderObserver;
  46490. /** Sets a function to be executed after rendering this scene */
  46491. set afterRender(callback: Nullable<() => void>);
  46492. /**
  46493. * An event triggered before animating the scene
  46494. */
  46495. onBeforeAnimationsObservable: Observable<Scene>;
  46496. /**
  46497. * An event triggered after animations processing
  46498. */
  46499. onAfterAnimationsObservable: Observable<Scene>;
  46500. /**
  46501. * An event triggered before draw calls are ready to be sent
  46502. */
  46503. onBeforeDrawPhaseObservable: Observable<Scene>;
  46504. /**
  46505. * An event triggered after draw calls have been sent
  46506. */
  46507. onAfterDrawPhaseObservable: Observable<Scene>;
  46508. /**
  46509. * An event triggered when the scene is ready
  46510. */
  46511. onReadyObservable: Observable<Scene>;
  46512. /**
  46513. * An event triggered before rendering a camera
  46514. */
  46515. onBeforeCameraRenderObservable: Observable<Camera>;
  46516. private _onBeforeCameraRenderObserver;
  46517. /** Sets a function to be executed before rendering a camera*/
  46518. set beforeCameraRender(callback: () => void);
  46519. /**
  46520. * An event triggered after rendering a camera
  46521. */
  46522. onAfterCameraRenderObservable: Observable<Camera>;
  46523. private _onAfterCameraRenderObserver;
  46524. /** Sets a function to be executed after rendering a camera*/
  46525. set afterCameraRender(callback: () => void);
  46526. /**
  46527. * An event triggered when active meshes evaluation is about to start
  46528. */
  46529. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46530. /**
  46531. * An event triggered when active meshes evaluation is done
  46532. */
  46533. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46534. /**
  46535. * An event triggered when particles rendering is about to start
  46536. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46537. */
  46538. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46539. /**
  46540. * An event triggered when particles rendering is done
  46541. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46542. */
  46543. onAfterParticlesRenderingObservable: Observable<Scene>;
  46544. /**
  46545. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46546. */
  46547. onDataLoadedObservable: Observable<Scene>;
  46548. /**
  46549. * An event triggered when a camera is created
  46550. */
  46551. onNewCameraAddedObservable: Observable<Camera>;
  46552. /**
  46553. * An event triggered when a camera is removed
  46554. */
  46555. onCameraRemovedObservable: Observable<Camera>;
  46556. /**
  46557. * An event triggered when a light is created
  46558. */
  46559. onNewLightAddedObservable: Observable<Light>;
  46560. /**
  46561. * An event triggered when a light is removed
  46562. */
  46563. onLightRemovedObservable: Observable<Light>;
  46564. /**
  46565. * An event triggered when a geometry is created
  46566. */
  46567. onNewGeometryAddedObservable: Observable<Geometry>;
  46568. /**
  46569. * An event triggered when a geometry is removed
  46570. */
  46571. onGeometryRemovedObservable: Observable<Geometry>;
  46572. /**
  46573. * An event triggered when a transform node is created
  46574. */
  46575. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46576. /**
  46577. * An event triggered when a transform node is removed
  46578. */
  46579. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46580. /**
  46581. * An event triggered when a mesh is created
  46582. */
  46583. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46584. /**
  46585. * An event triggered when a mesh is removed
  46586. */
  46587. onMeshRemovedObservable: Observable<AbstractMesh>;
  46588. /**
  46589. * An event triggered when a skeleton is created
  46590. */
  46591. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46592. /**
  46593. * An event triggered when a skeleton is removed
  46594. */
  46595. onSkeletonRemovedObservable: Observable<Skeleton>;
  46596. /**
  46597. * An event triggered when a material is created
  46598. */
  46599. onNewMaterialAddedObservable: Observable<Material>;
  46600. /**
  46601. * An event triggered when a multi material is created
  46602. */
  46603. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46604. /**
  46605. * An event triggered when a material is removed
  46606. */
  46607. onMaterialRemovedObservable: Observable<Material>;
  46608. /**
  46609. * An event triggered when a multi material is removed
  46610. */
  46611. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46612. /**
  46613. * An event triggered when a texture is created
  46614. */
  46615. onNewTextureAddedObservable: Observable<BaseTexture>;
  46616. /**
  46617. * An event triggered when a texture is removed
  46618. */
  46619. onTextureRemovedObservable: Observable<BaseTexture>;
  46620. /**
  46621. * An event triggered when render targets are about to be rendered
  46622. * Can happen multiple times per frame.
  46623. */
  46624. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46625. /**
  46626. * An event triggered when render targets were rendered.
  46627. * Can happen multiple times per frame.
  46628. */
  46629. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46630. /**
  46631. * An event triggered before calculating deterministic simulation step
  46632. */
  46633. onBeforeStepObservable: Observable<Scene>;
  46634. /**
  46635. * An event triggered after calculating deterministic simulation step
  46636. */
  46637. onAfterStepObservable: Observable<Scene>;
  46638. /**
  46639. * An event triggered when the activeCamera property is updated
  46640. */
  46641. onActiveCameraChanged: Observable<Scene>;
  46642. /**
  46643. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46644. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46645. * 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)
  46646. */
  46647. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46648. /**
  46649. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46650. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46651. * 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)
  46652. */
  46653. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46654. /**
  46655. * This Observable will when a mesh has been imported into the scene.
  46656. */
  46657. onMeshImportedObservable: Observable<AbstractMesh>;
  46658. /**
  46659. * This Observable will when an animation file has been imported into the scene.
  46660. */
  46661. onAnimationFileImportedObservable: Observable<Scene>;
  46662. /**
  46663. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46664. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46665. */
  46666. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46667. /** @hidden */
  46668. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46669. /**
  46670. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46671. */
  46672. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46673. /**
  46674. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46675. */
  46676. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46677. /**
  46678. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46679. */
  46680. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46681. /** Callback called when a pointer move is detected */
  46682. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46683. /** Callback called when a pointer down is detected */
  46684. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46685. /** Callback called when a pointer up is detected */
  46686. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46687. /** Callback called when a pointer pick is detected */
  46688. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46689. /**
  46690. * 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).
  46691. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46692. */
  46693. onPrePointerObservable: Observable<PointerInfoPre>;
  46694. /**
  46695. * Observable event triggered each time an input event is received from the rendering canvas
  46696. */
  46697. onPointerObservable: Observable<PointerInfo>;
  46698. /**
  46699. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46700. */
  46701. get unTranslatedPointer(): Vector2;
  46702. /**
  46703. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46704. */
  46705. static get DragMovementThreshold(): number;
  46706. static set DragMovementThreshold(value: number);
  46707. /**
  46708. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46709. */
  46710. static get LongPressDelay(): number;
  46711. static set LongPressDelay(value: number);
  46712. /**
  46713. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46714. */
  46715. static get DoubleClickDelay(): number;
  46716. static set DoubleClickDelay(value: number);
  46717. /** If you need to check double click without raising a single click at first click, enable this flag */
  46718. static get ExclusiveDoubleClickMode(): boolean;
  46719. static set ExclusiveDoubleClickMode(value: boolean);
  46720. /** @hidden */
  46721. _mirroredCameraPosition: Nullable<Vector3>;
  46722. /**
  46723. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46724. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46725. */
  46726. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46727. /**
  46728. * Observable event triggered each time an keyboard event is received from the hosting window
  46729. */
  46730. onKeyboardObservable: Observable<KeyboardInfo>;
  46731. private _useRightHandedSystem;
  46732. /**
  46733. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46734. */
  46735. set useRightHandedSystem(value: boolean);
  46736. get useRightHandedSystem(): boolean;
  46737. private _timeAccumulator;
  46738. private _currentStepId;
  46739. private _currentInternalStep;
  46740. /**
  46741. * Sets the step Id used by deterministic lock step
  46742. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46743. * @param newStepId defines the step Id
  46744. */
  46745. setStepId(newStepId: number): void;
  46746. /**
  46747. * Gets the step Id used by deterministic lock step
  46748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46749. * @returns the step Id
  46750. */
  46751. getStepId(): number;
  46752. /**
  46753. * Gets the internal step used by deterministic lock step
  46754. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46755. * @returns the internal step
  46756. */
  46757. getInternalStep(): number;
  46758. private _fogEnabled;
  46759. /**
  46760. * Gets or sets a boolean indicating if fog is enabled on this scene
  46761. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46762. * (Default is true)
  46763. */
  46764. set fogEnabled(value: boolean);
  46765. get fogEnabled(): boolean;
  46766. private _fogMode;
  46767. /**
  46768. * Gets or sets the fog mode to use
  46769. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46770. * | mode | value |
  46771. * | --- | --- |
  46772. * | FOGMODE_NONE | 0 |
  46773. * | FOGMODE_EXP | 1 |
  46774. * | FOGMODE_EXP2 | 2 |
  46775. * | FOGMODE_LINEAR | 3 |
  46776. */
  46777. set fogMode(value: number);
  46778. get fogMode(): number;
  46779. /**
  46780. * Gets or sets the fog color to use
  46781. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46782. * (Default is Color3(0.2, 0.2, 0.3))
  46783. */
  46784. fogColor: Color3;
  46785. /**
  46786. * Gets or sets the fog density to use
  46787. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46788. * (Default is 0.1)
  46789. */
  46790. fogDensity: number;
  46791. /**
  46792. * Gets or sets the fog start distance to use
  46793. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46794. * (Default is 0)
  46795. */
  46796. fogStart: number;
  46797. /**
  46798. * Gets or sets the fog end distance to use
  46799. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46800. * (Default is 1000)
  46801. */
  46802. fogEnd: number;
  46803. /**
  46804. * Flag indicating that the frame buffer binding is handled by another component
  46805. */
  46806. get prePass(): boolean;
  46807. private _shadowsEnabled;
  46808. /**
  46809. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46810. */
  46811. set shadowsEnabled(value: boolean);
  46812. get shadowsEnabled(): boolean;
  46813. private _lightsEnabled;
  46814. /**
  46815. * Gets or sets a boolean indicating if lights are enabled on this scene
  46816. */
  46817. set lightsEnabled(value: boolean);
  46818. get lightsEnabled(): boolean;
  46819. /** All of the active cameras added to this scene. */
  46820. activeCameras: Nullable<Camera[]>;
  46821. /** @hidden */
  46822. _activeCamera: Nullable<Camera>;
  46823. /** Gets or sets the current active camera */
  46824. get activeCamera(): Nullable<Camera>;
  46825. set activeCamera(value: Nullable<Camera>);
  46826. private _defaultMaterial;
  46827. /** The default material used on meshes when no material is affected */
  46828. get defaultMaterial(): Material;
  46829. /** The default material used on meshes when no material is affected */
  46830. set defaultMaterial(value: Material);
  46831. private _texturesEnabled;
  46832. /**
  46833. * Gets or sets a boolean indicating if textures are enabled on this scene
  46834. */
  46835. set texturesEnabled(value: boolean);
  46836. get texturesEnabled(): boolean;
  46837. /**
  46838. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46839. */
  46840. physicsEnabled: boolean;
  46841. /**
  46842. * Gets or sets a boolean indicating if particles are enabled on this scene
  46843. */
  46844. particlesEnabled: boolean;
  46845. /**
  46846. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46847. */
  46848. spritesEnabled: boolean;
  46849. private _skeletonsEnabled;
  46850. /**
  46851. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46852. */
  46853. set skeletonsEnabled(value: boolean);
  46854. get skeletonsEnabled(): boolean;
  46855. /**
  46856. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46857. */
  46858. lensFlaresEnabled: boolean;
  46859. /**
  46860. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46861. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46862. */
  46863. collisionsEnabled: boolean;
  46864. private _collisionCoordinator;
  46865. /** @hidden */
  46866. get collisionCoordinator(): ICollisionCoordinator;
  46867. /**
  46868. * Defines the gravity applied to this scene (used only for collisions)
  46869. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46870. */
  46871. gravity: Vector3;
  46872. /**
  46873. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46874. */
  46875. postProcessesEnabled: boolean;
  46876. /**
  46877. * Gets the current postprocess manager
  46878. */
  46879. postProcessManager: PostProcessManager;
  46880. /**
  46881. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46882. */
  46883. renderTargetsEnabled: boolean;
  46884. /**
  46885. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46886. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46887. */
  46888. dumpNextRenderTargets: boolean;
  46889. /**
  46890. * The list of user defined render targets added to the scene
  46891. */
  46892. customRenderTargets: RenderTargetTexture[];
  46893. /**
  46894. * Defines if texture loading must be delayed
  46895. * If true, textures will only be loaded when they need to be rendered
  46896. */
  46897. useDelayedTextureLoading: boolean;
  46898. /**
  46899. * Gets the list of meshes imported to the scene through SceneLoader
  46900. */
  46901. importedMeshesFiles: String[];
  46902. /**
  46903. * Gets or sets a boolean indicating if probes are enabled on this scene
  46904. */
  46905. probesEnabled: boolean;
  46906. /**
  46907. * Gets or sets the current offline provider to use to store scene data
  46908. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46909. */
  46910. offlineProvider: IOfflineProvider;
  46911. /**
  46912. * Gets or sets the action manager associated with the scene
  46913. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46914. */
  46915. actionManager: AbstractActionManager;
  46916. private _meshesForIntersections;
  46917. /**
  46918. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46919. */
  46920. proceduralTexturesEnabled: boolean;
  46921. private _engine;
  46922. private _totalVertices;
  46923. /** @hidden */
  46924. _activeIndices: PerfCounter;
  46925. /** @hidden */
  46926. _activeParticles: PerfCounter;
  46927. /** @hidden */
  46928. _activeBones: PerfCounter;
  46929. private _animationRatio;
  46930. /** @hidden */
  46931. _animationTimeLast: number;
  46932. /** @hidden */
  46933. _animationTime: number;
  46934. /**
  46935. * Gets or sets a general scale for animation speed
  46936. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46937. */
  46938. animationTimeScale: number;
  46939. /** @hidden */
  46940. _cachedMaterial: Nullable<Material>;
  46941. /** @hidden */
  46942. _cachedEffect: Nullable<Effect>;
  46943. /** @hidden */
  46944. _cachedVisibility: Nullable<number>;
  46945. private _renderId;
  46946. private _frameId;
  46947. private _executeWhenReadyTimeoutId;
  46948. private _intermediateRendering;
  46949. private _viewUpdateFlag;
  46950. private _projectionUpdateFlag;
  46951. /** @hidden */
  46952. _toBeDisposed: Nullable<IDisposable>[];
  46953. private _activeRequests;
  46954. /** @hidden */
  46955. _pendingData: any[];
  46956. private _isDisposed;
  46957. /**
  46958. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46959. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46960. */
  46961. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46962. private _activeMeshes;
  46963. private _processedMaterials;
  46964. private _renderTargets;
  46965. /** @hidden */
  46966. _activeParticleSystems: SmartArray<IParticleSystem>;
  46967. private _activeSkeletons;
  46968. private _softwareSkinnedMeshes;
  46969. private _renderingManager;
  46970. /** @hidden */
  46971. _activeAnimatables: Animatable[];
  46972. private _transformMatrix;
  46973. private _sceneUbo;
  46974. /** @hidden */
  46975. _viewMatrix: Matrix;
  46976. /** @hidden */
  46977. _projectionMatrix: Matrix;
  46978. /** @hidden */
  46979. _forcedViewPosition: Nullable<Vector3>;
  46980. /** @hidden */
  46981. _frustumPlanes: Plane[];
  46982. /**
  46983. * Gets the list of frustum planes (built from the active camera)
  46984. */
  46985. get frustumPlanes(): Plane[];
  46986. /**
  46987. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46988. * This is useful if there are more lights that the maximum simulteanous authorized
  46989. */
  46990. requireLightSorting: boolean;
  46991. /** @hidden */
  46992. readonly useMaterialMeshMap: boolean;
  46993. /** @hidden */
  46994. readonly useClonedMeshMap: boolean;
  46995. private _externalData;
  46996. private _uid;
  46997. /**
  46998. * @hidden
  46999. * Backing store of defined scene components.
  47000. */
  47001. _components: ISceneComponent[];
  47002. /**
  47003. * @hidden
  47004. * Backing store of defined scene components.
  47005. */
  47006. _serializableComponents: ISceneSerializableComponent[];
  47007. /**
  47008. * List of components to register on the next registration step.
  47009. */
  47010. private _transientComponents;
  47011. /**
  47012. * Registers the transient components if needed.
  47013. */
  47014. private _registerTransientComponents;
  47015. /**
  47016. * @hidden
  47017. * Add a component to the scene.
  47018. * Note that the ccomponent could be registered on th next frame if this is called after
  47019. * the register component stage.
  47020. * @param component Defines the component to add to the scene
  47021. */
  47022. _addComponent(component: ISceneComponent): void;
  47023. /**
  47024. * @hidden
  47025. * Gets a component from the scene.
  47026. * @param name defines the name of the component to retrieve
  47027. * @returns the component or null if not present
  47028. */
  47029. _getComponent(name: string): Nullable<ISceneComponent>;
  47030. /**
  47031. * @hidden
  47032. * Defines the actions happening before camera updates.
  47033. */
  47034. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47035. /**
  47036. * @hidden
  47037. * Defines the actions happening before clear the canvas.
  47038. */
  47039. _beforeClearStage: Stage<SimpleStageAction>;
  47040. /**
  47041. * @hidden
  47042. * Defines the actions happening before clear the canvas.
  47043. */
  47044. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47045. /**
  47046. * @hidden
  47047. * Defines the actions when collecting render targets for the frame.
  47048. */
  47049. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47050. /**
  47051. * @hidden
  47052. * Defines the actions happening for one camera in the frame.
  47053. */
  47054. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47055. /**
  47056. * @hidden
  47057. * Defines the actions happening during the per mesh ready checks.
  47058. */
  47059. _isReadyForMeshStage: Stage<MeshStageAction>;
  47060. /**
  47061. * @hidden
  47062. * Defines the actions happening before evaluate active mesh checks.
  47063. */
  47064. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47065. /**
  47066. * @hidden
  47067. * Defines the actions happening during the evaluate sub mesh checks.
  47068. */
  47069. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47070. /**
  47071. * @hidden
  47072. * Defines the actions happening during the active mesh stage.
  47073. */
  47074. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47075. /**
  47076. * @hidden
  47077. * Defines the actions happening during the per camera render target step.
  47078. */
  47079. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47080. /**
  47081. * @hidden
  47082. * Defines the actions happening just before the active camera is drawing.
  47083. */
  47084. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47085. /**
  47086. * @hidden
  47087. * Defines the actions happening just before a render target is drawing.
  47088. */
  47089. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47090. /**
  47091. * @hidden
  47092. * Defines the actions happening just before a rendering group is drawing.
  47093. */
  47094. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47095. /**
  47096. * @hidden
  47097. * Defines the actions happening just before a mesh is drawing.
  47098. */
  47099. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47100. /**
  47101. * @hidden
  47102. * Defines the actions happening just after a mesh has been drawn.
  47103. */
  47104. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47105. /**
  47106. * @hidden
  47107. * Defines the actions happening just after a rendering group has been drawn.
  47108. */
  47109. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47110. /**
  47111. * @hidden
  47112. * Defines the actions happening just after the active camera has been drawn.
  47113. */
  47114. _afterCameraDrawStage: Stage<CameraStageAction>;
  47115. /**
  47116. * @hidden
  47117. * Defines the actions happening just after a render target has been drawn.
  47118. */
  47119. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47120. /**
  47121. * @hidden
  47122. * Defines the actions happening just after rendering all cameras and computing intersections.
  47123. */
  47124. _afterRenderStage: Stage<SimpleStageAction>;
  47125. /**
  47126. * @hidden
  47127. * Defines the actions happening when a pointer move event happens.
  47128. */
  47129. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47130. /**
  47131. * @hidden
  47132. * Defines the actions happening when a pointer down event happens.
  47133. */
  47134. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47135. /**
  47136. * @hidden
  47137. * Defines the actions happening when a pointer up event happens.
  47138. */
  47139. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47140. /**
  47141. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47142. */
  47143. private geometriesByUniqueId;
  47144. private _renderBundles;
  47145. /**
  47146. * Creates a new Scene
  47147. * @param engine defines the engine to use to render this scene
  47148. * @param options defines the scene options
  47149. */
  47150. constructor(engine: Engine, options?: SceneOptions);
  47151. /**
  47152. * Gets a string identifying the name of the class
  47153. * @returns "Scene" string
  47154. */
  47155. getClassName(): string;
  47156. private _defaultMeshCandidates;
  47157. /**
  47158. * @hidden
  47159. */
  47160. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47161. private _defaultSubMeshCandidates;
  47162. /**
  47163. * @hidden
  47164. */
  47165. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47166. /**
  47167. * Sets the default candidate providers for the scene.
  47168. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47169. * and getCollidingSubMeshCandidates to their default function
  47170. */
  47171. setDefaultCandidateProviders(): void;
  47172. /**
  47173. * Gets the mesh that is currently under the pointer
  47174. */
  47175. get meshUnderPointer(): Nullable<AbstractMesh>;
  47176. /**
  47177. * Gets or sets the current on-screen X position of the pointer
  47178. */
  47179. get pointerX(): number;
  47180. set pointerX(value: number);
  47181. /**
  47182. * Gets or sets the current on-screen Y position of the pointer
  47183. */
  47184. get pointerY(): number;
  47185. set pointerY(value: number);
  47186. /**
  47187. * Gets the cached material (ie. the latest rendered one)
  47188. * @returns the cached material
  47189. */
  47190. getCachedMaterial(): Nullable<Material>;
  47191. /**
  47192. * Gets the cached effect (ie. the latest rendered one)
  47193. * @returns the cached effect
  47194. */
  47195. getCachedEffect(): Nullable<Effect>;
  47196. /**
  47197. * Gets the cached visibility state (ie. the latest rendered one)
  47198. * @returns the cached visibility state
  47199. */
  47200. getCachedVisibility(): Nullable<number>;
  47201. /**
  47202. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47203. * @param material defines the current material
  47204. * @param effect defines the current effect
  47205. * @param visibility defines the current visibility state
  47206. * @returns true if one parameter is not cached
  47207. */
  47208. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47209. /**
  47210. * Gets the engine associated with the scene
  47211. * @returns an Engine
  47212. */
  47213. getEngine(): Engine;
  47214. /**
  47215. * Gets the total number of vertices rendered per frame
  47216. * @returns the total number of vertices rendered per frame
  47217. */
  47218. getTotalVertices(): number;
  47219. /**
  47220. * Gets the performance counter for total vertices
  47221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47222. */
  47223. get totalVerticesPerfCounter(): PerfCounter;
  47224. /**
  47225. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47226. * @returns the total number of active indices rendered per frame
  47227. */
  47228. getActiveIndices(): number;
  47229. /**
  47230. * Gets the performance counter for active indices
  47231. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47232. */
  47233. get totalActiveIndicesPerfCounter(): PerfCounter;
  47234. /**
  47235. * Gets the total number of active particles rendered per frame
  47236. * @returns the total number of active particles rendered per frame
  47237. */
  47238. getActiveParticles(): number;
  47239. /**
  47240. * Gets the performance counter for active particles
  47241. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47242. */
  47243. get activeParticlesPerfCounter(): PerfCounter;
  47244. /**
  47245. * Gets the total number of active bones rendered per frame
  47246. * @returns the total number of active bones rendered per frame
  47247. */
  47248. getActiveBones(): number;
  47249. /**
  47250. * Gets the performance counter for active bones
  47251. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47252. */
  47253. get activeBonesPerfCounter(): PerfCounter;
  47254. /**
  47255. * Gets the array of active meshes
  47256. * @returns an array of AbstractMesh
  47257. */
  47258. getActiveMeshes(): SmartArray<AbstractMesh>;
  47259. /**
  47260. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47261. * @returns a number
  47262. */
  47263. getAnimationRatio(): number;
  47264. /**
  47265. * Gets an unique Id for the current render phase
  47266. * @returns a number
  47267. */
  47268. getRenderId(): number;
  47269. /**
  47270. * Gets an unique Id for the current frame
  47271. * @returns a number
  47272. */
  47273. getFrameId(): number;
  47274. /** Call this function if you want to manually increment the render Id*/
  47275. incrementRenderId(): void;
  47276. private _createUbo;
  47277. /**
  47278. * Use this method to simulate a pointer move on a mesh
  47279. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47280. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47281. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47282. * @returns the current scene
  47283. */
  47284. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47285. /**
  47286. * Use this method to simulate a pointer down on a mesh
  47287. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47288. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47289. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47290. * @returns the current scene
  47291. */
  47292. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47293. /**
  47294. * Use this method to simulate a pointer up on a mesh
  47295. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47296. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47297. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47298. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47299. * @returns the current scene
  47300. */
  47301. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47302. /**
  47303. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47304. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47305. * @returns true if the pointer was captured
  47306. */
  47307. isPointerCaptured(pointerId?: number): boolean;
  47308. /**
  47309. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47310. * @param attachUp defines if you want to attach events to pointerup
  47311. * @param attachDown defines if you want to attach events to pointerdown
  47312. * @param attachMove defines if you want to attach events to pointermove
  47313. */
  47314. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47315. /** Detaches all event handlers*/
  47316. detachControl(): void;
  47317. /**
  47318. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47319. * Delay loaded resources are not taking in account
  47320. * @return true if all required resources are ready
  47321. */
  47322. isReady(): boolean;
  47323. /** Resets all cached information relative to material (including effect and visibility) */
  47324. resetCachedMaterial(): void;
  47325. /**
  47326. * Registers a function to be called before every frame render
  47327. * @param func defines the function to register
  47328. */
  47329. registerBeforeRender(func: () => void): void;
  47330. /**
  47331. * Unregisters a function called before every frame render
  47332. * @param func defines the function to unregister
  47333. */
  47334. unregisterBeforeRender(func: () => void): void;
  47335. /**
  47336. * Registers a function to be called after every frame render
  47337. * @param func defines the function to register
  47338. */
  47339. registerAfterRender(func: () => void): void;
  47340. /**
  47341. * Unregisters a function called after every frame render
  47342. * @param func defines the function to unregister
  47343. */
  47344. unregisterAfterRender(func: () => void): void;
  47345. private _executeOnceBeforeRender;
  47346. /**
  47347. * The provided function will run before render once and will be disposed afterwards.
  47348. * A timeout delay can be provided so that the function will be executed in N ms.
  47349. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47350. * @param func The function to be executed.
  47351. * @param timeout optional delay in ms
  47352. */
  47353. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47354. /** @hidden */
  47355. _addPendingData(data: any): void;
  47356. /** @hidden */
  47357. _removePendingData(data: any): void;
  47358. /**
  47359. * Returns the number of items waiting to be loaded
  47360. * @returns the number of items waiting to be loaded
  47361. */
  47362. getWaitingItemsCount(): number;
  47363. /**
  47364. * Returns a boolean indicating if the scene is still loading data
  47365. */
  47366. get isLoading(): boolean;
  47367. /**
  47368. * Registers a function to be executed when the scene is ready
  47369. * @param {Function} func - the function to be executed
  47370. */
  47371. executeWhenReady(func: () => void): void;
  47372. /**
  47373. * Returns a promise that resolves when the scene is ready
  47374. * @returns A promise that resolves when the scene is ready
  47375. */
  47376. whenReadyAsync(): Promise<void>;
  47377. /** @hidden */
  47378. _checkIsReady(): void;
  47379. /**
  47380. * Gets all animatable attached to the scene
  47381. */
  47382. get animatables(): Animatable[];
  47383. /**
  47384. * Resets the last animation time frame.
  47385. * Useful to override when animations start running when loading a scene for the first time.
  47386. */
  47387. resetLastAnimationTimeFrame(): void;
  47388. /**
  47389. * Gets the current view matrix
  47390. * @returns a Matrix
  47391. */
  47392. getViewMatrix(): Matrix;
  47393. /**
  47394. * Gets the current projection matrix
  47395. * @returns a Matrix
  47396. */
  47397. getProjectionMatrix(): Matrix;
  47398. /**
  47399. * Gets the current transform matrix
  47400. * @returns a Matrix made of View * Projection
  47401. */
  47402. getTransformMatrix(): Matrix;
  47403. /**
  47404. * Sets the current transform matrix
  47405. * @param viewL defines the View matrix to use
  47406. * @param projectionL defines the Projection matrix to use
  47407. * @param viewR defines the right View matrix to use (if provided)
  47408. * @param projectionR defines the right Projection matrix to use (if provided)
  47409. */
  47410. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47411. /**
  47412. * Gets the uniform buffer used to store scene data
  47413. * @returns a UniformBuffer
  47414. */
  47415. getSceneUniformBuffer(): UniformBuffer;
  47416. /**
  47417. * Gets an unique (relatively to the current scene) Id
  47418. * @returns an unique number for the scene
  47419. */
  47420. getUniqueId(): number;
  47421. /**
  47422. * Add a mesh to the list of scene's meshes
  47423. * @param newMesh defines the mesh to add
  47424. * @param recursive if all child meshes should also be added to the scene
  47425. */
  47426. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47427. /**
  47428. * Remove a mesh for the list of scene's meshes
  47429. * @param toRemove defines the mesh to remove
  47430. * @param recursive if all child meshes should also be removed from the scene
  47431. * @returns the index where the mesh was in the mesh list
  47432. */
  47433. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47434. /**
  47435. * Add a transform node to the list of scene's transform nodes
  47436. * @param newTransformNode defines the transform node to add
  47437. */
  47438. addTransformNode(newTransformNode: TransformNode): void;
  47439. /**
  47440. * Remove a transform node for the list of scene's transform nodes
  47441. * @param toRemove defines the transform node to remove
  47442. * @returns the index where the transform node was in the transform node list
  47443. */
  47444. removeTransformNode(toRemove: TransformNode): number;
  47445. /**
  47446. * Remove a skeleton for the list of scene's skeletons
  47447. * @param toRemove defines the skeleton to remove
  47448. * @returns the index where the skeleton was in the skeleton list
  47449. */
  47450. removeSkeleton(toRemove: Skeleton): number;
  47451. /**
  47452. * Remove a morph target for the list of scene's morph targets
  47453. * @param toRemove defines the morph target to remove
  47454. * @returns the index where the morph target was in the morph target list
  47455. */
  47456. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47457. /**
  47458. * Remove a light for the list of scene's lights
  47459. * @param toRemove defines the light to remove
  47460. * @returns the index where the light was in the light list
  47461. */
  47462. removeLight(toRemove: Light): number;
  47463. /**
  47464. * Remove a camera for the list of scene's cameras
  47465. * @param toRemove defines the camera to remove
  47466. * @returns the index where the camera was in the camera list
  47467. */
  47468. removeCamera(toRemove: Camera): number;
  47469. /**
  47470. * Remove a particle system for the list of scene's particle systems
  47471. * @param toRemove defines the particle system to remove
  47472. * @returns the index where the particle system was in the particle system list
  47473. */
  47474. removeParticleSystem(toRemove: IParticleSystem): number;
  47475. /**
  47476. * Remove a animation for the list of scene's animations
  47477. * @param toRemove defines the animation to remove
  47478. * @returns the index where the animation was in the animation list
  47479. */
  47480. removeAnimation(toRemove: Animation): number;
  47481. /**
  47482. * Will stop the animation of the given target
  47483. * @param target - the target
  47484. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47485. * @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)
  47486. */
  47487. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47488. /**
  47489. * Removes the given animation group from this scene.
  47490. * @param toRemove The animation group to remove
  47491. * @returns The index of the removed animation group
  47492. */
  47493. removeAnimationGroup(toRemove: AnimationGroup): number;
  47494. /**
  47495. * Removes the given multi-material from this scene.
  47496. * @param toRemove The multi-material to remove
  47497. * @returns The index of the removed multi-material
  47498. */
  47499. removeMultiMaterial(toRemove: MultiMaterial): number;
  47500. /**
  47501. * Removes the given material from this scene.
  47502. * @param toRemove The material to remove
  47503. * @returns The index of the removed material
  47504. */
  47505. removeMaterial(toRemove: Material): number;
  47506. /**
  47507. * Removes the given action manager from this scene.
  47508. * @param toRemove The action manager to remove
  47509. * @returns The index of the removed action manager
  47510. */
  47511. removeActionManager(toRemove: AbstractActionManager): number;
  47512. /**
  47513. * Removes the given texture from this scene.
  47514. * @param toRemove The texture to remove
  47515. * @returns The index of the removed texture
  47516. */
  47517. removeTexture(toRemove: BaseTexture): number;
  47518. /**
  47519. * Adds the given light to this scene
  47520. * @param newLight The light to add
  47521. */
  47522. addLight(newLight: Light): void;
  47523. /**
  47524. * Sorts the list list based on light priorities
  47525. */
  47526. sortLightsByPriority(): void;
  47527. /**
  47528. * Adds the given camera to this scene
  47529. * @param newCamera The camera to add
  47530. */
  47531. addCamera(newCamera: Camera): void;
  47532. /**
  47533. * Adds the given skeleton to this scene
  47534. * @param newSkeleton The skeleton to add
  47535. */
  47536. addSkeleton(newSkeleton: Skeleton): void;
  47537. /**
  47538. * Adds the given particle system to this scene
  47539. * @param newParticleSystem The particle system to add
  47540. */
  47541. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47542. /**
  47543. * Adds the given animation to this scene
  47544. * @param newAnimation The animation to add
  47545. */
  47546. addAnimation(newAnimation: Animation): void;
  47547. /**
  47548. * Adds the given animation group to this scene.
  47549. * @param newAnimationGroup The animation group to add
  47550. */
  47551. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47552. /**
  47553. * Adds the given multi-material to this scene
  47554. * @param newMultiMaterial The multi-material to add
  47555. */
  47556. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47557. /**
  47558. * Adds the given material to this scene
  47559. * @param newMaterial The material to add
  47560. */
  47561. addMaterial(newMaterial: Material): void;
  47562. /**
  47563. * Adds the given morph target to this scene
  47564. * @param newMorphTargetManager The morph target to add
  47565. */
  47566. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47567. /**
  47568. * Adds the given geometry to this scene
  47569. * @param newGeometry The geometry to add
  47570. */
  47571. addGeometry(newGeometry: Geometry): void;
  47572. /**
  47573. * Adds the given action manager to this scene
  47574. * @param newActionManager The action manager to add
  47575. */
  47576. addActionManager(newActionManager: AbstractActionManager): void;
  47577. /**
  47578. * Adds the given texture to this scene.
  47579. * @param newTexture The texture to add
  47580. */
  47581. addTexture(newTexture: BaseTexture): void;
  47582. /**
  47583. * Switch active camera
  47584. * @param newCamera defines the new active camera
  47585. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47586. */
  47587. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47588. /**
  47589. * sets the active camera of the scene using its ID
  47590. * @param id defines the camera's ID
  47591. * @return the new active camera or null if none found.
  47592. */
  47593. setActiveCameraByID(id: string): Nullable<Camera>;
  47594. /**
  47595. * sets the active camera of the scene using its name
  47596. * @param name defines the camera's name
  47597. * @returns the new active camera or null if none found.
  47598. */
  47599. setActiveCameraByName(name: string): Nullable<Camera>;
  47600. /**
  47601. * get an animation group using its name
  47602. * @param name defines the material's name
  47603. * @return the animation group or null if none found.
  47604. */
  47605. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47606. /**
  47607. * Get a material using its unique id
  47608. * @param uniqueId defines the material's unique id
  47609. * @return the material or null if none found.
  47610. */
  47611. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47612. /**
  47613. * get a material using its id
  47614. * @param id defines the material's ID
  47615. * @return the material or null if none found.
  47616. */
  47617. getMaterialByID(id: string): Nullable<Material>;
  47618. /**
  47619. * Gets a the last added material using a given id
  47620. * @param id defines the material's ID
  47621. * @return the last material with the given id or null if none found.
  47622. */
  47623. getLastMaterialByID(id: string): Nullable<Material>;
  47624. /**
  47625. * Gets a material using its name
  47626. * @param name defines the material's name
  47627. * @return the material or null if none found.
  47628. */
  47629. getMaterialByName(name: string): Nullable<Material>;
  47630. /**
  47631. * Get a texture using its unique id
  47632. * @param uniqueId defines the texture's unique id
  47633. * @return the texture or null if none found.
  47634. */
  47635. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47636. /**
  47637. * Gets a camera using its id
  47638. * @param id defines the id to look for
  47639. * @returns the camera or null if not found
  47640. */
  47641. getCameraByID(id: string): Nullable<Camera>;
  47642. /**
  47643. * Gets a camera using its unique id
  47644. * @param uniqueId defines the unique id to look for
  47645. * @returns the camera or null if not found
  47646. */
  47647. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47648. /**
  47649. * Gets a camera using its name
  47650. * @param name defines the camera's name
  47651. * @return the camera or null if none found.
  47652. */
  47653. getCameraByName(name: string): Nullable<Camera>;
  47654. /**
  47655. * Gets a bone using its id
  47656. * @param id defines the bone's id
  47657. * @return the bone or null if not found
  47658. */
  47659. getBoneByID(id: string): Nullable<Bone>;
  47660. /**
  47661. * Gets a bone using its id
  47662. * @param name defines the bone's name
  47663. * @return the bone or null if not found
  47664. */
  47665. getBoneByName(name: string): Nullable<Bone>;
  47666. /**
  47667. * Gets a light node using its name
  47668. * @param name defines the the light's name
  47669. * @return the light or null if none found.
  47670. */
  47671. getLightByName(name: string): Nullable<Light>;
  47672. /**
  47673. * Gets a light node using its id
  47674. * @param id defines the light's id
  47675. * @return the light or null if none found.
  47676. */
  47677. getLightByID(id: string): Nullable<Light>;
  47678. /**
  47679. * Gets a light node using its scene-generated unique ID
  47680. * @param uniqueId defines the light's unique id
  47681. * @return the light or null if none found.
  47682. */
  47683. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47684. /**
  47685. * Gets a particle system by id
  47686. * @param id defines the particle system id
  47687. * @return the corresponding system or null if none found
  47688. */
  47689. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47690. /**
  47691. * Gets a geometry using its ID
  47692. * @param id defines the geometry's id
  47693. * @return the geometry or null if none found.
  47694. */
  47695. getGeometryByID(id: string): Nullable<Geometry>;
  47696. private _getGeometryByUniqueID;
  47697. /**
  47698. * Add a new geometry to this scene
  47699. * @param geometry defines the geometry to be added to the scene.
  47700. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47701. * @return a boolean defining if the geometry was added or not
  47702. */
  47703. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47704. /**
  47705. * Removes an existing geometry
  47706. * @param geometry defines the geometry to be removed from the scene
  47707. * @return a boolean defining if the geometry was removed or not
  47708. */
  47709. removeGeometry(geometry: Geometry): boolean;
  47710. /**
  47711. * Gets the list of geometries attached to the scene
  47712. * @returns an array of Geometry
  47713. */
  47714. getGeometries(): Geometry[];
  47715. /**
  47716. * Gets the first added mesh found of a given ID
  47717. * @param id defines the id to search for
  47718. * @return the mesh found or null if not found at all
  47719. */
  47720. getMeshByID(id: string): Nullable<AbstractMesh>;
  47721. /**
  47722. * Gets a list of meshes using their id
  47723. * @param id defines the id to search for
  47724. * @returns a list of meshes
  47725. */
  47726. getMeshesByID(id: string): Array<AbstractMesh>;
  47727. /**
  47728. * Gets the first added transform node found of a given ID
  47729. * @param id defines the id to search for
  47730. * @return the found transform node or null if not found at all.
  47731. */
  47732. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47733. /**
  47734. * Gets a transform node with its auto-generated unique id
  47735. * @param uniqueId efines the unique id to search for
  47736. * @return the found transform node or null if not found at all.
  47737. */
  47738. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47739. /**
  47740. * Gets a list of transform nodes using their id
  47741. * @param id defines the id to search for
  47742. * @returns a list of transform nodes
  47743. */
  47744. getTransformNodesByID(id: string): Array<TransformNode>;
  47745. /**
  47746. * Gets a mesh with its auto-generated unique id
  47747. * @param uniqueId defines the unique id to search for
  47748. * @return the found mesh or null if not found at all.
  47749. */
  47750. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47751. /**
  47752. * Gets a the last added mesh using a given id
  47753. * @param id defines the id to search for
  47754. * @return the found mesh or null if not found at all.
  47755. */
  47756. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47757. /**
  47758. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47759. * @param id defines the id to search for
  47760. * @return the found node or null if not found at all
  47761. */
  47762. getLastEntryByID(id: string): Nullable<Node>;
  47763. /**
  47764. * Gets a node (Mesh, Camera, Light) using a given id
  47765. * @param id defines the id to search for
  47766. * @return the found node or null if not found at all
  47767. */
  47768. getNodeByID(id: string): Nullable<Node>;
  47769. /**
  47770. * Gets a node (Mesh, Camera, Light) using a given name
  47771. * @param name defines the name to search for
  47772. * @return the found node or null if not found at all.
  47773. */
  47774. getNodeByName(name: string): Nullable<Node>;
  47775. /**
  47776. * Gets a mesh using a given name
  47777. * @param name defines the name to search for
  47778. * @return the found mesh or null if not found at all.
  47779. */
  47780. getMeshByName(name: string): Nullable<AbstractMesh>;
  47781. /**
  47782. * Gets a transform node using a given name
  47783. * @param name defines the name to search for
  47784. * @return the found transform node or null if not found at all.
  47785. */
  47786. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47787. /**
  47788. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47789. * @param id defines the id to search for
  47790. * @return the found skeleton or null if not found at all.
  47791. */
  47792. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47793. /**
  47794. * Gets a skeleton using a given auto generated unique id
  47795. * @param uniqueId defines the unique id to search for
  47796. * @return the found skeleton or null if not found at all.
  47797. */
  47798. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47799. /**
  47800. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47801. * @param id defines the id to search for
  47802. * @return the found skeleton or null if not found at all.
  47803. */
  47804. getSkeletonById(id: string): Nullable<Skeleton>;
  47805. /**
  47806. * Gets a skeleton using a given name
  47807. * @param name defines the name to search for
  47808. * @return the found skeleton or null if not found at all.
  47809. */
  47810. getSkeletonByName(name: string): Nullable<Skeleton>;
  47811. /**
  47812. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47813. * @param id defines the id to search for
  47814. * @return the found morph target manager or null if not found at all.
  47815. */
  47816. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47817. /**
  47818. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47819. * @param id defines the id to search for
  47820. * @return the found morph target or null if not found at all.
  47821. */
  47822. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47823. /**
  47824. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47825. * @param name defines the name to search for
  47826. * @return the found morph target or null if not found at all.
  47827. */
  47828. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47829. /**
  47830. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47831. * @param name defines the name to search for
  47832. * @return the found post process or null if not found at all.
  47833. */
  47834. getPostProcessByName(name: string): Nullable<PostProcess>;
  47835. /**
  47836. * Gets a boolean indicating if the given mesh is active
  47837. * @param mesh defines the mesh to look for
  47838. * @returns true if the mesh is in the active list
  47839. */
  47840. isActiveMesh(mesh: AbstractMesh): boolean;
  47841. /**
  47842. * Return a unique id as a string which can serve as an identifier for the scene
  47843. */
  47844. get uid(): string;
  47845. /**
  47846. * Add an externaly attached data from its key.
  47847. * This method call will fail and return false, if such key already exists.
  47848. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47849. * @param key the unique key that identifies the data
  47850. * @param data the data object to associate to the key for this Engine instance
  47851. * @return true if no such key were already present and the data was added successfully, false otherwise
  47852. */
  47853. addExternalData<T>(key: string, data: T): boolean;
  47854. /**
  47855. * Get an externaly attached data from its key
  47856. * @param key the unique key that identifies the data
  47857. * @return the associated data, if present (can be null), or undefined if not present
  47858. */
  47859. getExternalData<T>(key: string): Nullable<T>;
  47860. /**
  47861. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47862. * @param key the unique key that identifies the data
  47863. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47864. * @return the associated data, can be null if the factory returned null.
  47865. */
  47866. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47867. /**
  47868. * Remove an externaly attached data from the Engine instance
  47869. * @param key the unique key that identifies the data
  47870. * @return true if the data was successfully removed, false if it doesn't exist
  47871. */
  47872. removeExternalData(key: string): boolean;
  47873. private _evaluateSubMesh;
  47874. /**
  47875. * Clear the processed materials smart array preventing retention point in material dispose.
  47876. */
  47877. freeProcessedMaterials(): void;
  47878. private _preventFreeActiveMeshesAndRenderingGroups;
  47879. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47880. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47881. * when disposing several meshes in a row or a hierarchy of meshes.
  47882. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47883. */
  47884. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47885. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47886. /**
  47887. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47888. */
  47889. freeActiveMeshes(): void;
  47890. /**
  47891. * Clear the info related to rendering groups preventing retention points during dispose.
  47892. */
  47893. freeRenderingGroups(): void;
  47894. /** @hidden */
  47895. _isInIntermediateRendering(): boolean;
  47896. /**
  47897. * Lambda returning the list of potentially active meshes.
  47898. */
  47899. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47900. /**
  47901. * Lambda returning the list of potentially active sub meshes.
  47902. */
  47903. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47904. /**
  47905. * Lambda returning the list of potentially intersecting sub meshes.
  47906. */
  47907. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47908. /**
  47909. * Lambda returning the list of potentially colliding sub meshes.
  47910. */
  47911. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47912. /** @hidden */
  47913. _activeMeshesFrozen: boolean;
  47914. private _skipEvaluateActiveMeshesCompletely;
  47915. /**
  47916. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47917. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47918. * @param onSuccess optional success callback
  47919. * @param onError optional error callback
  47920. * @returns the current scene
  47921. */
  47922. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47923. /**
  47924. * Use this function to restart evaluating active meshes on every frame
  47925. * @returns the current scene
  47926. */
  47927. unfreezeActiveMeshes(): Scene;
  47928. private _evaluateActiveMeshes;
  47929. private _activeMesh;
  47930. /**
  47931. * Update the transform matrix to update from the current active camera
  47932. * @param force defines a boolean used to force the update even if cache is up to date
  47933. */
  47934. updateTransformMatrix(force?: boolean): void;
  47935. private _bindFrameBuffer;
  47936. /** @hidden */
  47937. _allowPostProcessClearColor: boolean;
  47938. /** @hidden */
  47939. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47940. private _processSubCameras;
  47941. private _checkIntersections;
  47942. /** @hidden */
  47943. _advancePhysicsEngineStep(step: number): void;
  47944. /**
  47945. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47946. */
  47947. getDeterministicFrameTime: () => number;
  47948. /** @hidden */
  47949. _animate(): void;
  47950. /** Execute all animations (for a frame) */
  47951. animate(): void;
  47952. /**
  47953. * Render the scene
  47954. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47955. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47956. */
  47957. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47958. /**
  47959. * Freeze all materials
  47960. * A frozen material will not be updatable but should be faster to render
  47961. */
  47962. freezeMaterials(): void;
  47963. /**
  47964. * Unfreeze all materials
  47965. * A frozen material will not be updatable but should be faster to render
  47966. */
  47967. unfreezeMaterials(): void;
  47968. /**
  47969. * Releases all held ressources
  47970. */
  47971. dispose(): void;
  47972. /**
  47973. * Gets if the scene is already disposed
  47974. */
  47975. get isDisposed(): boolean;
  47976. /**
  47977. * Call this function to reduce memory footprint of the scene.
  47978. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47979. */
  47980. clearCachedVertexData(): void;
  47981. /**
  47982. * This function will remove the local cached buffer data from texture.
  47983. * It will save memory but will prevent the texture from being rebuilt
  47984. */
  47985. cleanCachedTextureBuffer(): void;
  47986. /**
  47987. * Get the world extend vectors with an optional filter
  47988. *
  47989. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47990. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47991. */
  47992. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47993. min: Vector3;
  47994. max: Vector3;
  47995. };
  47996. /**
  47997. * Creates a ray that can be used to pick in the scene
  47998. * @param x defines the x coordinate of the origin (on-screen)
  47999. * @param y defines the y coordinate of the origin (on-screen)
  48000. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48001. * @param camera defines the camera to use for the picking
  48002. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48003. * @returns a Ray
  48004. */
  48005. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  48006. /**
  48007. * Creates a ray that can be used to pick in the scene
  48008. * @param x defines the x coordinate of the origin (on-screen)
  48009. * @param y defines the y coordinate of the origin (on-screen)
  48010. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  48011. * @param result defines the ray where to store the picking ray
  48012. * @param camera defines the camera to use for the picking
  48013. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48014. * @returns the current scene
  48015. */
  48016. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  48017. /**
  48018. * Creates a ray that can be used to pick in the scene
  48019. * @param x defines the x coordinate of the origin (on-screen)
  48020. * @param y defines the y coordinate of the origin (on-screen)
  48021. * @param camera defines the camera to use for the picking
  48022. * @returns a Ray
  48023. */
  48024. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48025. /**
  48026. * Creates a ray that can be used to pick in the scene
  48027. * @param x defines the x coordinate of the origin (on-screen)
  48028. * @param y defines the y coordinate of the origin (on-screen)
  48029. * @param result defines the ray where to store the picking ray
  48030. * @param camera defines the camera to use for the picking
  48031. * @returns the current scene
  48032. */
  48033. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48034. /** Launch a ray to try to pick a mesh in the scene
  48035. * @param x position on screen
  48036. * @param y position on screen
  48037. * @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
  48038. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48039. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48040. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48041. * @returns a PickingInfo
  48042. */
  48043. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48044. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48045. * @param x position on screen
  48046. * @param y position on screen
  48047. * @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
  48048. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48049. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48050. * @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)
  48051. */
  48052. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48053. /** Use the given ray to pick a mesh in the scene
  48054. * @param ray The ray to use to pick meshes
  48055. * @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
  48056. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48057. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48058. * @returns a PickingInfo
  48059. */
  48060. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48061. /**
  48062. * Launch a ray to try to pick a mesh in the scene
  48063. * @param x X position on screen
  48064. * @param y Y position on screen
  48065. * @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
  48066. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48067. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48068. * @returns an array of PickingInfo
  48069. */
  48070. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48071. /**
  48072. * Launch a ray to try to pick a mesh in the scene
  48073. * @param ray Ray to use
  48074. * @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
  48075. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48076. * @returns an array of PickingInfo
  48077. */
  48078. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48079. /**
  48080. * Force the value of meshUnderPointer
  48081. * @param mesh defines the mesh to use
  48082. * @param pointerId optional pointer id when using more than one pointer
  48083. */
  48084. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48085. /**
  48086. * Gets the mesh under the pointer
  48087. * @returns a Mesh or null if no mesh is under the pointer
  48088. */
  48089. getPointerOverMesh(): Nullable<AbstractMesh>;
  48090. /** @hidden */
  48091. _rebuildGeometries(): void;
  48092. /** @hidden */
  48093. _rebuildTextures(): void;
  48094. private _getByTags;
  48095. /**
  48096. * Get a list of meshes by tags
  48097. * @param tagsQuery defines the tags query to use
  48098. * @param forEach defines a predicate used to filter results
  48099. * @returns an array of Mesh
  48100. */
  48101. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48102. /**
  48103. * Get a list of cameras by tags
  48104. * @param tagsQuery defines the tags query to use
  48105. * @param forEach defines a predicate used to filter results
  48106. * @returns an array of Camera
  48107. */
  48108. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48109. /**
  48110. * Get a list of lights by tags
  48111. * @param tagsQuery defines the tags query to use
  48112. * @param forEach defines a predicate used to filter results
  48113. * @returns an array of Light
  48114. */
  48115. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48116. /**
  48117. * Get a list of materials by tags
  48118. * @param tagsQuery defines the tags query to use
  48119. * @param forEach defines a predicate used to filter results
  48120. * @returns an array of Material
  48121. */
  48122. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48123. /**
  48124. * Get a list of transform nodes by tags
  48125. * @param tagsQuery defines the tags query to use
  48126. * @param forEach defines a predicate used to filter results
  48127. * @returns an array of TransformNode
  48128. */
  48129. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48130. /**
  48131. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48132. * This allowed control for front to back rendering or reversly depending of the special needs.
  48133. *
  48134. * @param renderingGroupId The rendering group id corresponding to its index
  48135. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48136. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48137. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48138. */
  48139. 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;
  48140. /**
  48141. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48142. *
  48143. * @param renderingGroupId The rendering group id corresponding to its index
  48144. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48145. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48146. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48147. */
  48148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48149. /**
  48150. * Gets the current auto clear configuration for one rendering group of the rendering
  48151. * manager.
  48152. * @param index the rendering group index to get the information for
  48153. * @returns The auto clear setup for the requested rendering group
  48154. */
  48155. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48156. private _blockMaterialDirtyMechanism;
  48157. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48158. get blockMaterialDirtyMechanism(): boolean;
  48159. set blockMaterialDirtyMechanism(value: boolean);
  48160. /**
  48161. * Will flag all materials as dirty to trigger new shader compilation
  48162. * @param flag defines the flag used to specify which material part must be marked as dirty
  48163. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48164. */
  48165. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48166. /** @hidden */
  48167. _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;
  48168. /** @hidden */
  48169. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48170. /** @hidden */
  48171. _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;
  48172. /** @hidden */
  48173. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48174. /** @hidden */
  48175. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48176. /** @hidden */
  48177. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48178. }
  48179. }
  48180. declare module BABYLON {
  48181. /**
  48182. * Set of assets to keep when moving a scene into an asset container.
  48183. */
  48184. export class KeepAssets extends AbstractScene {
  48185. }
  48186. /**
  48187. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48188. */
  48189. export class InstantiatedEntries {
  48190. /**
  48191. * List of new root nodes (eg. nodes with no parent)
  48192. */
  48193. rootNodes: TransformNode[];
  48194. /**
  48195. * List of new skeletons
  48196. */
  48197. skeletons: Skeleton[];
  48198. /**
  48199. * List of new animation groups
  48200. */
  48201. animationGroups: AnimationGroup[];
  48202. }
  48203. /**
  48204. * Container with a set of assets that can be added or removed from a scene.
  48205. */
  48206. export class AssetContainer extends AbstractScene {
  48207. private _wasAddedToScene;
  48208. /**
  48209. * The scene the AssetContainer belongs to.
  48210. */
  48211. scene: Scene;
  48212. /**
  48213. * Instantiates an AssetContainer.
  48214. * @param scene The scene the AssetContainer belongs to.
  48215. */
  48216. constructor(scene: Scene);
  48217. /**
  48218. * Instantiate or clone all meshes and add the new ones to the scene.
  48219. * Skeletons and animation groups will all be cloned
  48220. * @param nameFunction defines an optional function used to get new names for clones
  48221. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48222. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48223. */
  48224. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48225. /**
  48226. * Adds all the assets from the container to the scene.
  48227. */
  48228. addAllToScene(): void;
  48229. /**
  48230. * Removes all the assets in the container from the scene
  48231. */
  48232. removeAllFromScene(): void;
  48233. /**
  48234. * Disposes all the assets in the container
  48235. */
  48236. dispose(): void;
  48237. private _moveAssets;
  48238. /**
  48239. * Removes all the assets contained in the scene and adds them to the container.
  48240. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48241. */
  48242. moveAllFromScene(keepAssets?: KeepAssets): void;
  48243. /**
  48244. * 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.
  48245. * @returns the root mesh
  48246. */
  48247. createRootMesh(): Mesh;
  48248. /**
  48249. * Merge animations (direct and animation groups) from this asset container into a scene
  48250. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48251. * @param animatables set of animatables to retarget to a node from the scene
  48252. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48253. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48254. */
  48255. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48256. }
  48257. }
  48258. declare module BABYLON {
  48259. /**
  48260. * Defines how the parser contract is defined.
  48261. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48262. */
  48263. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48264. /**
  48265. * Defines how the individual parser contract is defined.
  48266. * These parser can parse an individual asset
  48267. */
  48268. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48269. /**
  48270. * Base class of the scene acting as a container for the different elements composing a scene.
  48271. * This class is dynamically extended by the different components of the scene increasing
  48272. * flexibility and reducing coupling
  48273. */
  48274. export abstract class AbstractScene {
  48275. /**
  48276. * Stores the list of available parsers in the application.
  48277. */
  48278. private static _BabylonFileParsers;
  48279. /**
  48280. * Stores the list of available individual parsers in the application.
  48281. */
  48282. private static _IndividualBabylonFileParsers;
  48283. /**
  48284. * Adds a parser in the list of available ones
  48285. * @param name Defines the name of the parser
  48286. * @param parser Defines the parser to add
  48287. */
  48288. static AddParser(name: string, parser: BabylonFileParser): void;
  48289. /**
  48290. * Gets a general parser from the list of avaialble ones
  48291. * @param name Defines the name of the parser
  48292. * @returns the requested parser or null
  48293. */
  48294. static GetParser(name: string): Nullable<BabylonFileParser>;
  48295. /**
  48296. * Adds n individual parser in the list of available ones
  48297. * @param name Defines the name of the parser
  48298. * @param parser Defines the parser to add
  48299. */
  48300. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48301. /**
  48302. * Gets an individual parser from the list of avaialble ones
  48303. * @param name Defines the name of the parser
  48304. * @returns the requested parser or null
  48305. */
  48306. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48307. /**
  48308. * Parser json data and populate both a scene and its associated container object
  48309. * @param jsonData Defines the data to parse
  48310. * @param scene Defines the scene to parse the data for
  48311. * @param container Defines the container attached to the parsing sequence
  48312. * @param rootUrl Defines the root url of the data
  48313. */
  48314. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48315. /**
  48316. * Gets the list of root nodes (ie. nodes with no parent)
  48317. */
  48318. rootNodes: Node[];
  48319. /** All of the cameras added to this scene
  48320. * @see https://doc.babylonjs.com/babylon101/cameras
  48321. */
  48322. cameras: Camera[];
  48323. /**
  48324. * All of the lights added to this scene
  48325. * @see https://doc.babylonjs.com/babylon101/lights
  48326. */
  48327. lights: Light[];
  48328. /**
  48329. * All of the (abstract) meshes added to this scene
  48330. */
  48331. meshes: AbstractMesh[];
  48332. /**
  48333. * The list of skeletons added to the scene
  48334. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48335. */
  48336. skeletons: Skeleton[];
  48337. /**
  48338. * All of the particle systems added to this scene
  48339. * @see https://doc.babylonjs.com/babylon101/particles
  48340. */
  48341. particleSystems: IParticleSystem[];
  48342. /**
  48343. * Gets a list of Animations associated with the scene
  48344. */
  48345. animations: Animation[];
  48346. /**
  48347. * All of the animation groups added to this scene
  48348. * @see https://doc.babylonjs.com/how_to/group
  48349. */
  48350. animationGroups: AnimationGroup[];
  48351. /**
  48352. * All of the multi-materials added to this scene
  48353. * @see https://doc.babylonjs.com/how_to/multi_materials
  48354. */
  48355. multiMaterials: MultiMaterial[];
  48356. /**
  48357. * All of the materials added to this scene
  48358. * In the context of a Scene, it is not supposed to be modified manually.
  48359. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48360. * Note also that the order of the Material within the array is not significant and might change.
  48361. * @see https://doc.babylonjs.com/babylon101/materials
  48362. */
  48363. materials: Material[];
  48364. /**
  48365. * The list of morph target managers added to the scene
  48366. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48367. */
  48368. morphTargetManagers: MorphTargetManager[];
  48369. /**
  48370. * The list of geometries used in the scene.
  48371. */
  48372. geometries: Geometry[];
  48373. /**
  48374. * All of the tranform nodes added to this scene
  48375. * In the context of a Scene, it is not supposed to be modified manually.
  48376. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48377. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48378. * @see https://doc.babylonjs.com/how_to/transformnode
  48379. */
  48380. transformNodes: TransformNode[];
  48381. /**
  48382. * ActionManagers available on the scene.
  48383. */
  48384. actionManagers: AbstractActionManager[];
  48385. /**
  48386. * Textures to keep.
  48387. */
  48388. textures: BaseTexture[];
  48389. /** @hidden */
  48390. protected _environmentTexture: Nullable<BaseTexture>;
  48391. /**
  48392. * Texture used in all pbr material as the reflection texture.
  48393. * As in the majority of the scene they are the same (exception for multi room and so on),
  48394. * this is easier to reference from here than from all the materials.
  48395. */
  48396. get environmentTexture(): Nullable<BaseTexture>;
  48397. set environmentTexture(value: Nullable<BaseTexture>);
  48398. /**
  48399. * The list of postprocesses added to the scene
  48400. */
  48401. postProcesses: PostProcess[];
  48402. /**
  48403. * @returns all meshes, lights, cameras, transformNodes and bones
  48404. */
  48405. getNodes(): Array<Node>;
  48406. }
  48407. }
  48408. declare module BABYLON {
  48409. /**
  48410. * Interface used to define options for Sound class
  48411. */
  48412. export interface ISoundOptions {
  48413. /**
  48414. * Does the sound autoplay once loaded.
  48415. */
  48416. autoplay?: boolean;
  48417. /**
  48418. * Does the sound loop after it finishes playing once.
  48419. */
  48420. loop?: boolean;
  48421. /**
  48422. * Sound's volume
  48423. */
  48424. volume?: number;
  48425. /**
  48426. * Is it a spatial sound?
  48427. */
  48428. spatialSound?: boolean;
  48429. /**
  48430. * Maximum distance to hear that sound
  48431. */
  48432. maxDistance?: number;
  48433. /**
  48434. * Uses user defined attenuation function
  48435. */
  48436. useCustomAttenuation?: boolean;
  48437. /**
  48438. * Define the roll off factor of spatial sounds.
  48439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48440. */
  48441. rolloffFactor?: number;
  48442. /**
  48443. * Define the reference distance the sound should be heard perfectly.
  48444. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48445. */
  48446. refDistance?: number;
  48447. /**
  48448. * Define the distance attenuation model the sound will follow.
  48449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48450. */
  48451. distanceModel?: string;
  48452. /**
  48453. * Defines the playback speed (1 by default)
  48454. */
  48455. playbackRate?: number;
  48456. /**
  48457. * Defines if the sound is from a streaming source
  48458. */
  48459. streaming?: boolean;
  48460. /**
  48461. * Defines an optional length (in seconds) inside the sound file
  48462. */
  48463. length?: number;
  48464. /**
  48465. * Defines an optional offset (in seconds) inside the sound file
  48466. */
  48467. offset?: number;
  48468. /**
  48469. * If true, URLs will not be required to state the audio file codec to use.
  48470. */
  48471. skipCodecCheck?: boolean;
  48472. }
  48473. }
  48474. declare module BABYLON {
  48475. /**
  48476. * Defines a sound that can be played in the application.
  48477. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48479. */
  48480. export class Sound {
  48481. /**
  48482. * The name of the sound in the scene.
  48483. */
  48484. name: string;
  48485. /**
  48486. * Does the sound autoplay once loaded.
  48487. */
  48488. autoplay: boolean;
  48489. private _loop;
  48490. /**
  48491. * Does the sound loop after it finishes playing once.
  48492. */
  48493. get loop(): boolean;
  48494. set loop(value: boolean);
  48495. /**
  48496. * Does the sound use a custom attenuation curve to simulate the falloff
  48497. * happening when the source gets further away from the camera.
  48498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48499. */
  48500. useCustomAttenuation: boolean;
  48501. /**
  48502. * The sound track id this sound belongs to.
  48503. */
  48504. soundTrackId: number;
  48505. /**
  48506. * Is this sound currently played.
  48507. */
  48508. isPlaying: boolean;
  48509. /**
  48510. * Is this sound currently paused.
  48511. */
  48512. isPaused: boolean;
  48513. /**
  48514. * Does this sound enables spatial sound.
  48515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48516. */
  48517. spatialSound: boolean;
  48518. /**
  48519. * Define the reference distance the sound should be heard perfectly.
  48520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48521. */
  48522. refDistance: number;
  48523. /**
  48524. * Define the roll off factor of spatial sounds.
  48525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48526. */
  48527. rolloffFactor: number;
  48528. /**
  48529. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48531. */
  48532. maxDistance: number;
  48533. /**
  48534. * Define the distance attenuation model the sound will follow.
  48535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48536. */
  48537. distanceModel: string;
  48538. /**
  48539. * @hidden
  48540. * Back Compat
  48541. **/
  48542. onended: () => any;
  48543. /**
  48544. * Gets or sets an object used to store user defined information for the sound.
  48545. */
  48546. metadata: any;
  48547. /**
  48548. * Observable event when the current playing sound finishes.
  48549. */
  48550. onEndedObservable: Observable<Sound>;
  48551. /**
  48552. * Gets the current time for the sound.
  48553. */
  48554. get currentTime(): number;
  48555. private _panningModel;
  48556. private _playbackRate;
  48557. private _streaming;
  48558. private _startTime;
  48559. private _startOffset;
  48560. private _position;
  48561. /** @hidden */
  48562. _positionInEmitterSpace: boolean;
  48563. private _localDirection;
  48564. private _volume;
  48565. private _isReadyToPlay;
  48566. private _isDirectional;
  48567. private _readyToPlayCallback;
  48568. private _audioBuffer;
  48569. private _soundSource;
  48570. private _streamingSource;
  48571. private _soundPanner;
  48572. private _soundGain;
  48573. private _inputAudioNode;
  48574. private _outputAudioNode;
  48575. private _coneInnerAngle;
  48576. private _coneOuterAngle;
  48577. private _coneOuterGain;
  48578. private _scene;
  48579. private _connectedTransformNode;
  48580. private _customAttenuationFunction;
  48581. private _registerFunc;
  48582. private _isOutputConnected;
  48583. private _htmlAudioElement;
  48584. private _urlType;
  48585. private _length?;
  48586. private _offset?;
  48587. /** @hidden */
  48588. static _SceneComponentInitialization: (scene: Scene) => void;
  48589. /**
  48590. * Create a sound and attach it to a scene
  48591. * @param name Name of your sound
  48592. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48593. * @param scene defines the scene the sound belongs to
  48594. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48595. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48596. */
  48597. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48598. /**
  48599. * Release the sound and its associated resources
  48600. */
  48601. dispose(): void;
  48602. /**
  48603. * Gets if the sounds is ready to be played or not.
  48604. * @returns true if ready, otherwise false
  48605. */
  48606. isReady(): boolean;
  48607. /**
  48608. * Get the current class name.
  48609. * @returns current class name
  48610. */
  48611. getClassName(): string;
  48612. private _soundLoaded;
  48613. /**
  48614. * Sets the data of the sound from an audiobuffer
  48615. * @param audioBuffer The audioBuffer containing the data
  48616. */
  48617. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48618. /**
  48619. * Updates the current sounds options such as maxdistance, loop...
  48620. * @param options A JSON object containing values named as the object properties
  48621. */
  48622. updateOptions(options: ISoundOptions): void;
  48623. private _createSpatialParameters;
  48624. private _updateSpatialParameters;
  48625. /**
  48626. * Switch the panning model to HRTF:
  48627. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48628. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48629. */
  48630. switchPanningModelToHRTF(): void;
  48631. /**
  48632. * Switch the panning model to Equal Power:
  48633. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48635. */
  48636. switchPanningModelToEqualPower(): void;
  48637. private _switchPanningModel;
  48638. /**
  48639. * Connect this sound to a sound track audio node like gain...
  48640. * @param soundTrackAudioNode the sound track audio node to connect to
  48641. */
  48642. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48643. /**
  48644. * Transform this sound into a directional source
  48645. * @param coneInnerAngle Size of the inner cone in degree
  48646. * @param coneOuterAngle Size of the outer cone in degree
  48647. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48648. */
  48649. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48650. /**
  48651. * Gets or sets the inner angle for the directional cone.
  48652. */
  48653. get directionalConeInnerAngle(): number;
  48654. /**
  48655. * Gets or sets the inner angle for the directional cone.
  48656. */
  48657. set directionalConeInnerAngle(value: number);
  48658. /**
  48659. * Gets or sets the outer angle for the directional cone.
  48660. */
  48661. get directionalConeOuterAngle(): number;
  48662. /**
  48663. * Gets or sets the outer angle for the directional cone.
  48664. */
  48665. set directionalConeOuterAngle(value: number);
  48666. /**
  48667. * Sets the position of the emitter if spatial sound is enabled
  48668. * @param newPosition Defines the new position
  48669. */
  48670. setPosition(newPosition: Vector3): void;
  48671. /**
  48672. * Sets the local direction of the emitter if spatial sound is enabled
  48673. * @param newLocalDirection Defines the new local direction
  48674. */
  48675. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48676. private _updateDirection;
  48677. /** @hidden */
  48678. updateDistanceFromListener(): void;
  48679. /**
  48680. * Sets a new custom attenuation function for the sound.
  48681. * @param callback Defines the function used for the attenuation
  48682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48683. */
  48684. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48685. /**
  48686. * Play the sound
  48687. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48688. * @param offset (optional) Start the sound at a specific time in seconds
  48689. * @param length (optional) Sound duration (in seconds)
  48690. */
  48691. play(time?: number, offset?: number, length?: number): void;
  48692. private _onended;
  48693. /**
  48694. * Stop the sound
  48695. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48696. */
  48697. stop(time?: number): void;
  48698. /**
  48699. * Put the sound in pause
  48700. */
  48701. pause(): void;
  48702. /**
  48703. * Sets a dedicated volume for this sounds
  48704. * @param newVolume Define the new volume of the sound
  48705. * @param time Define time for gradual change to new volume
  48706. */
  48707. setVolume(newVolume: number, time?: number): void;
  48708. /**
  48709. * Set the sound play back rate
  48710. * @param newPlaybackRate Define the playback rate the sound should be played at
  48711. */
  48712. setPlaybackRate(newPlaybackRate: number): void;
  48713. /**
  48714. * Gets the volume of the sound.
  48715. * @returns the volume of the sound
  48716. */
  48717. getVolume(): number;
  48718. /**
  48719. * Attach the sound to a dedicated mesh
  48720. * @param transformNode The transform node to connect the sound with
  48721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48722. */
  48723. attachToMesh(transformNode: TransformNode): void;
  48724. /**
  48725. * Detach the sound from the previously attached mesh
  48726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48727. */
  48728. detachFromMesh(): void;
  48729. private _onRegisterAfterWorldMatrixUpdate;
  48730. /**
  48731. * Clone the current sound in the scene.
  48732. * @returns the new sound clone
  48733. */
  48734. clone(): Nullable<Sound>;
  48735. /**
  48736. * Gets the current underlying audio buffer containing the data
  48737. * @returns the audio buffer
  48738. */
  48739. getAudioBuffer(): Nullable<AudioBuffer>;
  48740. /**
  48741. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48742. * @returns the source node
  48743. */
  48744. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48745. /**
  48746. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48747. * @returns the gain node
  48748. */
  48749. getSoundGain(): Nullable<GainNode>;
  48750. /**
  48751. * Serializes the Sound in a JSON representation
  48752. * @returns the JSON representation of the sound
  48753. */
  48754. serialize(): any;
  48755. /**
  48756. * Parse a JSON representation of a sound to instantiate in a given scene
  48757. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48758. * @param scene Define the scene the new parsed sound should be created in
  48759. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48760. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48761. * @returns the newly parsed sound
  48762. */
  48763. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /**
  48768. * This defines an action helpful to play a defined sound on a triggered action.
  48769. */
  48770. export class PlaySoundAction extends Action {
  48771. private _sound;
  48772. /**
  48773. * Instantiate the action
  48774. * @param triggerOptions defines the trigger options
  48775. * @param sound defines the sound to play
  48776. * @param condition defines the trigger related conditions
  48777. */
  48778. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48779. /** @hidden */
  48780. _prepare(): void;
  48781. /**
  48782. * Execute the action and play the sound.
  48783. */
  48784. execute(): void;
  48785. /**
  48786. * Serializes the actions and its related information.
  48787. * @param parent defines the object to serialize in
  48788. * @returns the serialized object
  48789. */
  48790. serialize(parent: any): any;
  48791. }
  48792. /**
  48793. * This defines an action helpful to stop a defined sound on a triggered action.
  48794. */
  48795. export class StopSoundAction extends Action {
  48796. private _sound;
  48797. /**
  48798. * Instantiate the action
  48799. * @param triggerOptions defines the trigger options
  48800. * @param sound defines the sound to stop
  48801. * @param condition defines the trigger related conditions
  48802. */
  48803. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48804. /** @hidden */
  48805. _prepare(): void;
  48806. /**
  48807. * Execute the action and stop the sound.
  48808. */
  48809. execute(): void;
  48810. /**
  48811. * Serializes the actions and its related information.
  48812. * @param parent defines the object to serialize in
  48813. * @returns the serialized object
  48814. */
  48815. serialize(parent: any): any;
  48816. }
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * This defines an action responsible to change the value of a property
  48821. * by interpolating between its current value and the newly set one once triggered.
  48822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48823. */
  48824. export class InterpolateValueAction extends Action {
  48825. /**
  48826. * Defines the path of the property where the value should be interpolated
  48827. */
  48828. propertyPath: string;
  48829. /**
  48830. * Defines the target value at the end of the interpolation.
  48831. */
  48832. value: any;
  48833. /**
  48834. * Defines the time it will take for the property to interpolate to the value.
  48835. */
  48836. duration: number;
  48837. /**
  48838. * Defines if the other scene animations should be stopped when the action has been triggered
  48839. */
  48840. stopOtherAnimations?: boolean;
  48841. /**
  48842. * Defines a callback raised once the interpolation animation has been done.
  48843. */
  48844. onInterpolationDone?: () => void;
  48845. /**
  48846. * Observable triggered once the interpolation animation has been done.
  48847. */
  48848. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48849. private _target;
  48850. private _effectiveTarget;
  48851. private _property;
  48852. /**
  48853. * Instantiate the action
  48854. * @param triggerOptions defines the trigger options
  48855. * @param target defines the object containing the value to interpolate
  48856. * @param propertyPath defines the path to the property in the target object
  48857. * @param value defines the target value at the end of the interpolation
  48858. * @param duration defines the time it will take for the property to interpolate to the value.
  48859. * @param condition defines the trigger related conditions
  48860. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48861. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48862. */
  48863. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48864. /** @hidden */
  48865. _prepare(): void;
  48866. /**
  48867. * Execute the action starts the value interpolation.
  48868. */
  48869. execute(): void;
  48870. /**
  48871. * Serializes the actions and its related information.
  48872. * @param parent defines the object to serialize in
  48873. * @returns the serialized object
  48874. */
  48875. serialize(parent: any): any;
  48876. }
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * A cursor which tracks a point on a path
  48881. */
  48882. export class PathCursor {
  48883. private path;
  48884. /**
  48885. * Stores path cursor callbacks for when an onchange event is triggered
  48886. */
  48887. private _onchange;
  48888. /**
  48889. * The value of the path cursor
  48890. */
  48891. value: number;
  48892. /**
  48893. * The animation array of the path cursor
  48894. */
  48895. animations: Animation[];
  48896. /**
  48897. * Initializes the path cursor
  48898. * @param path The path to track
  48899. */
  48900. constructor(path: Path2);
  48901. /**
  48902. * Gets the cursor point on the path
  48903. * @returns A point on the path cursor at the cursor location
  48904. */
  48905. getPoint(): Vector3;
  48906. /**
  48907. * Moves the cursor ahead by the step amount
  48908. * @param step The amount to move the cursor forward
  48909. * @returns This path cursor
  48910. */
  48911. moveAhead(step?: number): PathCursor;
  48912. /**
  48913. * Moves the cursor behind by the step amount
  48914. * @param step The amount to move the cursor back
  48915. * @returns This path cursor
  48916. */
  48917. moveBack(step?: number): PathCursor;
  48918. /**
  48919. * Moves the cursor by the step amount
  48920. * If the step amount is greater than one, an exception is thrown
  48921. * @param step The amount to move the cursor
  48922. * @returns This path cursor
  48923. */
  48924. move(step: number): PathCursor;
  48925. /**
  48926. * Ensures that the value is limited between zero and one
  48927. * @returns This path cursor
  48928. */
  48929. private ensureLimits;
  48930. /**
  48931. * Runs onchange callbacks on change (used by the animation engine)
  48932. * @returns This path cursor
  48933. */
  48934. private raiseOnChange;
  48935. /**
  48936. * Executes a function on change
  48937. * @param f A path cursor onchange callback
  48938. * @returns This path cursor
  48939. */
  48940. onchange(f: (cursor: PathCursor) => void): PathCursor;
  48941. }
  48942. }
  48943. declare module BABYLON {
  48944. /**
  48945. * This represents the default audio engine used in babylon.
  48946. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48948. */
  48949. export class AudioEngine implements IAudioEngine {
  48950. private _audioContext;
  48951. private _audioContextInitialized;
  48952. private _muteButton;
  48953. private _hostElement;
  48954. /**
  48955. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48956. */
  48957. canUseWebAudio: boolean;
  48958. /**
  48959. * The master gain node defines the global audio volume of your audio engine.
  48960. */
  48961. masterGain: GainNode;
  48962. /**
  48963. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48964. * @ignoreNaming
  48965. */
  48966. WarnedWebAudioUnsupported: boolean;
  48967. /**
  48968. * Gets whether or not mp3 are supported by your browser.
  48969. */
  48970. isMP3supported: boolean;
  48971. /**
  48972. * Gets whether or not ogg are supported by your browser.
  48973. */
  48974. isOGGsupported: boolean;
  48975. /**
  48976. * Gets whether audio has been unlocked on the device.
  48977. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48978. * a user interaction has happened.
  48979. */
  48980. unlocked: boolean;
  48981. /**
  48982. * Defines if the audio engine relies on a custom unlocked button.
  48983. * In this case, the embedded button will not be displayed.
  48984. */
  48985. useCustomUnlockedButton: boolean;
  48986. /**
  48987. * Event raised when audio has been unlocked on the browser.
  48988. */
  48989. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48990. /**
  48991. * Event raised when audio has been locked on the browser.
  48992. */
  48993. onAudioLockedObservable: Observable<IAudioEngine>;
  48994. /**
  48995. * Gets the current AudioContext if available.
  48996. */
  48997. get audioContext(): Nullable<AudioContext>;
  48998. private _connectedAnalyser;
  48999. /**
  49000. * Instantiates a new audio engine.
  49001. *
  49002. * There should be only one per page as some browsers restrict the number
  49003. * of audio contexts you can create.
  49004. * @param hostElement defines the host element where to display the mute icon if necessary
  49005. */
  49006. constructor(hostElement?: Nullable<HTMLElement>);
  49007. /**
  49008. * Flags the audio engine in Locked state.
  49009. * This happens due to new browser policies preventing audio to autoplay.
  49010. */
  49011. lock(): void;
  49012. /**
  49013. * Unlocks the audio engine once a user action has been done on the dom.
  49014. * This is helpful to resume play once browser policies have been satisfied.
  49015. */
  49016. unlock(): void;
  49017. private _resumeAudioContext;
  49018. private _initializeAudioContext;
  49019. private _tryToRun;
  49020. private _triggerRunningState;
  49021. private _triggerSuspendedState;
  49022. private _displayMuteButton;
  49023. private _moveButtonToTopLeft;
  49024. private _onResize;
  49025. private _hideMuteButton;
  49026. /**
  49027. * Destroy and release the resources associated with the audio context.
  49028. */
  49029. dispose(): void;
  49030. /**
  49031. * Gets the global volume sets on the master gain.
  49032. * @returns the global volume if set or -1 otherwise
  49033. */
  49034. getGlobalVolume(): number;
  49035. /**
  49036. * Sets the global volume of your experience (sets on the master gain).
  49037. * @param newVolume Defines the new global volume of the application
  49038. */
  49039. setGlobalVolume(newVolume: number): void;
  49040. /**
  49041. * Connect the audio engine to an audio analyser allowing some amazing
  49042. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49043. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49044. * @param analyser The analyser to connect to the engine
  49045. */
  49046. connectToAnalyser(analyser: Analyser): void;
  49047. }
  49048. }
  49049. declare module BABYLON {
  49050. /**
  49051. * Options allowed during the creation of a sound track.
  49052. */
  49053. export interface ISoundTrackOptions {
  49054. /**
  49055. * The volume the sound track should take during creation
  49056. */
  49057. volume?: number;
  49058. /**
  49059. * Define if the sound track is the main sound track of the scene
  49060. */
  49061. mainTrack?: boolean;
  49062. }
  49063. /**
  49064. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49065. * It will be also used in a future release to apply effects on a specific track.
  49066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49067. */
  49068. export class SoundTrack {
  49069. /**
  49070. * The unique identifier of the sound track in the scene.
  49071. */
  49072. id: number;
  49073. /**
  49074. * The list of sounds included in the sound track.
  49075. */
  49076. soundCollection: Array<Sound>;
  49077. private _outputAudioNode;
  49078. private _scene;
  49079. private _connectedAnalyser;
  49080. private _options;
  49081. private _isInitialized;
  49082. /**
  49083. * Creates a new sound track.
  49084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49085. * @param scene Define the scene the sound track belongs to
  49086. * @param options
  49087. */
  49088. constructor(scene: Scene, options?: ISoundTrackOptions);
  49089. private _initializeSoundTrackAudioGraph;
  49090. /**
  49091. * Release the sound track and its associated resources
  49092. */
  49093. dispose(): void;
  49094. /**
  49095. * Adds a sound to this sound track
  49096. * @param sound define the sound to add
  49097. * @ignoreNaming
  49098. */
  49099. addSound(sound: Sound): void;
  49100. /**
  49101. * Removes a sound to this sound track
  49102. * @param sound define the sound to remove
  49103. * @ignoreNaming
  49104. */
  49105. removeSound(sound: Sound): void;
  49106. /**
  49107. * Set a global volume for the full sound track.
  49108. * @param newVolume Define the new volume of the sound track
  49109. */
  49110. setVolume(newVolume: number): void;
  49111. /**
  49112. * Switch the panning model to HRTF:
  49113. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49115. */
  49116. switchPanningModelToHRTF(): void;
  49117. /**
  49118. * Switch the panning model to Equal Power:
  49119. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49121. */
  49122. switchPanningModelToEqualPower(): void;
  49123. /**
  49124. * Connect the sound track to an audio analyser allowing some amazing
  49125. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49127. * @param analyser The analyser to connect to the engine
  49128. */
  49129. connectToAnalyser(analyser: Analyser): void;
  49130. }
  49131. }
  49132. declare module BABYLON {
  49133. interface AbstractScene {
  49134. /**
  49135. * The list of sounds used in the scene.
  49136. */
  49137. sounds: Nullable<Array<Sound>>;
  49138. }
  49139. interface Scene {
  49140. /**
  49141. * @hidden
  49142. * Backing field
  49143. */
  49144. _mainSoundTrack: SoundTrack;
  49145. /**
  49146. * The main sound track played by the scene.
  49147. * It contains your primary collection of sounds.
  49148. */
  49149. mainSoundTrack: SoundTrack;
  49150. /**
  49151. * The list of sound tracks added to the scene
  49152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49153. */
  49154. soundTracks: Nullable<Array<SoundTrack>>;
  49155. /**
  49156. * Gets a sound using a given name
  49157. * @param name defines the name to search for
  49158. * @return the found sound or null if not found at all.
  49159. */
  49160. getSoundByName(name: string): Nullable<Sound>;
  49161. /**
  49162. * Gets or sets if audio support is enabled
  49163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49164. */
  49165. audioEnabled: boolean;
  49166. /**
  49167. * Gets or sets if audio will be output to headphones
  49168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49169. */
  49170. headphone: boolean;
  49171. /**
  49172. * Gets or sets custom audio listener position provider
  49173. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49174. */
  49175. audioListenerPositionProvider: Nullable<() => Vector3>;
  49176. /**
  49177. * Gets or sets a refresh rate when using 3D audio positioning
  49178. */
  49179. audioPositioningRefreshRate: number;
  49180. }
  49181. /**
  49182. * Defines the sound scene component responsible to manage any sounds
  49183. * in a given scene.
  49184. */
  49185. export class AudioSceneComponent implements ISceneSerializableComponent {
  49186. private static _CameraDirectionLH;
  49187. private static _CameraDirectionRH;
  49188. /**
  49189. * The component name helpful to identify the component in the list of scene components.
  49190. */
  49191. readonly name: string;
  49192. /**
  49193. * The scene the component belongs to.
  49194. */
  49195. scene: Scene;
  49196. private _audioEnabled;
  49197. /**
  49198. * Gets whether audio is enabled or not.
  49199. * Please use related enable/disable method to switch state.
  49200. */
  49201. get audioEnabled(): boolean;
  49202. private _headphone;
  49203. /**
  49204. * Gets whether audio is outputting to headphone or not.
  49205. * Please use the according Switch methods to change output.
  49206. */
  49207. get headphone(): boolean;
  49208. /**
  49209. * Gets or sets a refresh rate when using 3D audio positioning
  49210. */
  49211. audioPositioningRefreshRate: number;
  49212. private _audioListenerPositionProvider;
  49213. /**
  49214. * Gets the current audio listener position provider
  49215. */
  49216. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49217. /**
  49218. * Sets a custom listener position for all sounds in the scene
  49219. * By default, this is the position of the first active camera
  49220. */
  49221. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49222. /**
  49223. * Creates a new instance of the component for the given scene
  49224. * @param scene Defines the scene to register the component in
  49225. */
  49226. constructor(scene: Scene);
  49227. /**
  49228. * Registers the component in a given scene
  49229. */
  49230. register(): void;
  49231. /**
  49232. * Rebuilds the elements related to this component in case of
  49233. * context lost for instance.
  49234. */
  49235. rebuild(): void;
  49236. /**
  49237. * Serializes the component data to the specified json object
  49238. * @param serializationObject The object to serialize to
  49239. */
  49240. serialize(serializationObject: any): void;
  49241. /**
  49242. * Adds all the elements from the container to the scene
  49243. * @param container the container holding the elements
  49244. */
  49245. addFromContainer(container: AbstractScene): void;
  49246. /**
  49247. * Removes all the elements in the container from the scene
  49248. * @param container contains the elements to remove
  49249. * @param dispose if the removed element should be disposed (default: false)
  49250. */
  49251. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49252. /**
  49253. * Disposes the component and the associated resources.
  49254. */
  49255. dispose(): void;
  49256. /**
  49257. * Disables audio in the associated scene.
  49258. */
  49259. disableAudio(): void;
  49260. /**
  49261. * Enables audio in the associated scene.
  49262. */
  49263. enableAudio(): void;
  49264. /**
  49265. * Switch audio to headphone output.
  49266. */
  49267. switchAudioModeForHeadphones(): void;
  49268. /**
  49269. * Switch audio to normal speakers.
  49270. */
  49271. switchAudioModeForNormalSpeakers(): void;
  49272. private _cachedCameraDirection;
  49273. private _cachedCameraPosition;
  49274. private _lastCheck;
  49275. private _afterRender;
  49276. }
  49277. }
  49278. declare module BABYLON {
  49279. /**
  49280. * Wraps one or more Sound objects and selects one with random weight for playback.
  49281. */
  49282. export class WeightedSound {
  49283. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49284. loop: boolean;
  49285. private _coneInnerAngle;
  49286. private _coneOuterAngle;
  49287. private _volume;
  49288. /** A Sound is currently playing. */
  49289. isPlaying: boolean;
  49290. /** A Sound is currently paused. */
  49291. isPaused: boolean;
  49292. private _sounds;
  49293. private _weights;
  49294. private _currentIndex?;
  49295. /**
  49296. * Creates a new WeightedSound from the list of sounds given.
  49297. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49298. * @param sounds Array of Sounds that will be selected from.
  49299. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49300. */
  49301. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49302. /**
  49303. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49304. */
  49305. get directionalConeInnerAngle(): number;
  49306. /**
  49307. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49308. */
  49309. set directionalConeInnerAngle(value: number);
  49310. /**
  49311. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49312. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49313. */
  49314. get directionalConeOuterAngle(): number;
  49315. /**
  49316. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49317. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49318. */
  49319. set directionalConeOuterAngle(value: number);
  49320. /**
  49321. * Playback volume.
  49322. */
  49323. get volume(): number;
  49324. /**
  49325. * Playback volume.
  49326. */
  49327. set volume(value: number);
  49328. private _onended;
  49329. /**
  49330. * Suspend playback
  49331. */
  49332. pause(): void;
  49333. /**
  49334. * Stop playback
  49335. */
  49336. stop(): void;
  49337. /**
  49338. * Start playback.
  49339. * @param startOffset Position the clip head at a specific time in seconds.
  49340. */
  49341. play(startOffset?: number): void;
  49342. }
  49343. }
  49344. declare module BABYLON {
  49345. /**
  49346. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49347. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49348. */
  49349. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49350. /**
  49351. * Gets the name of the behavior.
  49352. */
  49353. get name(): string;
  49354. /**
  49355. * The easing function used by animations
  49356. */
  49357. static EasingFunction: BackEase;
  49358. /**
  49359. * The easing mode used by animations
  49360. */
  49361. static EasingMode: number;
  49362. /**
  49363. * The duration of the animation, in milliseconds
  49364. */
  49365. transitionDuration: number;
  49366. /**
  49367. * Length of the distance animated by the transition when lower radius is reached
  49368. */
  49369. lowerRadiusTransitionRange: number;
  49370. /**
  49371. * Length of the distance animated by the transition when upper radius is reached
  49372. */
  49373. upperRadiusTransitionRange: number;
  49374. private _autoTransitionRange;
  49375. /**
  49376. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49377. */
  49378. get autoTransitionRange(): boolean;
  49379. /**
  49380. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49381. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49382. */
  49383. set autoTransitionRange(value: boolean);
  49384. private _attachedCamera;
  49385. private _onAfterCheckInputsObserver;
  49386. private _onMeshTargetChangedObserver;
  49387. /**
  49388. * Initializes the behavior.
  49389. */
  49390. init(): void;
  49391. /**
  49392. * Attaches the behavior to its arc rotate camera.
  49393. * @param camera Defines the camera to attach the behavior to
  49394. */
  49395. attach(camera: ArcRotateCamera): void;
  49396. /**
  49397. * Detaches the behavior from its current arc rotate camera.
  49398. */
  49399. detach(): void;
  49400. private _radiusIsAnimating;
  49401. private _radiusBounceTransition;
  49402. private _animatables;
  49403. private _cachedWheelPrecision;
  49404. /**
  49405. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49406. * @param radiusLimit The limit to check against.
  49407. * @return Bool to indicate if at limit.
  49408. */
  49409. private _isRadiusAtLimit;
  49410. /**
  49411. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49412. * @param radiusDelta The delta by which to animate to. Can be negative.
  49413. */
  49414. private _applyBoundRadiusAnimation;
  49415. /**
  49416. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49417. */
  49418. protected _clearAnimationLocks(): void;
  49419. /**
  49420. * Stops and removes all animations that have been applied to the camera
  49421. */
  49422. stopAllAnimations(): void;
  49423. }
  49424. }
  49425. declare module BABYLON {
  49426. /**
  49427. * 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.
  49428. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49429. */
  49430. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49431. /**
  49432. * Gets the name of the behavior.
  49433. */
  49434. get name(): string;
  49435. private _mode;
  49436. private _radiusScale;
  49437. private _positionScale;
  49438. private _defaultElevation;
  49439. private _elevationReturnTime;
  49440. private _elevationReturnWaitTime;
  49441. private _zoomStopsAnimation;
  49442. private _framingTime;
  49443. /**
  49444. * The easing function used by animations
  49445. */
  49446. static EasingFunction: ExponentialEase;
  49447. /**
  49448. * The easing mode used by animations
  49449. */
  49450. static EasingMode: number;
  49451. /**
  49452. * Sets the current mode used by the behavior
  49453. */
  49454. set mode(mode: number);
  49455. /**
  49456. * Gets current mode used by the behavior.
  49457. */
  49458. get mode(): number;
  49459. /**
  49460. * Sets the scale applied to the radius (1 by default)
  49461. */
  49462. set radiusScale(radius: number);
  49463. /**
  49464. * Gets the scale applied to the radius
  49465. */
  49466. get radiusScale(): number;
  49467. /**
  49468. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49469. */
  49470. set positionScale(scale: number);
  49471. /**
  49472. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49473. */
  49474. get positionScale(): number;
  49475. /**
  49476. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49477. * behaviour is triggered, in radians.
  49478. */
  49479. set defaultElevation(elevation: number);
  49480. /**
  49481. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49482. * behaviour is triggered, in radians.
  49483. */
  49484. get defaultElevation(): number;
  49485. /**
  49486. * Sets the time (in milliseconds) taken to return to the default beta position.
  49487. * Negative value indicates camera should not return to default.
  49488. */
  49489. set elevationReturnTime(speed: number);
  49490. /**
  49491. * Gets the time (in milliseconds) taken to return to the default beta position.
  49492. * Negative value indicates camera should not return to default.
  49493. */
  49494. get elevationReturnTime(): number;
  49495. /**
  49496. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49497. */
  49498. set elevationReturnWaitTime(time: number);
  49499. /**
  49500. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49501. */
  49502. get elevationReturnWaitTime(): number;
  49503. /**
  49504. * Sets the flag that indicates if user zooming should stop animation.
  49505. */
  49506. set zoomStopsAnimation(flag: boolean);
  49507. /**
  49508. * Gets the flag that indicates if user zooming should stop animation.
  49509. */
  49510. get zoomStopsAnimation(): boolean;
  49511. /**
  49512. * Sets the transition time when framing the mesh, in milliseconds
  49513. */
  49514. set framingTime(time: number);
  49515. /**
  49516. * Gets the transition time when framing the mesh, in milliseconds
  49517. */
  49518. get framingTime(): number;
  49519. /**
  49520. * Define if the behavior should automatically change the configured
  49521. * camera limits and sensibilities.
  49522. */
  49523. autoCorrectCameraLimitsAndSensibility: boolean;
  49524. private _onPrePointerObservableObserver;
  49525. private _onAfterCheckInputsObserver;
  49526. private _onMeshTargetChangedObserver;
  49527. private _attachedCamera;
  49528. private _isPointerDown;
  49529. private _lastInteractionTime;
  49530. /**
  49531. * Initializes the behavior.
  49532. */
  49533. init(): void;
  49534. /**
  49535. * Attaches the behavior to its arc rotate camera.
  49536. * @param camera Defines the camera to attach the behavior to
  49537. */
  49538. attach(camera: ArcRotateCamera): void;
  49539. /**
  49540. * Detaches the behavior from its current arc rotate camera.
  49541. */
  49542. detach(): void;
  49543. private _animatables;
  49544. private _betaIsAnimating;
  49545. private _betaTransition;
  49546. private _radiusTransition;
  49547. private _vectorTransition;
  49548. /**
  49549. * Targets the given mesh and updates zoom level accordingly.
  49550. * @param mesh The mesh to target.
  49551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49553. */
  49554. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49555. /**
  49556. * Targets the given mesh with its children and updates zoom level accordingly.
  49557. * @param mesh The mesh to target.
  49558. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49559. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49560. */
  49561. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49562. /**
  49563. * Targets the given meshes with their children and updates zoom level accordingly.
  49564. * @param meshes The mesh to target.
  49565. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49566. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49567. */
  49568. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49569. /**
  49570. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49571. * @param minimumWorld Determines the smaller position of the bounding box extend
  49572. * @param maximumWorld Determines the bigger position of the bounding box extend
  49573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49575. */
  49576. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49577. /**
  49578. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49579. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49580. * frustum width.
  49581. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49582. * to fully enclose the mesh in the viewing frustum.
  49583. */
  49584. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49585. /**
  49586. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49587. * is automatically returned to its default position (expected to be above ground plane).
  49588. */
  49589. private _maintainCameraAboveGround;
  49590. /**
  49591. * Returns the frustum slope based on the canvas ratio and camera FOV
  49592. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49593. */
  49594. private _getFrustumSlope;
  49595. /**
  49596. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49597. */
  49598. private _clearAnimationLocks;
  49599. /**
  49600. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49601. */
  49602. private _applyUserInteraction;
  49603. /**
  49604. * Stops and removes all animations that have been applied to the camera
  49605. */
  49606. stopAllAnimations(): void;
  49607. /**
  49608. * Gets a value indicating if the user is moving the camera
  49609. */
  49610. get isUserIsMoving(): boolean;
  49611. /**
  49612. * The camera can move all the way towards the mesh.
  49613. */
  49614. static IgnoreBoundsSizeMode: number;
  49615. /**
  49616. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49617. */
  49618. static FitFrustumSidesMode: number;
  49619. }
  49620. }
  49621. declare module BABYLON {
  49622. /**
  49623. * Base class for Camera Pointer Inputs.
  49624. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49625. * for example usage.
  49626. */
  49627. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49628. /**
  49629. * Defines the camera the input is attached to.
  49630. */
  49631. abstract camera: Camera;
  49632. /**
  49633. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49634. */
  49635. protected _altKey: boolean;
  49636. protected _ctrlKey: boolean;
  49637. protected _metaKey: boolean;
  49638. protected _shiftKey: boolean;
  49639. /**
  49640. * Which mouse buttons were pressed at time of last mouse event.
  49641. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49642. */
  49643. protected _buttonsPressed: number;
  49644. /**
  49645. * Defines the buttons associated with the input to handle camera move.
  49646. */
  49647. buttons: number[];
  49648. /**
  49649. * Attach the input controls to a specific dom element to get the input from.
  49650. * @param element Defines the element the controls should be listened from
  49651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49652. */
  49653. attachControl(noPreventDefault?: boolean): void;
  49654. /**
  49655. * Detach the current controls from the specified dom element.
  49656. */
  49657. detachControl(): void;
  49658. /**
  49659. * Gets the class name of the current input.
  49660. * @returns the class name
  49661. */
  49662. getClassName(): string;
  49663. /**
  49664. * Get the friendly name associated with the input class.
  49665. * @returns the input friendly name
  49666. */
  49667. getSimpleName(): string;
  49668. /**
  49669. * Called on pointer POINTERDOUBLETAP event.
  49670. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49671. */
  49672. protected onDoubleTap(type: string): void;
  49673. /**
  49674. * Called on pointer POINTERMOVE event if only a single touch is active.
  49675. * Override this method to provide functionality.
  49676. */
  49677. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49678. /**
  49679. * Called on pointer POINTERMOVE event if multiple touches are active.
  49680. * Override this method to provide functionality.
  49681. */
  49682. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49683. /**
  49684. * Called on JS contextmenu event.
  49685. * Override this method to provide functionality.
  49686. */
  49687. protected onContextMenu(evt: PointerEvent): void;
  49688. /**
  49689. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49690. * press.
  49691. * Override this method to provide functionality.
  49692. */
  49693. protected onButtonDown(evt: PointerEvent): void;
  49694. /**
  49695. * Called each time a new POINTERUP event occurs. Ie, for each button
  49696. * release.
  49697. * Override this method to provide functionality.
  49698. */
  49699. protected onButtonUp(evt: PointerEvent): void;
  49700. /**
  49701. * Called when window becomes inactive.
  49702. * Override this method to provide functionality.
  49703. */
  49704. protected onLostFocus(): void;
  49705. private _pointerInput;
  49706. private _observer;
  49707. private _onLostFocus;
  49708. private pointA;
  49709. private pointB;
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /**
  49714. * Manage the pointers inputs to control an arc rotate camera.
  49715. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49716. */
  49717. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49718. /**
  49719. * Defines the camera the input is attached to.
  49720. */
  49721. camera: ArcRotateCamera;
  49722. /**
  49723. * Gets the class name of the current input.
  49724. * @returns the class name
  49725. */
  49726. getClassName(): string;
  49727. /**
  49728. * Defines the buttons associated with the input to handle camera move.
  49729. */
  49730. buttons: number[];
  49731. /**
  49732. * Defines the pointer angular sensibility along the X axis or how fast is
  49733. * the camera rotating.
  49734. */
  49735. angularSensibilityX: number;
  49736. /**
  49737. * Defines the pointer angular sensibility along the Y axis or how fast is
  49738. * the camera rotating.
  49739. */
  49740. angularSensibilityY: number;
  49741. /**
  49742. * Defines the pointer pinch precision or how fast is the camera zooming.
  49743. */
  49744. pinchPrecision: number;
  49745. /**
  49746. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49747. * from 0.
  49748. * It defines the percentage of current camera.radius to use as delta when
  49749. * pinch zoom is used.
  49750. */
  49751. pinchDeltaPercentage: number;
  49752. /**
  49753. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49754. * that any object in the plane at the camera's target point will scale
  49755. * perfectly with finger motion.
  49756. * Overrides pinchDeltaPercentage and pinchPrecision.
  49757. */
  49758. useNaturalPinchZoom: boolean;
  49759. /**
  49760. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49761. */
  49762. pinchZoom: boolean;
  49763. /**
  49764. * Defines the pointer panning sensibility or how fast is the camera moving.
  49765. */
  49766. panningSensibility: number;
  49767. /**
  49768. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49769. */
  49770. multiTouchPanning: boolean;
  49771. /**
  49772. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49773. * zoom (pinch) through multitouch.
  49774. */
  49775. multiTouchPanAndZoom: boolean;
  49776. /**
  49777. * Revers pinch action direction.
  49778. */
  49779. pinchInwards: boolean;
  49780. private _isPanClick;
  49781. private _twoFingerActivityCount;
  49782. private _isPinching;
  49783. /**
  49784. * Move camera from multi touch panning positions.
  49785. */
  49786. private _computeMultiTouchPanning;
  49787. /**
  49788. * Move camera from pinch zoom distances.
  49789. */
  49790. private _computePinchZoom;
  49791. /**
  49792. * Called on pointer POINTERMOVE event if only a single touch is active.
  49793. */
  49794. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49795. /**
  49796. * Called on pointer POINTERDOUBLETAP event.
  49797. */
  49798. protected onDoubleTap(type: string): void;
  49799. /**
  49800. * Called on pointer POINTERMOVE event if multiple touches are active.
  49801. */
  49802. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49803. /**
  49804. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49805. * press.
  49806. */
  49807. protected onButtonDown(evt: PointerEvent): void;
  49808. /**
  49809. * Called each time a new POINTERUP event occurs. Ie, for each button
  49810. * release.
  49811. */
  49812. protected onButtonUp(evt: PointerEvent): void;
  49813. /**
  49814. * Called when window becomes inactive.
  49815. */
  49816. protected onLostFocus(): void;
  49817. }
  49818. }
  49819. declare module BABYLON {
  49820. /**
  49821. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49823. */
  49824. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49825. /**
  49826. * Defines the camera the input is attached to.
  49827. */
  49828. camera: ArcRotateCamera;
  49829. /**
  49830. * Defines the list of key codes associated with the up action (increase alpha)
  49831. */
  49832. keysUp: number[];
  49833. /**
  49834. * Defines the list of key codes associated with the down action (decrease alpha)
  49835. */
  49836. keysDown: number[];
  49837. /**
  49838. * Defines the list of key codes associated with the left action (increase beta)
  49839. */
  49840. keysLeft: number[];
  49841. /**
  49842. * Defines the list of key codes associated with the right action (decrease beta)
  49843. */
  49844. keysRight: number[];
  49845. /**
  49846. * Defines the list of key codes associated with the reset action.
  49847. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49848. */
  49849. keysReset: number[];
  49850. /**
  49851. * Defines the panning sensibility of the inputs.
  49852. * (How fast is the camera panning)
  49853. */
  49854. panningSensibility: number;
  49855. /**
  49856. * Defines the zooming sensibility of the inputs.
  49857. * (How fast is the camera zooming)
  49858. */
  49859. zoomingSensibility: number;
  49860. /**
  49861. * Defines whether maintaining the alt key down switch the movement mode from
  49862. * orientation to zoom.
  49863. */
  49864. useAltToZoom: boolean;
  49865. /**
  49866. * Rotation speed of the camera
  49867. */
  49868. angularSpeed: number;
  49869. private _keys;
  49870. private _ctrlPressed;
  49871. private _altPressed;
  49872. private _onCanvasBlurObserver;
  49873. private _onKeyboardObserver;
  49874. private _engine;
  49875. private _scene;
  49876. /**
  49877. * Attach the input controls to a specific dom element to get the input from.
  49878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49879. */
  49880. attachControl(noPreventDefault?: boolean): void;
  49881. /**
  49882. * Detach the current controls from the specified dom element.
  49883. */
  49884. detachControl(): void;
  49885. /**
  49886. * Update the current camera state depending on the inputs that have been used this frame.
  49887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49888. */
  49889. checkInputs(): void;
  49890. /**
  49891. * Gets the class name of the current input.
  49892. * @returns the class name
  49893. */
  49894. getClassName(): string;
  49895. /**
  49896. * Get the friendly name associated with the input class.
  49897. * @returns the input friendly name
  49898. */
  49899. getSimpleName(): string;
  49900. }
  49901. }
  49902. declare module BABYLON {
  49903. /**
  49904. * Manage the mouse wheel inputs to control an arc rotate camera.
  49905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49906. */
  49907. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49908. /**
  49909. * Defines the camera the input is attached to.
  49910. */
  49911. camera: ArcRotateCamera;
  49912. /**
  49913. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49914. */
  49915. wheelPrecision: number;
  49916. /**
  49917. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49918. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49919. */
  49920. wheelDeltaPercentage: number;
  49921. private _wheel;
  49922. private _observer;
  49923. private computeDeltaFromMouseWheelLegacyEvent;
  49924. /**
  49925. * Attach the input controls to a specific dom element to get the input from.
  49926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49927. */
  49928. attachControl(noPreventDefault?: boolean): void;
  49929. /**
  49930. * Detach the current controls from the specified dom element.
  49931. */
  49932. detachControl(): void;
  49933. /**
  49934. * Gets the class name of the current input.
  49935. * @returns the class name
  49936. */
  49937. getClassName(): string;
  49938. /**
  49939. * Get the friendly name associated with the input class.
  49940. * @returns the input friendly name
  49941. */
  49942. getSimpleName(): string;
  49943. }
  49944. }
  49945. declare module BABYLON {
  49946. /**
  49947. * Default Inputs manager for the ArcRotateCamera.
  49948. * It groups all the default supported inputs for ease of use.
  49949. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49950. */
  49951. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49952. /**
  49953. * Instantiates a new ArcRotateCameraInputsManager.
  49954. * @param camera Defines the camera the inputs belong to
  49955. */
  49956. constructor(camera: ArcRotateCamera);
  49957. /**
  49958. * Add mouse wheel input support to the input manager.
  49959. * @returns the current input manager
  49960. */
  49961. addMouseWheel(): ArcRotateCameraInputsManager;
  49962. /**
  49963. * Add pointers input support to the input manager.
  49964. * @returns the current input manager
  49965. */
  49966. addPointers(): ArcRotateCameraInputsManager;
  49967. /**
  49968. * Add keyboard input support to the input manager.
  49969. * @returns the current input manager
  49970. */
  49971. addKeyboard(): ArcRotateCameraInputsManager;
  49972. }
  49973. }
  49974. declare module BABYLON {
  49975. /**
  49976. * This represents an orbital type of camera.
  49977. *
  49978. * 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.
  49979. * 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.
  49980. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49981. */
  49982. export class ArcRotateCamera extends TargetCamera {
  49983. /**
  49984. * Defines the rotation angle of the camera along the longitudinal axis.
  49985. */
  49986. alpha: number;
  49987. /**
  49988. * Defines the rotation angle of the camera along the latitudinal axis.
  49989. */
  49990. beta: number;
  49991. /**
  49992. * Defines the radius of the camera from it s target point.
  49993. */
  49994. radius: number;
  49995. protected _target: Vector3;
  49996. protected _targetHost: Nullable<AbstractMesh>;
  49997. /**
  49998. * Defines the target point of the camera.
  49999. * The camera looks towards it form the radius distance.
  50000. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  50001. */
  50002. get target(): Vector3;
  50003. set target(value: Vector3);
  50004. /**
  50005. * Define the current local position of the camera in the scene
  50006. */
  50007. get position(): Vector3;
  50008. set position(newPosition: Vector3);
  50009. protected _upToYMatrix: Matrix;
  50010. protected _YToUpMatrix: Matrix;
  50011. /**
  50012. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  50013. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  50014. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  50015. */
  50016. set upVector(vec: Vector3);
  50017. get upVector(): Vector3;
  50018. /**
  50019. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50020. */
  50021. setMatUp(): void;
  50022. /**
  50023. * Current inertia value on the longitudinal axis.
  50024. * The bigger this number the longer it will take for the camera to stop.
  50025. */
  50026. inertialAlphaOffset: number;
  50027. /**
  50028. * Current inertia value on the latitudinal axis.
  50029. * The bigger this number the longer it will take for the camera to stop.
  50030. */
  50031. inertialBetaOffset: number;
  50032. /**
  50033. * Current inertia value on the radius axis.
  50034. * The bigger this number the longer it will take for the camera to stop.
  50035. */
  50036. inertialRadiusOffset: number;
  50037. /**
  50038. * Minimum allowed angle on the longitudinal axis.
  50039. * This can help limiting how the Camera is able to move in the scene.
  50040. */
  50041. lowerAlphaLimit: Nullable<number>;
  50042. /**
  50043. * Maximum allowed angle on the longitudinal axis.
  50044. * This can help limiting how the Camera is able to move in the scene.
  50045. */
  50046. upperAlphaLimit: Nullable<number>;
  50047. /**
  50048. * Minimum allowed angle on the latitudinal axis.
  50049. * This can help limiting how the Camera is able to move in the scene.
  50050. */
  50051. lowerBetaLimit: number;
  50052. /**
  50053. * Maximum allowed angle on the latitudinal axis.
  50054. * This can help limiting how the Camera is able to move in the scene.
  50055. */
  50056. upperBetaLimit: number;
  50057. /**
  50058. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50059. * This can help limiting how the Camera is able to move in the scene.
  50060. */
  50061. lowerRadiusLimit: Nullable<number>;
  50062. /**
  50063. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50064. * This can help limiting how the Camera is able to move in the scene.
  50065. */
  50066. upperRadiusLimit: Nullable<number>;
  50067. /**
  50068. * Defines the current inertia value used during panning of the camera along the X axis.
  50069. */
  50070. inertialPanningX: number;
  50071. /**
  50072. * Defines the current inertia value used during panning of the camera along the Y axis.
  50073. */
  50074. inertialPanningY: number;
  50075. /**
  50076. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50077. * Basically if your fingers moves away from more than this distance you will be considered
  50078. * in pinch mode.
  50079. */
  50080. pinchToPanMaxDistance: number;
  50081. /**
  50082. * Defines the maximum distance the camera can pan.
  50083. * This could help keeping the camera always in your scene.
  50084. */
  50085. panningDistanceLimit: Nullable<number>;
  50086. /**
  50087. * Defines the target of the camera before panning.
  50088. */
  50089. panningOriginTarget: Vector3;
  50090. /**
  50091. * Defines the value of the inertia used during panning.
  50092. * 0 would mean stop inertia and one would mean no decelleration at all.
  50093. */
  50094. panningInertia: number;
  50095. /**
  50096. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50097. */
  50098. get angularSensibilityX(): number;
  50099. set angularSensibilityX(value: number);
  50100. /**
  50101. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50102. */
  50103. get angularSensibilityY(): number;
  50104. set angularSensibilityY(value: number);
  50105. /**
  50106. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50107. */
  50108. get pinchPrecision(): number;
  50109. set pinchPrecision(value: number);
  50110. /**
  50111. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50112. * It will be used instead of pinchDeltaPrecision if different from 0.
  50113. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50114. */
  50115. get pinchDeltaPercentage(): number;
  50116. set pinchDeltaPercentage(value: number);
  50117. /**
  50118. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50119. * and pinch delta percentage.
  50120. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50121. * that any object in the plane at the camera's target point will scale
  50122. * perfectly with finger motion.
  50123. */
  50124. get useNaturalPinchZoom(): boolean;
  50125. set useNaturalPinchZoom(value: boolean);
  50126. /**
  50127. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50128. */
  50129. get panningSensibility(): number;
  50130. set panningSensibility(value: number);
  50131. /**
  50132. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50133. */
  50134. get keysUp(): number[];
  50135. set keysUp(value: number[]);
  50136. /**
  50137. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50138. */
  50139. get keysDown(): number[];
  50140. set keysDown(value: number[]);
  50141. /**
  50142. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50143. */
  50144. get keysLeft(): number[];
  50145. set keysLeft(value: number[]);
  50146. /**
  50147. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50148. */
  50149. get keysRight(): number[];
  50150. set keysRight(value: number[]);
  50151. /**
  50152. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50153. */
  50154. get wheelPrecision(): number;
  50155. set wheelPrecision(value: number);
  50156. /**
  50157. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50158. * It will be used instead of pinchDeltaPrecision if different from 0.
  50159. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50160. */
  50161. get wheelDeltaPercentage(): number;
  50162. set wheelDeltaPercentage(value: number);
  50163. /**
  50164. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50165. */
  50166. zoomOnFactor: number;
  50167. /**
  50168. * Defines a screen offset for the camera position.
  50169. */
  50170. targetScreenOffset: Vector2;
  50171. /**
  50172. * Allows the camera to be completely reversed.
  50173. * If false the camera can not arrive upside down.
  50174. */
  50175. allowUpsideDown: boolean;
  50176. /**
  50177. * Define if double tap/click is used to restore the previously saved state of the camera.
  50178. */
  50179. useInputToRestoreState: boolean;
  50180. /** @hidden */
  50181. _viewMatrix: Matrix;
  50182. /** @hidden */
  50183. _useCtrlForPanning: boolean;
  50184. /** @hidden */
  50185. _panningMouseButton: number;
  50186. /**
  50187. * Defines the input associated to the camera.
  50188. */
  50189. inputs: ArcRotateCameraInputsManager;
  50190. /** @hidden */
  50191. _reset: () => void;
  50192. /**
  50193. * Defines the allowed panning axis.
  50194. */
  50195. panningAxis: Vector3;
  50196. protected _transformedDirection: Vector3;
  50197. private _bouncingBehavior;
  50198. /**
  50199. * Gets the bouncing behavior of the camera if it has been enabled.
  50200. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50201. */
  50202. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50203. /**
  50204. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50205. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50206. */
  50207. get useBouncingBehavior(): boolean;
  50208. set useBouncingBehavior(value: boolean);
  50209. private _framingBehavior;
  50210. /**
  50211. * Gets the framing behavior of the camera if it has been enabled.
  50212. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50213. */
  50214. get framingBehavior(): Nullable<FramingBehavior>;
  50215. /**
  50216. * Defines if the framing behavior of the camera is enabled on the camera.
  50217. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50218. */
  50219. get useFramingBehavior(): boolean;
  50220. set useFramingBehavior(value: boolean);
  50221. private _autoRotationBehavior;
  50222. /**
  50223. * Gets the auto rotation behavior of the camera if it has been enabled.
  50224. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50225. */
  50226. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50227. /**
  50228. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50229. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50230. */
  50231. get useAutoRotationBehavior(): boolean;
  50232. set useAutoRotationBehavior(value: boolean);
  50233. /**
  50234. * Observable triggered when the mesh target has been changed on the camera.
  50235. */
  50236. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50237. /**
  50238. * Event raised when the camera is colliding with a mesh.
  50239. */
  50240. onCollide: (collidedMesh: AbstractMesh) => void;
  50241. /**
  50242. * Defines whether the camera should check collision with the objects oh the scene.
  50243. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50244. */
  50245. checkCollisions: boolean;
  50246. /**
  50247. * Defines the collision radius of the camera.
  50248. * This simulates a sphere around the camera.
  50249. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50250. */
  50251. collisionRadius: Vector3;
  50252. protected _collider: Collider;
  50253. protected _previousPosition: Vector3;
  50254. protected _collisionVelocity: Vector3;
  50255. protected _newPosition: Vector3;
  50256. protected _previousAlpha: number;
  50257. protected _previousBeta: number;
  50258. protected _previousRadius: number;
  50259. protected _collisionTriggered: boolean;
  50260. protected _targetBoundingCenter: Nullable<Vector3>;
  50261. private _computationVector;
  50262. /**
  50263. * Instantiates a new ArcRotateCamera in a given scene
  50264. * @param name Defines the name of the camera
  50265. * @param alpha Defines the camera rotation along the longitudinal axis
  50266. * @param beta Defines the camera rotation along the latitudinal axis
  50267. * @param radius Defines the camera distance from its target
  50268. * @param target Defines the camera target
  50269. * @param scene Defines the scene the camera belongs to
  50270. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50271. */
  50272. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50273. /** @hidden */
  50274. _initCache(): void;
  50275. /** @hidden */
  50276. _updateCache(ignoreParentClass?: boolean): void;
  50277. protected _getTargetPosition(): Vector3;
  50278. private _storedAlpha;
  50279. private _storedBeta;
  50280. private _storedRadius;
  50281. private _storedTarget;
  50282. private _storedTargetScreenOffset;
  50283. /**
  50284. * Stores the current state of the camera (alpha, beta, radius and target)
  50285. * @returns the camera itself
  50286. */
  50287. storeState(): Camera;
  50288. /**
  50289. * @hidden
  50290. * Restored camera state. You must call storeState() first
  50291. */
  50292. _restoreStateValues(): boolean;
  50293. /** @hidden */
  50294. _isSynchronizedViewMatrix(): boolean;
  50295. /**
  50296. * Attach the input controls to a specific dom element to get the input from.
  50297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50298. */
  50299. attachControl(noPreventDefault?: boolean): void;
  50300. /**
  50301. * Attach the input controls to a specific dom element to get the input from.
  50302. * @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
  50303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50304. */
  50305. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50306. /**
  50307. * Attached controls to the current camera.
  50308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50309. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50310. */
  50311. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50312. /**
  50313. * Attached controls to the current camera.
  50314. * @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
  50315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50316. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50317. */
  50318. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50319. /**
  50320. * Attached controls to the current camera.
  50321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50322. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50323. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50324. */
  50325. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50326. /**
  50327. * Detach the current controls from the specified dom element.
  50328. */
  50329. detachControl(): void;
  50330. /**
  50331. * Detach the current controls from the specified dom element.
  50332. * @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
  50333. */
  50334. detachControl(ignored: any): void;
  50335. /** @hidden */
  50336. _checkInputs(): void;
  50337. protected _checkLimits(): void;
  50338. /**
  50339. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50340. */
  50341. rebuildAnglesAndRadius(): void;
  50342. /**
  50343. * Use a position to define the current camera related information like alpha, beta and radius
  50344. * @param position Defines the position to set the camera at
  50345. */
  50346. setPosition(position: Vector3): void;
  50347. /**
  50348. * Defines the target the camera should look at.
  50349. * This will automatically adapt alpha beta and radius to fit within the new target.
  50350. * @param target Defines the new target as a Vector or a mesh
  50351. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50352. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50353. */
  50354. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50355. /** @hidden */
  50356. _getViewMatrix(): Matrix;
  50357. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50358. /**
  50359. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50360. * @param meshes Defines the mesh to zoom on
  50361. * @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)
  50362. */
  50363. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50364. /**
  50365. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50366. * The target will be changed but the radius
  50367. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50368. * @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)
  50369. */
  50370. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50371. min: Vector3;
  50372. max: Vector3;
  50373. distance: number;
  50374. }, doNotUpdateMaxZ?: boolean): void;
  50375. /**
  50376. * @override
  50377. * Override Camera.createRigCamera
  50378. */
  50379. createRigCamera(name: string, cameraIndex: number): Camera;
  50380. /**
  50381. * @hidden
  50382. * @override
  50383. * Override Camera._updateRigCameras
  50384. */
  50385. _updateRigCameras(): void;
  50386. /**
  50387. * Destroy the camera and release the current resources hold by it.
  50388. */
  50389. dispose(): void;
  50390. /**
  50391. * Gets the current object class name.
  50392. * @return the class name
  50393. */
  50394. getClassName(): string;
  50395. }
  50396. }
  50397. declare module BABYLON {
  50398. /**
  50399. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50400. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50401. */
  50402. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50403. /**
  50404. * Gets the name of the behavior.
  50405. */
  50406. get name(): string;
  50407. private _zoomStopsAnimation;
  50408. private _idleRotationSpeed;
  50409. private _idleRotationWaitTime;
  50410. private _idleRotationSpinupTime;
  50411. /**
  50412. * Sets the flag that indicates if user zooming should stop animation.
  50413. */
  50414. set zoomStopsAnimation(flag: boolean);
  50415. /**
  50416. * Gets the flag that indicates if user zooming should stop animation.
  50417. */
  50418. get zoomStopsAnimation(): boolean;
  50419. /**
  50420. * Sets the default speed at which the camera rotates around the model.
  50421. */
  50422. set idleRotationSpeed(speed: number);
  50423. /**
  50424. * Gets the default speed at which the camera rotates around the model.
  50425. */
  50426. get idleRotationSpeed(): number;
  50427. /**
  50428. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50429. */
  50430. set idleRotationWaitTime(time: number);
  50431. /**
  50432. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50433. */
  50434. get idleRotationWaitTime(): number;
  50435. /**
  50436. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50437. */
  50438. set idleRotationSpinupTime(time: number);
  50439. /**
  50440. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50441. */
  50442. get idleRotationSpinupTime(): number;
  50443. /**
  50444. * Gets a value indicating if the camera is currently rotating because of this behavior
  50445. */
  50446. get rotationInProgress(): boolean;
  50447. private _onPrePointerObservableObserver;
  50448. private _onAfterCheckInputsObserver;
  50449. private _attachedCamera;
  50450. private _isPointerDown;
  50451. private _lastFrameTime;
  50452. private _lastInteractionTime;
  50453. private _cameraRotationSpeed;
  50454. /**
  50455. * Initializes the behavior.
  50456. */
  50457. init(): void;
  50458. /**
  50459. * Attaches the behavior to its arc rotate camera.
  50460. * @param camera Defines the camera to attach the behavior to
  50461. */
  50462. attach(camera: ArcRotateCamera): void;
  50463. /**
  50464. * Detaches the behavior from its current arc rotate camera.
  50465. */
  50466. detach(): void;
  50467. /**
  50468. * Returns true if user is scrolling.
  50469. * @return true if user is scrolling.
  50470. */
  50471. private _userIsZooming;
  50472. private _lastFrameRadius;
  50473. private _shouldAnimationStopForInteraction;
  50474. /**
  50475. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50476. */
  50477. private _applyUserInteraction;
  50478. private _userIsMoving;
  50479. }
  50480. }
  50481. declare module BABYLON {
  50482. /**
  50483. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50484. */
  50485. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50486. private ui;
  50487. /**
  50488. * The name of the behavior
  50489. */
  50490. name: string;
  50491. /**
  50492. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50493. */
  50494. distanceAwayFromFace: number;
  50495. /**
  50496. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50497. */
  50498. distanceAwayFromBottomOfFace: number;
  50499. private _faceVectors;
  50500. private _target;
  50501. private _scene;
  50502. private _onRenderObserver;
  50503. private _tmpMatrix;
  50504. private _tmpVector;
  50505. /**
  50506. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50507. * @param ui The transform node that should be attached to the mesh
  50508. */
  50509. constructor(ui: TransformNode);
  50510. /**
  50511. * Initializes the behavior
  50512. */
  50513. init(): void;
  50514. private _closestFace;
  50515. private _zeroVector;
  50516. private _lookAtTmpMatrix;
  50517. private _lookAtToRef;
  50518. /**
  50519. * Attaches the AttachToBoxBehavior to the passed in mesh
  50520. * @param target The mesh that the specified node will be attached to
  50521. */
  50522. attach(target: Mesh): void;
  50523. /**
  50524. * Detaches the behavior from the mesh
  50525. */
  50526. detach(): void;
  50527. }
  50528. }
  50529. declare module BABYLON {
  50530. /**
  50531. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50532. */
  50533. export class FadeInOutBehavior implements Behavior<Mesh> {
  50534. /**
  50535. * Time in milliseconds to delay before fading in (Default: 0)
  50536. */
  50537. delay: number;
  50538. /**
  50539. * Time in milliseconds for the mesh to fade in (Default: 300)
  50540. */
  50541. fadeInTime: number;
  50542. private _millisecondsPerFrame;
  50543. private _hovered;
  50544. private _hoverValue;
  50545. private _ownerNode;
  50546. /**
  50547. * Instantiates the FadeInOutBehavior
  50548. */
  50549. constructor();
  50550. /**
  50551. * The name of the behavior
  50552. */
  50553. get name(): string;
  50554. /**
  50555. * Initializes the behavior
  50556. */
  50557. init(): void;
  50558. /**
  50559. * Attaches the fade behavior on the passed in mesh
  50560. * @param ownerNode The mesh that will be faded in/out once attached
  50561. */
  50562. attach(ownerNode: Mesh): void;
  50563. /**
  50564. * Detaches the behavior from the mesh
  50565. */
  50566. detach(): void;
  50567. /**
  50568. * Triggers the mesh to begin fading in or out
  50569. * @param value if the object should fade in or out (true to fade in)
  50570. */
  50571. fadeIn(value: boolean): void;
  50572. private _update;
  50573. private _setAllVisibility;
  50574. }
  50575. }
  50576. declare module BABYLON {
  50577. /**
  50578. * Class containing a set of static utilities functions for managing Pivots
  50579. * @hidden
  50580. */
  50581. export class PivotTools {
  50582. private static _PivotCached;
  50583. private static _OldPivotPoint;
  50584. private static _PivotTranslation;
  50585. private static _PivotTmpVector;
  50586. private static _PivotPostMultiplyPivotMatrix;
  50587. /** @hidden */
  50588. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50589. /** @hidden */
  50590. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50591. }
  50592. }
  50593. declare module BABYLON {
  50594. /**
  50595. * Class containing static functions to help procedurally build meshes
  50596. */
  50597. export class PlaneBuilder {
  50598. /**
  50599. * Creates a plane mesh
  50600. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50601. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50602. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50604. * * 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
  50605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50606. * @param name defines the name of the mesh
  50607. * @param options defines the options used to create the mesh
  50608. * @param scene defines the hosting scene
  50609. * @returns the plane mesh
  50610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50611. */
  50612. static CreatePlane(name: string, options: {
  50613. size?: number;
  50614. width?: number;
  50615. height?: number;
  50616. sideOrientation?: number;
  50617. frontUVs?: Vector4;
  50618. backUVs?: Vector4;
  50619. updatable?: boolean;
  50620. sourcePlane?: Plane;
  50621. }, scene?: Nullable<Scene>): Mesh;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. /**
  50626. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50627. */
  50628. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50629. private static _AnyMouseID;
  50630. /**
  50631. * Abstract mesh the behavior is set on
  50632. */
  50633. attachedNode: AbstractMesh;
  50634. private _dragPlane;
  50635. private _scene;
  50636. private _pointerObserver;
  50637. private _beforeRenderObserver;
  50638. private static _planeScene;
  50639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50640. /**
  50641. * 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)
  50642. */
  50643. maxDragAngle: number;
  50644. /**
  50645. * @hidden
  50646. */
  50647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50648. /**
  50649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50650. */
  50651. currentDraggingPointerID: number;
  50652. /**
  50653. * The last position where the pointer hit the drag plane in world space
  50654. */
  50655. lastDragPosition: Vector3;
  50656. /**
  50657. * If the behavior is currently in a dragging state
  50658. */
  50659. dragging: boolean;
  50660. /**
  50661. * 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)
  50662. */
  50663. dragDeltaRatio: number;
  50664. /**
  50665. * If the drag plane orientation should be updated during the dragging (Default: true)
  50666. */
  50667. updateDragPlane: boolean;
  50668. private _debugMode;
  50669. private _moving;
  50670. /**
  50671. * Fires each time the attached mesh is dragged with the pointer
  50672. * * delta between last drag position and current drag position in world space
  50673. * * dragDistance along the drag axis
  50674. * * dragPlaneNormal normal of the current drag plane used during the drag
  50675. * * dragPlanePoint in world space where the drag intersects the drag plane
  50676. */
  50677. onDragObservable: Observable<{
  50678. delta: Vector3;
  50679. dragPlanePoint: Vector3;
  50680. dragPlaneNormal: Vector3;
  50681. dragDistance: number;
  50682. pointerId: number;
  50683. }>;
  50684. /**
  50685. * Fires each time a drag begins (eg. mouse down on mesh)
  50686. */
  50687. onDragStartObservable: Observable<{
  50688. dragPlanePoint: Vector3;
  50689. pointerId: number;
  50690. }>;
  50691. /**
  50692. * Fires each time a drag ends (eg. mouse release after drag)
  50693. */
  50694. onDragEndObservable: Observable<{
  50695. dragPlanePoint: Vector3;
  50696. pointerId: number;
  50697. }>;
  50698. /**
  50699. * If the attached mesh should be moved when dragged
  50700. */
  50701. moveAttached: boolean;
  50702. /**
  50703. * If the drag behavior will react to drag events (Default: true)
  50704. */
  50705. enabled: boolean;
  50706. /**
  50707. * If pointer events should start and release the drag (Default: true)
  50708. */
  50709. startAndReleaseDragOnPointerEvents: boolean;
  50710. /**
  50711. * If camera controls should be detached during the drag
  50712. */
  50713. detachCameraControls: boolean;
  50714. /**
  50715. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50716. */
  50717. useObjectOrientationForDragging: boolean;
  50718. private _options;
  50719. /**
  50720. * Gets the options used by the behavior
  50721. */
  50722. get options(): {
  50723. dragAxis?: Vector3;
  50724. dragPlaneNormal?: Vector3;
  50725. };
  50726. /**
  50727. * Sets the options used by the behavior
  50728. */
  50729. set options(options: {
  50730. dragAxis?: Vector3;
  50731. dragPlaneNormal?: Vector3;
  50732. });
  50733. /**
  50734. * Creates a pointer drag behavior that can be attached to a mesh
  50735. * @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)
  50736. */
  50737. constructor(options?: {
  50738. dragAxis?: Vector3;
  50739. dragPlaneNormal?: Vector3;
  50740. });
  50741. /**
  50742. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50743. */
  50744. validateDrag: (targetPosition: Vector3) => boolean;
  50745. /**
  50746. * The name of the behavior
  50747. */
  50748. get name(): string;
  50749. /**
  50750. * Initializes the behavior
  50751. */
  50752. init(): void;
  50753. private _tmpVector;
  50754. private _alternatePickedPoint;
  50755. private _worldDragAxis;
  50756. private _targetPosition;
  50757. private _attachedToElement;
  50758. /**
  50759. * Attaches the drag behavior the passed in mesh
  50760. * @param ownerNode The mesh that will be dragged around once attached
  50761. * @param predicate Predicate to use for pick filtering
  50762. */
  50763. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50764. /**
  50765. * Force release the drag action by code.
  50766. */
  50767. releaseDrag(): void;
  50768. private _startDragRay;
  50769. private _lastPointerRay;
  50770. /**
  50771. * Simulates the start of a pointer drag event on the behavior
  50772. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50773. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50774. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50775. */
  50776. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50777. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50778. private _dragDelta;
  50779. protected _moveDrag(ray: Ray): void;
  50780. private _pickWithRayOnDragPlane;
  50781. private _pointA;
  50782. private _pointC;
  50783. private _localAxis;
  50784. private _lookAt;
  50785. private _updateDragPlanePosition;
  50786. /**
  50787. * Detaches the behavior from the mesh
  50788. */
  50789. detach(): void;
  50790. }
  50791. }
  50792. declare module BABYLON {
  50793. /**
  50794. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50795. */
  50796. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50797. private _dragBehaviorA;
  50798. private _dragBehaviorB;
  50799. private _startDistance;
  50800. private _initialScale;
  50801. private _targetScale;
  50802. private _ownerNode;
  50803. private _sceneRenderObserver;
  50804. /**
  50805. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50806. */
  50807. constructor();
  50808. /**
  50809. * The name of the behavior
  50810. */
  50811. get name(): string;
  50812. /**
  50813. * Initializes the behavior
  50814. */
  50815. init(): void;
  50816. private _getCurrentDistance;
  50817. /**
  50818. * Attaches the scale behavior the passed in mesh
  50819. * @param ownerNode The mesh that will be scaled around once attached
  50820. */
  50821. attach(ownerNode: Mesh): void;
  50822. /**
  50823. * Detaches the behavior from the mesh
  50824. */
  50825. detach(): void;
  50826. }
  50827. }
  50828. declare module BABYLON {
  50829. /**
  50830. * 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
  50831. */
  50832. export class SixDofDragBehavior implements Behavior<Mesh> {
  50833. private static _virtualScene;
  50834. private _ownerNode;
  50835. private _sceneRenderObserver;
  50836. private _scene;
  50837. private _targetPosition;
  50838. private _virtualOriginMesh;
  50839. private _virtualDragMesh;
  50840. private _pointerObserver;
  50841. private _moving;
  50842. private _startingOrientation;
  50843. private _attachedToElement;
  50844. /**
  50845. * 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)
  50846. */
  50847. private zDragFactor;
  50848. /**
  50849. * If the object should rotate to face the drag origin
  50850. */
  50851. rotateDraggedObject: boolean;
  50852. /**
  50853. * If the behavior is currently in a dragging state
  50854. */
  50855. dragging: boolean;
  50856. /**
  50857. * 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)
  50858. */
  50859. dragDeltaRatio: number;
  50860. /**
  50861. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50862. */
  50863. currentDraggingPointerID: number;
  50864. /**
  50865. * If camera controls should be detached during the drag
  50866. */
  50867. detachCameraControls: boolean;
  50868. /**
  50869. * Fires each time a drag starts
  50870. */
  50871. onDragStartObservable: Observable<{}>;
  50872. /**
  50873. * Fires each time a drag happens
  50874. */
  50875. onDragObservable: Observable<void>;
  50876. /**
  50877. * Fires each time a drag ends (eg. mouse release after drag)
  50878. */
  50879. onDragEndObservable: Observable<{}>;
  50880. /**
  50881. * 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
  50882. */
  50883. constructor();
  50884. /**
  50885. * The name of the behavior
  50886. */
  50887. get name(): string;
  50888. /**
  50889. * Initializes the behavior
  50890. */
  50891. init(): void;
  50892. /**
  50893. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50894. */
  50895. private get _pointerCamera();
  50896. /**
  50897. * Attaches the scale behavior the passed in mesh
  50898. * @param ownerNode The mesh that will be scaled around once attached
  50899. */
  50900. attach(ownerNode: Mesh): void;
  50901. /**
  50902. * Detaches the behavior from the mesh
  50903. */
  50904. detach(): void;
  50905. }
  50906. }
  50907. declare module BABYLON {
  50908. /**
  50909. * Class used to apply inverse kinematics to bones
  50910. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50911. */
  50912. export class BoneIKController {
  50913. private static _tmpVecs;
  50914. private static _tmpQuat;
  50915. private static _tmpMats;
  50916. /**
  50917. * Gets or sets the target mesh
  50918. */
  50919. targetMesh: AbstractMesh;
  50920. /** Gets or sets the mesh used as pole */
  50921. poleTargetMesh: AbstractMesh;
  50922. /**
  50923. * Gets or sets the bone used as pole
  50924. */
  50925. poleTargetBone: Nullable<Bone>;
  50926. /**
  50927. * Gets or sets the target position
  50928. */
  50929. targetPosition: Vector3;
  50930. /**
  50931. * Gets or sets the pole target position
  50932. */
  50933. poleTargetPosition: Vector3;
  50934. /**
  50935. * Gets or sets the pole target local offset
  50936. */
  50937. poleTargetLocalOffset: Vector3;
  50938. /**
  50939. * Gets or sets the pole angle
  50940. */
  50941. poleAngle: number;
  50942. /**
  50943. * Gets or sets the mesh associated with the controller
  50944. */
  50945. mesh: AbstractMesh;
  50946. /**
  50947. * 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)
  50948. */
  50949. slerpAmount: number;
  50950. private _bone1Quat;
  50951. private _bone1Mat;
  50952. private _bone2Ang;
  50953. private _bone1;
  50954. private _bone2;
  50955. private _bone1Length;
  50956. private _bone2Length;
  50957. private _maxAngle;
  50958. private _maxReach;
  50959. private _rightHandedSystem;
  50960. private _bendAxis;
  50961. private _slerping;
  50962. private _adjustRoll;
  50963. /**
  50964. * Gets or sets maximum allowed angle
  50965. */
  50966. get maxAngle(): number;
  50967. set maxAngle(value: number);
  50968. /**
  50969. * Creates a new BoneIKController
  50970. * @param mesh defines the mesh to control
  50971. * @param bone defines the bone to control
  50972. * @param options defines options to set up the controller
  50973. */
  50974. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50975. targetMesh?: AbstractMesh;
  50976. poleTargetMesh?: AbstractMesh;
  50977. poleTargetBone?: Bone;
  50978. poleTargetLocalOffset?: Vector3;
  50979. poleAngle?: number;
  50980. bendAxis?: Vector3;
  50981. maxAngle?: number;
  50982. slerpAmount?: number;
  50983. });
  50984. private _setMaxAngle;
  50985. /**
  50986. * Force the controller to update the bones
  50987. */
  50988. update(): void;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * Class used to make a bone look toward a point in space
  50994. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50995. */
  50996. export class BoneLookController {
  50997. private static _tmpVecs;
  50998. private static _tmpQuat;
  50999. private static _tmpMats;
  51000. /**
  51001. * The target Vector3 that the bone will look at
  51002. */
  51003. target: Vector3;
  51004. /**
  51005. * The mesh that the bone is attached to
  51006. */
  51007. mesh: AbstractMesh;
  51008. /**
  51009. * The bone that will be looking to the target
  51010. */
  51011. bone: Bone;
  51012. /**
  51013. * The up axis of the coordinate system that is used when the bone is rotated
  51014. */
  51015. upAxis: Vector3;
  51016. /**
  51017. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  51018. */
  51019. upAxisSpace: Space;
  51020. /**
  51021. * Used to make an adjustment to the yaw of the bone
  51022. */
  51023. adjustYaw: number;
  51024. /**
  51025. * Used to make an adjustment to the pitch of the bone
  51026. */
  51027. adjustPitch: number;
  51028. /**
  51029. * Used to make an adjustment to the roll of the bone
  51030. */
  51031. adjustRoll: number;
  51032. /**
  51033. * 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)
  51034. */
  51035. slerpAmount: number;
  51036. private _minYaw;
  51037. private _maxYaw;
  51038. private _minPitch;
  51039. private _maxPitch;
  51040. private _minYawSin;
  51041. private _minYawCos;
  51042. private _maxYawSin;
  51043. private _maxYawCos;
  51044. private _midYawConstraint;
  51045. private _minPitchTan;
  51046. private _maxPitchTan;
  51047. private _boneQuat;
  51048. private _slerping;
  51049. private _transformYawPitch;
  51050. private _transformYawPitchInv;
  51051. private _firstFrameSkipped;
  51052. private _yawRange;
  51053. private _fowardAxis;
  51054. /**
  51055. * Gets or sets the minimum yaw angle that the bone can look to
  51056. */
  51057. get minYaw(): number;
  51058. set minYaw(value: number);
  51059. /**
  51060. * Gets or sets the maximum yaw angle that the bone can look to
  51061. */
  51062. get maxYaw(): number;
  51063. set maxYaw(value: number);
  51064. /**
  51065. * Gets or sets the minimum pitch angle that the bone can look to
  51066. */
  51067. get minPitch(): number;
  51068. set minPitch(value: number);
  51069. /**
  51070. * Gets or sets the maximum pitch angle that the bone can look to
  51071. */
  51072. get maxPitch(): number;
  51073. set maxPitch(value: number);
  51074. /**
  51075. * Create a BoneLookController
  51076. * @param mesh the mesh that the bone belongs to
  51077. * @param bone the bone that will be looking to the target
  51078. * @param target the target Vector3 to look at
  51079. * @param options optional settings:
  51080. * * maxYaw: the maximum angle the bone will yaw to
  51081. * * minYaw: the minimum angle the bone will yaw to
  51082. * * maxPitch: the maximum angle the bone will pitch to
  51083. * * minPitch: the minimum angle the bone will yaw to
  51084. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51085. * * upAxis: the up axis of the coordinate system
  51086. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51087. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51088. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51089. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51090. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51091. * * adjustRoll: used to make an adjustment to the roll of the bone
  51092. **/
  51093. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51094. maxYaw?: number;
  51095. minYaw?: number;
  51096. maxPitch?: number;
  51097. minPitch?: number;
  51098. slerpAmount?: number;
  51099. upAxis?: Vector3;
  51100. upAxisSpace?: Space;
  51101. yawAxis?: Vector3;
  51102. pitchAxis?: Vector3;
  51103. adjustYaw?: number;
  51104. adjustPitch?: number;
  51105. adjustRoll?: number;
  51106. });
  51107. /**
  51108. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51109. */
  51110. update(): void;
  51111. private _getAngleDiff;
  51112. private _getAngleBetween;
  51113. private _isAngleBetween;
  51114. }
  51115. }
  51116. declare module BABYLON {
  51117. /**
  51118. * Manage the gamepad inputs to control an arc rotate camera.
  51119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51120. */
  51121. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51122. /**
  51123. * Defines the camera the input is attached to.
  51124. */
  51125. camera: ArcRotateCamera;
  51126. /**
  51127. * Defines the gamepad the input is gathering event from.
  51128. */
  51129. gamepad: Nullable<Gamepad>;
  51130. /**
  51131. * Defines the gamepad rotation sensiblity.
  51132. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51133. */
  51134. gamepadRotationSensibility: number;
  51135. /**
  51136. * Defines the gamepad move sensiblity.
  51137. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51138. */
  51139. gamepadMoveSensibility: number;
  51140. private _yAxisScale;
  51141. /**
  51142. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51143. */
  51144. get invertYAxis(): boolean;
  51145. set invertYAxis(value: boolean);
  51146. private _onGamepadConnectedObserver;
  51147. private _onGamepadDisconnectedObserver;
  51148. /**
  51149. * Attach the input controls to a specific dom element to get the input from.
  51150. */
  51151. attachControl(): void;
  51152. /**
  51153. * Detach the current controls from the specified dom element.
  51154. */
  51155. detachControl(): void;
  51156. /**
  51157. * Update the current camera state depending on the inputs that have been used this frame.
  51158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51159. */
  51160. checkInputs(): void;
  51161. /**
  51162. * Gets the class name of the current intput.
  51163. * @returns the class name
  51164. */
  51165. getClassName(): string;
  51166. /**
  51167. * Get the friendly name associated with the input class.
  51168. * @returns the input friendly name
  51169. */
  51170. getSimpleName(): string;
  51171. }
  51172. }
  51173. declare module BABYLON {
  51174. interface ArcRotateCameraInputsManager {
  51175. /**
  51176. * Add orientation input support to the input manager.
  51177. * @returns the current input manager
  51178. */
  51179. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51180. }
  51181. /**
  51182. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51184. */
  51185. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51186. /**
  51187. * Defines the camera the input is attached to.
  51188. */
  51189. camera: ArcRotateCamera;
  51190. /**
  51191. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51192. */
  51193. alphaCorrection: number;
  51194. /**
  51195. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51196. */
  51197. gammaCorrection: number;
  51198. private _alpha;
  51199. private _gamma;
  51200. private _dirty;
  51201. private _deviceOrientationHandler;
  51202. /**
  51203. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51204. */
  51205. constructor();
  51206. /**
  51207. * Attach the input controls to a specific dom element to get the input from.
  51208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51209. */
  51210. attachControl(noPreventDefault?: boolean): void;
  51211. /** @hidden */
  51212. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51213. /**
  51214. * Update the current camera state depending on the inputs that have been used this frame.
  51215. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51216. */
  51217. checkInputs(): void;
  51218. /**
  51219. * Detach the current controls from the specified dom element.
  51220. */
  51221. detachControl(): void;
  51222. /**
  51223. * Gets the class name of the current input.
  51224. * @returns the class name
  51225. */
  51226. getClassName(): string;
  51227. /**
  51228. * Get the friendly name associated with the input class.
  51229. * @returns the input friendly name
  51230. */
  51231. getSimpleName(): string;
  51232. }
  51233. }
  51234. declare module BABYLON {
  51235. /**
  51236. * Listen to mouse events to control the camera.
  51237. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51238. */
  51239. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51240. /**
  51241. * Defines the camera the input is attached to.
  51242. */
  51243. camera: FlyCamera;
  51244. /**
  51245. * Defines if touch is enabled. (Default is true.)
  51246. */
  51247. touchEnabled: boolean;
  51248. /**
  51249. * Defines the buttons associated with the input to handle camera rotation.
  51250. */
  51251. buttons: number[];
  51252. /**
  51253. * Assign buttons for Yaw control.
  51254. */
  51255. buttonsYaw: number[];
  51256. /**
  51257. * Assign buttons for Pitch control.
  51258. */
  51259. buttonsPitch: number[];
  51260. /**
  51261. * Assign buttons for Roll control.
  51262. */
  51263. buttonsRoll: number[];
  51264. /**
  51265. * Detect if any button is being pressed while mouse is moved.
  51266. * -1 = Mouse locked.
  51267. * 0 = Left button.
  51268. * 1 = Middle Button.
  51269. * 2 = Right Button.
  51270. */
  51271. activeButton: number;
  51272. /**
  51273. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51274. * Higher values reduce its sensitivity.
  51275. */
  51276. angularSensibility: number;
  51277. private _observer;
  51278. private _rollObserver;
  51279. private previousPosition;
  51280. private noPreventDefault;
  51281. private element;
  51282. /**
  51283. * Listen to mouse events to control the camera.
  51284. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51286. */
  51287. constructor(touchEnabled?: boolean);
  51288. /**
  51289. * Attach the mouse control to the HTML DOM element.
  51290. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51291. */
  51292. attachControl(noPreventDefault?: boolean): void;
  51293. /**
  51294. * Detach the current controls from the specified dom element.
  51295. */
  51296. detachControl(): void;
  51297. /**
  51298. * Gets the class name of the current input.
  51299. * @returns the class name.
  51300. */
  51301. getClassName(): string;
  51302. /**
  51303. * Get the friendly name associated with the input class.
  51304. * @returns the input's friendly name.
  51305. */
  51306. getSimpleName(): string;
  51307. private _pointerInput;
  51308. private _onMouseMove;
  51309. /**
  51310. * Rotate camera by mouse offset.
  51311. */
  51312. private rotateCamera;
  51313. }
  51314. }
  51315. declare module BABYLON {
  51316. /**
  51317. * Default Inputs manager for the FlyCamera.
  51318. * It groups all the default supported inputs for ease of use.
  51319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51320. */
  51321. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51322. /**
  51323. * Instantiates a new FlyCameraInputsManager.
  51324. * @param camera Defines the camera the inputs belong to.
  51325. */
  51326. constructor(camera: FlyCamera);
  51327. /**
  51328. * Add keyboard input support to the input manager.
  51329. * @returns the new FlyCameraKeyboardMoveInput().
  51330. */
  51331. addKeyboard(): FlyCameraInputsManager;
  51332. /**
  51333. * Add mouse input support to the input manager.
  51334. * @param touchEnabled Enable touch screen support.
  51335. * @returns the new FlyCameraMouseInput().
  51336. */
  51337. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51338. }
  51339. }
  51340. declare module BABYLON {
  51341. /**
  51342. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51343. * such as in a 3D Space Shooter or a Flight Simulator.
  51344. */
  51345. export class FlyCamera extends TargetCamera {
  51346. /**
  51347. * Define the collision ellipsoid of the camera.
  51348. * This is helpful for simulating a camera body, like a player's body.
  51349. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51350. */
  51351. ellipsoid: Vector3;
  51352. /**
  51353. * Define an offset for the position of the ellipsoid around the camera.
  51354. * This can be helpful if the camera is attached away from the player's body center,
  51355. * such as at its head.
  51356. */
  51357. ellipsoidOffset: Vector3;
  51358. /**
  51359. * Enable or disable collisions of the camera with the rest of the scene objects.
  51360. */
  51361. checkCollisions: boolean;
  51362. /**
  51363. * Enable or disable gravity on the camera.
  51364. */
  51365. applyGravity: boolean;
  51366. /**
  51367. * Define the current direction the camera is moving to.
  51368. */
  51369. cameraDirection: Vector3;
  51370. /**
  51371. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51372. * This overrides and empties cameraRotation.
  51373. */
  51374. rotationQuaternion: Quaternion;
  51375. /**
  51376. * Track Roll to maintain the wanted Rolling when looking around.
  51377. */
  51378. _trackRoll: number;
  51379. /**
  51380. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51381. */
  51382. rollCorrect: number;
  51383. /**
  51384. * Mimic a banked turn, Rolling the camera when Yawing.
  51385. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51386. */
  51387. bankedTurn: boolean;
  51388. /**
  51389. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51390. */
  51391. bankedTurnLimit: number;
  51392. /**
  51393. * Value of 0 disables the banked Roll.
  51394. * Value of 1 is equal to the Yaw angle in radians.
  51395. */
  51396. bankedTurnMultiplier: number;
  51397. /**
  51398. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51399. */
  51400. inputs: FlyCameraInputsManager;
  51401. /**
  51402. * Gets the input sensibility for mouse input.
  51403. * Higher values reduce sensitivity.
  51404. */
  51405. get angularSensibility(): number;
  51406. /**
  51407. * Sets the input sensibility for a mouse input.
  51408. * Higher values reduce sensitivity.
  51409. */
  51410. set angularSensibility(value: number);
  51411. /**
  51412. * Get the keys for camera movement forward.
  51413. */
  51414. get keysForward(): number[];
  51415. /**
  51416. * Set the keys for camera movement forward.
  51417. */
  51418. set keysForward(value: number[]);
  51419. /**
  51420. * Get the keys for camera movement backward.
  51421. */
  51422. get keysBackward(): number[];
  51423. set keysBackward(value: number[]);
  51424. /**
  51425. * Get the keys for camera movement up.
  51426. */
  51427. get keysUp(): number[];
  51428. /**
  51429. * Set the keys for camera movement up.
  51430. */
  51431. set keysUp(value: number[]);
  51432. /**
  51433. * Get the keys for camera movement down.
  51434. */
  51435. get keysDown(): number[];
  51436. /**
  51437. * Set the keys for camera movement down.
  51438. */
  51439. set keysDown(value: number[]);
  51440. /**
  51441. * Get the keys for camera movement left.
  51442. */
  51443. get keysLeft(): number[];
  51444. /**
  51445. * Set the keys for camera movement left.
  51446. */
  51447. set keysLeft(value: number[]);
  51448. /**
  51449. * Set the keys for camera movement right.
  51450. */
  51451. get keysRight(): number[];
  51452. /**
  51453. * Set the keys for camera movement right.
  51454. */
  51455. set keysRight(value: number[]);
  51456. /**
  51457. * Event raised when the camera collides with a mesh in the scene.
  51458. */
  51459. onCollide: (collidedMesh: AbstractMesh) => void;
  51460. private _collider;
  51461. private _needMoveForGravity;
  51462. private _oldPosition;
  51463. private _diffPosition;
  51464. private _newPosition;
  51465. /** @hidden */
  51466. _localDirection: Vector3;
  51467. /** @hidden */
  51468. _transformedDirection: Vector3;
  51469. /**
  51470. * Instantiates a FlyCamera.
  51471. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51472. * such as in a 3D Space Shooter or a Flight Simulator.
  51473. * @param name Define the name of the camera in the scene.
  51474. * @param position Define the starting position of the camera in the scene.
  51475. * @param scene Define the scene the camera belongs to.
  51476. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51477. */
  51478. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51479. /**
  51480. * Attach the input controls to a specific dom element to get the input from.
  51481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51482. */
  51483. attachControl(noPreventDefault?: boolean): void;
  51484. /**
  51485. * Detach a control from the HTML DOM element.
  51486. * The camera will stop reacting to that input.
  51487. */
  51488. detachControl(): void;
  51489. private _collisionMask;
  51490. /**
  51491. * Get the mask that the camera ignores in collision events.
  51492. */
  51493. get collisionMask(): number;
  51494. /**
  51495. * Set the mask that the camera ignores in collision events.
  51496. */
  51497. set collisionMask(mask: number);
  51498. /** @hidden */
  51499. _collideWithWorld(displacement: Vector3): void;
  51500. /** @hidden */
  51501. private _onCollisionPositionChange;
  51502. /** @hidden */
  51503. _checkInputs(): void;
  51504. /** @hidden */
  51505. _decideIfNeedsToMove(): boolean;
  51506. /** @hidden */
  51507. _updatePosition(): void;
  51508. /**
  51509. * Restore the Roll to its target value at the rate specified.
  51510. * @param rate - Higher means slower restoring.
  51511. * @hidden
  51512. */
  51513. restoreRoll(rate: number): void;
  51514. /**
  51515. * Destroy the camera and release the current resources held by it.
  51516. */
  51517. dispose(): void;
  51518. /**
  51519. * Get the current object class name.
  51520. * @returns the class name.
  51521. */
  51522. getClassName(): string;
  51523. }
  51524. }
  51525. declare module BABYLON {
  51526. /**
  51527. * Listen to keyboard events to control the camera.
  51528. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51529. */
  51530. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51531. /**
  51532. * Defines the camera the input is attached to.
  51533. */
  51534. camera: FlyCamera;
  51535. /**
  51536. * The list of keyboard keys used to control the forward move of the camera.
  51537. */
  51538. keysForward: number[];
  51539. /**
  51540. * The list of keyboard keys used to control the backward move of the camera.
  51541. */
  51542. keysBackward: number[];
  51543. /**
  51544. * The list of keyboard keys used to control the forward move of the camera.
  51545. */
  51546. keysUp: number[];
  51547. /**
  51548. * The list of keyboard keys used to control the backward move of the camera.
  51549. */
  51550. keysDown: number[];
  51551. /**
  51552. * The list of keyboard keys used to control the right strafe move of the camera.
  51553. */
  51554. keysRight: number[];
  51555. /**
  51556. * The list of keyboard keys used to control the left strafe move of the camera.
  51557. */
  51558. keysLeft: number[];
  51559. private _keys;
  51560. private _onCanvasBlurObserver;
  51561. private _onKeyboardObserver;
  51562. private _engine;
  51563. private _scene;
  51564. /**
  51565. * Attach the input controls to a specific dom element to get the input from.
  51566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51567. */
  51568. attachControl(noPreventDefault?: boolean): void;
  51569. /**
  51570. * Detach the current controls from the specified dom element.
  51571. */
  51572. detachControl(): void;
  51573. /**
  51574. * Gets the class name of the current intput.
  51575. * @returns the class name
  51576. */
  51577. getClassName(): string;
  51578. /** @hidden */
  51579. _onLostFocus(e: FocusEvent): void;
  51580. /**
  51581. * Get the friendly name associated with the input class.
  51582. * @returns the input friendly name
  51583. */
  51584. getSimpleName(): string;
  51585. /**
  51586. * Update the current camera state depending on the inputs that have been used this frame.
  51587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51588. */
  51589. checkInputs(): void;
  51590. }
  51591. }
  51592. declare module BABYLON {
  51593. /**
  51594. * Manage the mouse wheel inputs to control a follow camera.
  51595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51596. */
  51597. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51598. /**
  51599. * Defines the camera the input is attached to.
  51600. */
  51601. camera: FollowCamera;
  51602. /**
  51603. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51604. */
  51605. axisControlRadius: boolean;
  51606. /**
  51607. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51608. */
  51609. axisControlHeight: boolean;
  51610. /**
  51611. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51612. */
  51613. axisControlRotation: boolean;
  51614. /**
  51615. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51616. * relation to mouseWheel events.
  51617. */
  51618. wheelPrecision: number;
  51619. /**
  51620. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51621. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51622. */
  51623. wheelDeltaPercentage: number;
  51624. private _wheel;
  51625. private _observer;
  51626. /**
  51627. * Attach the input controls to a specific dom element to get the input from.
  51628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51629. */
  51630. attachControl(noPreventDefault?: boolean): void;
  51631. /**
  51632. * Detach the current controls from the specified dom element.
  51633. */
  51634. detachControl(): void;
  51635. /**
  51636. * Gets the class name of the current input.
  51637. * @returns the class name
  51638. */
  51639. getClassName(): string;
  51640. /**
  51641. * Get the friendly name associated with the input class.
  51642. * @returns the input friendly name
  51643. */
  51644. getSimpleName(): string;
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. /**
  51649. * Manage the pointers inputs to control an follow camera.
  51650. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51651. */
  51652. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51653. /**
  51654. * Defines the camera the input is attached to.
  51655. */
  51656. camera: FollowCamera;
  51657. /**
  51658. * Gets the class name of the current input.
  51659. * @returns the class name
  51660. */
  51661. getClassName(): string;
  51662. /**
  51663. * Defines the pointer angular sensibility along the X axis or how fast is
  51664. * the camera rotating.
  51665. * A negative number will reverse the axis direction.
  51666. */
  51667. angularSensibilityX: number;
  51668. /**
  51669. * Defines the pointer angular sensibility along the Y axis or how fast is
  51670. * the camera rotating.
  51671. * A negative number will reverse the axis direction.
  51672. */
  51673. angularSensibilityY: number;
  51674. /**
  51675. * Defines the pointer pinch precision or how fast is the camera zooming.
  51676. * A negative number will reverse the axis direction.
  51677. */
  51678. pinchPrecision: number;
  51679. /**
  51680. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51681. * from 0.
  51682. * It defines the percentage of current camera.radius to use as delta when
  51683. * pinch zoom is used.
  51684. */
  51685. pinchDeltaPercentage: number;
  51686. /**
  51687. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51688. */
  51689. axisXControlRadius: boolean;
  51690. /**
  51691. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51692. */
  51693. axisXControlHeight: boolean;
  51694. /**
  51695. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51696. */
  51697. axisXControlRotation: boolean;
  51698. /**
  51699. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51700. */
  51701. axisYControlRadius: boolean;
  51702. /**
  51703. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51704. */
  51705. axisYControlHeight: boolean;
  51706. /**
  51707. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51708. */
  51709. axisYControlRotation: boolean;
  51710. /**
  51711. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51712. */
  51713. axisPinchControlRadius: boolean;
  51714. /**
  51715. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51716. */
  51717. axisPinchControlHeight: boolean;
  51718. /**
  51719. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51720. */
  51721. axisPinchControlRotation: boolean;
  51722. /**
  51723. * Log error messages if basic misconfiguration has occurred.
  51724. */
  51725. warningEnable: boolean;
  51726. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51727. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51728. private _warningCounter;
  51729. private _warning;
  51730. }
  51731. }
  51732. declare module BABYLON {
  51733. /**
  51734. * Default Inputs manager for the FollowCamera.
  51735. * It groups all the default supported inputs for ease of use.
  51736. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51737. */
  51738. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51739. /**
  51740. * Instantiates a new FollowCameraInputsManager.
  51741. * @param camera Defines the camera the inputs belong to
  51742. */
  51743. constructor(camera: FollowCamera);
  51744. /**
  51745. * Add keyboard input support to the input manager.
  51746. * @returns the current input manager
  51747. */
  51748. addKeyboard(): FollowCameraInputsManager;
  51749. /**
  51750. * Add mouse wheel input support to the input manager.
  51751. * @returns the current input manager
  51752. */
  51753. addMouseWheel(): FollowCameraInputsManager;
  51754. /**
  51755. * Add pointers input support to the input manager.
  51756. * @returns the current input manager
  51757. */
  51758. addPointers(): FollowCameraInputsManager;
  51759. /**
  51760. * Add orientation input support to the input manager.
  51761. * @returns the current input manager
  51762. */
  51763. addVRDeviceOrientation(): FollowCameraInputsManager;
  51764. }
  51765. }
  51766. declare module BABYLON {
  51767. /**
  51768. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51769. * an arc rotate version arcFollowCamera are available.
  51770. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51771. */
  51772. export class FollowCamera extends TargetCamera {
  51773. /**
  51774. * Distance the follow camera should follow an object at
  51775. */
  51776. radius: number;
  51777. /**
  51778. * Minimum allowed distance of the camera to the axis of rotation
  51779. * (The camera can not get closer).
  51780. * This can help limiting how the Camera is able to move in the scene.
  51781. */
  51782. lowerRadiusLimit: Nullable<number>;
  51783. /**
  51784. * Maximum allowed distance of the camera to the axis of rotation
  51785. * (The camera can not get further).
  51786. * This can help limiting how the Camera is able to move in the scene.
  51787. */
  51788. upperRadiusLimit: Nullable<number>;
  51789. /**
  51790. * Define a rotation offset between the camera and the object it follows
  51791. */
  51792. rotationOffset: number;
  51793. /**
  51794. * Minimum allowed angle to camera position relative to target object.
  51795. * This can help limiting how the Camera is able to move in the scene.
  51796. */
  51797. lowerRotationOffsetLimit: Nullable<number>;
  51798. /**
  51799. * Maximum allowed angle to camera position relative to target object.
  51800. * This can help limiting how the Camera is able to move in the scene.
  51801. */
  51802. upperRotationOffsetLimit: Nullable<number>;
  51803. /**
  51804. * Define a height offset between the camera and the object it follows.
  51805. * It can help following an object from the top (like a car chasing a plane)
  51806. */
  51807. heightOffset: number;
  51808. /**
  51809. * Minimum allowed height of camera position relative to target object.
  51810. * This can help limiting how the Camera is able to move in the scene.
  51811. */
  51812. lowerHeightOffsetLimit: Nullable<number>;
  51813. /**
  51814. * Maximum allowed height of camera position relative to target object.
  51815. * This can help limiting how the Camera is able to move in the scene.
  51816. */
  51817. upperHeightOffsetLimit: Nullable<number>;
  51818. /**
  51819. * Define how fast the camera can accelerate to follow it s target.
  51820. */
  51821. cameraAcceleration: number;
  51822. /**
  51823. * Define the speed limit of the camera following an object.
  51824. */
  51825. maxCameraSpeed: number;
  51826. /**
  51827. * Define the target of the camera.
  51828. */
  51829. lockedTarget: Nullable<AbstractMesh>;
  51830. /**
  51831. * Defines the input associated with the camera.
  51832. */
  51833. inputs: FollowCameraInputsManager;
  51834. /**
  51835. * Instantiates the follow camera.
  51836. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51837. * @param name Define the name of the camera in the scene
  51838. * @param position Define the position of the camera
  51839. * @param scene Define the scene the camera belong to
  51840. * @param lockedTarget Define the target of the camera
  51841. */
  51842. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51843. private _follow;
  51844. /**
  51845. * Attach the input controls to a specific dom element to get the input from.
  51846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51847. */
  51848. attachControl(noPreventDefault?: boolean): void;
  51849. /**
  51850. * Detach the current controls from the specified dom element.
  51851. */
  51852. detachControl(): void;
  51853. /** @hidden */
  51854. _checkInputs(): void;
  51855. private _checkLimits;
  51856. /**
  51857. * Gets the camera class name.
  51858. * @returns the class name
  51859. */
  51860. getClassName(): string;
  51861. }
  51862. /**
  51863. * Arc Rotate version of the follow camera.
  51864. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51865. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51866. */
  51867. export class ArcFollowCamera extends TargetCamera {
  51868. /** The longitudinal angle of the camera */
  51869. alpha: number;
  51870. /** The latitudinal angle of the camera */
  51871. beta: number;
  51872. /** The radius of the camera from its target */
  51873. radius: number;
  51874. private _cartesianCoordinates;
  51875. /** Define the camera target (the mesh it should follow) */
  51876. private _meshTarget;
  51877. /**
  51878. * Instantiates a new ArcFollowCamera
  51879. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51880. * @param name Define the name of the camera
  51881. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51882. * @param beta Define the rotation angle of the camera around the elevation axis
  51883. * @param radius Define the radius of the camera from its target point
  51884. * @param target Define the target of the camera
  51885. * @param scene Define the scene the camera belongs to
  51886. */
  51887. constructor(name: string,
  51888. /** The longitudinal angle of the camera */
  51889. alpha: number,
  51890. /** The latitudinal angle of the camera */
  51891. beta: number,
  51892. /** The radius of the camera from its target */
  51893. radius: number,
  51894. /** Define the camera target (the mesh it should follow) */
  51895. target: Nullable<AbstractMesh>, scene: Scene);
  51896. private _follow;
  51897. /** @hidden */
  51898. _checkInputs(): void;
  51899. /**
  51900. * Returns the class name of the object.
  51901. * It is mostly used internally for serialization purposes.
  51902. */
  51903. getClassName(): string;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. /**
  51908. * Manage the keyboard inputs to control the movement of a follow camera.
  51909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51910. */
  51911. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51912. /**
  51913. * Defines the camera the input is attached to.
  51914. */
  51915. camera: FollowCamera;
  51916. /**
  51917. * Defines the list of key codes associated with the up action (increase heightOffset)
  51918. */
  51919. keysHeightOffsetIncr: number[];
  51920. /**
  51921. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51922. */
  51923. keysHeightOffsetDecr: number[];
  51924. /**
  51925. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51926. */
  51927. keysHeightOffsetModifierAlt: boolean;
  51928. /**
  51929. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51930. */
  51931. keysHeightOffsetModifierCtrl: boolean;
  51932. /**
  51933. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51934. */
  51935. keysHeightOffsetModifierShift: boolean;
  51936. /**
  51937. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51938. */
  51939. keysRotationOffsetIncr: number[];
  51940. /**
  51941. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51942. */
  51943. keysRotationOffsetDecr: number[];
  51944. /**
  51945. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51946. */
  51947. keysRotationOffsetModifierAlt: boolean;
  51948. /**
  51949. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51950. */
  51951. keysRotationOffsetModifierCtrl: boolean;
  51952. /**
  51953. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51954. */
  51955. keysRotationOffsetModifierShift: boolean;
  51956. /**
  51957. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51958. */
  51959. keysRadiusIncr: number[];
  51960. /**
  51961. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51962. */
  51963. keysRadiusDecr: number[];
  51964. /**
  51965. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51966. */
  51967. keysRadiusModifierAlt: boolean;
  51968. /**
  51969. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51970. */
  51971. keysRadiusModifierCtrl: boolean;
  51972. /**
  51973. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51974. */
  51975. keysRadiusModifierShift: boolean;
  51976. /**
  51977. * Defines the rate of change of heightOffset.
  51978. */
  51979. heightSensibility: number;
  51980. /**
  51981. * Defines the rate of change of rotationOffset.
  51982. */
  51983. rotationSensibility: number;
  51984. /**
  51985. * Defines the rate of change of radius.
  51986. */
  51987. radiusSensibility: number;
  51988. private _keys;
  51989. private _ctrlPressed;
  51990. private _altPressed;
  51991. private _shiftPressed;
  51992. private _onCanvasBlurObserver;
  51993. private _onKeyboardObserver;
  51994. private _engine;
  51995. private _scene;
  51996. /**
  51997. * Attach the input controls to a specific dom element to get the input from.
  51998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51999. */
  52000. attachControl(noPreventDefault?: boolean): void;
  52001. /**
  52002. * Detach the current controls from the specified dom element.
  52003. */
  52004. detachControl(): void;
  52005. /**
  52006. * Update the current camera state depending on the inputs that have been used this frame.
  52007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52008. */
  52009. checkInputs(): void;
  52010. /**
  52011. * Gets the class name of the current input.
  52012. * @returns the class name
  52013. */
  52014. getClassName(): string;
  52015. /**
  52016. * Get the friendly name associated with the input class.
  52017. * @returns the input friendly name
  52018. */
  52019. getSimpleName(): string;
  52020. /**
  52021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52022. * allow modification of the heightOffset value.
  52023. */
  52024. private _modifierHeightOffset;
  52025. /**
  52026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52027. * allow modification of the rotationOffset value.
  52028. */
  52029. private _modifierRotationOffset;
  52030. /**
  52031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52032. * allow modification of the radius value.
  52033. */
  52034. private _modifierRadius;
  52035. }
  52036. }
  52037. declare module BABYLON {
  52038. interface FreeCameraInputsManager {
  52039. /**
  52040. * @hidden
  52041. */
  52042. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52043. /**
  52044. * Add orientation input support to the input manager.
  52045. * @returns the current input manager
  52046. */
  52047. addDeviceOrientation(): FreeCameraInputsManager;
  52048. }
  52049. /**
  52050. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52051. * Screen rotation is taken into account.
  52052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52053. */
  52054. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52055. private _camera;
  52056. private _screenOrientationAngle;
  52057. private _constantTranform;
  52058. private _screenQuaternion;
  52059. private _alpha;
  52060. private _beta;
  52061. private _gamma;
  52062. /**
  52063. * Can be used to detect if a device orientation sensor is available on a device
  52064. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52065. * @returns a promise that will resolve on orientation change
  52066. */
  52067. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52068. /**
  52069. * @hidden
  52070. */
  52071. _onDeviceOrientationChangedObservable: Observable<void>;
  52072. /**
  52073. * Instantiates a new input
  52074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52075. */
  52076. constructor();
  52077. /**
  52078. * Define the camera controlled by the input.
  52079. */
  52080. get camera(): FreeCamera;
  52081. set camera(camera: FreeCamera);
  52082. /**
  52083. * Attach the input controls to a specific dom element to get the input from.
  52084. */
  52085. attachControl(): void;
  52086. private _orientationChanged;
  52087. private _deviceOrientation;
  52088. /**
  52089. * Detach the current controls from the specified dom element.
  52090. */
  52091. detachControl(): void;
  52092. /**
  52093. * Update the current camera state depending on the inputs that have been used this frame.
  52094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52095. */
  52096. checkInputs(): void;
  52097. /**
  52098. * Gets the class name of the current input.
  52099. * @returns the class name
  52100. */
  52101. getClassName(): string;
  52102. /**
  52103. * Get the friendly name associated with the input class.
  52104. * @returns the input friendly name
  52105. */
  52106. getSimpleName(): string;
  52107. }
  52108. }
  52109. declare module BABYLON {
  52110. /**
  52111. * Manage the gamepad inputs to control a free camera.
  52112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52113. */
  52114. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52115. /**
  52116. * Define the camera the input is attached to.
  52117. */
  52118. camera: FreeCamera;
  52119. /**
  52120. * Define the Gamepad controlling the input
  52121. */
  52122. gamepad: Nullable<Gamepad>;
  52123. /**
  52124. * Defines the gamepad rotation sensiblity.
  52125. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52126. */
  52127. gamepadAngularSensibility: number;
  52128. /**
  52129. * Defines the gamepad move sensiblity.
  52130. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52131. */
  52132. gamepadMoveSensibility: number;
  52133. private _yAxisScale;
  52134. /**
  52135. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52136. */
  52137. get invertYAxis(): boolean;
  52138. set invertYAxis(value: boolean);
  52139. private _onGamepadConnectedObserver;
  52140. private _onGamepadDisconnectedObserver;
  52141. private _cameraTransform;
  52142. private _deltaTransform;
  52143. private _vector3;
  52144. private _vector2;
  52145. /**
  52146. * Attach the input controls to a specific dom element to get the input from.
  52147. */
  52148. attachControl(): void;
  52149. /**
  52150. * Detach the current controls from the specified dom element.
  52151. */
  52152. detachControl(): void;
  52153. /**
  52154. * Update the current camera state depending on the inputs that have been used this frame.
  52155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52156. */
  52157. checkInputs(): void;
  52158. /**
  52159. * Gets the class name of the current input.
  52160. * @returns the class name
  52161. */
  52162. getClassName(): string;
  52163. /**
  52164. * Get the friendly name associated with the input class.
  52165. * @returns the input friendly name
  52166. */
  52167. getSimpleName(): string;
  52168. }
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. * Defines the potential axis of a Joystick
  52173. */
  52174. export enum JoystickAxis {
  52175. /** X axis */
  52176. X = 0,
  52177. /** Y axis */
  52178. Y = 1,
  52179. /** Z axis */
  52180. Z = 2
  52181. }
  52182. /**
  52183. * Represents the different customization options available
  52184. * for VirtualJoystick
  52185. */
  52186. interface VirtualJoystickCustomizations {
  52187. /**
  52188. * Size of the joystick's puck
  52189. */
  52190. puckSize: number;
  52191. /**
  52192. * Size of the joystick's container
  52193. */
  52194. containerSize: number;
  52195. /**
  52196. * Color of the joystick && puck
  52197. */
  52198. color: string;
  52199. /**
  52200. * Image URL for the joystick's puck
  52201. */
  52202. puckImage?: string;
  52203. /**
  52204. * Image URL for the joystick's container
  52205. */
  52206. containerImage?: string;
  52207. /**
  52208. * Defines the unmoving position of the joystick container
  52209. */
  52210. position?: {
  52211. x: number;
  52212. y: number;
  52213. };
  52214. /**
  52215. * Defines whether or not the joystick container is always visible
  52216. */
  52217. alwaysVisible: boolean;
  52218. /**
  52219. * Defines whether or not to limit the movement of the puck to the joystick's container
  52220. */
  52221. limitToContainer: boolean;
  52222. }
  52223. /**
  52224. * Class used to define virtual joystick (used in touch mode)
  52225. */
  52226. export class VirtualJoystick {
  52227. /**
  52228. * Gets or sets a boolean indicating that left and right values must be inverted
  52229. */
  52230. reverseLeftRight: boolean;
  52231. /**
  52232. * Gets or sets a boolean indicating that up and down values must be inverted
  52233. */
  52234. reverseUpDown: boolean;
  52235. /**
  52236. * Gets the offset value for the position (ie. the change of the position value)
  52237. */
  52238. deltaPosition: Vector3;
  52239. /**
  52240. * Gets a boolean indicating if the virtual joystick was pressed
  52241. */
  52242. pressed: boolean;
  52243. /**
  52244. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52245. */
  52246. static Canvas: Nullable<HTMLCanvasElement>;
  52247. /**
  52248. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52249. */
  52250. limitToContainer: boolean;
  52251. private static _globalJoystickIndex;
  52252. private static _alwaysVisibleSticks;
  52253. private static vjCanvasContext;
  52254. private static vjCanvasWidth;
  52255. private static vjCanvasHeight;
  52256. private static halfWidth;
  52257. private static _GetDefaultOptions;
  52258. private _action;
  52259. private _axisTargetedByLeftAndRight;
  52260. private _axisTargetedByUpAndDown;
  52261. private _joystickSensibility;
  52262. private _inversedSensibility;
  52263. private _joystickPointerID;
  52264. private _joystickColor;
  52265. private _joystickPointerPos;
  52266. private _joystickPreviousPointerPos;
  52267. private _joystickPointerStartPos;
  52268. private _deltaJoystickVector;
  52269. private _leftJoystick;
  52270. private _touches;
  52271. private _joystickPosition;
  52272. private _alwaysVisible;
  52273. private _puckImage;
  52274. private _containerImage;
  52275. private _joystickPuckSize;
  52276. private _joystickContainerSize;
  52277. private _clearPuckSize;
  52278. private _clearContainerSize;
  52279. private _clearPuckSizeOffset;
  52280. private _clearContainerSizeOffset;
  52281. private _onPointerDownHandlerRef;
  52282. private _onPointerMoveHandlerRef;
  52283. private _onPointerUpHandlerRef;
  52284. private _onResize;
  52285. /**
  52286. * Creates a new virtual joystick
  52287. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52288. * @param customizations Defines the options we want to customize the VirtualJoystick
  52289. */
  52290. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52291. /**
  52292. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52293. * @param newJoystickSensibility defines the new sensibility
  52294. */
  52295. setJoystickSensibility(newJoystickSensibility: number): void;
  52296. private _onPointerDown;
  52297. private _onPointerMove;
  52298. private _onPointerUp;
  52299. /**
  52300. * Change the color of the virtual joystick
  52301. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52302. */
  52303. setJoystickColor(newColor: string): void;
  52304. /**
  52305. * Size of the joystick's container
  52306. */
  52307. set containerSize(newSize: number);
  52308. get containerSize(): number;
  52309. /**
  52310. * Size of the joystick's puck
  52311. */
  52312. set puckSize(newSize: number);
  52313. get puckSize(): number;
  52314. /**
  52315. * Clears the set position of the joystick
  52316. */
  52317. clearPosition(): void;
  52318. /**
  52319. * Defines whether or not the joystick container is always visible
  52320. */
  52321. set alwaysVisible(value: boolean);
  52322. get alwaysVisible(): boolean;
  52323. /**
  52324. * Sets the constant position of the Joystick container
  52325. * @param x X axis coordinate
  52326. * @param y Y axis coordinate
  52327. */
  52328. setPosition(x: number, y: number): void;
  52329. /**
  52330. * Defines a callback to call when the joystick is touched
  52331. * @param action defines the callback
  52332. */
  52333. setActionOnTouch(action: () => any): void;
  52334. /**
  52335. * Defines which axis you'd like to control for left & right
  52336. * @param axis defines the axis to use
  52337. */
  52338. setAxisForLeftRight(axis: JoystickAxis): void;
  52339. /**
  52340. * Defines which axis you'd like to control for up & down
  52341. * @param axis defines the axis to use
  52342. */
  52343. setAxisForUpDown(axis: JoystickAxis): void;
  52344. /**
  52345. * Clears the canvas from the previous puck / container draw
  52346. */
  52347. private _clearPreviousDraw;
  52348. /**
  52349. * Loads `urlPath` to be used for the container's image
  52350. * @param urlPath defines the urlPath of an image to use
  52351. */
  52352. setContainerImage(urlPath: string): void;
  52353. /**
  52354. * Loads `urlPath` to be used for the puck's image
  52355. * @param urlPath defines the urlPath of an image to use
  52356. */
  52357. setPuckImage(urlPath: string): void;
  52358. /**
  52359. * Draws the Virtual Joystick's container
  52360. */
  52361. private _drawContainer;
  52362. /**
  52363. * Draws the Virtual Joystick's puck
  52364. */
  52365. private _drawPuck;
  52366. private _drawVirtualJoystick;
  52367. /**
  52368. * Release internal HTML canvas
  52369. */
  52370. releaseCanvas(): void;
  52371. }
  52372. }
  52373. declare module BABYLON {
  52374. interface FreeCameraInputsManager {
  52375. /**
  52376. * Add virtual joystick input support to the input manager.
  52377. * @returns the current input manager
  52378. */
  52379. addVirtualJoystick(): FreeCameraInputsManager;
  52380. }
  52381. /**
  52382. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52383. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52384. */
  52385. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52386. /**
  52387. * Defines the camera the input is attached to.
  52388. */
  52389. camera: FreeCamera;
  52390. private _leftjoystick;
  52391. private _rightjoystick;
  52392. /**
  52393. * Gets the left stick of the virtual joystick.
  52394. * @returns The virtual Joystick
  52395. */
  52396. getLeftJoystick(): VirtualJoystick;
  52397. /**
  52398. * Gets the right stick of the virtual joystick.
  52399. * @returns The virtual Joystick
  52400. */
  52401. getRightJoystick(): VirtualJoystick;
  52402. /**
  52403. * Update the current camera state depending on the inputs that have been used this frame.
  52404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52405. */
  52406. checkInputs(): void;
  52407. /**
  52408. * Attach the input controls to a specific dom element to get the input from.
  52409. */
  52410. attachControl(): void;
  52411. /**
  52412. * Detach the current controls from the specified dom element.
  52413. */
  52414. detachControl(): void;
  52415. /**
  52416. * Gets the class name of the current input.
  52417. * @returns the class name
  52418. */
  52419. getClassName(): string;
  52420. /**
  52421. * Get the friendly name associated with the input class.
  52422. * @returns the input friendly name
  52423. */
  52424. getSimpleName(): string;
  52425. }
  52426. }
  52427. declare module BABYLON {
  52428. /**
  52429. * This represents a FPS type of camera controlled by touch.
  52430. * This is like a universal camera minus the Gamepad controls.
  52431. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52432. */
  52433. export class TouchCamera extends FreeCamera {
  52434. /**
  52435. * Defines the touch sensibility for rotation.
  52436. * The higher the faster.
  52437. */
  52438. get touchAngularSensibility(): number;
  52439. set touchAngularSensibility(value: number);
  52440. /**
  52441. * Defines the touch sensibility for move.
  52442. * The higher the faster.
  52443. */
  52444. get touchMoveSensibility(): number;
  52445. set touchMoveSensibility(value: number);
  52446. /**
  52447. * Instantiates a new touch camera.
  52448. * This represents a FPS type of camera controlled by touch.
  52449. * This is like a universal camera minus the Gamepad controls.
  52450. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52451. * @param name Define the name of the camera in the scene
  52452. * @param position Define the start position of the camera in the scene
  52453. * @param scene Define the scene the camera belongs to
  52454. */
  52455. constructor(name: string, position: Vector3, scene: Scene);
  52456. /**
  52457. * Gets the current object class name.
  52458. * @return the class name
  52459. */
  52460. getClassName(): string;
  52461. /** @hidden */
  52462. _setupInputs(): void;
  52463. }
  52464. }
  52465. declare module BABYLON {
  52466. /**
  52467. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52468. * being tilted forward or back and left or right.
  52469. */
  52470. export class DeviceOrientationCamera extends FreeCamera {
  52471. private _initialQuaternion;
  52472. private _quaternionCache;
  52473. private _tmpDragQuaternion;
  52474. private _disablePointerInputWhenUsingDeviceOrientation;
  52475. /**
  52476. * Creates a new device orientation camera
  52477. * @param name The name of the camera
  52478. * @param position The start position camera
  52479. * @param scene The scene the camera belongs to
  52480. */
  52481. constructor(name: string, position: Vector3, scene: Scene);
  52482. /**
  52483. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52484. */
  52485. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52486. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52487. private _dragFactor;
  52488. /**
  52489. * Enabled turning on the y axis when the orientation sensor is active
  52490. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52491. */
  52492. enableHorizontalDragging(dragFactor?: number): void;
  52493. /**
  52494. * Gets the current instance class name ("DeviceOrientationCamera").
  52495. * This helps avoiding instanceof at run time.
  52496. * @returns the class name
  52497. */
  52498. getClassName(): string;
  52499. /**
  52500. * @hidden
  52501. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52502. */
  52503. _checkInputs(): void;
  52504. /**
  52505. * Reset the camera to its default orientation on the specified axis only.
  52506. * @param axis The axis to reset
  52507. */
  52508. resetToCurrentRotation(axis?: Axis): void;
  52509. }
  52510. }
  52511. declare module BABYLON {
  52512. /**
  52513. * Defines supported buttons for XBox360 compatible gamepads
  52514. */
  52515. export enum Xbox360Button {
  52516. /** A */
  52517. A = 0,
  52518. /** B */
  52519. B = 1,
  52520. /** X */
  52521. X = 2,
  52522. /** Y */
  52523. Y = 3,
  52524. /** Left button */
  52525. LB = 4,
  52526. /** Right button */
  52527. RB = 5,
  52528. /** Back */
  52529. Back = 8,
  52530. /** Start */
  52531. Start = 9,
  52532. /** Left stick */
  52533. LeftStick = 10,
  52534. /** Right stick */
  52535. RightStick = 11
  52536. }
  52537. /** Defines values for XBox360 DPad */
  52538. export enum Xbox360Dpad {
  52539. /** Up */
  52540. Up = 12,
  52541. /** Down */
  52542. Down = 13,
  52543. /** Left */
  52544. Left = 14,
  52545. /** Right */
  52546. Right = 15
  52547. }
  52548. /**
  52549. * Defines a XBox360 gamepad
  52550. */
  52551. export class Xbox360Pad extends Gamepad {
  52552. private _leftTrigger;
  52553. private _rightTrigger;
  52554. private _onlefttriggerchanged;
  52555. private _onrighttriggerchanged;
  52556. private _onbuttondown;
  52557. private _onbuttonup;
  52558. private _ondpaddown;
  52559. private _ondpadup;
  52560. /** Observable raised when a button is pressed */
  52561. onButtonDownObservable: Observable<Xbox360Button>;
  52562. /** Observable raised when a button is released */
  52563. onButtonUpObservable: Observable<Xbox360Button>;
  52564. /** Observable raised when a pad is pressed */
  52565. onPadDownObservable: Observable<Xbox360Dpad>;
  52566. /** Observable raised when a pad is released */
  52567. onPadUpObservable: Observable<Xbox360Dpad>;
  52568. private _buttonA;
  52569. private _buttonB;
  52570. private _buttonX;
  52571. private _buttonY;
  52572. private _buttonBack;
  52573. private _buttonStart;
  52574. private _buttonLB;
  52575. private _buttonRB;
  52576. private _buttonLeftStick;
  52577. private _buttonRightStick;
  52578. private _dPadUp;
  52579. private _dPadDown;
  52580. private _dPadLeft;
  52581. private _dPadRight;
  52582. private _isXboxOnePad;
  52583. /**
  52584. * Creates a new XBox360 gamepad object
  52585. * @param id defines the id of this gamepad
  52586. * @param index defines its index
  52587. * @param gamepad defines the internal HTML gamepad object
  52588. * @param xboxOne defines if it is a XBox One gamepad
  52589. */
  52590. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52591. /**
  52592. * Defines the callback to call when left trigger is pressed
  52593. * @param callback defines the callback to use
  52594. */
  52595. onlefttriggerchanged(callback: (value: number) => void): void;
  52596. /**
  52597. * Defines the callback to call when right trigger is pressed
  52598. * @param callback defines the callback to use
  52599. */
  52600. onrighttriggerchanged(callback: (value: number) => void): void;
  52601. /**
  52602. * Gets the left trigger value
  52603. */
  52604. get leftTrigger(): number;
  52605. /**
  52606. * Sets the left trigger value
  52607. */
  52608. set leftTrigger(newValue: number);
  52609. /**
  52610. * Gets the right trigger value
  52611. */
  52612. get rightTrigger(): number;
  52613. /**
  52614. * Sets the right trigger value
  52615. */
  52616. set rightTrigger(newValue: number);
  52617. /**
  52618. * Defines the callback to call when a button is pressed
  52619. * @param callback defines the callback to use
  52620. */
  52621. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52622. /**
  52623. * Defines the callback to call when a button is released
  52624. * @param callback defines the callback to use
  52625. */
  52626. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52627. /**
  52628. * Defines the callback to call when a pad is pressed
  52629. * @param callback defines the callback to use
  52630. */
  52631. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52632. /**
  52633. * Defines the callback to call when a pad is released
  52634. * @param callback defines the callback to use
  52635. */
  52636. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52637. private _setButtonValue;
  52638. private _setDPadValue;
  52639. /**
  52640. * Gets the value of the `A` button
  52641. */
  52642. get buttonA(): number;
  52643. /**
  52644. * Sets the value of the `A` button
  52645. */
  52646. set buttonA(value: number);
  52647. /**
  52648. * Gets the value of the `B` button
  52649. */
  52650. get buttonB(): number;
  52651. /**
  52652. * Sets the value of the `B` button
  52653. */
  52654. set buttonB(value: number);
  52655. /**
  52656. * Gets the value of the `X` button
  52657. */
  52658. get buttonX(): number;
  52659. /**
  52660. * Sets the value of the `X` button
  52661. */
  52662. set buttonX(value: number);
  52663. /**
  52664. * Gets the value of the `Y` button
  52665. */
  52666. get buttonY(): number;
  52667. /**
  52668. * Sets the value of the `Y` button
  52669. */
  52670. set buttonY(value: number);
  52671. /**
  52672. * Gets the value of the `Start` button
  52673. */
  52674. get buttonStart(): number;
  52675. /**
  52676. * Sets the value of the `Start` button
  52677. */
  52678. set buttonStart(value: number);
  52679. /**
  52680. * Gets the value of the `Back` button
  52681. */
  52682. get buttonBack(): number;
  52683. /**
  52684. * Sets the value of the `Back` button
  52685. */
  52686. set buttonBack(value: number);
  52687. /**
  52688. * Gets the value of the `Left` button
  52689. */
  52690. get buttonLB(): number;
  52691. /**
  52692. * Sets the value of the `Left` button
  52693. */
  52694. set buttonLB(value: number);
  52695. /**
  52696. * Gets the value of the `Right` button
  52697. */
  52698. get buttonRB(): number;
  52699. /**
  52700. * Sets the value of the `Right` button
  52701. */
  52702. set buttonRB(value: number);
  52703. /**
  52704. * Gets the value of the Left joystick
  52705. */
  52706. get buttonLeftStick(): number;
  52707. /**
  52708. * Sets the value of the Left joystick
  52709. */
  52710. set buttonLeftStick(value: number);
  52711. /**
  52712. * Gets the value of the Right joystick
  52713. */
  52714. get buttonRightStick(): number;
  52715. /**
  52716. * Sets the value of the Right joystick
  52717. */
  52718. set buttonRightStick(value: number);
  52719. /**
  52720. * Gets the value of D-pad up
  52721. */
  52722. get dPadUp(): number;
  52723. /**
  52724. * Sets the value of D-pad up
  52725. */
  52726. set dPadUp(value: number);
  52727. /**
  52728. * Gets the value of D-pad down
  52729. */
  52730. get dPadDown(): number;
  52731. /**
  52732. * Sets the value of D-pad down
  52733. */
  52734. set dPadDown(value: number);
  52735. /**
  52736. * Gets the value of D-pad left
  52737. */
  52738. get dPadLeft(): number;
  52739. /**
  52740. * Sets the value of D-pad left
  52741. */
  52742. set dPadLeft(value: number);
  52743. /**
  52744. * Gets the value of D-pad right
  52745. */
  52746. get dPadRight(): number;
  52747. /**
  52748. * Sets the value of D-pad right
  52749. */
  52750. set dPadRight(value: number);
  52751. /**
  52752. * Force the gamepad to synchronize with device values
  52753. */
  52754. update(): void;
  52755. /**
  52756. * Disposes the gamepad
  52757. */
  52758. dispose(): void;
  52759. }
  52760. }
  52761. declare module BABYLON {
  52762. /**
  52763. * Defines supported buttons for DualShock compatible gamepads
  52764. */
  52765. export enum DualShockButton {
  52766. /** Cross */
  52767. Cross = 0,
  52768. /** Circle */
  52769. Circle = 1,
  52770. /** Square */
  52771. Square = 2,
  52772. /** Triangle */
  52773. Triangle = 3,
  52774. /** L1 */
  52775. L1 = 4,
  52776. /** R1 */
  52777. R1 = 5,
  52778. /** Share */
  52779. Share = 8,
  52780. /** Options */
  52781. Options = 9,
  52782. /** Left stick */
  52783. LeftStick = 10,
  52784. /** Right stick */
  52785. RightStick = 11
  52786. }
  52787. /** Defines values for DualShock DPad */
  52788. export enum DualShockDpad {
  52789. /** Up */
  52790. Up = 12,
  52791. /** Down */
  52792. Down = 13,
  52793. /** Left */
  52794. Left = 14,
  52795. /** Right */
  52796. Right = 15
  52797. }
  52798. /**
  52799. * Defines a DualShock gamepad
  52800. */
  52801. export class DualShockPad extends Gamepad {
  52802. private _leftTrigger;
  52803. private _rightTrigger;
  52804. private _onlefttriggerchanged;
  52805. private _onrighttriggerchanged;
  52806. private _onbuttondown;
  52807. private _onbuttonup;
  52808. private _ondpaddown;
  52809. private _ondpadup;
  52810. /** Observable raised when a button is pressed */
  52811. onButtonDownObservable: Observable<DualShockButton>;
  52812. /** Observable raised when a button is released */
  52813. onButtonUpObservable: Observable<DualShockButton>;
  52814. /** Observable raised when a pad is pressed */
  52815. onPadDownObservable: Observable<DualShockDpad>;
  52816. /** Observable raised when a pad is released */
  52817. onPadUpObservable: Observable<DualShockDpad>;
  52818. private _buttonCross;
  52819. private _buttonCircle;
  52820. private _buttonSquare;
  52821. private _buttonTriangle;
  52822. private _buttonShare;
  52823. private _buttonOptions;
  52824. private _buttonL1;
  52825. private _buttonR1;
  52826. private _buttonLeftStick;
  52827. private _buttonRightStick;
  52828. private _dPadUp;
  52829. private _dPadDown;
  52830. private _dPadLeft;
  52831. private _dPadRight;
  52832. /**
  52833. * Creates a new DualShock gamepad object
  52834. * @param id defines the id of this gamepad
  52835. * @param index defines its index
  52836. * @param gamepad defines the internal HTML gamepad object
  52837. */
  52838. constructor(id: string, index: number, gamepad: any);
  52839. /**
  52840. * Defines the callback to call when left trigger is pressed
  52841. * @param callback defines the callback to use
  52842. */
  52843. onlefttriggerchanged(callback: (value: number) => void): void;
  52844. /**
  52845. * Defines the callback to call when right trigger is pressed
  52846. * @param callback defines the callback to use
  52847. */
  52848. onrighttriggerchanged(callback: (value: number) => void): void;
  52849. /**
  52850. * Gets the left trigger value
  52851. */
  52852. get leftTrigger(): number;
  52853. /**
  52854. * Sets the left trigger value
  52855. */
  52856. set leftTrigger(newValue: number);
  52857. /**
  52858. * Gets the right trigger value
  52859. */
  52860. get rightTrigger(): number;
  52861. /**
  52862. * Sets the right trigger value
  52863. */
  52864. set rightTrigger(newValue: number);
  52865. /**
  52866. * Defines the callback to call when a button is pressed
  52867. * @param callback defines the callback to use
  52868. */
  52869. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52870. /**
  52871. * Defines the callback to call when a button is released
  52872. * @param callback defines the callback to use
  52873. */
  52874. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52875. /**
  52876. * Defines the callback to call when a pad is pressed
  52877. * @param callback defines the callback to use
  52878. */
  52879. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52880. /**
  52881. * Defines the callback to call when a pad is released
  52882. * @param callback defines the callback to use
  52883. */
  52884. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52885. private _setButtonValue;
  52886. private _setDPadValue;
  52887. /**
  52888. * Gets the value of the `Cross` button
  52889. */
  52890. get buttonCross(): number;
  52891. /**
  52892. * Sets the value of the `Cross` button
  52893. */
  52894. set buttonCross(value: number);
  52895. /**
  52896. * Gets the value of the `Circle` button
  52897. */
  52898. get buttonCircle(): number;
  52899. /**
  52900. * Sets the value of the `Circle` button
  52901. */
  52902. set buttonCircle(value: number);
  52903. /**
  52904. * Gets the value of the `Square` button
  52905. */
  52906. get buttonSquare(): number;
  52907. /**
  52908. * Sets the value of the `Square` button
  52909. */
  52910. set buttonSquare(value: number);
  52911. /**
  52912. * Gets the value of the `Triangle` button
  52913. */
  52914. get buttonTriangle(): number;
  52915. /**
  52916. * Sets the value of the `Triangle` button
  52917. */
  52918. set buttonTriangle(value: number);
  52919. /**
  52920. * Gets the value of the `Options` button
  52921. */
  52922. get buttonOptions(): number;
  52923. /**
  52924. * Sets the value of the `Options` button
  52925. */
  52926. set buttonOptions(value: number);
  52927. /**
  52928. * Gets the value of the `Share` button
  52929. */
  52930. get buttonShare(): number;
  52931. /**
  52932. * Sets the value of the `Share` button
  52933. */
  52934. set buttonShare(value: number);
  52935. /**
  52936. * Gets the value of the `L1` button
  52937. */
  52938. get buttonL1(): number;
  52939. /**
  52940. * Sets the value of the `L1` button
  52941. */
  52942. set buttonL1(value: number);
  52943. /**
  52944. * Gets the value of the `R1` button
  52945. */
  52946. get buttonR1(): number;
  52947. /**
  52948. * Sets the value of the `R1` button
  52949. */
  52950. set buttonR1(value: number);
  52951. /**
  52952. * Gets the value of the Left joystick
  52953. */
  52954. get buttonLeftStick(): number;
  52955. /**
  52956. * Sets the value of the Left joystick
  52957. */
  52958. set buttonLeftStick(value: number);
  52959. /**
  52960. * Gets the value of the Right joystick
  52961. */
  52962. get buttonRightStick(): number;
  52963. /**
  52964. * Sets the value of the Right joystick
  52965. */
  52966. set buttonRightStick(value: number);
  52967. /**
  52968. * Gets the value of D-pad up
  52969. */
  52970. get dPadUp(): number;
  52971. /**
  52972. * Sets the value of D-pad up
  52973. */
  52974. set dPadUp(value: number);
  52975. /**
  52976. * Gets the value of D-pad down
  52977. */
  52978. get dPadDown(): number;
  52979. /**
  52980. * Sets the value of D-pad down
  52981. */
  52982. set dPadDown(value: number);
  52983. /**
  52984. * Gets the value of D-pad left
  52985. */
  52986. get dPadLeft(): number;
  52987. /**
  52988. * Sets the value of D-pad left
  52989. */
  52990. set dPadLeft(value: number);
  52991. /**
  52992. * Gets the value of D-pad right
  52993. */
  52994. get dPadRight(): number;
  52995. /**
  52996. * Sets the value of D-pad right
  52997. */
  52998. set dPadRight(value: number);
  52999. /**
  53000. * Force the gamepad to synchronize with device values
  53001. */
  53002. update(): void;
  53003. /**
  53004. * Disposes the gamepad
  53005. */
  53006. dispose(): void;
  53007. }
  53008. }
  53009. declare module BABYLON {
  53010. /**
  53011. * Manager for handling gamepads
  53012. */
  53013. export class GamepadManager {
  53014. private _scene?;
  53015. private _babylonGamepads;
  53016. private _oneGamepadConnected;
  53017. /** @hidden */
  53018. _isMonitoring: boolean;
  53019. private _gamepadEventSupported;
  53020. private _gamepadSupport?;
  53021. /**
  53022. * observable to be triggered when the gamepad controller has been connected
  53023. */
  53024. onGamepadConnectedObservable: Observable<Gamepad>;
  53025. /**
  53026. * observable to be triggered when the gamepad controller has been disconnected
  53027. */
  53028. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53029. private _onGamepadConnectedEvent;
  53030. private _onGamepadDisconnectedEvent;
  53031. /**
  53032. * Initializes the gamepad manager
  53033. * @param _scene BabylonJS scene
  53034. */
  53035. constructor(_scene?: Scene | undefined);
  53036. /**
  53037. * The gamepads in the game pad manager
  53038. */
  53039. get gamepads(): Gamepad[];
  53040. /**
  53041. * Get the gamepad controllers based on type
  53042. * @param type The type of gamepad controller
  53043. * @returns Nullable gamepad
  53044. */
  53045. getGamepadByType(type?: number): Nullable<Gamepad>;
  53046. /**
  53047. * Disposes the gamepad manager
  53048. */
  53049. dispose(): void;
  53050. private _addNewGamepad;
  53051. private _startMonitoringGamepads;
  53052. private _stopMonitoringGamepads;
  53053. /** @hidden */
  53054. _checkGamepadsStatus(): void;
  53055. private _updateGamepadObjects;
  53056. }
  53057. }
  53058. declare module BABYLON {
  53059. interface Scene {
  53060. /** @hidden */
  53061. _gamepadManager: Nullable<GamepadManager>;
  53062. /**
  53063. * Gets the gamepad manager associated with the scene
  53064. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53065. */
  53066. gamepadManager: GamepadManager;
  53067. }
  53068. /**
  53069. * Interface representing a free camera inputs manager
  53070. */
  53071. interface FreeCameraInputsManager {
  53072. /**
  53073. * Adds gamepad input support to the FreeCameraInputsManager.
  53074. * @returns the FreeCameraInputsManager
  53075. */
  53076. addGamepad(): FreeCameraInputsManager;
  53077. }
  53078. /**
  53079. * Interface representing an arc rotate camera inputs manager
  53080. */
  53081. interface ArcRotateCameraInputsManager {
  53082. /**
  53083. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53084. * @returns the camera inputs manager
  53085. */
  53086. addGamepad(): ArcRotateCameraInputsManager;
  53087. }
  53088. /**
  53089. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53090. */
  53091. export class GamepadSystemSceneComponent implements ISceneComponent {
  53092. /**
  53093. * The component name helpfull to identify the component in the list of scene components.
  53094. */
  53095. readonly name: string;
  53096. /**
  53097. * The scene the component belongs to.
  53098. */
  53099. scene: Scene;
  53100. /**
  53101. * Creates a new instance of the component for the given scene
  53102. * @param scene Defines the scene to register the component in
  53103. */
  53104. constructor(scene: Scene);
  53105. /**
  53106. * Registers the component in a given scene
  53107. */
  53108. register(): void;
  53109. /**
  53110. * Rebuilds the elements related to this component in case of
  53111. * context lost for instance.
  53112. */
  53113. rebuild(): void;
  53114. /**
  53115. * Disposes the component and the associated ressources
  53116. */
  53117. dispose(): void;
  53118. private _beforeCameraUpdate;
  53119. }
  53120. }
  53121. declare module BABYLON {
  53122. /**
  53123. * 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,
  53124. * which still works and will still be found in many Playgrounds.
  53125. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53126. */
  53127. export class UniversalCamera extends TouchCamera {
  53128. /**
  53129. * Defines the gamepad rotation sensiblity.
  53130. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53131. */
  53132. get gamepadAngularSensibility(): number;
  53133. set gamepadAngularSensibility(value: number);
  53134. /**
  53135. * Defines the gamepad move sensiblity.
  53136. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53137. */
  53138. get gamepadMoveSensibility(): number;
  53139. set gamepadMoveSensibility(value: number);
  53140. /**
  53141. * 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,
  53142. * which still works and will still be found in many Playgrounds.
  53143. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53144. * @param name Define the name of the camera in the scene
  53145. * @param position Define the start position of the camera in the scene
  53146. * @param scene Define the scene the camera belongs to
  53147. */
  53148. constructor(name: string, position: Vector3, scene: Scene);
  53149. /**
  53150. * Gets the current object class name.
  53151. * @return the class name
  53152. */
  53153. getClassName(): string;
  53154. }
  53155. }
  53156. declare module BABYLON {
  53157. /**
  53158. * This represents a FPS type of camera. This is only here for back compat purpose.
  53159. * Please use the UniversalCamera instead as both are identical.
  53160. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53161. */
  53162. export class GamepadCamera extends UniversalCamera {
  53163. /**
  53164. * Instantiates a new Gamepad Camera
  53165. * This represents a FPS type of camera. This is only here for back compat purpose.
  53166. * Please use the UniversalCamera instead as both are identical.
  53167. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53168. * @param name Define the name of the camera in the scene
  53169. * @param position Define the start position of the camera in the scene
  53170. * @param scene Define the scene the camera belongs to
  53171. */
  53172. constructor(name: string, position: Vector3, scene: Scene);
  53173. /**
  53174. * Gets the current object class name.
  53175. * @return the class name
  53176. */
  53177. getClassName(): string;
  53178. }
  53179. }
  53180. declare module BABYLON {
  53181. /** @hidden */
  53182. export var anaglyphPixelShader: {
  53183. name: string;
  53184. shader: string;
  53185. };
  53186. }
  53187. declare module BABYLON {
  53188. /**
  53189. * Postprocess used to generate anaglyphic rendering
  53190. */
  53191. export class AnaglyphPostProcess extends PostProcess {
  53192. private _passedProcess;
  53193. /**
  53194. * Gets a string identifying the name of the class
  53195. * @returns "AnaglyphPostProcess" string
  53196. */
  53197. getClassName(): string;
  53198. /**
  53199. * Creates a new AnaglyphPostProcess
  53200. * @param name defines postprocess name
  53201. * @param options defines creation options or target ratio scale
  53202. * @param rigCameras defines cameras using this postprocess
  53203. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53204. * @param engine defines hosting engine
  53205. * @param reusable defines if the postprocess will be reused multiple times per frame
  53206. */
  53207. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53208. }
  53209. }
  53210. declare module BABYLON {
  53211. /**
  53212. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53213. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53214. */
  53215. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53216. /**
  53217. * Creates a new AnaglyphArcRotateCamera
  53218. * @param name defines camera name
  53219. * @param alpha defines alpha angle (in radians)
  53220. * @param beta defines beta angle (in radians)
  53221. * @param radius defines radius
  53222. * @param target defines camera target
  53223. * @param interaxialDistance defines distance between each color axis
  53224. * @param scene defines the hosting scene
  53225. */
  53226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53227. /**
  53228. * Gets camera class name
  53229. * @returns AnaglyphArcRotateCamera
  53230. */
  53231. getClassName(): string;
  53232. }
  53233. }
  53234. declare module BABYLON {
  53235. /**
  53236. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53237. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53238. */
  53239. export class AnaglyphFreeCamera extends FreeCamera {
  53240. /**
  53241. * Creates a new AnaglyphFreeCamera
  53242. * @param name defines camera name
  53243. * @param position defines initial position
  53244. * @param interaxialDistance defines distance between each color axis
  53245. * @param scene defines the hosting scene
  53246. */
  53247. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53248. /**
  53249. * Gets camera class name
  53250. * @returns AnaglyphFreeCamera
  53251. */
  53252. getClassName(): string;
  53253. }
  53254. }
  53255. declare module BABYLON {
  53256. /**
  53257. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53258. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53259. */
  53260. export class AnaglyphGamepadCamera extends GamepadCamera {
  53261. /**
  53262. * Creates a new AnaglyphGamepadCamera
  53263. * @param name defines camera name
  53264. * @param position defines initial position
  53265. * @param interaxialDistance defines distance between each color axis
  53266. * @param scene defines the hosting scene
  53267. */
  53268. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53269. /**
  53270. * Gets camera class name
  53271. * @returns AnaglyphGamepadCamera
  53272. */
  53273. getClassName(): string;
  53274. }
  53275. }
  53276. declare module BABYLON {
  53277. /**
  53278. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53279. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53280. */
  53281. export class AnaglyphUniversalCamera extends UniversalCamera {
  53282. /**
  53283. * Creates a new AnaglyphUniversalCamera
  53284. * @param name defines camera name
  53285. * @param position defines initial position
  53286. * @param interaxialDistance defines distance between each color axis
  53287. * @param scene defines the hosting scene
  53288. */
  53289. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53290. /**
  53291. * Gets camera class name
  53292. * @returns AnaglyphUniversalCamera
  53293. */
  53294. getClassName(): string;
  53295. }
  53296. }
  53297. declare module BABYLON {
  53298. /** @hidden */
  53299. export var stereoscopicInterlacePixelShader: {
  53300. name: string;
  53301. shader: string;
  53302. };
  53303. }
  53304. declare module BABYLON {
  53305. /**
  53306. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53307. */
  53308. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53309. private _stepSize;
  53310. private _passedProcess;
  53311. /**
  53312. * Gets a string identifying the name of the class
  53313. * @returns "StereoscopicInterlacePostProcessI" string
  53314. */
  53315. getClassName(): string;
  53316. /**
  53317. * Initializes a StereoscopicInterlacePostProcessI
  53318. * @param name The name of the effect.
  53319. * @param rigCameras The rig cameras to be applied to the post process
  53320. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53321. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53323. * @param engine The engine which the post process will be applied. (default: current engine)
  53324. * @param reusable If the post process can be reused on the same frame. (default: false)
  53325. */
  53326. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53327. }
  53328. /**
  53329. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53330. */
  53331. export class StereoscopicInterlacePostProcess extends PostProcess {
  53332. private _stepSize;
  53333. private _passedProcess;
  53334. /**
  53335. * Gets a string identifying the name of the class
  53336. * @returns "StereoscopicInterlacePostProcess" string
  53337. */
  53338. getClassName(): string;
  53339. /**
  53340. * Initializes a StereoscopicInterlacePostProcess
  53341. * @param name The name of the effect.
  53342. * @param rigCameras The rig cameras to be applied to the post process
  53343. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53345. * @param engine The engine which the post process will be applied. (default: current engine)
  53346. * @param reusable If the post process can be reused on the same frame. (default: false)
  53347. */
  53348. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53349. }
  53350. }
  53351. declare module BABYLON {
  53352. /**
  53353. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53354. * @see https://doc.babylonjs.com/features/cameras
  53355. */
  53356. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53357. /**
  53358. * Creates a new StereoscopicArcRotateCamera
  53359. * @param name defines camera name
  53360. * @param alpha defines alpha angle (in radians)
  53361. * @param beta defines beta angle (in radians)
  53362. * @param radius defines radius
  53363. * @param target defines camera target
  53364. * @param interaxialDistance defines distance between each color axis
  53365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53366. * @param scene defines the hosting scene
  53367. */
  53368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53369. /**
  53370. * Gets camera class name
  53371. * @returns StereoscopicArcRotateCamera
  53372. */
  53373. getClassName(): string;
  53374. }
  53375. }
  53376. declare module BABYLON {
  53377. /**
  53378. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53379. * @see https://doc.babylonjs.com/features/cameras
  53380. */
  53381. export class StereoscopicFreeCamera extends FreeCamera {
  53382. /**
  53383. * Creates a new StereoscopicFreeCamera
  53384. * @param name defines camera name
  53385. * @param position defines initial position
  53386. * @param interaxialDistance defines distance between each color axis
  53387. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53388. * @param scene defines the hosting scene
  53389. */
  53390. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53391. /**
  53392. * Gets camera class name
  53393. * @returns StereoscopicFreeCamera
  53394. */
  53395. getClassName(): string;
  53396. }
  53397. }
  53398. declare module BABYLON {
  53399. /**
  53400. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53401. * @see https://doc.babylonjs.com/features/cameras
  53402. */
  53403. export class StereoscopicGamepadCamera extends GamepadCamera {
  53404. /**
  53405. * Creates a new StereoscopicGamepadCamera
  53406. * @param name defines camera name
  53407. * @param position defines initial position
  53408. * @param interaxialDistance defines distance between each color axis
  53409. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53410. * @param scene defines the hosting scene
  53411. */
  53412. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53413. /**
  53414. * Gets camera class name
  53415. * @returns StereoscopicGamepadCamera
  53416. */
  53417. getClassName(): string;
  53418. }
  53419. }
  53420. declare module BABYLON {
  53421. /**
  53422. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53423. * @see https://doc.babylonjs.com/features/cameras
  53424. */
  53425. export class StereoscopicUniversalCamera extends UniversalCamera {
  53426. /**
  53427. * Creates a new StereoscopicUniversalCamera
  53428. * @param name defines camera name
  53429. * @param position defines initial position
  53430. * @param interaxialDistance defines distance between each color axis
  53431. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53432. * @param scene defines the hosting scene
  53433. */
  53434. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53435. /**
  53436. * Gets camera class name
  53437. * @returns StereoscopicUniversalCamera
  53438. */
  53439. getClassName(): string;
  53440. }
  53441. }
  53442. declare module BABYLON {
  53443. /**
  53444. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53445. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53446. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53447. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53448. */
  53449. export class VirtualJoysticksCamera extends FreeCamera {
  53450. /**
  53451. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53452. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53453. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53454. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53455. * @param name Define the name of the camera in the scene
  53456. * @param position Define the start position of the camera in the scene
  53457. * @param scene Define the scene the camera belongs to
  53458. */
  53459. constructor(name: string, position: Vector3, scene: Scene);
  53460. /**
  53461. * Gets the current object class name.
  53462. * @return the class name
  53463. */
  53464. getClassName(): string;
  53465. }
  53466. }
  53467. declare module BABYLON {
  53468. /**
  53469. * This represents all the required metrics to create a VR camera.
  53470. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53471. */
  53472. export class VRCameraMetrics {
  53473. /**
  53474. * Define the horizontal resolution off the screen.
  53475. */
  53476. hResolution: number;
  53477. /**
  53478. * Define the vertical resolution off the screen.
  53479. */
  53480. vResolution: number;
  53481. /**
  53482. * Define the horizontal screen size.
  53483. */
  53484. hScreenSize: number;
  53485. /**
  53486. * Define the vertical screen size.
  53487. */
  53488. vScreenSize: number;
  53489. /**
  53490. * Define the vertical screen center position.
  53491. */
  53492. vScreenCenter: number;
  53493. /**
  53494. * Define the distance of the eyes to the screen.
  53495. */
  53496. eyeToScreenDistance: number;
  53497. /**
  53498. * Define the distance between both lenses
  53499. */
  53500. lensSeparationDistance: number;
  53501. /**
  53502. * Define the distance between both viewer's eyes.
  53503. */
  53504. interpupillaryDistance: number;
  53505. /**
  53506. * Define the distortion factor of the VR postprocess.
  53507. * Please, touch with care.
  53508. */
  53509. distortionK: number[];
  53510. /**
  53511. * Define the chromatic aberration correction factors for the VR post process.
  53512. */
  53513. chromaAbCorrection: number[];
  53514. /**
  53515. * Define the scale factor of the post process.
  53516. * The smaller the better but the slower.
  53517. */
  53518. postProcessScaleFactor: number;
  53519. /**
  53520. * Define an offset for the lens center.
  53521. */
  53522. lensCenterOffset: number;
  53523. /**
  53524. * Define if the current vr camera should compensate the distortion of the lens or not.
  53525. */
  53526. compensateDistortion: boolean;
  53527. /**
  53528. * Defines if multiview should be enabled when rendering (Default: false)
  53529. */
  53530. multiviewEnabled: boolean;
  53531. /**
  53532. * Gets the rendering aspect ratio based on the provided resolutions.
  53533. */
  53534. get aspectRatio(): number;
  53535. /**
  53536. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53537. */
  53538. get aspectRatioFov(): number;
  53539. /**
  53540. * @hidden
  53541. */
  53542. get leftHMatrix(): Matrix;
  53543. /**
  53544. * @hidden
  53545. */
  53546. get rightHMatrix(): Matrix;
  53547. /**
  53548. * @hidden
  53549. */
  53550. get leftPreViewMatrix(): Matrix;
  53551. /**
  53552. * @hidden
  53553. */
  53554. get rightPreViewMatrix(): Matrix;
  53555. /**
  53556. * Get the default VRMetrics based on the most generic setup.
  53557. * @returns the default vr metrics
  53558. */
  53559. static GetDefault(): VRCameraMetrics;
  53560. }
  53561. }
  53562. declare module BABYLON {
  53563. /** @hidden */
  53564. export var vrDistortionCorrectionPixelShader: {
  53565. name: string;
  53566. shader: string;
  53567. };
  53568. }
  53569. declare module BABYLON {
  53570. /**
  53571. * VRDistortionCorrectionPostProcess used for mobile VR
  53572. */
  53573. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53574. private _isRightEye;
  53575. private _distortionFactors;
  53576. private _postProcessScaleFactor;
  53577. private _lensCenterOffset;
  53578. private _scaleIn;
  53579. private _scaleFactor;
  53580. private _lensCenter;
  53581. /**
  53582. * Gets a string identifying the name of the class
  53583. * @returns "VRDistortionCorrectionPostProcess" string
  53584. */
  53585. getClassName(): string;
  53586. /**
  53587. * Initializes the VRDistortionCorrectionPostProcess
  53588. * @param name The name of the effect.
  53589. * @param camera The camera to apply the render pass to.
  53590. * @param isRightEye If this is for the right eye distortion
  53591. * @param vrMetrics All the required metrics for the VR camera
  53592. */
  53593. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53594. }
  53595. }
  53596. declare module BABYLON {
  53597. /**
  53598. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53599. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53600. */
  53601. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53602. /**
  53603. * Creates a new VRDeviceOrientationArcRotateCamera
  53604. * @param name defines camera name
  53605. * @param alpha defines the camera rotation along the longitudinal axis
  53606. * @param beta defines the camera rotation along the latitudinal axis
  53607. * @param radius defines the camera distance from its target
  53608. * @param target defines the camera target
  53609. * @param scene defines the scene the camera belongs to
  53610. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53611. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53612. */
  53613. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53614. /**
  53615. * Gets camera class name
  53616. * @returns VRDeviceOrientationArcRotateCamera
  53617. */
  53618. getClassName(): string;
  53619. }
  53620. }
  53621. declare module BABYLON {
  53622. /**
  53623. * Camera used to simulate VR rendering (based on FreeCamera)
  53624. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53625. */
  53626. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53627. /**
  53628. * Creates a new VRDeviceOrientationFreeCamera
  53629. * @param name defines camera name
  53630. * @param position defines the start position of the camera
  53631. * @param scene defines the scene the camera belongs to
  53632. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53633. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53634. */
  53635. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53636. /**
  53637. * Gets camera class name
  53638. * @returns VRDeviceOrientationFreeCamera
  53639. */
  53640. getClassName(): string;
  53641. }
  53642. }
  53643. declare module BABYLON {
  53644. /**
  53645. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53646. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53647. */
  53648. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53649. /**
  53650. * Creates a new VRDeviceOrientationGamepadCamera
  53651. * @param name defines camera name
  53652. * @param position defines the start position of the camera
  53653. * @param scene defines the scene the camera belongs to
  53654. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53655. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53656. */
  53657. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53658. /**
  53659. * Gets camera class name
  53660. * @returns VRDeviceOrientationGamepadCamera
  53661. */
  53662. getClassName(): string;
  53663. }
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * A class extending Texture allowing drawing on a texture
  53668. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53669. */
  53670. export class DynamicTexture extends Texture {
  53671. private _generateMipMaps;
  53672. private _canvas;
  53673. private _context;
  53674. /**
  53675. * Creates a DynamicTexture
  53676. * @param name defines the name of the texture
  53677. * @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
  53678. * @param scene defines the scene where you want the texture
  53679. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53680. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53681. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53682. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53683. */
  53684. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53685. /**
  53686. * Get the current class name of the texture useful for serialization or dynamic coding.
  53687. * @returns "DynamicTexture"
  53688. */
  53689. getClassName(): string;
  53690. /**
  53691. * Gets the current state of canRescale
  53692. */
  53693. get canRescale(): boolean;
  53694. private _recreate;
  53695. /**
  53696. * Scales the texture
  53697. * @param ratio the scale factor to apply to both width and height
  53698. */
  53699. scale(ratio: number): void;
  53700. /**
  53701. * Resizes the texture
  53702. * @param width the new width
  53703. * @param height the new height
  53704. */
  53705. scaleTo(width: number, height: number): void;
  53706. /**
  53707. * Gets the context of the canvas used by the texture
  53708. * @returns the canvas context of the dynamic texture
  53709. */
  53710. getContext(): CanvasRenderingContext2D;
  53711. /**
  53712. * Clears the texture
  53713. */
  53714. clear(): void;
  53715. /**
  53716. * Updates the texture
  53717. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53718. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53719. */
  53720. update(invertY?: boolean, premulAlpha?: boolean): void;
  53721. /**
  53722. * Draws text onto the texture
  53723. * @param text defines the text to be drawn
  53724. * @param x defines the placement of the text from the left
  53725. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53726. * @param font defines the font to be used with font-style, font-size, font-name
  53727. * @param color defines the color used for the text
  53728. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53729. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53730. * @param update defines whether texture is immediately update (default is true)
  53731. */
  53732. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53733. /**
  53734. * Clones the texture
  53735. * @returns the clone of the texture.
  53736. */
  53737. clone(): DynamicTexture;
  53738. /**
  53739. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53740. * @returns a serialized dynamic texture object
  53741. */
  53742. serialize(): any;
  53743. private _IsCanvasElement;
  53744. /** @hidden */
  53745. _rebuild(): void;
  53746. }
  53747. }
  53748. declare module BABYLON {
  53749. /**
  53750. * Class containing static functions to help procedurally build meshes
  53751. */
  53752. export class GroundBuilder {
  53753. /**
  53754. * Creates a ground mesh
  53755. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53756. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53758. * @param name defines the name of the mesh
  53759. * @param options defines the options used to create the mesh
  53760. * @param scene defines the hosting scene
  53761. * @returns the ground mesh
  53762. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53763. */
  53764. static CreateGround(name: string, options: {
  53765. width?: number;
  53766. height?: number;
  53767. subdivisions?: number;
  53768. subdivisionsX?: number;
  53769. subdivisionsY?: number;
  53770. updatable?: boolean;
  53771. }, scene: any): Mesh;
  53772. /**
  53773. * Creates a tiled ground mesh
  53774. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53775. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53776. * * 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
  53777. * * 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
  53778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53779. * @param name defines the name of the mesh
  53780. * @param options defines the options used to create the mesh
  53781. * @param scene defines the hosting scene
  53782. * @returns the tiled ground mesh
  53783. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53784. */
  53785. static CreateTiledGround(name: string, options: {
  53786. xmin: number;
  53787. zmin: number;
  53788. xmax: number;
  53789. zmax: number;
  53790. subdivisions?: {
  53791. w: number;
  53792. h: number;
  53793. };
  53794. precision?: {
  53795. w: number;
  53796. h: number;
  53797. };
  53798. updatable?: boolean;
  53799. }, scene?: Nullable<Scene>): Mesh;
  53800. /**
  53801. * Creates a ground mesh from a height map
  53802. * * The parameter `url` sets the URL of the height map image resource.
  53803. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53804. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53805. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53806. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53807. * * 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.
  53808. * * 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).
  53809. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53811. * @param name defines the name of the mesh
  53812. * @param url defines the url to the height map
  53813. * @param options defines the options used to create the mesh
  53814. * @param scene defines the hosting scene
  53815. * @returns the ground mesh
  53816. * @see https://doc.babylonjs.com/babylon101/height_map
  53817. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53818. */
  53819. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53820. width?: number;
  53821. height?: number;
  53822. subdivisions?: number;
  53823. minHeight?: number;
  53824. maxHeight?: number;
  53825. colorFilter?: Color3;
  53826. alphaFilter?: number;
  53827. updatable?: boolean;
  53828. onReady?: (mesh: GroundMesh) => void;
  53829. }, scene?: Nullable<Scene>): GroundMesh;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. /**
  53834. * Class containing static functions to help procedurally build meshes
  53835. */
  53836. export class TorusBuilder {
  53837. /**
  53838. * Creates a torus mesh
  53839. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53840. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53841. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53843. * * 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
  53844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53845. * @param name defines the name of the mesh
  53846. * @param options defines the options used to create the mesh
  53847. * @param scene defines the hosting scene
  53848. * @returns the torus mesh
  53849. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53850. */
  53851. static CreateTorus(name: string, options: {
  53852. diameter?: number;
  53853. thickness?: number;
  53854. tessellation?: number;
  53855. updatable?: boolean;
  53856. sideOrientation?: number;
  53857. frontUVs?: Vector4;
  53858. backUVs?: Vector4;
  53859. }, scene: any): Mesh;
  53860. }
  53861. }
  53862. declare module BABYLON {
  53863. /**
  53864. * Class containing static functions to help procedurally build meshes
  53865. */
  53866. export class CylinderBuilder {
  53867. /**
  53868. * Creates a cylinder or a cone mesh
  53869. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53870. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53871. * * 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.
  53872. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53873. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53874. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53875. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53876. * * 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).
  53877. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53878. * * 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).
  53879. * * 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
  53880. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53881. * * 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
  53882. * * 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.
  53883. * * If `enclose` is false, a ring surface is one element.
  53884. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53885. * * 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
  53886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53887. * * 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
  53888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53889. * @param name defines the name of the mesh
  53890. * @param options defines the options used to create the mesh
  53891. * @param scene defines the hosting scene
  53892. * @returns the cylinder mesh
  53893. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53894. */
  53895. static CreateCylinder(name: string, options: {
  53896. height?: number;
  53897. diameterTop?: number;
  53898. diameterBottom?: number;
  53899. diameter?: number;
  53900. tessellation?: number;
  53901. subdivisions?: number;
  53902. arc?: number;
  53903. faceColors?: Color4[];
  53904. faceUV?: Vector4[];
  53905. updatable?: boolean;
  53906. hasRings?: boolean;
  53907. enclose?: boolean;
  53908. cap?: number;
  53909. sideOrientation?: number;
  53910. frontUVs?: Vector4;
  53911. backUVs?: Vector4;
  53912. }, scene: any): Mesh;
  53913. }
  53914. }
  53915. declare module BABYLON {
  53916. /**
  53917. * States of the webXR experience
  53918. */
  53919. export enum WebXRState {
  53920. /**
  53921. * Transitioning to being in XR mode
  53922. */
  53923. ENTERING_XR = 0,
  53924. /**
  53925. * Transitioning to non XR mode
  53926. */
  53927. EXITING_XR = 1,
  53928. /**
  53929. * In XR mode and presenting
  53930. */
  53931. IN_XR = 2,
  53932. /**
  53933. * Not entered XR mode
  53934. */
  53935. NOT_IN_XR = 3
  53936. }
  53937. /**
  53938. * The state of the XR camera's tracking
  53939. */
  53940. export enum WebXRTrackingState {
  53941. /**
  53942. * No transformation received, device is not being tracked
  53943. */
  53944. NOT_TRACKING = 0,
  53945. /**
  53946. * Tracking lost - using emulated position
  53947. */
  53948. TRACKING_LOST = 1,
  53949. /**
  53950. * Transformation tracking works normally
  53951. */
  53952. TRACKING = 2
  53953. }
  53954. /**
  53955. * Abstraction of the XR render target
  53956. */
  53957. export interface WebXRRenderTarget extends IDisposable {
  53958. /**
  53959. * xrpresent context of the canvas which can be used to display/mirror xr content
  53960. */
  53961. canvasContext: WebGLRenderingContext;
  53962. /**
  53963. * xr layer for the canvas
  53964. */
  53965. xrLayer: Nullable<XRWebGLLayer>;
  53966. /**
  53967. * Initializes the xr layer for the session
  53968. * @param xrSession xr session
  53969. * @returns a promise that will resolve once the XR Layer has been created
  53970. */
  53971. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53972. }
  53973. }
  53974. declare module BABYLON {
  53975. /**
  53976. * Configuration object for WebXR output canvas
  53977. */
  53978. export class WebXRManagedOutputCanvasOptions {
  53979. /**
  53980. * An optional canvas in case you wish to create it yourself and provide it here.
  53981. * If not provided, a new canvas will be created
  53982. */
  53983. canvasElement?: HTMLCanvasElement;
  53984. /**
  53985. * Options for this XR Layer output
  53986. */
  53987. canvasOptions?: XRWebGLLayerInit;
  53988. /**
  53989. * CSS styling for a newly created canvas (if not provided)
  53990. */
  53991. newCanvasCssStyle?: string;
  53992. /**
  53993. * Get the default values of the configuration object
  53994. * @param engine defines the engine to use (can be null)
  53995. * @returns default values of this configuration object
  53996. */
  53997. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53998. }
  53999. /**
  54000. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  54001. */
  54002. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  54003. private _options;
  54004. private _canvas;
  54005. private _engine;
  54006. private _originalCanvasSize;
  54007. /**
  54008. * Rendering context of the canvas which can be used to display/mirror xr content
  54009. */
  54010. canvasContext: WebGLRenderingContext;
  54011. /**
  54012. * xr layer for the canvas
  54013. */
  54014. xrLayer: Nullable<XRWebGLLayer>;
  54015. /**
  54016. * Observers registered here will be triggered when the xr layer was initialized
  54017. */
  54018. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  54019. /**
  54020. * Initializes the canvas to be added/removed upon entering/exiting xr
  54021. * @param _xrSessionManager The XR Session manager
  54022. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54023. */
  54024. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54025. /**
  54026. * Disposes of the object
  54027. */
  54028. dispose(): void;
  54029. /**
  54030. * Initializes the xr layer for the session
  54031. * @param xrSession xr session
  54032. * @returns a promise that will resolve once the XR Layer has been created
  54033. */
  54034. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54035. private _addCanvas;
  54036. private _removeCanvas;
  54037. private _setCanvasSize;
  54038. private _setManagedOutputCanvas;
  54039. }
  54040. }
  54041. declare module BABYLON {
  54042. /**
  54043. * Manages an XRSession to work with Babylon's engine
  54044. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54045. */
  54046. export class WebXRSessionManager implements IDisposable {
  54047. /** The scene which the session should be created for */
  54048. scene: Scene;
  54049. private _referenceSpace;
  54050. private _rttProvider;
  54051. private _sessionEnded;
  54052. private _xrNavigator;
  54053. private baseLayer;
  54054. /**
  54055. * The base reference space from which the session started. good if you want to reset your
  54056. * reference space
  54057. */
  54058. baseReferenceSpace: XRReferenceSpace;
  54059. /**
  54060. * Current XR frame
  54061. */
  54062. currentFrame: Nullable<XRFrame>;
  54063. /** WebXR timestamp updated every frame */
  54064. currentTimestamp: number;
  54065. /**
  54066. * Used just in case of a failure to initialize an immersive session.
  54067. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54068. */
  54069. defaultHeightCompensation: number;
  54070. /**
  54071. * Fires every time a new xrFrame arrives which can be used to update the camera
  54072. */
  54073. onXRFrameObservable: Observable<XRFrame>;
  54074. /**
  54075. * Fires when the reference space changed
  54076. */
  54077. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54078. /**
  54079. * Fires when the xr session is ended either by the device or manually done
  54080. */
  54081. onXRSessionEnded: Observable<any>;
  54082. /**
  54083. * Fires when the xr session is ended either by the device or manually done
  54084. */
  54085. onXRSessionInit: Observable<XRSession>;
  54086. /**
  54087. * Underlying xr session
  54088. */
  54089. session: XRSession;
  54090. /**
  54091. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54092. * or get the offset the player is currently at.
  54093. */
  54094. viewerReferenceSpace: XRReferenceSpace;
  54095. /**
  54096. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54097. * @param scene The scene which the session should be created for
  54098. */
  54099. constructor(
  54100. /** The scene which the session should be created for */
  54101. scene: Scene);
  54102. /**
  54103. * The current reference space used in this session. This reference space can constantly change!
  54104. * It is mainly used to offset the camera's position.
  54105. */
  54106. get referenceSpace(): XRReferenceSpace;
  54107. /**
  54108. * Set a new reference space and triggers the observable
  54109. */
  54110. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54111. /**
  54112. * Disposes of the session manager
  54113. */
  54114. dispose(): void;
  54115. /**
  54116. * Stops the xrSession and restores the render loop
  54117. * @returns Promise which resolves after it exits XR
  54118. */
  54119. exitXRAsync(): Promise<void>;
  54120. /**
  54121. * Gets the correct render target texture to be rendered this frame for this eye
  54122. * @param eye the eye for which to get the render target
  54123. * @returns the render target for the specified eye
  54124. */
  54125. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54126. /**
  54127. * Creates a WebXRRenderTarget object for the XR session
  54128. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54129. * @param options optional options to provide when creating a new render target
  54130. * @returns a WebXR render target to which the session can render
  54131. */
  54132. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54133. /**
  54134. * Initializes the manager
  54135. * After initialization enterXR can be called to start an XR session
  54136. * @returns Promise which resolves after it is initialized
  54137. */
  54138. initializeAsync(): Promise<void>;
  54139. /**
  54140. * Initializes an xr session
  54141. * @param xrSessionMode mode to initialize
  54142. * @param xrSessionInit defines optional and required values to pass to the session builder
  54143. * @returns a promise which will resolve once the session has been initialized
  54144. */
  54145. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54146. /**
  54147. * Checks if a session would be supported for the creation options specified
  54148. * @param sessionMode session mode to check if supported eg. immersive-vr
  54149. * @returns A Promise that resolves to true if supported and false if not
  54150. */
  54151. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54152. /**
  54153. * Resets the reference space to the one started the session
  54154. */
  54155. resetReferenceSpace(): void;
  54156. /**
  54157. * Starts rendering to the xr layer
  54158. */
  54159. runXRRenderLoop(): void;
  54160. /**
  54161. * Sets the reference space on the xr session
  54162. * @param referenceSpaceType space to set
  54163. * @returns a promise that will resolve once the reference space has been set
  54164. */
  54165. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54166. /**
  54167. * Updates the render state of the session
  54168. * @param state state to set
  54169. * @returns a promise that resolves once the render state has been updated
  54170. */
  54171. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54172. /**
  54173. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54174. * @param sessionMode defines the session to test
  54175. * @returns a promise with boolean as final value
  54176. */
  54177. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54178. /**
  54179. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54180. */
  54181. get isNative(): boolean;
  54182. private _createRenderTargetTexture;
  54183. }
  54184. }
  54185. declare module BABYLON {
  54186. /**
  54187. * WebXR Camera which holds the views for the xrSession
  54188. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54189. */
  54190. export class WebXRCamera extends FreeCamera {
  54191. private _xrSessionManager;
  54192. private _firstFrame;
  54193. private _referenceQuaternion;
  54194. private _referencedPosition;
  54195. private _xrInvPositionCache;
  54196. private _xrInvQuaternionCache;
  54197. private _trackingState;
  54198. /**
  54199. * Observable raised before camera teleportation
  54200. */
  54201. onBeforeCameraTeleport: Observable<Vector3>;
  54202. /**
  54203. * Observable raised after camera teleportation
  54204. */
  54205. onAfterCameraTeleport: Observable<Vector3>;
  54206. /**
  54207. * Notifies when the camera's tracking state has changed.
  54208. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54209. */
  54210. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54211. /**
  54212. * Should position compensation execute on first frame.
  54213. * This is used when copying the position from a native (non XR) camera
  54214. */
  54215. compensateOnFirstFrame: boolean;
  54216. /**
  54217. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54218. * @param name the name of the camera
  54219. * @param scene the scene to add the camera to
  54220. * @param _xrSessionManager a constructed xr session manager
  54221. */
  54222. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54223. /**
  54224. * Get the current XR tracking state of the camera
  54225. */
  54226. get trackingState(): WebXRTrackingState;
  54227. private _setTrackingState;
  54228. /**
  54229. * Return the user's height, unrelated to the current ground.
  54230. * This will be the y position of this camera, when ground level is 0.
  54231. */
  54232. get realWorldHeight(): number;
  54233. /** @hidden */
  54234. _updateForDualEyeDebugging(): void;
  54235. /**
  54236. * Sets this camera's transformation based on a non-vr camera
  54237. * @param otherCamera the non-vr camera to copy the transformation from
  54238. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54239. */
  54240. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54241. /**
  54242. * Gets the current instance class name ("WebXRCamera").
  54243. * @returns the class name
  54244. */
  54245. getClassName(): string;
  54246. private _rotate180;
  54247. private _updateFromXRSession;
  54248. private _updateNumberOfRigCameras;
  54249. private _updateReferenceSpace;
  54250. private _updateReferenceSpaceOffset;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * Defining the interface required for a (webxr) feature
  54256. */
  54257. export interface IWebXRFeature extends IDisposable {
  54258. /**
  54259. * Is this feature attached
  54260. */
  54261. attached: boolean;
  54262. /**
  54263. * Should auto-attach be disabled?
  54264. */
  54265. disableAutoAttach: boolean;
  54266. /**
  54267. * Attach the feature to the session
  54268. * Will usually be called by the features manager
  54269. *
  54270. * @param force should attachment be forced (even when already attached)
  54271. * @returns true if successful.
  54272. */
  54273. attach(force?: boolean): boolean;
  54274. /**
  54275. * Detach the feature from the session
  54276. * Will usually be called by the features manager
  54277. *
  54278. * @returns true if successful.
  54279. */
  54280. detach(): boolean;
  54281. /**
  54282. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54283. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54284. *
  54285. * @returns whether or not the feature is compatible in this environment
  54286. */
  54287. isCompatible(): boolean;
  54288. /**
  54289. * Was this feature disposed;
  54290. */
  54291. isDisposed: boolean;
  54292. /**
  54293. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54294. */
  54295. xrNativeFeatureName?: string;
  54296. /**
  54297. * A list of (Babylon WebXR) features this feature depends on
  54298. */
  54299. dependsOn?: string[];
  54300. /**
  54301. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54302. */
  54303. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54304. }
  54305. /**
  54306. * A list of the currently available features without referencing them
  54307. */
  54308. export class WebXRFeatureName {
  54309. /**
  54310. * The name of the anchor system feature
  54311. */
  54312. static readonly ANCHOR_SYSTEM: string;
  54313. /**
  54314. * The name of the background remover feature
  54315. */
  54316. static readonly BACKGROUND_REMOVER: string;
  54317. /**
  54318. * The name of the hit test feature
  54319. */
  54320. static readonly HIT_TEST: string;
  54321. /**
  54322. * The name of the mesh detection feature
  54323. */
  54324. static readonly MESH_DETECTION: string;
  54325. /**
  54326. * physics impostors for xr controllers feature
  54327. */
  54328. static readonly PHYSICS_CONTROLLERS: string;
  54329. /**
  54330. * The name of the plane detection feature
  54331. */
  54332. static readonly PLANE_DETECTION: string;
  54333. /**
  54334. * The name of the pointer selection feature
  54335. */
  54336. static readonly POINTER_SELECTION: string;
  54337. /**
  54338. * The name of the teleportation feature
  54339. */
  54340. static readonly TELEPORTATION: string;
  54341. /**
  54342. * The name of the feature points feature.
  54343. */
  54344. static readonly FEATURE_POINTS: string;
  54345. /**
  54346. * The name of the hand tracking feature.
  54347. */
  54348. static readonly HAND_TRACKING: string;
  54349. /**
  54350. * The name of the image tracking feature
  54351. */
  54352. static readonly IMAGE_TRACKING: string;
  54353. }
  54354. /**
  54355. * Defining the constructor of a feature. Used to register the modules.
  54356. */
  54357. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54358. /**
  54359. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54360. * It is mainly used in AR sessions.
  54361. *
  54362. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54363. */
  54364. export class WebXRFeaturesManager implements IDisposable {
  54365. private _xrSessionManager;
  54366. private static readonly _AvailableFeatures;
  54367. private _features;
  54368. /**
  54369. * constructs a new features manages.
  54370. *
  54371. * @param _xrSessionManager an instance of WebXRSessionManager
  54372. */
  54373. constructor(_xrSessionManager: WebXRSessionManager);
  54374. /**
  54375. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54376. * Mainly used internally.
  54377. *
  54378. * @param featureName the name of the feature to register
  54379. * @param constructorFunction the function used to construct the module
  54380. * @param version the (babylon) version of the module
  54381. * @param stable is that a stable version of this module
  54382. */
  54383. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54384. /**
  54385. * Returns a constructor of a specific feature.
  54386. *
  54387. * @param featureName the name of the feature to construct
  54388. * @param version the version of the feature to load
  54389. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54390. * @param options optional options provided to the module.
  54391. * @returns a function that, when called, will return a new instance of this feature
  54392. */
  54393. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54394. /**
  54395. * Can be used to return the list of features currently registered
  54396. *
  54397. * @returns an Array of available features
  54398. */
  54399. static GetAvailableFeatures(): string[];
  54400. /**
  54401. * Gets the versions available for a specific feature
  54402. * @param featureName the name of the feature
  54403. * @returns an array with the available versions
  54404. */
  54405. static GetAvailableVersions(featureName: string): string[];
  54406. /**
  54407. * Return the latest unstable version of this feature
  54408. * @param featureName the name of the feature to search
  54409. * @returns the version number. if not found will return -1
  54410. */
  54411. static GetLatestVersionOfFeature(featureName: string): number;
  54412. /**
  54413. * Return the latest stable version of this feature
  54414. * @param featureName the name of the feature to search
  54415. * @returns the version number. if not found will return -1
  54416. */
  54417. static GetStableVersionOfFeature(featureName: string): number;
  54418. /**
  54419. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54420. * Can be used during a session to start a feature
  54421. * @param featureName the name of feature to attach
  54422. */
  54423. attachFeature(featureName: string): void;
  54424. /**
  54425. * Can be used inside a session or when the session ends to detach a specific feature
  54426. * @param featureName the name of the feature to detach
  54427. */
  54428. detachFeature(featureName: string): void;
  54429. /**
  54430. * Used to disable an already-enabled feature
  54431. * The feature will be disposed and will be recreated once enabled.
  54432. * @param featureName the feature to disable
  54433. * @returns true if disable was successful
  54434. */
  54435. disableFeature(featureName: string | {
  54436. Name: string;
  54437. }): boolean;
  54438. /**
  54439. * dispose this features manager
  54440. */
  54441. dispose(): void;
  54442. /**
  54443. * 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.
  54444. * 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.
  54445. *
  54446. * @param featureName the name of the feature to load or the class of the feature
  54447. * @param version optional version to load. if not provided the latest version will be enabled
  54448. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54449. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54450. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54451. * @returns a new constructed feature or throws an error if feature not found.
  54452. */
  54453. enableFeature(featureName: string | {
  54454. Name: string;
  54455. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54456. /**
  54457. * get the implementation of an enabled feature.
  54458. * @param featureName the name of the feature to load
  54459. * @returns the feature class, if found
  54460. */
  54461. getEnabledFeature(featureName: string): IWebXRFeature;
  54462. /**
  54463. * Get the list of enabled features
  54464. * @returns an array of enabled features
  54465. */
  54466. getEnabledFeatures(): string[];
  54467. /**
  54468. * This function will extend the session creation configuration object with enabled features.
  54469. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54470. * according to the defined "required" variable, provided during enableFeature call
  54471. * @param xrSessionInit the xr Session init object to extend
  54472. *
  54473. * @returns an extended XRSessionInit object
  54474. */
  54475. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54476. }
  54477. }
  54478. declare module BABYLON {
  54479. /**
  54480. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54481. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54482. */
  54483. export class WebXRExperienceHelper implements IDisposable {
  54484. private scene;
  54485. private _nonVRCamera;
  54486. private _originalSceneAutoClear;
  54487. private _supported;
  54488. /**
  54489. * Camera used to render xr content
  54490. */
  54491. camera: WebXRCamera;
  54492. /** A features manager for this xr session */
  54493. featuresManager: WebXRFeaturesManager;
  54494. /**
  54495. * Observers registered here will be triggered after the camera's initial transformation is set
  54496. * This can be used to set a different ground level or an extra rotation.
  54497. *
  54498. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54499. * to the position set after this observable is done executing.
  54500. */
  54501. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54502. /**
  54503. * Fires when the state of the experience helper has changed
  54504. */
  54505. onStateChangedObservable: Observable<WebXRState>;
  54506. /** Session manager used to keep track of xr session */
  54507. sessionManager: WebXRSessionManager;
  54508. /**
  54509. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54510. */
  54511. state: WebXRState;
  54512. /**
  54513. * Creates a WebXRExperienceHelper
  54514. * @param scene The scene the helper should be created in
  54515. */
  54516. private constructor();
  54517. /**
  54518. * Creates the experience helper
  54519. * @param scene the scene to attach the experience helper to
  54520. * @returns a promise for the experience helper
  54521. */
  54522. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54523. /**
  54524. * Disposes of the experience helper
  54525. */
  54526. dispose(): void;
  54527. /**
  54528. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54529. * @param sessionMode options for the XR session
  54530. * @param referenceSpaceType frame of reference of the XR session
  54531. * @param renderTarget the output canvas that will be used to enter XR mode
  54532. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54533. * @returns promise that resolves after xr mode has entered
  54534. */
  54535. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54536. /**
  54537. * Exits XR mode and returns the scene to its original state
  54538. * @returns promise that resolves after xr mode has exited
  54539. */
  54540. exitXRAsync(): Promise<void>;
  54541. private _nonXRToXRCamera;
  54542. private _setState;
  54543. }
  54544. }
  54545. declare module BABYLON {
  54546. /**
  54547. * X-Y values for axes in WebXR
  54548. */
  54549. export interface IWebXRMotionControllerAxesValue {
  54550. /**
  54551. * The value of the x axis
  54552. */
  54553. x: number;
  54554. /**
  54555. * The value of the y-axis
  54556. */
  54557. y: number;
  54558. }
  54559. /**
  54560. * changed / previous values for the values of this component
  54561. */
  54562. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54563. /**
  54564. * current (this frame) value
  54565. */
  54566. current: T;
  54567. /**
  54568. * previous (last change) value
  54569. */
  54570. previous: T;
  54571. }
  54572. /**
  54573. * Represents changes in the component between current frame and last values recorded
  54574. */
  54575. export interface IWebXRMotionControllerComponentChanges {
  54576. /**
  54577. * will be populated with previous and current values if axes changed
  54578. */
  54579. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54580. /**
  54581. * will be populated with previous and current values if pressed changed
  54582. */
  54583. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54584. /**
  54585. * will be populated with previous and current values if touched changed
  54586. */
  54587. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54588. /**
  54589. * will be populated with previous and current values if value changed
  54590. */
  54591. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54592. }
  54593. /**
  54594. * This class represents a single component (for example button or thumbstick) of a motion controller
  54595. */
  54596. export class WebXRControllerComponent implements IDisposable {
  54597. /**
  54598. * the id of this component
  54599. */
  54600. id: string;
  54601. /**
  54602. * the type of the component
  54603. */
  54604. type: MotionControllerComponentType;
  54605. private _buttonIndex;
  54606. private _axesIndices;
  54607. private _axes;
  54608. private _changes;
  54609. private _currentValue;
  54610. private _hasChanges;
  54611. private _pressed;
  54612. private _touched;
  54613. /**
  54614. * button component type
  54615. */
  54616. static BUTTON_TYPE: MotionControllerComponentType;
  54617. /**
  54618. * squeeze component type
  54619. */
  54620. static SQUEEZE_TYPE: MotionControllerComponentType;
  54621. /**
  54622. * Thumbstick component type
  54623. */
  54624. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54625. /**
  54626. * Touchpad component type
  54627. */
  54628. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54629. /**
  54630. * trigger component type
  54631. */
  54632. static TRIGGER_TYPE: MotionControllerComponentType;
  54633. /**
  54634. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54635. * the axes data changes
  54636. */
  54637. onAxisValueChangedObservable: Observable<{
  54638. x: number;
  54639. y: number;
  54640. }>;
  54641. /**
  54642. * Observers registered here will be triggered when the state of a button changes
  54643. * State change is either pressed / touched / value
  54644. */
  54645. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54646. /**
  54647. * Creates a new component for a motion controller.
  54648. * It is created by the motion controller itself
  54649. *
  54650. * @param id the id of this component
  54651. * @param type the type of the component
  54652. * @param _buttonIndex index in the buttons array of the gamepad
  54653. * @param _axesIndices indices of the values in the axes array of the gamepad
  54654. */
  54655. constructor(
  54656. /**
  54657. * the id of this component
  54658. */
  54659. id: string,
  54660. /**
  54661. * the type of the component
  54662. */
  54663. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54664. /**
  54665. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54666. */
  54667. get axes(): IWebXRMotionControllerAxesValue;
  54668. /**
  54669. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54670. */
  54671. get changes(): IWebXRMotionControllerComponentChanges;
  54672. /**
  54673. * Return whether or not the component changed the last frame
  54674. */
  54675. get hasChanges(): boolean;
  54676. /**
  54677. * is the button currently pressed
  54678. */
  54679. get pressed(): boolean;
  54680. /**
  54681. * is the button currently touched
  54682. */
  54683. get touched(): boolean;
  54684. /**
  54685. * Get the current value of this component
  54686. */
  54687. get value(): number;
  54688. /**
  54689. * Dispose this component
  54690. */
  54691. dispose(): void;
  54692. /**
  54693. * Are there axes correlating to this component
  54694. * @return true is axes data is available
  54695. */
  54696. isAxes(): boolean;
  54697. /**
  54698. * Is this component a button (hence - pressable)
  54699. * @returns true if can be pressed
  54700. */
  54701. isButton(): boolean;
  54702. /**
  54703. * update this component using the gamepad object it is in. Called on every frame
  54704. * @param nativeController the native gamepad controller object
  54705. */
  54706. update(nativeController: IMinimalMotionControllerObject): void;
  54707. }
  54708. }
  54709. declare module BABYLON {
  54710. /**
  54711. * Type used for the success callback of ImportMesh
  54712. */
  54713. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54714. /**
  54715. * Interface used for the result of ImportMeshAsync
  54716. */
  54717. export interface ISceneLoaderAsyncResult {
  54718. /**
  54719. * The array of loaded meshes
  54720. */
  54721. readonly meshes: AbstractMesh[];
  54722. /**
  54723. * The array of loaded particle systems
  54724. */
  54725. readonly particleSystems: IParticleSystem[];
  54726. /**
  54727. * The array of loaded skeletons
  54728. */
  54729. readonly skeletons: Skeleton[];
  54730. /**
  54731. * The array of loaded animation groups
  54732. */
  54733. readonly animationGroups: AnimationGroup[];
  54734. /**
  54735. * The array of loaded transform nodes
  54736. */
  54737. readonly transformNodes: TransformNode[];
  54738. /**
  54739. * The array of loaded geometries
  54740. */
  54741. readonly geometries: Geometry[];
  54742. /**
  54743. * The array of loaded lights
  54744. */
  54745. readonly lights: Light[];
  54746. }
  54747. /**
  54748. * Interface used to represent data loading progression
  54749. */
  54750. export interface ISceneLoaderProgressEvent {
  54751. /**
  54752. * Defines if data length to load can be evaluated
  54753. */
  54754. readonly lengthComputable: boolean;
  54755. /**
  54756. * Defines the loaded data length
  54757. */
  54758. readonly loaded: number;
  54759. /**
  54760. * Defines the data length to load
  54761. */
  54762. readonly total: number;
  54763. }
  54764. /**
  54765. * Interface used by SceneLoader plugins to define supported file extensions
  54766. */
  54767. export interface ISceneLoaderPluginExtensions {
  54768. /**
  54769. * Defines the list of supported extensions
  54770. */
  54771. [extension: string]: {
  54772. isBinary: boolean;
  54773. };
  54774. }
  54775. /**
  54776. * Interface used by SceneLoader plugin factory
  54777. */
  54778. export interface ISceneLoaderPluginFactory {
  54779. /**
  54780. * Defines the name of the factory
  54781. */
  54782. name: string;
  54783. /**
  54784. * Function called to create a new plugin
  54785. * @return the new plugin
  54786. */
  54787. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54788. /**
  54789. * The callback that returns true if the data can be directly loaded.
  54790. * @param data string containing the file data
  54791. * @returns if the data can be loaded directly
  54792. */
  54793. canDirectLoad?(data: string): boolean;
  54794. }
  54795. /**
  54796. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54797. */
  54798. export interface ISceneLoaderPluginBase {
  54799. /**
  54800. * The friendly name of this plugin.
  54801. */
  54802. name: string;
  54803. /**
  54804. * The file extensions supported by this plugin.
  54805. */
  54806. extensions: string | ISceneLoaderPluginExtensions;
  54807. /**
  54808. * The callback called when loading from a url.
  54809. * @param scene scene loading this url
  54810. * @param url url to load
  54811. * @param onSuccess callback called when the file successfully loads
  54812. * @param onProgress callback called while file is loading (if the server supports this mode)
  54813. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54814. * @param onError callback called when the file fails to load
  54815. * @returns a file request object
  54816. */
  54817. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54818. /**
  54819. * The callback called when loading from a file object.
  54820. * @param scene scene loading this file
  54821. * @param file defines the file to load
  54822. * @param onSuccess defines the callback to call when data is loaded
  54823. * @param onProgress defines the callback to call during loading process
  54824. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54825. * @param onError defines the callback to call when an error occurs
  54826. * @returns a file request object
  54827. */
  54828. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54829. /**
  54830. * The callback that returns true if the data can be directly loaded.
  54831. * @param data string containing the file data
  54832. * @returns if the data can be loaded directly
  54833. */
  54834. canDirectLoad?(data: string): boolean;
  54835. /**
  54836. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54837. * @param scene scene loading this data
  54838. * @param data string containing the data
  54839. * @returns data to pass to the plugin
  54840. */
  54841. directLoad?(scene: Scene, data: string): any;
  54842. /**
  54843. * The callback that allows custom handling of the root url based on the response url.
  54844. * @param rootUrl the original root url
  54845. * @param responseURL the response url if available
  54846. * @returns the new root url
  54847. */
  54848. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54849. }
  54850. /**
  54851. * Interface used to define a SceneLoader plugin
  54852. */
  54853. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54854. /**
  54855. * Import meshes into a scene.
  54856. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54857. * @param scene The scene to import into
  54858. * @param data The data to import
  54859. * @param rootUrl The root url for scene and resources
  54860. * @param meshes The meshes array to import into
  54861. * @param particleSystems The particle systems array to import into
  54862. * @param skeletons The skeletons array to import into
  54863. * @param onError The callback when import fails
  54864. * @returns True if successful or false otherwise
  54865. */
  54866. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54867. /**
  54868. * Load into a scene.
  54869. * @param scene The scene to load into
  54870. * @param data The data to import
  54871. * @param rootUrl The root url for scene and resources
  54872. * @param onError The callback when import fails
  54873. * @returns True if successful or false otherwise
  54874. */
  54875. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54876. /**
  54877. * Load into an asset container.
  54878. * @param scene The scene to load into
  54879. * @param data The data to import
  54880. * @param rootUrl The root url for scene and resources
  54881. * @param onError The callback when import fails
  54882. * @returns The loaded asset container
  54883. */
  54884. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54885. }
  54886. /**
  54887. * Interface used to define an async SceneLoader plugin
  54888. */
  54889. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54890. /**
  54891. * Import meshes into a scene.
  54892. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54893. * @param scene The scene to import into
  54894. * @param data The data to import
  54895. * @param rootUrl The root url for scene and resources
  54896. * @param onProgress The callback when the load progresses
  54897. * @param fileName Defines the name of the file to load
  54898. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54899. */
  54900. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54901. /**
  54902. * Load into a scene.
  54903. * @param scene The scene to load into
  54904. * @param data The data to import
  54905. * @param rootUrl The root url for scene and resources
  54906. * @param onProgress The callback when the load progresses
  54907. * @param fileName Defines the name of the file to load
  54908. * @returns Nothing
  54909. */
  54910. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54911. /**
  54912. * Load into an asset container.
  54913. * @param scene The scene to load into
  54914. * @param data The data to import
  54915. * @param rootUrl The root url for scene and resources
  54916. * @param onProgress The callback when the load progresses
  54917. * @param fileName Defines the name of the file to load
  54918. * @returns The loaded asset container
  54919. */
  54920. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54921. }
  54922. /**
  54923. * Mode that determines how to handle old animation groups before loading new ones.
  54924. */
  54925. export enum SceneLoaderAnimationGroupLoadingMode {
  54926. /**
  54927. * Reset all old animations to initial state then dispose them.
  54928. */
  54929. Clean = 0,
  54930. /**
  54931. * Stop all old animations.
  54932. */
  54933. Stop = 1,
  54934. /**
  54935. * Restart old animations from first frame.
  54936. */
  54937. Sync = 2,
  54938. /**
  54939. * Old animations remains untouched.
  54940. */
  54941. NoSync = 3
  54942. }
  54943. /**
  54944. * Defines a plugin registered by the SceneLoader
  54945. */
  54946. interface IRegisteredPlugin {
  54947. /**
  54948. * Defines the plugin to use
  54949. */
  54950. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54951. /**
  54952. * Defines if the plugin supports binary data
  54953. */
  54954. isBinary: boolean;
  54955. }
  54956. /**
  54957. * Class used to load scene from various file formats using registered plugins
  54958. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54959. */
  54960. export class SceneLoader {
  54961. /**
  54962. * No logging while loading
  54963. */
  54964. static readonly NO_LOGGING: number;
  54965. /**
  54966. * Minimal logging while loading
  54967. */
  54968. static readonly MINIMAL_LOGGING: number;
  54969. /**
  54970. * Summary logging while loading
  54971. */
  54972. static readonly SUMMARY_LOGGING: number;
  54973. /**
  54974. * Detailed logging while loading
  54975. */
  54976. static readonly DETAILED_LOGGING: number;
  54977. /**
  54978. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54979. */
  54980. static get ForceFullSceneLoadingForIncremental(): boolean;
  54981. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54982. /**
  54983. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54984. */
  54985. static get ShowLoadingScreen(): boolean;
  54986. static set ShowLoadingScreen(value: boolean);
  54987. /**
  54988. * Defines the current logging level (while loading the scene)
  54989. * @ignorenaming
  54990. */
  54991. static get loggingLevel(): number;
  54992. static set loggingLevel(value: number);
  54993. /**
  54994. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54995. */
  54996. static get CleanBoneMatrixWeights(): boolean;
  54997. static set CleanBoneMatrixWeights(value: boolean);
  54998. /**
  54999. * Event raised when a plugin is used to load a scene
  55000. */
  55001. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  55002. private static _registeredPlugins;
  55003. private static _showingLoadingScreen;
  55004. /**
  55005. * Gets the default plugin (used to load Babylon files)
  55006. * @returns the .babylon plugin
  55007. */
  55008. static GetDefaultPlugin(): IRegisteredPlugin;
  55009. private static _GetPluginForExtension;
  55010. private static _GetPluginForDirectLoad;
  55011. private static _GetPluginForFilename;
  55012. private static _GetDirectLoad;
  55013. private static _LoadData;
  55014. private static _GetFileInfo;
  55015. /**
  55016. * Gets a plugin that can load the given extension
  55017. * @param extension defines the extension to load
  55018. * @returns a plugin or null if none works
  55019. */
  55020. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55021. /**
  55022. * Gets a boolean indicating that the given extension can be loaded
  55023. * @param extension defines the extension to load
  55024. * @returns true if the extension is supported
  55025. */
  55026. static IsPluginForExtensionAvailable(extension: string): boolean;
  55027. /**
  55028. * Adds a new plugin to the list of registered plugins
  55029. * @param plugin defines the plugin to add
  55030. */
  55031. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55032. /**
  55033. * Import meshes into a scene
  55034. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55035. * @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)
  55036. * @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)
  55037. * @param scene the instance of BABYLON.Scene to append to
  55038. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55039. * @param onProgress a callback with a progress event for each file being loaded
  55040. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55041. * @param pluginExtension the extension used to determine the plugin
  55042. * @returns The loaded plugin
  55043. */
  55044. 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>;
  55045. /**
  55046. * Import meshes into a scene
  55047. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55048. * @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)
  55049. * @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)
  55050. * @param scene the instance of BABYLON.Scene to append to
  55051. * @param onProgress a callback with a progress event for each file being loaded
  55052. * @param pluginExtension the extension used to determine the plugin
  55053. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55054. */
  55055. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55056. /**
  55057. * Load a scene
  55058. * @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)
  55059. * @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)
  55060. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55061. * @param onSuccess a callback with the scene when import succeeds
  55062. * @param onProgress a callback with a progress event for each file being loaded
  55063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55064. * @param pluginExtension the extension used to determine the plugin
  55065. * @returns The loaded plugin
  55066. */
  55067. 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>;
  55068. /**
  55069. * Load a scene
  55070. * @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)
  55071. * @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)
  55072. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55073. * @param onProgress a callback with a progress event for each file being loaded
  55074. * @param pluginExtension the extension used to determine the plugin
  55075. * @returns The loaded scene
  55076. */
  55077. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55078. /**
  55079. * Append a scene
  55080. * @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)
  55081. * @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)
  55082. * @param scene is the instance of BABYLON.Scene to append to
  55083. * @param onSuccess a callback with the scene when import succeeds
  55084. * @param onProgress a callback with a progress event for each file being loaded
  55085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55086. * @param pluginExtension the extension used to determine the plugin
  55087. * @returns The loaded plugin
  55088. */
  55089. 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>;
  55090. /**
  55091. * Append a scene
  55092. * @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)
  55093. * @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)
  55094. * @param scene is the instance of BABYLON.Scene to append to
  55095. * @param onProgress a callback with a progress event for each file being loaded
  55096. * @param pluginExtension the extension used to determine the plugin
  55097. * @returns The given scene
  55098. */
  55099. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55100. /**
  55101. * Load a scene into an asset container
  55102. * @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)
  55103. * @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)
  55104. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55105. * @param onSuccess a callback with the scene when import succeeds
  55106. * @param onProgress a callback with a progress event for each file being loaded
  55107. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55108. * @param pluginExtension the extension used to determine the plugin
  55109. * @returns The loaded plugin
  55110. */
  55111. 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>;
  55112. /**
  55113. * Load a scene into an asset container
  55114. * @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)
  55115. * @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)
  55116. * @param scene is the instance of Scene to append to
  55117. * @param onProgress a callback with a progress event for each file being loaded
  55118. * @param pluginExtension the extension used to determine the plugin
  55119. * @returns The loaded asset container
  55120. */
  55121. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55122. /**
  55123. * Import animations from a file into a scene
  55124. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  55125. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  55126. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55127. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55128. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55129. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55130. * @param onSuccess a callback with the scene when import succeeds
  55131. * @param onProgress a callback with a progress event for each file being loaded
  55132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55133. * @param pluginExtension the extension used to determine the plugin
  55134. */
  55135. 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;
  55136. /**
  55137. * Import animations from a file into a scene
  55138. * @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)
  55139. * @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)
  55140. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55141. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55142. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55143. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55144. * @param onSuccess a callback with the scene when import succeeds
  55145. * @param onProgress a callback with a progress event for each file being loaded
  55146. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55147. * @param pluginExtension the extension used to determine the plugin
  55148. * @returns the updated scene with imported animations
  55149. */
  55150. 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>;
  55151. }
  55152. }
  55153. declare module BABYLON {
  55154. /**
  55155. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55156. */
  55157. export type MotionControllerHandedness = "none" | "left" | "right";
  55158. /**
  55159. * The type of components available in motion controllers.
  55160. * This is not the name of the component.
  55161. */
  55162. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55163. /**
  55164. * The state of a controller component
  55165. */
  55166. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55167. /**
  55168. * The schema of motion controller layout.
  55169. * No object will be initialized using this interface
  55170. * This is used just to define the profile.
  55171. */
  55172. export interface IMotionControllerLayout {
  55173. /**
  55174. * Path to load the assets. Usually relative to the base path
  55175. */
  55176. assetPath: string;
  55177. /**
  55178. * Available components (unsorted)
  55179. */
  55180. components: {
  55181. /**
  55182. * A map of component Ids
  55183. */
  55184. [componentId: string]: {
  55185. /**
  55186. * The type of input the component outputs
  55187. */
  55188. type: MotionControllerComponentType;
  55189. /**
  55190. * The indices of this component in the gamepad object
  55191. */
  55192. gamepadIndices: {
  55193. /**
  55194. * Index of button
  55195. */
  55196. button?: number;
  55197. /**
  55198. * If available, index of x-axis
  55199. */
  55200. xAxis?: number;
  55201. /**
  55202. * If available, index of y-axis
  55203. */
  55204. yAxis?: number;
  55205. };
  55206. /**
  55207. * The mesh's root node name
  55208. */
  55209. rootNodeName: string;
  55210. /**
  55211. * Animation definitions for this model
  55212. */
  55213. visualResponses: {
  55214. [stateKey: string]: {
  55215. /**
  55216. * What property will be animated
  55217. */
  55218. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55219. /**
  55220. * What states influence this visual response
  55221. */
  55222. states: MotionControllerComponentStateType[];
  55223. /**
  55224. * Type of animation - movement or visibility
  55225. */
  55226. valueNodeProperty: "transform" | "visibility";
  55227. /**
  55228. * Base node name to move. Its position will be calculated according to the min and max nodes
  55229. */
  55230. valueNodeName?: string;
  55231. /**
  55232. * Minimum movement node
  55233. */
  55234. minNodeName?: string;
  55235. /**
  55236. * Max movement node
  55237. */
  55238. maxNodeName?: string;
  55239. };
  55240. };
  55241. /**
  55242. * If touch enabled, what is the name of node to display user feedback
  55243. */
  55244. touchPointNodeName?: string;
  55245. };
  55246. };
  55247. /**
  55248. * Is it xr standard mapping or not
  55249. */
  55250. gamepadMapping: "" | "xr-standard";
  55251. /**
  55252. * Base root node of this entire model
  55253. */
  55254. rootNodeName: string;
  55255. /**
  55256. * Defines the main button component id
  55257. */
  55258. selectComponentId: string;
  55259. }
  55260. /**
  55261. * A definition for the layout map in the input profile
  55262. */
  55263. export interface IMotionControllerLayoutMap {
  55264. /**
  55265. * Layouts with handedness type as a key
  55266. */
  55267. [handedness: string]: IMotionControllerLayout;
  55268. }
  55269. /**
  55270. * The XR Input profile schema
  55271. * Profiles can be found here:
  55272. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55273. */
  55274. export interface IMotionControllerProfile {
  55275. /**
  55276. * fallback profiles for this profileId
  55277. */
  55278. fallbackProfileIds: string[];
  55279. /**
  55280. * The layout map, with handedness as key
  55281. */
  55282. layouts: IMotionControllerLayoutMap;
  55283. /**
  55284. * The id of this profile
  55285. * correlates to the profile(s) in the xrInput.profiles array
  55286. */
  55287. profileId: string;
  55288. }
  55289. /**
  55290. * A helper-interface for the 3 meshes needed for controller button animation
  55291. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55292. */
  55293. export interface IMotionControllerButtonMeshMap {
  55294. /**
  55295. * the mesh that defines the pressed value mesh position.
  55296. * This is used to find the max-position of this button
  55297. */
  55298. pressedMesh: AbstractMesh;
  55299. /**
  55300. * the mesh that defines the unpressed value mesh position.
  55301. * This is used to find the min (or initial) position of this button
  55302. */
  55303. unpressedMesh: AbstractMesh;
  55304. /**
  55305. * The mesh that will be changed when value changes
  55306. */
  55307. valueMesh: AbstractMesh;
  55308. }
  55309. /**
  55310. * A helper-interface for the 3 meshes needed for controller axis animation.
  55311. * This will be expanded when touchpad animations are fully supported
  55312. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55313. */
  55314. export interface IMotionControllerMeshMap {
  55315. /**
  55316. * the mesh that defines the maximum value mesh position.
  55317. */
  55318. maxMesh?: AbstractMesh;
  55319. /**
  55320. * the mesh that defines the minimum value mesh position.
  55321. */
  55322. minMesh?: AbstractMesh;
  55323. /**
  55324. * The mesh that will be changed when axis value changes
  55325. */
  55326. valueMesh?: AbstractMesh;
  55327. }
  55328. /**
  55329. * The elements needed for change-detection of the gamepad objects in motion controllers
  55330. */
  55331. export interface IMinimalMotionControllerObject {
  55332. /**
  55333. * Available axes of this controller
  55334. */
  55335. axes: number[];
  55336. /**
  55337. * An array of available buttons
  55338. */
  55339. buttons: Array<{
  55340. /**
  55341. * Value of the button/trigger
  55342. */
  55343. value: number;
  55344. /**
  55345. * If the button/trigger is currently touched
  55346. */
  55347. touched: boolean;
  55348. /**
  55349. * If the button/trigger is currently pressed
  55350. */
  55351. pressed: boolean;
  55352. }>;
  55353. /**
  55354. * EXPERIMENTAL haptic support.
  55355. */
  55356. hapticActuators?: Array<{
  55357. pulse: (value: number, duration: number) => Promise<boolean>;
  55358. }>;
  55359. }
  55360. /**
  55361. * An Abstract Motion controller
  55362. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55363. * Each component has an observable to check for changes in value and state
  55364. */
  55365. export abstract class WebXRAbstractMotionController implements IDisposable {
  55366. protected scene: Scene;
  55367. protected layout: IMotionControllerLayout;
  55368. /**
  55369. * The gamepad object correlating to this controller
  55370. */
  55371. gamepadObject: IMinimalMotionControllerObject;
  55372. /**
  55373. * handedness (left/right/none) of this controller
  55374. */
  55375. handedness: MotionControllerHandedness;
  55376. private _initComponent;
  55377. private _modelReady;
  55378. /**
  55379. * A map of components (WebXRControllerComponent) in this motion controller
  55380. * Components have a ComponentType and can also have both button and axis definitions
  55381. */
  55382. readonly components: {
  55383. [id: string]: WebXRControllerComponent;
  55384. };
  55385. /**
  55386. * Disable the model's animation. Can be set at any time.
  55387. */
  55388. disableAnimation: boolean;
  55389. /**
  55390. * Observers registered here will be triggered when the model of this controller is done loading
  55391. */
  55392. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55393. /**
  55394. * The profile id of this motion controller
  55395. */
  55396. abstract profileId: string;
  55397. /**
  55398. * The root mesh of the model. It is null if the model was not yet initialized
  55399. */
  55400. rootMesh: Nullable<AbstractMesh>;
  55401. /**
  55402. * constructs a new abstract motion controller
  55403. * @param scene the scene to which the model of the controller will be added
  55404. * @param layout The profile layout to load
  55405. * @param gamepadObject The gamepad object correlating to this controller
  55406. * @param handedness handedness (left/right/none) of this controller
  55407. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55408. */
  55409. constructor(scene: Scene, layout: IMotionControllerLayout,
  55410. /**
  55411. * The gamepad object correlating to this controller
  55412. */
  55413. gamepadObject: IMinimalMotionControllerObject,
  55414. /**
  55415. * handedness (left/right/none) of this controller
  55416. */
  55417. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55418. /**
  55419. * Dispose this controller, the model mesh and all its components
  55420. */
  55421. dispose(): void;
  55422. /**
  55423. * Returns all components of specific type
  55424. * @param type the type to search for
  55425. * @return an array of components with this type
  55426. */
  55427. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55428. /**
  55429. * get a component based an its component id as defined in layout.components
  55430. * @param id the id of the component
  55431. * @returns the component correlates to the id or undefined if not found
  55432. */
  55433. getComponent(id: string): WebXRControllerComponent;
  55434. /**
  55435. * Get the list of components available in this motion controller
  55436. * @returns an array of strings correlating to available components
  55437. */
  55438. getComponentIds(): string[];
  55439. /**
  55440. * Get the first component of specific type
  55441. * @param type type of component to find
  55442. * @return a controller component or null if not found
  55443. */
  55444. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55445. /**
  55446. * Get the main (Select) component of this controller as defined in the layout
  55447. * @returns the main component of this controller
  55448. */
  55449. getMainComponent(): WebXRControllerComponent;
  55450. /**
  55451. * Loads the model correlating to this controller
  55452. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55453. * @returns A promise fulfilled with the result of the model loading
  55454. */
  55455. loadModel(): Promise<boolean>;
  55456. /**
  55457. * Update this model using the current XRFrame
  55458. * @param xrFrame the current xr frame to use and update the model
  55459. */
  55460. updateFromXRFrame(xrFrame: XRFrame): void;
  55461. /**
  55462. * Backwards compatibility due to a deeply-integrated typo
  55463. */
  55464. get handness(): XREye;
  55465. /**
  55466. * Pulse (vibrate) this controller
  55467. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55468. * Consecutive calls to this function will cancel the last pulse call
  55469. *
  55470. * @param value the strength of the pulse in 0.0...1.0 range
  55471. * @param duration Duration of the pulse in milliseconds
  55472. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55473. * @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
  55474. */
  55475. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55476. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55477. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55478. /**
  55479. * Moves the axis on the controller mesh based on its current state
  55480. * @param axis the index of the axis
  55481. * @param axisValue the value of the axis which determines the meshes new position
  55482. * @hidden
  55483. */
  55484. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55485. /**
  55486. * Update the model itself with the current frame data
  55487. * @param xrFrame the frame to use for updating the model mesh
  55488. */
  55489. protected updateModel(xrFrame: XRFrame): void;
  55490. /**
  55491. * Get the filename and path for this controller's model
  55492. * @returns a map of filename and path
  55493. */
  55494. protected abstract _getFilenameAndPath(): {
  55495. filename: string;
  55496. path: string;
  55497. };
  55498. /**
  55499. * This function is called before the mesh is loaded. It checks for loading constraints.
  55500. * For example, this function can check if the GLB loader is available
  55501. * If this function returns false, the generic controller will be loaded instead
  55502. * @returns Is the client ready to load the mesh
  55503. */
  55504. protected abstract _getModelLoadingConstraints(): boolean;
  55505. /**
  55506. * This function will be called after the model was successfully loaded and can be used
  55507. * for mesh transformations before it is available for the user
  55508. * @param meshes the loaded meshes
  55509. */
  55510. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55511. /**
  55512. * Set the root mesh for this controller. Important for the WebXR controller class
  55513. * @param meshes the loaded meshes
  55514. */
  55515. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55516. /**
  55517. * A function executed each frame that updates the mesh (if needed)
  55518. * @param xrFrame the current xrFrame
  55519. */
  55520. protected abstract _updateModel(xrFrame: XRFrame): void;
  55521. private _getGenericFilenameAndPath;
  55522. private _getGenericParentMesh;
  55523. }
  55524. }
  55525. declare module BABYLON {
  55526. /**
  55527. * A generic trigger-only motion controller for WebXR
  55528. */
  55529. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55530. /**
  55531. * Static version of the profile id of this controller
  55532. */
  55533. static ProfileId: string;
  55534. profileId: string;
  55535. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55536. protected _getFilenameAndPath(): {
  55537. filename: string;
  55538. path: string;
  55539. };
  55540. protected _getModelLoadingConstraints(): boolean;
  55541. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55542. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55543. protected _updateModel(): void;
  55544. }
  55545. }
  55546. declare module BABYLON {
  55547. /**
  55548. * Class containing static functions to help procedurally build meshes
  55549. */
  55550. export class SphereBuilder {
  55551. /**
  55552. * Creates a sphere mesh
  55553. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55554. * * 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`)
  55555. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55556. * * 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
  55557. * * 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)
  55558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55559. * * 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
  55560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55561. * @param name defines the name of the mesh
  55562. * @param options defines the options used to create the mesh
  55563. * @param scene defines the hosting scene
  55564. * @returns the sphere mesh
  55565. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55566. */
  55567. static CreateSphere(name: string, options: {
  55568. segments?: number;
  55569. diameter?: number;
  55570. diameterX?: number;
  55571. diameterY?: number;
  55572. diameterZ?: number;
  55573. arc?: number;
  55574. slice?: number;
  55575. sideOrientation?: number;
  55576. frontUVs?: Vector4;
  55577. backUVs?: Vector4;
  55578. updatable?: boolean;
  55579. }, scene?: Nullable<Scene>): Mesh;
  55580. }
  55581. }
  55582. declare module BABYLON {
  55583. /**
  55584. * A profiled motion controller has its profile loaded from an online repository.
  55585. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55586. */
  55587. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55588. private _repositoryUrl;
  55589. private _buttonMeshMapping;
  55590. private _touchDots;
  55591. /**
  55592. * The profile ID of this controller. Will be populated when the controller initializes.
  55593. */
  55594. profileId: string;
  55595. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55596. dispose(): void;
  55597. protected _getFilenameAndPath(): {
  55598. filename: string;
  55599. path: string;
  55600. };
  55601. protected _getModelLoadingConstraints(): boolean;
  55602. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55603. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55604. protected _updateModel(_xrFrame: XRFrame): void;
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. /**
  55609. * A construction function type to create a new controller based on an xrInput object
  55610. */
  55611. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55612. /**
  55613. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55614. *
  55615. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55616. * it should be replaced with auto-loaded controllers.
  55617. *
  55618. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55619. */
  55620. export class WebXRMotionControllerManager {
  55621. private static _AvailableControllers;
  55622. private static _Fallbacks;
  55623. private static _ProfileLoadingPromises;
  55624. private static _ProfilesList;
  55625. /**
  55626. * The base URL of the online controller repository. Can be changed at any time.
  55627. */
  55628. static BaseRepositoryUrl: string;
  55629. /**
  55630. * Which repository gets priority - local or online
  55631. */
  55632. static PrioritizeOnlineRepository: boolean;
  55633. /**
  55634. * Use the online repository, or use only locally-defined controllers
  55635. */
  55636. static UseOnlineRepository: boolean;
  55637. /**
  55638. * Clear the cache used for profile loading and reload when requested again
  55639. */
  55640. static ClearProfilesCache(): void;
  55641. /**
  55642. * Register the default fallbacks.
  55643. * This function is called automatically when this file is imported.
  55644. */
  55645. static DefaultFallbacks(): void;
  55646. /**
  55647. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55648. * @param profileId the profile to which a fallback needs to be found
  55649. * @return an array with corresponding fallback profiles
  55650. */
  55651. static FindFallbackWithProfileId(profileId: string): string[];
  55652. /**
  55653. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55654. * The order of search:
  55655. *
  55656. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55657. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55658. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55659. * 4) return the generic trigger controller if none were found
  55660. *
  55661. * @param xrInput the xrInput to which a new controller is initialized
  55662. * @param scene the scene to which the model will be added
  55663. * @param forceProfile force a certain profile for this controller
  55664. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55665. */
  55666. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55667. /**
  55668. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55669. *
  55670. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55671. *
  55672. * @param type the profile type to register
  55673. * @param constructFunction the function to be called when loading this profile
  55674. */
  55675. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55676. /**
  55677. * Register a fallback to a specific profile.
  55678. * @param profileId the profileId that will receive the fallbacks
  55679. * @param fallbacks A list of fallback profiles
  55680. */
  55681. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55682. /**
  55683. * Will update the list of profiles available in the repository
  55684. * @return a promise that resolves to a map of profiles available online
  55685. */
  55686. static UpdateProfilesList(): Promise<{
  55687. [profile: string]: string;
  55688. }>;
  55689. private static _LoadProfileFromRepository;
  55690. private static _LoadProfilesFromAvailableControllers;
  55691. }
  55692. }
  55693. declare module BABYLON {
  55694. /**
  55695. * Configuration options for the WebXR controller creation
  55696. */
  55697. export interface IWebXRControllerOptions {
  55698. /**
  55699. * Should the controller mesh be animated when a user interacts with it
  55700. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55701. */
  55702. disableMotionControllerAnimation?: boolean;
  55703. /**
  55704. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55705. */
  55706. doNotLoadControllerMesh?: boolean;
  55707. /**
  55708. * Force a specific controller type for this controller.
  55709. * This can be used when creating your own profile or when testing different controllers
  55710. */
  55711. forceControllerProfile?: string;
  55712. /**
  55713. * Defines a rendering group ID for meshes that will be loaded.
  55714. * This is for the default controllers only.
  55715. */
  55716. renderingGroupId?: number;
  55717. }
  55718. /**
  55719. * Represents an XR controller
  55720. */
  55721. export class WebXRInputSource {
  55722. private _scene;
  55723. /** The underlying input source for the controller */
  55724. inputSource: XRInputSource;
  55725. private _options;
  55726. private _tmpVector;
  55727. private _uniqueId;
  55728. private _disposed;
  55729. /**
  55730. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available
  55731. */
  55732. grip?: AbstractMesh;
  55733. /**
  55734. * If available, this is the gamepad object related to this controller.
  55735. * Using this object it is possible to get click events and trackpad changes of the
  55736. * webxr controller that is currently being used.
  55737. */
  55738. motionController?: WebXRAbstractMotionController;
  55739. /**
  55740. * Event that fires when the controller is removed/disposed.
  55741. * The object provided as event data is this controller, after associated assets were disposed.
  55742. * uniqueId is still available.
  55743. */
  55744. onDisposeObservable: Observable<WebXRInputSource>;
  55745. /**
  55746. * Will be triggered when the mesh associated with the motion controller is done loading.
  55747. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55748. * A shortened version of controller -> motion controller -> on mesh loaded.
  55749. */
  55750. onMeshLoadedObservable: Observable<AbstractMesh>;
  55751. /**
  55752. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55753. */
  55754. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55755. /**
  55756. * Pointer which can be used to select objects or attach a visible laser to
  55757. */
  55758. pointer: AbstractMesh;
  55759. /**
  55760. * Creates the input source object
  55761. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55762. * @param _scene the scene which the controller should be associated to
  55763. * @param inputSource the underlying input source for the controller
  55764. * @param _options options for this controller creation
  55765. */
  55766. constructor(_scene: Scene,
  55767. /** The underlying input source for the controller */
  55768. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55769. /**
  55770. * Get this controllers unique id
  55771. */
  55772. get uniqueId(): string;
  55773. /**
  55774. * Disposes of the object
  55775. */
  55776. dispose(): void;
  55777. /**
  55778. * Gets a world space ray coming from the pointer or grip
  55779. * @param result the resulting ray
  55780. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55781. */
  55782. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55783. /**
  55784. * Updates the controller pose based on the given XRFrame
  55785. * @param xrFrame xr frame to update the pose with
  55786. * @param referenceSpace reference space to use
  55787. */
  55788. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55789. }
  55790. }
  55791. declare module BABYLON {
  55792. /**
  55793. * The schema for initialization options of the XR Input class
  55794. */
  55795. export interface IWebXRInputOptions {
  55796. /**
  55797. * If set to true no model will be automatically loaded
  55798. */
  55799. doNotLoadControllerMeshes?: boolean;
  55800. /**
  55801. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55802. * If not found, the xr input profile data will be used.
  55803. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55804. */
  55805. forceInputProfile?: string;
  55806. /**
  55807. * Do not send a request to the controller repository to load the profile.
  55808. *
  55809. * Instead, use the controllers available in babylon itself.
  55810. */
  55811. disableOnlineControllerRepository?: boolean;
  55812. /**
  55813. * A custom URL for the controllers repository
  55814. */
  55815. customControllersRepositoryURL?: string;
  55816. /**
  55817. * Should the controller model's components not move according to the user input
  55818. */
  55819. disableControllerAnimation?: boolean;
  55820. /**
  55821. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55822. */
  55823. controllerOptions?: IWebXRControllerOptions;
  55824. }
  55825. /**
  55826. * XR input used to track XR inputs such as controllers/rays
  55827. */
  55828. export class WebXRInput implements IDisposable {
  55829. /**
  55830. * the xr session manager for this session
  55831. */
  55832. xrSessionManager: WebXRSessionManager;
  55833. /**
  55834. * the WebXR camera for this session. Mainly used for teleportation
  55835. */
  55836. xrCamera: WebXRCamera;
  55837. private readonly options;
  55838. /**
  55839. * XR controllers being tracked
  55840. */
  55841. controllers: Array<WebXRInputSource>;
  55842. private _frameObserver;
  55843. private _sessionEndedObserver;
  55844. private _sessionInitObserver;
  55845. /**
  55846. * Event when a controller has been connected/added
  55847. */
  55848. onControllerAddedObservable: Observable<WebXRInputSource>;
  55849. /**
  55850. * Event when a controller has been removed/disconnected
  55851. */
  55852. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55853. /**
  55854. * Initializes the WebXRInput
  55855. * @param xrSessionManager the xr session manager for this session
  55856. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55857. * @param options = initialization options for this xr input
  55858. */
  55859. constructor(
  55860. /**
  55861. * the xr session manager for this session
  55862. */
  55863. xrSessionManager: WebXRSessionManager,
  55864. /**
  55865. * the WebXR camera for this session. Mainly used for teleportation
  55866. */
  55867. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55868. private _onInputSourcesChange;
  55869. private _addAndRemoveControllers;
  55870. /**
  55871. * Disposes of the object
  55872. */
  55873. dispose(): void;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * This is the base class for all WebXR features.
  55879. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55880. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55881. */
  55882. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55883. protected _xrSessionManager: WebXRSessionManager;
  55884. private _attached;
  55885. private _removeOnDetach;
  55886. /**
  55887. * Is this feature disposed?
  55888. */
  55889. isDisposed: boolean;
  55890. /**
  55891. * Should auto-attach be disabled?
  55892. */
  55893. disableAutoAttach: boolean;
  55894. /**
  55895. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55896. */
  55897. xrNativeFeatureName: string;
  55898. /**
  55899. * Construct a new (abstract) WebXR feature
  55900. * @param _xrSessionManager the xr session manager for this feature
  55901. */
  55902. constructor(_xrSessionManager: WebXRSessionManager);
  55903. /**
  55904. * Is this feature attached
  55905. */
  55906. get attached(): boolean;
  55907. /**
  55908. * attach this feature
  55909. *
  55910. * @param force should attachment be forced (even when already attached)
  55911. * @returns true if successful, false is failed or already attached
  55912. */
  55913. attach(force?: boolean): boolean;
  55914. /**
  55915. * detach this feature.
  55916. *
  55917. * @returns true if successful, false if failed or already detached
  55918. */
  55919. detach(): boolean;
  55920. /**
  55921. * Dispose this feature and all of the resources attached
  55922. */
  55923. dispose(): void;
  55924. /**
  55925. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55926. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55927. *
  55928. * @returns whether or not the feature is compatible in this environment
  55929. */
  55930. isCompatible(): boolean;
  55931. /**
  55932. * This is used to register callbacks that will automatically be removed when detach is called.
  55933. * @param observable the observable to which the observer will be attached
  55934. * @param callback the callback to register
  55935. */
  55936. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55937. /**
  55938. * Code in this function will be executed on each xrFrame received from the browser.
  55939. * This function will not execute after the feature is detached.
  55940. * @param _xrFrame the current frame
  55941. */
  55942. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55943. }
  55944. }
  55945. declare module BABYLON {
  55946. /**
  55947. * Renders a layer on top of an existing scene
  55948. */
  55949. export class UtilityLayerRenderer implements IDisposable {
  55950. /** the original scene that will be rendered on top of */
  55951. originalScene: Scene;
  55952. private _pointerCaptures;
  55953. private _lastPointerEvents;
  55954. private static _DefaultUtilityLayer;
  55955. private static _DefaultKeepDepthUtilityLayer;
  55956. private _sharedGizmoLight;
  55957. private _renderCamera;
  55958. /**
  55959. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55960. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55961. * @returns the camera that is used when rendering the utility layer
  55962. */
  55963. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55964. /**
  55965. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55966. * @param cam the camera that should be used when rendering the utility layer
  55967. */
  55968. setRenderCamera(cam: Nullable<Camera>): void;
  55969. /**
  55970. * @hidden
  55971. * Light which used by gizmos to get light shading
  55972. */
  55973. _getSharedGizmoLight(): HemisphericLight;
  55974. /**
  55975. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55976. */
  55977. pickUtilitySceneFirst: boolean;
  55978. /**
  55979. * 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)
  55980. */
  55981. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55982. /**
  55983. * 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)
  55984. */
  55985. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55986. /**
  55987. * The scene that is rendered on top of the original scene
  55988. */
  55989. utilityLayerScene: Scene;
  55990. /**
  55991. * If the utility layer should automatically be rendered on top of existing scene
  55992. */
  55993. shouldRender: boolean;
  55994. /**
  55995. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55996. */
  55997. onlyCheckPointerDownEvents: boolean;
  55998. /**
  55999. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  56000. */
  56001. processAllEvents: boolean;
  56002. /**
  56003. * Observable raised when the pointer move from the utility layer scene to the main scene
  56004. */
  56005. onPointerOutObservable: Observable<number>;
  56006. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  56007. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  56008. private _afterRenderObserver;
  56009. private _sceneDisposeObserver;
  56010. private _originalPointerObserver;
  56011. /**
  56012. * Instantiates a UtilityLayerRenderer
  56013. * @param originalScene the original scene that will be rendered on top of
  56014. * @param handleEvents boolean indicating if the utility layer should handle events
  56015. */
  56016. constructor(
  56017. /** the original scene that will be rendered on top of */
  56018. originalScene: Scene, handleEvents?: boolean);
  56019. private _notifyObservers;
  56020. /**
  56021. * Renders the utility layers scene on top of the original scene
  56022. */
  56023. render(): void;
  56024. /**
  56025. * Disposes of the renderer
  56026. */
  56027. dispose(): void;
  56028. private _updateCamera;
  56029. }
  56030. }
  56031. declare module BABYLON {
  56032. /**
  56033. * Options interface for the pointer selection module
  56034. */
  56035. export interface IWebXRControllerPointerSelectionOptions {
  56036. /**
  56037. * if provided, this scene will be used to render meshes.
  56038. */
  56039. customUtilityLayerScene?: Scene;
  56040. /**
  56041. * 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)
  56042. * If not disabled, the last picked point will be used to execute a pointer up event
  56043. * If disabled, pointer up event will be triggered right after the pointer down event.
  56044. * Used in screen and gaze target ray mode only
  56045. */
  56046. disablePointerUpOnTouchOut: boolean;
  56047. /**
  56048. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56049. */
  56050. forceGazeMode: boolean;
  56051. /**
  56052. * 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
  56053. * to start a new countdown to the pointer down event.
  56054. * Defaults to 1.
  56055. */
  56056. gazeModePointerMovedFactor?: number;
  56057. /**
  56058. * Different button type to use instead of the main component
  56059. */
  56060. overrideButtonId?: string;
  56061. /**
  56062. * use this rendering group id for the meshes (optional)
  56063. */
  56064. renderingGroupId?: number;
  56065. /**
  56066. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56067. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56068. * 3000 means 3 seconds between pointing at something and selecting it
  56069. */
  56070. timeToSelect?: number;
  56071. /**
  56072. * Should meshes created here be added to a utility layer or the main scene
  56073. */
  56074. useUtilityLayer?: boolean;
  56075. /**
  56076. * Optional WebXR camera to be used for gaze selection
  56077. */
  56078. gazeCamera?: WebXRCamera;
  56079. /**
  56080. * the xr input to use with this pointer selection
  56081. */
  56082. xrInput: WebXRInput;
  56083. /**
  56084. * Should the scene pointerX and pointerY update be disabled
  56085. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56086. * Disable in VR, if not needed.
  56087. * The first rig camera (left eye) will be used to calculate the projection
  56088. */
  56089. disableScenePointerVectorUpdate: boolean;
  56090. /**
  56091. * Enable pointer selection on all controllers instead of switching between them
  56092. */
  56093. enablePointerSelectionOnAllControllers?: boolean;
  56094. /**
  56095. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56096. * If switch is enabled, it will still allow the user to switch between the different controllers
  56097. */
  56098. preferredHandedness?: XRHandedness;
  56099. /**
  56100. * Disable switching the pointer selection from one controller to the other.
  56101. * 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
  56102. */
  56103. disableSwitchOnClick?: boolean;
  56104. /**
  56105. * The maximum distance of the pointer selection feature. Defaults to 100.
  56106. */
  56107. maxPointerDistance?: number;
  56108. }
  56109. /**
  56110. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56111. */
  56112. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56113. private readonly _options;
  56114. private static _idCounter;
  56115. private _attachController;
  56116. private _controllers;
  56117. private _scene;
  56118. private _tmpVectorForPickCompare;
  56119. private _attachedController;
  56120. /**
  56121. * The module's name
  56122. */
  56123. static readonly Name: string;
  56124. /**
  56125. * The (Babylon) version of this module.
  56126. * This is an integer representing the implementation version.
  56127. * This number does not correspond to the WebXR specs version
  56128. */
  56129. static readonly Version: number;
  56130. /**
  56131. * Disable lighting on the laser pointer (so it will always be visible)
  56132. */
  56133. disablePointerLighting: boolean;
  56134. /**
  56135. * Disable lighting on the selection mesh (so it will always be visible)
  56136. */
  56137. disableSelectionMeshLighting: boolean;
  56138. /**
  56139. * Should the laser pointer be displayed
  56140. */
  56141. displayLaserPointer: boolean;
  56142. /**
  56143. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56144. */
  56145. displaySelectionMesh: boolean;
  56146. /**
  56147. * This color will be set to the laser pointer when selection is triggered
  56148. */
  56149. laserPointerPickedColor: Color3;
  56150. /**
  56151. * Default color of the laser pointer
  56152. */
  56153. laserPointerDefaultColor: Color3;
  56154. /**
  56155. * default color of the selection ring
  56156. */
  56157. selectionMeshDefaultColor: Color3;
  56158. /**
  56159. * This color will be applied to the selection ring when selection is triggered
  56160. */
  56161. selectionMeshPickedColor: Color3;
  56162. /**
  56163. * Optional filter to be used for ray selection. This predicate shares behavior with
  56164. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56165. */
  56166. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56167. /**
  56168. * constructs a new background remover module
  56169. * @param _xrSessionManager the session manager for this module
  56170. * @param _options read-only options to be used in this module
  56171. */
  56172. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56173. /**
  56174. * attach this feature
  56175. * Will usually be called by the features manager
  56176. *
  56177. * @returns true if successful.
  56178. */
  56179. attach(): boolean;
  56180. /**
  56181. * detach this feature.
  56182. * Will usually be called by the features manager
  56183. *
  56184. * @returns true if successful.
  56185. */
  56186. detach(): boolean;
  56187. /**
  56188. * Will get the mesh under a specific pointer.
  56189. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56190. * @param controllerId the controllerId to check
  56191. * @returns The mesh under pointer or null if no mesh is under the pointer
  56192. */
  56193. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56194. /**
  56195. * Get the xr controller that correlates to the pointer id in the pointer event
  56196. *
  56197. * @param id the pointer id to search for
  56198. * @returns the controller that correlates to this id or null if not found
  56199. */
  56200. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56201. private _identityMatrix;
  56202. private _screenCoordinatesRef;
  56203. private _viewportRef;
  56204. protected _onXRFrame(_xrFrame: XRFrame): void;
  56205. private _attachGazeMode;
  56206. private _attachScreenRayMode;
  56207. private _attachTrackedPointerRayMode;
  56208. private _convertNormalToDirectionOfRay;
  56209. private _detachController;
  56210. private _generateNewMeshPair;
  56211. private _pickingMoved;
  56212. private _updatePointerDistance;
  56213. /** @hidden */
  56214. get lasterPointerDefaultColor(): Color3;
  56215. }
  56216. }
  56217. declare module BABYLON {
  56218. /**
  56219. * Button which can be used to enter a different mode of XR
  56220. */
  56221. export class WebXREnterExitUIButton {
  56222. /** button element */
  56223. element: HTMLElement;
  56224. /** XR initialization options for the button */
  56225. sessionMode: XRSessionMode;
  56226. /** Reference space type */
  56227. referenceSpaceType: XRReferenceSpaceType;
  56228. /**
  56229. * Creates a WebXREnterExitUIButton
  56230. * @param element button element
  56231. * @param sessionMode XR initialization session mode
  56232. * @param referenceSpaceType the type of reference space to be used
  56233. */
  56234. constructor(
  56235. /** button element */
  56236. element: HTMLElement,
  56237. /** XR initialization options for the button */
  56238. sessionMode: XRSessionMode,
  56239. /** Reference space type */
  56240. referenceSpaceType: XRReferenceSpaceType);
  56241. /**
  56242. * Extendable function which can be used to update the button's visuals when the state changes
  56243. * @param activeButton the current active button in the UI
  56244. */
  56245. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56246. }
  56247. /**
  56248. * Options to create the webXR UI
  56249. */
  56250. export class WebXREnterExitUIOptions {
  56251. /**
  56252. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56253. */
  56254. customButtons?: Array<WebXREnterExitUIButton>;
  56255. /**
  56256. * A reference space type to use when creating the default button.
  56257. * Default is local-floor
  56258. */
  56259. referenceSpaceType?: XRReferenceSpaceType;
  56260. /**
  56261. * Context to enter xr with
  56262. */
  56263. renderTarget?: Nullable<WebXRRenderTarget>;
  56264. /**
  56265. * A session mode to use when creating the default button.
  56266. * Default is immersive-vr
  56267. */
  56268. sessionMode?: XRSessionMode;
  56269. /**
  56270. * A list of optional features to init the session with
  56271. */
  56272. optionalFeatures?: string[];
  56273. /**
  56274. * A list of optional features to init the session with
  56275. */
  56276. requiredFeatures?: string[];
  56277. /**
  56278. * If defined, this function will be executed if the UI encounters an error when entering XR
  56279. */
  56280. onError?: (error: any) => void;
  56281. }
  56282. /**
  56283. * UI to allow the user to enter/exit XR mode
  56284. */
  56285. export class WebXREnterExitUI implements IDisposable {
  56286. private scene;
  56287. /** version of the options passed to this UI */
  56288. options: WebXREnterExitUIOptions;
  56289. private _activeButton;
  56290. private _buttons;
  56291. /**
  56292. * The HTML Div Element to which buttons are added.
  56293. */
  56294. readonly overlay: HTMLDivElement;
  56295. /**
  56296. * Fired every time the active button is changed.
  56297. *
  56298. * When xr is entered via a button that launches xr that button will be the callback parameter
  56299. *
  56300. * When exiting xr the callback parameter will be null)
  56301. */
  56302. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56303. /**
  56304. *
  56305. * @param scene babylon scene object to use
  56306. * @param options (read-only) version of the options passed to this UI
  56307. */
  56308. private constructor();
  56309. /**
  56310. * Creates UI to allow the user to enter/exit XR mode
  56311. * @param scene the scene to add the ui to
  56312. * @param helper the xr experience helper to enter/exit xr with
  56313. * @param options options to configure the UI
  56314. * @returns the created ui
  56315. */
  56316. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56317. /**
  56318. * Disposes of the XR UI component
  56319. */
  56320. dispose(): void;
  56321. private _updateButtons;
  56322. }
  56323. }
  56324. declare module BABYLON {
  56325. /**
  56326. * Class containing static functions to help procedurally build meshes
  56327. */
  56328. export class LinesBuilder {
  56329. /**
  56330. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56331. * * 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
  56332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56333. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56334. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56335. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56336. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56337. * * 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
  56338. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56341. * @param name defines the name of the new line system
  56342. * @param options defines the options used to create the line system
  56343. * @param scene defines the hosting scene
  56344. * @returns a new line system mesh
  56345. */
  56346. static CreateLineSystem(name: string, options: {
  56347. lines: Vector3[][];
  56348. updatable?: boolean;
  56349. instance?: Nullable<LinesMesh>;
  56350. colors?: Nullable<Color4[][]>;
  56351. useVertexAlpha?: boolean;
  56352. }, scene: Nullable<Scene>): LinesMesh;
  56353. /**
  56354. * Creates a line mesh
  56355. * 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
  56356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56357. * * The parameter `points` is an array successive Vector3
  56358. * * 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
  56359. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56361. * * When updating an instance, remember that only point positions can change, not the number of points
  56362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56364. * @param name defines the name of the new line system
  56365. * @param options defines the options used to create the line system
  56366. * @param scene defines the hosting scene
  56367. * @returns a new line mesh
  56368. */
  56369. static CreateLines(name: string, options: {
  56370. points: Vector3[];
  56371. updatable?: boolean;
  56372. instance?: Nullable<LinesMesh>;
  56373. colors?: Color4[];
  56374. useVertexAlpha?: boolean;
  56375. }, scene?: Nullable<Scene>): LinesMesh;
  56376. /**
  56377. * Creates a dashed line mesh
  56378. * * 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
  56379. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56380. * * The parameter `points` is an array successive Vector3
  56381. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56382. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56383. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56384. * * 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
  56385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56386. * * When updating an instance, remember that only point positions can change, not the number of points
  56387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56388. * @param name defines the name of the mesh
  56389. * @param options defines the options used to create the mesh
  56390. * @param scene defines the hosting scene
  56391. * @returns the dashed line mesh
  56392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56393. */
  56394. static CreateDashedLines(name: string, options: {
  56395. points: Vector3[];
  56396. dashSize?: number;
  56397. gapSize?: number;
  56398. dashNb?: number;
  56399. updatable?: boolean;
  56400. instance?: LinesMesh;
  56401. useVertexAlpha?: boolean;
  56402. }, scene?: Nullable<Scene>): LinesMesh;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /**
  56407. * Construction options for a timer
  56408. */
  56409. export interface ITimerOptions<T> {
  56410. /**
  56411. * Time-to-end
  56412. */
  56413. timeout: number;
  56414. /**
  56415. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56416. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56417. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56418. */
  56419. contextObservable: Observable<T>;
  56420. /**
  56421. * Optional parameters when adding an observer to the observable
  56422. */
  56423. observableParameters?: {
  56424. mask?: number;
  56425. insertFirst?: boolean;
  56426. scope?: any;
  56427. };
  56428. /**
  56429. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56430. */
  56431. breakCondition?: (data?: ITimerData<T>) => boolean;
  56432. /**
  56433. * Will be triggered when the time condition has met
  56434. */
  56435. onEnded?: (data: ITimerData<any>) => void;
  56436. /**
  56437. * Will be triggered when the break condition has met (prematurely ended)
  56438. */
  56439. onAborted?: (data: ITimerData<any>) => void;
  56440. /**
  56441. * Optional function to execute on each tick (or count)
  56442. */
  56443. onTick?: (data: ITimerData<any>) => void;
  56444. }
  56445. /**
  56446. * An interface defining the data sent by the timer
  56447. */
  56448. export interface ITimerData<T> {
  56449. /**
  56450. * When did it start
  56451. */
  56452. startTime: number;
  56453. /**
  56454. * Time now
  56455. */
  56456. currentTime: number;
  56457. /**
  56458. * Time passed since started
  56459. */
  56460. deltaTime: number;
  56461. /**
  56462. * How much is completed, in [0.0...1.0].
  56463. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56464. */
  56465. completeRate: number;
  56466. /**
  56467. * What the registered observable sent in the last count
  56468. */
  56469. payload: T;
  56470. }
  56471. /**
  56472. * The current state of the timer
  56473. */
  56474. export enum TimerState {
  56475. /**
  56476. * Timer initialized, not yet started
  56477. */
  56478. INIT = 0,
  56479. /**
  56480. * Timer started and counting
  56481. */
  56482. STARTED = 1,
  56483. /**
  56484. * Timer ended (whether aborted or time reached)
  56485. */
  56486. ENDED = 2
  56487. }
  56488. /**
  56489. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56490. *
  56491. * @param options options with which to initialize this timer
  56492. */
  56493. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56494. /**
  56495. * An advanced implementation of a timer class
  56496. */
  56497. export class AdvancedTimer<T = any> implements IDisposable {
  56498. /**
  56499. * Will notify each time the timer calculates the remaining time
  56500. */
  56501. onEachCountObservable: Observable<ITimerData<T>>;
  56502. /**
  56503. * Will trigger when the timer was aborted due to the break condition
  56504. */
  56505. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56506. /**
  56507. * Will trigger when the timer ended successfully
  56508. */
  56509. onTimerEndedObservable: Observable<ITimerData<T>>;
  56510. /**
  56511. * Will trigger when the timer state has changed
  56512. */
  56513. onStateChangedObservable: Observable<TimerState>;
  56514. private _observer;
  56515. private _contextObservable;
  56516. private _observableParameters;
  56517. private _startTime;
  56518. private _timer;
  56519. private _state;
  56520. private _breakCondition;
  56521. private _timeToEnd;
  56522. private _breakOnNextTick;
  56523. /**
  56524. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56525. * @param options construction options for this advanced timer
  56526. */
  56527. constructor(options: ITimerOptions<T>);
  56528. /**
  56529. * set a breaking condition for this timer. Default is to never break during count
  56530. * @param predicate the new break condition. Returns true to break, false otherwise
  56531. */
  56532. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56533. /**
  56534. * Reset ALL associated observables in this advanced timer
  56535. */
  56536. clearObservables(): void;
  56537. /**
  56538. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56539. *
  56540. * @param timeToEnd how much time to measure until timer ended
  56541. */
  56542. start(timeToEnd?: number): void;
  56543. /**
  56544. * Will force a stop on the next tick.
  56545. */
  56546. stop(): void;
  56547. /**
  56548. * Dispose this timer, clearing all resources
  56549. */
  56550. dispose(): void;
  56551. private _setState;
  56552. private _tick;
  56553. private _stop;
  56554. }
  56555. }
  56556. declare module BABYLON {
  56557. /**
  56558. * The options container for the teleportation module
  56559. */
  56560. export interface IWebXRTeleportationOptions {
  56561. /**
  56562. * if provided, this scene will be used to render meshes.
  56563. */
  56564. customUtilityLayerScene?: Scene;
  56565. /**
  56566. * Values to configure the default target mesh
  56567. */
  56568. defaultTargetMeshOptions?: {
  56569. /**
  56570. * Fill color of the teleportation area
  56571. */
  56572. teleportationFillColor?: string;
  56573. /**
  56574. * Border color for the teleportation area
  56575. */
  56576. teleportationBorderColor?: string;
  56577. /**
  56578. * Disable the mesh's animation sequence
  56579. */
  56580. disableAnimation?: boolean;
  56581. /**
  56582. * Disable lighting on the material or the ring and arrow
  56583. */
  56584. disableLighting?: boolean;
  56585. /**
  56586. * Override the default material of the torus and arrow
  56587. */
  56588. torusArrowMaterial?: Material;
  56589. };
  56590. /**
  56591. * A list of meshes to use as floor meshes.
  56592. * Meshes can be added and removed after initializing the feature using the
  56593. * addFloorMesh and removeFloorMesh functions
  56594. * If empty, rotation will still work
  56595. */
  56596. floorMeshes?: AbstractMesh[];
  56597. /**
  56598. * use this rendering group id for the meshes (optional)
  56599. */
  56600. renderingGroupId?: number;
  56601. /**
  56602. * Should teleportation move only to snap points
  56603. */
  56604. snapPointsOnly?: boolean;
  56605. /**
  56606. * An array of points to which the teleportation will snap to.
  56607. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56608. */
  56609. snapPositions?: Vector3[];
  56610. /**
  56611. * How close should the teleportation ray be in order to snap to position.
  56612. * Default to 0.8 units (meters)
  56613. */
  56614. snapToPositionRadius?: number;
  56615. /**
  56616. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56617. * If you want to support rotation, make sure your mesh has a direction indicator.
  56618. *
  56619. * When left untouched, the default mesh will be initialized.
  56620. */
  56621. teleportationTargetMesh?: AbstractMesh;
  56622. /**
  56623. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56624. */
  56625. timeToTeleport?: number;
  56626. /**
  56627. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56628. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56629. */
  56630. useMainComponentOnly?: boolean;
  56631. /**
  56632. * Should meshes created here be added to a utility layer or the main scene
  56633. */
  56634. useUtilityLayer?: boolean;
  56635. /**
  56636. * Babylon XR Input class for controller
  56637. */
  56638. xrInput: WebXRInput;
  56639. /**
  56640. * Meshes that the teleportation ray cannot go through
  56641. */
  56642. pickBlockerMeshes?: AbstractMesh[];
  56643. /**
  56644. * Should teleport work only on a specific hand?
  56645. */
  56646. forceHandedness?: XRHandedness;
  56647. /**
  56648. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56649. */
  56650. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56651. }
  56652. /**
  56653. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56654. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56655. * the input of the attached controllers.
  56656. */
  56657. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56658. private _options;
  56659. private _controllers;
  56660. private _currentTeleportationControllerId;
  56661. private _floorMeshes;
  56662. private _quadraticBezierCurve;
  56663. private _selectionFeature;
  56664. private _snapToPositions;
  56665. private _snappedToPoint;
  56666. private _teleportationRingMaterial?;
  56667. private _tmpRay;
  56668. private _tmpVector;
  56669. private _tmpQuaternion;
  56670. /**
  56671. * The module's name
  56672. */
  56673. static readonly Name: string;
  56674. /**
  56675. * The (Babylon) version of this module.
  56676. * This is an integer representing the implementation version.
  56677. * This number does not correspond to the webxr specs version
  56678. */
  56679. static readonly Version: number;
  56680. /**
  56681. * Is movement backwards enabled
  56682. */
  56683. backwardsMovementEnabled: boolean;
  56684. /**
  56685. * Distance to travel when moving backwards
  56686. */
  56687. backwardsTeleportationDistance: number;
  56688. /**
  56689. * The distance from the user to the inspection point in the direction of the controller
  56690. * A higher number will allow the user to move further
  56691. * defaults to 5 (meters, in xr units)
  56692. */
  56693. parabolicCheckRadius: number;
  56694. /**
  56695. * Should the module support parabolic ray on top of direct ray
  56696. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56697. * Very helpful when moving between floors / different heights
  56698. */
  56699. parabolicRayEnabled: boolean;
  56700. /**
  56701. * The second type of ray - straight line.
  56702. * Should it be enabled or should the parabolic line be the only one.
  56703. */
  56704. straightRayEnabled: boolean;
  56705. /**
  56706. * How much rotation should be applied when rotating right and left
  56707. */
  56708. rotationAngle: number;
  56709. private _rotationEnabled;
  56710. /**
  56711. * Is rotation enabled when moving forward?
  56712. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56713. */
  56714. get rotationEnabled(): boolean;
  56715. /**
  56716. * Sets whether rotation is enabled or not
  56717. * @param enabled is rotation enabled when teleportation is shown
  56718. */
  56719. set rotationEnabled(enabled: boolean);
  56720. /**
  56721. * Exposes the currently set teleportation target mesh.
  56722. */
  56723. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56724. /**
  56725. * constructs a new anchor system
  56726. * @param _xrSessionManager an instance of WebXRSessionManager
  56727. * @param _options configuration object for this feature
  56728. */
  56729. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56730. /**
  56731. * Get the snapPointsOnly flag
  56732. */
  56733. get snapPointsOnly(): boolean;
  56734. /**
  56735. * Sets the snapPointsOnly flag
  56736. * @param snapToPoints should teleportation be exclusively to snap points
  56737. */
  56738. set snapPointsOnly(snapToPoints: boolean);
  56739. /**
  56740. * Add a new mesh to the floor meshes array
  56741. * @param mesh the mesh to use as floor mesh
  56742. */
  56743. addFloorMesh(mesh: AbstractMesh): void;
  56744. /**
  56745. * Add a new snap-to point to fix teleportation to this position
  56746. * @param newSnapPoint The new Snap-To point
  56747. */
  56748. addSnapPoint(newSnapPoint: Vector3): void;
  56749. attach(): boolean;
  56750. detach(): boolean;
  56751. dispose(): void;
  56752. /**
  56753. * Remove a mesh from the floor meshes array
  56754. * @param mesh the mesh to remove
  56755. */
  56756. removeFloorMesh(mesh: AbstractMesh): void;
  56757. /**
  56758. * Remove a mesh from the floor meshes array using its name
  56759. * @param name the mesh name to remove
  56760. */
  56761. removeFloorMeshByName(name: string): void;
  56762. /**
  56763. * 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
  56764. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56765. * @returns was the point found and removed or not
  56766. */
  56767. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56768. /**
  56769. * This function sets a selection feature that will be disabled when
  56770. * the forward ray is shown and will be reattached when hidden.
  56771. * This is used to remove the selection rays when moving.
  56772. * @param selectionFeature the feature to disable when forward movement is enabled
  56773. */
  56774. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56775. protected _onXRFrame(_xrFrame: XRFrame): void;
  56776. private _attachController;
  56777. private _createDefaultTargetMesh;
  56778. private _detachController;
  56779. private _findClosestSnapPointWithRadius;
  56780. private _setTargetMeshPosition;
  56781. private _setTargetMeshVisibility;
  56782. private _showParabolicPath;
  56783. private _teleportForward;
  56784. }
  56785. }
  56786. declare module BABYLON {
  56787. /**
  56788. * Options for the default xr helper
  56789. */
  56790. export class WebXRDefaultExperienceOptions {
  56791. /**
  56792. * Enable or disable default UI to enter XR
  56793. */
  56794. disableDefaultUI?: boolean;
  56795. /**
  56796. * Should teleportation not initialize. defaults to false.
  56797. */
  56798. disableTeleportation?: boolean;
  56799. /**
  56800. * Floor meshes that will be used for teleport
  56801. */
  56802. floorMeshes?: Array<AbstractMesh>;
  56803. /**
  56804. * If set to true, the first frame will not be used to reset position
  56805. * The first frame is mainly used when copying transformation from the old camera
  56806. * Mainly used in AR
  56807. */
  56808. ignoreNativeCameraTransformation?: boolean;
  56809. /**
  56810. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56811. */
  56812. inputOptions?: IWebXRInputOptions;
  56813. /**
  56814. * optional configuration for the output canvas
  56815. */
  56816. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56817. /**
  56818. * optional UI options. This can be used among other to change session mode and reference space type
  56819. */
  56820. uiOptions?: WebXREnterExitUIOptions;
  56821. /**
  56822. * When loading teleportation and pointer select, use stable versions instead of latest.
  56823. */
  56824. useStablePlugins?: boolean;
  56825. /**
  56826. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56827. */
  56828. renderingGroupId?: number;
  56829. /**
  56830. * A list of optional features to init the session with
  56831. * If set to true, all features we support will be added
  56832. */
  56833. optionalFeatures?: boolean | string[];
  56834. }
  56835. /**
  56836. * Default experience which provides a similar setup to the previous webVRExperience
  56837. */
  56838. export class WebXRDefaultExperience {
  56839. /**
  56840. * Base experience
  56841. */
  56842. baseExperience: WebXRExperienceHelper;
  56843. /**
  56844. * Enables ui for entering/exiting xr
  56845. */
  56846. enterExitUI: WebXREnterExitUI;
  56847. /**
  56848. * Input experience extension
  56849. */
  56850. input: WebXRInput;
  56851. /**
  56852. * Enables laser pointer and selection
  56853. */
  56854. pointerSelection: WebXRControllerPointerSelection;
  56855. /**
  56856. * Default target xr should render to
  56857. */
  56858. renderTarget: WebXRRenderTarget;
  56859. /**
  56860. * Enables teleportation
  56861. */
  56862. teleportation: WebXRMotionControllerTeleportation;
  56863. private constructor();
  56864. /**
  56865. * Creates the default xr experience
  56866. * @param scene scene
  56867. * @param options options for basic configuration
  56868. * @returns resulting WebXRDefaultExperience
  56869. */
  56870. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56871. /**
  56872. * Disposes of the experience helper
  56873. */
  56874. dispose(): void;
  56875. }
  56876. }
  56877. declare module BABYLON {
  56878. /**
  56879. * Options to modify the vr teleportation behavior.
  56880. */
  56881. export interface VRTeleportationOptions {
  56882. /**
  56883. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56884. */
  56885. floorMeshName?: string;
  56886. /**
  56887. * A list of meshes to be used as the teleportation floor. (default: empty)
  56888. */
  56889. floorMeshes?: Mesh[];
  56890. /**
  56891. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56892. */
  56893. teleportationMode?: number;
  56894. /**
  56895. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56896. */
  56897. teleportationTime?: number;
  56898. /**
  56899. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56900. */
  56901. teleportationSpeed?: number;
  56902. /**
  56903. * The easing function used in the animation or null for Linear. (default CircleEase)
  56904. */
  56905. easingFunction?: EasingFunction;
  56906. }
  56907. /**
  56908. * Options to modify the vr experience helper's behavior.
  56909. */
  56910. export interface VRExperienceHelperOptions extends WebVROptions {
  56911. /**
  56912. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56913. */
  56914. createDeviceOrientationCamera?: boolean;
  56915. /**
  56916. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56917. */
  56918. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56919. /**
  56920. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56921. */
  56922. laserToggle?: boolean;
  56923. /**
  56924. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56925. */
  56926. floorMeshes?: Mesh[];
  56927. /**
  56928. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56929. */
  56930. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56931. /**
  56932. * Defines if WebXR should be used instead of WebVR (if available)
  56933. */
  56934. useXR?: boolean;
  56935. }
  56936. /**
  56937. * Event containing information after VR has been entered
  56938. */
  56939. export class OnAfterEnteringVRObservableEvent {
  56940. /**
  56941. * If entering vr was successful
  56942. */
  56943. success: boolean;
  56944. }
  56945. /**
  56946. * Helps to quickly add VR support to an existing scene.
  56947. * See https://doc.babylonjs.com/how_to/webvr_helper
  56948. */
  56949. export class VRExperienceHelper {
  56950. /** Options to modify the vr experience helper's behavior. */
  56951. webVROptions: VRExperienceHelperOptions;
  56952. private _scene;
  56953. private _position;
  56954. private _btnVR;
  56955. private _btnVRDisplayed;
  56956. private _webVRsupported;
  56957. private _webVRready;
  56958. private _webVRrequesting;
  56959. private _webVRpresenting;
  56960. private _hasEnteredVR;
  56961. private _fullscreenVRpresenting;
  56962. private _inputElement;
  56963. private _webVRCamera;
  56964. private _vrDeviceOrientationCamera;
  56965. private _deviceOrientationCamera;
  56966. private _existingCamera;
  56967. private _onKeyDown;
  56968. private _onVrDisplayPresentChange;
  56969. private _onVRDisplayChanged;
  56970. private _onVRRequestPresentStart;
  56971. private _onVRRequestPresentComplete;
  56972. /**
  56973. * 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)
  56974. */
  56975. enableGazeEvenWhenNoPointerLock: boolean;
  56976. /**
  56977. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56978. */
  56979. exitVROnDoubleTap: boolean;
  56980. /**
  56981. * Observable raised right before entering VR.
  56982. */
  56983. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56984. /**
  56985. * Observable raised when entering VR has completed.
  56986. */
  56987. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56988. /**
  56989. * Observable raised when exiting VR.
  56990. */
  56991. onExitingVRObservable: Observable<VRExperienceHelper>;
  56992. /**
  56993. * Observable raised when controller mesh is loaded.
  56994. */
  56995. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56996. /** Return this.onEnteringVRObservable
  56997. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56998. */
  56999. get onEnteringVR(): Observable<VRExperienceHelper>;
  57000. /** Return this.onExitingVRObservable
  57001. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  57002. */
  57003. get onExitingVR(): Observable<VRExperienceHelper>;
  57004. /** Return this.onControllerMeshLoadedObservable
  57005. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  57006. */
  57007. get onControllerMeshLoaded(): Observable<WebVRController>;
  57008. private _rayLength;
  57009. private _useCustomVRButton;
  57010. private _teleportationRequested;
  57011. private _teleportActive;
  57012. private _floorMeshName;
  57013. private _floorMeshesCollection;
  57014. private _teleportationMode;
  57015. private _teleportationTime;
  57016. private _teleportationSpeed;
  57017. private _teleportationEasing;
  57018. private _rotationAllowed;
  57019. private _teleportBackwardsVector;
  57020. private _teleportationTarget;
  57021. private _isDefaultTeleportationTarget;
  57022. private _postProcessMove;
  57023. private _teleportationFillColor;
  57024. private _teleportationBorderColor;
  57025. private _rotationAngle;
  57026. private _haloCenter;
  57027. private _cameraGazer;
  57028. private _padSensibilityUp;
  57029. private _padSensibilityDown;
  57030. private _leftController;
  57031. private _rightController;
  57032. private _gazeColor;
  57033. private _laserColor;
  57034. private _pickedLaserColor;
  57035. private _pickedGazeColor;
  57036. /**
  57037. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57038. */
  57039. onNewMeshSelected: Observable<AbstractMesh>;
  57040. /**
  57041. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57042. * This observable will provide the mesh and the controller used to select the mesh
  57043. */
  57044. onMeshSelectedWithController: Observable<{
  57045. mesh: AbstractMesh;
  57046. controller: WebVRController;
  57047. }>;
  57048. /**
  57049. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57050. */
  57051. onNewMeshPicked: Observable<PickingInfo>;
  57052. private _circleEase;
  57053. /**
  57054. * Observable raised before camera teleportation
  57055. */
  57056. onBeforeCameraTeleport: Observable<Vector3>;
  57057. /**
  57058. * Observable raised after camera teleportation
  57059. */
  57060. onAfterCameraTeleport: Observable<Vector3>;
  57061. /**
  57062. * Observable raised when current selected mesh gets unselected
  57063. */
  57064. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57065. private _raySelectionPredicate;
  57066. /**
  57067. * To be optionally changed by user to define custom ray selection
  57068. */
  57069. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57070. /**
  57071. * To be optionally changed by user to define custom selection logic (after ray selection)
  57072. */
  57073. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57074. /**
  57075. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57076. */
  57077. teleportationEnabled: boolean;
  57078. private _defaultHeight;
  57079. private _teleportationInitialized;
  57080. private _interactionsEnabled;
  57081. private _interactionsRequested;
  57082. private _displayGaze;
  57083. private _displayLaserPointer;
  57084. /**
  57085. * The mesh used to display where the user is going to teleport.
  57086. */
  57087. get teleportationTarget(): Mesh;
  57088. /**
  57089. * Sets the mesh to be used to display where the user is going to teleport.
  57090. */
  57091. set teleportationTarget(value: Mesh);
  57092. /**
  57093. * 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
  57094. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57095. * See https://doc.babylonjs.com/resources/baking_transformations
  57096. */
  57097. get gazeTrackerMesh(): Mesh;
  57098. set gazeTrackerMesh(value: Mesh);
  57099. /**
  57100. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57101. */
  57102. updateGazeTrackerScale: boolean;
  57103. /**
  57104. * If the gaze trackers color should be updated when selecting meshes
  57105. */
  57106. updateGazeTrackerColor: boolean;
  57107. /**
  57108. * If the controller laser color should be updated when selecting meshes
  57109. */
  57110. updateControllerLaserColor: boolean;
  57111. /**
  57112. * The gaze tracking mesh corresponding to the left controller
  57113. */
  57114. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57115. /**
  57116. * The gaze tracking mesh corresponding to the right controller
  57117. */
  57118. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57119. /**
  57120. * If the ray of the gaze should be displayed.
  57121. */
  57122. get displayGaze(): boolean;
  57123. /**
  57124. * Sets if the ray of the gaze should be displayed.
  57125. */
  57126. set displayGaze(value: boolean);
  57127. /**
  57128. * If the ray of the LaserPointer should be displayed.
  57129. */
  57130. get displayLaserPointer(): boolean;
  57131. /**
  57132. * Sets if the ray of the LaserPointer should be displayed.
  57133. */
  57134. set displayLaserPointer(value: boolean);
  57135. /**
  57136. * The deviceOrientationCamera used as the camera when not in VR.
  57137. */
  57138. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57139. /**
  57140. * Based on the current WebVR support, returns the current VR camera used.
  57141. */
  57142. get currentVRCamera(): Nullable<Camera>;
  57143. /**
  57144. * The webVRCamera which is used when in VR.
  57145. */
  57146. get webVRCamera(): WebVRFreeCamera;
  57147. /**
  57148. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57149. */
  57150. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57151. /**
  57152. * The html button that is used to trigger entering into VR.
  57153. */
  57154. get vrButton(): Nullable<HTMLButtonElement>;
  57155. private get _teleportationRequestInitiated();
  57156. /**
  57157. * Defines whether or not Pointer lock should be requested when switching to
  57158. * full screen.
  57159. */
  57160. requestPointerLockOnFullScreen: boolean;
  57161. /**
  57162. * If asking to force XR, this will be populated with the default xr experience
  57163. */
  57164. xr: WebXRDefaultExperience;
  57165. /**
  57166. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57167. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57168. */
  57169. xrTestDone: boolean;
  57170. /**
  57171. * Instantiates a VRExperienceHelper.
  57172. * Helps to quickly add VR support to an existing scene.
  57173. * @param scene The scene the VRExperienceHelper belongs to.
  57174. * @param webVROptions Options to modify the vr experience helper's behavior.
  57175. */
  57176. constructor(scene: Scene,
  57177. /** Options to modify the vr experience helper's behavior. */
  57178. webVROptions?: VRExperienceHelperOptions);
  57179. private completeVRInit;
  57180. private _onDefaultMeshLoaded;
  57181. private _onResize;
  57182. private _onFullscreenChange;
  57183. /**
  57184. * Gets a value indicating if we are currently in VR mode.
  57185. */
  57186. get isInVRMode(): boolean;
  57187. private onVrDisplayPresentChange;
  57188. private onVRDisplayChanged;
  57189. private moveButtonToBottomRight;
  57190. private displayVRButton;
  57191. private updateButtonVisibility;
  57192. private _cachedAngularSensibility;
  57193. /**
  57194. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57195. * Otherwise, will use the fullscreen API.
  57196. */
  57197. enterVR(): void;
  57198. /**
  57199. * Attempt to exit VR, or fullscreen.
  57200. */
  57201. exitVR(): void;
  57202. /**
  57203. * The position of the vr experience helper.
  57204. */
  57205. get position(): Vector3;
  57206. /**
  57207. * Sets the position of the vr experience helper.
  57208. */
  57209. set position(value: Vector3);
  57210. /**
  57211. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57212. */
  57213. enableInteractions(): void;
  57214. private get _noControllerIsActive();
  57215. private beforeRender;
  57216. private _isTeleportationFloor;
  57217. /**
  57218. * Adds a floor mesh to be used for teleportation.
  57219. * @param floorMesh the mesh to be used for teleportation.
  57220. */
  57221. addFloorMesh(floorMesh: Mesh): void;
  57222. /**
  57223. * Removes a floor mesh from being used for teleportation.
  57224. * @param floorMesh the mesh to be removed.
  57225. */
  57226. removeFloorMesh(floorMesh: Mesh): void;
  57227. /**
  57228. * Enables interactions and teleportation using the VR controllers and gaze.
  57229. * @param vrTeleportationOptions options to modify teleportation behavior.
  57230. */
  57231. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57232. private _onNewGamepadConnected;
  57233. private _tryEnableInteractionOnController;
  57234. private _onNewGamepadDisconnected;
  57235. private _enableInteractionOnController;
  57236. private _checkTeleportWithRay;
  57237. private _checkRotate;
  57238. private _checkTeleportBackwards;
  57239. private _enableTeleportationOnController;
  57240. private _createTeleportationCircles;
  57241. private _displayTeleportationTarget;
  57242. private _hideTeleportationTarget;
  57243. private _rotateCamera;
  57244. private _moveTeleportationSelectorTo;
  57245. private _workingVector;
  57246. private _workingQuaternion;
  57247. private _workingMatrix;
  57248. /**
  57249. * Time Constant Teleportation Mode
  57250. */
  57251. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57252. /**
  57253. * Speed Constant Teleportation Mode
  57254. */
  57255. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57256. /**
  57257. * Teleports the users feet to the desired location
  57258. * @param location The location where the user's feet should be placed
  57259. */
  57260. teleportCamera(location: Vector3): void;
  57261. private _convertNormalToDirectionOfRay;
  57262. private _castRayAndSelectObject;
  57263. private _notifySelectedMeshUnselected;
  57264. /**
  57265. * Permanently set new colors for the laser pointer
  57266. * @param color the new laser color
  57267. * @param pickedColor the new laser color when picked mesh detected
  57268. */
  57269. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57270. /**
  57271. * Set lighting enabled / disabled on the laser pointer of both controllers
  57272. * @param enabled should the lighting be enabled on the laser pointer
  57273. */
  57274. setLaserLightingState(enabled?: boolean): void;
  57275. /**
  57276. * Permanently set new colors for the gaze pointer
  57277. * @param color the new gaze color
  57278. * @param pickedColor the new gaze color when picked mesh detected
  57279. */
  57280. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57281. /**
  57282. * Sets the color of the laser ray from the vr controllers.
  57283. * @param color new color for the ray.
  57284. */
  57285. changeLaserColor(color: Color3): void;
  57286. /**
  57287. * Sets the color of the ray from the vr headsets gaze.
  57288. * @param color new color for the ray.
  57289. */
  57290. changeGazeColor(color: Color3): void;
  57291. /**
  57292. * Exits VR and disposes of the vr experience helper
  57293. */
  57294. dispose(): void;
  57295. /**
  57296. * Gets the name of the VRExperienceHelper class
  57297. * @returns "VRExperienceHelper"
  57298. */
  57299. getClassName(): string;
  57300. }
  57301. }
  57302. declare module BABYLON {
  57303. /**
  57304. * Contains an array of blocks representing the octree
  57305. */
  57306. export interface IOctreeContainer<T> {
  57307. /**
  57308. * Blocks within the octree
  57309. */
  57310. blocks: Array<OctreeBlock<T>>;
  57311. }
  57312. /**
  57313. * Class used to store a cell in an octree
  57314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57315. */
  57316. export class OctreeBlock<T> {
  57317. /**
  57318. * Gets the content of the current block
  57319. */
  57320. entries: T[];
  57321. /**
  57322. * Gets the list of block children
  57323. */
  57324. blocks: Array<OctreeBlock<T>>;
  57325. private _depth;
  57326. private _maxDepth;
  57327. private _capacity;
  57328. private _minPoint;
  57329. private _maxPoint;
  57330. private _boundingVectors;
  57331. private _creationFunc;
  57332. /**
  57333. * Creates a new block
  57334. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57335. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57336. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57337. * @param depth defines the current depth of this block in the octree
  57338. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57339. * @param creationFunc defines a callback to call when an element is added to the block
  57340. */
  57341. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57342. /**
  57343. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57344. */
  57345. get capacity(): number;
  57346. /**
  57347. * Gets the minimum vector (in world space) of the block's bounding box
  57348. */
  57349. get minPoint(): Vector3;
  57350. /**
  57351. * Gets the maximum vector (in world space) of the block's bounding box
  57352. */
  57353. get maxPoint(): Vector3;
  57354. /**
  57355. * Add a new element to this block
  57356. * @param entry defines the element to add
  57357. */
  57358. addEntry(entry: T): void;
  57359. /**
  57360. * Remove an element from this block
  57361. * @param entry defines the element to remove
  57362. */
  57363. removeEntry(entry: T): void;
  57364. /**
  57365. * Add an array of elements to this block
  57366. * @param entries defines the array of elements to add
  57367. */
  57368. addEntries(entries: T[]): void;
  57369. /**
  57370. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57371. * @param frustumPlanes defines the frustum planes to test
  57372. * @param selection defines the array to store current content if selection is positive
  57373. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57374. */
  57375. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57376. /**
  57377. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57378. * @param sphereCenter defines the bounding sphere center
  57379. * @param sphereRadius defines the bounding sphere radius
  57380. * @param selection defines the array to store current content if selection is positive
  57381. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57382. */
  57383. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57384. /**
  57385. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57386. * @param ray defines the ray to test with
  57387. * @param selection defines the array to store current content if selection is positive
  57388. */
  57389. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57390. /**
  57391. * Subdivide the content into child blocks (this block will then be empty)
  57392. */
  57393. createInnerBlocks(): void;
  57394. /**
  57395. * @hidden
  57396. */
  57397. 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;
  57398. }
  57399. }
  57400. declare module BABYLON {
  57401. /**
  57402. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57404. */
  57405. export class Octree<T> {
  57406. /** 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.) */
  57407. maxDepth: number;
  57408. /**
  57409. * Blocks within the octree containing objects
  57410. */
  57411. blocks: Array<OctreeBlock<T>>;
  57412. /**
  57413. * Content stored in the octree
  57414. */
  57415. dynamicContent: T[];
  57416. private _maxBlockCapacity;
  57417. private _selectionContent;
  57418. private _creationFunc;
  57419. /**
  57420. * Creates a octree
  57421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57422. * @param creationFunc function to be used to instantiate the octree
  57423. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57424. * @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.)
  57425. */
  57426. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57427. /** 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.) */
  57428. maxDepth?: number);
  57429. /**
  57430. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57431. * @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);
  57432. * @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);
  57433. * @param entries meshes to be added to the octree blocks
  57434. */
  57435. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57436. /**
  57437. * Adds a mesh to the octree
  57438. * @param entry Mesh to add to the octree
  57439. */
  57440. addMesh(entry: T): void;
  57441. /**
  57442. * Remove an element from the octree
  57443. * @param entry defines the element to remove
  57444. */
  57445. removeMesh(entry: T): void;
  57446. /**
  57447. * Selects an array of meshes within the frustum
  57448. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57449. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57450. * @returns array of meshes within the frustum
  57451. */
  57452. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57453. /**
  57454. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57455. * @param sphereCenter defines the bounding sphere center
  57456. * @param sphereRadius defines the bounding sphere radius
  57457. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57458. * @returns an array of objects that intersect the sphere
  57459. */
  57460. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57461. /**
  57462. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57463. * @param ray defines the ray to test with
  57464. * @returns array of intersected objects
  57465. */
  57466. intersectsRay(ray: Ray): SmartArray<T>;
  57467. /**
  57468. * Adds a mesh into the octree block if it intersects the block
  57469. */
  57470. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57471. /**
  57472. * Adds a submesh into the octree block if it intersects the block
  57473. */
  57474. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57475. }
  57476. }
  57477. declare module BABYLON {
  57478. interface Scene {
  57479. /**
  57480. * @hidden
  57481. * Backing Filed
  57482. */
  57483. _selectionOctree: Octree<AbstractMesh>;
  57484. /**
  57485. * Gets the octree used to boost mesh selection (picking)
  57486. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57487. */
  57488. selectionOctree: Octree<AbstractMesh>;
  57489. /**
  57490. * Creates or updates the octree used to boost selection (picking)
  57491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57492. * @param maxCapacity defines the maximum capacity per leaf
  57493. * @param maxDepth defines the maximum depth of the octree
  57494. * @returns an octree of AbstractMesh
  57495. */
  57496. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57497. }
  57498. interface AbstractMesh {
  57499. /**
  57500. * @hidden
  57501. * Backing Field
  57502. */
  57503. _submeshesOctree: Octree<SubMesh>;
  57504. /**
  57505. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57506. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57507. * @param maxCapacity defines the maximum size of each block (64 by default)
  57508. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57509. * @returns the new octree
  57510. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57512. */
  57513. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57514. }
  57515. /**
  57516. * Defines the octree scene component responsible to manage any octrees
  57517. * in a given scene.
  57518. */
  57519. export class OctreeSceneComponent {
  57520. /**
  57521. * The component name help to identify the component in the list of scene components.
  57522. */
  57523. readonly name: string;
  57524. /**
  57525. * The scene the component belongs to.
  57526. */
  57527. scene: Scene;
  57528. /**
  57529. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57530. */
  57531. readonly checksIsEnabled: boolean;
  57532. /**
  57533. * Creates a new instance of the component for the given scene
  57534. * @param scene Defines the scene to register the component in
  57535. */
  57536. constructor(scene: Scene);
  57537. /**
  57538. * Registers the component in a given scene
  57539. */
  57540. register(): void;
  57541. /**
  57542. * Return the list of active meshes
  57543. * @returns the list of active meshes
  57544. */
  57545. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57546. /**
  57547. * Return the list of active sub meshes
  57548. * @param mesh The mesh to get the candidates sub meshes from
  57549. * @returns the list of active sub meshes
  57550. */
  57551. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57552. private _tempRay;
  57553. /**
  57554. * Return the list of sub meshes intersecting with a given local ray
  57555. * @param mesh defines the mesh to find the submesh for
  57556. * @param localRay defines the ray in local space
  57557. * @returns the list of intersecting sub meshes
  57558. */
  57559. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57560. /**
  57561. * Return the list of sub meshes colliding with a collider
  57562. * @param mesh defines the mesh to find the submesh for
  57563. * @param collider defines the collider to evaluate the collision against
  57564. * @returns the list of colliding sub meshes
  57565. */
  57566. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57567. /**
  57568. * Rebuilds the elements related to this component in case of
  57569. * context lost for instance.
  57570. */
  57571. rebuild(): void;
  57572. /**
  57573. * Disposes the component and the associated resources.
  57574. */
  57575. dispose(): void;
  57576. }
  57577. }
  57578. declare module BABYLON {
  57579. /**
  57580. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57581. */
  57582. export interface GizmoAxisCache {
  57583. /** Mesh used to render the Gizmo */
  57584. gizmoMeshes: Mesh[];
  57585. /** Mesh used to detect user interaction with Gizmo */
  57586. colliderMeshes: Mesh[];
  57587. /** Material used to indicate color of gizmo mesh */
  57588. material: StandardMaterial;
  57589. /** Material used to indicate hover state of the Gizmo */
  57590. hoverMaterial: StandardMaterial;
  57591. /** Material used to indicate disabled state of the Gizmo */
  57592. disableMaterial: StandardMaterial;
  57593. /** Used to indicate Active state of the Gizmo */
  57594. active: boolean;
  57595. }
  57596. /**
  57597. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57598. */
  57599. export class Gizmo implements IDisposable {
  57600. /** The utility layer the gizmo will be added to */
  57601. gizmoLayer: UtilityLayerRenderer;
  57602. /**
  57603. * The root mesh of the gizmo
  57604. */
  57605. _rootMesh: Mesh;
  57606. private _attachedMesh;
  57607. private _attachedNode;
  57608. /**
  57609. * Ratio for the scale of the gizmo (Default: 1)
  57610. */
  57611. protected _scaleRatio: number;
  57612. /**
  57613. * boolean updated by pointermove when a gizmo mesh is hovered
  57614. */
  57615. protected _isHovered: boolean;
  57616. /**
  57617. * Ratio for the scale of the gizmo (Default: 1)
  57618. */
  57619. set scaleRatio(value: number);
  57620. get scaleRatio(): number;
  57621. /**
  57622. * True when the mouse pointer is hovered a gizmo mesh
  57623. */
  57624. get isHovered(): boolean;
  57625. /**
  57626. * If a custom mesh has been set (Default: false)
  57627. */
  57628. protected _customMeshSet: boolean;
  57629. /**
  57630. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57631. * * When set, interactions will be enabled
  57632. */
  57633. get attachedMesh(): Nullable<AbstractMesh>;
  57634. set attachedMesh(value: Nullable<AbstractMesh>);
  57635. /**
  57636. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57637. * * When set, interactions will be enabled
  57638. */
  57639. get attachedNode(): Nullable<Node>;
  57640. set attachedNode(value: Nullable<Node>);
  57641. /**
  57642. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57643. * @param mesh The mesh to replace the default mesh of the gizmo
  57644. */
  57645. setCustomMesh(mesh: Mesh): void;
  57646. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57647. /**
  57648. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57649. */
  57650. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57651. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57652. /**
  57653. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57654. */
  57655. updateGizmoPositionToMatchAttachedMesh: boolean;
  57656. /**
  57657. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57658. */
  57659. updateScale: boolean;
  57660. protected _interactionsEnabled: boolean;
  57661. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57662. private _beforeRenderObserver;
  57663. private _tempQuaternion;
  57664. private _tempVector;
  57665. private _tempVector2;
  57666. private _tempMatrix1;
  57667. private _tempMatrix2;
  57668. private _rightHandtoLeftHandMatrix;
  57669. /**
  57670. * Creates a gizmo
  57671. * @param gizmoLayer The utility layer the gizmo will be added to
  57672. */
  57673. constructor(
  57674. /** The utility layer the gizmo will be added to */
  57675. gizmoLayer?: UtilityLayerRenderer);
  57676. /**
  57677. * Updates the gizmo to match the attached mesh's position/rotation
  57678. */
  57679. protected _update(): void;
  57680. /**
  57681. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57682. * @param value Node, TransformNode or mesh
  57683. */
  57684. protected _matrixChanged(): void;
  57685. /**
  57686. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57687. * @param gizmoLayer The utility layer the gizmo will be added to
  57688. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57689. * @returns {Observer<PointerInfo>} pointerObserver
  57690. */
  57691. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57692. /**
  57693. * Disposes of the gizmo
  57694. */
  57695. dispose(): void;
  57696. }
  57697. }
  57698. declare module BABYLON {
  57699. /**
  57700. * Single plane drag gizmo
  57701. */
  57702. export class PlaneDragGizmo extends Gizmo {
  57703. /**
  57704. * Drag behavior responsible for the gizmos dragging interactions
  57705. */
  57706. dragBehavior: PointerDragBehavior;
  57707. private _pointerObserver;
  57708. /**
  57709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57710. */
  57711. snapDistance: number;
  57712. /**
  57713. * Event that fires each time the gizmo snaps to a new location.
  57714. * * snapDistance is the the change in distance
  57715. */
  57716. onSnapObservable: Observable<{
  57717. snapDistance: number;
  57718. }>;
  57719. private _gizmoMesh;
  57720. private _coloredMaterial;
  57721. private _hoverMaterial;
  57722. private _disableMaterial;
  57723. private _isEnabled;
  57724. private _parent;
  57725. private _dragging;
  57726. /** @hidden */
  57727. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57728. /**
  57729. * Creates a PlaneDragGizmo
  57730. * @param gizmoLayer The utility layer the gizmo will be added to
  57731. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57732. * @param color The color of the gizmo
  57733. */
  57734. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57735. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57736. /**
  57737. * If the gizmo is enabled
  57738. */
  57739. set isEnabled(value: boolean);
  57740. get isEnabled(): boolean;
  57741. /**
  57742. * Disposes of the gizmo
  57743. */
  57744. dispose(): void;
  57745. }
  57746. }
  57747. declare module BABYLON {
  57748. /**
  57749. * Single plane rotation gizmo
  57750. */
  57751. export class PlaneRotationGizmo extends Gizmo {
  57752. /**
  57753. * Drag behavior responsible for the gizmos dragging interactions
  57754. */
  57755. dragBehavior: PointerDragBehavior;
  57756. private _pointerObserver;
  57757. /**
  57758. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57759. */
  57760. snapDistance: number;
  57761. /**
  57762. * Event that fires each time the gizmo snaps to a new location.
  57763. * * snapDistance is the the change in distance
  57764. */
  57765. onSnapObservable: Observable<{
  57766. snapDistance: number;
  57767. }>;
  57768. private _isEnabled;
  57769. private _parent;
  57770. private _coloredMaterial;
  57771. private _hoverMaterial;
  57772. private _disableMaterial;
  57773. private _gizmoMesh;
  57774. private _rotationCircle;
  57775. private _dragging;
  57776. private static _CircleConstants;
  57777. /**
  57778. * Creates a PlaneRotationGizmo
  57779. * @param gizmoLayer The utility layer the gizmo will be added to
  57780. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57781. * @param color The color of the gizmo
  57782. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57783. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57784. * @param thickness display gizmo axis thickness
  57785. */
  57786. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57787. /** Create Geometry for Gizmo */
  57788. private _createGizmoMesh;
  57789. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57790. private setupRotationCircle;
  57791. private updateRotationPath;
  57792. private updateRotationCircle;
  57793. /**
  57794. * If the gizmo is enabled
  57795. */
  57796. set isEnabled(value: boolean);
  57797. get isEnabled(): boolean;
  57798. /**
  57799. * Disposes of the gizmo
  57800. */
  57801. dispose(): void;
  57802. }
  57803. }
  57804. declare module BABYLON {
  57805. /**
  57806. * Gizmo that enables rotating a mesh along 3 axis
  57807. */
  57808. export class RotationGizmo extends Gizmo {
  57809. /**
  57810. * Internal gizmo used for interactions on the x axis
  57811. */
  57812. xGizmo: PlaneRotationGizmo;
  57813. /**
  57814. * Internal gizmo used for interactions on the y axis
  57815. */
  57816. yGizmo: PlaneRotationGizmo;
  57817. /**
  57818. * Internal gizmo used for interactions on the z axis
  57819. */
  57820. zGizmo: PlaneRotationGizmo;
  57821. /** Fires an event when any of it's sub gizmos are dragged */
  57822. onDragStartObservable: Observable<unknown>;
  57823. /** Fires an event when any of it's sub gizmos are released from dragging */
  57824. onDragEndObservable: Observable<unknown>;
  57825. private _meshAttached;
  57826. private _nodeAttached;
  57827. private _observables;
  57828. /** Node Caching for quick lookup */
  57829. private _gizmoAxisCache;
  57830. get attachedMesh(): Nullable<AbstractMesh>;
  57831. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57832. get attachedNode(): Nullable<Node>;
  57833. set attachedNode(node: Nullable<Node>);
  57834. protected _checkBillboardTransform(): void;
  57835. /**
  57836. * True when the mouse pointer is hovering a gizmo mesh
  57837. */
  57838. get isHovered(): boolean;
  57839. /**
  57840. * Creates a RotationGizmo
  57841. * @param gizmoLayer The utility layer the gizmo will be added to
  57842. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57843. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57844. * @param thickness display gizmo axis thickness
  57845. */
  57846. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57847. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57848. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57849. /**
  57850. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57851. */
  57852. set snapDistance(value: number);
  57853. get snapDistance(): number;
  57854. /**
  57855. * Ratio for the scale of the gizmo (Default: 1)
  57856. */
  57857. set scaleRatio(value: number);
  57858. get scaleRatio(): number;
  57859. /**
  57860. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57861. * @param mesh Axis gizmo mesh
  57862. * @param cache Gizmo axis definition used for reactive gizmo UI
  57863. */
  57864. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57865. /**
  57866. * Disposes of the gizmo
  57867. */
  57868. dispose(): void;
  57869. /**
  57870. * CustomMeshes are not supported by this gizmo
  57871. * @param mesh The mesh to replace the default mesh of the gizmo
  57872. */
  57873. setCustomMesh(mesh: Mesh): void;
  57874. }
  57875. }
  57876. declare module BABYLON {
  57877. /**
  57878. * Class containing static functions to help procedurally build meshes
  57879. */
  57880. export class PolyhedronBuilder {
  57881. /**
  57882. * Creates a polyhedron mesh
  57883. * * 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
  57884. * * The parameter `size` (positive float, default 1) sets the polygon size
  57885. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57886. * * 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`
  57887. * * 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
  57888. * * 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)`)
  57889. * * 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
  57890. * * 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
  57891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57892. * * 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
  57893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57894. * @param name defines the name of the mesh
  57895. * @param options defines the options used to create the mesh
  57896. * @param scene defines the hosting scene
  57897. * @returns the polyhedron mesh
  57898. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57899. */
  57900. static CreatePolyhedron(name: string, options: {
  57901. type?: number;
  57902. size?: number;
  57903. sizeX?: number;
  57904. sizeY?: number;
  57905. sizeZ?: number;
  57906. custom?: any;
  57907. faceUV?: Vector4[];
  57908. faceColors?: Color4[];
  57909. flat?: boolean;
  57910. updatable?: boolean;
  57911. sideOrientation?: number;
  57912. frontUVs?: Vector4;
  57913. backUVs?: Vector4;
  57914. }, scene?: Nullable<Scene>): Mesh;
  57915. }
  57916. }
  57917. declare module BABYLON {
  57918. /**
  57919. * Class containing static functions to help procedurally build meshes
  57920. */
  57921. export class BoxBuilder {
  57922. /**
  57923. * Creates a box mesh
  57924. * * The parameter `size` sets the size (float) of each box side (default 1)
  57925. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57926. * * 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)
  57927. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57929. * * 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
  57930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57931. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57932. * @param name defines the name of the mesh
  57933. * @param options defines the options used to create the mesh
  57934. * @param scene defines the hosting scene
  57935. * @returns the box mesh
  57936. */
  57937. static CreateBox(name: string, options: {
  57938. size?: number;
  57939. width?: number;
  57940. height?: number;
  57941. depth?: number;
  57942. faceUV?: Vector4[];
  57943. faceColors?: Color4[];
  57944. sideOrientation?: number;
  57945. frontUVs?: Vector4;
  57946. backUVs?: Vector4;
  57947. wrap?: boolean;
  57948. topBaseAt?: number;
  57949. bottomBaseAt?: number;
  57950. updatable?: boolean;
  57951. }, scene?: Nullable<Scene>): Mesh;
  57952. }
  57953. }
  57954. declare module BABYLON {
  57955. /**
  57956. * Single axis scale gizmo
  57957. */
  57958. export class AxisScaleGizmo extends Gizmo {
  57959. /**
  57960. * Drag behavior responsible for the gizmos dragging interactions
  57961. */
  57962. dragBehavior: PointerDragBehavior;
  57963. private _pointerObserver;
  57964. /**
  57965. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57966. */
  57967. snapDistance: number;
  57968. /**
  57969. * Event that fires each time the gizmo snaps to a new location.
  57970. * * snapDistance is the the change in distance
  57971. */
  57972. onSnapObservable: Observable<{
  57973. snapDistance: number;
  57974. }>;
  57975. /**
  57976. * If the scaling operation should be done on all axis (default: false)
  57977. */
  57978. uniformScaling: boolean;
  57979. /**
  57980. * Custom sensitivity value for the drag strength
  57981. */
  57982. sensitivity: number;
  57983. private _isEnabled;
  57984. private _parent;
  57985. private _gizmoMesh;
  57986. private _coloredMaterial;
  57987. private _hoverMaterial;
  57988. private _disableMaterial;
  57989. private _dragging;
  57990. private _tmpVector;
  57991. private _tmpMatrix;
  57992. private _tmpMatrix2;
  57993. /**
  57994. * Creates an AxisScaleGizmo
  57995. * @param gizmoLayer The utility layer the gizmo will be added to
  57996. * @param dragAxis The axis which the gizmo will be able to scale on
  57997. * @param color The color of the gizmo
  57998. * @param thickness display gizmo axis thickness
  57999. */
  58000. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58001. /** Create Geometry for Gizmo */
  58002. private _createGizmoMesh;
  58003. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58004. /**
  58005. * If the gizmo is enabled
  58006. */
  58007. set isEnabled(value: boolean);
  58008. get isEnabled(): boolean;
  58009. /**
  58010. * Disposes of the gizmo
  58011. */
  58012. dispose(): void;
  58013. /**
  58014. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58015. * @param mesh The mesh to replace the default mesh of the gizmo
  58016. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58017. */
  58018. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58019. }
  58020. }
  58021. declare module BABYLON {
  58022. /**
  58023. * Gizmo that enables scaling a mesh along 3 axis
  58024. */
  58025. export class ScaleGizmo extends Gizmo {
  58026. /**
  58027. * Internal gizmo used for interactions on the x axis
  58028. */
  58029. xGizmo: AxisScaleGizmo;
  58030. /**
  58031. * Internal gizmo used for interactions on the y axis
  58032. */
  58033. yGizmo: AxisScaleGizmo;
  58034. /**
  58035. * Internal gizmo used for interactions on the z axis
  58036. */
  58037. zGizmo: AxisScaleGizmo;
  58038. /**
  58039. * Internal gizmo used to scale all axis equally
  58040. */
  58041. uniformScaleGizmo: AxisScaleGizmo;
  58042. private _meshAttached;
  58043. private _nodeAttached;
  58044. private _snapDistance;
  58045. private _uniformScalingMesh;
  58046. private _octahedron;
  58047. private _sensitivity;
  58048. private _coloredMaterial;
  58049. private _hoverMaterial;
  58050. private _disableMaterial;
  58051. private _observables;
  58052. /** Node Caching for quick lookup */
  58053. private _gizmoAxisCache;
  58054. /** Fires an event when any of it's sub gizmos are dragged */
  58055. onDragStartObservable: Observable<unknown>;
  58056. /** Fires an event when any of it's sub gizmos are released from dragging */
  58057. onDragEndObservable: Observable<unknown>;
  58058. get attachedMesh(): Nullable<AbstractMesh>;
  58059. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58060. get attachedNode(): Nullable<Node>;
  58061. set attachedNode(node: Nullable<Node>);
  58062. /**
  58063. * True when the mouse pointer is hovering a gizmo mesh
  58064. */
  58065. get isHovered(): boolean;
  58066. /**
  58067. * Creates a ScaleGizmo
  58068. * @param gizmoLayer The utility layer the gizmo will be added to
  58069. * @param thickness display gizmo axis thickness
  58070. */
  58071. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58072. /** Create Geometry for Gizmo */
  58073. private _createUniformScaleMesh;
  58074. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58075. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58076. /**
  58077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58078. */
  58079. set snapDistance(value: number);
  58080. get snapDistance(): number;
  58081. /**
  58082. * Ratio for the scale of the gizmo (Default: 1)
  58083. */
  58084. set scaleRatio(value: number);
  58085. get scaleRatio(): number;
  58086. /**
  58087. * Sensitivity factor for dragging (Default: 1)
  58088. */
  58089. set sensitivity(value: number);
  58090. get sensitivity(): number;
  58091. /**
  58092. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58093. * @param mesh Axis gizmo mesh
  58094. * @param cache Gizmo axis definition used for reactive gizmo UI
  58095. */
  58096. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58097. /**
  58098. * Disposes of the gizmo
  58099. */
  58100. dispose(): void;
  58101. }
  58102. }
  58103. declare module BABYLON {
  58104. /**
  58105. * Bounding box gizmo
  58106. */
  58107. export class BoundingBoxGizmo extends Gizmo {
  58108. private _lineBoundingBox;
  58109. private _rotateSpheresParent;
  58110. private _scaleBoxesParent;
  58111. private _boundingDimensions;
  58112. private _renderObserver;
  58113. private _pointerObserver;
  58114. private _scaleDragSpeed;
  58115. private _tmpQuaternion;
  58116. private _tmpVector;
  58117. private _tmpRotationMatrix;
  58118. /**
  58119. * 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)
  58120. */
  58121. ignoreChildren: boolean;
  58122. /**
  58123. * 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)
  58124. */
  58125. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58126. /**
  58127. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58128. */
  58129. rotationSphereSize: number;
  58130. /**
  58131. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58132. */
  58133. scaleBoxSize: number;
  58134. /**
  58135. * 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)
  58136. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58137. */
  58138. fixedDragMeshScreenSize: boolean;
  58139. /**
  58140. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58141. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58142. */
  58143. fixedDragMeshBoundsSize: boolean;
  58144. /**
  58145. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58146. */
  58147. fixedDragMeshScreenSizeDistanceFactor: number;
  58148. /**
  58149. * Fired when a rotation sphere or scale box is dragged
  58150. */
  58151. onDragStartObservable: Observable<{}>;
  58152. /**
  58153. * Fired when a scale box is dragged
  58154. */
  58155. onScaleBoxDragObservable: Observable<{}>;
  58156. /**
  58157. * Fired when a scale box drag is ended
  58158. */
  58159. onScaleBoxDragEndObservable: Observable<{}>;
  58160. /**
  58161. * Fired when a rotation sphere is dragged
  58162. */
  58163. onRotationSphereDragObservable: Observable<{}>;
  58164. /**
  58165. * Fired when a rotation sphere drag is ended
  58166. */
  58167. onRotationSphereDragEndObservable: Observable<{}>;
  58168. /**
  58169. * 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)
  58170. */
  58171. scalePivot: Nullable<Vector3>;
  58172. /**
  58173. * Mesh used as a pivot to rotate the attached node
  58174. */
  58175. private _anchorMesh;
  58176. private _existingMeshScale;
  58177. private _dragMesh;
  58178. private pointerDragBehavior;
  58179. private coloredMaterial;
  58180. private hoverColoredMaterial;
  58181. /**
  58182. * Sets the color of the bounding box gizmo
  58183. * @param color the color to set
  58184. */
  58185. setColor(color: Color3): void;
  58186. /**
  58187. * Creates an BoundingBoxGizmo
  58188. * @param gizmoLayer The utility layer the gizmo will be added to
  58189. * @param color The color of the gizmo
  58190. */
  58191. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58192. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58193. private _selectNode;
  58194. /**
  58195. * Updates the bounding box information for the Gizmo
  58196. */
  58197. updateBoundingBox(): void;
  58198. private _updateRotationSpheres;
  58199. private _updateScaleBoxes;
  58200. /**
  58201. * Enables rotation on the specified axis and disables rotation on the others
  58202. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58203. */
  58204. setEnabledRotationAxis(axis: string): void;
  58205. /**
  58206. * Enables/disables scaling
  58207. * @param enable if scaling should be enabled
  58208. * @param homogeneousScaling defines if scaling should only be homogeneous
  58209. */
  58210. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58211. private _updateDummy;
  58212. /**
  58213. * Enables a pointer drag behavior on the bounding box of the gizmo
  58214. */
  58215. enableDragBehavior(): void;
  58216. /**
  58217. * Disposes of the gizmo
  58218. */
  58219. dispose(): void;
  58220. /**
  58221. * 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)
  58222. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58223. * @returns the bounding box mesh with the passed in mesh as a child
  58224. */
  58225. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58226. /**
  58227. * CustomMeshes are not supported by this gizmo
  58228. * @param mesh The mesh to replace the default mesh of the gizmo
  58229. */
  58230. setCustomMesh(mesh: Mesh): void;
  58231. }
  58232. }
  58233. declare module BABYLON {
  58234. /**
  58235. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58236. */
  58237. export class GizmoManager implements IDisposable {
  58238. private scene;
  58239. /**
  58240. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58241. */
  58242. gizmos: {
  58243. positionGizmo: Nullable<PositionGizmo>;
  58244. rotationGizmo: Nullable<RotationGizmo>;
  58245. scaleGizmo: Nullable<ScaleGizmo>;
  58246. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58247. };
  58248. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58249. clearGizmoOnEmptyPointerEvent: boolean;
  58250. /** Fires an event when the manager is attached to a mesh */
  58251. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58252. /** Fires an event when the manager is attached to a node */
  58253. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58254. private _gizmosEnabled;
  58255. private _pointerObservers;
  58256. private _attachedMesh;
  58257. private _attachedNode;
  58258. private _boundingBoxColor;
  58259. private _defaultUtilityLayer;
  58260. private _defaultKeepDepthUtilityLayer;
  58261. private _thickness;
  58262. /** Node Caching for quick lookup */
  58263. private _gizmoAxisCache;
  58264. /**
  58265. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58266. */
  58267. boundingBoxDragBehavior: SixDofDragBehavior;
  58268. /**
  58269. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58270. */
  58271. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58272. /**
  58273. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58274. */
  58275. attachableNodes: Nullable<Array<Node>>;
  58276. /**
  58277. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58278. */
  58279. usePointerToAttachGizmos: boolean;
  58280. /**
  58281. * Utility layer that the bounding box gizmo belongs to
  58282. */
  58283. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58284. /**
  58285. * Utility layer that all gizmos besides bounding box belong to
  58286. */
  58287. get utilityLayer(): UtilityLayerRenderer;
  58288. /**
  58289. * True when the mouse pointer is hovering a gizmo mesh
  58290. */
  58291. get isHovered(): boolean;
  58292. /**
  58293. * Instantiates a gizmo manager
  58294. * @param scene the scene to overlay the gizmos on top of
  58295. * @param thickness display gizmo axis thickness
  58296. * @param utilityLayer the layer where gizmos are rendered
  58297. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58298. */
  58299. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58300. /**
  58301. * Subscribes to pointer down events, for attaching and detaching mesh
  58302. * @param scene The scene layer the observer will be added to
  58303. */
  58304. private _attachToMeshPointerObserver;
  58305. /**
  58306. * Attaches a set of gizmos to the specified mesh
  58307. * @param mesh The mesh the gizmo's should be attached to
  58308. */
  58309. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58310. /**
  58311. * Attaches a set of gizmos to the specified node
  58312. * @param node The node the gizmo's should be attached to
  58313. */
  58314. attachToNode(node: Nullable<Node>): void;
  58315. /**
  58316. * If the position gizmo is enabled
  58317. */
  58318. set positionGizmoEnabled(value: boolean);
  58319. get positionGizmoEnabled(): boolean;
  58320. /**
  58321. * If the rotation gizmo is enabled
  58322. */
  58323. set rotationGizmoEnabled(value: boolean);
  58324. get rotationGizmoEnabled(): boolean;
  58325. /**
  58326. * If the scale gizmo is enabled
  58327. */
  58328. set scaleGizmoEnabled(value: boolean);
  58329. get scaleGizmoEnabled(): boolean;
  58330. /**
  58331. * If the boundingBox gizmo is enabled
  58332. */
  58333. set boundingBoxGizmoEnabled(value: boolean);
  58334. get boundingBoxGizmoEnabled(): boolean;
  58335. /**
  58336. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58337. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58338. */
  58339. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58340. /**
  58341. * Disposes of the gizmo manager
  58342. */
  58343. dispose(): void;
  58344. }
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * Gizmo that enables dragging a mesh along 3 axis
  58349. */
  58350. export class PositionGizmo extends Gizmo {
  58351. /**
  58352. * Internal gizmo used for interactions on the x axis
  58353. */
  58354. xGizmo: AxisDragGizmo;
  58355. /**
  58356. * Internal gizmo used for interactions on the y axis
  58357. */
  58358. yGizmo: AxisDragGizmo;
  58359. /**
  58360. * Internal gizmo used for interactions on the z axis
  58361. */
  58362. zGizmo: AxisDragGizmo;
  58363. /**
  58364. * Internal gizmo used for interactions on the yz plane
  58365. */
  58366. xPlaneGizmo: PlaneDragGizmo;
  58367. /**
  58368. * Internal gizmo used for interactions on the xz plane
  58369. */
  58370. yPlaneGizmo: PlaneDragGizmo;
  58371. /**
  58372. * Internal gizmo used for interactions on the xy plane
  58373. */
  58374. zPlaneGizmo: PlaneDragGizmo;
  58375. /**
  58376. * private variables
  58377. */
  58378. private _meshAttached;
  58379. private _nodeAttached;
  58380. private _snapDistance;
  58381. private _observables;
  58382. /** Node Caching for quick lookup */
  58383. private _gizmoAxisCache;
  58384. /** Fires an event when any of it's sub gizmos are dragged */
  58385. onDragStartObservable: Observable<unknown>;
  58386. /** Fires an event when any of it's sub gizmos are released from dragging */
  58387. onDragEndObservable: Observable<unknown>;
  58388. /**
  58389. * If set to true, planar drag is enabled
  58390. */
  58391. private _planarGizmoEnabled;
  58392. get attachedMesh(): Nullable<AbstractMesh>;
  58393. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58394. get attachedNode(): Nullable<Node>;
  58395. set attachedNode(node: Nullable<Node>);
  58396. /**
  58397. * True when the mouse pointer is hovering a gizmo mesh
  58398. */
  58399. get isHovered(): boolean;
  58400. /**
  58401. * Creates a PositionGizmo
  58402. * @param gizmoLayer The utility layer the gizmo will be added to
  58403. @param thickness display gizmo axis thickness
  58404. */
  58405. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58406. /**
  58407. * If the planar drag gizmo is enabled
  58408. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58409. */
  58410. set planarGizmoEnabled(value: boolean);
  58411. get planarGizmoEnabled(): boolean;
  58412. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58413. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58414. /**
  58415. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58416. */
  58417. set snapDistance(value: number);
  58418. get snapDistance(): number;
  58419. /**
  58420. * Ratio for the scale of the gizmo (Default: 1)
  58421. */
  58422. set scaleRatio(value: number);
  58423. get scaleRatio(): number;
  58424. /**
  58425. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58426. * @param mesh Axis gizmo mesh
  58427. * @param cache Gizmo axis definition used for reactive gizmo UI
  58428. */
  58429. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58430. /**
  58431. * Disposes of the gizmo
  58432. */
  58433. dispose(): void;
  58434. /**
  58435. * CustomMeshes are not supported by this gizmo
  58436. * @param mesh The mesh to replace the default mesh of the gizmo
  58437. */
  58438. setCustomMesh(mesh: Mesh): void;
  58439. }
  58440. }
  58441. declare module BABYLON {
  58442. /**
  58443. * Single axis drag gizmo
  58444. */
  58445. export class AxisDragGizmo extends Gizmo {
  58446. /**
  58447. * Drag behavior responsible for the gizmos dragging interactions
  58448. */
  58449. dragBehavior: PointerDragBehavior;
  58450. private _pointerObserver;
  58451. /**
  58452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58453. */
  58454. snapDistance: number;
  58455. /**
  58456. * Event that fires each time the gizmo snaps to a new location.
  58457. * * snapDistance is the the change in distance
  58458. */
  58459. onSnapObservable: Observable<{
  58460. snapDistance: number;
  58461. }>;
  58462. private _isEnabled;
  58463. private _parent;
  58464. private _gizmoMesh;
  58465. private _coloredMaterial;
  58466. private _hoverMaterial;
  58467. private _disableMaterial;
  58468. private _dragging;
  58469. /** @hidden */
  58470. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58471. /** @hidden */
  58472. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58473. /**
  58474. * Creates an AxisDragGizmo
  58475. * @param gizmoLayer The utility layer the gizmo will be added to
  58476. * @param dragAxis The axis which the gizmo will be able to drag on
  58477. * @param color The color of the gizmo
  58478. * @param thickness display gizmo axis thickness
  58479. */
  58480. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58481. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58482. /**
  58483. * If the gizmo is enabled
  58484. */
  58485. set isEnabled(value: boolean);
  58486. get isEnabled(): boolean;
  58487. /**
  58488. * Disposes of the gizmo
  58489. */
  58490. dispose(): void;
  58491. }
  58492. }
  58493. declare module BABYLON.Debug {
  58494. /**
  58495. * The Axes viewer will show 3 axes in a specific point in space
  58496. */
  58497. export class AxesViewer {
  58498. private _xAxis;
  58499. private _yAxis;
  58500. private _zAxis;
  58501. private _scaleLinesFactor;
  58502. private _instanced;
  58503. /**
  58504. * Gets the hosting scene
  58505. */
  58506. scene: Nullable<Scene>;
  58507. /**
  58508. * Gets or sets a number used to scale line length
  58509. */
  58510. scaleLines: number;
  58511. /** Gets the node hierarchy used to render x-axis */
  58512. get xAxis(): TransformNode;
  58513. /** Gets the node hierarchy used to render y-axis */
  58514. get yAxis(): TransformNode;
  58515. /** Gets the node hierarchy used to render z-axis */
  58516. get zAxis(): TransformNode;
  58517. /**
  58518. * Creates a new AxesViewer
  58519. * @param scene defines the hosting scene
  58520. * @param scaleLines defines a number used to scale line length (1 by default)
  58521. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58522. * @param xAxis defines the node hierarchy used to render the x-axis
  58523. * @param yAxis defines the node hierarchy used to render the y-axis
  58524. * @param zAxis defines the node hierarchy used to render the z-axis
  58525. */
  58526. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58527. /**
  58528. * Force the viewer to update
  58529. * @param position defines the position of the viewer
  58530. * @param xaxis defines the x axis of the viewer
  58531. * @param yaxis defines the y axis of the viewer
  58532. * @param zaxis defines the z axis of the viewer
  58533. */
  58534. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58535. /**
  58536. * Creates an instance of this axes viewer.
  58537. * @returns a new axes viewer with instanced meshes
  58538. */
  58539. createInstance(): AxesViewer;
  58540. /** Releases resources */
  58541. dispose(): void;
  58542. private static _SetRenderingGroupId;
  58543. }
  58544. }
  58545. declare module BABYLON.Debug {
  58546. /**
  58547. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58548. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58549. */
  58550. export class BoneAxesViewer extends AxesViewer {
  58551. /**
  58552. * Gets or sets the target mesh where to display the axes viewer
  58553. */
  58554. mesh: Nullable<Mesh>;
  58555. /**
  58556. * Gets or sets the target bone where to display the axes viewer
  58557. */
  58558. bone: Nullable<Bone>;
  58559. /** Gets current position */
  58560. pos: Vector3;
  58561. /** Gets direction of X axis */
  58562. xaxis: Vector3;
  58563. /** Gets direction of Y axis */
  58564. yaxis: Vector3;
  58565. /** Gets direction of Z axis */
  58566. zaxis: Vector3;
  58567. /**
  58568. * Creates a new BoneAxesViewer
  58569. * @param scene defines the hosting scene
  58570. * @param bone defines the target bone
  58571. * @param mesh defines the target mesh
  58572. * @param scaleLines defines a scaling factor for line length (1 by default)
  58573. */
  58574. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58575. /**
  58576. * Force the viewer to update
  58577. */
  58578. update(): void;
  58579. /** Releases resources */
  58580. dispose(): void;
  58581. }
  58582. }
  58583. declare module BABYLON {
  58584. /**
  58585. * Interface used to define scene explorer extensibility option
  58586. */
  58587. export interface IExplorerExtensibilityOption {
  58588. /**
  58589. * Define the option label
  58590. */
  58591. label: string;
  58592. /**
  58593. * Defines the action to execute on click
  58594. */
  58595. action: (entity: any) => void;
  58596. }
  58597. /**
  58598. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58599. */
  58600. export interface IExplorerExtensibilityGroup {
  58601. /**
  58602. * Defines a predicate to test if a given type mut be extended
  58603. */
  58604. predicate: (entity: any) => boolean;
  58605. /**
  58606. * Gets the list of options added to a type
  58607. */
  58608. entries: IExplorerExtensibilityOption[];
  58609. }
  58610. /**
  58611. * Interface used to define the options to use to create the Inspector
  58612. */
  58613. export interface IInspectorOptions {
  58614. /**
  58615. * Display in overlay mode (default: false)
  58616. */
  58617. overlay?: boolean;
  58618. /**
  58619. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58620. */
  58621. globalRoot?: HTMLElement;
  58622. /**
  58623. * Display the Scene explorer
  58624. */
  58625. showExplorer?: boolean;
  58626. /**
  58627. * Display the property inspector
  58628. */
  58629. showInspector?: boolean;
  58630. /**
  58631. * Display in embed mode (both panes on the right)
  58632. */
  58633. embedMode?: boolean;
  58634. /**
  58635. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58636. */
  58637. handleResize?: boolean;
  58638. /**
  58639. * Allow the panes to popup (default: true)
  58640. */
  58641. enablePopup?: boolean;
  58642. /**
  58643. * Allow the panes to be closed by users (default: true)
  58644. */
  58645. enableClose?: boolean;
  58646. /**
  58647. * Optional list of extensibility entries
  58648. */
  58649. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58650. /**
  58651. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58652. */
  58653. inspectorURL?: string;
  58654. /**
  58655. * Optional initial tab (default to DebugLayerTab.Properties)
  58656. */
  58657. initialTab?: DebugLayerTab;
  58658. }
  58659. interface Scene {
  58660. /**
  58661. * @hidden
  58662. * Backing field
  58663. */
  58664. _debugLayer: DebugLayer;
  58665. /**
  58666. * Gets the debug layer (aka Inspector) associated with the scene
  58667. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58668. */
  58669. debugLayer: DebugLayer;
  58670. }
  58671. /**
  58672. * Enum of inspector action tab
  58673. */
  58674. export enum DebugLayerTab {
  58675. /**
  58676. * Properties tag (default)
  58677. */
  58678. Properties = 0,
  58679. /**
  58680. * Debug tab
  58681. */
  58682. Debug = 1,
  58683. /**
  58684. * Statistics tab
  58685. */
  58686. Statistics = 2,
  58687. /**
  58688. * Tools tab
  58689. */
  58690. Tools = 3,
  58691. /**
  58692. * Settings tab
  58693. */
  58694. Settings = 4
  58695. }
  58696. /**
  58697. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58698. * what is happening in your scene
  58699. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58700. */
  58701. export class DebugLayer {
  58702. /**
  58703. * Define the url to get the inspector script from.
  58704. * By default it uses the babylonjs CDN.
  58705. * @ignoreNaming
  58706. */
  58707. static InspectorURL: string;
  58708. private _scene;
  58709. private BJSINSPECTOR;
  58710. private _onPropertyChangedObservable?;
  58711. /**
  58712. * Observable triggered when a property is changed through the inspector.
  58713. */
  58714. get onPropertyChangedObservable(): any;
  58715. /**
  58716. * Instantiates a new debug layer.
  58717. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58718. * what is happening in your scene
  58719. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58720. * @param scene Defines the scene to inspect
  58721. */
  58722. constructor(scene: Scene);
  58723. /** Creates the inspector window. */
  58724. private _createInspector;
  58725. /**
  58726. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58727. * @param entity defines the entity to select
  58728. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58729. */
  58730. select(entity: any, lineContainerTitles?: string | string[]): void;
  58731. /** Get the inspector from bundle or global */
  58732. private _getGlobalInspector;
  58733. /**
  58734. * Get if the inspector is visible or not.
  58735. * @returns true if visible otherwise, false
  58736. */
  58737. isVisible(): boolean;
  58738. /**
  58739. * Hide the inspector and close its window.
  58740. */
  58741. hide(): void;
  58742. /**
  58743. * Update the scene in the inspector
  58744. */
  58745. setAsActiveScene(): void;
  58746. /**
  58747. * Launch the debugLayer.
  58748. * @param config Define the configuration of the inspector
  58749. * @return a promise fulfilled when the debug layer is visible
  58750. */
  58751. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58752. }
  58753. }
  58754. declare module BABYLON.Debug {
  58755. /**
  58756. * Used to show the physics impostor around the specific mesh
  58757. */
  58758. export class PhysicsViewer {
  58759. /** @hidden */
  58760. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58761. /** @hidden */
  58762. protected _meshes: Array<Nullable<AbstractMesh>>;
  58763. /** @hidden */
  58764. protected _scene: Nullable<Scene>;
  58765. /** @hidden */
  58766. protected _numMeshes: number;
  58767. /** @hidden */
  58768. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58769. private _renderFunction;
  58770. private _utilityLayer;
  58771. private _debugBoxMesh;
  58772. private _debugSphereMesh;
  58773. private _debugCylinderMesh;
  58774. private _debugMaterial;
  58775. private _debugMeshMeshes;
  58776. /**
  58777. * Creates a new PhysicsViewer
  58778. * @param scene defines the hosting scene
  58779. */
  58780. constructor(scene: Scene);
  58781. /** @hidden */
  58782. protected _updateDebugMeshes(): void;
  58783. /**
  58784. * Renders a specified physic impostor
  58785. * @param impostor defines the impostor to render
  58786. * @param targetMesh defines the mesh represented by the impostor
  58787. * @returns the new debug mesh used to render the impostor
  58788. */
  58789. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58790. /**
  58791. * Hides a specified physic impostor
  58792. * @param impostor defines the impostor to hide
  58793. */
  58794. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58795. private _getDebugMaterial;
  58796. private _getDebugBoxMesh;
  58797. private _getDebugSphereMesh;
  58798. private _getDebugCylinderMesh;
  58799. private _getDebugMeshMesh;
  58800. private _getDebugMesh;
  58801. /** Releases all resources */
  58802. dispose(): void;
  58803. }
  58804. }
  58805. declare module BABYLON {
  58806. /**
  58807. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58808. * in order to better appreciate the issue one might have.
  58809. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58810. */
  58811. export class RayHelper {
  58812. /**
  58813. * Defines the ray we are currently tryin to visualize.
  58814. */
  58815. ray: Nullable<Ray>;
  58816. private _renderPoints;
  58817. private _renderLine;
  58818. private _renderFunction;
  58819. private _scene;
  58820. private _onAfterRenderObserver;
  58821. private _onAfterStepObserver;
  58822. private _attachedToMesh;
  58823. private _meshSpaceDirection;
  58824. private _meshSpaceOrigin;
  58825. /**
  58826. * Helper function to create a colored helper in a scene in one line.
  58827. * @param ray Defines the ray we are currently tryin to visualize
  58828. * @param scene Defines the scene the ray is used in
  58829. * @param color Defines the color we want to see the ray in
  58830. * @returns The newly created ray helper.
  58831. */
  58832. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58833. /**
  58834. * Instantiate a new ray helper.
  58835. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58836. * in order to better appreciate the issue one might have.
  58837. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58838. * @param ray Defines the ray we are currently tryin to visualize
  58839. */
  58840. constructor(ray: Ray);
  58841. /**
  58842. * Shows the ray we are willing to debug.
  58843. * @param scene Defines the scene the ray needs to be rendered in
  58844. * @param color Defines the color the ray needs to be rendered in
  58845. */
  58846. show(scene: Scene, color?: Color3): void;
  58847. /**
  58848. * Hides the ray we are debugging.
  58849. */
  58850. hide(): void;
  58851. private _render;
  58852. /**
  58853. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58854. * @param mesh Defines the mesh we want the helper attached to
  58855. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58856. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58857. * @param length Defines the length of the ray
  58858. */
  58859. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58860. /**
  58861. * Detach the ray helper from the mesh it has previously been attached to.
  58862. */
  58863. detachFromMesh(): void;
  58864. private _updateToMesh;
  58865. /**
  58866. * Dispose the helper and release its associated resources.
  58867. */
  58868. dispose(): void;
  58869. }
  58870. }
  58871. declare module BABYLON {
  58872. /**
  58873. * Defines the options associated with the creation of a SkeletonViewer.
  58874. */
  58875. export interface ISkeletonViewerOptions {
  58876. /** Should the system pause animations before building the Viewer? */
  58877. pauseAnimations: boolean;
  58878. /** Should the system return the skeleton to rest before building? */
  58879. returnToRest: boolean;
  58880. /** public Display Mode of the Viewer */
  58881. displayMode: number;
  58882. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58883. displayOptions: ISkeletonViewerDisplayOptions;
  58884. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58885. computeBonesUsingShaders: boolean;
  58886. /** Flag ignore non weighted bones */
  58887. useAllBones: boolean;
  58888. }
  58889. /**
  58890. * Defines how to display the various bone meshes for the viewer.
  58891. */
  58892. export interface ISkeletonViewerDisplayOptions {
  58893. /** How far down to start tapering the bone spurs */
  58894. midStep?: number;
  58895. /** How big is the midStep? */
  58896. midStepFactor?: number;
  58897. /** Base for the Sphere Size */
  58898. sphereBaseSize?: number;
  58899. /** The ratio of the sphere to the longest bone in units */
  58900. sphereScaleUnit?: number;
  58901. /** Ratio for the Sphere Size */
  58902. sphereFactor?: number;
  58903. /** Whether a spur should attach its far end to the child bone position */
  58904. spurFollowsChild?: boolean;
  58905. /** Whether to show local axes or not */
  58906. showLocalAxes?: boolean;
  58907. /** Length of each local axis */
  58908. localAxesSize?: number;
  58909. }
  58910. /**
  58911. * Defines the constructor options for the BoneWeight Shader.
  58912. */
  58913. export interface IBoneWeightShaderOptions {
  58914. /** Skeleton to Map */
  58915. skeleton: Skeleton;
  58916. /** Colors for Uninfluenced bones */
  58917. colorBase?: Color3;
  58918. /** Colors for 0.0-0.25 Weight bones */
  58919. colorZero?: Color3;
  58920. /** Color for 0.25-0.5 Weight Influence */
  58921. colorQuarter?: Color3;
  58922. /** Color for 0.5-0.75 Weight Influence */
  58923. colorHalf?: Color3;
  58924. /** Color for 0.75-1 Weight Influence */
  58925. colorFull?: Color3;
  58926. /** Color for Zero Weight Influence */
  58927. targetBoneIndex?: number;
  58928. }
  58929. /**
  58930. * Simple structure of the gradient steps for the Color Map.
  58931. */
  58932. export interface ISkeletonMapShaderColorMapKnot {
  58933. /** Color of the Knot */
  58934. color: Color3;
  58935. /** Location of the Knot */
  58936. location: number;
  58937. }
  58938. /**
  58939. * Defines the constructor options for the SkeletonMap Shader.
  58940. */
  58941. export interface ISkeletonMapShaderOptions {
  58942. /** Skeleton to Map */
  58943. skeleton: Skeleton;
  58944. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58945. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58946. }
  58947. }
  58948. declare module BABYLON {
  58949. /**
  58950. * Class containing static functions to help procedurally build meshes
  58951. */
  58952. export class RibbonBuilder {
  58953. /**
  58954. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58955. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58956. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58957. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58958. * * 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
  58959. * * 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
  58960. * * 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
  58961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58962. * * 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
  58963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58964. * * 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
  58965. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58966. * * 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
  58967. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58969. * @param name defines the name of the mesh
  58970. * @param options defines the options used to create the mesh
  58971. * @param scene defines the hosting scene
  58972. * @returns the ribbon mesh
  58973. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58975. */
  58976. static CreateRibbon(name: string, options: {
  58977. pathArray: Vector3[][];
  58978. closeArray?: boolean;
  58979. closePath?: boolean;
  58980. offset?: number;
  58981. updatable?: boolean;
  58982. sideOrientation?: number;
  58983. frontUVs?: Vector4;
  58984. backUVs?: Vector4;
  58985. instance?: Mesh;
  58986. invertUV?: boolean;
  58987. uvs?: Vector2[];
  58988. colors?: Color4[];
  58989. }, scene?: Nullable<Scene>): Mesh;
  58990. }
  58991. }
  58992. declare module BABYLON {
  58993. /**
  58994. * Class containing static functions to help procedurally build meshes
  58995. */
  58996. export class ShapeBuilder {
  58997. /**
  58998. * 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.
  58999. * * 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.
  59000. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59001. * * 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.
  59002. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59003. * * 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
  59004. * * 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
  59005. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59007. * * 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
  59008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59010. * @param name defines the name of the mesh
  59011. * @param options defines the options used to create the mesh
  59012. * @param scene defines the hosting scene
  59013. * @returns the extruded shape mesh
  59014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59016. */
  59017. static ExtrudeShape(name: string, options: {
  59018. shape: Vector3[];
  59019. path: Vector3[];
  59020. scale?: number;
  59021. rotation?: number;
  59022. cap?: number;
  59023. updatable?: boolean;
  59024. sideOrientation?: number;
  59025. frontUVs?: Vector4;
  59026. backUVs?: Vector4;
  59027. instance?: Mesh;
  59028. invertUV?: boolean;
  59029. }, scene?: Nullable<Scene>): Mesh;
  59030. /**
  59031. * Creates an custom extruded shape mesh.
  59032. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59033. * * 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.
  59034. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59035. * * 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
  59036. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59037. * * 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
  59038. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59039. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59040. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59041. * * 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
  59042. * * 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
  59043. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59045. * * 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
  59046. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59048. * @param name defines the name of the mesh
  59049. * @param options defines the options used to create the mesh
  59050. * @param scene defines the hosting scene
  59051. * @returns the custom extruded shape mesh
  59052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59055. */
  59056. static ExtrudeShapeCustom(name: string, options: {
  59057. shape: Vector3[];
  59058. path: Vector3[];
  59059. scaleFunction?: any;
  59060. rotationFunction?: any;
  59061. ribbonCloseArray?: boolean;
  59062. ribbonClosePath?: boolean;
  59063. cap?: number;
  59064. updatable?: boolean;
  59065. sideOrientation?: number;
  59066. frontUVs?: Vector4;
  59067. backUVs?: Vector4;
  59068. instance?: Mesh;
  59069. invertUV?: boolean;
  59070. }, scene?: Nullable<Scene>): Mesh;
  59071. private static _ExtrudeShapeGeneric;
  59072. }
  59073. }
  59074. declare module BABYLON.Debug {
  59075. /**
  59076. * Class used to render a debug view of a given skeleton
  59077. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59078. */
  59079. export class SkeletonViewer {
  59080. /** defines the skeleton to render */
  59081. skeleton: Skeleton;
  59082. /** defines the mesh attached to the skeleton */
  59083. mesh: AbstractMesh;
  59084. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59085. autoUpdateBonesMatrices: boolean;
  59086. /** defines the rendering group id to use with the viewer */
  59087. renderingGroupId: number;
  59088. /** is the options for the viewer */
  59089. options: Partial<ISkeletonViewerOptions>;
  59090. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59091. static readonly DISPLAY_LINES: number;
  59092. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59093. static readonly DISPLAY_SPHERES: number;
  59094. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59095. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59096. /** public static method to create a BoneWeight Shader
  59097. * @param options The constructor options
  59098. * @param scene The scene that the shader is scoped to
  59099. * @returns The created ShaderMaterial
  59100. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59101. */
  59102. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59103. /** public static method to create a BoneWeight Shader
  59104. * @param options The constructor options
  59105. * @param scene The scene that the shader is scoped to
  59106. * @returns The created ShaderMaterial
  59107. */
  59108. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59109. /** private static method to create a BoneWeight Shader
  59110. * @param size The size of the buffer to create (usually the bone count)
  59111. * @param colorMap The gradient data to generate
  59112. * @param scene The scene that the shader is scoped to
  59113. * @returns an Array of floats from the color gradient values
  59114. */
  59115. private static _CreateBoneMapColorBuffer;
  59116. /** If SkeletonViewer scene scope. */
  59117. private _scene;
  59118. /** Gets or sets the color used to render the skeleton */
  59119. color: Color3;
  59120. /** Array of the points of the skeleton fo the line view. */
  59121. private _debugLines;
  59122. /** The SkeletonViewers Mesh. */
  59123. private _debugMesh;
  59124. /** The local axes Meshes. */
  59125. private _localAxes;
  59126. /** If SkeletonViewer is enabled. */
  59127. private _isEnabled;
  59128. /** If SkeletonViewer is ready. */
  59129. private _ready;
  59130. /** SkeletonViewer render observable. */
  59131. private _obs;
  59132. /** The Utility Layer to render the gizmos in. */
  59133. private _utilityLayer;
  59134. private _boneIndices;
  59135. /** Gets the Scene. */
  59136. get scene(): Scene;
  59137. /** Gets the utilityLayer. */
  59138. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59139. /** Checks Ready Status. */
  59140. get isReady(): Boolean;
  59141. /** Sets Ready Status. */
  59142. set ready(value: boolean);
  59143. /** Gets the debugMesh */
  59144. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59145. /** Sets the debugMesh */
  59146. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59147. /** Gets the displayMode */
  59148. get displayMode(): number;
  59149. /** Sets the displayMode */
  59150. set displayMode(value: number);
  59151. /**
  59152. * Creates a new SkeletonViewer
  59153. * @param skeleton defines the skeleton to render
  59154. * @param mesh defines the mesh attached to the skeleton
  59155. * @param scene defines the hosting scene
  59156. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59157. * @param renderingGroupId defines the rendering group id to use with the viewer
  59158. * @param options All of the extra constructor options for the SkeletonViewer
  59159. */
  59160. constructor(
  59161. /** defines the skeleton to render */
  59162. skeleton: Skeleton,
  59163. /** defines the mesh attached to the skeleton */
  59164. mesh: AbstractMesh,
  59165. /** The Scene scope*/
  59166. scene: Scene,
  59167. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59168. autoUpdateBonesMatrices?: boolean,
  59169. /** defines the rendering group id to use with the viewer */
  59170. renderingGroupId?: number,
  59171. /** is the options for the viewer */
  59172. options?: Partial<ISkeletonViewerOptions>);
  59173. /** The Dynamic bindings for the update functions */
  59174. private _bindObs;
  59175. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59176. update(): void;
  59177. /** Gets or sets a boolean indicating if the viewer is enabled */
  59178. set isEnabled(value: boolean);
  59179. get isEnabled(): boolean;
  59180. private _getBonePosition;
  59181. private _getLinesForBonesWithLength;
  59182. private _getLinesForBonesNoLength;
  59183. /** function to revert the mesh and scene back to the initial state. */
  59184. private _revert;
  59185. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59186. private _getAbsoluteBindPoseToRef;
  59187. /** function to build and bind sphere joint points and spur bone representations. */
  59188. private _buildSpheresAndSpurs;
  59189. private _buildLocalAxes;
  59190. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59191. private _displayLinesUpdate;
  59192. /** Changes the displayMode of the skeleton viewer
  59193. * @param mode The displayMode numerical value
  59194. */
  59195. changeDisplayMode(mode: number): void;
  59196. /** Sets a display option of the skeleton viewer
  59197. *
  59198. * | Option | Type | Default | Description |
  59199. * | ---------------- | ------- | ------- | ----------- |
  59200. * | 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`. |
  59201. * | 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`. |
  59202. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59203. * | 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`. |
  59204. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59205. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59206. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59207. *
  59208. * @param option String of the option name
  59209. * @param value The numerical option value
  59210. */
  59211. changeDisplayOptions(option: string, value: number): void;
  59212. /** Release associated resources */
  59213. dispose(): void;
  59214. }
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * Enum for Device Types
  59219. */
  59220. export enum DeviceType {
  59221. /** Generic */
  59222. Generic = 0,
  59223. /** Keyboard */
  59224. Keyboard = 1,
  59225. /** Mouse */
  59226. Mouse = 2,
  59227. /** Touch Pointers */
  59228. Touch = 3,
  59229. /** PS4 Dual Shock */
  59230. DualShock = 4,
  59231. /** Xbox */
  59232. Xbox = 5,
  59233. /** Switch Controller */
  59234. Switch = 6
  59235. }
  59236. /**
  59237. * Enum for All Pointers (Touch/Mouse)
  59238. */
  59239. export enum PointerInput {
  59240. /** Horizontal Axis */
  59241. Horizontal = 0,
  59242. /** Vertical Axis */
  59243. Vertical = 1,
  59244. /** Left Click or Touch */
  59245. LeftClick = 2,
  59246. /** Middle Click */
  59247. MiddleClick = 3,
  59248. /** Right Click */
  59249. RightClick = 4,
  59250. /** Browser Back */
  59251. BrowserBack = 5,
  59252. /** Browser Forward */
  59253. BrowserForward = 6
  59254. }
  59255. /**
  59256. * Enum for Dual Shock Gamepad
  59257. */
  59258. export enum DualShockInput {
  59259. /** Cross */
  59260. Cross = 0,
  59261. /** Circle */
  59262. Circle = 1,
  59263. /** Square */
  59264. Square = 2,
  59265. /** Triangle */
  59266. Triangle = 3,
  59267. /** L1 */
  59268. L1 = 4,
  59269. /** R1 */
  59270. R1 = 5,
  59271. /** L2 */
  59272. L2 = 6,
  59273. /** R2 */
  59274. R2 = 7,
  59275. /** Share */
  59276. Share = 8,
  59277. /** Options */
  59278. Options = 9,
  59279. /** L3 */
  59280. L3 = 10,
  59281. /** R3 */
  59282. R3 = 11,
  59283. /** DPadUp */
  59284. DPadUp = 12,
  59285. /** DPadDown */
  59286. DPadDown = 13,
  59287. /** DPadLeft */
  59288. DPadLeft = 14,
  59289. /** DRight */
  59290. DPadRight = 15,
  59291. /** Home */
  59292. Home = 16,
  59293. /** TouchPad */
  59294. TouchPad = 17,
  59295. /** LStickXAxis */
  59296. LStickXAxis = 18,
  59297. /** LStickYAxis */
  59298. LStickYAxis = 19,
  59299. /** RStickXAxis */
  59300. RStickXAxis = 20,
  59301. /** RStickYAxis */
  59302. RStickYAxis = 21
  59303. }
  59304. /**
  59305. * Enum for Xbox Gamepad
  59306. */
  59307. export enum XboxInput {
  59308. /** A */
  59309. A = 0,
  59310. /** B */
  59311. B = 1,
  59312. /** X */
  59313. X = 2,
  59314. /** Y */
  59315. Y = 3,
  59316. /** LB */
  59317. LB = 4,
  59318. /** RB */
  59319. RB = 5,
  59320. /** LT */
  59321. LT = 6,
  59322. /** RT */
  59323. RT = 7,
  59324. /** Back */
  59325. Back = 8,
  59326. /** Start */
  59327. Start = 9,
  59328. /** LS */
  59329. LS = 10,
  59330. /** RS */
  59331. RS = 11,
  59332. /** DPadUp */
  59333. DPadUp = 12,
  59334. /** DPadDown */
  59335. DPadDown = 13,
  59336. /** DPadLeft */
  59337. DPadLeft = 14,
  59338. /** DRight */
  59339. DPadRight = 15,
  59340. /** Home */
  59341. Home = 16,
  59342. /** LStickXAxis */
  59343. LStickXAxis = 17,
  59344. /** LStickYAxis */
  59345. LStickYAxis = 18,
  59346. /** RStickXAxis */
  59347. RStickXAxis = 19,
  59348. /** RStickYAxis */
  59349. RStickYAxis = 20
  59350. }
  59351. /**
  59352. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59353. */
  59354. export enum SwitchInput {
  59355. /** B */
  59356. B = 0,
  59357. /** A */
  59358. A = 1,
  59359. /** Y */
  59360. Y = 2,
  59361. /** X */
  59362. X = 3,
  59363. /** L */
  59364. L = 4,
  59365. /** R */
  59366. R = 5,
  59367. /** ZL */
  59368. ZL = 6,
  59369. /** ZR */
  59370. ZR = 7,
  59371. /** Minus */
  59372. Minus = 8,
  59373. /** Plus */
  59374. Plus = 9,
  59375. /** LS */
  59376. LS = 10,
  59377. /** RS */
  59378. RS = 11,
  59379. /** DPadUp */
  59380. DPadUp = 12,
  59381. /** DPadDown */
  59382. DPadDown = 13,
  59383. /** DPadLeft */
  59384. DPadLeft = 14,
  59385. /** DRight */
  59386. DPadRight = 15,
  59387. /** Home */
  59388. Home = 16,
  59389. /** Capture */
  59390. Capture = 17,
  59391. /** LStickXAxis */
  59392. LStickXAxis = 18,
  59393. /** LStickYAxis */
  59394. LStickYAxis = 19,
  59395. /** RStickXAxis */
  59396. RStickXAxis = 20,
  59397. /** RStickYAxis */
  59398. RStickYAxis = 21
  59399. }
  59400. }
  59401. declare module BABYLON {
  59402. /**
  59403. * This class will take all inputs from Keyboard, Pointer, and
  59404. * any Gamepads and provide a polling system that all devices
  59405. * will use. This class assumes that there will only be one
  59406. * pointer device and one keyboard.
  59407. */
  59408. export class DeviceInputSystem implements IDisposable {
  59409. /**
  59410. * Returns onDeviceConnected callback property
  59411. * @returns Callback with function to execute when a device is connected
  59412. */
  59413. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59414. /**
  59415. * Sets callback function when a device is connected and executes against all connected devices
  59416. * @param callback Function to execute when a device is connected
  59417. */
  59418. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59419. /**
  59420. * Callback to be triggered when a device is disconnected
  59421. */
  59422. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59423. /**
  59424. * Callback to be triggered when event driven input is updated
  59425. */
  59426. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59427. private _inputs;
  59428. private _gamepads;
  59429. private _keyboardActive;
  59430. private _pointerActive;
  59431. private _elementToAttachTo;
  59432. private _keyboardDownEvent;
  59433. private _keyboardUpEvent;
  59434. private _pointerMoveEvent;
  59435. private _pointerDownEvent;
  59436. private _pointerUpEvent;
  59437. private _gamepadConnectedEvent;
  59438. private _gamepadDisconnectedEvent;
  59439. private _onDeviceConnected;
  59440. private static _MAX_KEYCODES;
  59441. private static _MAX_POINTER_INPUTS;
  59442. private constructor();
  59443. /**
  59444. * Creates a new DeviceInputSystem instance
  59445. * @param engine Engine to pull input element from
  59446. * @returns The new instance
  59447. */
  59448. static Create(engine: Engine): DeviceInputSystem;
  59449. /**
  59450. * Checks for current device input value, given an id and input index
  59451. * @param deviceName Id of connected device
  59452. * @param inputIndex Index of device input
  59453. * @returns Current value of input
  59454. */
  59455. /**
  59456. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59457. * @param deviceType Enum specifiying device type
  59458. * @param deviceSlot "Slot" or index that device is referenced in
  59459. * @param inputIndex Id of input to be checked
  59460. * @returns Current value of input
  59461. */
  59462. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59463. /**
  59464. * Dispose of all the eventlisteners
  59465. */
  59466. dispose(): void;
  59467. /**
  59468. * Checks for existing connections to devices and register them, if necessary
  59469. * Currently handles gamepads and mouse
  59470. */
  59471. private _checkForConnectedDevices;
  59472. /**
  59473. * Add a gamepad to the DeviceInputSystem
  59474. * @param gamepad A single DOM Gamepad object
  59475. */
  59476. private _addGamePad;
  59477. /**
  59478. * Add pointer device to DeviceInputSystem
  59479. * @param deviceType Type of Pointer to add
  59480. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59481. * @param currentX Current X at point of adding
  59482. * @param currentY Current Y at point of adding
  59483. */
  59484. private _addPointerDevice;
  59485. /**
  59486. * Add device and inputs to device array
  59487. * @param deviceType Enum specifiying device type
  59488. * @param deviceSlot "Slot" or index that device is referenced in
  59489. * @param numberOfInputs Number of input entries to create for given device
  59490. */
  59491. private _registerDevice;
  59492. /**
  59493. * Given a specific device name, remove that device from the device map
  59494. * @param deviceType Enum specifiying device type
  59495. * @param deviceSlot "Slot" or index that device is referenced in
  59496. */
  59497. private _unregisterDevice;
  59498. /**
  59499. * Handle all actions that come from keyboard interaction
  59500. */
  59501. private _handleKeyActions;
  59502. /**
  59503. * Handle all actions that come from pointer interaction
  59504. */
  59505. private _handlePointerActions;
  59506. /**
  59507. * Handle all actions that come from gamepad interaction
  59508. */
  59509. private _handleGamepadActions;
  59510. /**
  59511. * Update all non-event based devices with each frame
  59512. * @param deviceType Enum specifiying device type
  59513. * @param deviceSlot "Slot" or index that device is referenced in
  59514. * @param inputIndex Id of input to be checked
  59515. */
  59516. private _updateDevice;
  59517. /**
  59518. * Gets DeviceType from the device name
  59519. * @param deviceName Name of Device from DeviceInputSystem
  59520. * @returns DeviceType enum value
  59521. */
  59522. private _getGamepadDeviceType;
  59523. }
  59524. }
  59525. declare module BABYLON {
  59526. /**
  59527. * Type to handle enforcement of inputs
  59528. */
  59529. 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;
  59530. }
  59531. declare module BABYLON {
  59532. /**
  59533. * Class that handles all input for a specific device
  59534. */
  59535. export class DeviceSource<T extends DeviceType> {
  59536. /** Type of device */
  59537. readonly deviceType: DeviceType;
  59538. /** "Slot" or index that device is referenced in */
  59539. readonly deviceSlot: number;
  59540. /**
  59541. * Observable to handle device input changes per device
  59542. */
  59543. readonly onInputChangedObservable: Observable<{
  59544. inputIndex: DeviceInput<T>;
  59545. previousState: Nullable<number>;
  59546. currentState: Nullable<number>;
  59547. }>;
  59548. private readonly _deviceInputSystem;
  59549. /**
  59550. * Default Constructor
  59551. * @param deviceInputSystem Reference to DeviceInputSystem
  59552. * @param deviceType Type of device
  59553. * @param deviceSlot "Slot" or index that device is referenced in
  59554. */
  59555. constructor(deviceInputSystem: DeviceInputSystem,
  59556. /** Type of device */
  59557. deviceType: DeviceType,
  59558. /** "Slot" or index that device is referenced in */
  59559. deviceSlot?: number);
  59560. /**
  59561. * Get input for specific input
  59562. * @param inputIndex index of specific input on device
  59563. * @returns Input value from DeviceInputSystem
  59564. */
  59565. getInput(inputIndex: DeviceInput<T>): number;
  59566. }
  59567. /**
  59568. * Class to keep track of devices
  59569. */
  59570. export class DeviceSourceManager implements IDisposable {
  59571. /**
  59572. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59573. */
  59574. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59575. /**
  59576. * Observable to be triggered when after a device is disconnected
  59577. */
  59578. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59579. private readonly _devices;
  59580. private readonly _firstDevice;
  59581. private readonly _deviceInputSystem;
  59582. /**
  59583. * Default Constructor
  59584. * @param engine engine to pull input element from
  59585. */
  59586. constructor(engine: Engine);
  59587. /**
  59588. * Gets a DeviceSource, given a type and slot
  59589. * @param deviceType Enum specifying device type
  59590. * @param deviceSlot "Slot" or index that device is referenced in
  59591. * @returns DeviceSource object
  59592. */
  59593. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59594. /**
  59595. * Gets an array of DeviceSource objects for a given device type
  59596. * @param deviceType Enum specifying device type
  59597. * @returns Array of DeviceSource objects
  59598. */
  59599. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59600. /**
  59601. * Returns a read-only list of all available devices
  59602. * @returns Read-only array with active devices
  59603. */
  59604. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59605. /**
  59606. * Dispose of DeviceInputSystem and other parts
  59607. */
  59608. dispose(): void;
  59609. /**
  59610. * Function to add device name to device list
  59611. * @param deviceType Enum specifying device type
  59612. * @param deviceSlot "Slot" or index that device is referenced in
  59613. */
  59614. private _addDevice;
  59615. /**
  59616. * Function to remove device name to device list
  59617. * @param deviceType Enum specifying device type
  59618. * @param deviceSlot "Slot" or index that device is referenced in
  59619. */
  59620. private _removeDevice;
  59621. /**
  59622. * Updates array storing first connected device of each type
  59623. * @param type Type of Device
  59624. */
  59625. private _updateFirstDevices;
  59626. }
  59627. }
  59628. declare module BABYLON {
  59629. /**
  59630. * Options to create the null engine
  59631. */
  59632. export class NullEngineOptions {
  59633. /**
  59634. * Render width (Default: 512)
  59635. */
  59636. renderWidth: number;
  59637. /**
  59638. * Render height (Default: 256)
  59639. */
  59640. renderHeight: number;
  59641. /**
  59642. * Texture size (Default: 512)
  59643. */
  59644. textureSize: number;
  59645. /**
  59646. * If delta time between frames should be constant
  59647. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59648. */
  59649. deterministicLockstep: boolean;
  59650. /**
  59651. * Maximum about of steps between frames (Default: 4)
  59652. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59653. */
  59654. lockstepMaxSteps: number;
  59655. /**
  59656. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59657. */
  59658. useHighPrecisionMatrix?: boolean;
  59659. }
  59660. /**
  59661. * The null engine class provides support for headless version of babylon.js.
  59662. * This can be used in server side scenario or for testing purposes
  59663. */
  59664. export class NullEngine extends Engine {
  59665. private _options;
  59666. /**
  59667. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59668. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59669. * @returns true if engine is in deterministic lock step mode
  59670. */
  59671. isDeterministicLockStep(): boolean;
  59672. /**
  59673. * Gets the max steps when engine is running in deterministic lock step
  59674. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59675. * @returns the max steps
  59676. */
  59677. getLockstepMaxSteps(): number;
  59678. /**
  59679. * Gets the current hardware scaling level.
  59680. * By default the hardware scaling level is computed from the window device ratio.
  59681. * 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.
  59682. * @returns a number indicating the current hardware scaling level
  59683. */
  59684. getHardwareScalingLevel(): number;
  59685. constructor(options?: NullEngineOptions);
  59686. /**
  59687. * Creates a vertex buffer
  59688. * @param vertices the data for the vertex buffer
  59689. * @returns the new WebGL static buffer
  59690. */
  59691. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59692. /**
  59693. * Creates a new index buffer
  59694. * @param indices defines the content of the index buffer
  59695. * @param updatable defines if the index buffer must be updatable
  59696. * @returns a new webGL buffer
  59697. */
  59698. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59699. /**
  59700. * Clear the current render buffer or the current render target (if any is set up)
  59701. * @param color defines the color to use
  59702. * @param backBuffer defines if the back buffer must be cleared
  59703. * @param depth defines if the depth buffer must be cleared
  59704. * @param stencil defines if the stencil buffer must be cleared
  59705. */
  59706. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59707. /**
  59708. * Gets the current render width
  59709. * @param useScreen defines if screen size must be used (or the current render target if any)
  59710. * @returns a number defining the current render width
  59711. */
  59712. getRenderWidth(useScreen?: boolean): number;
  59713. /**
  59714. * Gets the current render height
  59715. * @param useScreen defines if screen size must be used (or the current render target if any)
  59716. * @returns a number defining the current render height
  59717. */
  59718. getRenderHeight(useScreen?: boolean): number;
  59719. /**
  59720. * Set the WebGL's viewport
  59721. * @param viewport defines the viewport element to be used
  59722. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59723. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59724. */
  59725. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59726. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59727. /**
  59728. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59729. * @param pipelineContext defines the pipeline context to use
  59730. * @param uniformsNames defines the list of uniform names
  59731. * @returns an array of webGL uniform locations
  59732. */
  59733. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59734. /**
  59735. * Gets the lsit of active attributes for a given webGL program
  59736. * @param pipelineContext defines the pipeline context to use
  59737. * @param attributesNames defines the list of attribute names to get
  59738. * @returns an array of indices indicating the offset of each attribute
  59739. */
  59740. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59741. /**
  59742. * Binds an effect to the webGL context
  59743. * @param effect defines the effect to bind
  59744. */
  59745. bindSamplers(effect: Effect): void;
  59746. /**
  59747. * Activates an effect, making it the current one (ie. the one used for rendering)
  59748. * @param effect defines the effect to activate
  59749. */
  59750. enableEffect(effect: Effect): void;
  59751. /**
  59752. * Set various states to the webGL context
  59753. * @param culling defines backface culling state
  59754. * @param zOffset defines the value to apply to zOffset (0 by default)
  59755. * @param force defines if states must be applied even if cache is up to date
  59756. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59757. */
  59758. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59759. /**
  59760. * Set the value of an uniform to an array of int32
  59761. * @param uniform defines the webGL uniform location where to store the value
  59762. * @param array defines the array of int32 to store
  59763. * @returns true if value was set
  59764. */
  59765. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59766. /**
  59767. * Set the value of an uniform to an array of int32 (stored as vec2)
  59768. * @param uniform defines the webGL uniform location where to store the value
  59769. * @param array defines the array of int32 to store
  59770. * @returns true if value was set
  59771. */
  59772. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59773. /**
  59774. * Set the value of an uniform to an array of int32 (stored as vec3)
  59775. * @param uniform defines the webGL uniform location where to store the value
  59776. * @param array defines the array of int32 to store
  59777. * @returns true if value was set
  59778. */
  59779. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59780. /**
  59781. * Set the value of an uniform to an array of int32 (stored as vec4)
  59782. * @param uniform defines the webGL uniform location where to store the value
  59783. * @param array defines the array of int32 to store
  59784. * @returns true if value was set
  59785. */
  59786. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59787. /**
  59788. * Set the value of an uniform to an array of float32
  59789. * @param uniform defines the webGL uniform location where to store the value
  59790. * @param array defines the array of float32 to store
  59791. * @returns true if value was set
  59792. */
  59793. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59794. /**
  59795. * Set the value of an uniform to an array of float32 (stored as vec2)
  59796. * @param uniform defines the webGL uniform location where to store the value
  59797. * @param array defines the array of float32 to store
  59798. * @returns true if value was set
  59799. */
  59800. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59801. /**
  59802. * Set the value of an uniform to an array of float32 (stored as vec3)
  59803. * @param uniform defines the webGL uniform location where to store the value
  59804. * @param array defines the array of float32 to store
  59805. * @returns true if value was set
  59806. */
  59807. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59808. /**
  59809. * Set the value of an uniform to an array of float32 (stored as vec4)
  59810. * @param uniform defines the webGL uniform location where to store the value
  59811. * @param array defines the array of float32 to store
  59812. * @returns true if value was set
  59813. */
  59814. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59815. /**
  59816. * Set the value of an uniform to an array of number
  59817. * @param uniform defines the webGL uniform location where to store the value
  59818. * @param array defines the array of number to store
  59819. * @returns true if value was set
  59820. */
  59821. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59822. /**
  59823. * Set the value of an uniform to an array of number (stored as vec2)
  59824. * @param uniform defines the webGL uniform location where to store the value
  59825. * @param array defines the array of number to store
  59826. * @returns true if value was set
  59827. */
  59828. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59829. /**
  59830. * Set the value of an uniform to an array of number (stored as vec3)
  59831. * @param uniform defines the webGL uniform location where to store the value
  59832. * @param array defines the array of number to store
  59833. * @returns true if value was set
  59834. */
  59835. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59836. /**
  59837. * Set the value of an uniform to an array of number (stored as vec4)
  59838. * @param uniform defines the webGL uniform location where to store the value
  59839. * @param array defines the array of number to store
  59840. * @returns true if value was set
  59841. */
  59842. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59843. /**
  59844. * Set the value of an uniform to an array of float32 (stored as matrices)
  59845. * @param uniform defines the webGL uniform location where to store the value
  59846. * @param matrices defines the array of float32 to store
  59847. * @returns true if value was set
  59848. */
  59849. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59850. /**
  59851. * Set the value of an uniform to a matrix (3x3)
  59852. * @param uniform defines the webGL uniform location where to store the value
  59853. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59854. * @returns true if value was set
  59855. */
  59856. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59857. /**
  59858. * Set the value of an uniform to a matrix (2x2)
  59859. * @param uniform defines the webGL uniform location where to store the value
  59860. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59861. * @returns true if value was set
  59862. */
  59863. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59864. /**
  59865. * Set the value of an uniform to a number (float)
  59866. * @param uniform defines the webGL uniform location where to store the value
  59867. * @param value defines the float number to store
  59868. * @returns true if value was set
  59869. */
  59870. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59871. /**
  59872. * Set the value of an uniform to a vec2
  59873. * @param uniform defines the webGL uniform location where to store the value
  59874. * @param x defines the 1st component of the value
  59875. * @param y defines the 2nd component of the value
  59876. * @returns true if value was set
  59877. */
  59878. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59879. /**
  59880. * Set the value of an uniform to a vec3
  59881. * @param uniform defines the webGL uniform location where to store the value
  59882. * @param x defines the 1st component of the value
  59883. * @param y defines the 2nd component of the value
  59884. * @param z defines the 3rd component of the value
  59885. * @returns true if value was set
  59886. */
  59887. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59888. /**
  59889. * Set the value of an uniform to a boolean
  59890. * @param uniform defines the webGL uniform location where to store the value
  59891. * @param bool defines the boolean to store
  59892. * @returns true if value was set
  59893. */
  59894. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59895. /**
  59896. * Set the value of an uniform to a vec4
  59897. * @param uniform defines the webGL uniform location where to store the value
  59898. * @param x defines the 1st component of the value
  59899. * @param y defines the 2nd component of the value
  59900. * @param z defines the 3rd component of the value
  59901. * @param w defines the 4th component of the value
  59902. * @returns true if value was set
  59903. */
  59904. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59905. /**
  59906. * Sets the current alpha mode
  59907. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59908. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59910. */
  59911. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59912. /**
  59913. * Bind webGl buffers directly to the webGL context
  59914. * @param vertexBuffers defines the vertex buffer to bind
  59915. * @param indexBuffer defines the index buffer to bind
  59916. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59917. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59918. * @param effect defines the effect associated with the vertex buffer
  59919. */
  59920. bindBuffers(vertexBuffers: {
  59921. [key: string]: VertexBuffer;
  59922. }, indexBuffer: DataBuffer, effect: Effect): void;
  59923. /**
  59924. * Force the entire cache to be cleared
  59925. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59926. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59927. */
  59928. wipeCaches(bruteForce?: boolean): void;
  59929. /**
  59930. * Send a draw order
  59931. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59932. * @param indexStart defines the starting index
  59933. * @param indexCount defines the number of index to draw
  59934. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59935. */
  59936. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59937. /**
  59938. * Draw a list of indexed primitives
  59939. * @param fillMode defines the primitive to use
  59940. * @param indexStart defines the starting index
  59941. * @param indexCount defines the number of index to draw
  59942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59943. */
  59944. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59945. /**
  59946. * Draw a list of unindexed primitives
  59947. * @param fillMode defines the primitive to use
  59948. * @param verticesStart defines the index of first vertex to draw
  59949. * @param verticesCount defines the count of vertices to draw
  59950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59951. */
  59952. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59953. /** @hidden */
  59954. protected _createTexture(): WebGLTexture;
  59955. /** @hidden */
  59956. _releaseTexture(texture: InternalTexture): void;
  59957. /**
  59958. * Usually called from Texture.ts.
  59959. * Passed information to create a WebGLTexture
  59960. * @param urlArg defines a value which contains one of the following:
  59961. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59962. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59963. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59964. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59965. * @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)
  59966. * @param scene needed for loading to the correct scene
  59967. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59968. * @param onLoad optional callback to be called upon successful completion
  59969. * @param onError optional callback to be called upon failure
  59970. * @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
  59971. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59972. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59973. * @param forcedExtension defines the extension to use to pick the right loader
  59974. * @param mimeType defines an optional mime type
  59975. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59976. */
  59977. 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;
  59978. /**
  59979. * Creates a new render target texture
  59980. * @param size defines the size of the texture
  59981. * @param options defines the options used to create the texture
  59982. * @returns a new render target texture stored in an InternalTexture
  59983. */
  59984. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59985. /**
  59986. * Update the sampling mode of a given texture
  59987. * @param samplingMode defines the required sampling mode
  59988. * @param texture defines the texture to update
  59989. */
  59990. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59991. /**
  59992. * Binds the frame buffer to the specified texture.
  59993. * @param texture The texture to render to or null for the default canvas
  59994. * @param faceIndex The face of the texture to render to in case of cube texture
  59995. * @param requiredWidth The width of the target to render to
  59996. * @param requiredHeight The height of the target to render to
  59997. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59998. * @param lodLevel defines le lod level to bind to the frame buffer
  59999. */
  60000. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60001. /**
  60002. * Unbind the current render target texture from the webGL context
  60003. * @param texture defines the render target texture to unbind
  60004. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  60005. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  60006. */
  60007. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60008. /**
  60009. * Creates a dynamic vertex buffer
  60010. * @param vertices the data for the dynamic vertex buffer
  60011. * @returns the new WebGL dynamic buffer
  60012. */
  60013. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  60014. /**
  60015. * Update the content of a dynamic texture
  60016. * @param texture defines the texture to update
  60017. * @param canvas defines the canvas containing the source
  60018. * @param invertY defines if data must be stored with Y axis inverted
  60019. * @param premulAlpha defines if alpha is stored as premultiplied
  60020. * @param format defines the format of the data
  60021. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60022. */
  60023. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60024. /**
  60025. * Gets a boolean indicating if all created effects are ready
  60026. * @returns true if all effects are ready
  60027. */
  60028. areAllEffectsReady(): boolean;
  60029. /**
  60030. * @hidden
  60031. * Get the current error code of the webGL context
  60032. * @returns the error code
  60033. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60034. */
  60035. getError(): number;
  60036. /** @hidden */
  60037. _getUnpackAlignement(): number;
  60038. /** @hidden */
  60039. _unpackFlipY(value: boolean): void;
  60040. /**
  60041. * Update a dynamic index buffer
  60042. * @param indexBuffer defines the target index buffer
  60043. * @param indices defines the data to update
  60044. * @param offset defines the offset in the target index buffer where update should start
  60045. */
  60046. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60047. /**
  60048. * Updates a dynamic vertex buffer.
  60049. * @param vertexBuffer the vertex buffer to update
  60050. * @param vertices the data used to update the vertex buffer
  60051. * @param byteOffset the byte offset of the data (optional)
  60052. * @param byteLength the byte length of the data (optional)
  60053. */
  60054. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60055. /** @hidden */
  60056. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60057. /** @hidden */
  60058. _bindTexture(channel: number, texture: InternalTexture): void;
  60059. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60060. /**
  60061. * 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
  60062. */
  60063. releaseEffects(): void;
  60064. displayLoadingUI(): void;
  60065. hideLoadingUI(): void;
  60066. /** @hidden */
  60067. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60068. /** @hidden */
  60069. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60070. /** @hidden */
  60071. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60072. /** @hidden */
  60073. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60074. }
  60075. }
  60076. declare module BABYLON {
  60077. /** @hidden */
  60078. export class _OcclusionDataStorage {
  60079. /** @hidden */
  60080. occlusionInternalRetryCounter: number;
  60081. /** @hidden */
  60082. isOcclusionQueryInProgress: boolean;
  60083. /** @hidden */
  60084. isOccluded: boolean;
  60085. /** @hidden */
  60086. occlusionRetryCount: number;
  60087. /** @hidden */
  60088. occlusionType: number;
  60089. /** @hidden */
  60090. occlusionQueryAlgorithmType: number;
  60091. }
  60092. interface Engine {
  60093. /**
  60094. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60095. * @return the new query
  60096. */
  60097. createQuery(): WebGLQuery;
  60098. /**
  60099. * Delete and release a webGL query
  60100. * @param query defines the query to delete
  60101. * @return the current engine
  60102. */
  60103. deleteQuery(query: WebGLQuery): Engine;
  60104. /**
  60105. * Check if a given query has resolved and got its value
  60106. * @param query defines the query to check
  60107. * @returns true if the query got its value
  60108. */
  60109. isQueryResultAvailable(query: WebGLQuery): boolean;
  60110. /**
  60111. * Gets the value of a given query
  60112. * @param query defines the query to check
  60113. * @returns the value of the query
  60114. */
  60115. getQueryResult(query: WebGLQuery): number;
  60116. /**
  60117. * Initiates an occlusion query
  60118. * @param algorithmType defines the algorithm to use
  60119. * @param query defines the query to use
  60120. * @returns the current engine
  60121. * @see https://doc.babylonjs.com/features/occlusionquery
  60122. */
  60123. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60124. /**
  60125. * Ends an occlusion query
  60126. * @see https://doc.babylonjs.com/features/occlusionquery
  60127. * @param algorithmType defines the algorithm to use
  60128. * @returns the current engine
  60129. */
  60130. endOcclusionQuery(algorithmType: number): Engine;
  60131. /**
  60132. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60133. * Please note that only one query can be issued at a time
  60134. * @returns a time token used to track the time span
  60135. */
  60136. startTimeQuery(): Nullable<_TimeToken>;
  60137. /**
  60138. * Ends a time query
  60139. * @param token defines the token used to measure the time span
  60140. * @returns the time spent (in ns)
  60141. */
  60142. endTimeQuery(token: _TimeToken): int;
  60143. /** @hidden */
  60144. _currentNonTimestampToken: Nullable<_TimeToken>;
  60145. /** @hidden */
  60146. _createTimeQuery(): WebGLQuery;
  60147. /** @hidden */
  60148. _deleteTimeQuery(query: WebGLQuery): void;
  60149. /** @hidden */
  60150. _getGlAlgorithmType(algorithmType: number): number;
  60151. /** @hidden */
  60152. _getTimeQueryResult(query: WebGLQuery): any;
  60153. /** @hidden */
  60154. _getTimeQueryAvailability(query: WebGLQuery): any;
  60155. }
  60156. interface AbstractMesh {
  60157. /**
  60158. * Backing filed
  60159. * @hidden
  60160. */
  60161. __occlusionDataStorage: _OcclusionDataStorage;
  60162. /**
  60163. * Access property
  60164. * @hidden
  60165. */
  60166. _occlusionDataStorage: _OcclusionDataStorage;
  60167. /**
  60168. * 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.
  60169. * The default value is -1 which means don't break the query and wait till the result
  60170. * @see https://doc.babylonjs.com/features/occlusionquery
  60171. */
  60172. occlusionRetryCount: number;
  60173. /**
  60174. * 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:
  60175. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60176. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60177. * * 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.
  60178. * @see https://doc.babylonjs.com/features/occlusionquery
  60179. */
  60180. occlusionType: number;
  60181. /**
  60182. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60183. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60184. * * 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.
  60185. * @see https://doc.babylonjs.com/features/occlusionquery
  60186. */
  60187. occlusionQueryAlgorithmType: number;
  60188. /**
  60189. * 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
  60190. * @see https://doc.babylonjs.com/features/occlusionquery
  60191. */
  60192. isOccluded: boolean;
  60193. /**
  60194. * Flag to check the progress status of the query
  60195. * @see https://doc.babylonjs.com/features/occlusionquery
  60196. */
  60197. isOcclusionQueryInProgress: boolean;
  60198. }
  60199. }
  60200. declare module BABYLON {
  60201. /** @hidden */
  60202. export var _forceTransformFeedbackToBundle: boolean;
  60203. interface Engine {
  60204. /**
  60205. * Creates a webGL transform feedback object
  60206. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60207. * @returns the webGL transform feedback object
  60208. */
  60209. createTransformFeedback(): WebGLTransformFeedback;
  60210. /**
  60211. * Delete a webGL transform feedback object
  60212. * @param value defines the webGL transform feedback object to delete
  60213. */
  60214. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60215. /**
  60216. * Bind a webGL transform feedback object to the webgl context
  60217. * @param value defines the webGL transform feedback object to bind
  60218. */
  60219. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60220. /**
  60221. * Begins a transform feedback operation
  60222. * @param usePoints defines if points or triangles must be used
  60223. */
  60224. beginTransformFeedback(usePoints: boolean): void;
  60225. /**
  60226. * Ends a transform feedback operation
  60227. */
  60228. endTransformFeedback(): void;
  60229. /**
  60230. * Specify the varyings to use with transform feedback
  60231. * @param program defines the associated webGL program
  60232. * @param value defines the list of strings representing the varying names
  60233. */
  60234. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60235. /**
  60236. * Bind a webGL buffer for a transform feedback operation
  60237. * @param value defines the webGL buffer to bind
  60238. */
  60239. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60240. }
  60241. }
  60242. declare module BABYLON {
  60243. /**
  60244. * Class used to define an additional view for the engine
  60245. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60246. */
  60247. export class EngineView {
  60248. /** Defines the canvas where to render the view */
  60249. target: HTMLCanvasElement;
  60250. /** Defines an optional camera used to render the view (will use active camera else) */
  60251. camera?: Camera;
  60252. }
  60253. interface Engine {
  60254. /**
  60255. * Gets or sets the HTML element to use for attaching events
  60256. */
  60257. inputElement: Nullable<HTMLElement>;
  60258. /**
  60259. * Gets the current engine view
  60260. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60261. */
  60262. activeView: Nullable<EngineView>;
  60263. /** Gets or sets the list of views */
  60264. views: EngineView[];
  60265. /**
  60266. * Register a new child canvas
  60267. * @param canvas defines the canvas to register
  60268. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60269. * @returns the associated view
  60270. */
  60271. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60272. /**
  60273. * Remove a registered child canvas
  60274. * @param canvas defines the canvas to remove
  60275. * @returns the current engine
  60276. */
  60277. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60278. }
  60279. }
  60280. declare module BABYLON {
  60281. interface Engine {
  60282. /** @hidden */
  60283. _excludedCompressedTextures: string[];
  60284. /** @hidden */
  60285. _textureFormatInUse: string;
  60286. /**
  60287. * Gets the list of texture formats supported
  60288. */
  60289. readonly texturesSupported: Array<string>;
  60290. /**
  60291. * Gets the texture format in use
  60292. */
  60293. readonly textureFormatInUse: Nullable<string>;
  60294. /**
  60295. * Set the compressed texture extensions or file names to skip.
  60296. *
  60297. * @param skippedFiles defines the list of those texture files you want to skip
  60298. * Example: [".dds", ".env", "myfile.png"]
  60299. */
  60300. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60301. /**
  60302. * Set the compressed texture format to use, based on the formats you have, and the formats
  60303. * supported by the hardware / browser.
  60304. *
  60305. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60306. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60307. * to API arguments needed to compressed textures. This puts the burden on the container
  60308. * generator to house the arcane code for determining these for current & future formats.
  60309. *
  60310. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60311. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60312. *
  60313. * Note: The result of this call is not taken into account when a texture is base64.
  60314. *
  60315. * @param formatsAvailable defines the list of those format families you have created
  60316. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60317. *
  60318. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60319. * @returns The extension selected.
  60320. */
  60321. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60322. }
  60323. }
  60324. declare module BABYLON {
  60325. /** @hidden */
  60326. export var rgbdEncodePixelShader: {
  60327. name: string;
  60328. shader: string;
  60329. };
  60330. }
  60331. declare module BABYLON {
  60332. /**
  60333. * Raw texture data and descriptor sufficient for WebGL texture upload
  60334. */
  60335. export interface EnvironmentTextureInfo {
  60336. /**
  60337. * Version of the environment map
  60338. */
  60339. version: number;
  60340. /**
  60341. * Width of image
  60342. */
  60343. width: number;
  60344. /**
  60345. * Irradiance information stored in the file.
  60346. */
  60347. irradiance: any;
  60348. /**
  60349. * Specular information stored in the file.
  60350. */
  60351. specular: any;
  60352. }
  60353. /**
  60354. * Defines One Image in the file. It requires only the position in the file
  60355. * as well as the length.
  60356. */
  60357. interface BufferImageData {
  60358. /**
  60359. * Length of the image data.
  60360. */
  60361. length: number;
  60362. /**
  60363. * Position of the data from the null terminator delimiting the end of the JSON.
  60364. */
  60365. position: number;
  60366. }
  60367. /**
  60368. * Defines the specular data enclosed in the file.
  60369. * This corresponds to the version 1 of the data.
  60370. */
  60371. export interface EnvironmentTextureSpecularInfoV1 {
  60372. /**
  60373. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60374. */
  60375. specularDataPosition?: number;
  60376. /**
  60377. * This contains all the images data needed to reconstruct the cubemap.
  60378. */
  60379. mipmaps: Array<BufferImageData>;
  60380. /**
  60381. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60382. */
  60383. lodGenerationScale: number;
  60384. }
  60385. /**
  60386. * Sets of helpers addressing the serialization and deserialization of environment texture
  60387. * stored in a BabylonJS env file.
  60388. * Those files are usually stored as .env files.
  60389. */
  60390. export class EnvironmentTextureTools {
  60391. /**
  60392. * Magic number identifying the env file.
  60393. */
  60394. private static _MagicBytes;
  60395. /**
  60396. * Gets the environment info from an env file.
  60397. * @param data The array buffer containing the .env bytes.
  60398. * @returns the environment file info (the json header) if successfully parsed.
  60399. */
  60400. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60401. /**
  60402. * Creates an environment texture from a loaded cube texture.
  60403. * @param texture defines the cube texture to convert in env file
  60404. * @return a promise containing the environment data if successful.
  60405. */
  60406. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60407. /**
  60408. * Creates a JSON representation of the spherical data.
  60409. * @param texture defines the texture containing the polynomials
  60410. * @return the JSON representation of the spherical info
  60411. */
  60412. private static _CreateEnvTextureIrradiance;
  60413. /**
  60414. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60415. * @param data the image data
  60416. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60417. * @return the views described by info providing access to the underlying buffer
  60418. */
  60419. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60420. /**
  60421. * Uploads the texture info contained in the env file to the GPU.
  60422. * @param texture defines the internal texture to upload to
  60423. * @param data defines the data to load
  60424. * @param info defines the texture info retrieved through the GetEnvInfo method
  60425. * @returns a promise
  60426. */
  60427. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60428. private static _OnImageReadyAsync;
  60429. /**
  60430. * Uploads the levels of image data to the GPU.
  60431. * @param texture defines the internal texture to upload to
  60432. * @param imageData defines the array buffer views of image data [mipmap][face]
  60433. * @returns a promise
  60434. */
  60435. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60436. /**
  60437. * Uploads spherical polynomials information to the texture.
  60438. * @param texture defines the texture we are trying to upload the information to
  60439. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60440. */
  60441. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60442. /** @hidden */
  60443. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60444. }
  60445. }
  60446. declare module BABYLON {
  60447. /**
  60448. * Container for accessors for natively-stored mesh data buffers.
  60449. */
  60450. class NativeDataBuffer extends DataBuffer {
  60451. /**
  60452. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60453. */
  60454. nativeIndexBuffer?: any;
  60455. /**
  60456. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60457. */
  60458. nativeVertexBuffer?: any;
  60459. }
  60460. /** @hidden */
  60461. class NativeTexture extends InternalTexture {
  60462. getInternalTexture(): InternalTexture;
  60463. getViewCount(): number;
  60464. }
  60465. /** @hidden */
  60466. export class NativeEngine extends Engine {
  60467. private readonly _native;
  60468. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60469. private readonly INVALID_HANDLE;
  60470. private _boundBuffersVertexArray;
  60471. private _currentDepthTest;
  60472. getHardwareScalingLevel(): number;
  60473. constructor();
  60474. dispose(): void;
  60475. /**
  60476. * Can be used to override the current requestAnimationFrame requester.
  60477. * @hidden
  60478. */
  60479. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60480. /**
  60481. * Override default engine behavior.
  60482. * @param color
  60483. * @param backBuffer
  60484. * @param depth
  60485. * @param stencil
  60486. */
  60487. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60488. /**
  60489. * Gets host document
  60490. * @returns the host document object
  60491. */
  60492. getHostDocument(): Nullable<Document>;
  60493. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60494. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60495. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60496. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60497. [key: string]: VertexBuffer;
  60498. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60499. bindBuffers(vertexBuffers: {
  60500. [key: string]: VertexBuffer;
  60501. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60502. recordVertexArrayObject(vertexBuffers: {
  60503. [key: string]: VertexBuffer;
  60504. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60505. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60506. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60507. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60508. /**
  60509. * Draw a list of indexed primitives
  60510. * @param fillMode defines the primitive to use
  60511. * @param indexStart defines the starting index
  60512. * @param indexCount defines the number of index to draw
  60513. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60514. */
  60515. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60516. /**
  60517. * Draw a list of unindexed primitives
  60518. * @param fillMode defines the primitive to use
  60519. * @param verticesStart defines the index of first vertex to draw
  60520. * @param verticesCount defines the count of vertices to draw
  60521. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60522. */
  60523. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60524. createPipelineContext(): IPipelineContext;
  60525. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60526. /** @hidden */
  60527. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60528. /** @hidden */
  60529. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60530. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60531. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60532. protected _setProgram(program: WebGLProgram): void;
  60533. _releaseEffect(effect: Effect): void;
  60534. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60535. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60536. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60537. bindSamplers(effect: Effect): void;
  60538. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60539. getRenderWidth(useScreen?: boolean): number;
  60540. getRenderHeight(useScreen?: boolean): number;
  60541. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60542. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60543. /**
  60544. * Set the z offset to apply to current rendering
  60545. * @param value defines the offset to apply
  60546. */
  60547. setZOffset(value: number): void;
  60548. /**
  60549. * Gets the current value of the zOffset
  60550. * @returns the current zOffset state
  60551. */
  60552. getZOffset(): number;
  60553. /**
  60554. * Enable or disable depth buffering
  60555. * @param enable defines the state to set
  60556. */
  60557. setDepthBuffer(enable: boolean): void;
  60558. /**
  60559. * Gets a boolean indicating if depth writing is enabled
  60560. * @returns the current depth writing state
  60561. */
  60562. getDepthWrite(): boolean;
  60563. setDepthFunctionToGreater(): void;
  60564. setDepthFunctionToGreaterOrEqual(): void;
  60565. setDepthFunctionToLess(): void;
  60566. setDepthFunctionToLessOrEqual(): void;
  60567. /**
  60568. * Enable or disable depth writing
  60569. * @param enable defines the state to set
  60570. */
  60571. setDepthWrite(enable: boolean): void;
  60572. /**
  60573. * Enable or disable color writing
  60574. * @param enable defines the state to set
  60575. */
  60576. setColorWrite(enable: boolean): void;
  60577. /**
  60578. * Gets a boolean indicating if color writing is enabled
  60579. * @returns the current color writing state
  60580. */
  60581. getColorWrite(): boolean;
  60582. /**
  60583. * Sets alpha constants used by some alpha blending modes
  60584. * @param r defines the red component
  60585. * @param g defines the green component
  60586. * @param b defines the blue component
  60587. * @param a defines the alpha component
  60588. */
  60589. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60590. /**
  60591. * Sets the current alpha mode
  60592. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60593. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60594. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60595. */
  60596. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60597. /**
  60598. * Gets the current alpha mode
  60599. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60600. * @returns the current alpha mode
  60601. */
  60602. getAlphaMode(): number;
  60603. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60604. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60605. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60606. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60607. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60608. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60609. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60610. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60611. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60612. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60613. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60614. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60615. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60616. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60617. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60618. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60619. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60620. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60621. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60622. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60623. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60624. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60625. wipeCaches(bruteForce?: boolean): void;
  60626. protected _createTexture(): WebGLTexture;
  60627. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60628. /**
  60629. * Update the content of a dynamic texture
  60630. * @param texture defines the texture to update
  60631. * @param canvas defines the canvas containing the source
  60632. * @param invertY defines if data must be stored with Y axis inverted
  60633. * @param premulAlpha defines if alpha is stored as premultiplied
  60634. * @param format defines the format of the data
  60635. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60636. */
  60637. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60638. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60639. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60640. /**
  60641. * Usually called from Texture.ts.
  60642. * Passed information to create a WebGLTexture
  60643. * @param url defines a value which contains one of the following:
  60644. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60645. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60646. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60648. * @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)
  60649. * @param scene needed for loading to the correct scene
  60650. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60651. * @param onLoad optional callback to be called upon successful completion
  60652. * @param onError optional callback to be called upon failure
  60653. * @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
  60654. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60655. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60656. * @param forcedExtension defines the extension to use to pick the right loader
  60657. * @param mimeType defines an optional mime type
  60658. * @param loaderOptions options to be passed to the loader
  60659. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60660. */
  60661. 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;
  60662. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60663. _releaseFramebufferObjects(texture: InternalTexture): void;
  60664. /**
  60665. * Creates a cube texture
  60666. * @param rootUrl defines the url where the files to load is located
  60667. * @param scene defines the current scene
  60668. * @param files defines the list of files to load (1 per face)
  60669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60670. * @param onLoad defines an optional callback raised when the texture is loaded
  60671. * @param onError defines an optional callback raised if there is an issue to load the texture
  60672. * @param format defines the format of the data
  60673. * @param forcedExtension defines the extension to use to pick the right loader
  60674. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60675. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60676. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60677. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60678. * @returns the cube texture as an InternalTexture
  60679. */
  60680. 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;
  60681. createRenderTargetTexture(size: number | {
  60682. width: number;
  60683. height: number;
  60684. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60685. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60686. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60687. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60688. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60689. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60690. /**
  60691. * Updates a dynamic vertex buffer.
  60692. * @param vertexBuffer the vertex buffer to update
  60693. * @param data the data used to update the vertex buffer
  60694. * @param byteOffset the byte offset of the data (optional)
  60695. * @param byteLength the byte length of the data (optional)
  60696. */
  60697. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60698. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60699. private _updateAnisotropicLevel;
  60700. private _getAddressMode;
  60701. /** @hidden */
  60702. _bindTexture(channel: number, texture: InternalTexture): void;
  60703. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60704. releaseEffects(): void;
  60705. /** @hidden */
  60706. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60707. /** @hidden */
  60708. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60709. /** @hidden */
  60710. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60711. /** @hidden */
  60712. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60713. private _getNativeSamplingMode;
  60714. private _getNativeTextureFormat;
  60715. private _getNativeAlphaMode;
  60716. private _getNativeAttribType;
  60717. }
  60718. }
  60719. declare module BABYLON {
  60720. /**
  60721. * Helper class to create the best engine depending on the current hardware
  60722. */
  60723. export class EngineFactory {
  60724. /**
  60725. * Creates an engine based on the capabilities of the underlying hardware
  60726. * @param canvas Defines the canvas to use to display the result
  60727. * @param options Defines the options passed to the engine to create the context dependencies
  60728. * @returns a promise that resolves with the created engine
  60729. */
  60730. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60731. }
  60732. }
  60733. declare module BABYLON {
  60734. /**
  60735. * Gather the list of clipboard event types as constants.
  60736. */
  60737. export class ClipboardEventTypes {
  60738. /**
  60739. * The clipboard event is fired when a copy command is active (pressed).
  60740. */
  60741. static readonly COPY: number;
  60742. /**
  60743. * The clipboard event is fired when a cut command is active (pressed).
  60744. */
  60745. static readonly CUT: number;
  60746. /**
  60747. * The clipboard event is fired when a paste command is active (pressed).
  60748. */
  60749. static readonly PASTE: number;
  60750. }
  60751. /**
  60752. * This class is used to store clipboard related info for the onClipboardObservable event.
  60753. */
  60754. export class ClipboardInfo {
  60755. /**
  60756. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60757. */
  60758. type: number;
  60759. /**
  60760. * Defines the related dom event
  60761. */
  60762. event: ClipboardEvent;
  60763. /**
  60764. *Creates an instance of ClipboardInfo.
  60765. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60766. * @param event Defines the related dom event
  60767. */
  60768. constructor(
  60769. /**
  60770. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60771. */
  60772. type: number,
  60773. /**
  60774. * Defines the related dom event
  60775. */
  60776. event: ClipboardEvent);
  60777. /**
  60778. * Get the clipboard event's type from the keycode.
  60779. * @param keyCode Defines the keyCode for the current keyboard event.
  60780. * @return {number}
  60781. */
  60782. static GetTypeFromCharacter(keyCode: number): number;
  60783. }
  60784. }
  60785. declare module BABYLON {
  60786. /**
  60787. * Google Daydream controller
  60788. */
  60789. export class DaydreamController extends WebVRController {
  60790. /**
  60791. * Base Url for the controller model.
  60792. */
  60793. static MODEL_BASE_URL: string;
  60794. /**
  60795. * File name for the controller model.
  60796. */
  60797. static MODEL_FILENAME: string;
  60798. /**
  60799. * Gamepad Id prefix used to identify Daydream Controller.
  60800. */
  60801. static readonly GAMEPAD_ID_PREFIX: string;
  60802. /**
  60803. * Creates a new DaydreamController from a gamepad
  60804. * @param vrGamepad the gamepad that the controller should be created from
  60805. */
  60806. constructor(vrGamepad: any);
  60807. /**
  60808. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60809. * @param scene scene in which to add meshes
  60810. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60811. */
  60812. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60813. /**
  60814. * Called once for each button that changed state since the last frame
  60815. * @param buttonIdx Which button index changed
  60816. * @param state New state of the button
  60817. * @param changes Which properties on the state changed since last frame
  60818. */
  60819. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60820. }
  60821. }
  60822. declare module BABYLON {
  60823. /**
  60824. * Gear VR Controller
  60825. */
  60826. export class GearVRController extends WebVRController {
  60827. /**
  60828. * Base Url for the controller model.
  60829. */
  60830. static MODEL_BASE_URL: string;
  60831. /**
  60832. * File name for the controller model.
  60833. */
  60834. static MODEL_FILENAME: string;
  60835. /**
  60836. * Gamepad Id prefix used to identify this controller.
  60837. */
  60838. static readonly GAMEPAD_ID_PREFIX: string;
  60839. private readonly _buttonIndexToObservableNameMap;
  60840. /**
  60841. * Creates a new GearVRController from a gamepad
  60842. * @param vrGamepad the gamepad that the controller should be created from
  60843. */
  60844. constructor(vrGamepad: any);
  60845. /**
  60846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60847. * @param scene scene in which to add meshes
  60848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60849. */
  60850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60851. /**
  60852. * Called once for each button that changed state since the last frame
  60853. * @param buttonIdx Which button index changed
  60854. * @param state New state of the button
  60855. * @param changes Which properties on the state changed since last frame
  60856. */
  60857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /**
  60862. * Generic Controller
  60863. */
  60864. export class GenericController extends WebVRController {
  60865. /**
  60866. * Base Url for the controller model.
  60867. */
  60868. static readonly MODEL_BASE_URL: string;
  60869. /**
  60870. * File name for the controller model.
  60871. */
  60872. static readonly MODEL_FILENAME: string;
  60873. /**
  60874. * Creates a new GenericController from a gamepad
  60875. * @param vrGamepad the gamepad that the controller should be created from
  60876. */
  60877. constructor(vrGamepad: any);
  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): void;
  60884. /**
  60885. * Called once for each button that changed state since the last frame
  60886. * @param buttonIdx Which button index changed
  60887. * @param state New state of the button
  60888. * @param changes Which properties on the state changed since last frame
  60889. */
  60890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60891. }
  60892. }
  60893. declare module BABYLON {
  60894. /**
  60895. * Oculus Touch Controller
  60896. */
  60897. export class OculusTouchController extends WebVRController {
  60898. /**
  60899. * Base Url for the controller model.
  60900. */
  60901. static MODEL_BASE_URL: string;
  60902. /**
  60903. * File name for the left controller model.
  60904. */
  60905. static MODEL_LEFT_FILENAME: string;
  60906. /**
  60907. * File name for the right controller model.
  60908. */
  60909. static MODEL_RIGHT_FILENAME: string;
  60910. /**
  60911. * Base Url for the Quest controller model.
  60912. */
  60913. static QUEST_MODEL_BASE_URL: string;
  60914. /**
  60915. * @hidden
  60916. * If the controllers are running on a device that needs the updated Quest controller models
  60917. */
  60918. static _IsQuest: boolean;
  60919. /**
  60920. * Fired when the secondary trigger on this controller is modified
  60921. */
  60922. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60923. /**
  60924. * Fired when the thumb rest on this controller is modified
  60925. */
  60926. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60927. /**
  60928. * Creates a new OculusTouchController from a gamepad
  60929. * @param vrGamepad the gamepad that the controller should be created from
  60930. */
  60931. constructor(vrGamepad: any);
  60932. /**
  60933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60934. * @param scene scene in which to add meshes
  60935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60936. */
  60937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60938. /**
  60939. * Fired when the A button on this controller is modified
  60940. */
  60941. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60942. /**
  60943. * Fired when the B button on this controller is modified
  60944. */
  60945. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60946. /**
  60947. * Fired when the X button on this controller is modified
  60948. */
  60949. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60950. /**
  60951. * Fired when the Y button on this controller is modified
  60952. */
  60953. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60954. /**
  60955. * Called once for each button that changed state since the last frame
  60956. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60957. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60958. * 2) secondary trigger (same)
  60959. * 3) A (right) X (left), touch, pressed = value
  60960. * 4) B / Y
  60961. * 5) thumb rest
  60962. * @param buttonIdx Which button index changed
  60963. * @param state New state of the button
  60964. * @param changes Which properties on the state changed since last frame
  60965. */
  60966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60967. }
  60968. }
  60969. declare module BABYLON {
  60970. /**
  60971. * Vive Controller
  60972. */
  60973. export class ViveController extends WebVRController {
  60974. /**
  60975. * Base Url for the controller model.
  60976. */
  60977. static MODEL_BASE_URL: string;
  60978. /**
  60979. * File name for the controller model.
  60980. */
  60981. static MODEL_FILENAME: string;
  60982. /**
  60983. * Creates a new ViveController from a gamepad
  60984. * @param vrGamepad the gamepad that the controller should be created from
  60985. */
  60986. constructor(vrGamepad: any);
  60987. /**
  60988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60989. * @param scene scene in which to add meshes
  60990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60991. */
  60992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60993. /**
  60994. * Fired when the left button on this controller is modified
  60995. */
  60996. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60997. /**
  60998. * Fired when the right button on this controller is modified
  60999. */
  61000. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61001. /**
  61002. * Fired when the menu button on this controller is modified
  61003. */
  61004. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61005. /**
  61006. * Called once for each button that changed state since the last frame
  61007. * Vive mapping:
  61008. * 0: touchpad
  61009. * 1: trigger
  61010. * 2: left AND right buttons
  61011. * 3: menu button
  61012. * @param buttonIdx Which button index changed
  61013. * @param state New state of the button
  61014. * @param changes Which properties on the state changed since last frame
  61015. */
  61016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61017. }
  61018. }
  61019. declare module BABYLON {
  61020. /**
  61021. * Defines the WindowsMotionController object that the state of the windows motion controller
  61022. */
  61023. export class WindowsMotionController extends WebVRController {
  61024. /**
  61025. * The base url used to load the left and right controller models
  61026. */
  61027. static MODEL_BASE_URL: string;
  61028. /**
  61029. * The name of the left controller model file
  61030. */
  61031. static MODEL_LEFT_FILENAME: string;
  61032. /**
  61033. * The name of the right controller model file
  61034. */
  61035. static MODEL_RIGHT_FILENAME: string;
  61036. /**
  61037. * The controller name prefix for this controller type
  61038. */
  61039. static readonly GAMEPAD_ID_PREFIX: string;
  61040. /**
  61041. * The controller id pattern for this controller type
  61042. */
  61043. private static readonly GAMEPAD_ID_PATTERN;
  61044. private _loadedMeshInfo;
  61045. protected readonly _mapping: {
  61046. buttons: string[];
  61047. buttonMeshNames: {
  61048. trigger: string;
  61049. menu: string;
  61050. grip: string;
  61051. thumbstick: string;
  61052. trackpad: string;
  61053. };
  61054. buttonObservableNames: {
  61055. trigger: string;
  61056. menu: string;
  61057. grip: string;
  61058. thumbstick: string;
  61059. trackpad: string;
  61060. };
  61061. axisMeshNames: string[];
  61062. pointingPoseMeshName: string;
  61063. };
  61064. /**
  61065. * Fired when the trackpad on this controller is clicked
  61066. */
  61067. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61068. /**
  61069. * Fired when the trackpad on this controller is modified
  61070. */
  61071. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61072. /**
  61073. * The current x and y values of this controller's trackpad
  61074. */
  61075. trackpad: StickValues;
  61076. /**
  61077. * Creates a new WindowsMotionController from a gamepad
  61078. * @param vrGamepad the gamepad that the controller should be created from
  61079. */
  61080. constructor(vrGamepad: any);
  61081. /**
  61082. * Fired when the trigger on this controller is modified
  61083. */
  61084. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61085. /**
  61086. * Fired when the menu button on this controller is modified
  61087. */
  61088. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61089. /**
  61090. * Fired when the grip button on this controller is modified
  61091. */
  61092. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61093. /**
  61094. * Fired when the thumbstick button on this controller is modified
  61095. */
  61096. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61097. /**
  61098. * Fired when the touchpad button on this controller is modified
  61099. */
  61100. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61101. /**
  61102. * Fired when the touchpad values on this controller are modified
  61103. */
  61104. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61105. protected _updateTrackpad(): void;
  61106. /**
  61107. * Called once per frame by the engine.
  61108. */
  61109. update(): void;
  61110. /**
  61111. * Called once for each button that changed state since the last frame
  61112. * @param buttonIdx Which button index changed
  61113. * @param state New state of the button
  61114. * @param changes Which properties on the state changed since last frame
  61115. */
  61116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61117. /**
  61118. * Moves the buttons on the controller mesh based on their current state
  61119. * @param buttonName the name of the button to move
  61120. * @param buttonValue the value of the button which determines the buttons new position
  61121. */
  61122. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61123. /**
  61124. * Moves the axis on the controller mesh based on its current state
  61125. * @param axis the index of the axis
  61126. * @param axisValue the value of the axis which determines the meshes new position
  61127. * @hidden
  61128. */
  61129. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61130. /**
  61131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61132. * @param scene scene in which to add meshes
  61133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61134. */
  61135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61136. /**
  61137. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61138. * can be transformed by button presses and axes values, based on this._mapping.
  61139. *
  61140. * @param scene scene in which the meshes exist
  61141. * @param meshes list of meshes that make up the controller model to process
  61142. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61143. */
  61144. private processModel;
  61145. private createMeshInfo;
  61146. /**
  61147. * Gets the ray of the controller in the direction the controller is pointing
  61148. * @param length the length the resulting ray should be
  61149. * @returns a ray in the direction the controller is pointing
  61150. */
  61151. getForwardRay(length?: number): Ray;
  61152. /**
  61153. * Disposes of the controller
  61154. */
  61155. dispose(): void;
  61156. }
  61157. /**
  61158. * This class represents a new windows motion controller in XR.
  61159. */
  61160. export class XRWindowsMotionController extends WindowsMotionController {
  61161. /**
  61162. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61163. */
  61164. protected readonly _mapping: {
  61165. buttons: string[];
  61166. buttonMeshNames: {
  61167. trigger: string;
  61168. menu: string;
  61169. grip: string;
  61170. thumbstick: string;
  61171. trackpad: string;
  61172. };
  61173. buttonObservableNames: {
  61174. trigger: string;
  61175. menu: string;
  61176. grip: string;
  61177. thumbstick: string;
  61178. trackpad: string;
  61179. };
  61180. axisMeshNames: string[];
  61181. pointingPoseMeshName: string;
  61182. };
  61183. /**
  61184. * Construct a new XR-Based windows motion controller
  61185. *
  61186. * @param gamepadInfo the gamepad object from the browser
  61187. */
  61188. constructor(gamepadInfo: any);
  61189. /**
  61190. * holds the thumbstick values (X,Y)
  61191. */
  61192. thumbstickValues: StickValues;
  61193. /**
  61194. * Fired when the thumbstick on this controller is clicked
  61195. */
  61196. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61197. /**
  61198. * Fired when the thumbstick on this controller is modified
  61199. */
  61200. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61201. /**
  61202. * Fired when the touchpad button on this controller is modified
  61203. */
  61204. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61205. /**
  61206. * Fired when the touchpad values on this controller are modified
  61207. */
  61208. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61209. /**
  61210. * Fired when the thumbstick button on this controller is modified
  61211. * here to prevent breaking changes
  61212. */
  61213. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61214. /**
  61215. * updating the thumbstick(!) and not the trackpad.
  61216. * This is named this way due to the difference between WebVR and XR and to avoid
  61217. * changing the parent class.
  61218. */
  61219. protected _updateTrackpad(): void;
  61220. /**
  61221. * Disposes the class with joy
  61222. */
  61223. dispose(): void;
  61224. }
  61225. }
  61226. declare module BABYLON {
  61227. /**
  61228. * A directional light is defined by a direction (what a surprise!).
  61229. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  61230. * 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.
  61231. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61232. */
  61233. export class DirectionalLight extends ShadowLight {
  61234. private _shadowFrustumSize;
  61235. /**
  61236. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  61237. */
  61238. get shadowFrustumSize(): number;
  61239. /**
  61240. * Specifies a fix frustum size for the shadow generation.
  61241. */
  61242. set shadowFrustumSize(value: number);
  61243. private _shadowOrthoScale;
  61244. /**
  61245. * Gets the shadow projection scale against the optimal computed one.
  61246. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61247. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61248. */
  61249. get shadowOrthoScale(): number;
  61250. /**
  61251. * Sets the shadow projection scale against the optimal computed one.
  61252. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61253. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61254. */
  61255. set shadowOrthoScale(value: number);
  61256. /**
  61257. * Automatically compute the projection matrix to best fit (including all the casters)
  61258. * on each frame.
  61259. */
  61260. autoUpdateExtends: boolean;
  61261. /**
  61262. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61263. * on each frame. autoUpdateExtends must be set to true for this to work
  61264. */
  61265. autoCalcShadowZBounds: boolean;
  61266. private _orthoLeft;
  61267. private _orthoRight;
  61268. private _orthoTop;
  61269. private _orthoBottom;
  61270. /**
  61271. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61272. * The directional light is emitted from everywhere in the given direction.
  61273. * It can cast shadows.
  61274. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61275. * @param name The friendly name of the light
  61276. * @param direction The direction of the light
  61277. * @param scene The scene the light belongs to
  61278. */
  61279. constructor(name: string, direction: Vector3, scene: Scene);
  61280. /**
  61281. * Returns the string "DirectionalLight".
  61282. * @return The class name
  61283. */
  61284. getClassName(): string;
  61285. /**
  61286. * Returns the integer 1.
  61287. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61288. */
  61289. getTypeID(): number;
  61290. /**
  61291. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61292. * Returns the DirectionalLight Shadow projection matrix.
  61293. */
  61294. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61295. /**
  61296. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61297. * Returns the DirectionalLight Shadow projection matrix.
  61298. */
  61299. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61300. /**
  61301. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61302. * Returns the DirectionalLight Shadow projection matrix.
  61303. */
  61304. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61305. protected _buildUniformLayout(): void;
  61306. /**
  61307. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61308. * @param effect The effect to update
  61309. * @param lightIndex The index of the light in the effect to update
  61310. * @returns The directional light
  61311. */
  61312. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61314. /**
  61315. * Gets the minZ used for shadow according to both the scene and the light.
  61316. *
  61317. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61318. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61319. * @param activeCamera The camera we are returning the min for
  61320. * @returns the depth min z
  61321. */
  61322. getDepthMinZ(activeCamera: Camera): number;
  61323. /**
  61324. * Gets the maxZ used for shadow according to both the scene and the light.
  61325. *
  61326. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61327. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61328. * @param activeCamera The camera we are returning the max for
  61329. * @returns the depth max z
  61330. */
  61331. getDepthMaxZ(activeCamera: Camera): number;
  61332. /**
  61333. * Prepares the list of defines specific to the light type.
  61334. * @param defines the list of defines
  61335. * @param lightIndex defines the index of the light for the effect
  61336. */
  61337. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61338. }
  61339. }
  61340. declare module BABYLON {
  61341. /**
  61342. * Class containing static functions to help procedurally build meshes
  61343. */
  61344. export class HemisphereBuilder {
  61345. /**
  61346. * Creates a hemisphere mesh
  61347. * @param name defines the name of the mesh
  61348. * @param options defines the options used to create the mesh
  61349. * @param scene defines the hosting scene
  61350. * @returns the hemisphere mesh
  61351. */
  61352. static CreateHemisphere(name: string, options: {
  61353. segments?: number;
  61354. diameter?: number;
  61355. sideOrientation?: number;
  61356. }, scene: any): Mesh;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61362. * These values define a cone of light starting from the position, emitting toward the direction.
  61363. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61364. * and the exponent defines the speed of the decay of the light with distance (reach).
  61365. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61366. */
  61367. export class SpotLight extends ShadowLight {
  61368. private _angle;
  61369. private _innerAngle;
  61370. private _cosHalfAngle;
  61371. private _lightAngleScale;
  61372. private _lightAngleOffset;
  61373. /**
  61374. * Gets the cone angle of the spot light in Radians.
  61375. */
  61376. get angle(): number;
  61377. /**
  61378. * Sets the cone angle of the spot light in Radians.
  61379. */
  61380. set angle(value: number);
  61381. /**
  61382. * Only used in gltf falloff mode, this defines the angle where
  61383. * the directional falloff will start before cutting at angle which could be seen
  61384. * as outer angle.
  61385. */
  61386. get innerAngle(): number;
  61387. /**
  61388. * Only used in gltf falloff mode, this defines the angle where
  61389. * the directional falloff will start before cutting at angle which could be seen
  61390. * as outer angle.
  61391. */
  61392. set innerAngle(value: number);
  61393. private _shadowAngleScale;
  61394. /**
  61395. * Allows scaling the angle of the light for shadow generation only.
  61396. */
  61397. get shadowAngleScale(): number;
  61398. /**
  61399. * Allows scaling the angle of the light for shadow generation only.
  61400. */
  61401. set shadowAngleScale(value: number);
  61402. /**
  61403. * The light decay speed with the distance from the emission spot.
  61404. */
  61405. exponent: number;
  61406. private _projectionTextureMatrix;
  61407. /**
  61408. * Allows reading the projection texture
  61409. */
  61410. get projectionTextureMatrix(): Matrix;
  61411. protected _projectionTextureLightNear: number;
  61412. /**
  61413. * Gets the near clip of the Spotlight for texture projection.
  61414. */
  61415. get projectionTextureLightNear(): number;
  61416. /**
  61417. * Sets the near clip of the Spotlight for texture projection.
  61418. */
  61419. set projectionTextureLightNear(value: number);
  61420. protected _projectionTextureLightFar: number;
  61421. /**
  61422. * Gets the far clip of the Spotlight for texture projection.
  61423. */
  61424. get projectionTextureLightFar(): number;
  61425. /**
  61426. * Sets the far clip of the Spotlight for texture projection.
  61427. */
  61428. set projectionTextureLightFar(value: number);
  61429. protected _projectionTextureUpDirection: Vector3;
  61430. /**
  61431. * Gets the Up vector of the Spotlight for texture projection.
  61432. */
  61433. get projectionTextureUpDirection(): Vector3;
  61434. /**
  61435. * Sets the Up vector of the Spotlight for texture projection.
  61436. */
  61437. set projectionTextureUpDirection(value: Vector3);
  61438. private _projectionTexture;
  61439. /**
  61440. * Gets the projection texture of the light.
  61441. */
  61442. get projectionTexture(): Nullable<BaseTexture>;
  61443. /**
  61444. * Sets the projection texture of the light.
  61445. */
  61446. set projectionTexture(value: Nullable<BaseTexture>);
  61447. private static _IsProceduralTexture;
  61448. private static _IsTexture;
  61449. private _projectionTextureViewLightDirty;
  61450. private _projectionTextureProjectionLightDirty;
  61451. private _projectionTextureDirty;
  61452. private _projectionTextureViewTargetVector;
  61453. private _projectionTextureViewLightMatrix;
  61454. private _projectionTextureProjectionLightMatrix;
  61455. private _projectionTextureScalingMatrix;
  61456. /**
  61457. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61458. * It can cast shadows.
  61459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61460. * @param name The light friendly name
  61461. * @param position The position of the spot light in the scene
  61462. * @param direction The direction of the light in the scene
  61463. * @param angle The cone angle of the light in Radians
  61464. * @param exponent The light decay speed with the distance from the emission spot
  61465. * @param scene The scene the lights belongs to
  61466. */
  61467. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61468. /**
  61469. * Returns the string "SpotLight".
  61470. * @returns the class name
  61471. */
  61472. getClassName(): string;
  61473. /**
  61474. * Returns the integer 2.
  61475. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61476. */
  61477. getTypeID(): number;
  61478. /**
  61479. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61480. */
  61481. protected _setDirection(value: Vector3): void;
  61482. /**
  61483. * Overrides the position setter to recompute the projection texture view light Matrix.
  61484. */
  61485. protected _setPosition(value: Vector3): void;
  61486. /**
  61487. * 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.
  61488. * Returns the SpotLight.
  61489. */
  61490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61491. protected _computeProjectionTextureViewLightMatrix(): void;
  61492. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61493. /**
  61494. * Main function for light texture projection matrix computing.
  61495. */
  61496. protected _computeProjectionTextureMatrix(): void;
  61497. protected _buildUniformLayout(): void;
  61498. private _computeAngleValues;
  61499. /**
  61500. * Sets the passed Effect "effect" with the Light textures.
  61501. * @param effect The effect to update
  61502. * @param lightIndex The index of the light in the effect to update
  61503. * @returns The light
  61504. */
  61505. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61506. /**
  61507. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61508. * @param effect The effect to update
  61509. * @param lightIndex The index of the light in the effect to update
  61510. * @returns The spot light
  61511. */
  61512. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61513. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61514. /**
  61515. * Disposes the light and the associated resources.
  61516. */
  61517. dispose(): void;
  61518. /**
  61519. * Prepares the list of defines specific to the light type.
  61520. * @param defines the list of defines
  61521. * @param lightIndex defines the index of the light for the effect
  61522. */
  61523. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61524. }
  61525. }
  61526. declare module BABYLON {
  61527. /**
  61528. * Gizmo that enables viewing a light
  61529. */
  61530. export class LightGizmo extends Gizmo {
  61531. private _lightMesh;
  61532. private _material;
  61533. private _cachedPosition;
  61534. private _cachedForward;
  61535. private _attachedMeshParent;
  61536. private _pointerObserver;
  61537. /**
  61538. * Event that fires each time the gizmo is clicked
  61539. */
  61540. onClickedObservable: Observable<Light>;
  61541. /**
  61542. * Creates a LightGizmo
  61543. * @param gizmoLayer The utility layer the gizmo will be added to
  61544. */
  61545. constructor(gizmoLayer?: UtilityLayerRenderer);
  61546. private _light;
  61547. /**
  61548. * The light that the gizmo is attached to
  61549. */
  61550. set light(light: Nullable<Light>);
  61551. get light(): Nullable<Light>;
  61552. /**
  61553. * Gets the material used to render the light gizmo
  61554. */
  61555. get material(): StandardMaterial;
  61556. /**
  61557. * @hidden
  61558. * Updates the gizmo to match the attached mesh's position/rotation
  61559. */
  61560. protected _update(): void;
  61561. private static _Scale;
  61562. /**
  61563. * Creates the lines for a light mesh
  61564. */
  61565. private static _CreateLightLines;
  61566. /**
  61567. * Disposes of the light gizmo
  61568. */
  61569. dispose(): void;
  61570. private static _CreateHemisphericLightMesh;
  61571. private static _CreatePointLightMesh;
  61572. private static _CreateSpotLightMesh;
  61573. private static _CreateDirectionalLightMesh;
  61574. }
  61575. }
  61576. declare module BABYLON {
  61577. /**
  61578. * Gizmo that enables viewing a camera
  61579. */
  61580. export class CameraGizmo extends Gizmo {
  61581. private _cameraMesh;
  61582. private _cameraLinesMesh;
  61583. private _material;
  61584. private _pointerObserver;
  61585. /**
  61586. * Event that fires each time the gizmo is clicked
  61587. */
  61588. onClickedObservable: Observable<Camera>;
  61589. /**
  61590. * Creates a CameraGizmo
  61591. * @param gizmoLayer The utility layer the gizmo will be added to
  61592. */
  61593. constructor(gizmoLayer?: UtilityLayerRenderer);
  61594. private _camera;
  61595. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61596. get displayFrustum(): boolean;
  61597. set displayFrustum(value: boolean);
  61598. /**
  61599. * The camera that the gizmo is attached to
  61600. */
  61601. set camera(camera: Nullable<Camera>);
  61602. get camera(): Nullable<Camera>;
  61603. /**
  61604. * Gets the material used to render the camera gizmo
  61605. */
  61606. get material(): StandardMaterial;
  61607. /**
  61608. * @hidden
  61609. * Updates the gizmo to match the attached mesh's position/rotation
  61610. */
  61611. protected _update(): void;
  61612. private static _Scale;
  61613. private _invProjection;
  61614. /**
  61615. * Disposes of the camera gizmo
  61616. */
  61617. dispose(): void;
  61618. private static _CreateCameraMesh;
  61619. private static _CreateCameraFrustum;
  61620. }
  61621. }
  61622. declare module BABYLON {
  61623. /** @hidden */
  61624. export var backgroundFragmentDeclaration: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module BABYLON {
  61630. /** @hidden */
  61631. export var backgroundUboDeclaration: {
  61632. name: string;
  61633. shader: string;
  61634. };
  61635. }
  61636. declare module BABYLON {
  61637. /** @hidden */
  61638. export var backgroundPixelShader: {
  61639. name: string;
  61640. shader: string;
  61641. };
  61642. }
  61643. declare module BABYLON {
  61644. /** @hidden */
  61645. export var backgroundVertexDeclaration: {
  61646. name: string;
  61647. shader: string;
  61648. };
  61649. }
  61650. declare module BABYLON {
  61651. /** @hidden */
  61652. export var backgroundVertexShader: {
  61653. name: string;
  61654. shader: string;
  61655. };
  61656. }
  61657. declare module BABYLON {
  61658. /**
  61659. * Background material used to create an efficient environment around your scene.
  61660. */
  61661. export class BackgroundMaterial extends PushMaterial {
  61662. /**
  61663. * Standard reflectance value at parallel view angle.
  61664. */
  61665. static StandardReflectance0: number;
  61666. /**
  61667. * Standard reflectance value at grazing angle.
  61668. */
  61669. static StandardReflectance90: number;
  61670. protected _primaryColor: Color3;
  61671. /**
  61672. * Key light Color (multiply against the environment texture)
  61673. */
  61674. primaryColor: Color3;
  61675. protected __perceptualColor: Nullable<Color3>;
  61676. /**
  61677. * Experimental Internal Use Only.
  61678. *
  61679. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61680. * This acts as a helper to set the primary color to a more "human friendly" value.
  61681. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61682. * output color as close as possible from the chosen value.
  61683. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61684. * part of lighting setup.)
  61685. */
  61686. get _perceptualColor(): Nullable<Color3>;
  61687. set _perceptualColor(value: Nullable<Color3>);
  61688. protected _primaryColorShadowLevel: float;
  61689. /**
  61690. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61691. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61692. */
  61693. get primaryColorShadowLevel(): float;
  61694. set primaryColorShadowLevel(value: float);
  61695. protected _primaryColorHighlightLevel: float;
  61696. /**
  61697. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61698. * The primary color is used at the level chosen to define what the white area would look.
  61699. */
  61700. get primaryColorHighlightLevel(): float;
  61701. set primaryColorHighlightLevel(value: float);
  61702. protected _reflectionTexture: Nullable<BaseTexture>;
  61703. /**
  61704. * Reflection Texture used in the material.
  61705. * Should be author in a specific way for the best result (refer to the documentation).
  61706. */
  61707. reflectionTexture: Nullable<BaseTexture>;
  61708. protected _reflectionBlur: float;
  61709. /**
  61710. * Reflection Texture level of blur.
  61711. *
  61712. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61713. * texture twice.
  61714. */
  61715. reflectionBlur: float;
  61716. protected _diffuseTexture: Nullable<BaseTexture>;
  61717. /**
  61718. * Diffuse Texture used in the material.
  61719. * Should be author in a specific way for the best result (refer to the documentation).
  61720. */
  61721. diffuseTexture: Nullable<BaseTexture>;
  61722. protected _shadowLights: Nullable<IShadowLight[]>;
  61723. /**
  61724. * Specify the list of lights casting shadow on the material.
  61725. * All scene shadow lights will be included if null.
  61726. */
  61727. shadowLights: Nullable<IShadowLight[]>;
  61728. protected _shadowLevel: float;
  61729. /**
  61730. * Helps adjusting the shadow to a softer level if required.
  61731. * 0 means black shadows and 1 means no shadows.
  61732. */
  61733. shadowLevel: float;
  61734. protected _sceneCenter: Vector3;
  61735. /**
  61736. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61737. * It is usually zero but might be interesting to modify according to your setup.
  61738. */
  61739. sceneCenter: Vector3;
  61740. protected _opacityFresnel: boolean;
  61741. /**
  61742. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61743. * This helps ensuring a nice transition when the camera goes under the ground.
  61744. */
  61745. opacityFresnel: boolean;
  61746. protected _reflectionFresnel: boolean;
  61747. /**
  61748. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61749. * This helps adding a mirror texture on the ground.
  61750. */
  61751. reflectionFresnel: boolean;
  61752. protected _reflectionFalloffDistance: number;
  61753. /**
  61754. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61755. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61756. */
  61757. reflectionFalloffDistance: number;
  61758. protected _reflectionAmount: number;
  61759. /**
  61760. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61761. */
  61762. reflectionAmount: number;
  61763. protected _reflectionReflectance0: number;
  61764. /**
  61765. * This specifies the weight of the reflection at grazing angle.
  61766. */
  61767. reflectionReflectance0: number;
  61768. protected _reflectionReflectance90: number;
  61769. /**
  61770. * This specifies the weight of the reflection at a perpendicular point of view.
  61771. */
  61772. reflectionReflectance90: number;
  61773. /**
  61774. * Sets the reflection reflectance fresnel values according to the default standard
  61775. * empirically know to work well :-)
  61776. */
  61777. set reflectionStandardFresnelWeight(value: number);
  61778. protected _useRGBColor: boolean;
  61779. /**
  61780. * Helps to directly use the maps channels instead of their level.
  61781. */
  61782. useRGBColor: boolean;
  61783. protected _enableNoise: boolean;
  61784. /**
  61785. * This helps reducing the banding effect that could occur on the background.
  61786. */
  61787. enableNoise: boolean;
  61788. /**
  61789. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61790. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61791. * Recommended to be keep at 1.0 except for special cases.
  61792. */
  61793. get fovMultiplier(): number;
  61794. set fovMultiplier(value: number);
  61795. private _fovMultiplier;
  61796. /**
  61797. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61798. */
  61799. useEquirectangularFOV: boolean;
  61800. private _maxSimultaneousLights;
  61801. /**
  61802. * Number of Simultaneous lights allowed on the material.
  61803. */
  61804. maxSimultaneousLights: int;
  61805. private _shadowOnly;
  61806. /**
  61807. * Make the material only render shadows
  61808. */
  61809. shadowOnly: boolean;
  61810. /**
  61811. * Default configuration related to image processing available in the Background Material.
  61812. */
  61813. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61814. /**
  61815. * Keep track of the image processing observer to allow dispose and replace.
  61816. */
  61817. private _imageProcessingObserver;
  61818. /**
  61819. * Attaches a new image processing configuration to the PBR Material.
  61820. * @param configuration (if null the scene configuration will be use)
  61821. */
  61822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61823. /**
  61824. * Gets the image processing configuration used either in this material.
  61825. */
  61826. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61827. /**
  61828. * Sets the Default image processing configuration used either in the this material.
  61829. *
  61830. * If sets to null, the scene one is in use.
  61831. */
  61832. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61833. /**
  61834. * Gets whether the color curves effect is enabled.
  61835. */
  61836. get cameraColorCurvesEnabled(): boolean;
  61837. /**
  61838. * Sets whether the color curves effect is enabled.
  61839. */
  61840. set cameraColorCurvesEnabled(value: boolean);
  61841. /**
  61842. * Gets whether the color grading effect is enabled.
  61843. */
  61844. get cameraColorGradingEnabled(): boolean;
  61845. /**
  61846. * Gets whether the color grading effect is enabled.
  61847. */
  61848. set cameraColorGradingEnabled(value: boolean);
  61849. /**
  61850. * Gets whether tonemapping is enabled or not.
  61851. */
  61852. get cameraToneMappingEnabled(): boolean;
  61853. /**
  61854. * Sets whether tonemapping is enabled or not
  61855. */
  61856. set cameraToneMappingEnabled(value: boolean);
  61857. /**
  61858. * The camera exposure used on this material.
  61859. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61860. * This corresponds to a photographic exposure.
  61861. */
  61862. get cameraExposure(): float;
  61863. /**
  61864. * The camera exposure used on this material.
  61865. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61866. * This corresponds to a photographic exposure.
  61867. */
  61868. set cameraExposure(value: float);
  61869. /**
  61870. * Gets The camera contrast used on this material.
  61871. */
  61872. get cameraContrast(): float;
  61873. /**
  61874. * Sets The camera contrast used on this material.
  61875. */
  61876. set cameraContrast(value: float);
  61877. /**
  61878. * Gets the Color Grading 2D Lookup Texture.
  61879. */
  61880. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61881. /**
  61882. * Sets the Color Grading 2D Lookup Texture.
  61883. */
  61884. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61885. /**
  61886. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61887. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61888. * 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;
  61889. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61890. */
  61891. get cameraColorCurves(): Nullable<ColorCurves>;
  61892. /**
  61893. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61895. * 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;
  61896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61897. */
  61898. set cameraColorCurves(value: Nullable<ColorCurves>);
  61899. /**
  61900. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61901. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61902. */
  61903. switchToBGR: boolean;
  61904. private _renderTargets;
  61905. private _reflectionControls;
  61906. private _white;
  61907. private _primaryShadowColor;
  61908. private _primaryHighlightColor;
  61909. /**
  61910. * Instantiates a Background Material in the given scene
  61911. * @param name The friendly name of the material
  61912. * @param scene The scene to add the material to
  61913. */
  61914. constructor(name: string, scene: Scene);
  61915. /**
  61916. * Gets a boolean indicating that current material needs to register RTT
  61917. */
  61918. get hasRenderTargetTextures(): boolean;
  61919. /**
  61920. * The entire material has been created in order to prevent overdraw.
  61921. * @returns false
  61922. */
  61923. needAlphaTesting(): boolean;
  61924. /**
  61925. * The entire material has been created in order to prevent overdraw.
  61926. * @returns true if blending is enable
  61927. */
  61928. needAlphaBlending(): boolean;
  61929. /**
  61930. * Checks whether the material is ready to be rendered for a given mesh.
  61931. * @param mesh The mesh to render
  61932. * @param subMesh The submesh to check against
  61933. * @param useInstances Specify wether or not the material is used with instances
  61934. * @returns true if all the dependencies are ready (Textures, Effects...)
  61935. */
  61936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61937. /**
  61938. * Compute the primary color according to the chosen perceptual color.
  61939. */
  61940. private _computePrimaryColorFromPerceptualColor;
  61941. /**
  61942. * Compute the highlights and shadow colors according to their chosen levels.
  61943. */
  61944. private _computePrimaryColors;
  61945. /**
  61946. * Build the uniform buffer used in the material.
  61947. */
  61948. buildUniformLayout(): void;
  61949. /**
  61950. * Unbind the material.
  61951. */
  61952. unbind(): void;
  61953. /**
  61954. * Bind only the world matrix to the material.
  61955. * @param world The world matrix to bind.
  61956. */
  61957. bindOnlyWorldMatrix(world: Matrix): void;
  61958. /**
  61959. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61960. * @param world The world matrix to bind.
  61961. * @param subMesh The submesh to bind for.
  61962. */
  61963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61964. /**
  61965. * Checks to see if a texture is used in the material.
  61966. * @param texture - Base texture to use.
  61967. * @returns - Boolean specifying if a texture is used in the material.
  61968. */
  61969. hasTexture(texture: BaseTexture): boolean;
  61970. /**
  61971. * Dispose the material.
  61972. * @param forceDisposeEffect Force disposal of the associated effect.
  61973. * @param forceDisposeTextures Force disposal of the associated textures.
  61974. */
  61975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61976. /**
  61977. * Clones the material.
  61978. * @param name The cloned name.
  61979. * @returns The cloned material.
  61980. */
  61981. clone(name: string): BackgroundMaterial;
  61982. /**
  61983. * Serializes the current material to its JSON representation.
  61984. * @returns The JSON representation.
  61985. */
  61986. serialize(): any;
  61987. /**
  61988. * Gets the class name of the material
  61989. * @returns "BackgroundMaterial"
  61990. */
  61991. getClassName(): string;
  61992. /**
  61993. * Parse a JSON input to create back a background material.
  61994. * @param source The JSON data to parse
  61995. * @param scene The scene to create the parsed material in
  61996. * @param rootUrl The root url of the assets the material depends upon
  61997. * @returns the instantiated BackgroundMaterial.
  61998. */
  61999. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  62000. }
  62001. }
  62002. declare module BABYLON {
  62003. /**
  62004. * Represents the different options available during the creation of
  62005. * a Environment helper.
  62006. *
  62007. * This can control the default ground, skybox and image processing setup of your scene.
  62008. */
  62009. export interface IEnvironmentHelperOptions {
  62010. /**
  62011. * Specifies whether or not to create a ground.
  62012. * True by default.
  62013. */
  62014. createGround: boolean;
  62015. /**
  62016. * Specifies the ground size.
  62017. * 15 by default.
  62018. */
  62019. groundSize: number;
  62020. /**
  62021. * The texture used on the ground for the main color.
  62022. * Comes from the BabylonJS CDN by default.
  62023. *
  62024. * Remarks: Can be either a texture or a url.
  62025. */
  62026. groundTexture: string | BaseTexture;
  62027. /**
  62028. * The color mixed in the ground texture by default.
  62029. * BabylonJS clearColor by default.
  62030. */
  62031. groundColor: Color3;
  62032. /**
  62033. * Specifies the ground opacity.
  62034. * 1 by default.
  62035. */
  62036. groundOpacity: number;
  62037. /**
  62038. * Enables the ground to receive shadows.
  62039. * True by default.
  62040. */
  62041. enableGroundShadow: boolean;
  62042. /**
  62043. * Helps preventing the shadow to be fully black on the ground.
  62044. * 0.5 by default.
  62045. */
  62046. groundShadowLevel: number;
  62047. /**
  62048. * Creates a mirror texture attach to the ground.
  62049. * false by default.
  62050. */
  62051. enableGroundMirror: boolean;
  62052. /**
  62053. * Specifies the ground mirror size ratio.
  62054. * 0.3 by default as the default kernel is 64.
  62055. */
  62056. groundMirrorSizeRatio: number;
  62057. /**
  62058. * Specifies the ground mirror blur kernel size.
  62059. * 64 by default.
  62060. */
  62061. groundMirrorBlurKernel: number;
  62062. /**
  62063. * Specifies the ground mirror visibility amount.
  62064. * 1 by default
  62065. */
  62066. groundMirrorAmount: number;
  62067. /**
  62068. * Specifies the ground mirror reflectance weight.
  62069. * This uses the standard weight of the background material to setup the fresnel effect
  62070. * of the mirror.
  62071. * 1 by default.
  62072. */
  62073. groundMirrorFresnelWeight: number;
  62074. /**
  62075. * Specifies the ground mirror Falloff distance.
  62076. * This can helps reducing the size of the reflection.
  62077. * 0 by Default.
  62078. */
  62079. groundMirrorFallOffDistance: number;
  62080. /**
  62081. * Specifies the ground mirror texture type.
  62082. * Unsigned Int by Default.
  62083. */
  62084. groundMirrorTextureType: number;
  62085. /**
  62086. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62087. * the shown objects.
  62088. */
  62089. groundYBias: number;
  62090. /**
  62091. * Specifies whether or not to create a skybox.
  62092. * True by default.
  62093. */
  62094. createSkybox: boolean;
  62095. /**
  62096. * Specifies the skybox size.
  62097. * 20 by default.
  62098. */
  62099. skyboxSize: number;
  62100. /**
  62101. * The texture used on the skybox for the main color.
  62102. * Comes from the BabylonJS CDN by default.
  62103. *
  62104. * Remarks: Can be either a texture or a url.
  62105. */
  62106. skyboxTexture: string | BaseTexture;
  62107. /**
  62108. * The color mixed in the skybox texture by default.
  62109. * BabylonJS clearColor by default.
  62110. */
  62111. skyboxColor: Color3;
  62112. /**
  62113. * The background rotation around the Y axis of the scene.
  62114. * This helps aligning the key lights of your scene with the background.
  62115. * 0 by default.
  62116. */
  62117. backgroundYRotation: number;
  62118. /**
  62119. * Compute automatically the size of the elements to best fit with the scene.
  62120. */
  62121. sizeAuto: boolean;
  62122. /**
  62123. * Default position of the rootMesh if autoSize is not true.
  62124. */
  62125. rootPosition: Vector3;
  62126. /**
  62127. * Sets up the image processing in the scene.
  62128. * true by default.
  62129. */
  62130. setupImageProcessing: boolean;
  62131. /**
  62132. * The texture used as your environment texture in the scene.
  62133. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62134. *
  62135. * Remarks: Can be either a texture or a url.
  62136. */
  62137. environmentTexture: string | BaseTexture;
  62138. /**
  62139. * The value of the exposure to apply to the scene.
  62140. * 0.6 by default if setupImageProcessing is true.
  62141. */
  62142. cameraExposure: number;
  62143. /**
  62144. * The value of the contrast to apply to the scene.
  62145. * 1.6 by default if setupImageProcessing is true.
  62146. */
  62147. cameraContrast: number;
  62148. /**
  62149. * Specifies whether or not tonemapping should be enabled in the scene.
  62150. * true by default if setupImageProcessing is true.
  62151. */
  62152. toneMappingEnabled: boolean;
  62153. }
  62154. /**
  62155. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62156. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62157. * It also helps with the default setup of your imageProcessing configuration.
  62158. */
  62159. export class EnvironmentHelper {
  62160. /**
  62161. * Default ground texture URL.
  62162. */
  62163. private static _groundTextureCDNUrl;
  62164. /**
  62165. * Default skybox texture URL.
  62166. */
  62167. private static _skyboxTextureCDNUrl;
  62168. /**
  62169. * Default environment texture URL.
  62170. */
  62171. private static _environmentTextureCDNUrl;
  62172. /**
  62173. * Creates the default options for the helper.
  62174. */
  62175. private static _getDefaultOptions;
  62176. private _rootMesh;
  62177. /**
  62178. * Gets the root mesh created by the helper.
  62179. */
  62180. get rootMesh(): Mesh;
  62181. private _skybox;
  62182. /**
  62183. * Gets the skybox created by the helper.
  62184. */
  62185. get skybox(): Nullable<Mesh>;
  62186. private _skyboxTexture;
  62187. /**
  62188. * Gets the skybox texture created by the helper.
  62189. */
  62190. get skyboxTexture(): Nullable<BaseTexture>;
  62191. private _skyboxMaterial;
  62192. /**
  62193. * Gets the skybox material created by the helper.
  62194. */
  62195. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62196. private _ground;
  62197. /**
  62198. * Gets the ground mesh created by the helper.
  62199. */
  62200. get ground(): Nullable<Mesh>;
  62201. private _groundTexture;
  62202. /**
  62203. * Gets the ground texture created by the helper.
  62204. */
  62205. get groundTexture(): Nullable<BaseTexture>;
  62206. private _groundMirror;
  62207. /**
  62208. * Gets the ground mirror created by the helper.
  62209. */
  62210. get groundMirror(): Nullable<MirrorTexture>;
  62211. /**
  62212. * Gets the ground mirror render list to helps pushing the meshes
  62213. * you wish in the ground reflection.
  62214. */
  62215. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62216. private _groundMaterial;
  62217. /**
  62218. * Gets the ground material created by the helper.
  62219. */
  62220. get groundMaterial(): Nullable<BackgroundMaterial>;
  62221. /**
  62222. * Stores the creation options.
  62223. */
  62224. private readonly _scene;
  62225. private _options;
  62226. /**
  62227. * This observable will be notified with any error during the creation of the environment,
  62228. * mainly texture creation errors.
  62229. */
  62230. onErrorObservable: Observable<{
  62231. message?: string;
  62232. exception?: any;
  62233. }>;
  62234. /**
  62235. * constructor
  62236. * @param options Defines the options we want to customize the helper
  62237. * @param scene The scene to add the material to
  62238. */
  62239. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62240. /**
  62241. * Updates the background according to the new options
  62242. * @param options
  62243. */
  62244. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62245. /**
  62246. * Sets the primary color of all the available elements.
  62247. * @param color the main color to affect to the ground and the background
  62248. */
  62249. setMainColor(color: Color3): void;
  62250. /**
  62251. * Setup the image processing according to the specified options.
  62252. */
  62253. private _setupImageProcessing;
  62254. /**
  62255. * Setup the environment texture according to the specified options.
  62256. */
  62257. private _setupEnvironmentTexture;
  62258. /**
  62259. * Setup the background according to the specified options.
  62260. */
  62261. private _setupBackground;
  62262. /**
  62263. * Get the scene sizes according to the setup.
  62264. */
  62265. private _getSceneSize;
  62266. /**
  62267. * Setup the ground according to the specified options.
  62268. */
  62269. private _setupGround;
  62270. /**
  62271. * Setup the ground material according to the specified options.
  62272. */
  62273. private _setupGroundMaterial;
  62274. /**
  62275. * Setup the ground diffuse texture according to the specified options.
  62276. */
  62277. private _setupGroundDiffuseTexture;
  62278. /**
  62279. * Setup the ground mirror texture according to the specified options.
  62280. */
  62281. private _setupGroundMirrorTexture;
  62282. /**
  62283. * Setup the ground to receive the mirror texture.
  62284. */
  62285. private _setupMirrorInGroundMaterial;
  62286. /**
  62287. * Setup the skybox according to the specified options.
  62288. */
  62289. private _setupSkybox;
  62290. /**
  62291. * Setup the skybox material according to the specified options.
  62292. */
  62293. private _setupSkyboxMaterial;
  62294. /**
  62295. * Setup the skybox reflection texture according to the specified options.
  62296. */
  62297. private _setupSkyboxReflectionTexture;
  62298. private _errorHandler;
  62299. /**
  62300. * Dispose all the elements created by the Helper.
  62301. */
  62302. dispose(): void;
  62303. }
  62304. }
  62305. declare module BABYLON {
  62306. /**
  62307. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62308. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62309. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62310. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62311. */
  62312. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62313. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62314. /**
  62315. * Define the source as a Monoscopic panoramic 360/180.
  62316. */
  62317. static readonly MODE_MONOSCOPIC: number;
  62318. /**
  62319. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62320. */
  62321. static readonly MODE_TOPBOTTOM: number;
  62322. /**
  62323. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62324. */
  62325. static readonly MODE_SIDEBYSIDE: number;
  62326. private _halfDome;
  62327. private _crossEye;
  62328. protected _useDirectMapping: boolean;
  62329. /**
  62330. * The texture being displayed on the sphere
  62331. */
  62332. protected _texture: T;
  62333. /**
  62334. * Gets the texture being displayed on the sphere
  62335. */
  62336. get texture(): T;
  62337. /**
  62338. * Sets the texture being displayed on the sphere
  62339. */
  62340. set texture(newTexture: T);
  62341. /**
  62342. * The skybox material
  62343. */
  62344. protected _material: BackgroundMaterial;
  62345. /**
  62346. * The surface used for the dome
  62347. */
  62348. protected _mesh: Mesh;
  62349. /**
  62350. * Gets the mesh used for the dome.
  62351. */
  62352. get mesh(): Mesh;
  62353. /**
  62354. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62355. */
  62356. private _halfDomeMask;
  62357. /**
  62358. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62359. * Also see the options.resolution property.
  62360. */
  62361. get fovMultiplier(): number;
  62362. set fovMultiplier(value: number);
  62363. protected _textureMode: number;
  62364. /**
  62365. * Gets or set the current texture mode for the texture. It can be:
  62366. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62367. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62368. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62369. */
  62370. get textureMode(): number;
  62371. /**
  62372. * Sets the current texture mode for the texture. It can be:
  62373. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62374. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62375. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62376. */
  62377. set textureMode(value: number);
  62378. /**
  62379. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62380. */
  62381. get halfDome(): boolean;
  62382. /**
  62383. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62384. */
  62385. set halfDome(enabled: boolean);
  62386. /**
  62387. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62388. */
  62389. set crossEye(enabled: boolean);
  62390. /**
  62391. * Is it a cross-eye texture?
  62392. */
  62393. get crossEye(): boolean;
  62394. /**
  62395. * The background material of this dome.
  62396. */
  62397. get material(): BackgroundMaterial;
  62398. /**
  62399. * Oberserver used in Stereoscopic VR Mode.
  62400. */
  62401. private _onBeforeCameraRenderObserver;
  62402. /**
  62403. * Observable raised when an error occurred while loading the texture
  62404. */
  62405. onLoadErrorObservable: Observable<string>;
  62406. /**
  62407. * Observable raised when the texture finished loading
  62408. */
  62409. onLoadObservable: Observable<void>;
  62410. /**
  62411. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62412. * @param name Element's name, child elements will append suffixes for their own names.
  62413. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62414. * @param options An object containing optional or exposed sub element properties
  62415. */
  62416. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62417. resolution?: number;
  62418. clickToPlay?: boolean;
  62419. autoPlay?: boolean;
  62420. loop?: boolean;
  62421. size?: number;
  62422. poster?: string;
  62423. faceForward?: boolean;
  62424. useDirectMapping?: boolean;
  62425. halfDomeMode?: boolean;
  62426. crossEyeMode?: boolean;
  62427. generateMipMaps?: boolean;
  62428. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62429. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62430. protected _changeTextureMode(value: number): void;
  62431. /**
  62432. * Releases resources associated with this node.
  62433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62435. */
  62436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62442. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62443. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62444. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62445. */
  62446. export class PhotoDome extends TextureDome<Texture> {
  62447. /**
  62448. * Define the image as a Monoscopic panoramic 360 image.
  62449. */
  62450. static readonly MODE_MONOSCOPIC: number;
  62451. /**
  62452. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62453. */
  62454. static readonly MODE_TOPBOTTOM: number;
  62455. /**
  62456. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62457. */
  62458. static readonly MODE_SIDEBYSIDE: number;
  62459. /**
  62460. * Gets or sets the texture being displayed on the sphere
  62461. */
  62462. get photoTexture(): Texture;
  62463. /**
  62464. * sets the texture being displayed on the sphere
  62465. */
  62466. set photoTexture(value: Texture);
  62467. /**
  62468. * Gets the current video mode for the video. It can be:
  62469. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62470. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62471. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62472. */
  62473. get imageMode(): number;
  62474. /**
  62475. * Sets the current video mode for the video. It can be:
  62476. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62477. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62478. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62479. */
  62480. set imageMode(value: number);
  62481. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62482. }
  62483. }
  62484. declare module BABYLON {
  62485. /**
  62486. * Direct draw surface info
  62487. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62488. */
  62489. export interface DDSInfo {
  62490. /**
  62491. * Width of the texture
  62492. */
  62493. width: number;
  62494. /**
  62495. * Width of the texture
  62496. */
  62497. height: number;
  62498. /**
  62499. * Number of Mipmaps for the texture
  62500. * @see https://en.wikipedia.org/wiki/Mipmap
  62501. */
  62502. mipmapCount: number;
  62503. /**
  62504. * If the textures format is a known fourCC format
  62505. * @see https://www.fourcc.org/
  62506. */
  62507. isFourCC: boolean;
  62508. /**
  62509. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62510. */
  62511. isRGB: boolean;
  62512. /**
  62513. * If the texture is a lumincance format
  62514. */
  62515. isLuminance: boolean;
  62516. /**
  62517. * If this is a cube texture
  62518. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62519. */
  62520. isCube: boolean;
  62521. /**
  62522. * If the texture is a compressed format eg. FOURCC_DXT1
  62523. */
  62524. isCompressed: boolean;
  62525. /**
  62526. * The dxgiFormat of the texture
  62527. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62528. */
  62529. dxgiFormat: number;
  62530. /**
  62531. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62532. */
  62533. textureType: number;
  62534. /**
  62535. * Sphericle polynomial created for the dds texture
  62536. */
  62537. sphericalPolynomial?: SphericalPolynomial;
  62538. }
  62539. /**
  62540. * Class used to provide DDS decompression tools
  62541. */
  62542. export class DDSTools {
  62543. /**
  62544. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62545. */
  62546. static StoreLODInAlphaChannel: boolean;
  62547. /**
  62548. * Gets DDS information from an array buffer
  62549. * @param data defines the array buffer view to read data from
  62550. * @returns the DDS information
  62551. */
  62552. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62553. private static _FloatView;
  62554. private static _Int32View;
  62555. private static _ToHalfFloat;
  62556. private static _FromHalfFloat;
  62557. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62558. private static _GetHalfFloatRGBAArrayBuffer;
  62559. private static _GetFloatRGBAArrayBuffer;
  62560. private static _GetFloatAsUIntRGBAArrayBuffer;
  62561. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62562. private static _GetRGBAArrayBuffer;
  62563. private static _ExtractLongWordOrder;
  62564. private static _GetRGBArrayBuffer;
  62565. private static _GetLuminanceArrayBuffer;
  62566. /**
  62567. * Uploads DDS Levels to a Babylon Texture
  62568. * @hidden
  62569. */
  62570. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62571. }
  62572. interface ThinEngine {
  62573. /**
  62574. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62575. * @param rootUrl defines the url where the file to load is located
  62576. * @param scene defines the current scene
  62577. * @param lodScale defines scale to apply to the mip map selection
  62578. * @param lodOffset defines offset to apply to the mip map selection
  62579. * @param onLoad defines an optional callback raised when the texture is loaded
  62580. * @param onError defines an optional callback raised if there is an issue to load the texture
  62581. * @param format defines the format of the data
  62582. * @param forcedExtension defines the extension to use to pick the right loader
  62583. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62584. * @returns the cube texture as an InternalTexture
  62585. */
  62586. 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;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /**
  62591. * Implementation of the DDS Texture Loader.
  62592. * @hidden
  62593. */
  62594. export class _DDSTextureLoader implements IInternalTextureLoader {
  62595. /**
  62596. * Defines whether the loader supports cascade loading the different faces.
  62597. */
  62598. readonly supportCascades: boolean;
  62599. /**
  62600. * This returns if the loader support the current file information.
  62601. * @param extension defines the file extension of the file being loaded
  62602. * @returns true if the loader can load the specified file
  62603. */
  62604. canLoad(extension: string): boolean;
  62605. /**
  62606. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62607. * @param data contains the texture data
  62608. * @param texture defines the BabylonJS internal texture
  62609. * @param createPolynomials will be true if polynomials have been requested
  62610. * @param onLoad defines the callback to trigger once the texture is ready
  62611. * @param onError defines the callback to trigger in case of error
  62612. */
  62613. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62614. /**
  62615. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62616. * @param data contains the texture data
  62617. * @param texture defines the BabylonJS internal texture
  62618. * @param callback defines the method to call once ready to upload
  62619. */
  62620. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62621. }
  62622. }
  62623. declare module BABYLON {
  62624. /**
  62625. * Implementation of the ENV Texture Loader.
  62626. * @hidden
  62627. */
  62628. export class _ENVTextureLoader implements IInternalTextureLoader {
  62629. /**
  62630. * Defines whether the loader supports cascade loading the different faces.
  62631. */
  62632. readonly supportCascades: boolean;
  62633. /**
  62634. * This returns if the loader support the current file information.
  62635. * @param extension defines the file extension of the file being loaded
  62636. * @returns true if the loader can load the specified file
  62637. */
  62638. canLoad(extension: string): boolean;
  62639. /**
  62640. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62641. * @param data contains the texture data
  62642. * @param texture defines the BabylonJS internal texture
  62643. * @param createPolynomials will be true if polynomials have been requested
  62644. * @param onLoad defines the callback to trigger once the texture is ready
  62645. * @param onError defines the callback to trigger in case of error
  62646. */
  62647. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62648. /**
  62649. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62650. * @param data contains the texture data
  62651. * @param texture defines the BabylonJS internal texture
  62652. * @param callback defines the method to call once ready to upload
  62653. */
  62654. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62655. }
  62656. }
  62657. declare module BABYLON {
  62658. /**
  62659. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62660. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62661. */
  62662. export class KhronosTextureContainer {
  62663. /** contents of the KTX container file */
  62664. data: ArrayBufferView;
  62665. private static HEADER_LEN;
  62666. private static COMPRESSED_2D;
  62667. private static COMPRESSED_3D;
  62668. private static TEX_2D;
  62669. private static TEX_3D;
  62670. /**
  62671. * Gets the openGL type
  62672. */
  62673. glType: number;
  62674. /**
  62675. * Gets the openGL type size
  62676. */
  62677. glTypeSize: number;
  62678. /**
  62679. * Gets the openGL format
  62680. */
  62681. glFormat: number;
  62682. /**
  62683. * Gets the openGL internal format
  62684. */
  62685. glInternalFormat: number;
  62686. /**
  62687. * Gets the base internal format
  62688. */
  62689. glBaseInternalFormat: number;
  62690. /**
  62691. * Gets image width in pixel
  62692. */
  62693. pixelWidth: number;
  62694. /**
  62695. * Gets image height in pixel
  62696. */
  62697. pixelHeight: number;
  62698. /**
  62699. * Gets image depth in pixels
  62700. */
  62701. pixelDepth: number;
  62702. /**
  62703. * Gets the number of array elements
  62704. */
  62705. numberOfArrayElements: number;
  62706. /**
  62707. * Gets the number of faces
  62708. */
  62709. numberOfFaces: number;
  62710. /**
  62711. * Gets the number of mipmap levels
  62712. */
  62713. numberOfMipmapLevels: number;
  62714. /**
  62715. * Gets the bytes of key value data
  62716. */
  62717. bytesOfKeyValueData: number;
  62718. /**
  62719. * Gets the load type
  62720. */
  62721. loadType: number;
  62722. /**
  62723. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62724. */
  62725. isInvalid: boolean;
  62726. /**
  62727. * Creates a new KhronosTextureContainer
  62728. * @param data contents of the KTX container file
  62729. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62730. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62731. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62732. */
  62733. constructor(
  62734. /** contents of the KTX container file */
  62735. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62736. /**
  62737. * Uploads KTX content to a Babylon Texture.
  62738. * It is assumed that the texture has already been created & is currently bound
  62739. * @hidden
  62740. */
  62741. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62742. private _upload2DCompressedLevels;
  62743. /**
  62744. * Checks if the given data starts with a KTX file identifier.
  62745. * @param data the data to check
  62746. * @returns true if the data is a KTX file or false otherwise
  62747. */
  62748. static IsValid(data: ArrayBufferView): boolean;
  62749. }
  62750. }
  62751. declare module BABYLON {
  62752. /**
  62753. * Helper class to push actions to a pool of workers.
  62754. */
  62755. export class WorkerPool implements IDisposable {
  62756. private _workerInfos;
  62757. private _pendingActions;
  62758. /**
  62759. * Constructor
  62760. * @param workers Array of workers to use for actions
  62761. */
  62762. constructor(workers: Array<Worker>);
  62763. /**
  62764. * Terminates all workers and clears any pending actions.
  62765. */
  62766. dispose(): void;
  62767. /**
  62768. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62769. * pended until a worker has completed its action.
  62770. * @param action The action to perform. Call onComplete when the action is complete.
  62771. */
  62772. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62773. private _execute;
  62774. }
  62775. }
  62776. declare module BABYLON {
  62777. /**
  62778. * Class for loading KTX2 files
  62779. */
  62780. export class KhronosTextureContainer2 {
  62781. private static _WorkerPoolPromise?;
  62782. private static _Initialized;
  62783. private static _Ktx2Decoder;
  62784. /**
  62785. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62786. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62787. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62788. * Urls you can change:
  62789. * URLConfig.jsDecoderModule
  62790. * URLConfig.wasmUASTCToASTC
  62791. * URLConfig.wasmUASTCToBC7
  62792. * URLConfig.wasmUASTCToRGBA_UNORM
  62793. * URLConfig.wasmUASTCToRGBA_SRGB
  62794. * URLConfig.jsMSCTranscoder
  62795. * URLConfig.wasmMSCTranscoder
  62796. * URLConfig.wasmZSTDDecoder
  62797. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#29
  62798. */
  62799. static URLConfig: {
  62800. jsDecoderModule: string;
  62801. wasmUASTCToASTC: null;
  62802. wasmUASTCToBC7: null;
  62803. wasmUASTCToRGBA_UNORM: null;
  62804. wasmUASTCToRGBA_SRGB: null;
  62805. jsMSCTranscoder: null;
  62806. wasmMSCTranscoder: null;
  62807. wasmZSTDDecoder: null;
  62808. };
  62809. /**
  62810. * Default number of workers used to handle data decoding
  62811. */
  62812. static DefaultNumWorkers: number;
  62813. private static GetDefaultNumWorkers;
  62814. private _engine;
  62815. private static _CreateWorkerPool;
  62816. /**
  62817. * Constructor
  62818. * @param engine The engine to use
  62819. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62820. */
  62821. constructor(engine: ThinEngine, numWorkers?: number);
  62822. /** @hidden */
  62823. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62824. /**
  62825. * Stop all async operations and release resources.
  62826. */
  62827. dispose(): void;
  62828. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62829. /**
  62830. * Checks if the given data starts with a KTX2 file identifier.
  62831. * @param data the data to check
  62832. * @returns true if the data is a KTX2 file or false otherwise
  62833. */
  62834. static IsValid(data: ArrayBufferView): boolean;
  62835. }
  62836. }
  62837. declare module BABYLON {
  62838. /**
  62839. * Implementation of the KTX Texture Loader.
  62840. * @hidden
  62841. */
  62842. export class _KTXTextureLoader implements IInternalTextureLoader {
  62843. /**
  62844. * Defines whether the loader supports cascade loading the different faces.
  62845. */
  62846. readonly supportCascades: boolean;
  62847. /**
  62848. * This returns if the loader support the current file information.
  62849. * @param extension defines the file extension of the file being loaded
  62850. * @param mimeType defines the optional mime type of the file being loaded
  62851. * @returns true if the loader can load the specified file
  62852. */
  62853. canLoad(extension: string, mimeType?: string): boolean;
  62854. /**
  62855. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62856. * @param data contains the texture data
  62857. * @param texture defines the BabylonJS internal texture
  62858. * @param createPolynomials will be true if polynomials have been requested
  62859. * @param onLoad defines the callback to trigger once the texture is ready
  62860. * @param onError defines the callback to trigger in case of error
  62861. */
  62862. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62863. /**
  62864. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62865. * @param data contains the texture data
  62866. * @param texture defines the BabylonJS internal texture
  62867. * @param callback defines the method to call once ready to upload
  62868. */
  62869. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62870. }
  62871. }
  62872. declare module BABYLON {
  62873. /** @hidden */
  62874. export var _forceSceneHelpersToBundle: boolean;
  62875. interface Scene {
  62876. /**
  62877. * Creates a default light for the scene.
  62878. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62879. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62880. */
  62881. createDefaultLight(replace?: boolean): void;
  62882. /**
  62883. * Creates a default camera for the scene.
  62884. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62885. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62886. * @param replace has default false, when true replaces the active camera in the scene
  62887. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62888. */
  62889. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62890. /**
  62891. * Creates a default camera and a default light.
  62892. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62893. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62894. * @param replace has the default false, when true replaces the active camera/light in the scene
  62895. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62896. */
  62897. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62898. /**
  62899. * Creates a new sky box
  62900. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62901. * @param environmentTexture defines the texture to use as environment texture
  62902. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62903. * @param scale defines the overall scale of the skybox
  62904. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62905. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62906. * @returns a new mesh holding the sky box
  62907. */
  62908. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62909. /**
  62910. * Creates a new environment
  62911. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62912. * @param options defines the options you can use to configure the environment
  62913. * @returns the new EnvironmentHelper
  62914. */
  62915. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62916. /**
  62917. * Creates a new VREXperienceHelper
  62918. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62919. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62920. * @returns a new VREXperienceHelper
  62921. */
  62922. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62923. /**
  62924. * Creates a new WebXRDefaultExperience
  62925. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62926. * @param options experience options
  62927. * @returns a promise for a new WebXRDefaultExperience
  62928. */
  62929. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62930. }
  62931. }
  62932. declare module BABYLON {
  62933. /**
  62934. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62935. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62936. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62937. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62938. */
  62939. export class VideoDome extends TextureDome<VideoTexture> {
  62940. /**
  62941. * Define the video source as a Monoscopic panoramic 360 video.
  62942. */
  62943. static readonly MODE_MONOSCOPIC: number;
  62944. /**
  62945. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62946. */
  62947. static readonly MODE_TOPBOTTOM: number;
  62948. /**
  62949. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62950. */
  62951. static readonly MODE_SIDEBYSIDE: number;
  62952. /**
  62953. * Get the video texture associated with this video dome
  62954. */
  62955. get videoTexture(): VideoTexture;
  62956. /**
  62957. * Get the video mode of this dome
  62958. */
  62959. get videoMode(): number;
  62960. /**
  62961. * Set the video mode of this dome.
  62962. * @see textureMode
  62963. */
  62964. set videoMode(value: number);
  62965. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * This class can be used to get instrumentation data from a Babylon engine
  62971. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62972. */
  62973. export class EngineInstrumentation implements IDisposable {
  62974. /**
  62975. * Define the instrumented engine.
  62976. */
  62977. engine: Engine;
  62978. private _captureGPUFrameTime;
  62979. private _gpuFrameTimeToken;
  62980. private _gpuFrameTime;
  62981. private _captureShaderCompilationTime;
  62982. private _shaderCompilationTime;
  62983. private _onBeginFrameObserver;
  62984. private _onEndFrameObserver;
  62985. private _onBeforeShaderCompilationObserver;
  62986. private _onAfterShaderCompilationObserver;
  62987. /**
  62988. * Gets the perf counter used for GPU frame time
  62989. */
  62990. get gpuFrameTimeCounter(): PerfCounter;
  62991. /**
  62992. * Gets the GPU frame time capture status
  62993. */
  62994. get captureGPUFrameTime(): boolean;
  62995. /**
  62996. * Enable or disable the GPU frame time capture
  62997. */
  62998. set captureGPUFrameTime(value: boolean);
  62999. /**
  63000. * Gets the perf counter used for shader compilation time
  63001. */
  63002. get shaderCompilationTimeCounter(): PerfCounter;
  63003. /**
  63004. * Gets the shader compilation time capture status
  63005. */
  63006. get captureShaderCompilationTime(): boolean;
  63007. /**
  63008. * Enable or disable the shader compilation time capture
  63009. */
  63010. set captureShaderCompilationTime(value: boolean);
  63011. /**
  63012. * Instantiates a new engine instrumentation.
  63013. * This class can be used to get instrumentation data from a Babylon engine
  63014. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  63015. * @param engine Defines the engine to instrument
  63016. */
  63017. constructor(
  63018. /**
  63019. * Define the instrumented engine.
  63020. */
  63021. engine: Engine);
  63022. /**
  63023. * Dispose and release associated resources.
  63024. */
  63025. dispose(): void;
  63026. }
  63027. }
  63028. declare module BABYLON {
  63029. /**
  63030. * This class can be used to get instrumentation data from a Babylon engine
  63031. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63032. */
  63033. export class SceneInstrumentation implements IDisposable {
  63034. /**
  63035. * Defines the scene to instrument
  63036. */
  63037. scene: Scene;
  63038. private _captureActiveMeshesEvaluationTime;
  63039. private _activeMeshesEvaluationTime;
  63040. private _captureRenderTargetsRenderTime;
  63041. private _renderTargetsRenderTime;
  63042. private _captureFrameTime;
  63043. private _frameTime;
  63044. private _captureRenderTime;
  63045. private _renderTime;
  63046. private _captureInterFrameTime;
  63047. private _interFrameTime;
  63048. private _captureParticlesRenderTime;
  63049. private _particlesRenderTime;
  63050. private _captureSpritesRenderTime;
  63051. private _spritesRenderTime;
  63052. private _capturePhysicsTime;
  63053. private _physicsTime;
  63054. private _captureAnimationsTime;
  63055. private _animationsTime;
  63056. private _captureCameraRenderTime;
  63057. private _cameraRenderTime;
  63058. private _onBeforeActiveMeshesEvaluationObserver;
  63059. private _onAfterActiveMeshesEvaluationObserver;
  63060. private _onBeforeRenderTargetsRenderObserver;
  63061. private _onAfterRenderTargetsRenderObserver;
  63062. private _onAfterRenderObserver;
  63063. private _onBeforeDrawPhaseObserver;
  63064. private _onAfterDrawPhaseObserver;
  63065. private _onBeforeAnimationsObserver;
  63066. private _onBeforeParticlesRenderingObserver;
  63067. private _onAfterParticlesRenderingObserver;
  63068. private _onBeforeSpritesRenderingObserver;
  63069. private _onAfterSpritesRenderingObserver;
  63070. private _onBeforePhysicsObserver;
  63071. private _onAfterPhysicsObserver;
  63072. private _onAfterAnimationsObserver;
  63073. private _onBeforeCameraRenderObserver;
  63074. private _onAfterCameraRenderObserver;
  63075. /**
  63076. * Gets the perf counter used for active meshes evaluation time
  63077. */
  63078. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63079. /**
  63080. * Gets the active meshes evaluation time capture status
  63081. */
  63082. get captureActiveMeshesEvaluationTime(): boolean;
  63083. /**
  63084. * Enable or disable the active meshes evaluation time capture
  63085. */
  63086. set captureActiveMeshesEvaluationTime(value: boolean);
  63087. /**
  63088. * Gets the perf counter used for render targets render time
  63089. */
  63090. get renderTargetsRenderTimeCounter(): PerfCounter;
  63091. /**
  63092. * Gets the render targets render time capture status
  63093. */
  63094. get captureRenderTargetsRenderTime(): boolean;
  63095. /**
  63096. * Enable or disable the render targets render time capture
  63097. */
  63098. set captureRenderTargetsRenderTime(value: boolean);
  63099. /**
  63100. * Gets the perf counter used for particles render time
  63101. */
  63102. get particlesRenderTimeCounter(): PerfCounter;
  63103. /**
  63104. * Gets the particles render time capture status
  63105. */
  63106. get captureParticlesRenderTime(): boolean;
  63107. /**
  63108. * Enable or disable the particles render time capture
  63109. */
  63110. set captureParticlesRenderTime(value: boolean);
  63111. /**
  63112. * Gets the perf counter used for sprites render time
  63113. */
  63114. get spritesRenderTimeCounter(): PerfCounter;
  63115. /**
  63116. * Gets the sprites render time capture status
  63117. */
  63118. get captureSpritesRenderTime(): boolean;
  63119. /**
  63120. * Enable or disable the sprites render time capture
  63121. */
  63122. set captureSpritesRenderTime(value: boolean);
  63123. /**
  63124. * Gets the perf counter used for physics time
  63125. */
  63126. get physicsTimeCounter(): PerfCounter;
  63127. /**
  63128. * Gets the physics time capture status
  63129. */
  63130. get capturePhysicsTime(): boolean;
  63131. /**
  63132. * Enable or disable the physics time capture
  63133. */
  63134. set capturePhysicsTime(value: boolean);
  63135. /**
  63136. * Gets the perf counter used for animations time
  63137. */
  63138. get animationsTimeCounter(): PerfCounter;
  63139. /**
  63140. * Gets the animations time capture status
  63141. */
  63142. get captureAnimationsTime(): boolean;
  63143. /**
  63144. * Enable or disable the animations time capture
  63145. */
  63146. set captureAnimationsTime(value: boolean);
  63147. /**
  63148. * Gets the perf counter used for frame time capture
  63149. */
  63150. get frameTimeCounter(): PerfCounter;
  63151. /**
  63152. * Gets the frame time capture status
  63153. */
  63154. get captureFrameTime(): boolean;
  63155. /**
  63156. * Enable or disable the frame time capture
  63157. */
  63158. set captureFrameTime(value: boolean);
  63159. /**
  63160. * Gets the perf counter used for inter-frames time capture
  63161. */
  63162. get interFrameTimeCounter(): PerfCounter;
  63163. /**
  63164. * Gets the inter-frames time capture status
  63165. */
  63166. get captureInterFrameTime(): boolean;
  63167. /**
  63168. * Enable or disable the inter-frames time capture
  63169. */
  63170. set captureInterFrameTime(value: boolean);
  63171. /**
  63172. * Gets the perf counter used for render time capture
  63173. */
  63174. get renderTimeCounter(): PerfCounter;
  63175. /**
  63176. * Gets the render time capture status
  63177. */
  63178. get captureRenderTime(): boolean;
  63179. /**
  63180. * Enable or disable the render time capture
  63181. */
  63182. set captureRenderTime(value: boolean);
  63183. /**
  63184. * Gets the perf counter used for camera render time capture
  63185. */
  63186. get cameraRenderTimeCounter(): PerfCounter;
  63187. /**
  63188. * Gets the camera render time capture status
  63189. */
  63190. get captureCameraRenderTime(): boolean;
  63191. /**
  63192. * Enable or disable the camera render time capture
  63193. */
  63194. set captureCameraRenderTime(value: boolean);
  63195. /**
  63196. * Gets the perf counter used for draw calls
  63197. */
  63198. get drawCallsCounter(): PerfCounter;
  63199. /**
  63200. * Instantiates a new scene instrumentation.
  63201. * This class can be used to get instrumentation data from a Babylon engine
  63202. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63203. * @param scene Defines the scene to instrument
  63204. */
  63205. constructor(
  63206. /**
  63207. * Defines the scene to instrument
  63208. */
  63209. scene: Scene);
  63210. /**
  63211. * Dispose and release associated resources.
  63212. */
  63213. dispose(): void;
  63214. }
  63215. }
  63216. declare module BABYLON {
  63217. /** @hidden */
  63218. export var glowMapGenerationPixelShader: {
  63219. name: string;
  63220. shader: string;
  63221. };
  63222. }
  63223. declare module BABYLON {
  63224. /** @hidden */
  63225. export var glowMapGenerationVertexShader: {
  63226. name: string;
  63227. shader: string;
  63228. };
  63229. }
  63230. declare module BABYLON {
  63231. /**
  63232. * Effect layer options. This helps customizing the behaviour
  63233. * of the effect layer.
  63234. */
  63235. export interface IEffectLayerOptions {
  63236. /**
  63237. * Multiplication factor apply to the canvas size to compute the render target size
  63238. * used to generated the objects (the smaller the faster).
  63239. */
  63240. mainTextureRatio: number;
  63241. /**
  63242. * Enforces a fixed size texture to ensure effect stability across devices.
  63243. */
  63244. mainTextureFixedSize?: number;
  63245. /**
  63246. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63247. */
  63248. alphaBlendingMode: number;
  63249. /**
  63250. * The camera attached to the layer.
  63251. */
  63252. camera: Nullable<Camera>;
  63253. /**
  63254. * The rendering group to draw the layer in.
  63255. */
  63256. renderingGroupId: number;
  63257. }
  63258. /**
  63259. * The effect layer Helps adding post process effect blended with the main pass.
  63260. *
  63261. * This can be for instance use to generate glow or highlight effects on the scene.
  63262. *
  63263. * The effect layer class can not be used directly and is intented to inherited from to be
  63264. * customized per effects.
  63265. */
  63266. export abstract class EffectLayer {
  63267. private _vertexBuffers;
  63268. private _indexBuffer;
  63269. private _cachedDefines;
  63270. private _effectLayerMapGenerationEffect;
  63271. private _effectLayerOptions;
  63272. private _mergeEffect;
  63273. protected _scene: Scene;
  63274. protected _engine: Engine;
  63275. protected _maxSize: number;
  63276. protected _mainTextureDesiredSize: ISize;
  63277. protected _mainTexture: RenderTargetTexture;
  63278. protected _shouldRender: boolean;
  63279. protected _postProcesses: PostProcess[];
  63280. protected _textures: BaseTexture[];
  63281. protected _emissiveTextureAndColor: {
  63282. texture: Nullable<BaseTexture>;
  63283. color: Color4;
  63284. };
  63285. /**
  63286. * The name of the layer
  63287. */
  63288. name: string;
  63289. /**
  63290. * The clear color of the texture used to generate the glow map.
  63291. */
  63292. neutralColor: Color4;
  63293. /**
  63294. * Specifies whether the highlight layer is enabled or not.
  63295. */
  63296. isEnabled: boolean;
  63297. /**
  63298. * Gets the camera attached to the layer.
  63299. */
  63300. get camera(): Nullable<Camera>;
  63301. /**
  63302. * Gets the rendering group id the layer should render in.
  63303. */
  63304. get renderingGroupId(): number;
  63305. set renderingGroupId(renderingGroupId: number);
  63306. /**
  63307. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63308. */
  63309. disableBoundingBoxesFromEffectLayer: boolean;
  63310. /**
  63311. * An event triggered when the effect layer has been disposed.
  63312. */
  63313. onDisposeObservable: Observable<EffectLayer>;
  63314. /**
  63315. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63316. */
  63317. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63318. /**
  63319. * An event triggered when the generated texture is being merged in the scene.
  63320. */
  63321. onBeforeComposeObservable: Observable<EffectLayer>;
  63322. /**
  63323. * An event triggered when the mesh is rendered into the effect render target.
  63324. */
  63325. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63326. /**
  63327. * An event triggered after the mesh has been rendered into the effect render target.
  63328. */
  63329. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63330. /**
  63331. * An event triggered when the generated texture has been merged in the scene.
  63332. */
  63333. onAfterComposeObservable: Observable<EffectLayer>;
  63334. /**
  63335. * An event triggered when the effect layer changes its size.
  63336. */
  63337. onSizeChangedObservable: Observable<EffectLayer>;
  63338. /** @hidden */
  63339. static _SceneComponentInitialization: (scene: Scene) => void;
  63340. /**
  63341. * Instantiates a new effect Layer and references it in the scene.
  63342. * @param name The name of the layer
  63343. * @param scene The scene to use the layer in
  63344. */
  63345. constructor(
  63346. /** The Friendly of the effect in the scene */
  63347. name: string, scene: Scene);
  63348. /**
  63349. * Get the effect name of the layer.
  63350. * @return The effect name
  63351. */
  63352. abstract getEffectName(): string;
  63353. /**
  63354. * Checks for the readiness of the element composing the layer.
  63355. * @param subMesh the mesh to check for
  63356. * @param useInstances specify whether or not to use instances to render the mesh
  63357. * @return true if ready otherwise, false
  63358. */
  63359. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63360. /**
  63361. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63362. * @returns true if the effect requires stencil during the main canvas render pass.
  63363. */
  63364. abstract needStencil(): boolean;
  63365. /**
  63366. * Create the merge effect. This is the shader use to blit the information back
  63367. * to the main canvas at the end of the scene rendering.
  63368. * @returns The effect containing the shader used to merge the effect on the main canvas
  63369. */
  63370. protected abstract _createMergeEffect(): Effect;
  63371. /**
  63372. * Creates the render target textures and post processes used in the effect layer.
  63373. */
  63374. protected abstract _createTextureAndPostProcesses(): void;
  63375. /**
  63376. * Implementation specific of rendering the generating effect on the main canvas.
  63377. * @param effect The effect used to render through
  63378. */
  63379. protected abstract _internalRender(effect: Effect): void;
  63380. /**
  63381. * Sets the required values for both the emissive texture and and the main color.
  63382. */
  63383. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63384. /**
  63385. * Free any resources and references associated to a mesh.
  63386. * Internal use
  63387. * @param mesh The mesh to free.
  63388. */
  63389. abstract _disposeMesh(mesh: Mesh): void;
  63390. /**
  63391. * Serializes this layer (Glow or Highlight for example)
  63392. * @returns a serialized layer object
  63393. */
  63394. abstract serialize?(): any;
  63395. /**
  63396. * Initializes the effect layer with the required options.
  63397. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63398. */
  63399. protected _init(options: Partial<IEffectLayerOptions>): void;
  63400. /**
  63401. * Generates the index buffer of the full screen quad blending to the main canvas.
  63402. */
  63403. private _generateIndexBuffer;
  63404. /**
  63405. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63406. */
  63407. private _generateVertexBuffer;
  63408. /**
  63409. * Sets the main texture desired size which is the closest power of two
  63410. * of the engine canvas size.
  63411. */
  63412. private _setMainTextureSize;
  63413. /**
  63414. * Creates the main texture for the effect layer.
  63415. */
  63416. protected _createMainTexture(): void;
  63417. /**
  63418. * Adds specific effects defines.
  63419. * @param defines The defines to add specifics to.
  63420. */
  63421. protected _addCustomEffectDefines(defines: string[]): void;
  63422. /**
  63423. * Checks for the readiness of the element composing the layer.
  63424. * @param subMesh the mesh to check for
  63425. * @param useInstances specify whether or not to use instances to render the mesh
  63426. * @param emissiveTexture the associated emissive texture used to generate the glow
  63427. * @return true if ready otherwise, false
  63428. */
  63429. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63430. /**
  63431. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63432. */
  63433. render(): void;
  63434. /**
  63435. * Determine if a given mesh will be used in the current effect.
  63436. * @param mesh mesh to test
  63437. * @returns true if the mesh will be used
  63438. */
  63439. hasMesh(mesh: AbstractMesh): boolean;
  63440. /**
  63441. * Returns true if the layer contains information to display, otherwise false.
  63442. * @returns true if the glow layer should be rendered
  63443. */
  63444. shouldRender(): boolean;
  63445. /**
  63446. * Returns true if the mesh should render, otherwise false.
  63447. * @param mesh The mesh to render
  63448. * @returns true if it should render otherwise false
  63449. */
  63450. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63451. /**
  63452. * Returns true if the mesh can be rendered, otherwise false.
  63453. * @param mesh The mesh to render
  63454. * @param material The material used on the mesh
  63455. * @returns true if it can be rendered otherwise false
  63456. */
  63457. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63458. /**
  63459. * Returns true if the mesh should render, otherwise false.
  63460. * @param mesh The mesh to render
  63461. * @returns true if it should render otherwise false
  63462. */
  63463. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63464. /**
  63465. * Renders the submesh passed in parameter to the generation map.
  63466. */
  63467. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63468. /**
  63469. * Defines whether the current material of the mesh should be use to render the effect.
  63470. * @param mesh defines the current mesh to render
  63471. */
  63472. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63473. /**
  63474. * Rebuild the required buffers.
  63475. * @hidden Internal use only.
  63476. */
  63477. _rebuild(): void;
  63478. /**
  63479. * Dispose only the render target textures and post process.
  63480. */
  63481. private _disposeTextureAndPostProcesses;
  63482. /**
  63483. * Dispose the highlight layer and free resources.
  63484. */
  63485. dispose(): void;
  63486. /**
  63487. * Gets the class name of the effect layer
  63488. * @returns the string with the class name of the effect layer
  63489. */
  63490. getClassName(): string;
  63491. /**
  63492. * Creates an effect layer from parsed effect layer data
  63493. * @param parsedEffectLayer defines effect layer data
  63494. * @param scene defines the current scene
  63495. * @param rootUrl defines the root URL containing the effect layer information
  63496. * @returns a parsed effect Layer
  63497. */
  63498. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. interface AbstractScene {
  63503. /**
  63504. * The list of effect layers (highlights/glow) added to the scene
  63505. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63506. * @see https://doc.babylonjs.com/how_to/glow_layer
  63507. */
  63508. effectLayers: Array<EffectLayer>;
  63509. /**
  63510. * Removes the given effect layer from this scene.
  63511. * @param toRemove defines the effect layer to remove
  63512. * @returns the index of the removed effect layer
  63513. */
  63514. removeEffectLayer(toRemove: EffectLayer): number;
  63515. /**
  63516. * Adds the given effect layer to this scene
  63517. * @param newEffectLayer defines the effect layer to add
  63518. */
  63519. addEffectLayer(newEffectLayer: EffectLayer): void;
  63520. }
  63521. /**
  63522. * Defines the layer scene component responsible to manage any effect layers
  63523. * in a given scene.
  63524. */
  63525. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63526. /**
  63527. * The component name helpful to identify the component in the list of scene components.
  63528. */
  63529. readonly name: string;
  63530. /**
  63531. * The scene the component belongs to.
  63532. */
  63533. scene: Scene;
  63534. private _engine;
  63535. private _renderEffects;
  63536. private _needStencil;
  63537. private _previousStencilState;
  63538. /**
  63539. * Creates a new instance of the component for the given scene
  63540. * @param scene Defines the scene to register the component in
  63541. */
  63542. constructor(scene: Scene);
  63543. /**
  63544. * Registers the component in a given scene
  63545. */
  63546. register(): void;
  63547. /**
  63548. * Rebuilds the elements related to this component in case of
  63549. * context lost for instance.
  63550. */
  63551. rebuild(): void;
  63552. /**
  63553. * Serializes the component data to the specified json object
  63554. * @param serializationObject The object to serialize to
  63555. */
  63556. serialize(serializationObject: any): void;
  63557. /**
  63558. * Adds all the elements from the container to the scene
  63559. * @param container the container holding the elements
  63560. */
  63561. addFromContainer(container: AbstractScene): void;
  63562. /**
  63563. * Removes all the elements in the container from the scene
  63564. * @param container contains the elements to remove
  63565. * @param dispose if the removed element should be disposed (default: false)
  63566. */
  63567. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63568. /**
  63569. * Disposes the component and the associated resources.
  63570. */
  63571. dispose(): void;
  63572. private _isReadyForMesh;
  63573. private _renderMainTexture;
  63574. private _setStencil;
  63575. private _setStencilBack;
  63576. private _draw;
  63577. private _drawCamera;
  63578. private _drawRenderingGroup;
  63579. }
  63580. }
  63581. declare module BABYLON {
  63582. /** @hidden */
  63583. export var glowMapMergePixelShader: {
  63584. name: string;
  63585. shader: string;
  63586. };
  63587. }
  63588. declare module BABYLON {
  63589. /** @hidden */
  63590. export var glowMapMergeVertexShader: {
  63591. name: string;
  63592. shader: string;
  63593. };
  63594. }
  63595. declare module BABYLON {
  63596. interface AbstractScene {
  63597. /**
  63598. * Return a the first highlight layer of the scene with a given name.
  63599. * @param name The name of the highlight layer to look for.
  63600. * @return The highlight layer if found otherwise null.
  63601. */
  63602. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63603. }
  63604. /**
  63605. * Glow layer options. This helps customizing the behaviour
  63606. * of the glow layer.
  63607. */
  63608. export interface IGlowLayerOptions {
  63609. /**
  63610. * Multiplication factor apply to the canvas size to compute the render target size
  63611. * used to generated the glowing objects (the smaller the faster).
  63612. */
  63613. mainTextureRatio: number;
  63614. /**
  63615. * Enforces a fixed size texture to ensure resize independent blur.
  63616. */
  63617. mainTextureFixedSize?: number;
  63618. /**
  63619. * How big is the kernel of the blur texture.
  63620. */
  63621. blurKernelSize: number;
  63622. /**
  63623. * The camera attached to the layer.
  63624. */
  63625. camera: Nullable<Camera>;
  63626. /**
  63627. * Enable MSAA by choosing the number of samples.
  63628. */
  63629. mainTextureSamples?: number;
  63630. /**
  63631. * The rendering group to draw the layer in.
  63632. */
  63633. renderingGroupId: number;
  63634. }
  63635. /**
  63636. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63637. *
  63638. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63639. *
  63640. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63641. */
  63642. export class GlowLayer extends EffectLayer {
  63643. /**
  63644. * Effect Name of the layer.
  63645. */
  63646. static readonly EffectName: string;
  63647. /**
  63648. * The default blur kernel size used for the glow.
  63649. */
  63650. static DefaultBlurKernelSize: number;
  63651. /**
  63652. * The default texture size ratio used for the glow.
  63653. */
  63654. static DefaultTextureRatio: number;
  63655. /**
  63656. * Sets the kernel size of the blur.
  63657. */
  63658. set blurKernelSize(value: number);
  63659. /**
  63660. * Gets the kernel size of the blur.
  63661. */
  63662. get blurKernelSize(): number;
  63663. /**
  63664. * Sets the glow intensity.
  63665. */
  63666. set intensity(value: number);
  63667. /**
  63668. * Gets the glow intensity.
  63669. */
  63670. get intensity(): number;
  63671. private _options;
  63672. private _intensity;
  63673. private _horizontalBlurPostprocess1;
  63674. private _verticalBlurPostprocess1;
  63675. private _horizontalBlurPostprocess2;
  63676. private _verticalBlurPostprocess2;
  63677. private _blurTexture1;
  63678. private _blurTexture2;
  63679. private _postProcesses1;
  63680. private _postProcesses2;
  63681. private _includedOnlyMeshes;
  63682. private _excludedMeshes;
  63683. private _meshesUsingTheirOwnMaterials;
  63684. /**
  63685. * Callback used to let the user override the color selection on a per mesh basis
  63686. */
  63687. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63688. /**
  63689. * Callback used to let the user override the texture selection on a per mesh basis
  63690. */
  63691. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63692. /**
  63693. * Instantiates a new glow Layer and references it to the scene.
  63694. * @param name The name of the layer
  63695. * @param scene The scene to use the layer in
  63696. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63697. */
  63698. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63699. /**
  63700. * Get the effect name of the layer.
  63701. * @return The effect name
  63702. */
  63703. getEffectName(): string;
  63704. /**
  63705. * Create the merge effect. This is the shader use to blit the information back
  63706. * to the main canvas at the end of the scene rendering.
  63707. */
  63708. protected _createMergeEffect(): Effect;
  63709. /**
  63710. * Creates the render target textures and post processes used in the glow layer.
  63711. */
  63712. protected _createTextureAndPostProcesses(): void;
  63713. /**
  63714. * Checks for the readiness of the element composing the layer.
  63715. * @param subMesh the mesh to check for
  63716. * @param useInstances specify whether or not to use instances to render the mesh
  63717. * @param emissiveTexture the associated emissive texture used to generate the glow
  63718. * @return true if ready otherwise, false
  63719. */
  63720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63721. /**
  63722. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63723. */
  63724. needStencil(): boolean;
  63725. /**
  63726. * Returns true if the mesh can be rendered, otherwise false.
  63727. * @param mesh The mesh to render
  63728. * @param material The material used on the mesh
  63729. * @returns true if it can be rendered otherwise false
  63730. */
  63731. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63732. /**
  63733. * Implementation specific of rendering the generating effect on the main canvas.
  63734. * @param effect The effect used to render through
  63735. */
  63736. protected _internalRender(effect: Effect): void;
  63737. /**
  63738. * Sets the required values for both the emissive texture and and the main color.
  63739. */
  63740. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63741. /**
  63742. * Returns true if the mesh should render, otherwise false.
  63743. * @param mesh The mesh to render
  63744. * @returns true if it should render otherwise false
  63745. */
  63746. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63747. /**
  63748. * Adds specific effects defines.
  63749. * @param defines The defines to add specifics to.
  63750. */
  63751. protected _addCustomEffectDefines(defines: string[]): void;
  63752. /**
  63753. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63754. * @param mesh The mesh to exclude from the glow layer
  63755. */
  63756. addExcludedMesh(mesh: Mesh): void;
  63757. /**
  63758. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63759. * @param mesh The mesh to remove
  63760. */
  63761. removeExcludedMesh(mesh: Mesh): void;
  63762. /**
  63763. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63764. * @param mesh The mesh to include in the glow layer
  63765. */
  63766. addIncludedOnlyMesh(mesh: Mesh): void;
  63767. /**
  63768. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63769. * @param mesh The mesh to remove
  63770. */
  63771. removeIncludedOnlyMesh(mesh: Mesh): void;
  63772. /**
  63773. * Determine if a given mesh will be used in the glow layer
  63774. * @param mesh The mesh to test
  63775. * @returns true if the mesh will be highlighted by the current glow layer
  63776. */
  63777. hasMesh(mesh: AbstractMesh): boolean;
  63778. /**
  63779. * Defines whether the current material of the mesh should be use to render the effect.
  63780. * @param mesh defines the current mesh to render
  63781. */
  63782. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63783. /**
  63784. * Add a mesh to be rendered through its own material and not with emissive only.
  63785. * @param mesh The mesh for which we need to use its material
  63786. */
  63787. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63788. /**
  63789. * Remove a mesh from being rendered through its own material and not with emissive only.
  63790. * @param mesh The mesh for which we need to not use its material
  63791. */
  63792. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63793. /**
  63794. * Free any resources and references associated to a mesh.
  63795. * Internal use
  63796. * @param mesh The mesh to free.
  63797. * @hidden
  63798. */
  63799. _disposeMesh(mesh: Mesh): 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 glow layer
  63807. * @returns a serialized glow layer object
  63808. */
  63809. serialize(): any;
  63810. /**
  63811. * Creates a Glow Layer from parsed glow layer data
  63812. * @param parsedGlowLayer defines glow layer data
  63813. * @param scene defines the current scene
  63814. * @param rootUrl defines the root URL containing the glow layer information
  63815. * @returns a parsed Glow Layer
  63816. */
  63817. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63818. }
  63819. }
  63820. declare module BABYLON {
  63821. /** @hidden */
  63822. export var glowBlurPostProcessPixelShader: {
  63823. name: string;
  63824. shader: string;
  63825. };
  63826. }
  63827. declare module BABYLON {
  63828. interface AbstractScene {
  63829. /**
  63830. * Return a the first highlight layer of the scene with a given name.
  63831. * @param name The name of the highlight layer to look for.
  63832. * @return The highlight layer if found otherwise null.
  63833. */
  63834. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63835. }
  63836. /**
  63837. * Highlight layer options. This helps customizing the behaviour
  63838. * of the highlight layer.
  63839. */
  63840. export interface IHighlightLayerOptions {
  63841. /**
  63842. * Multiplication factor apply to the canvas size to compute the render target size
  63843. * used to generated the glowing objects (the smaller the faster).
  63844. */
  63845. mainTextureRatio: number;
  63846. /**
  63847. * Enforces a fixed size texture to ensure resize independent blur.
  63848. */
  63849. mainTextureFixedSize?: number;
  63850. /**
  63851. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63852. * of the picture to blur (the smaller the faster).
  63853. */
  63854. blurTextureSizeRatio: number;
  63855. /**
  63856. * How big in texel of the blur texture is the vertical blur.
  63857. */
  63858. blurVerticalSize: number;
  63859. /**
  63860. * How big in texel of the blur texture is the horizontal blur.
  63861. */
  63862. blurHorizontalSize: number;
  63863. /**
  63864. * Alpha blending mode used to apply the blur. Default is combine.
  63865. */
  63866. alphaBlendingMode: number;
  63867. /**
  63868. * The camera attached to the layer.
  63869. */
  63870. camera: Nullable<Camera>;
  63871. /**
  63872. * Should we display highlight as a solid stroke?
  63873. */
  63874. isStroke?: boolean;
  63875. /**
  63876. * The rendering group to draw the layer in.
  63877. */
  63878. renderingGroupId: number;
  63879. }
  63880. /**
  63881. * The highlight layer Helps adding a glow effect around a mesh.
  63882. *
  63883. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63884. * glowy meshes to your scene.
  63885. *
  63886. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63887. */
  63888. export class HighlightLayer extends EffectLayer {
  63889. name: string;
  63890. /**
  63891. * Effect Name of the highlight layer.
  63892. */
  63893. static readonly EffectName: string;
  63894. /**
  63895. * The neutral color used during the preparation of the glow effect.
  63896. * This is black by default as the blend operation is a blend operation.
  63897. */
  63898. static NeutralColor: Color4;
  63899. /**
  63900. * Stencil value used for glowing meshes.
  63901. */
  63902. static GlowingMeshStencilReference: number;
  63903. /**
  63904. * Stencil value used for the other meshes in the scene.
  63905. */
  63906. static NormalMeshStencilReference: number;
  63907. /**
  63908. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63909. */
  63910. innerGlow: boolean;
  63911. /**
  63912. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63913. */
  63914. outerGlow: boolean;
  63915. /**
  63916. * Specifies the horizontal size of the blur.
  63917. */
  63918. set blurHorizontalSize(value: number);
  63919. /**
  63920. * Specifies the vertical size of the blur.
  63921. */
  63922. set blurVerticalSize(value: number);
  63923. /**
  63924. * Gets the horizontal size of the blur.
  63925. */
  63926. get blurHorizontalSize(): number;
  63927. /**
  63928. * Gets the vertical size of the blur.
  63929. */
  63930. get blurVerticalSize(): number;
  63931. /**
  63932. * An event triggered when the highlight layer is being blurred.
  63933. */
  63934. onBeforeBlurObservable: Observable<HighlightLayer>;
  63935. /**
  63936. * An event triggered when the highlight layer has been blurred.
  63937. */
  63938. onAfterBlurObservable: Observable<HighlightLayer>;
  63939. private _instanceGlowingMeshStencilReference;
  63940. private _options;
  63941. private _downSamplePostprocess;
  63942. private _horizontalBlurPostprocess;
  63943. private _verticalBlurPostprocess;
  63944. private _blurTexture;
  63945. private _meshes;
  63946. private _excludedMeshes;
  63947. /**
  63948. * Instantiates a new highlight Layer and references it to the scene..
  63949. * @param name The name of the layer
  63950. * @param scene The scene to use the layer in
  63951. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63952. */
  63953. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63954. /**
  63955. * Get the effect name of the layer.
  63956. * @return The effect name
  63957. */
  63958. getEffectName(): string;
  63959. /**
  63960. * Create the merge effect. This is the shader use to blit the information back
  63961. * to the main canvas at the end of the scene rendering.
  63962. */
  63963. protected _createMergeEffect(): Effect;
  63964. /**
  63965. * Creates the render target textures and post processes used in the highlight layer.
  63966. */
  63967. protected _createTextureAndPostProcesses(): void;
  63968. /**
  63969. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63970. */
  63971. needStencil(): boolean;
  63972. /**
  63973. * Checks for the readiness of the element composing the layer.
  63974. * @param subMesh the mesh to check for
  63975. * @param useInstances specify wether or not to use instances to render the mesh
  63976. * @param emissiveTexture the associated emissive texture used to generate the glow
  63977. * @return true if ready otherwise, false
  63978. */
  63979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63980. /**
  63981. * Implementation specific of rendering the generating effect on the main canvas.
  63982. * @param effect The effect used to render through
  63983. */
  63984. protected _internalRender(effect: Effect): void;
  63985. /**
  63986. * Returns true if the layer contains information to display, otherwise false.
  63987. */
  63988. shouldRender(): boolean;
  63989. /**
  63990. * Returns true if the mesh should render, otherwise false.
  63991. * @param mesh The mesh to render
  63992. * @returns true if it should render otherwise false
  63993. */
  63994. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63995. /**
  63996. * Returns true if the mesh can be rendered, otherwise false.
  63997. * @param mesh The mesh to render
  63998. * @param material The material used on the mesh
  63999. * @returns true if it can be rendered otherwise false
  64000. */
  64001. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  64002. /**
  64003. * Adds specific effects defines.
  64004. * @param defines The defines to add specifics to.
  64005. */
  64006. protected _addCustomEffectDefines(defines: string[]): void;
  64007. /**
  64008. * Sets the required values for both the emissive texture and and the main color.
  64009. */
  64010. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  64011. /**
  64012. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  64013. * @param mesh The mesh to exclude from the highlight layer
  64014. */
  64015. addExcludedMesh(mesh: Mesh): void;
  64016. /**
  64017. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  64018. * @param mesh The mesh to highlight
  64019. */
  64020. removeExcludedMesh(mesh: Mesh): void;
  64021. /**
  64022. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64023. * @param mesh mesh to test
  64024. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64025. */
  64026. hasMesh(mesh: AbstractMesh): boolean;
  64027. /**
  64028. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64029. * @param mesh The mesh to highlight
  64030. * @param color The color of the highlight
  64031. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64032. */
  64033. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64034. /**
  64035. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64036. * @param mesh The mesh to highlight
  64037. */
  64038. removeMesh(mesh: Mesh): void;
  64039. /**
  64040. * Remove all the meshes currently referenced in the highlight layer
  64041. */
  64042. removeAllMeshes(): void;
  64043. /**
  64044. * Force the stencil to the normal expected value for none glowing parts
  64045. */
  64046. private _defaultStencilReference;
  64047. /**
  64048. * Free any resources and references associated to a mesh.
  64049. * Internal use
  64050. * @param mesh The mesh to free.
  64051. * @hidden
  64052. */
  64053. _disposeMesh(mesh: Mesh): void;
  64054. /**
  64055. * Dispose the highlight layer and free resources.
  64056. */
  64057. dispose(): void;
  64058. /**
  64059. * Gets the class name of the effect layer
  64060. * @returns the string with the class name of the effect layer
  64061. */
  64062. getClassName(): string;
  64063. /**
  64064. * Serializes this Highlight layer
  64065. * @returns a serialized Highlight layer object
  64066. */
  64067. serialize(): any;
  64068. /**
  64069. * Creates a Highlight layer from parsed Highlight layer data
  64070. * @param parsedHightlightLayer defines the Highlight layer data
  64071. * @param scene defines the current scene
  64072. * @param rootUrl defines the root URL containing the Highlight layer information
  64073. * @returns a parsed Highlight layer
  64074. */
  64075. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. interface AbstractScene {
  64080. /**
  64081. * The list of layers (background and foreground) of the scene
  64082. */
  64083. layers: Array<Layer>;
  64084. }
  64085. /**
  64086. * Defines the layer scene component responsible to manage any layers
  64087. * in a given scene.
  64088. */
  64089. export class LayerSceneComponent implements ISceneComponent {
  64090. /**
  64091. * The component name helpful to identify the component in the list of scene components.
  64092. */
  64093. readonly name: string;
  64094. /**
  64095. * The scene the component belongs to.
  64096. */
  64097. scene: Scene;
  64098. private _engine;
  64099. /**
  64100. * Creates a new instance of the component for the given scene
  64101. * @param scene Defines the scene to register the component in
  64102. */
  64103. constructor(scene: Scene);
  64104. /**
  64105. * Registers the component in a given scene
  64106. */
  64107. register(): void;
  64108. /**
  64109. * Rebuilds the elements related to this component in case of
  64110. * context lost for instance.
  64111. */
  64112. rebuild(): void;
  64113. /**
  64114. * Disposes the component and the associated resources.
  64115. */
  64116. dispose(): void;
  64117. private _draw;
  64118. private _drawCameraPredicate;
  64119. private _drawCameraBackground;
  64120. private _drawCameraForeground;
  64121. private _drawRenderTargetPredicate;
  64122. private _drawRenderTargetBackground;
  64123. private _drawRenderTargetForeground;
  64124. /**
  64125. * Adds all the elements from the container to the scene
  64126. * @param container the container holding the elements
  64127. */
  64128. addFromContainer(container: AbstractScene): void;
  64129. /**
  64130. * Removes all the elements in the container from the scene
  64131. * @param container contains the elements to remove
  64132. * @param dispose if the removed element should be disposed (default: false)
  64133. */
  64134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64135. }
  64136. }
  64137. declare module BABYLON {
  64138. /** @hidden */
  64139. export var layerPixelShader: {
  64140. name: string;
  64141. shader: string;
  64142. };
  64143. }
  64144. declare module BABYLON {
  64145. /** @hidden */
  64146. export var layerVertexShader: {
  64147. name: string;
  64148. shader: string;
  64149. };
  64150. }
  64151. declare module BABYLON {
  64152. /**
  64153. * This represents a full screen 2d layer.
  64154. * This can be useful to display a picture in the background of your scene for instance.
  64155. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64156. */
  64157. export class Layer {
  64158. /**
  64159. * Define the name of the layer.
  64160. */
  64161. name: string;
  64162. /**
  64163. * Define the texture the layer should display.
  64164. */
  64165. texture: Nullable<Texture>;
  64166. /**
  64167. * Is the layer in background or foreground.
  64168. */
  64169. isBackground: boolean;
  64170. /**
  64171. * Define the color of the layer (instead of texture).
  64172. */
  64173. color: Color4;
  64174. /**
  64175. * Define the scale of the layer in order to zoom in out of the texture.
  64176. */
  64177. scale: Vector2;
  64178. /**
  64179. * Define an offset for the layer in order to shift the texture.
  64180. */
  64181. offset: Vector2;
  64182. /**
  64183. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64184. */
  64185. alphaBlendingMode: number;
  64186. /**
  64187. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64188. * Alpha test will not mix with the background color in case of transparency.
  64189. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64190. */
  64191. alphaTest: boolean;
  64192. /**
  64193. * Define a mask to restrict the layer to only some of the scene cameras.
  64194. */
  64195. layerMask: number;
  64196. /**
  64197. * Define the list of render target the layer is visible into.
  64198. */
  64199. renderTargetTextures: RenderTargetTexture[];
  64200. /**
  64201. * Define if the layer is only used in renderTarget or if it also
  64202. * renders in the main frame buffer of the canvas.
  64203. */
  64204. renderOnlyInRenderTargetTextures: boolean;
  64205. private _scene;
  64206. private _vertexBuffers;
  64207. private _indexBuffer;
  64208. private _effect;
  64209. private _previousDefines;
  64210. /**
  64211. * An event triggered when the layer is disposed.
  64212. */
  64213. onDisposeObservable: Observable<Layer>;
  64214. private _onDisposeObserver;
  64215. /**
  64216. * Back compatibility with callback before the onDisposeObservable existed.
  64217. * The set callback will be triggered when the layer has been disposed.
  64218. */
  64219. set onDispose(callback: () => void);
  64220. /**
  64221. * An event triggered before rendering the scene
  64222. */
  64223. onBeforeRenderObservable: Observable<Layer>;
  64224. private _onBeforeRenderObserver;
  64225. /**
  64226. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64227. * The set callback will be triggered just before rendering the layer.
  64228. */
  64229. set onBeforeRender(callback: () => void);
  64230. /**
  64231. * An event triggered after rendering the scene
  64232. */
  64233. onAfterRenderObservable: Observable<Layer>;
  64234. private _onAfterRenderObserver;
  64235. /**
  64236. * Back compatibility with callback before the onAfterRenderObservable existed.
  64237. * The set callback will be triggered just after rendering the layer.
  64238. */
  64239. set onAfterRender(callback: () => void);
  64240. /**
  64241. * Instantiates a new layer.
  64242. * This represents a full screen 2d layer.
  64243. * This can be useful to display a picture in the background of your scene for instance.
  64244. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64245. * @param name Define the name of the layer in the scene
  64246. * @param imgUrl Define the url of the texture to display in the layer
  64247. * @param scene Define the scene the layer belongs to
  64248. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64249. * @param color Defines a color for the layer
  64250. */
  64251. constructor(
  64252. /**
  64253. * Define the name of the layer.
  64254. */
  64255. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64256. private _createIndexBuffer;
  64257. /** @hidden */
  64258. _rebuild(): void;
  64259. /**
  64260. * Renders the layer in the scene.
  64261. */
  64262. render(): void;
  64263. /**
  64264. * Disposes and releases the associated resources.
  64265. */
  64266. dispose(): void;
  64267. }
  64268. }
  64269. declare module BABYLON {
  64270. /** @hidden */
  64271. export var lensFlarePixelShader: {
  64272. name: string;
  64273. shader: string;
  64274. };
  64275. }
  64276. declare module BABYLON {
  64277. /** @hidden */
  64278. export var lensFlareVertexShader: {
  64279. name: string;
  64280. shader: string;
  64281. };
  64282. }
  64283. declare module BABYLON {
  64284. /**
  64285. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64286. * It is usually composed of several `lensFlare`.
  64287. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64288. */
  64289. export class LensFlareSystem {
  64290. /**
  64291. * Define the name of the lens flare system
  64292. */
  64293. name: string;
  64294. /**
  64295. * List of lens flares used in this system.
  64296. */
  64297. lensFlares: LensFlare[];
  64298. /**
  64299. * Define a limit from the border the lens flare can be visible.
  64300. */
  64301. borderLimit: number;
  64302. /**
  64303. * Define a viewport border we do not want to see the lens flare in.
  64304. */
  64305. viewportBorder: number;
  64306. /**
  64307. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64308. */
  64309. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64310. /**
  64311. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64312. */
  64313. layerMask: number;
  64314. /**
  64315. * Define the id of the lens flare system in the scene.
  64316. * (equal to name by default)
  64317. */
  64318. id: string;
  64319. private _scene;
  64320. private _emitter;
  64321. private _vertexBuffers;
  64322. private _indexBuffer;
  64323. private _effect;
  64324. private _positionX;
  64325. private _positionY;
  64326. private _isEnabled;
  64327. /** @hidden */
  64328. static _SceneComponentInitialization: (scene: Scene) => void;
  64329. /**
  64330. * Instantiates a lens flare system.
  64331. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64332. * It is usually composed of several `lensFlare`.
  64333. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64334. * @param name Define the name of the lens flare system in the scene
  64335. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64336. * @param scene Define the scene the lens flare system belongs to
  64337. */
  64338. constructor(
  64339. /**
  64340. * Define the name of the lens flare system
  64341. */
  64342. name: string, emitter: any, scene: Scene);
  64343. /**
  64344. * Define if the lens flare system is enabled.
  64345. */
  64346. get isEnabled(): boolean;
  64347. set isEnabled(value: boolean);
  64348. /**
  64349. * Get the scene the effects belongs to.
  64350. * @returns the scene holding the lens flare system
  64351. */
  64352. getScene(): Scene;
  64353. /**
  64354. * Get the emitter of the lens flare system.
  64355. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64356. * @returns the emitter of the lens flare system
  64357. */
  64358. getEmitter(): any;
  64359. /**
  64360. * Set the emitter of the lens flare system.
  64361. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64362. * @param newEmitter Define the new emitter of the system
  64363. */
  64364. setEmitter(newEmitter: any): void;
  64365. /**
  64366. * Get the lens flare system emitter position.
  64367. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64368. * @returns the position
  64369. */
  64370. getEmitterPosition(): Vector3;
  64371. /**
  64372. * @hidden
  64373. */
  64374. computeEffectivePosition(globalViewport: Viewport): boolean;
  64375. /** @hidden */
  64376. _isVisible(): boolean;
  64377. /**
  64378. * @hidden
  64379. */
  64380. render(): boolean;
  64381. /**
  64382. * Dispose and release the lens flare with its associated resources.
  64383. */
  64384. dispose(): void;
  64385. /**
  64386. * Parse a lens flare system from a JSON representation
  64387. * @param parsedLensFlareSystem Define the JSON to parse
  64388. * @param scene Define the scene the parsed system should be instantiated in
  64389. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64390. * @returns the parsed system
  64391. */
  64392. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64393. /**
  64394. * Serialize the current Lens Flare System into a JSON representation.
  64395. * @returns the serialized JSON
  64396. */
  64397. serialize(): any;
  64398. }
  64399. }
  64400. declare module BABYLON {
  64401. /**
  64402. * This represents one of the lens effect in a `lensFlareSystem`.
  64403. * It controls one of the individual texture used in the effect.
  64404. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64405. */
  64406. export class LensFlare {
  64407. /**
  64408. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64409. */
  64410. size: number;
  64411. /**
  64412. * 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.
  64413. */
  64414. position: number;
  64415. /**
  64416. * Define the lens color.
  64417. */
  64418. color: Color3;
  64419. /**
  64420. * Define the lens texture.
  64421. */
  64422. texture: Nullable<Texture>;
  64423. /**
  64424. * Define the alpha mode to render this particular lens.
  64425. */
  64426. alphaMode: number;
  64427. private _system;
  64428. /**
  64429. * Creates a new Lens Flare.
  64430. * This represents one of the lens effect in a `lensFlareSystem`.
  64431. * It controls one of the individual texture used in the effect.
  64432. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64433. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64434. * @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.
  64435. * @param color Define the lens color
  64436. * @param imgUrl Define the lens texture url
  64437. * @param system Define the `lensFlareSystem` this flare is part of
  64438. * @returns The newly created Lens Flare
  64439. */
  64440. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64441. /**
  64442. * Instantiates a new Lens Flare.
  64443. * This represents one of the lens effect in a `lensFlareSystem`.
  64444. * It controls one of the individual texture used in the effect.
  64445. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64446. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64447. * @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.
  64448. * @param color Define the lens color
  64449. * @param imgUrl Define the lens texture url
  64450. * @param system Define the `lensFlareSystem` this flare is part of
  64451. */
  64452. constructor(
  64453. /**
  64454. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64455. */
  64456. size: number,
  64457. /**
  64458. * 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.
  64459. */
  64460. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64461. /**
  64462. * Dispose and release the lens flare with its associated resources.
  64463. */
  64464. dispose(): void;
  64465. }
  64466. }
  64467. declare module BABYLON {
  64468. interface AbstractScene {
  64469. /**
  64470. * The list of lens flare system added to the scene
  64471. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64472. */
  64473. lensFlareSystems: Array<LensFlareSystem>;
  64474. /**
  64475. * Removes the given lens flare system from this scene.
  64476. * @param toRemove The lens flare system to remove
  64477. * @returns The index of the removed lens flare system
  64478. */
  64479. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64480. /**
  64481. * Adds the given lens flare system to this scene
  64482. * @param newLensFlareSystem The lens flare system to add
  64483. */
  64484. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64485. /**
  64486. * Gets a lens flare system using its name
  64487. * @param name defines the name to look for
  64488. * @returns the lens flare system or null if not found
  64489. */
  64490. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64491. /**
  64492. * Gets a lens flare system using its id
  64493. * @param id defines the id to look for
  64494. * @returns the lens flare system or null if not found
  64495. */
  64496. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64497. }
  64498. /**
  64499. * Defines the lens flare scene component responsible to manage any lens flares
  64500. * in a given scene.
  64501. */
  64502. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64503. /**
  64504. * The component name helpful to identify the component in the list of scene components.
  64505. */
  64506. readonly name: string;
  64507. /**
  64508. * The scene the component belongs to.
  64509. */
  64510. scene: Scene;
  64511. /**
  64512. * Creates a new instance of the component for the given scene
  64513. * @param scene Defines the scene to register the component in
  64514. */
  64515. constructor(scene: Scene);
  64516. /**
  64517. * Registers the component in a given scene
  64518. */
  64519. register(): void;
  64520. /**
  64521. * Rebuilds the elements related to this component in case of
  64522. * context lost for instance.
  64523. */
  64524. rebuild(): void;
  64525. /**
  64526. * Adds all the elements from the container to the scene
  64527. * @param container the container holding the elements
  64528. */
  64529. addFromContainer(container: AbstractScene): void;
  64530. /**
  64531. * Removes all the elements in the container from the scene
  64532. * @param container contains the elements to remove
  64533. * @param dispose if the removed element should be disposed (default: false)
  64534. */
  64535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64536. /**
  64537. * Serializes the component data to the specified json object
  64538. * @param serializationObject The object to serialize to
  64539. */
  64540. serialize(serializationObject: any): void;
  64541. /**
  64542. * Disposes the component and the associated resources.
  64543. */
  64544. dispose(): void;
  64545. private _draw;
  64546. }
  64547. }
  64548. declare module BABYLON {
  64549. /** @hidden */
  64550. export var depthPixelShader: {
  64551. name: string;
  64552. shader: string;
  64553. };
  64554. }
  64555. declare module BABYLON {
  64556. /** @hidden */
  64557. export var depthVertexShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module BABYLON {
  64563. /**
  64564. * This represents a depth renderer in Babylon.
  64565. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64566. */
  64567. export class DepthRenderer {
  64568. private _scene;
  64569. private _depthMap;
  64570. private _effect;
  64571. private readonly _storeNonLinearDepth;
  64572. private readonly _clearColor;
  64573. /** Get if the depth renderer is using packed depth or not */
  64574. readonly isPacked: boolean;
  64575. private _cachedDefines;
  64576. private _camera;
  64577. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64578. enabled: boolean;
  64579. /**
  64580. * Specifies that the depth renderer will only be used within
  64581. * the camera it is created for.
  64582. * This can help forcing its rendering during the camera processing.
  64583. */
  64584. useOnlyInActiveCamera: boolean;
  64585. /** @hidden */
  64586. static _SceneComponentInitialization: (scene: Scene) => void;
  64587. /**
  64588. * Instantiates a depth renderer
  64589. * @param scene The scene the renderer belongs to
  64590. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64591. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64592. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64593. */
  64594. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64595. /**
  64596. * Creates the depth rendering effect and checks if the effect is ready.
  64597. * @param subMesh The submesh to be used to render the depth map of
  64598. * @param useInstances If multiple world instances should be used
  64599. * @returns if the depth renderer is ready to render the depth map
  64600. */
  64601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64602. /**
  64603. * Gets the texture which the depth map will be written to.
  64604. * @returns The depth map texture
  64605. */
  64606. getDepthMap(): RenderTargetTexture;
  64607. /**
  64608. * Disposes of the depth renderer.
  64609. */
  64610. dispose(): void;
  64611. }
  64612. }
  64613. declare module BABYLON {
  64614. /** @hidden */
  64615. export var minmaxReduxPixelShader: {
  64616. name: string;
  64617. shader: string;
  64618. };
  64619. }
  64620. declare module BABYLON {
  64621. /**
  64622. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64623. * and maximum values from all values of the texture.
  64624. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64625. * The source values are read from the red channel of the texture.
  64626. */
  64627. export class MinMaxReducer {
  64628. /**
  64629. * Observable triggered when the computation has been performed
  64630. */
  64631. onAfterReductionPerformed: Observable<{
  64632. min: number;
  64633. max: number;
  64634. }>;
  64635. protected _camera: Camera;
  64636. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64637. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64638. protected _postProcessManager: PostProcessManager;
  64639. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64640. protected _forceFullscreenViewport: boolean;
  64641. /**
  64642. * Creates a min/max reducer
  64643. * @param camera The camera to use for the post processes
  64644. */
  64645. constructor(camera: Camera);
  64646. /**
  64647. * Gets the texture used to read the values from.
  64648. */
  64649. get sourceTexture(): Nullable<RenderTargetTexture>;
  64650. /**
  64651. * Sets the source texture to read the values from.
  64652. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64653. * because in such textures '1' value must not be taken into account to compute the maximum
  64654. * as this value is used to clear the texture.
  64655. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64656. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64657. * @param depthRedux Indicates if the texture is a depth texture or not
  64658. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64659. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64660. */
  64661. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64662. /**
  64663. * Defines the refresh rate of the computation.
  64664. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64665. */
  64666. get refreshRate(): number;
  64667. set refreshRate(value: number);
  64668. protected _activated: boolean;
  64669. /**
  64670. * Gets the activation status of the reducer
  64671. */
  64672. get activated(): boolean;
  64673. /**
  64674. * Activates the reduction computation.
  64675. * When activated, the observers registered in onAfterReductionPerformed are
  64676. * called after the computation is performed
  64677. */
  64678. activate(): void;
  64679. /**
  64680. * Deactivates the reduction computation.
  64681. */
  64682. deactivate(): void;
  64683. /**
  64684. * Disposes the min/max reducer
  64685. * @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.
  64686. */
  64687. dispose(disposeAll?: boolean): void;
  64688. }
  64689. }
  64690. declare module BABYLON {
  64691. /**
  64692. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64693. */
  64694. export class DepthReducer extends MinMaxReducer {
  64695. private _depthRenderer;
  64696. private _depthRendererId;
  64697. /**
  64698. * Gets the depth renderer used for the computation.
  64699. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64700. */
  64701. get depthRenderer(): Nullable<DepthRenderer>;
  64702. /**
  64703. * Creates a depth reducer
  64704. * @param camera The camera used to render the depth texture
  64705. */
  64706. constructor(camera: Camera);
  64707. /**
  64708. * Sets the depth renderer to use to generate the depth map
  64709. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64710. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64711. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64712. */
  64713. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64714. /** @hidden */
  64715. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64716. /**
  64717. * Activates the reduction computation.
  64718. * When activated, the observers registered in onAfterReductionPerformed are
  64719. * called after the computation is performed
  64720. */
  64721. activate(): void;
  64722. /**
  64723. * Deactivates the reduction computation.
  64724. */
  64725. deactivate(): void;
  64726. /**
  64727. * Disposes the depth reducer
  64728. * @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.
  64729. */
  64730. dispose(disposeAll?: boolean): void;
  64731. }
  64732. }
  64733. declare module BABYLON {
  64734. /**
  64735. * A CSM implementation allowing casting shadows on large scenes.
  64736. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64737. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64738. */
  64739. export class CascadedShadowGenerator extends ShadowGenerator {
  64740. private static readonly frustumCornersNDCSpace;
  64741. /**
  64742. * Name of the CSM class
  64743. */
  64744. static CLASSNAME: string;
  64745. /**
  64746. * Defines the default number of cascades used by the CSM.
  64747. */
  64748. static readonly DEFAULT_CASCADES_COUNT: number;
  64749. /**
  64750. * Defines the minimum number of cascades used by the CSM.
  64751. */
  64752. static readonly MIN_CASCADES_COUNT: number;
  64753. /**
  64754. * Defines the maximum number of cascades used by the CSM.
  64755. */
  64756. static readonly MAX_CASCADES_COUNT: number;
  64757. protected _validateFilter(filter: number): number;
  64758. /**
  64759. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64760. */
  64761. penumbraDarkness: number;
  64762. private _numCascades;
  64763. /**
  64764. * Gets or set the number of cascades used by the CSM.
  64765. */
  64766. get numCascades(): number;
  64767. set numCascades(value: number);
  64768. /**
  64769. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64770. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64771. */
  64772. stabilizeCascades: boolean;
  64773. private _freezeShadowCastersBoundingInfo;
  64774. private _freezeShadowCastersBoundingInfoObservable;
  64775. /**
  64776. * Enables or disables the shadow casters bounding info computation.
  64777. * If your shadow casters don't move, you can disable this feature.
  64778. * If it is enabled, the bounding box computation is done every frame.
  64779. */
  64780. get freezeShadowCastersBoundingInfo(): boolean;
  64781. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64782. private _scbiMin;
  64783. private _scbiMax;
  64784. protected _computeShadowCastersBoundingInfo(): void;
  64785. protected _shadowCastersBoundingInfo: BoundingInfo;
  64786. /**
  64787. * Gets or sets the shadow casters bounding info.
  64788. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64789. * so that the system won't overwrite the bounds you provide
  64790. */
  64791. get shadowCastersBoundingInfo(): BoundingInfo;
  64792. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64793. protected _breaksAreDirty: boolean;
  64794. protected _minDistance: number;
  64795. protected _maxDistance: number;
  64796. /**
  64797. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64798. *
  64799. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64800. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64801. * @param min minimal distance for the breaks (default to 0.)
  64802. * @param max maximal distance for the breaks (default to 1.)
  64803. */
  64804. setMinMaxDistance(min: number, max: number): void;
  64805. /** Gets the minimal distance used in the cascade break computation */
  64806. get minDistance(): number;
  64807. /** Gets the maximal distance used in the cascade break computation */
  64808. get maxDistance(): number;
  64809. /**
  64810. * Gets the class name of that object
  64811. * @returns "CascadedShadowGenerator"
  64812. */
  64813. getClassName(): string;
  64814. private _cascadeMinExtents;
  64815. private _cascadeMaxExtents;
  64816. /**
  64817. * Gets a cascade minimum extents
  64818. * @param cascadeIndex index of the cascade
  64819. * @returns the minimum cascade extents
  64820. */
  64821. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64822. /**
  64823. * Gets a cascade maximum extents
  64824. * @param cascadeIndex index of the cascade
  64825. * @returns the maximum cascade extents
  64826. */
  64827. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64828. private _cascades;
  64829. private _currentLayer;
  64830. private _viewSpaceFrustumsZ;
  64831. private _viewMatrices;
  64832. private _projectionMatrices;
  64833. private _transformMatrices;
  64834. private _transformMatricesAsArray;
  64835. private _frustumLengths;
  64836. private _lightSizeUVCorrection;
  64837. private _depthCorrection;
  64838. private _frustumCornersWorldSpace;
  64839. private _frustumCenter;
  64840. private _shadowCameraPos;
  64841. private _shadowMaxZ;
  64842. /**
  64843. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64844. * It defaults to camera.maxZ
  64845. */
  64846. get shadowMaxZ(): number;
  64847. /**
  64848. * Sets the shadow max z distance.
  64849. */
  64850. set shadowMaxZ(value: number);
  64851. protected _debug: boolean;
  64852. /**
  64853. * Gets or sets the debug flag.
  64854. * When enabled, the cascades are materialized by different colors on the screen.
  64855. */
  64856. get debug(): boolean;
  64857. set debug(dbg: boolean);
  64858. private _depthClamp;
  64859. /**
  64860. * Gets or sets the depth clamping value.
  64861. *
  64862. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64863. * to account for the shadow casters far away.
  64864. *
  64865. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64866. */
  64867. get depthClamp(): boolean;
  64868. set depthClamp(value: boolean);
  64869. private _cascadeBlendPercentage;
  64870. /**
  64871. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64872. * It defaults to 0.1 (10% blending).
  64873. */
  64874. get cascadeBlendPercentage(): number;
  64875. set cascadeBlendPercentage(value: number);
  64876. private _lambda;
  64877. /**
  64878. * Gets or set the lambda parameter.
  64879. * This parameter is used to split the camera frustum and create the cascades.
  64880. * 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.
  64881. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64882. */
  64883. get lambda(): number;
  64884. set lambda(value: number);
  64885. /**
  64886. * Gets the view matrix corresponding to a given cascade
  64887. * @param cascadeNum cascade to retrieve the view matrix from
  64888. * @returns the cascade view matrix
  64889. */
  64890. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64891. /**
  64892. * Gets the projection matrix corresponding to a given cascade
  64893. * @param cascadeNum cascade to retrieve the projection matrix from
  64894. * @returns the cascade projection matrix
  64895. */
  64896. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64897. /**
  64898. * Gets the transformation matrix corresponding to a given cascade
  64899. * @param cascadeNum cascade to retrieve the transformation matrix from
  64900. * @returns the cascade transformation matrix
  64901. */
  64902. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64903. private _depthRenderer;
  64904. /**
  64905. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64906. *
  64907. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64908. *
  64909. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64910. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64911. * @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
  64912. */
  64913. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64914. private _depthReducer;
  64915. private _autoCalcDepthBounds;
  64916. /**
  64917. * Gets or sets the autoCalcDepthBounds property.
  64918. *
  64919. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64920. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64921. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64922. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64923. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64924. */
  64925. get autoCalcDepthBounds(): boolean;
  64926. set autoCalcDepthBounds(value: boolean);
  64927. /**
  64928. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64929. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64930. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64931. * for setting the refresh rate on the renderer yourself!
  64932. */
  64933. get autoCalcDepthBoundsRefreshRate(): number;
  64934. set autoCalcDepthBoundsRefreshRate(value: number);
  64935. /**
  64936. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64937. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64938. * you change the camera near/far planes!
  64939. */
  64940. splitFrustum(): void;
  64941. private _splitFrustum;
  64942. private _computeMatrices;
  64943. private _computeFrustumInWorldSpace;
  64944. private _computeCascadeFrustum;
  64945. /**
  64946. * Support test.
  64947. */
  64948. static get IsSupported(): boolean;
  64949. /** @hidden */
  64950. static _SceneComponentInitialization: (scene: Scene) => void;
  64951. /**
  64952. * Creates a Cascaded Shadow Generator object.
  64953. * A ShadowGenerator is the required tool to use the shadows.
  64954. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64955. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64956. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64957. * @param light The directional light object generating the shadows.
  64958. * @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.
  64959. */
  64960. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64961. protected _initializeGenerator(): void;
  64962. protected _createTargetRenderTexture(): void;
  64963. protected _initializeShadowMap(): void;
  64964. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64965. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64966. /**
  64967. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64968. * @param defines Defines of the material we want to update
  64969. * @param lightIndex Index of the light in the enabled light list of the material
  64970. */
  64971. prepareDefines(defines: any, lightIndex: number): void;
  64972. /**
  64973. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64974. * defined in the generator but impacting the effect).
  64975. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64976. * @param effect The effect we are binfing the information for
  64977. */
  64978. bindShadowLight(lightIndex: string, effect: Effect): void;
  64979. /**
  64980. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64981. * (eq to view projection * shadow projection matrices)
  64982. * @returns The transform matrix used to create the shadow map
  64983. */
  64984. getTransformMatrix(): Matrix;
  64985. /**
  64986. * Disposes the ShadowGenerator.
  64987. * Returns nothing.
  64988. */
  64989. dispose(): void;
  64990. /**
  64991. * Serializes the shadow generator setup to a json object.
  64992. * @returns The serialized JSON object
  64993. */
  64994. serialize(): any;
  64995. /**
  64996. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64997. * @param parsedShadowGenerator The JSON object to parse
  64998. * @param scene The scene to create the shadow map for
  64999. * @returns The parsed shadow generator
  65000. */
  65001. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * Defines the shadow generator component responsible to manage any shadow generators
  65007. * in a given scene.
  65008. */
  65009. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  65010. /**
  65011. * The component name helpful to identify the component in the list of scene components.
  65012. */
  65013. readonly name: string;
  65014. /**
  65015. * The scene the component belongs to.
  65016. */
  65017. scene: Scene;
  65018. /**
  65019. * Creates a new instance of the component for the given scene
  65020. * @param scene Defines the scene to register the component in
  65021. */
  65022. constructor(scene: Scene);
  65023. /**
  65024. * Registers the component in a given scene
  65025. */
  65026. register(): void;
  65027. /**
  65028. * Rebuilds the elements related to this component in case of
  65029. * context lost for instance.
  65030. */
  65031. rebuild(): void;
  65032. /**
  65033. * Serializes the component data to the specified json object
  65034. * @param serializationObject The object to serialize to
  65035. */
  65036. serialize(serializationObject: any): void;
  65037. /**
  65038. * Adds all the elements from the container to the scene
  65039. * @param container the container holding the elements
  65040. */
  65041. addFromContainer(container: AbstractScene): void;
  65042. /**
  65043. * Removes all the elements in the container from the scene
  65044. * @param container contains the elements to remove
  65045. * @param dispose if the removed element should be disposed (default: false)
  65046. */
  65047. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65048. /**
  65049. * Rebuilds the elements related to this component in case of
  65050. * context lost for instance.
  65051. */
  65052. dispose(): void;
  65053. private _gatherRenderTargets;
  65054. }
  65055. }
  65056. declare module BABYLON {
  65057. /**
  65058. * A point light is a light defined by an unique point in world space.
  65059. * The light is emitted in every direction from this point.
  65060. * A good example of a point light is a standard light bulb.
  65061. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65062. */
  65063. export class PointLight extends ShadowLight {
  65064. private _shadowAngle;
  65065. /**
  65066. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65067. * This specifies what angle the shadow will use to be created.
  65068. *
  65069. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65070. */
  65071. get shadowAngle(): number;
  65072. /**
  65073. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65074. * This specifies what angle the shadow will use to be created.
  65075. *
  65076. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65077. */
  65078. set shadowAngle(value: number);
  65079. /**
  65080. * Gets the direction if it has been set.
  65081. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65082. */
  65083. get direction(): Vector3;
  65084. /**
  65085. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65086. */
  65087. set direction(value: Vector3);
  65088. /**
  65089. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65090. * A PointLight emits the light in every direction.
  65091. * It can cast shadows.
  65092. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65093. * ```javascript
  65094. * var pointLight = new PointLight("pl", camera.position, scene);
  65095. * ```
  65096. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65097. * @param name The light friendly name
  65098. * @param position The position of the point light in the scene
  65099. * @param scene The scene the lights belongs to
  65100. */
  65101. constructor(name: string, position: Vector3, scene: Scene);
  65102. /**
  65103. * Returns the string "PointLight"
  65104. * @returns the class name
  65105. */
  65106. getClassName(): string;
  65107. /**
  65108. * Returns the integer 0.
  65109. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65110. */
  65111. getTypeID(): number;
  65112. /**
  65113. * Specifies whether or not the shadowmap should be a cube texture.
  65114. * @returns true if the shadowmap needs to be a cube texture.
  65115. */
  65116. needCube(): boolean;
  65117. /**
  65118. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65119. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65120. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65121. */
  65122. getShadowDirection(faceIndex?: number): Vector3;
  65123. /**
  65124. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65125. * - fov = PI / 2
  65126. * - aspect ratio : 1.0
  65127. * - z-near and far equal to the active camera minZ and maxZ.
  65128. * Returns the PointLight.
  65129. */
  65130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65131. protected _buildUniformLayout(): void;
  65132. /**
  65133. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65134. * @param effect The effect to update
  65135. * @param lightIndex The index of the light in the effect to update
  65136. * @returns The point light
  65137. */
  65138. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65139. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65140. /**
  65141. * Prepares the list of defines specific to the light type.
  65142. * @param defines the list of defines
  65143. * @param lightIndex defines the index of the light for the effect
  65144. */
  65145. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65146. }
  65147. }
  65148. declare module BABYLON {
  65149. /**
  65150. * Header information of HDR texture files.
  65151. */
  65152. export interface HDRInfo {
  65153. /**
  65154. * The height of the texture in pixels.
  65155. */
  65156. height: number;
  65157. /**
  65158. * The width of the texture in pixels.
  65159. */
  65160. width: number;
  65161. /**
  65162. * The index of the beginning of the data in the binary file.
  65163. */
  65164. dataPosition: number;
  65165. }
  65166. /**
  65167. * This groups tools to convert HDR texture to native colors array.
  65168. */
  65169. export class HDRTools {
  65170. private static Ldexp;
  65171. private static Rgbe2float;
  65172. private static readStringLine;
  65173. /**
  65174. * Reads header information from an RGBE texture stored in a native array.
  65175. * More information on this format are available here:
  65176. * https://en.wikipedia.org/wiki/RGBE_image_format
  65177. *
  65178. * @param uint8array The binary file stored in native array.
  65179. * @return The header information.
  65180. */
  65181. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65182. /**
  65183. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65184. * This RGBE texture needs to store the information as a panorama.
  65185. *
  65186. * More information on this format are available here:
  65187. * https://en.wikipedia.org/wiki/RGBE_image_format
  65188. *
  65189. * @param buffer The binary file stored in an array buffer.
  65190. * @param size The expected size of the extracted cubemap.
  65191. * @return The Cube Map information.
  65192. */
  65193. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65194. /**
  65195. * Returns the pixels data extracted from an RGBE texture.
  65196. * This pixels will be stored left to right up to down in the R G B order in one array.
  65197. *
  65198. * More information on this format are available here:
  65199. * https://en.wikipedia.org/wiki/RGBE_image_format
  65200. *
  65201. * @param uint8array The binary file stored in an array buffer.
  65202. * @param hdrInfo The header information of the file.
  65203. * @return The pixels data in RGB right to left up to down order.
  65204. */
  65205. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65206. private static RGBE_ReadPixels_RLE;
  65207. private static RGBE_ReadPixels_NOT_RLE;
  65208. }
  65209. }
  65210. declare module BABYLON {
  65211. /**
  65212. * Effect Render Options
  65213. */
  65214. export interface IEffectRendererOptions {
  65215. /**
  65216. * Defines the vertices positions.
  65217. */
  65218. positions?: number[];
  65219. /**
  65220. * Defines the indices.
  65221. */
  65222. indices?: number[];
  65223. }
  65224. /**
  65225. * Helper class to render one or more effects.
  65226. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65227. */
  65228. export class EffectRenderer {
  65229. private engine;
  65230. private static _DefaultOptions;
  65231. private _vertexBuffers;
  65232. private _indexBuffer;
  65233. private _fullscreenViewport;
  65234. /**
  65235. * Creates an effect renderer
  65236. * @param engine the engine to use for rendering
  65237. * @param options defines the options of the effect renderer
  65238. */
  65239. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65240. /**
  65241. * Sets the current viewport in normalized coordinates 0-1
  65242. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65243. */
  65244. setViewport(viewport?: Viewport): void;
  65245. /**
  65246. * Binds the embedded attributes buffer to the effect.
  65247. * @param effect Defines the effect to bind the attributes for
  65248. */
  65249. bindBuffers(effect: Effect): void;
  65250. /**
  65251. * Sets the current effect wrapper to use during draw.
  65252. * The effect needs to be ready before calling this api.
  65253. * This also sets the default full screen position attribute.
  65254. * @param effectWrapper Defines the effect to draw with
  65255. */
  65256. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65257. /**
  65258. * Restores engine states
  65259. */
  65260. restoreStates(): void;
  65261. /**
  65262. * Draws a full screen quad.
  65263. */
  65264. draw(): void;
  65265. private isRenderTargetTexture;
  65266. /**
  65267. * renders one or more effects to a specified texture
  65268. * @param effectWrapper the effect to renderer
  65269. * @param outputTexture texture to draw to, if null it will render to the screen.
  65270. */
  65271. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65272. /**
  65273. * Disposes of the effect renderer
  65274. */
  65275. dispose(): void;
  65276. }
  65277. /**
  65278. * Options to create an EffectWrapper
  65279. */
  65280. interface EffectWrapperCreationOptions {
  65281. /**
  65282. * Engine to use to create the effect
  65283. */
  65284. engine: ThinEngine;
  65285. /**
  65286. * Fragment shader for the effect
  65287. */
  65288. fragmentShader: string;
  65289. /**
  65290. * Use the shader store instead of direct source code
  65291. */
  65292. useShaderStore?: boolean;
  65293. /**
  65294. * Vertex shader for the effect
  65295. */
  65296. vertexShader?: string;
  65297. /**
  65298. * Attributes to use in the shader
  65299. */
  65300. attributeNames?: Array<string>;
  65301. /**
  65302. * Uniforms to use in the shader
  65303. */
  65304. uniformNames?: Array<string>;
  65305. /**
  65306. * Texture sampler names to use in the shader
  65307. */
  65308. samplerNames?: Array<string>;
  65309. /**
  65310. * Defines to use in the shader
  65311. */
  65312. defines?: Array<string>;
  65313. /**
  65314. * Callback when effect is compiled
  65315. */
  65316. onCompiled?: Nullable<(effect: Effect) => void>;
  65317. /**
  65318. * The friendly name of the effect displayed in Spector.
  65319. */
  65320. name?: string;
  65321. }
  65322. /**
  65323. * Wraps an effect to be used for rendering
  65324. */
  65325. export class EffectWrapper {
  65326. /**
  65327. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65328. */
  65329. onApplyObservable: Observable<{}>;
  65330. /**
  65331. * The underlying effect
  65332. */
  65333. effect: Effect;
  65334. /**
  65335. * Creates an effect to be renderer
  65336. * @param creationOptions options to create the effect
  65337. */
  65338. constructor(creationOptions: EffectWrapperCreationOptions);
  65339. /**
  65340. * Disposes of the effect wrapper
  65341. */
  65342. dispose(): void;
  65343. }
  65344. }
  65345. declare module BABYLON {
  65346. /** @hidden */
  65347. export var hdrFilteringVertexShader: {
  65348. name: string;
  65349. shader: string;
  65350. };
  65351. }
  65352. declare module BABYLON {
  65353. /** @hidden */
  65354. export var hdrFilteringPixelShader: {
  65355. name: string;
  65356. shader: string;
  65357. };
  65358. }
  65359. declare module BABYLON {
  65360. /**
  65361. * Options for texture filtering
  65362. */
  65363. interface IHDRFilteringOptions {
  65364. /**
  65365. * Scales pixel intensity for the input HDR map.
  65366. */
  65367. hdrScale?: number;
  65368. /**
  65369. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65370. */
  65371. quality?: number;
  65372. }
  65373. /**
  65374. * Filters HDR maps to get correct renderings of PBR reflections
  65375. */
  65376. export class HDRFiltering {
  65377. private _engine;
  65378. private _effectRenderer;
  65379. private _effectWrapper;
  65380. private _lodGenerationOffset;
  65381. private _lodGenerationScale;
  65382. /**
  65383. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65384. * you care about baking speed.
  65385. */
  65386. quality: number;
  65387. /**
  65388. * Scales pixel intensity for the input HDR map.
  65389. */
  65390. hdrScale: number;
  65391. /**
  65392. * Instantiates HDR filter for reflection maps
  65393. *
  65394. * @param engine Thin engine
  65395. * @param options Options
  65396. */
  65397. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65398. private _createRenderTarget;
  65399. private _prefilterInternal;
  65400. private _createEffect;
  65401. /**
  65402. * Get a value indicating if the filter is ready to be used
  65403. * @param texture Texture to filter
  65404. * @returns true if the filter is ready
  65405. */
  65406. isReady(texture: BaseTexture): boolean;
  65407. /**
  65408. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65409. * Prefiltering will be invoked at the end of next rendering pass.
  65410. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65411. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65412. * @param texture Texture to filter
  65413. * @param onFinished Callback when filtering is done
  65414. * @return Promise called when prefiltering is done
  65415. */
  65416. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65417. }
  65418. }
  65419. declare module BABYLON {
  65420. /**
  65421. * This represents a texture coming from an HDR input.
  65422. *
  65423. * The only supported format is currently panorama picture stored in RGBE format.
  65424. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65425. */
  65426. export class HDRCubeTexture extends BaseTexture {
  65427. private static _facesMapping;
  65428. private _generateHarmonics;
  65429. private _noMipmap;
  65430. private _prefilterOnLoad;
  65431. private _textureMatrix;
  65432. private _size;
  65433. private _onLoad;
  65434. private _onError;
  65435. /**
  65436. * The texture URL.
  65437. */
  65438. url: string;
  65439. protected _isBlocking: boolean;
  65440. /**
  65441. * Sets whether or not the texture is blocking during loading.
  65442. */
  65443. set isBlocking(value: boolean);
  65444. /**
  65445. * Gets whether or not the texture is blocking during loading.
  65446. */
  65447. get isBlocking(): boolean;
  65448. protected _rotationY: number;
  65449. /**
  65450. * Sets texture matrix rotation angle around Y axis in radians.
  65451. */
  65452. set rotationY(value: number);
  65453. /**
  65454. * Gets texture matrix rotation angle around Y axis radians.
  65455. */
  65456. get rotationY(): number;
  65457. /**
  65458. * Gets or sets the center of the bounding box associated with the cube texture
  65459. * It must define where the camera used to render the texture was set
  65460. */
  65461. boundingBoxPosition: Vector3;
  65462. private _boundingBoxSize;
  65463. /**
  65464. * Gets or sets the size of the bounding box associated with the cube texture
  65465. * When defined, the cubemap will switch to local mode
  65466. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65467. * @example https://www.babylonjs-playground.com/#RNASML
  65468. */
  65469. set boundingBoxSize(value: Vector3);
  65470. get boundingBoxSize(): Vector3;
  65471. /**
  65472. * Instantiates an HDRTexture from the following parameters.
  65473. *
  65474. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65475. * @param sceneOrEngine The scene or engine the texture will be used in
  65476. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65477. * @param noMipmap Forces to not generate the mipmap if true
  65478. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65479. * @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)
  65480. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65481. */
  65482. 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>);
  65483. /**
  65484. * Get the current class name of the texture useful for serialization or dynamic coding.
  65485. * @returns "HDRCubeTexture"
  65486. */
  65487. getClassName(): string;
  65488. /**
  65489. * Occurs when the file is raw .hdr file.
  65490. */
  65491. private loadTexture;
  65492. clone(): HDRCubeTexture;
  65493. delayLoad(): void;
  65494. /**
  65495. * Get the texture reflection matrix used to rotate/transform the reflection.
  65496. * @returns the reflection matrix
  65497. */
  65498. getReflectionTextureMatrix(): Matrix;
  65499. /**
  65500. * Set the texture reflection matrix used to rotate/transform the reflection.
  65501. * @param value Define the reflection matrix to set
  65502. */
  65503. setReflectionTextureMatrix(value: Matrix): void;
  65504. /**
  65505. * Parses a JSON representation of an HDR Texture in order to create the texture
  65506. * @param parsedTexture Define the JSON representation
  65507. * @param scene Define the scene the texture should be created in
  65508. * @param rootUrl Define the root url in case we need to load relative dependencies
  65509. * @returns the newly created texture after parsing
  65510. */
  65511. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65512. serialize(): any;
  65513. }
  65514. }
  65515. declare module BABYLON {
  65516. /**
  65517. * Class used to control physics engine
  65518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65519. */
  65520. export class PhysicsEngine implements IPhysicsEngine {
  65521. private _physicsPlugin;
  65522. /**
  65523. * Global value used to control the smallest number supported by the simulation
  65524. */
  65525. static Epsilon: number;
  65526. private _impostors;
  65527. private _joints;
  65528. private _subTimeStep;
  65529. /**
  65530. * Gets the gravity vector used by the simulation
  65531. */
  65532. gravity: Vector3;
  65533. /**
  65534. * Factory used to create the default physics plugin.
  65535. * @returns The default physics plugin
  65536. */
  65537. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65538. /**
  65539. * Creates a new Physics Engine
  65540. * @param gravity defines the gravity vector used by the simulation
  65541. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65542. */
  65543. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65544. /**
  65545. * Sets the gravity vector used by the simulation
  65546. * @param gravity defines the gravity vector to use
  65547. */
  65548. setGravity(gravity: Vector3): void;
  65549. /**
  65550. * Set the time step of the physics engine.
  65551. * Default is 1/60.
  65552. * To slow it down, enter 1/600 for example.
  65553. * To speed it up, 1/30
  65554. * @param newTimeStep defines the new timestep to apply to this world.
  65555. */
  65556. setTimeStep(newTimeStep?: number): void;
  65557. /**
  65558. * Get the time step of the physics engine.
  65559. * @returns the current time step
  65560. */
  65561. getTimeStep(): number;
  65562. /**
  65563. * Set the sub time step of the physics engine.
  65564. * Default is 0 meaning there is no sub steps
  65565. * To increase physics resolution precision, set a small value (like 1 ms)
  65566. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65567. */
  65568. setSubTimeStep(subTimeStep?: number): void;
  65569. /**
  65570. * Get the sub time step of the physics engine.
  65571. * @returns the current sub time step
  65572. */
  65573. getSubTimeStep(): number;
  65574. /**
  65575. * Release all resources
  65576. */
  65577. dispose(): void;
  65578. /**
  65579. * Gets the name of the current physics plugin
  65580. * @returns the name of the plugin
  65581. */
  65582. getPhysicsPluginName(): string;
  65583. /**
  65584. * Adding a new impostor for the impostor tracking.
  65585. * This will be done by the impostor itself.
  65586. * @param impostor the impostor to add
  65587. */
  65588. addImpostor(impostor: PhysicsImpostor): void;
  65589. /**
  65590. * Remove an impostor from the engine.
  65591. * This impostor and its mesh will not longer be updated by the physics engine.
  65592. * @param impostor the impostor to remove
  65593. */
  65594. removeImpostor(impostor: PhysicsImpostor): void;
  65595. /**
  65596. * Add a joint to the physics engine
  65597. * @param mainImpostor defines the main impostor to which the joint is added.
  65598. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65599. * @param joint defines the joint that will connect both impostors.
  65600. */
  65601. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65602. /**
  65603. * Removes a joint from the simulation
  65604. * @param mainImpostor defines the impostor used with the joint
  65605. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65606. * @param joint defines the joint to remove
  65607. */
  65608. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65609. /**
  65610. * Called by the scene. No need to call it.
  65611. * @param delta defines the timespan between frames
  65612. */
  65613. _step(delta: number): void;
  65614. /**
  65615. * Gets the current plugin used to run the simulation
  65616. * @returns current plugin
  65617. */
  65618. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65619. /**
  65620. * Gets the list of physic impostors
  65621. * @returns an array of PhysicsImpostor
  65622. */
  65623. getImpostors(): Array<PhysicsImpostor>;
  65624. /**
  65625. * Gets the impostor for a physics enabled object
  65626. * @param object defines the object impersonated by the impostor
  65627. * @returns the PhysicsImpostor or null if not found
  65628. */
  65629. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65630. /**
  65631. * Gets the impostor for a physics body object
  65632. * @param body defines physics body used by the impostor
  65633. * @returns the PhysicsImpostor or null if not found
  65634. */
  65635. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65636. /**
  65637. * Does a raycast in the physics world
  65638. * @param from when should the ray start?
  65639. * @param to when should the ray end?
  65640. * @returns PhysicsRaycastResult
  65641. */
  65642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65643. }
  65644. }
  65645. declare module BABYLON {
  65646. /** @hidden */
  65647. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65648. private _useDeltaForWorldStep;
  65649. world: any;
  65650. name: string;
  65651. private _physicsMaterials;
  65652. private _fixedTimeStep;
  65653. private _cannonRaycastResult;
  65654. private _raycastResult;
  65655. private _physicsBodysToRemoveAfterStep;
  65656. private _firstFrame;
  65657. BJSCANNON: any;
  65658. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65659. setGravity(gravity: Vector3): void;
  65660. setTimeStep(timeStep: number): void;
  65661. getTimeStep(): number;
  65662. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65663. private _removeMarkedPhysicsBodiesFromWorld;
  65664. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65665. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65666. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65667. private _processChildMeshes;
  65668. removePhysicsBody(impostor: PhysicsImpostor): void;
  65669. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65670. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65671. private _addMaterial;
  65672. private _checkWithEpsilon;
  65673. private _createShape;
  65674. private _createHeightmap;
  65675. private _minus90X;
  65676. private _plus90X;
  65677. private _tmpPosition;
  65678. private _tmpDeltaPosition;
  65679. private _tmpUnityRotation;
  65680. private _updatePhysicsBodyTransformation;
  65681. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65682. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65683. isSupported(): boolean;
  65684. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65685. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65687. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65688. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65689. getBodyMass(impostor: PhysicsImpostor): number;
  65690. getBodyFriction(impostor: PhysicsImpostor): number;
  65691. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65692. getBodyRestitution(impostor: PhysicsImpostor): number;
  65693. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65694. sleepBody(impostor: PhysicsImpostor): void;
  65695. wakeUpBody(impostor: PhysicsImpostor): void;
  65696. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65697. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65698. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65699. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65700. getRadius(impostor: PhysicsImpostor): number;
  65701. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65702. dispose(): void;
  65703. private _extendNamespace;
  65704. /**
  65705. * Does a raycast in the physics world
  65706. * @param from when should the ray start?
  65707. * @param to when should the ray end?
  65708. * @returns PhysicsRaycastResult
  65709. */
  65710. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65711. }
  65712. }
  65713. declare module BABYLON {
  65714. /** @hidden */
  65715. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65716. private _useDeltaForWorldStep;
  65717. world: any;
  65718. name: string;
  65719. BJSOIMO: any;
  65720. private _raycastResult;
  65721. private _fixedTimeStep;
  65722. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65723. setGravity(gravity: Vector3): void;
  65724. setTimeStep(timeStep: number): void;
  65725. getTimeStep(): number;
  65726. private _tmpImpostorsArray;
  65727. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65728. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65729. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65730. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65731. private _tmpPositionVector;
  65732. removePhysicsBody(impostor: PhysicsImpostor): void;
  65733. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65734. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65735. isSupported(): boolean;
  65736. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65737. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65738. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65739. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65740. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65741. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65742. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65743. getBodyMass(impostor: PhysicsImpostor): number;
  65744. getBodyFriction(impostor: PhysicsImpostor): number;
  65745. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65746. getBodyRestitution(impostor: PhysicsImpostor): number;
  65747. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65748. sleepBody(impostor: PhysicsImpostor): void;
  65749. wakeUpBody(impostor: PhysicsImpostor): void;
  65750. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65751. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65752. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65753. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65754. getRadius(impostor: PhysicsImpostor): number;
  65755. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65756. dispose(): void;
  65757. /**
  65758. * Does a raycast in the physics world
  65759. * @param from when should the ray start?
  65760. * @param to when should the ray end?
  65761. * @returns PhysicsRaycastResult
  65762. */
  65763. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * AmmoJS Physics plugin
  65769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65770. * @see https://github.com/kripken/ammo.js/
  65771. */
  65772. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65773. private _useDeltaForWorldStep;
  65774. /**
  65775. * Reference to the Ammo library
  65776. */
  65777. bjsAMMO: any;
  65778. /**
  65779. * Created ammoJS world which physics bodies are added to
  65780. */
  65781. world: any;
  65782. /**
  65783. * Name of the plugin
  65784. */
  65785. name: string;
  65786. private _timeStep;
  65787. private _fixedTimeStep;
  65788. private _maxSteps;
  65789. private _tmpQuaternion;
  65790. private _tmpAmmoTransform;
  65791. private _tmpAmmoQuaternion;
  65792. private _tmpAmmoConcreteContactResultCallback;
  65793. private _collisionConfiguration;
  65794. private _dispatcher;
  65795. private _overlappingPairCache;
  65796. private _solver;
  65797. private _softBodySolver;
  65798. private _tmpAmmoVectorA;
  65799. private _tmpAmmoVectorB;
  65800. private _tmpAmmoVectorC;
  65801. private _tmpAmmoVectorD;
  65802. private _tmpContactCallbackResult;
  65803. private _tmpAmmoVectorRCA;
  65804. private _tmpAmmoVectorRCB;
  65805. private _raycastResult;
  65806. private _tmpContactPoint;
  65807. private static readonly DISABLE_COLLISION_FLAG;
  65808. private static readonly KINEMATIC_FLAG;
  65809. private static readonly DISABLE_DEACTIVATION_FLAG;
  65810. /**
  65811. * Initializes the ammoJS plugin
  65812. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65813. * @param ammoInjection can be used to inject your own ammo reference
  65814. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65815. */
  65816. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65817. /**
  65818. * Sets the gravity of the physics world (m/(s^2))
  65819. * @param gravity Gravity to set
  65820. */
  65821. setGravity(gravity: Vector3): void;
  65822. /**
  65823. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65824. * @param timeStep timestep to use in seconds
  65825. */
  65826. setTimeStep(timeStep: number): void;
  65827. /**
  65828. * 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)
  65829. * @param fixedTimeStep fixedTimeStep to use in seconds
  65830. */
  65831. setFixedTimeStep(fixedTimeStep: number): void;
  65832. /**
  65833. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65834. * @param maxSteps the maximum number of steps by the physics engine per frame
  65835. */
  65836. setMaxSteps(maxSteps: number): void;
  65837. /**
  65838. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65839. * @returns the current timestep in seconds
  65840. */
  65841. getTimeStep(): number;
  65842. /**
  65843. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65844. */
  65845. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65846. private _isImpostorInContact;
  65847. private _isImpostorPairInContact;
  65848. private _stepSimulation;
  65849. /**
  65850. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65851. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65852. * After the step the babylon meshes are set to the position of the physics imposters
  65853. * @param delta amount of time to step forward
  65854. * @param impostors array of imposters to update before/after the step
  65855. */
  65856. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65857. /**
  65858. * Update babylon mesh to match physics world object
  65859. * @param impostor imposter to match
  65860. */
  65861. private _afterSoftStep;
  65862. /**
  65863. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65864. * @param impostor imposter to match
  65865. */
  65866. private _ropeStep;
  65867. /**
  65868. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65869. * @param impostor imposter to match
  65870. */
  65871. private _softbodyOrClothStep;
  65872. private _tmpMatrix;
  65873. /**
  65874. * Applies an impulse on the imposter
  65875. * @param impostor imposter to apply impulse to
  65876. * @param force amount of force to be applied to the imposter
  65877. * @param contactPoint the location to apply the impulse on the imposter
  65878. */
  65879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65880. /**
  65881. * Applies a force on the imposter
  65882. * @param impostor imposter to apply force
  65883. * @param force amount of force to be applied to the imposter
  65884. * @param contactPoint the location to apply the force on the imposter
  65885. */
  65886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65887. /**
  65888. * Creates a physics body using the plugin
  65889. * @param impostor the imposter to create the physics body on
  65890. */
  65891. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65892. /**
  65893. * Removes the physics body from the imposter and disposes of the body's memory
  65894. * @param impostor imposter to remove the physics body from
  65895. */
  65896. removePhysicsBody(impostor: PhysicsImpostor): void;
  65897. /**
  65898. * Generates a joint
  65899. * @param impostorJoint the imposter joint to create the joint with
  65900. */
  65901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65902. /**
  65903. * Removes a joint
  65904. * @param impostorJoint the imposter joint to remove the joint from
  65905. */
  65906. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65907. private _addMeshVerts;
  65908. /**
  65909. * Initialise the soft body vertices to match its object's (mesh) vertices
  65910. * Softbody vertices (nodes) are in world space and to match this
  65911. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65912. * @param impostor to create the softbody for
  65913. */
  65914. private _softVertexData;
  65915. /**
  65916. * Create an impostor's soft body
  65917. * @param impostor to create the softbody for
  65918. */
  65919. private _createSoftbody;
  65920. /**
  65921. * Create cloth for an impostor
  65922. * @param impostor to create the softbody for
  65923. */
  65924. private _createCloth;
  65925. /**
  65926. * Create rope for an impostor
  65927. * @param impostor to create the softbody for
  65928. */
  65929. private _createRope;
  65930. /**
  65931. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65932. * @param impostor to create the custom physics shape for
  65933. */
  65934. private _createCustom;
  65935. private _addHullVerts;
  65936. private _createShape;
  65937. /**
  65938. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65939. * @param impostor imposter containing the physics body and babylon object
  65940. */
  65941. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65942. /**
  65943. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65944. * @param impostor imposter containing the physics body and babylon object
  65945. * @param newPosition new position
  65946. * @param newRotation new rotation
  65947. */
  65948. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65949. /**
  65950. * If this plugin is supported
  65951. * @returns true if its supported
  65952. */
  65953. isSupported(): boolean;
  65954. /**
  65955. * Sets the linear velocity of the physics body
  65956. * @param impostor imposter to set the velocity on
  65957. * @param velocity velocity to set
  65958. */
  65959. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65960. /**
  65961. * Sets the angular velocity of the physics body
  65962. * @param impostor imposter to set the velocity on
  65963. * @param velocity velocity to set
  65964. */
  65965. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65966. /**
  65967. * gets the linear velocity
  65968. * @param impostor imposter to get linear velocity from
  65969. * @returns linear velocity
  65970. */
  65971. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65972. /**
  65973. * gets the angular velocity
  65974. * @param impostor imposter to get angular velocity from
  65975. * @returns angular velocity
  65976. */
  65977. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65978. /**
  65979. * Sets the mass of physics body
  65980. * @param impostor imposter to set the mass on
  65981. * @param mass mass to set
  65982. */
  65983. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65984. /**
  65985. * Gets the mass of the physics body
  65986. * @param impostor imposter to get the mass from
  65987. * @returns mass
  65988. */
  65989. getBodyMass(impostor: PhysicsImpostor): number;
  65990. /**
  65991. * Gets friction of the impostor
  65992. * @param impostor impostor to get friction from
  65993. * @returns friction value
  65994. */
  65995. getBodyFriction(impostor: PhysicsImpostor): number;
  65996. /**
  65997. * Sets friction of the impostor
  65998. * @param impostor impostor to set friction on
  65999. * @param friction friction value
  66000. */
  66001. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  66002. /**
  66003. * Gets restitution of the impostor
  66004. * @param impostor impostor to get restitution from
  66005. * @returns restitution value
  66006. */
  66007. getBodyRestitution(impostor: PhysicsImpostor): number;
  66008. /**
  66009. * Sets restitution of the impostor
  66010. * @param impostor impostor to set resitution on
  66011. * @param restitution resitution value
  66012. */
  66013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  66014. /**
  66015. * Gets pressure inside the impostor
  66016. * @param impostor impostor to get pressure from
  66017. * @returns pressure value
  66018. */
  66019. getBodyPressure(impostor: PhysicsImpostor): number;
  66020. /**
  66021. * Sets pressure inside a soft body impostor
  66022. * Cloth and rope must remain 0 pressure
  66023. * @param impostor impostor to set pressure on
  66024. * @param pressure pressure value
  66025. */
  66026. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66027. /**
  66028. * Gets stiffness of the impostor
  66029. * @param impostor impostor to get stiffness from
  66030. * @returns pressure value
  66031. */
  66032. getBodyStiffness(impostor: PhysicsImpostor): number;
  66033. /**
  66034. * Sets stiffness of the impostor
  66035. * @param impostor impostor to set stiffness on
  66036. * @param stiffness stiffness value from 0 to 1
  66037. */
  66038. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66039. /**
  66040. * Gets velocityIterations of the impostor
  66041. * @param impostor impostor to get velocity iterations from
  66042. * @returns velocityIterations value
  66043. */
  66044. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66045. /**
  66046. * Sets velocityIterations of the impostor
  66047. * @param impostor impostor to set velocity iterations on
  66048. * @param velocityIterations velocityIterations value
  66049. */
  66050. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66051. /**
  66052. * Gets positionIterations of the impostor
  66053. * @param impostor impostor to get position iterations from
  66054. * @returns positionIterations value
  66055. */
  66056. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66057. /**
  66058. * Sets positionIterations of the impostor
  66059. * @param impostor impostor to set position on
  66060. * @param positionIterations positionIterations value
  66061. */
  66062. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66063. /**
  66064. * Append an anchor to a cloth object
  66065. * @param impostor is the cloth impostor to add anchor to
  66066. * @param otherImpostor is the rigid impostor to anchor to
  66067. * @param width ratio across width from 0 to 1
  66068. * @param height ratio up height from 0 to 1
  66069. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66070. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66071. */
  66072. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66073. /**
  66074. * Append an hook to a rope object
  66075. * @param impostor is the rope impostor to add hook to
  66076. * @param otherImpostor is the rigid impostor to hook to
  66077. * @param length ratio along the rope from 0 to 1
  66078. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66080. */
  66081. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66082. /**
  66083. * Sleeps the physics body and stops it from being active
  66084. * @param impostor impostor to sleep
  66085. */
  66086. sleepBody(impostor: PhysicsImpostor): void;
  66087. /**
  66088. * Activates the physics body
  66089. * @param impostor impostor to activate
  66090. */
  66091. wakeUpBody(impostor: PhysicsImpostor): void;
  66092. /**
  66093. * Updates the distance parameters of the joint
  66094. * @param joint joint to update
  66095. * @param maxDistance maximum distance of the joint
  66096. * @param minDistance minimum distance of the joint
  66097. */
  66098. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66099. /**
  66100. * Sets a motor on the joint
  66101. * @param joint joint to set motor on
  66102. * @param speed speed of the motor
  66103. * @param maxForce maximum force of the motor
  66104. * @param motorIndex index of the motor
  66105. */
  66106. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66107. /**
  66108. * Sets the motors limit
  66109. * @param joint joint to set limit on
  66110. * @param upperLimit upper limit
  66111. * @param lowerLimit lower limit
  66112. */
  66113. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66114. /**
  66115. * Syncs the position and rotation of a mesh with the impostor
  66116. * @param mesh mesh to sync
  66117. * @param impostor impostor to update the mesh with
  66118. */
  66119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66120. /**
  66121. * Gets the radius of the impostor
  66122. * @param impostor impostor to get radius from
  66123. * @returns the radius
  66124. */
  66125. getRadius(impostor: PhysicsImpostor): number;
  66126. /**
  66127. * Gets the box size of the impostor
  66128. * @param impostor impostor to get box size from
  66129. * @param result the resulting box size
  66130. */
  66131. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66132. /**
  66133. * Disposes of the impostor
  66134. */
  66135. dispose(): void;
  66136. /**
  66137. * Does a raycast in the physics world
  66138. * @param from when should the ray start?
  66139. * @param to when should the ray end?
  66140. * @returns PhysicsRaycastResult
  66141. */
  66142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66143. }
  66144. }
  66145. declare module BABYLON {
  66146. interface AbstractScene {
  66147. /**
  66148. * The list of reflection probes added to the scene
  66149. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66150. */
  66151. reflectionProbes: Array<ReflectionProbe>;
  66152. /**
  66153. * Removes the given reflection probe from this scene.
  66154. * @param toRemove The reflection probe to remove
  66155. * @returns The index of the removed reflection probe
  66156. */
  66157. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66158. /**
  66159. * Adds the given reflection probe to this scene.
  66160. * @param newReflectionProbe The reflection probe to add
  66161. */
  66162. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66163. }
  66164. /**
  66165. * Class used to generate realtime reflection / refraction cube textures
  66166. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66167. */
  66168. export class ReflectionProbe {
  66169. /** defines the name of the probe */
  66170. name: string;
  66171. private _scene;
  66172. private _renderTargetTexture;
  66173. private _projectionMatrix;
  66174. private _viewMatrix;
  66175. private _target;
  66176. private _add;
  66177. private _attachedMesh;
  66178. private _invertYAxis;
  66179. /** Gets or sets probe position (center of the cube map) */
  66180. position: Vector3;
  66181. /**
  66182. * Creates a new reflection probe
  66183. * @param name defines the name of the probe
  66184. * @param size defines the texture resolution (for each face)
  66185. * @param scene defines the hosting scene
  66186. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66187. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66188. * @param linearSpace defines if the probe should be generated in linear space or not (false by default)
  66189. */
  66190. constructor(
  66191. /** defines the name of the probe */
  66192. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean, linearSpace?: boolean);
  66193. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66194. get samples(): number;
  66195. set samples(value: number);
  66196. /** Gets or sets the refresh rate to use (on every frame by default) */
  66197. get refreshRate(): number;
  66198. set refreshRate(value: number);
  66199. /**
  66200. * Gets the hosting scene
  66201. * @returns a Scene
  66202. */
  66203. getScene(): Scene;
  66204. /** Gets the internal CubeTexture used to render to */
  66205. get cubeTexture(): RenderTargetTexture;
  66206. /** Gets the list of meshes to render */
  66207. get renderList(): Nullable<AbstractMesh[]>;
  66208. /**
  66209. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66210. * @param mesh defines the mesh to attach to
  66211. */
  66212. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66213. /**
  66214. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66215. * @param renderingGroupId The rendering group id corresponding to its index
  66216. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66217. */
  66218. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66219. /**
  66220. * Clean all associated resources
  66221. */
  66222. dispose(): void;
  66223. /**
  66224. * Converts the reflection probe information to a readable string for debug purpose.
  66225. * @param fullDetails Supports for multiple levels of logging within scene loading
  66226. * @returns the human readable reflection probe info
  66227. */
  66228. toString(fullDetails?: boolean): string;
  66229. /**
  66230. * Get the class name of the refection probe.
  66231. * @returns "ReflectionProbe"
  66232. */
  66233. getClassName(): string;
  66234. /**
  66235. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66236. * @returns The JSON representation of the texture
  66237. */
  66238. serialize(): any;
  66239. /**
  66240. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66241. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66242. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66243. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66244. * @returns The parsed reflection probe if successful
  66245. */
  66246. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66247. }
  66248. }
  66249. declare module BABYLON {
  66250. /** @hidden */
  66251. export var _BabylonLoaderRegistered: boolean;
  66252. /**
  66253. * Helps setting up some configuration for the babylon file loader.
  66254. */
  66255. export class BabylonFileLoaderConfiguration {
  66256. /**
  66257. * The loader does not allow injecting custom physics engine into the plugins.
  66258. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66259. * So you could set this variable to your engine import to make it work.
  66260. */
  66261. static LoaderInjectedPhysicsEngine: any;
  66262. }
  66263. }
  66264. declare module BABYLON {
  66265. /**
  66266. * A material to use for fast depth-only rendering.
  66267. */
  66268. export class OcclusionMaterial extends ShaderMaterial {
  66269. constructor(name: string, scene: Scene);
  66270. }
  66271. }
  66272. declare module BABYLON {
  66273. /**
  66274. * The Physically based simple base material of BJS.
  66275. *
  66276. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66277. * It is used as the base class for both the specGloss and metalRough conventions.
  66278. */
  66279. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66280. /**
  66281. * Number of Simultaneous lights allowed on the material.
  66282. */
  66283. maxSimultaneousLights: number;
  66284. /**
  66285. * If sets to true, disables all the lights affecting the material.
  66286. */
  66287. disableLighting: boolean;
  66288. /**
  66289. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66290. */
  66291. environmentTexture: BaseTexture;
  66292. /**
  66293. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66294. */
  66295. invertNormalMapX: boolean;
  66296. /**
  66297. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66298. */
  66299. invertNormalMapY: boolean;
  66300. /**
  66301. * Normal map used in the model.
  66302. */
  66303. normalTexture: BaseTexture;
  66304. /**
  66305. * Emissivie color used to self-illuminate the model.
  66306. */
  66307. emissiveColor: Color3;
  66308. /**
  66309. * Emissivie texture used to self-illuminate the model.
  66310. */
  66311. emissiveTexture: BaseTexture;
  66312. /**
  66313. * Occlusion Channel Strength.
  66314. */
  66315. occlusionStrength: number;
  66316. /**
  66317. * Occlusion Texture of the material (adding extra occlusion effects).
  66318. */
  66319. occlusionTexture: BaseTexture;
  66320. /**
  66321. * Defines the alpha limits in alpha test mode.
  66322. */
  66323. alphaCutOff: number;
  66324. /**
  66325. * Gets the current double sided mode.
  66326. */
  66327. get doubleSided(): boolean;
  66328. /**
  66329. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66330. */
  66331. set doubleSided(value: boolean);
  66332. /**
  66333. * Stores the pre-calculated light information of a mesh in a texture.
  66334. */
  66335. lightmapTexture: BaseTexture;
  66336. /**
  66337. * If true, the light map contains occlusion information instead of lighting info.
  66338. */
  66339. useLightmapAsShadowmap: boolean;
  66340. /**
  66341. * Instantiates a new PBRMaterial instance.
  66342. *
  66343. * @param name The material name
  66344. * @param scene The scene the material will be use in.
  66345. */
  66346. constructor(name: string, scene: Scene);
  66347. getClassName(): string;
  66348. }
  66349. }
  66350. declare module BABYLON {
  66351. /**
  66352. * The PBR material of BJS following the metal roughness convention.
  66353. *
  66354. * This fits to the PBR convention in the GLTF definition:
  66355. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66356. */
  66357. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66358. /**
  66359. * The base color has two different interpretations depending on the value of metalness.
  66360. * When the material is a metal, the base color is the specific measured reflectance value
  66361. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66362. * of the material.
  66363. */
  66364. baseColor: Color3;
  66365. /**
  66366. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66367. * well as opacity information in the alpha channel.
  66368. */
  66369. baseTexture: BaseTexture;
  66370. /**
  66371. * Specifies the metallic scalar value of the material.
  66372. * Can also be used to scale the metalness values of the metallic texture.
  66373. */
  66374. metallic: number;
  66375. /**
  66376. * Specifies the roughness scalar value of the material.
  66377. * Can also be used to scale the roughness values of the metallic texture.
  66378. */
  66379. roughness: number;
  66380. /**
  66381. * Texture containing both the metallic value in the B channel and the
  66382. * roughness value in the G channel to keep better precision.
  66383. */
  66384. metallicRoughnessTexture: BaseTexture;
  66385. /**
  66386. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66387. *
  66388. * @param name The material name
  66389. * @param scene The scene the material will be use in.
  66390. */
  66391. constructor(name: string, scene: Scene);
  66392. /**
  66393. * Return the current class name of the material.
  66394. */
  66395. getClassName(): string;
  66396. /**
  66397. * Makes a duplicate of the current material.
  66398. * @param name - name to use for the new material.
  66399. */
  66400. clone(name: string): PBRMetallicRoughnessMaterial;
  66401. /**
  66402. * Serialize the material to a parsable JSON object.
  66403. */
  66404. serialize(): any;
  66405. /**
  66406. * Parses a JSON object corresponding to the serialize function.
  66407. */
  66408. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66409. }
  66410. }
  66411. declare module BABYLON {
  66412. /**
  66413. * The PBR material of BJS following the specular glossiness convention.
  66414. *
  66415. * This fits to the PBR convention in the GLTF definition:
  66416. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66417. */
  66418. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66419. /**
  66420. * Specifies the diffuse color of the material.
  66421. */
  66422. diffuseColor: Color3;
  66423. /**
  66424. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66425. * channel.
  66426. */
  66427. diffuseTexture: BaseTexture;
  66428. /**
  66429. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66430. */
  66431. specularColor: Color3;
  66432. /**
  66433. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66434. */
  66435. glossiness: number;
  66436. /**
  66437. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66438. */
  66439. specularGlossinessTexture: BaseTexture;
  66440. /**
  66441. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66442. */
  66443. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66444. /**
  66445. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66446. *
  66447. * @param name The material name
  66448. * @param scene The scene the material will be use in.
  66449. */
  66450. constructor(name: string, scene: Scene);
  66451. /**
  66452. * Return the current class name of the material.
  66453. */
  66454. getClassName(): string;
  66455. /**
  66456. * Makes a duplicate of the current material.
  66457. * @param name - name to use for the new material.
  66458. */
  66459. clone(name: string): PBRSpecularGlossinessMaterial;
  66460. /**
  66461. * Serialize the material to a parsable JSON object.
  66462. */
  66463. serialize(): any;
  66464. /**
  66465. * Parses a JSON object corresponding to the serialize function.
  66466. */
  66467. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66468. }
  66469. }
  66470. declare module BABYLON {
  66471. /**
  66472. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66473. * It can help converting any input color in a desired output one. This can then be used to create effects
  66474. * from sepia, black and white to sixties or futuristic rendering...
  66475. *
  66476. * The only supported format is currently 3dl.
  66477. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66478. */
  66479. export class ColorGradingTexture extends BaseTexture {
  66480. /**
  66481. * The texture URL.
  66482. */
  66483. url: string;
  66484. /**
  66485. * Empty line regex stored for GC.
  66486. */
  66487. private static _noneEmptyLineRegex;
  66488. private _textureMatrix;
  66489. private _onLoad;
  66490. /**
  66491. * Instantiates a ColorGradingTexture from the following parameters.
  66492. *
  66493. * @param url The location of the color grading data (currently only supporting 3dl)
  66494. * @param sceneOrEngine The scene or engine the texture will be used in
  66495. * @param onLoad defines a callback triggered when the texture has been loaded
  66496. */
  66497. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66498. /**
  66499. * Fires the onload event from the constructor if requested.
  66500. */
  66501. private _triggerOnLoad;
  66502. /**
  66503. * Returns the texture matrix used in most of the material.
  66504. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66505. */
  66506. getTextureMatrix(): Matrix;
  66507. /**
  66508. * Occurs when the file being loaded is a .3dl LUT file.
  66509. */
  66510. private load3dlTexture;
  66511. /**
  66512. * Starts the loading process of the texture.
  66513. */
  66514. private loadTexture;
  66515. /**
  66516. * Clones the color grading texture.
  66517. */
  66518. clone(): ColorGradingTexture;
  66519. /**
  66520. * Called during delayed load for textures.
  66521. */
  66522. delayLoad(): void;
  66523. /**
  66524. * Parses a color grading texture serialized by Babylon.
  66525. * @param parsedTexture The texture information being parsedTexture
  66526. * @param scene The scene to load the texture in
  66527. * @param rootUrl The root url of the data assets to load
  66528. * @return A color grading texture
  66529. */
  66530. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66531. /**
  66532. * Serializes the LUT texture to json format.
  66533. */
  66534. serialize(): any;
  66535. }
  66536. }
  66537. declare module BABYLON {
  66538. /**
  66539. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66540. */
  66541. export class EquiRectangularCubeTexture extends BaseTexture {
  66542. /** The six faces of the cube. */
  66543. private static _FacesMapping;
  66544. private _noMipmap;
  66545. private _onLoad;
  66546. private _onError;
  66547. /** The size of the cubemap. */
  66548. private _size;
  66549. /** The buffer of the image. */
  66550. private _buffer;
  66551. /** The width of the input image. */
  66552. private _width;
  66553. /** The height of the input image. */
  66554. private _height;
  66555. /** The URL to the image. */
  66556. url: string;
  66557. /**
  66558. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66559. * @param url The location of the image
  66560. * @param scene The scene the texture will be used in
  66561. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66562. * @param noMipmap Forces to not generate the mipmap if true
  66563. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66564. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66565. * @param onLoad — defines a callback called when texture is loaded
  66566. * @param onError — defines a callback called if there is an error
  66567. */
  66568. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66569. /**
  66570. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66571. */
  66572. private loadImage;
  66573. /**
  66574. * Convert the image buffer into a cubemap and create a CubeTexture.
  66575. */
  66576. private loadTexture;
  66577. /**
  66578. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66579. * @param buffer The ArrayBuffer that should be converted.
  66580. * @returns The buffer as Float32Array.
  66581. */
  66582. private getFloat32ArrayFromArrayBuffer;
  66583. /**
  66584. * Get the current class name of the texture useful for serialization or dynamic coding.
  66585. * @returns "EquiRectangularCubeTexture"
  66586. */
  66587. getClassName(): string;
  66588. /**
  66589. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66590. * @returns A clone of the current EquiRectangularCubeTexture.
  66591. */
  66592. clone(): EquiRectangularCubeTexture;
  66593. }
  66594. }
  66595. declare module BABYLON {
  66596. /**
  66597. * Defines the options related to the creation of an HtmlElementTexture
  66598. */
  66599. export interface IHtmlElementTextureOptions {
  66600. /**
  66601. * Defines whether mip maps should be created or not.
  66602. */
  66603. generateMipMaps?: boolean;
  66604. /**
  66605. * Defines the sampling mode of the texture.
  66606. */
  66607. samplingMode?: number;
  66608. /**
  66609. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66610. */
  66611. engine: Nullable<ThinEngine>;
  66612. /**
  66613. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66614. */
  66615. scene: Nullable<Scene>;
  66616. }
  66617. /**
  66618. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66619. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66620. * is automatically managed.
  66621. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66622. * in your application.
  66623. *
  66624. * As the update is not automatic, you need to call them manually.
  66625. */
  66626. export class HtmlElementTexture extends BaseTexture {
  66627. /**
  66628. * The texture URL.
  66629. */
  66630. element: HTMLVideoElement | HTMLCanvasElement;
  66631. private static readonly DefaultOptions;
  66632. private _textureMatrix;
  66633. private _isVideo;
  66634. private _generateMipMaps;
  66635. private _samplingMode;
  66636. /**
  66637. * Instantiates a HtmlElementTexture from the following parameters.
  66638. *
  66639. * @param name Defines the name of the texture
  66640. * @param element Defines the video or canvas the texture is filled with
  66641. * @param options Defines the other none mandatory texture creation options
  66642. */
  66643. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66644. private _createInternalTexture;
  66645. /**
  66646. * Returns the texture matrix used in most of the material.
  66647. */
  66648. getTextureMatrix(): Matrix;
  66649. /**
  66650. * Updates the content of the texture.
  66651. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66652. */
  66653. update(invertY?: Nullable<boolean>): void;
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. /**
  66658. * Based on jsTGALoader - Javascript loader for TGA file
  66659. * By Vincent Thibault
  66660. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66661. */
  66662. export class TGATools {
  66663. private static _TYPE_INDEXED;
  66664. private static _TYPE_RGB;
  66665. private static _TYPE_GREY;
  66666. private static _TYPE_RLE_INDEXED;
  66667. private static _TYPE_RLE_RGB;
  66668. private static _TYPE_RLE_GREY;
  66669. private static _ORIGIN_MASK;
  66670. private static _ORIGIN_SHIFT;
  66671. private static _ORIGIN_BL;
  66672. private static _ORIGIN_BR;
  66673. private static _ORIGIN_UL;
  66674. private static _ORIGIN_UR;
  66675. /**
  66676. * Gets the header of a TGA file
  66677. * @param data defines the TGA data
  66678. * @returns the header
  66679. */
  66680. static GetTGAHeader(data: Uint8Array): any;
  66681. /**
  66682. * Uploads TGA content to a Babylon Texture
  66683. * @hidden
  66684. */
  66685. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66686. /** @hidden */
  66687. 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;
  66688. /** @hidden */
  66689. 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;
  66690. /** @hidden */
  66691. 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;
  66692. /** @hidden */
  66693. 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;
  66694. /** @hidden */
  66695. 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;
  66696. /** @hidden */
  66697. 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;
  66698. }
  66699. }
  66700. declare module BABYLON {
  66701. /**
  66702. * Implementation of the TGA Texture Loader.
  66703. * @hidden
  66704. */
  66705. export class _TGATextureLoader implements IInternalTextureLoader {
  66706. /**
  66707. * Defines whether the loader supports cascade loading the different faces.
  66708. */
  66709. readonly supportCascades: boolean;
  66710. /**
  66711. * This returns if the loader support the current file information.
  66712. * @param extension defines the file extension of the file being loaded
  66713. * @returns true if the loader can load the specified file
  66714. */
  66715. canLoad(extension: string): boolean;
  66716. /**
  66717. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66718. * @param data contains the texture data
  66719. * @param texture defines the BabylonJS internal texture
  66720. * @param createPolynomials will be true if polynomials have been requested
  66721. * @param onLoad defines the callback to trigger once the texture is ready
  66722. * @param onError defines the callback to trigger in case of error
  66723. */
  66724. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66725. /**
  66726. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66727. * @param data contains the texture data
  66728. * @param texture defines the BabylonJS internal texture
  66729. * @param callback defines the method to call once ready to upload
  66730. */
  66731. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66732. }
  66733. }
  66734. declare module BABYLON {
  66735. /**
  66736. * Implementation of the HDR Texture Loader.
  66737. * @hidden
  66738. */
  66739. export class _HDRTextureLoader implements IInternalTextureLoader {
  66740. /**
  66741. * Defines whether the loader supports cascade loading the different faces.
  66742. */
  66743. readonly supportCascades: boolean;
  66744. /**
  66745. * This returns if the loader support the current file information.
  66746. * @param extension defines the file extension of the file being loaded
  66747. * @returns true if the loader can load the specified file
  66748. */
  66749. canLoad(extension: string): boolean;
  66750. /**
  66751. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66752. * @param data contains the texture data
  66753. * @param texture defines the BabylonJS internal texture
  66754. * @param createPolynomials will be true if polynomials have been requested
  66755. * @param onLoad defines the callback to trigger once the texture is ready
  66756. * @param onError defines the callback to trigger in case of error
  66757. */
  66758. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66759. /**
  66760. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66761. * @param data contains the texture data
  66762. * @param texture defines the BabylonJS internal texture
  66763. * @param callback defines the method to call once ready to upload
  66764. */
  66765. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66766. }
  66767. }
  66768. declare module BABYLON {
  66769. /**
  66770. * Info about the .basis files
  66771. */
  66772. class BasisFileInfo {
  66773. /**
  66774. * If the file has alpha
  66775. */
  66776. hasAlpha: boolean;
  66777. /**
  66778. * Info about each image of the basis file
  66779. */
  66780. images: Array<{
  66781. levels: Array<{
  66782. width: number;
  66783. height: number;
  66784. transcodedPixels: ArrayBufferView;
  66785. }>;
  66786. }>;
  66787. }
  66788. /**
  66789. * Result of transcoding a basis file
  66790. */
  66791. class TranscodeResult {
  66792. /**
  66793. * Info about the .basis file
  66794. */
  66795. fileInfo: BasisFileInfo;
  66796. /**
  66797. * Format to use when loading the file
  66798. */
  66799. format: number;
  66800. }
  66801. /**
  66802. * Configuration options for the Basis transcoder
  66803. */
  66804. export class BasisTranscodeConfiguration {
  66805. /**
  66806. * Supported compression formats used to determine the supported output format of the transcoder
  66807. */
  66808. supportedCompressionFormats?: {
  66809. /**
  66810. * etc1 compression format
  66811. */
  66812. etc1?: boolean;
  66813. /**
  66814. * s3tc compression format
  66815. */
  66816. s3tc?: boolean;
  66817. /**
  66818. * pvrtc compression format
  66819. */
  66820. pvrtc?: boolean;
  66821. /**
  66822. * etc2 compression format
  66823. */
  66824. etc2?: boolean;
  66825. };
  66826. /**
  66827. * If mipmap levels should be loaded for transcoded images (Default: true)
  66828. */
  66829. loadMipmapLevels?: boolean;
  66830. /**
  66831. * Index of a single image to load (Default: all images)
  66832. */
  66833. loadSingleImage?: number;
  66834. }
  66835. /**
  66836. * Used to load .Basis files
  66837. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66838. */
  66839. export class BasisTools {
  66840. private static _IgnoreSupportedFormats;
  66841. /**
  66842. * URL to use when loading the basis transcoder
  66843. */
  66844. static JSModuleURL: string;
  66845. /**
  66846. * URL to use when loading the wasm module for the transcoder
  66847. */
  66848. static WasmModuleURL: string;
  66849. /**
  66850. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66851. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66852. * @returns internal format corresponding to the Basis format
  66853. */
  66854. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66855. private static _WorkerPromise;
  66856. private static _Worker;
  66857. private static _actionId;
  66858. private static _CreateWorkerAsync;
  66859. /**
  66860. * Transcodes a loaded image file to compressed pixel data
  66861. * @param data image data to transcode
  66862. * @param config configuration options for the transcoding
  66863. * @returns a promise resulting in the transcoded image
  66864. */
  66865. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66866. /**
  66867. * Loads a texture from the transcode result
  66868. * @param texture texture load to
  66869. * @param transcodeResult the result of transcoding the basis file to load from
  66870. */
  66871. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66872. }
  66873. }
  66874. declare module BABYLON {
  66875. /**
  66876. * Loader for .basis file format
  66877. */
  66878. export class _BasisTextureLoader implements IInternalTextureLoader {
  66879. /**
  66880. * Defines whether the loader supports cascade loading the different faces.
  66881. */
  66882. readonly supportCascades: boolean;
  66883. /**
  66884. * This returns if the loader support the current file information.
  66885. * @param extension defines the file extension of the file being loaded
  66886. * @returns true if the loader can load the specified file
  66887. */
  66888. canLoad(extension: string): boolean;
  66889. /**
  66890. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66891. * @param data contains the texture data
  66892. * @param texture defines the BabylonJS internal texture
  66893. * @param createPolynomials will be true if polynomials have been requested
  66894. * @param onLoad defines the callback to trigger once the texture is ready
  66895. * @param onError defines the callback to trigger in case of error
  66896. */
  66897. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66898. /**
  66899. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66900. * @param data contains the texture data
  66901. * @param texture defines the BabylonJS internal texture
  66902. * @param callback defines the method to call once ready to upload
  66903. */
  66904. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66905. }
  66906. }
  66907. declare module BABYLON {
  66908. /**
  66909. * Defines the basic options interface of a TexturePacker Frame
  66910. */
  66911. export interface ITexturePackerFrame {
  66912. /**
  66913. * The frame ID
  66914. */
  66915. id: number;
  66916. /**
  66917. * The frames Scale
  66918. */
  66919. scale: Vector2;
  66920. /**
  66921. * The Frames offset
  66922. */
  66923. offset: Vector2;
  66924. }
  66925. /**
  66926. * This is a support class for frame Data on texture packer sets.
  66927. */
  66928. export class TexturePackerFrame implements ITexturePackerFrame {
  66929. /**
  66930. * The frame ID
  66931. */
  66932. id: number;
  66933. /**
  66934. * The frames Scale
  66935. */
  66936. scale: Vector2;
  66937. /**
  66938. * The Frames offset
  66939. */
  66940. offset: Vector2;
  66941. /**
  66942. * Initializes a texture package frame.
  66943. * @param id The numerical frame identifier
  66944. * @param scale Scalar Vector2 for UV frame
  66945. * @param offset Vector2 for the frame position in UV units.
  66946. * @returns TexturePackerFrame
  66947. */
  66948. constructor(id: number, scale: Vector2, offset: Vector2);
  66949. }
  66950. }
  66951. declare module BABYLON {
  66952. /**
  66953. * Defines the basic options interface of a TexturePacker
  66954. */
  66955. export interface ITexturePackerOptions {
  66956. /**
  66957. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66958. */
  66959. map?: string[];
  66960. /**
  66961. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66962. */
  66963. uvsIn?: string;
  66964. /**
  66965. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66966. */
  66967. uvsOut?: string;
  66968. /**
  66969. * number representing the layout style. Defaults to LAYOUT_STRIP
  66970. */
  66971. layout?: number;
  66972. /**
  66973. * number of columns if using custom column count layout(2). This defaults to 4.
  66974. */
  66975. colnum?: number;
  66976. /**
  66977. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66978. */
  66979. updateInputMeshes?: boolean;
  66980. /**
  66981. * boolean flag to dispose all the source textures. Defaults to true.
  66982. */
  66983. disposeSources?: boolean;
  66984. /**
  66985. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66986. */
  66987. fillBlanks?: boolean;
  66988. /**
  66989. * string value representing the context fill style color. Defaults to 'black'.
  66990. */
  66991. customFillColor?: string;
  66992. /**
  66993. * Width and Height Value of each Frame in the TexturePacker Sets
  66994. */
  66995. frameSize?: number;
  66996. /**
  66997. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66998. */
  66999. paddingRatio?: number;
  67000. /**
  67001. * Number that declares the fill method for the padding gutter.
  67002. */
  67003. paddingMode?: number;
  67004. /**
  67005. * If in SUBUV_COLOR padding mode what color to use.
  67006. */
  67007. paddingColor?: Color3 | Color4;
  67008. }
  67009. /**
  67010. * Defines the basic interface of a TexturePacker JSON File
  67011. */
  67012. export interface ITexturePackerJSON {
  67013. /**
  67014. * The frame ID
  67015. */
  67016. name: string;
  67017. /**
  67018. * The base64 channel data
  67019. */
  67020. sets: any;
  67021. /**
  67022. * The options of the Packer
  67023. */
  67024. options: ITexturePackerOptions;
  67025. /**
  67026. * The frame data of the Packer
  67027. */
  67028. frames: Array<number>;
  67029. }
  67030. /**
  67031. * This is a support class that generates a series of packed texture sets.
  67032. * @see https://doc.babylonjs.com/babylon101/materials
  67033. */
  67034. export class TexturePacker {
  67035. /** Packer Layout Constant 0 */
  67036. static readonly LAYOUT_STRIP: number;
  67037. /** Packer Layout Constant 1 */
  67038. static readonly LAYOUT_POWER2: number;
  67039. /** Packer Layout Constant 2 */
  67040. static readonly LAYOUT_COLNUM: number;
  67041. /** Packer Layout Constant 0 */
  67042. static readonly SUBUV_WRAP: number;
  67043. /** Packer Layout Constant 1 */
  67044. static readonly SUBUV_EXTEND: number;
  67045. /** Packer Layout Constant 2 */
  67046. static readonly SUBUV_COLOR: number;
  67047. /** The Name of the Texture Package */
  67048. name: string;
  67049. /** The scene scope of the TexturePacker */
  67050. scene: Scene;
  67051. /** The Meshes to target */
  67052. meshes: AbstractMesh[];
  67053. /** Arguments passed with the Constructor */
  67054. options: ITexturePackerOptions;
  67055. /** The promise that is started upon initialization */
  67056. promise: Nullable<Promise<TexturePacker | string>>;
  67057. /** The Container object for the channel sets that are generated */
  67058. sets: object;
  67059. /** The Container array for the frames that are generated */
  67060. frames: TexturePackerFrame[];
  67061. /** The expected number of textures the system is parsing. */
  67062. private _expecting;
  67063. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67064. private _paddingValue;
  67065. /**
  67066. * Initializes a texture package series from an array of meshes or a single mesh.
  67067. * @param name The name of the package
  67068. * @param meshes The target meshes to compose the package from
  67069. * @param options The arguments that texture packer should follow while building.
  67070. * @param scene The scene which the textures are scoped to.
  67071. * @returns TexturePacker
  67072. */
  67073. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67074. /**
  67075. * Starts the package process
  67076. * @param resolve The promises resolution function
  67077. * @returns TexturePacker
  67078. */
  67079. private _createFrames;
  67080. /**
  67081. * Calculates the Size of the Channel Sets
  67082. * @returns Vector2
  67083. */
  67084. private _calculateSize;
  67085. /**
  67086. * Calculates the UV data for the frames.
  67087. * @param baseSize the base frameSize
  67088. * @param padding the base frame padding
  67089. * @param dtSize size of the Dynamic Texture for that channel
  67090. * @param dtUnits is 1/dtSize
  67091. * @param update flag to update the input meshes
  67092. */
  67093. private _calculateMeshUVFrames;
  67094. /**
  67095. * Calculates the frames Offset.
  67096. * @param index of the frame
  67097. * @returns Vector2
  67098. */
  67099. private _getFrameOffset;
  67100. /**
  67101. * Updates a Mesh to the frame data
  67102. * @param mesh that is the target
  67103. * @param frameID or the frame index
  67104. */
  67105. private _updateMeshUV;
  67106. /**
  67107. * Updates a Meshes materials to use the texture packer channels
  67108. * @param m is the mesh to target
  67109. * @param force all channels on the packer to be set.
  67110. */
  67111. private _updateTextureReferences;
  67112. /**
  67113. * Public method to set a Mesh to a frame
  67114. * @param m that is the target
  67115. * @param frameID or the frame index
  67116. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67117. */
  67118. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67119. /**
  67120. * Starts the async promise to compile the texture packer.
  67121. * @returns Promise<void>
  67122. */
  67123. processAsync(): Promise<void>;
  67124. /**
  67125. * Disposes all textures associated with this packer
  67126. */
  67127. dispose(): void;
  67128. /**
  67129. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67130. * @param imageType is the image type to use.
  67131. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67132. */
  67133. download(imageType?: string, quality?: number): void;
  67134. /**
  67135. * Public method to load a texturePacker JSON file.
  67136. * @param data of the JSON file in string format.
  67137. */
  67138. updateFromJSON(data: string): void;
  67139. }
  67140. }
  67141. declare module BABYLON {
  67142. /**
  67143. * 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.
  67144. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67145. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67146. */
  67147. export class CustomProceduralTexture extends ProceduralTexture {
  67148. private _animate;
  67149. private _time;
  67150. private _config;
  67151. private _texturePath;
  67152. /**
  67153. * Instantiates a new Custom Procedural Texture.
  67154. * 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.
  67155. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67156. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67157. * @param name Define the name of the texture
  67158. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67159. * @param size Define the size of the texture to create
  67160. * @param scene Define the scene the texture belongs to
  67161. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67162. * @param generateMipMaps Define if the texture should creates mip maps or not
  67163. */
  67164. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67165. private _loadJson;
  67166. /**
  67167. * Is the texture ready to be used ? (rendered at least once)
  67168. * @returns true if ready, otherwise, false.
  67169. */
  67170. isReady(): boolean;
  67171. /**
  67172. * Render the texture to its associated render target.
  67173. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67174. */
  67175. render(useCameraPostProcess?: boolean): void;
  67176. /**
  67177. * Update the list of dependant textures samplers in the shader.
  67178. */
  67179. updateTextures(): void;
  67180. /**
  67181. * Update the uniform values of the procedural texture in the shader.
  67182. */
  67183. updateShaderUniforms(): void;
  67184. /**
  67185. * Define if the texture animates or not.
  67186. */
  67187. get animate(): boolean;
  67188. set animate(value: boolean);
  67189. }
  67190. }
  67191. declare module BABYLON {
  67192. /** @hidden */
  67193. export var noisePixelShader: {
  67194. name: string;
  67195. shader: string;
  67196. };
  67197. }
  67198. declare module BABYLON {
  67199. /**
  67200. * Class used to generate noise procedural textures
  67201. */
  67202. export class NoiseProceduralTexture extends ProceduralTexture {
  67203. /** Gets or sets the start time (default is 0) */
  67204. time: number;
  67205. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67206. brightness: number;
  67207. /** Defines the number of octaves to process */
  67208. octaves: number;
  67209. /** Defines the level of persistence (0.8 by default) */
  67210. persistence: number;
  67211. /** Gets or sets animation speed factor (default is 1) */
  67212. animationSpeedFactor: number;
  67213. /**
  67214. * Creates a new NoiseProceduralTexture
  67215. * @param name defines the name fo the texture
  67216. * @param size defines the size of the texture (default is 256)
  67217. * @param scene defines the hosting scene
  67218. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67219. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67220. */
  67221. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67222. private _updateShaderUniforms;
  67223. protected _getDefines(): string;
  67224. /** Generate the current state of the procedural texture */
  67225. render(useCameraPostProcess?: boolean): void;
  67226. /**
  67227. * Serializes this noise procedural texture
  67228. * @returns a serialized noise procedural texture object
  67229. */
  67230. serialize(): any;
  67231. /**
  67232. * Clone the texture.
  67233. * @returns the cloned texture
  67234. */
  67235. clone(): NoiseProceduralTexture;
  67236. /**
  67237. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67238. * @param parsedTexture defines parsed texture data
  67239. * @param scene defines the current scene
  67240. * @param rootUrl defines the root URL containing noise procedural texture information
  67241. * @returns a parsed NoiseProceduralTexture
  67242. */
  67243. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67244. }
  67245. }
  67246. declare module BABYLON {
  67247. /**
  67248. * Raw cube texture where the raw buffers are passed in
  67249. */
  67250. export class RawCubeTexture extends CubeTexture {
  67251. /**
  67252. * Creates a cube texture where the raw buffers are passed in.
  67253. * @param scene defines the scene the texture is attached to
  67254. * @param data defines the array of data to use to create each face
  67255. * @param size defines the size of the textures
  67256. * @param format defines the format of the data
  67257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67258. * @param generateMipMaps defines if the engine should generate the mip levels
  67259. * @param invertY defines if data must be stored with Y axis inverted
  67260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67261. * @param compression defines the compression used (null by default)
  67262. */
  67263. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67264. /**
  67265. * Updates the raw cube texture.
  67266. * @param data defines the data to store
  67267. * @param format defines the data format
  67268. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67269. * @param invertY defines if data must be stored with Y axis inverted
  67270. * @param compression defines the compression used (null by default)
  67271. * @param level defines which level of the texture to update
  67272. */
  67273. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67274. /**
  67275. * Updates a raw cube texture with RGBD encoded data.
  67276. * @param data defines the array of data [mipmap][face] to use to create each face
  67277. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67280. * @returns a promise that resolves when the operation is complete
  67281. */
  67282. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67283. /**
  67284. * Clones the raw cube texture.
  67285. * @return a new cube texture
  67286. */
  67287. clone(): CubeTexture;
  67288. /** @hidden */
  67289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67290. }
  67291. }
  67292. declare module BABYLON {
  67293. /**
  67294. * Class used to store 3D textures containing user data
  67295. */
  67296. export class RawTexture3D extends Texture {
  67297. /** Gets or sets the texture format to use */
  67298. format: number;
  67299. /**
  67300. * Create a new RawTexture3D
  67301. * @param data defines the data of the texture
  67302. * @param width defines the width of the texture
  67303. * @param height defines the height of the texture
  67304. * @param depth defines the depth of the texture
  67305. * @param format defines the texture format to use
  67306. * @param scene defines the hosting scene
  67307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67308. * @param invertY defines if texture must be stored with Y axis inverted
  67309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67311. */
  67312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67313. /** Gets or sets the texture format to use */
  67314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67315. /**
  67316. * Update the texture with new data
  67317. * @param data defines the data to store in the texture
  67318. */
  67319. update(data: ArrayBufferView): void;
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. /**
  67324. * Creates a refraction texture used by refraction channel of the standard material.
  67325. * It is like a mirror but to see through a material.
  67326. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67327. */
  67328. export class RefractionTexture extends RenderTargetTexture {
  67329. /**
  67330. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67331. * 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.
  67332. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67333. */
  67334. refractionPlane: Plane;
  67335. /**
  67336. * Define how deep under the surface we should see.
  67337. */
  67338. depth: number;
  67339. /**
  67340. * Creates a refraction texture used by refraction channel of the standard material.
  67341. * It is like a mirror but to see through a material.
  67342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67343. * @param name Define the texture name
  67344. * @param size Define the size of the underlying texture
  67345. * @param scene Define the scene the refraction belongs to
  67346. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67347. */
  67348. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67349. /**
  67350. * Clone the refraction texture.
  67351. * @returns the cloned texture
  67352. */
  67353. clone(): RefractionTexture;
  67354. /**
  67355. * Serialize the texture to a JSON representation you could use in Parse later on
  67356. * @returns the serialized JSON representation
  67357. */
  67358. serialize(): any;
  67359. }
  67360. }
  67361. declare module BABYLON {
  67362. /**
  67363. * Block used to add support for vertex skinning (bones)
  67364. */
  67365. export class BonesBlock extends NodeMaterialBlock {
  67366. /**
  67367. * Creates a new BonesBlock
  67368. * @param name defines the block name
  67369. */
  67370. constructor(name: string);
  67371. /**
  67372. * Initialize the block and prepare the context for build
  67373. * @param state defines the state that will be used for the build
  67374. */
  67375. initialize(state: NodeMaterialBuildState): void;
  67376. /**
  67377. * Gets the current class name
  67378. * @returns the class name
  67379. */
  67380. getClassName(): string;
  67381. /**
  67382. * Gets the matrix indices input component
  67383. */
  67384. get matricesIndices(): NodeMaterialConnectionPoint;
  67385. /**
  67386. * Gets the matrix weights input component
  67387. */
  67388. get matricesWeights(): NodeMaterialConnectionPoint;
  67389. /**
  67390. * Gets the extra matrix indices input component
  67391. */
  67392. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67393. /**
  67394. * Gets the extra matrix weights input component
  67395. */
  67396. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67397. /**
  67398. * Gets the world input component
  67399. */
  67400. get world(): NodeMaterialConnectionPoint;
  67401. /**
  67402. * Gets the output component
  67403. */
  67404. get output(): NodeMaterialConnectionPoint;
  67405. autoConfigure(material: NodeMaterial): void;
  67406. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67408. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67409. protected _buildBlock(state: NodeMaterialBuildState): this;
  67410. }
  67411. }
  67412. declare module BABYLON {
  67413. /**
  67414. * Block used to add support for instances
  67415. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67416. */
  67417. export class InstancesBlock extends NodeMaterialBlock {
  67418. /**
  67419. * Creates a new InstancesBlock
  67420. * @param name defines the block name
  67421. */
  67422. constructor(name: string);
  67423. /**
  67424. * Gets the current class name
  67425. * @returns the class name
  67426. */
  67427. getClassName(): string;
  67428. /**
  67429. * Gets the first world row input component
  67430. */
  67431. get world0(): NodeMaterialConnectionPoint;
  67432. /**
  67433. * Gets the second world row input component
  67434. */
  67435. get world1(): NodeMaterialConnectionPoint;
  67436. /**
  67437. * Gets the third world row input component
  67438. */
  67439. get world2(): NodeMaterialConnectionPoint;
  67440. /**
  67441. * Gets the forth world row input component
  67442. */
  67443. get world3(): NodeMaterialConnectionPoint;
  67444. /**
  67445. * Gets the world input component
  67446. */
  67447. get world(): NodeMaterialConnectionPoint;
  67448. /**
  67449. * Gets the output component
  67450. */
  67451. get output(): NodeMaterialConnectionPoint;
  67452. /**
  67453. * Gets the instanceID component
  67454. */
  67455. get instanceID(): NodeMaterialConnectionPoint;
  67456. autoConfigure(material: NodeMaterial): void;
  67457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67458. protected _buildBlock(state: NodeMaterialBuildState): this;
  67459. }
  67460. }
  67461. declare module BABYLON {
  67462. /**
  67463. * Block used to add morph targets support to vertex shader
  67464. */
  67465. export class MorphTargetsBlock extends NodeMaterialBlock {
  67466. private _repeatableContentAnchor;
  67467. /**
  67468. * Create a new MorphTargetsBlock
  67469. * @param name defines the block name
  67470. */
  67471. constructor(name: string);
  67472. /**
  67473. * Gets the current class name
  67474. * @returns the class name
  67475. */
  67476. getClassName(): string;
  67477. /**
  67478. * Gets the position input component
  67479. */
  67480. get position(): NodeMaterialConnectionPoint;
  67481. /**
  67482. * Gets the normal input component
  67483. */
  67484. get normal(): NodeMaterialConnectionPoint;
  67485. /**
  67486. * Gets the tangent input component
  67487. */
  67488. get tangent(): NodeMaterialConnectionPoint;
  67489. /**
  67490. * Gets the tangent input component
  67491. */
  67492. get uv(): NodeMaterialConnectionPoint;
  67493. /**
  67494. * Gets the position output component
  67495. */
  67496. get positionOutput(): NodeMaterialConnectionPoint;
  67497. /**
  67498. * Gets the normal output component
  67499. */
  67500. get normalOutput(): NodeMaterialConnectionPoint;
  67501. /**
  67502. * Gets the tangent output component
  67503. */
  67504. get tangentOutput(): NodeMaterialConnectionPoint;
  67505. /**
  67506. * Gets the tangent output component
  67507. */
  67508. get uvOutput(): NodeMaterialConnectionPoint;
  67509. initialize(state: NodeMaterialBuildState): void;
  67510. autoConfigure(material: NodeMaterial): void;
  67511. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67512. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67513. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67514. protected _buildBlock(state: NodeMaterialBuildState): this;
  67515. }
  67516. }
  67517. declare module BABYLON {
  67518. /**
  67519. * Block used to get data information from a light
  67520. */
  67521. export class LightInformationBlock extends NodeMaterialBlock {
  67522. private _lightDataUniformName;
  67523. private _lightColorUniformName;
  67524. private _lightTypeDefineName;
  67525. /**
  67526. * Gets or sets the light associated with this block
  67527. */
  67528. light: Nullable<Light>;
  67529. /**
  67530. * Creates a new LightInformationBlock
  67531. * @param name defines the block name
  67532. */
  67533. constructor(name: string);
  67534. /**
  67535. * Gets the current class name
  67536. * @returns the class name
  67537. */
  67538. getClassName(): string;
  67539. /**
  67540. * Gets the world position input component
  67541. */
  67542. get worldPosition(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the direction output component
  67545. */
  67546. get direction(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the direction output component
  67549. */
  67550. get color(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the direction output component
  67553. */
  67554. get intensity(): NodeMaterialConnectionPoint;
  67555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67557. protected _buildBlock(state: NodeMaterialBuildState): this;
  67558. serialize(): any;
  67559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67560. }
  67561. }
  67562. declare module BABYLON {
  67563. /**
  67564. * Block used to add image processing support to fragment shader
  67565. */
  67566. export class ImageProcessingBlock extends NodeMaterialBlock {
  67567. /**
  67568. * Create a new ImageProcessingBlock
  67569. * @param name defines the block name
  67570. */
  67571. constructor(name: string);
  67572. /**
  67573. * Gets the current class name
  67574. * @returns the class name
  67575. */
  67576. getClassName(): string;
  67577. /**
  67578. * Gets the color input component
  67579. */
  67580. get color(): NodeMaterialConnectionPoint;
  67581. /**
  67582. * Gets the output component
  67583. */
  67584. get output(): NodeMaterialConnectionPoint;
  67585. /**
  67586. * Initialize the block and prepare the context for build
  67587. * @param state defines the state that will be used for the build
  67588. */
  67589. initialize(state: NodeMaterialBuildState): void;
  67590. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67593. protected _buildBlock(state: NodeMaterialBuildState): this;
  67594. }
  67595. }
  67596. declare module BABYLON {
  67597. /**
  67598. * Block used to perturb normals based on a normal map
  67599. */
  67600. export class PerturbNormalBlock extends NodeMaterialBlock {
  67601. private _tangentSpaceParameterName;
  67602. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67603. invertX: boolean;
  67604. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67605. invertY: boolean;
  67606. /**
  67607. * Create a new PerturbNormalBlock
  67608. * @param name defines the block name
  67609. */
  67610. constructor(name: string);
  67611. /**
  67612. * Gets the current class name
  67613. * @returns the class name
  67614. */
  67615. getClassName(): string;
  67616. /**
  67617. * Gets the world position input component
  67618. */
  67619. get worldPosition(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the world normal input component
  67622. */
  67623. get worldNormal(): NodeMaterialConnectionPoint;
  67624. /**
  67625. * Gets the world tangent input component
  67626. */
  67627. get worldTangent(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the uv input component
  67630. */
  67631. get uv(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the normal map color input component
  67634. */
  67635. get normalMapColor(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the strength input component
  67638. */
  67639. get strength(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the output component
  67642. */
  67643. get output(): NodeMaterialConnectionPoint;
  67644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67645. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67646. autoConfigure(material: NodeMaterial): void;
  67647. protected _buildBlock(state: NodeMaterialBuildState): this;
  67648. protected _dumpPropertiesCode(): string;
  67649. serialize(): any;
  67650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67651. }
  67652. }
  67653. declare module BABYLON {
  67654. /**
  67655. * Block used to discard a pixel if a value is smaller than a cutoff
  67656. */
  67657. export class DiscardBlock extends NodeMaterialBlock {
  67658. /**
  67659. * Create a new DiscardBlock
  67660. * @param name defines the block name
  67661. */
  67662. constructor(name: string);
  67663. /**
  67664. * Gets the current class name
  67665. * @returns the class name
  67666. */
  67667. getClassName(): string;
  67668. /**
  67669. * Gets the color input component
  67670. */
  67671. get value(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the cutoff input component
  67674. */
  67675. get cutoff(): NodeMaterialConnectionPoint;
  67676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67677. }
  67678. }
  67679. declare module BABYLON {
  67680. /**
  67681. * Block used to test if the fragment shader is front facing
  67682. */
  67683. export class FrontFacingBlock extends NodeMaterialBlock {
  67684. /**
  67685. * Creates a new FrontFacingBlock
  67686. * @param name defines the block name
  67687. */
  67688. constructor(name: string);
  67689. /**
  67690. * Gets the current class name
  67691. * @returns the class name
  67692. */
  67693. getClassName(): string;
  67694. /**
  67695. * Gets the output component
  67696. */
  67697. get output(): NodeMaterialConnectionPoint;
  67698. protected _buildBlock(state: NodeMaterialBuildState): this;
  67699. }
  67700. }
  67701. declare module BABYLON {
  67702. /**
  67703. * Block used to get the derivative value on x and y of a given input
  67704. */
  67705. export class DerivativeBlock extends NodeMaterialBlock {
  67706. /**
  67707. * Create a new DerivativeBlock
  67708. * @param name defines the block name
  67709. */
  67710. constructor(name: string);
  67711. /**
  67712. * Gets the current class name
  67713. * @returns the class name
  67714. */
  67715. getClassName(): string;
  67716. /**
  67717. * Gets the input component
  67718. */
  67719. get input(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the derivative output on x
  67722. */
  67723. get dx(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the derivative output on y
  67726. */
  67727. get dy(): NodeMaterialConnectionPoint;
  67728. protected _buildBlock(state: NodeMaterialBuildState): this;
  67729. }
  67730. }
  67731. declare module BABYLON {
  67732. /**
  67733. * Block used to make gl_FragCoord available
  67734. */
  67735. export class FragCoordBlock extends NodeMaterialBlock {
  67736. /**
  67737. * Creates a new FragCoordBlock
  67738. * @param name defines the block name
  67739. */
  67740. constructor(name: string);
  67741. /**
  67742. * Gets the current class name
  67743. * @returns the class name
  67744. */
  67745. getClassName(): string;
  67746. /**
  67747. * Gets the xy component
  67748. */
  67749. get xy(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the xyz component
  67752. */
  67753. get xyz(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the xyzw component
  67756. */
  67757. get xyzw(): NodeMaterialConnectionPoint;
  67758. /**
  67759. * Gets the x component
  67760. */
  67761. get x(): NodeMaterialConnectionPoint;
  67762. /**
  67763. * Gets the y component
  67764. */
  67765. get y(): NodeMaterialConnectionPoint;
  67766. /**
  67767. * Gets the z component
  67768. */
  67769. get z(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the w component
  67772. */
  67773. get output(): NodeMaterialConnectionPoint;
  67774. protected writeOutputs(state: NodeMaterialBuildState): string;
  67775. protected _buildBlock(state: NodeMaterialBuildState): this;
  67776. }
  67777. }
  67778. declare module BABYLON {
  67779. /**
  67780. * Block used to get the screen sizes
  67781. */
  67782. export class ScreenSizeBlock extends NodeMaterialBlock {
  67783. private _varName;
  67784. private _scene;
  67785. /**
  67786. * Creates a new ScreenSizeBlock
  67787. * @param name defines the block name
  67788. */
  67789. constructor(name: string);
  67790. /**
  67791. * Gets the current class name
  67792. * @returns the class name
  67793. */
  67794. getClassName(): string;
  67795. /**
  67796. * Gets the xy component
  67797. */
  67798. get xy(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the x component
  67801. */
  67802. get x(): NodeMaterialConnectionPoint;
  67803. /**
  67804. * Gets the y component
  67805. */
  67806. get y(): NodeMaterialConnectionPoint;
  67807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67808. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67809. protected _buildBlock(state: NodeMaterialBuildState): this;
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Block used to add support for scene fog
  67815. */
  67816. export class FogBlock extends NodeMaterialBlock {
  67817. private _fogDistanceName;
  67818. private _fogParameters;
  67819. /**
  67820. * Create a new FogBlock
  67821. * @param name defines the block name
  67822. */
  67823. constructor(name: string);
  67824. /**
  67825. * Gets the current class name
  67826. * @returns the class name
  67827. */
  67828. getClassName(): string;
  67829. /**
  67830. * Gets the world position input component
  67831. */
  67832. get worldPosition(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the view input component
  67835. */
  67836. get view(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the color input component
  67839. */
  67840. get input(): NodeMaterialConnectionPoint;
  67841. /**
  67842. * Gets the fog color input component
  67843. */
  67844. get fogColor(): NodeMaterialConnectionPoint;
  67845. /**
  67846. * Gets the output component
  67847. */
  67848. get output(): NodeMaterialConnectionPoint;
  67849. autoConfigure(material: NodeMaterial): void;
  67850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67851. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67852. protected _buildBlock(state: NodeMaterialBuildState): this;
  67853. }
  67854. }
  67855. declare module BABYLON {
  67856. /**
  67857. * Block used to add light in the fragment shader
  67858. */
  67859. export class LightBlock extends NodeMaterialBlock {
  67860. private _lightId;
  67861. /**
  67862. * Gets or sets the light associated with this block
  67863. */
  67864. light: Nullable<Light>;
  67865. /**
  67866. * Create a new LightBlock
  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 world position input component
  67877. */
  67878. get worldPosition(): NodeMaterialConnectionPoint;
  67879. /**
  67880. * Gets the world normal input component
  67881. */
  67882. get worldNormal(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the camera (or eye) position component
  67885. */
  67886. get cameraPosition(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the glossiness component
  67889. */
  67890. get glossiness(): NodeMaterialConnectionPoint;
  67891. /**
  67892. * Gets the glossiness power component
  67893. */
  67894. get glossPower(): NodeMaterialConnectionPoint;
  67895. /**
  67896. * Gets the diffuse color component
  67897. */
  67898. get diffuseColor(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the specular color component
  67901. */
  67902. get specularColor(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the view matrix component
  67905. */
  67906. get view(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the diffuse output component
  67909. */
  67910. get diffuseOutput(): NodeMaterialConnectionPoint;
  67911. /**
  67912. * Gets the specular output component
  67913. */
  67914. get specularOutput(): NodeMaterialConnectionPoint;
  67915. /**
  67916. * Gets the shadow output component
  67917. */
  67918. get shadow(): NodeMaterialConnectionPoint;
  67919. autoConfigure(material: NodeMaterial): void;
  67920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67921. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67923. private _injectVertexCode;
  67924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67925. serialize(): any;
  67926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67927. }
  67928. }
  67929. declare module BABYLON {
  67930. /**
  67931. * Block used to read a reflection texture from a sampler
  67932. */
  67933. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67934. /**
  67935. * Create a new ReflectionTextureBlock
  67936. * @param name defines the block name
  67937. */
  67938. constructor(name: string);
  67939. /**
  67940. * Gets the current class name
  67941. * @returns the class name
  67942. */
  67943. getClassName(): string;
  67944. /**
  67945. * Gets the world position input component
  67946. */
  67947. get position(): NodeMaterialConnectionPoint;
  67948. /**
  67949. * Gets the world position input component
  67950. */
  67951. get worldPosition(): NodeMaterialConnectionPoint;
  67952. /**
  67953. * Gets the world normal input component
  67954. */
  67955. get worldNormal(): NodeMaterialConnectionPoint;
  67956. /**
  67957. * Gets the world input component
  67958. */
  67959. get world(): NodeMaterialConnectionPoint;
  67960. /**
  67961. * Gets the camera (or eye) position component
  67962. */
  67963. get cameraPosition(): NodeMaterialConnectionPoint;
  67964. /**
  67965. * Gets the view input component
  67966. */
  67967. get view(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the rgb output component
  67970. */
  67971. get rgb(): NodeMaterialConnectionPoint;
  67972. /**
  67973. * Gets the rgba output component
  67974. */
  67975. get rgba(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the r output component
  67978. */
  67979. get r(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the g output component
  67982. */
  67983. get g(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the b output component
  67986. */
  67987. get b(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the a output component
  67990. */
  67991. get a(): NodeMaterialConnectionPoint;
  67992. autoConfigure(material: NodeMaterial): void;
  67993. protected _buildBlock(state: NodeMaterialBuildState): this;
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /**
  67998. * Block used to add 2 vectors
  67999. */
  68000. export class AddBlock extends NodeMaterialBlock {
  68001. /**
  68002. * Creates a new AddBlock
  68003. * @param name defines the block name
  68004. */
  68005. constructor(name: string);
  68006. /**
  68007. * Gets the current class name
  68008. * @returns the class name
  68009. */
  68010. getClassName(): string;
  68011. /**
  68012. * Gets the left operand input component
  68013. */
  68014. get left(): NodeMaterialConnectionPoint;
  68015. /**
  68016. * Gets the right operand input component
  68017. */
  68018. get right(): NodeMaterialConnectionPoint;
  68019. /**
  68020. * Gets the output component
  68021. */
  68022. get output(): NodeMaterialConnectionPoint;
  68023. protected _buildBlock(state: NodeMaterialBuildState): this;
  68024. }
  68025. }
  68026. declare module BABYLON {
  68027. /**
  68028. * Block used to scale a vector by a float
  68029. */
  68030. export class ScaleBlock extends NodeMaterialBlock {
  68031. /**
  68032. * Creates a new ScaleBlock
  68033. * @param name defines the block name
  68034. */
  68035. constructor(name: string);
  68036. /**
  68037. * Gets the current class name
  68038. * @returns the class name
  68039. */
  68040. getClassName(): string;
  68041. /**
  68042. * Gets the input component
  68043. */
  68044. get input(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the factor input component
  68047. */
  68048. get factor(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the output component
  68051. */
  68052. get output(): NodeMaterialConnectionPoint;
  68053. protected _buildBlock(state: NodeMaterialBuildState): this;
  68054. }
  68055. }
  68056. declare module BABYLON {
  68057. /**
  68058. * Block used to clamp a float
  68059. */
  68060. export class ClampBlock extends NodeMaterialBlock {
  68061. /** Gets or sets the minimum range */
  68062. minimum: number;
  68063. /** Gets or sets the maximum range */
  68064. maximum: number;
  68065. /**
  68066. * Creates a new ClampBlock
  68067. * @param name defines the block name
  68068. */
  68069. constructor(name: string);
  68070. /**
  68071. * Gets the current class name
  68072. * @returns the class name
  68073. */
  68074. getClassName(): string;
  68075. /**
  68076. * Gets the value input component
  68077. */
  68078. get value(): NodeMaterialConnectionPoint;
  68079. /**
  68080. * Gets the output component
  68081. */
  68082. get output(): NodeMaterialConnectionPoint;
  68083. protected _buildBlock(state: NodeMaterialBuildState): this;
  68084. protected _dumpPropertiesCode(): string;
  68085. serialize(): any;
  68086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * Block used to apply a cross product between 2 vectors
  68092. */
  68093. export class CrossBlock extends NodeMaterialBlock {
  68094. /**
  68095. * Creates a new CrossBlock
  68096. * @param name defines the block name
  68097. */
  68098. constructor(name: string);
  68099. /**
  68100. * Gets the current class name
  68101. * @returns the class name
  68102. */
  68103. getClassName(): string;
  68104. /**
  68105. * Gets the left operand input component
  68106. */
  68107. get left(): NodeMaterialConnectionPoint;
  68108. /**
  68109. * Gets the right operand input component
  68110. */
  68111. get right(): NodeMaterialConnectionPoint;
  68112. /**
  68113. * Gets the output component
  68114. */
  68115. get output(): NodeMaterialConnectionPoint;
  68116. protected _buildBlock(state: NodeMaterialBuildState): this;
  68117. }
  68118. }
  68119. declare module BABYLON {
  68120. /**
  68121. * Block used to apply a dot product between 2 vectors
  68122. */
  68123. export class DotBlock extends NodeMaterialBlock {
  68124. /**
  68125. * Creates a new DotBlock
  68126. * @param name defines the block name
  68127. */
  68128. constructor(name: string);
  68129. /**
  68130. * Gets the current class name
  68131. * @returns the class name
  68132. */
  68133. getClassName(): string;
  68134. /**
  68135. * Gets the left operand input component
  68136. */
  68137. get left(): NodeMaterialConnectionPoint;
  68138. /**
  68139. * Gets the right operand input component
  68140. */
  68141. get right(): NodeMaterialConnectionPoint;
  68142. /**
  68143. * Gets the output component
  68144. */
  68145. get output(): NodeMaterialConnectionPoint;
  68146. protected _buildBlock(state: NodeMaterialBuildState): this;
  68147. }
  68148. }
  68149. declare module BABYLON {
  68150. /**
  68151. * Block used to normalize a vector
  68152. */
  68153. export class NormalizeBlock extends NodeMaterialBlock {
  68154. /**
  68155. * Creates a new NormalizeBlock
  68156. * @param name defines the block name
  68157. */
  68158. constructor(name: string);
  68159. /**
  68160. * Gets the current class name
  68161. * @returns the class name
  68162. */
  68163. getClassName(): string;
  68164. /**
  68165. * Gets the input component
  68166. */
  68167. get input(): NodeMaterialConnectionPoint;
  68168. /**
  68169. * Gets the output component
  68170. */
  68171. get output(): NodeMaterialConnectionPoint;
  68172. protected _buildBlock(state: NodeMaterialBuildState): this;
  68173. }
  68174. }
  68175. declare module BABYLON {
  68176. /**
  68177. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68178. */
  68179. export class ColorMergerBlock extends NodeMaterialBlock {
  68180. /**
  68181. * Create a new ColorMergerBlock
  68182. * @param name defines the block name
  68183. */
  68184. constructor(name: string);
  68185. /**
  68186. * Gets the current class name
  68187. * @returns the class name
  68188. */
  68189. getClassName(): string;
  68190. /**
  68191. * Gets the rgb component (input)
  68192. */
  68193. get rgbIn(): NodeMaterialConnectionPoint;
  68194. /**
  68195. * Gets the r component (input)
  68196. */
  68197. get r(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the g component (input)
  68200. */
  68201. get g(): NodeMaterialConnectionPoint;
  68202. /**
  68203. * Gets the b component (input)
  68204. */
  68205. get b(): NodeMaterialConnectionPoint;
  68206. /**
  68207. * Gets the a component (input)
  68208. */
  68209. get a(): NodeMaterialConnectionPoint;
  68210. /**
  68211. * Gets the rgba component (output)
  68212. */
  68213. get rgba(): NodeMaterialConnectionPoint;
  68214. /**
  68215. * Gets the rgb component (output)
  68216. */
  68217. get rgbOut(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the rgb component (output)
  68220. * @deprecated Please use rgbOut instead.
  68221. */
  68222. get rgb(): NodeMaterialConnectionPoint;
  68223. protected _buildBlock(state: NodeMaterialBuildState): this;
  68224. }
  68225. }
  68226. declare module BABYLON {
  68227. /**
  68228. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68229. */
  68230. export class VectorSplitterBlock extends NodeMaterialBlock {
  68231. /**
  68232. * Create a new VectorSplitterBlock
  68233. * @param name defines the block name
  68234. */
  68235. constructor(name: string);
  68236. /**
  68237. * Gets the current class name
  68238. * @returns the class name
  68239. */
  68240. getClassName(): string;
  68241. /**
  68242. * Gets the xyzw component (input)
  68243. */
  68244. get xyzw(): NodeMaterialConnectionPoint;
  68245. /**
  68246. * Gets the xyz component (input)
  68247. */
  68248. get xyzIn(): NodeMaterialConnectionPoint;
  68249. /**
  68250. * Gets the xy component (input)
  68251. */
  68252. get xyIn(): NodeMaterialConnectionPoint;
  68253. /**
  68254. * Gets the xyz component (output)
  68255. */
  68256. get xyzOut(): NodeMaterialConnectionPoint;
  68257. /**
  68258. * Gets the xy component (output)
  68259. */
  68260. get xyOut(): NodeMaterialConnectionPoint;
  68261. /**
  68262. * Gets the x component (output)
  68263. */
  68264. get x(): NodeMaterialConnectionPoint;
  68265. /**
  68266. * Gets the y component (output)
  68267. */
  68268. get y(): NodeMaterialConnectionPoint;
  68269. /**
  68270. * Gets the z component (output)
  68271. */
  68272. get z(): NodeMaterialConnectionPoint;
  68273. /**
  68274. * Gets the w component (output)
  68275. */
  68276. get w(): NodeMaterialConnectionPoint;
  68277. protected _inputRename(name: string): string;
  68278. protected _outputRename(name: string): string;
  68279. protected _buildBlock(state: NodeMaterialBuildState): this;
  68280. }
  68281. }
  68282. declare module BABYLON {
  68283. /**
  68284. * Block used to lerp between 2 values
  68285. */
  68286. export class LerpBlock extends NodeMaterialBlock {
  68287. /**
  68288. * Creates a new LerpBlock
  68289. * @param name defines the block name
  68290. */
  68291. constructor(name: string);
  68292. /**
  68293. * Gets the current class name
  68294. * @returns the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the left operand input component
  68299. */
  68300. get left(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the right operand input component
  68303. */
  68304. get right(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the gradient operand input component
  68307. */
  68308. get gradient(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the output component
  68311. */
  68312. get output(): NodeMaterialConnectionPoint;
  68313. protected _buildBlock(state: NodeMaterialBuildState): this;
  68314. }
  68315. }
  68316. declare module BABYLON {
  68317. /**
  68318. * Block used to divide 2 vectors
  68319. */
  68320. export class DivideBlock extends NodeMaterialBlock {
  68321. /**
  68322. * Creates a new DivideBlock
  68323. * @param name defines the block name
  68324. */
  68325. constructor(name: string);
  68326. /**
  68327. * Gets the current class name
  68328. * @returns the class name
  68329. */
  68330. getClassName(): string;
  68331. /**
  68332. * Gets the left operand input component
  68333. */
  68334. get left(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the right operand input component
  68337. */
  68338. get right(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the output component
  68341. */
  68342. get output(): NodeMaterialConnectionPoint;
  68343. protected _buildBlock(state: NodeMaterialBuildState): this;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /**
  68348. * Block used to subtract 2 vectors
  68349. */
  68350. export class SubtractBlock extends NodeMaterialBlock {
  68351. /**
  68352. * Creates a new SubtractBlock
  68353. * @param name defines the block name
  68354. */
  68355. constructor(name: string);
  68356. /**
  68357. * Gets the current class name
  68358. * @returns the class name
  68359. */
  68360. getClassName(): string;
  68361. /**
  68362. * Gets the left operand input component
  68363. */
  68364. get left(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the right operand input component
  68367. */
  68368. get right(): NodeMaterialConnectionPoint;
  68369. /**
  68370. * Gets the output component
  68371. */
  68372. get output(): NodeMaterialConnectionPoint;
  68373. protected _buildBlock(state: NodeMaterialBuildState): this;
  68374. }
  68375. }
  68376. declare module BABYLON {
  68377. /**
  68378. * Block used to step a value
  68379. */
  68380. export class StepBlock extends NodeMaterialBlock {
  68381. /**
  68382. * Creates a new StepBlock
  68383. * @param name defines the block name
  68384. */
  68385. constructor(name: string);
  68386. /**
  68387. * Gets the current class name
  68388. * @returns the class name
  68389. */
  68390. getClassName(): string;
  68391. /**
  68392. * Gets the value operand input component
  68393. */
  68394. get value(): NodeMaterialConnectionPoint;
  68395. /**
  68396. * Gets the edge operand input component
  68397. */
  68398. get edge(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the output component
  68401. */
  68402. get output(): NodeMaterialConnectionPoint;
  68403. protected _buildBlock(state: NodeMaterialBuildState): this;
  68404. }
  68405. }
  68406. declare module BABYLON {
  68407. /**
  68408. * Block used to get the opposite (1 - x) of a value
  68409. */
  68410. export class OneMinusBlock extends NodeMaterialBlock {
  68411. /**
  68412. * Creates a new OneMinusBlock
  68413. * @param name defines the block name
  68414. */
  68415. constructor(name: string);
  68416. /**
  68417. * Gets the current class name
  68418. * @returns the class name
  68419. */
  68420. getClassName(): string;
  68421. /**
  68422. * Gets the input component
  68423. */
  68424. get input(): NodeMaterialConnectionPoint;
  68425. /**
  68426. * Gets the output component
  68427. */
  68428. get output(): NodeMaterialConnectionPoint;
  68429. protected _buildBlock(state: NodeMaterialBuildState): this;
  68430. }
  68431. }
  68432. declare module BABYLON {
  68433. /**
  68434. * Block used to get the view direction
  68435. */
  68436. export class ViewDirectionBlock extends NodeMaterialBlock {
  68437. /**
  68438. * Creates a new ViewDirectionBlock
  68439. * @param name defines the block name
  68440. */
  68441. constructor(name: string);
  68442. /**
  68443. * Gets the current class name
  68444. * @returns the class name
  68445. */
  68446. getClassName(): string;
  68447. /**
  68448. * Gets the world position component
  68449. */
  68450. get worldPosition(): NodeMaterialConnectionPoint;
  68451. /**
  68452. * Gets the camera position component
  68453. */
  68454. get cameraPosition(): NodeMaterialConnectionPoint;
  68455. /**
  68456. * Gets the output component
  68457. */
  68458. get output(): NodeMaterialConnectionPoint;
  68459. autoConfigure(material: NodeMaterial): void;
  68460. protected _buildBlock(state: NodeMaterialBuildState): this;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /**
  68465. * Block used to compute fresnel value
  68466. */
  68467. export class FresnelBlock extends NodeMaterialBlock {
  68468. /**
  68469. * Create a new FresnelBlock
  68470. * @param name defines the block name
  68471. */
  68472. constructor(name: string);
  68473. /**
  68474. * Gets the current class name
  68475. * @returns the class name
  68476. */
  68477. getClassName(): string;
  68478. /**
  68479. * Gets the world normal input component
  68480. */
  68481. get worldNormal(): NodeMaterialConnectionPoint;
  68482. /**
  68483. * Gets the view direction input component
  68484. */
  68485. get viewDirection(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the bias input component
  68488. */
  68489. get bias(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the camera (or eye) position component
  68492. */
  68493. get power(): NodeMaterialConnectionPoint;
  68494. /**
  68495. * Gets the fresnel output component
  68496. */
  68497. get fresnel(): NodeMaterialConnectionPoint;
  68498. autoConfigure(material: NodeMaterial): void;
  68499. protected _buildBlock(state: NodeMaterialBuildState): this;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /**
  68504. * Block used to get the max of 2 values
  68505. */
  68506. export class MaxBlock extends NodeMaterialBlock {
  68507. /**
  68508. * Creates a new MaxBlock
  68509. * @param name defines the block name
  68510. */
  68511. constructor(name: string);
  68512. /**
  68513. * Gets the current class name
  68514. * @returns the class name
  68515. */
  68516. getClassName(): string;
  68517. /**
  68518. * Gets the left operand input component
  68519. */
  68520. get left(): NodeMaterialConnectionPoint;
  68521. /**
  68522. * Gets the right operand input component
  68523. */
  68524. get right(): NodeMaterialConnectionPoint;
  68525. /**
  68526. * Gets the output component
  68527. */
  68528. get output(): NodeMaterialConnectionPoint;
  68529. protected _buildBlock(state: NodeMaterialBuildState): this;
  68530. }
  68531. }
  68532. declare module BABYLON {
  68533. /**
  68534. * Block used to get the min of 2 values
  68535. */
  68536. export class MinBlock extends NodeMaterialBlock {
  68537. /**
  68538. * Creates a new MinBlock
  68539. * @param name defines the block name
  68540. */
  68541. constructor(name: string);
  68542. /**
  68543. * Gets the current class name
  68544. * @returns the class name
  68545. */
  68546. getClassName(): string;
  68547. /**
  68548. * Gets the left operand input component
  68549. */
  68550. get left(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the right operand input component
  68553. */
  68554. get right(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the output component
  68557. */
  68558. get output(): NodeMaterialConnectionPoint;
  68559. protected _buildBlock(state: NodeMaterialBuildState): this;
  68560. }
  68561. }
  68562. declare module BABYLON {
  68563. /**
  68564. * Block used to get the distance between 2 values
  68565. */
  68566. export class DistanceBlock extends NodeMaterialBlock {
  68567. /**
  68568. * Creates a new DistanceBlock
  68569. * @param name defines the block name
  68570. */
  68571. constructor(name: string);
  68572. /**
  68573. * Gets the current class name
  68574. * @returns the class name
  68575. */
  68576. getClassName(): string;
  68577. /**
  68578. * Gets the left operand input component
  68579. */
  68580. get left(): NodeMaterialConnectionPoint;
  68581. /**
  68582. * Gets the right operand input component
  68583. */
  68584. get right(): NodeMaterialConnectionPoint;
  68585. /**
  68586. * Gets the output component
  68587. */
  68588. get output(): NodeMaterialConnectionPoint;
  68589. protected _buildBlock(state: NodeMaterialBuildState): this;
  68590. }
  68591. }
  68592. declare module BABYLON {
  68593. /**
  68594. * Block used to get the length of a vector
  68595. */
  68596. export class LengthBlock extends NodeMaterialBlock {
  68597. /**
  68598. * Creates a new LengthBlock
  68599. * @param name defines the block name
  68600. */
  68601. constructor(name: string);
  68602. /**
  68603. * Gets the current class name
  68604. * @returns the class name
  68605. */
  68606. getClassName(): string;
  68607. /**
  68608. * Gets the value input component
  68609. */
  68610. get value(): NodeMaterialConnectionPoint;
  68611. /**
  68612. * Gets the output component
  68613. */
  68614. get output(): NodeMaterialConnectionPoint;
  68615. protected _buildBlock(state: NodeMaterialBuildState): this;
  68616. }
  68617. }
  68618. declare module BABYLON {
  68619. /**
  68620. * Block used to get negative version of a value (i.e. x * -1)
  68621. */
  68622. export class NegateBlock extends NodeMaterialBlock {
  68623. /**
  68624. * Creates a new NegateBlock
  68625. * @param name defines the block name
  68626. */
  68627. constructor(name: string);
  68628. /**
  68629. * Gets the current class name
  68630. * @returns the class name
  68631. */
  68632. getClassName(): string;
  68633. /**
  68634. * Gets the value input component
  68635. */
  68636. get value(): NodeMaterialConnectionPoint;
  68637. /**
  68638. * Gets the output component
  68639. */
  68640. get output(): NodeMaterialConnectionPoint;
  68641. protected _buildBlock(state: NodeMaterialBuildState): this;
  68642. }
  68643. }
  68644. declare module BABYLON {
  68645. /**
  68646. * Block used to get the value of the first parameter raised to the power of the second
  68647. */
  68648. export class PowBlock extends NodeMaterialBlock {
  68649. /**
  68650. * Creates a new PowBlock
  68651. * @param name defines the block name
  68652. */
  68653. constructor(name: string);
  68654. /**
  68655. * Gets the current class name
  68656. * @returns the class name
  68657. */
  68658. getClassName(): string;
  68659. /**
  68660. * Gets the value operand input component
  68661. */
  68662. get value(): NodeMaterialConnectionPoint;
  68663. /**
  68664. * Gets the power operand input component
  68665. */
  68666. get power(): NodeMaterialConnectionPoint;
  68667. /**
  68668. * Gets the output component
  68669. */
  68670. get output(): NodeMaterialConnectionPoint;
  68671. protected _buildBlock(state: NodeMaterialBuildState): this;
  68672. }
  68673. }
  68674. declare module BABYLON {
  68675. /**
  68676. * Block used to get a random number
  68677. */
  68678. export class RandomNumberBlock extends NodeMaterialBlock {
  68679. /**
  68680. * Creates a new RandomNumberBlock
  68681. * @param name defines the block name
  68682. */
  68683. constructor(name: string);
  68684. /**
  68685. * Gets the current class name
  68686. * @returns the class name
  68687. */
  68688. getClassName(): string;
  68689. /**
  68690. * Gets the seed input component
  68691. */
  68692. get seed(): NodeMaterialConnectionPoint;
  68693. /**
  68694. * Gets the output component
  68695. */
  68696. get output(): NodeMaterialConnectionPoint;
  68697. protected _buildBlock(state: NodeMaterialBuildState): this;
  68698. }
  68699. }
  68700. declare module BABYLON {
  68701. /**
  68702. * Block used to compute arc tangent of 2 values
  68703. */
  68704. export class ArcTan2Block extends NodeMaterialBlock {
  68705. /**
  68706. * Creates a new ArcTan2Block
  68707. * @param name defines the block name
  68708. */
  68709. constructor(name: string);
  68710. /**
  68711. * Gets the current class name
  68712. * @returns the class name
  68713. */
  68714. getClassName(): string;
  68715. /**
  68716. * Gets the x operand input component
  68717. */
  68718. get x(): NodeMaterialConnectionPoint;
  68719. /**
  68720. * Gets the y operand input component
  68721. */
  68722. get y(): NodeMaterialConnectionPoint;
  68723. /**
  68724. * Gets the output component
  68725. */
  68726. get output(): NodeMaterialConnectionPoint;
  68727. protected _buildBlock(state: NodeMaterialBuildState): this;
  68728. }
  68729. }
  68730. declare module BABYLON {
  68731. /**
  68732. * Block used to smooth step a value
  68733. */
  68734. export class SmoothStepBlock extends NodeMaterialBlock {
  68735. /**
  68736. * Creates a new SmoothStepBlock
  68737. * @param name defines the block name
  68738. */
  68739. constructor(name: string);
  68740. /**
  68741. * Gets the current class name
  68742. * @returns the class name
  68743. */
  68744. getClassName(): string;
  68745. /**
  68746. * Gets the value operand input component
  68747. */
  68748. get value(): NodeMaterialConnectionPoint;
  68749. /**
  68750. * Gets the first edge operand input component
  68751. */
  68752. get edge0(): NodeMaterialConnectionPoint;
  68753. /**
  68754. * Gets the second edge operand input component
  68755. */
  68756. get edge1(): NodeMaterialConnectionPoint;
  68757. /**
  68758. * Gets the output component
  68759. */
  68760. get output(): NodeMaterialConnectionPoint;
  68761. protected _buildBlock(state: NodeMaterialBuildState): this;
  68762. }
  68763. }
  68764. declare module BABYLON {
  68765. /**
  68766. * Block used to get the reciprocal (1 / x) of a value
  68767. */
  68768. export class ReciprocalBlock extends NodeMaterialBlock {
  68769. /**
  68770. * Creates a new ReciprocalBlock
  68771. * @param name defines the block name
  68772. */
  68773. constructor(name: string);
  68774. /**
  68775. * Gets the current class name
  68776. * @returns the class name
  68777. */
  68778. getClassName(): string;
  68779. /**
  68780. * Gets the input component
  68781. */
  68782. get input(): NodeMaterialConnectionPoint;
  68783. /**
  68784. * Gets the output component
  68785. */
  68786. get output(): NodeMaterialConnectionPoint;
  68787. protected _buildBlock(state: NodeMaterialBuildState): this;
  68788. }
  68789. }
  68790. declare module BABYLON {
  68791. /**
  68792. * Block used to replace a color by another one
  68793. */
  68794. export class ReplaceColorBlock extends NodeMaterialBlock {
  68795. /**
  68796. * Creates a new ReplaceColorBlock
  68797. * @param name defines the block name
  68798. */
  68799. constructor(name: string);
  68800. /**
  68801. * Gets the current class name
  68802. * @returns the class name
  68803. */
  68804. getClassName(): string;
  68805. /**
  68806. * Gets the value input component
  68807. */
  68808. get value(): NodeMaterialConnectionPoint;
  68809. /**
  68810. * Gets the reference input component
  68811. */
  68812. get reference(): NodeMaterialConnectionPoint;
  68813. /**
  68814. * Gets the distance input component
  68815. */
  68816. get distance(): NodeMaterialConnectionPoint;
  68817. /**
  68818. * Gets the replacement input component
  68819. */
  68820. get replacement(): NodeMaterialConnectionPoint;
  68821. /**
  68822. * Gets the output component
  68823. */
  68824. get output(): NodeMaterialConnectionPoint;
  68825. protected _buildBlock(state: NodeMaterialBuildState): this;
  68826. }
  68827. }
  68828. declare module BABYLON {
  68829. /**
  68830. * Block used to posterize a value
  68831. * @see https://en.wikipedia.org/wiki/Posterization
  68832. */
  68833. export class PosterizeBlock extends NodeMaterialBlock {
  68834. /**
  68835. * Creates a new PosterizeBlock
  68836. * @param name defines the block name
  68837. */
  68838. constructor(name: string);
  68839. /**
  68840. * Gets the current class name
  68841. * @returns the class name
  68842. */
  68843. getClassName(): string;
  68844. /**
  68845. * Gets the value input component
  68846. */
  68847. get value(): NodeMaterialConnectionPoint;
  68848. /**
  68849. * Gets the steps input component
  68850. */
  68851. get steps(): NodeMaterialConnectionPoint;
  68852. /**
  68853. * Gets the output component
  68854. */
  68855. get output(): NodeMaterialConnectionPoint;
  68856. protected _buildBlock(state: NodeMaterialBuildState): this;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Operations supported by the Wave block
  68862. */
  68863. export enum WaveBlockKind {
  68864. /** SawTooth */
  68865. SawTooth = 0,
  68866. /** Square */
  68867. Square = 1,
  68868. /** Triangle */
  68869. Triangle = 2
  68870. }
  68871. /**
  68872. * Block used to apply wave operation to floats
  68873. */
  68874. export class WaveBlock extends NodeMaterialBlock {
  68875. /**
  68876. * Gets or sets the kibnd of wave to be applied by the block
  68877. */
  68878. kind: WaveBlockKind;
  68879. /**
  68880. * Creates a new WaveBlock
  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 component
  68891. */
  68892. get input(): NodeMaterialConnectionPoint;
  68893. /**
  68894. * Gets the output component
  68895. */
  68896. get output(): NodeMaterialConnectionPoint;
  68897. protected _buildBlock(state: NodeMaterialBuildState): this;
  68898. serialize(): any;
  68899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68900. }
  68901. }
  68902. declare module BABYLON {
  68903. /**
  68904. * Class used to store a color step for the GradientBlock
  68905. */
  68906. export class GradientBlockColorStep {
  68907. private _step;
  68908. /**
  68909. * Gets value indicating which step this color is associated with (between 0 and 1)
  68910. */
  68911. get step(): number;
  68912. /**
  68913. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68914. */
  68915. set step(val: number);
  68916. private _color;
  68917. /**
  68918. * Gets the color associated with this step
  68919. */
  68920. get color(): Color3;
  68921. /**
  68922. * Sets the color associated with this step
  68923. */
  68924. set color(val: Color3);
  68925. /**
  68926. * Creates a new GradientBlockColorStep
  68927. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68928. * @param color defines the color associated with this step
  68929. */
  68930. constructor(step: number, color: Color3);
  68931. }
  68932. /**
  68933. * Block used to return a color from a gradient based on an input value between 0 and 1
  68934. */
  68935. export class GradientBlock extends NodeMaterialBlock {
  68936. /**
  68937. * Gets or sets the list of color steps
  68938. */
  68939. colorSteps: GradientBlockColorStep[];
  68940. /** Gets an observable raised when the value is changed */
  68941. onValueChangedObservable: Observable<GradientBlock>;
  68942. /** calls observable when the value is changed*/
  68943. colorStepsUpdated(): void;
  68944. /**
  68945. * Creates a new GradientBlock
  68946. * @param name defines the block name
  68947. */
  68948. constructor(name: string);
  68949. /**
  68950. * Gets the current class name
  68951. * @returns the class name
  68952. */
  68953. getClassName(): string;
  68954. /**
  68955. * Gets the gradient input component
  68956. */
  68957. get gradient(): NodeMaterialConnectionPoint;
  68958. /**
  68959. * Gets the output component
  68960. */
  68961. get output(): NodeMaterialConnectionPoint;
  68962. private _writeColorConstant;
  68963. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68964. serialize(): any;
  68965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68966. protected _dumpPropertiesCode(): string;
  68967. }
  68968. }
  68969. declare module BABYLON {
  68970. /**
  68971. * Block used to normalize lerp between 2 values
  68972. */
  68973. export class NLerpBlock extends NodeMaterialBlock {
  68974. /**
  68975. * Creates a new NLerpBlock
  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 left operand input component
  68986. */
  68987. get left(): NodeMaterialConnectionPoint;
  68988. /**
  68989. * Gets the right operand input component
  68990. */
  68991. get right(): NodeMaterialConnectionPoint;
  68992. /**
  68993. * Gets the gradient operand input component
  68994. */
  68995. get gradient(): NodeMaterialConnectionPoint;
  68996. /**
  68997. * Gets the output component
  68998. */
  68999. get output(): NodeMaterialConnectionPoint;
  69000. protected _buildBlock(state: NodeMaterialBuildState): this;
  69001. }
  69002. }
  69003. declare module BABYLON {
  69004. /**
  69005. * block used to Generate a Worley Noise 3D Noise Pattern
  69006. */
  69007. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  69008. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69009. manhattanDistance: boolean;
  69010. /**
  69011. * Creates a new WorleyNoise3DBlock
  69012. * @param name defines the block name
  69013. */
  69014. constructor(name: string);
  69015. /**
  69016. * Gets the current class name
  69017. * @returns the class name
  69018. */
  69019. getClassName(): string;
  69020. /**
  69021. * Gets the seed input component
  69022. */
  69023. get seed(): NodeMaterialConnectionPoint;
  69024. /**
  69025. * Gets the jitter input component
  69026. */
  69027. get jitter(): NodeMaterialConnectionPoint;
  69028. /**
  69029. * Gets the output component
  69030. */
  69031. get output(): NodeMaterialConnectionPoint;
  69032. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69033. /**
  69034. * Exposes the properties to the UI?
  69035. */
  69036. protected _dumpPropertiesCode(): string;
  69037. /**
  69038. * Exposes the properties to the Serialize?
  69039. */
  69040. serialize(): any;
  69041. /**
  69042. * Exposes the properties to the deserialize?
  69043. */
  69044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69045. }
  69046. }
  69047. declare module BABYLON {
  69048. /**
  69049. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69050. */
  69051. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69052. /**
  69053. * Creates a new SimplexPerlin3DBlock
  69054. * @param name defines the block name
  69055. */
  69056. constructor(name: string);
  69057. /**
  69058. * Gets the current class name
  69059. * @returns the class name
  69060. */
  69061. getClassName(): string;
  69062. /**
  69063. * Gets the seed operand input component
  69064. */
  69065. get seed(): NodeMaterialConnectionPoint;
  69066. /**
  69067. * Gets the output component
  69068. */
  69069. get output(): NodeMaterialConnectionPoint;
  69070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69071. }
  69072. }
  69073. declare module BABYLON {
  69074. /**
  69075. * Block used to blend normals
  69076. */
  69077. export class NormalBlendBlock extends NodeMaterialBlock {
  69078. /**
  69079. * Creates a new NormalBlendBlock
  69080. * @param name defines the block name
  69081. */
  69082. constructor(name: string);
  69083. /**
  69084. * Gets the current class name
  69085. * @returns the class name
  69086. */
  69087. getClassName(): string;
  69088. /**
  69089. * Gets the first input component
  69090. */
  69091. get normalMap0(): NodeMaterialConnectionPoint;
  69092. /**
  69093. * Gets the second input component
  69094. */
  69095. get normalMap1(): NodeMaterialConnectionPoint;
  69096. /**
  69097. * Gets the output component
  69098. */
  69099. get output(): NodeMaterialConnectionPoint;
  69100. protected _buildBlock(state: NodeMaterialBuildState): this;
  69101. }
  69102. }
  69103. declare module BABYLON {
  69104. /**
  69105. * Block used to rotate a 2d vector by a given angle
  69106. */
  69107. export class Rotate2dBlock extends NodeMaterialBlock {
  69108. /**
  69109. * Creates a new Rotate2dBlock
  69110. * @param name defines the block name
  69111. */
  69112. constructor(name: string);
  69113. /**
  69114. * Gets the current class name
  69115. * @returns the class name
  69116. */
  69117. getClassName(): string;
  69118. /**
  69119. * Gets the input vector
  69120. */
  69121. get input(): NodeMaterialConnectionPoint;
  69122. /**
  69123. * Gets the input angle
  69124. */
  69125. get angle(): NodeMaterialConnectionPoint;
  69126. /**
  69127. * Gets the output component
  69128. */
  69129. get output(): NodeMaterialConnectionPoint;
  69130. autoConfigure(material: NodeMaterial): void;
  69131. protected _buildBlock(state: NodeMaterialBuildState): this;
  69132. }
  69133. }
  69134. declare module BABYLON {
  69135. /**
  69136. * Block used to get the reflected vector from a direction and a normal
  69137. */
  69138. export class ReflectBlock extends NodeMaterialBlock {
  69139. /**
  69140. * Creates a new ReflectBlock
  69141. * @param name defines the block name
  69142. */
  69143. constructor(name: string);
  69144. /**
  69145. * Gets the current class name
  69146. * @returns the class name
  69147. */
  69148. getClassName(): string;
  69149. /**
  69150. * Gets the incident component
  69151. */
  69152. get incident(): NodeMaterialConnectionPoint;
  69153. /**
  69154. * Gets the normal component
  69155. */
  69156. get normal(): NodeMaterialConnectionPoint;
  69157. /**
  69158. * Gets the output component
  69159. */
  69160. get output(): NodeMaterialConnectionPoint;
  69161. protected _buildBlock(state: NodeMaterialBuildState): this;
  69162. }
  69163. }
  69164. declare module BABYLON {
  69165. /**
  69166. * Block used to get the refracted vector from a direction and a normal
  69167. */
  69168. export class RefractBlock extends NodeMaterialBlock {
  69169. /**
  69170. * Creates a new RefractBlock
  69171. * @param name defines the block name
  69172. */
  69173. constructor(name: string);
  69174. /**
  69175. * Gets the current class name
  69176. * @returns the class name
  69177. */
  69178. getClassName(): string;
  69179. /**
  69180. * Gets the incident component
  69181. */
  69182. get incident(): NodeMaterialConnectionPoint;
  69183. /**
  69184. * Gets the normal component
  69185. */
  69186. get normal(): NodeMaterialConnectionPoint;
  69187. /**
  69188. * Gets the index of refraction component
  69189. */
  69190. get ior(): NodeMaterialConnectionPoint;
  69191. /**
  69192. * Gets the output component
  69193. */
  69194. get output(): NodeMaterialConnectionPoint;
  69195. protected _buildBlock(state: NodeMaterialBuildState): this;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * Block used to desaturate a color
  69201. */
  69202. export class DesaturateBlock extends NodeMaterialBlock {
  69203. /**
  69204. * Creates a new DesaturateBlock
  69205. * @param name defines the block name
  69206. */
  69207. constructor(name: string);
  69208. /**
  69209. * Gets the current class name
  69210. * @returns the class name
  69211. */
  69212. getClassName(): string;
  69213. /**
  69214. * Gets the color operand input component
  69215. */
  69216. get color(): NodeMaterialConnectionPoint;
  69217. /**
  69218. * Gets the level operand input component
  69219. */
  69220. get level(): NodeMaterialConnectionPoint;
  69221. /**
  69222. * Gets the output component
  69223. */
  69224. get output(): NodeMaterialConnectionPoint;
  69225. protected _buildBlock(state: NodeMaterialBuildState): this;
  69226. }
  69227. }
  69228. declare module BABYLON {
  69229. /**
  69230. * Block used to implement the reflection module of the PBR material
  69231. */
  69232. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69233. /** @hidden */
  69234. _defineLODReflectionAlpha: string;
  69235. /** @hidden */
  69236. _defineLinearSpecularReflection: string;
  69237. private _vEnvironmentIrradianceName;
  69238. /** @hidden */
  69239. _vReflectionMicrosurfaceInfosName: string;
  69240. /** @hidden */
  69241. _vReflectionInfosName: string;
  69242. /** @hidden */
  69243. _vReflectionFilteringInfoName: string;
  69244. private _scene;
  69245. /**
  69246. * The properties below are set by the main PBR block prior to calling methods of this class.
  69247. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69248. * It's less burden on the user side in the editor part.
  69249. */
  69250. /** @hidden */
  69251. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69252. /** @hidden */
  69253. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69254. /** @hidden */
  69255. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69256. /** @hidden */
  69257. viewConnectionPoint: NodeMaterialConnectionPoint;
  69258. /**
  69259. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69260. * diffuse part of the IBL.
  69261. */
  69262. useSphericalHarmonics: boolean;
  69263. /**
  69264. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69265. */
  69266. forceIrradianceInFragment: boolean;
  69267. /**
  69268. * Create a new ReflectionBlock
  69269. * @param name defines the block name
  69270. */
  69271. constructor(name: string);
  69272. /**
  69273. * Gets the current class name
  69274. * @returns the class name
  69275. */
  69276. getClassName(): string;
  69277. /**
  69278. * Gets the position input component
  69279. */
  69280. get position(): NodeMaterialConnectionPoint;
  69281. /**
  69282. * Gets the world position input component
  69283. */
  69284. get worldPosition(): NodeMaterialConnectionPoint;
  69285. /**
  69286. * Gets the world normal input component
  69287. */
  69288. get worldNormal(): NodeMaterialConnectionPoint;
  69289. /**
  69290. * Gets the world input component
  69291. */
  69292. get world(): NodeMaterialConnectionPoint;
  69293. /**
  69294. * Gets the camera (or eye) position component
  69295. */
  69296. get cameraPosition(): NodeMaterialConnectionPoint;
  69297. /**
  69298. * Gets the view input component
  69299. */
  69300. get view(): NodeMaterialConnectionPoint;
  69301. /**
  69302. * Gets the color input component
  69303. */
  69304. get color(): NodeMaterialConnectionPoint;
  69305. /**
  69306. * Gets the reflection object output component
  69307. */
  69308. get reflection(): NodeMaterialConnectionPoint;
  69309. /**
  69310. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69311. */
  69312. get hasTexture(): boolean;
  69313. /**
  69314. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69315. */
  69316. get reflectionColor(): string;
  69317. protected _getTexture(): Nullable<BaseTexture>;
  69318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69320. /**
  69321. * Gets the code to inject in the vertex shader
  69322. * @param state current state of the node material building
  69323. * @returns the shader code
  69324. */
  69325. handleVertexSide(state: NodeMaterialBuildState): string;
  69326. /**
  69327. * Gets the main code of the block (fragment side)
  69328. * @param state current state of the node material building
  69329. * @param normalVarName name of the existing variable corresponding to the normal
  69330. * @returns the shader code
  69331. */
  69332. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69333. protected _buildBlock(state: NodeMaterialBuildState): this;
  69334. protected _dumpPropertiesCode(): string;
  69335. serialize(): any;
  69336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69337. }
  69338. }
  69339. declare module BABYLON {
  69340. /**
  69341. * Block used to implement the sheen module of the PBR material
  69342. */
  69343. export class SheenBlock extends NodeMaterialBlock {
  69344. /**
  69345. * Create a new SheenBlock
  69346. * @param name defines the block name
  69347. */
  69348. constructor(name: string);
  69349. /**
  69350. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69351. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69352. * making it easier to setup and tweak the effect
  69353. */
  69354. albedoScaling: boolean;
  69355. /**
  69356. * Defines if the sheen is linked to the sheen color.
  69357. */
  69358. linkSheenWithAlbedo: boolean;
  69359. /**
  69360. * Initialize the block and prepare the context for build
  69361. * @param state defines the state that will be used for the build
  69362. */
  69363. initialize(state: NodeMaterialBuildState): void;
  69364. /**
  69365. * Gets the current class name
  69366. * @returns the class name
  69367. */
  69368. getClassName(): string;
  69369. /**
  69370. * Gets the intensity input component
  69371. */
  69372. get intensity(): NodeMaterialConnectionPoint;
  69373. /**
  69374. * Gets the color input component
  69375. */
  69376. get color(): NodeMaterialConnectionPoint;
  69377. /**
  69378. * Gets the roughness input component
  69379. */
  69380. get roughness(): NodeMaterialConnectionPoint;
  69381. /**
  69382. * Gets the sheen object output component
  69383. */
  69384. get sheen(): NodeMaterialConnectionPoint;
  69385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69386. /**
  69387. * Gets the main code of the block (fragment side)
  69388. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69389. * @returns the shader code
  69390. */
  69391. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69392. protected _buildBlock(state: NodeMaterialBuildState): this;
  69393. protected _dumpPropertiesCode(): string;
  69394. serialize(): any;
  69395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * Block used to implement the anisotropy module of the PBR material
  69401. */
  69402. export class AnisotropyBlock extends NodeMaterialBlock {
  69403. /**
  69404. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69405. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69406. * It's less burden on the user side in the editor part.
  69407. */
  69408. /** @hidden */
  69409. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69410. /** @hidden */
  69411. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69412. /**
  69413. * Create a new AnisotropyBlock
  69414. * @param name defines the block name
  69415. */
  69416. constructor(name: string);
  69417. /**
  69418. * Initialize the block and prepare the context for build
  69419. * @param state defines the state that will be used for the build
  69420. */
  69421. initialize(state: NodeMaterialBuildState): void;
  69422. /**
  69423. * Gets the current class name
  69424. * @returns the class name
  69425. */
  69426. getClassName(): string;
  69427. /**
  69428. * Gets the intensity input component
  69429. */
  69430. get intensity(): NodeMaterialConnectionPoint;
  69431. /**
  69432. * Gets the direction input component
  69433. */
  69434. get direction(): NodeMaterialConnectionPoint;
  69435. /**
  69436. * Gets the uv input component
  69437. */
  69438. get uv(): NodeMaterialConnectionPoint;
  69439. /**
  69440. * Gets the worldTangent input component
  69441. */
  69442. get worldTangent(): NodeMaterialConnectionPoint;
  69443. /**
  69444. * Gets the anisotropy object output component
  69445. */
  69446. get anisotropy(): NodeMaterialConnectionPoint;
  69447. private _generateTBNSpace;
  69448. /**
  69449. * Gets the main code of the block (fragment side)
  69450. * @param state current state of the node material building
  69451. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69452. * @returns the shader code
  69453. */
  69454. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69456. protected _buildBlock(state: NodeMaterialBuildState): this;
  69457. }
  69458. }
  69459. declare module BABYLON {
  69460. /**
  69461. * Block used to implement the clear coat module of the PBR material
  69462. */
  69463. export class ClearCoatBlock extends NodeMaterialBlock {
  69464. private _scene;
  69465. /**
  69466. * Create a new ClearCoatBlock
  69467. * @param name defines the block name
  69468. */
  69469. constructor(name: string);
  69470. /**
  69471. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69472. */
  69473. remapF0OnInterfaceChange: boolean;
  69474. /**
  69475. * Initialize the block and prepare the context for build
  69476. * @param state defines the state that will be used for the build
  69477. */
  69478. initialize(state: NodeMaterialBuildState): void;
  69479. /**
  69480. * Gets the current class name
  69481. * @returns the class name
  69482. */
  69483. getClassName(): string;
  69484. /**
  69485. * Gets the intensity input component
  69486. */
  69487. get intensity(): NodeMaterialConnectionPoint;
  69488. /**
  69489. * Gets the roughness input component
  69490. */
  69491. get roughness(): NodeMaterialConnectionPoint;
  69492. /**
  69493. * Gets the ior input component
  69494. */
  69495. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69496. /**
  69497. * Gets the bump texture input component
  69498. */
  69499. get normalMapColor(): NodeMaterialConnectionPoint;
  69500. /**
  69501. * Gets the uv input component
  69502. */
  69503. get uv(): NodeMaterialConnectionPoint;
  69504. /**
  69505. * Gets the tint color input component
  69506. */
  69507. get tintColor(): NodeMaterialConnectionPoint;
  69508. /**
  69509. * Gets the tint "at distance" input component
  69510. */
  69511. get tintAtDistance(): NodeMaterialConnectionPoint;
  69512. /**
  69513. * Gets the tint thickness input component
  69514. */
  69515. get tintThickness(): NodeMaterialConnectionPoint;
  69516. /**
  69517. * Gets the world tangent input component
  69518. */
  69519. get worldTangent(): NodeMaterialConnectionPoint;
  69520. /**
  69521. * Gets the clear coat object output component
  69522. */
  69523. get clearcoat(): NodeMaterialConnectionPoint;
  69524. autoConfigure(material: NodeMaterial): void;
  69525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69527. private _generateTBNSpace;
  69528. /**
  69529. * Gets the main code of the block (fragment side)
  69530. * @param state current state of the node material building
  69531. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69532. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69533. * @param worldPosVarName name of the variable holding the world position
  69534. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69535. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69536. * @param worldNormalVarName name of the variable holding the world normal
  69537. * @returns the shader code
  69538. */
  69539. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69540. protected _buildBlock(state: NodeMaterialBuildState): this;
  69541. protected _dumpPropertiesCode(): string;
  69542. serialize(): any;
  69543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69544. }
  69545. }
  69546. declare module BABYLON {
  69547. /**
  69548. * Block used to implement the sub surface module of the PBR material
  69549. */
  69550. export class SubSurfaceBlock extends NodeMaterialBlock {
  69551. /**
  69552. * Create a new SubSurfaceBlock
  69553. * @param name defines the block name
  69554. */
  69555. constructor(name: string);
  69556. /**
  69557. * Initialize the block and prepare the context for build
  69558. * @param state defines the state that will be used for the build
  69559. */
  69560. initialize(state: NodeMaterialBuildState): void;
  69561. /**
  69562. * Gets the current class name
  69563. * @returns the class name
  69564. */
  69565. getClassName(): string;
  69566. /**
  69567. * Gets the thickness component
  69568. */
  69569. get thickness(): NodeMaterialConnectionPoint;
  69570. /**
  69571. * Gets the tint color input component
  69572. */
  69573. get tintColor(): NodeMaterialConnectionPoint;
  69574. /**
  69575. * Gets the translucency intensity input component
  69576. */
  69577. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69578. /**
  69579. * Gets the translucency diffusion distance input component
  69580. */
  69581. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69582. /**
  69583. * Gets the refraction object parameters
  69584. */
  69585. get refraction(): NodeMaterialConnectionPoint;
  69586. /**
  69587. * Gets the sub surface object output component
  69588. */
  69589. get subsurface(): NodeMaterialConnectionPoint;
  69590. autoConfigure(material: NodeMaterial): void;
  69591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69592. /**
  69593. * Gets the main code of the block (fragment side)
  69594. * @param state current state of the node material building
  69595. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69596. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69597. * @param worldPosVarName name of the variable holding the world position
  69598. * @returns the shader code
  69599. */
  69600. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69601. protected _buildBlock(state: NodeMaterialBuildState): this;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. /**
  69606. * Block used to implement the PBR metallic/roughness model
  69607. */
  69608. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69609. /**
  69610. * Gets or sets the light associated with this block
  69611. */
  69612. light: Nullable<Light>;
  69613. private _lightId;
  69614. private _scene;
  69615. private _environmentBRDFTexture;
  69616. private _environmentBrdfSamplerName;
  69617. private _vNormalWName;
  69618. private _invertNormalName;
  69619. private _metallicReflectanceColor;
  69620. private _metallicF0Factor;
  69621. private _vMetallicReflectanceFactorsName;
  69622. /**
  69623. * Create a new ReflectionBlock
  69624. * @param name defines the block name
  69625. */
  69626. constructor(name: string);
  69627. /**
  69628. * Intensity of the direct lights e.g. the four lights available in your scene.
  69629. * This impacts both the direct diffuse and specular highlights.
  69630. */
  69631. directIntensity: number;
  69632. /**
  69633. * Intensity of the environment e.g. how much the environment will light the object
  69634. * either through harmonics for rough material or through the reflection for shiny ones.
  69635. */
  69636. environmentIntensity: number;
  69637. /**
  69638. * This is a special control allowing the reduction of the specular highlights coming from the
  69639. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69640. */
  69641. specularIntensity: number;
  69642. /**
  69643. * Defines the falloff type used in this material.
  69644. * It by default is Physical.
  69645. */
  69646. lightFalloff: number;
  69647. /**
  69648. * Specifies that alpha test should be used
  69649. */
  69650. useAlphaTest: boolean;
  69651. /**
  69652. * Defines the alpha limits in alpha test mode.
  69653. */
  69654. alphaTestCutoff: number;
  69655. /**
  69656. * Specifies that alpha blending should be used
  69657. */
  69658. useAlphaBlending: boolean;
  69659. /**
  69660. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69661. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69662. */
  69663. useRadianceOverAlpha: boolean;
  69664. /**
  69665. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69666. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69667. */
  69668. useSpecularOverAlpha: boolean;
  69669. /**
  69670. * Enables specular anti aliasing in the PBR shader.
  69671. * It will both interacts on the Geometry for analytical and IBL lighting.
  69672. * It also prefilter the roughness map based on the bump values.
  69673. */
  69674. enableSpecularAntiAliasing: boolean;
  69675. /**
  69676. * Enables realtime filtering on the texture.
  69677. */
  69678. realTimeFiltering: boolean;
  69679. /**
  69680. * Quality switch for realtime filtering
  69681. */
  69682. realTimeFilteringQuality: number;
  69683. /**
  69684. * Defines if the material uses energy conservation.
  69685. */
  69686. useEnergyConservation: boolean;
  69687. /**
  69688. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69689. * too much the area relying on ambient texture to define their ambient occlusion.
  69690. */
  69691. useRadianceOcclusion: boolean;
  69692. /**
  69693. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69694. * makes the reflect vector face the model (under horizon).
  69695. */
  69696. useHorizonOcclusion: boolean;
  69697. /**
  69698. * If set to true, no lighting calculations will be applied.
  69699. */
  69700. unlit: boolean;
  69701. /**
  69702. * Force normal to face away from face.
  69703. */
  69704. forceNormalForward: boolean;
  69705. /**
  69706. * Defines the material debug mode.
  69707. * It helps seeing only some components of the material while troubleshooting.
  69708. */
  69709. debugMode: number;
  69710. /**
  69711. * Specify from where on screen the debug mode should start.
  69712. * The value goes from -1 (full screen) to 1 (not visible)
  69713. * It helps with side by side comparison against the final render
  69714. * This defaults to 0
  69715. */
  69716. debugLimit: number;
  69717. /**
  69718. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69719. * You can use the factor to better multiply the final value.
  69720. */
  69721. debugFactor: number;
  69722. /**
  69723. * Initialize the block and prepare the context for build
  69724. * @param state defines the state that will be used for the build
  69725. */
  69726. initialize(state: NodeMaterialBuildState): void;
  69727. /**
  69728. * Gets the current class name
  69729. * @returns the class name
  69730. */
  69731. getClassName(): string;
  69732. /**
  69733. * Gets the world position input component
  69734. */
  69735. get worldPosition(): NodeMaterialConnectionPoint;
  69736. /**
  69737. * Gets the world normal input component
  69738. */
  69739. get worldNormal(): NodeMaterialConnectionPoint;
  69740. /**
  69741. * Gets the view matrix parameter
  69742. */
  69743. get view(): NodeMaterialConnectionPoint;
  69744. /**
  69745. * Gets the camera position input component
  69746. */
  69747. get cameraPosition(): NodeMaterialConnectionPoint;
  69748. /**
  69749. * Gets the perturbed normal input component
  69750. */
  69751. get perturbedNormal(): NodeMaterialConnectionPoint;
  69752. /**
  69753. * Gets the base color input component
  69754. */
  69755. get baseColor(): NodeMaterialConnectionPoint;
  69756. /**
  69757. * Gets the metallic input component
  69758. */
  69759. get metallic(): NodeMaterialConnectionPoint;
  69760. /**
  69761. * Gets the roughness input component
  69762. */
  69763. get roughness(): NodeMaterialConnectionPoint;
  69764. /**
  69765. * Gets the ambient occlusion input component
  69766. */
  69767. get ambientOcc(): NodeMaterialConnectionPoint;
  69768. /**
  69769. * Gets the opacity input component
  69770. */
  69771. get opacity(): NodeMaterialConnectionPoint;
  69772. /**
  69773. * Gets the index of refraction input component
  69774. */
  69775. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69776. /**
  69777. * Gets the ambient color input component
  69778. */
  69779. get ambientColor(): NodeMaterialConnectionPoint;
  69780. /**
  69781. * Gets the reflection object parameters
  69782. */
  69783. get reflection(): NodeMaterialConnectionPoint;
  69784. /**
  69785. * Gets the clear coat object parameters
  69786. */
  69787. get clearcoat(): NodeMaterialConnectionPoint;
  69788. /**
  69789. * Gets the sheen object parameters
  69790. */
  69791. get sheen(): NodeMaterialConnectionPoint;
  69792. /**
  69793. * Gets the sub surface object parameters
  69794. */
  69795. get subsurface(): NodeMaterialConnectionPoint;
  69796. /**
  69797. * Gets the anisotropy object parameters
  69798. */
  69799. get anisotropy(): NodeMaterialConnectionPoint;
  69800. /**
  69801. * Gets the ambient output component
  69802. */
  69803. get ambientClr(): NodeMaterialConnectionPoint;
  69804. /**
  69805. * Gets the diffuse output component
  69806. */
  69807. get diffuseDir(): NodeMaterialConnectionPoint;
  69808. /**
  69809. * Gets the specular output component
  69810. */
  69811. get specularDir(): NodeMaterialConnectionPoint;
  69812. /**
  69813. * Gets the clear coat output component
  69814. */
  69815. get clearcoatDir(): NodeMaterialConnectionPoint;
  69816. /**
  69817. * Gets the sheen output component
  69818. */
  69819. get sheenDir(): NodeMaterialConnectionPoint;
  69820. /**
  69821. * Gets the indirect diffuse output component
  69822. */
  69823. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69824. /**
  69825. * Gets the indirect specular output component
  69826. */
  69827. get specularIndirect(): NodeMaterialConnectionPoint;
  69828. /**
  69829. * Gets the indirect clear coat output component
  69830. */
  69831. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69832. /**
  69833. * Gets the indirect sheen output component
  69834. */
  69835. get sheenIndirect(): NodeMaterialConnectionPoint;
  69836. /**
  69837. * Gets the refraction output component
  69838. */
  69839. get refraction(): NodeMaterialConnectionPoint;
  69840. /**
  69841. * Gets the global lighting output component
  69842. */
  69843. get lighting(): NodeMaterialConnectionPoint;
  69844. /**
  69845. * Gets the shadow output component
  69846. */
  69847. get shadow(): NodeMaterialConnectionPoint;
  69848. /**
  69849. * Gets the alpha output component
  69850. */
  69851. get alpha(): NodeMaterialConnectionPoint;
  69852. autoConfigure(material: NodeMaterial): void;
  69853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69854. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69855. isReady(): boolean;
  69856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69857. private _injectVertexCode;
  69858. private _getAlbedoOpacityCode;
  69859. private _getAmbientOcclusionCode;
  69860. private _getReflectivityCode;
  69861. protected _buildBlock(state: NodeMaterialBuildState): this;
  69862. protected _dumpPropertiesCode(): string;
  69863. serialize(): any;
  69864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69865. }
  69866. }
  69867. declare module BABYLON {
  69868. /**
  69869. * Block used to compute value of one parameter modulo another
  69870. */
  69871. export class ModBlock extends NodeMaterialBlock {
  69872. /**
  69873. * Creates a new ModBlock
  69874. * @param name defines the block name
  69875. */
  69876. constructor(name: string);
  69877. /**
  69878. * Gets the current class name
  69879. * @returns the class name
  69880. */
  69881. getClassName(): string;
  69882. /**
  69883. * Gets the left operand input component
  69884. */
  69885. get left(): NodeMaterialConnectionPoint;
  69886. /**
  69887. * Gets the right operand input component
  69888. */
  69889. get right(): NodeMaterialConnectionPoint;
  69890. /**
  69891. * Gets the output component
  69892. */
  69893. get output(): NodeMaterialConnectionPoint;
  69894. protected _buildBlock(state: NodeMaterialBuildState): this;
  69895. }
  69896. }
  69897. declare module BABYLON {
  69898. /**
  69899. * Configuration for Draco compression
  69900. */
  69901. export interface IDracoCompressionConfiguration {
  69902. /**
  69903. * Configuration for the decoder.
  69904. */
  69905. decoder: {
  69906. /**
  69907. * The url to the WebAssembly module.
  69908. */
  69909. wasmUrl?: string;
  69910. /**
  69911. * The url to the WebAssembly binary.
  69912. */
  69913. wasmBinaryUrl?: string;
  69914. /**
  69915. * The url to the fallback JavaScript module.
  69916. */
  69917. fallbackUrl?: string;
  69918. };
  69919. }
  69920. /**
  69921. * Draco compression (https://google.github.io/draco/)
  69922. *
  69923. * This class wraps the Draco module.
  69924. *
  69925. * **Encoder**
  69926. *
  69927. * The encoder is not currently implemented.
  69928. *
  69929. * **Decoder**
  69930. *
  69931. * 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.
  69932. *
  69933. * To update the configuration, use the following code:
  69934. * ```javascript
  69935. * DracoCompression.Configuration = {
  69936. * decoder: {
  69937. * wasmUrl: "<url to the WebAssembly library>",
  69938. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69939. * fallbackUrl: "<url to the fallback JavaScript library>",
  69940. * }
  69941. * };
  69942. * ```
  69943. *
  69944. * 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.
  69945. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69946. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69947. *
  69948. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69949. * ```javascript
  69950. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69951. * ```
  69952. *
  69953. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69954. */
  69955. export class DracoCompression implements IDisposable {
  69956. private _workerPoolPromise?;
  69957. private _decoderModulePromise?;
  69958. /**
  69959. * The configuration. Defaults to the following urls:
  69960. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69961. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69962. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69963. */
  69964. static Configuration: IDracoCompressionConfiguration;
  69965. /**
  69966. * Returns true if the decoder configuration is available.
  69967. */
  69968. static get DecoderAvailable(): boolean;
  69969. /**
  69970. * Default number of workers to create when creating the draco compression object.
  69971. */
  69972. static DefaultNumWorkers: number;
  69973. private static GetDefaultNumWorkers;
  69974. private static _Default;
  69975. /**
  69976. * Default instance for the draco compression object.
  69977. */
  69978. static get Default(): DracoCompression;
  69979. /**
  69980. * Constructor
  69981. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69982. */
  69983. constructor(numWorkers?: number);
  69984. /**
  69985. * Stop all async operations and release resources.
  69986. */
  69987. dispose(): void;
  69988. /**
  69989. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69990. * @returns a promise that resolves when ready
  69991. */
  69992. whenReadyAsync(): Promise<void>;
  69993. /**
  69994. * Decode Draco compressed mesh data to vertex data.
  69995. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69996. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69997. * @returns A promise that resolves with the decoded vertex data
  69998. */
  69999. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70000. [kind: string]: number;
  70001. }): Promise<VertexData>;
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * Class for building Constructive Solid Geometry
  70007. */
  70008. export class CSG {
  70009. private polygons;
  70010. /**
  70011. * The world matrix
  70012. */
  70013. matrix: Matrix;
  70014. /**
  70015. * Stores the position
  70016. */
  70017. position: Vector3;
  70018. /**
  70019. * Stores the rotation
  70020. */
  70021. rotation: Vector3;
  70022. /**
  70023. * Stores the rotation quaternion
  70024. */
  70025. rotationQuaternion: Nullable<Quaternion>;
  70026. /**
  70027. * Stores the scaling vector
  70028. */
  70029. scaling: Vector3;
  70030. /**
  70031. * Convert the Mesh to CSG
  70032. * @param mesh The Mesh to convert to CSG
  70033. * @returns A new CSG from the Mesh
  70034. */
  70035. static FromMesh(mesh: Mesh): CSG;
  70036. /**
  70037. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70038. * @param polygons Polygons used to construct a CSG solid
  70039. */
  70040. private static FromPolygons;
  70041. /**
  70042. * Clones, or makes a deep copy, of the CSG
  70043. * @returns A new CSG
  70044. */
  70045. clone(): CSG;
  70046. /**
  70047. * Unions this CSG with another CSG
  70048. * @param csg The CSG to union against this CSG
  70049. * @returns The unioned CSG
  70050. */
  70051. union(csg: CSG): CSG;
  70052. /**
  70053. * Unions this CSG with another CSG in place
  70054. * @param csg The CSG to union against this CSG
  70055. */
  70056. unionInPlace(csg: CSG): void;
  70057. /**
  70058. * Subtracts this CSG with another CSG
  70059. * @param csg The CSG to subtract against this CSG
  70060. * @returns A new CSG
  70061. */
  70062. subtract(csg: CSG): CSG;
  70063. /**
  70064. * Subtracts this CSG with another CSG in place
  70065. * @param csg The CSG to subtract against this CSG
  70066. */
  70067. subtractInPlace(csg: CSG): void;
  70068. /**
  70069. * Intersect this CSG with another CSG
  70070. * @param csg The CSG to intersect against this CSG
  70071. * @returns A new CSG
  70072. */
  70073. intersect(csg: CSG): CSG;
  70074. /**
  70075. * Intersects this CSG with another CSG in place
  70076. * @param csg The CSG to intersect against this CSG
  70077. */
  70078. intersectInPlace(csg: CSG): void;
  70079. /**
  70080. * Return a new CSG solid with solid and empty space switched. This solid is
  70081. * not modified.
  70082. * @returns A new CSG solid with solid and empty space switched
  70083. */
  70084. inverse(): CSG;
  70085. /**
  70086. * Inverses the CSG in place
  70087. */
  70088. inverseInPlace(): void;
  70089. /**
  70090. * This is used to keep meshes transformations so they can be restored
  70091. * when we build back a Babylon Mesh
  70092. * NB : All CSG operations are performed in world coordinates
  70093. * @param csg The CSG to copy the transform attributes from
  70094. * @returns This CSG
  70095. */
  70096. copyTransformAttributes(csg: CSG): CSG;
  70097. /**
  70098. * Build Raw mesh from CSG
  70099. * Coordinates here are in world space
  70100. * @param name The name of the mesh geometry
  70101. * @param scene The Scene
  70102. * @param keepSubMeshes Specifies if the submeshes should be kept
  70103. * @returns A new Mesh
  70104. */
  70105. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70106. /**
  70107. * Build Mesh from CSG taking material and transforms into account
  70108. * @param name The name of the Mesh
  70109. * @param material The material of the Mesh
  70110. * @param scene The Scene
  70111. * @param keepSubMeshes Specifies if submeshes should be kept
  70112. * @returns The new Mesh
  70113. */
  70114. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /**
  70119. * Class used to create a trail following a mesh
  70120. */
  70121. export class TrailMesh extends Mesh {
  70122. private _generator;
  70123. private _autoStart;
  70124. private _running;
  70125. private _diameter;
  70126. private _length;
  70127. private _sectionPolygonPointsCount;
  70128. private _sectionVectors;
  70129. private _sectionNormalVectors;
  70130. private _beforeRenderObserver;
  70131. /**
  70132. * @constructor
  70133. * @param name The value used by scene.getMeshByName() to do a lookup.
  70134. * @param generator The mesh or transform node to generate a trail.
  70135. * @param scene The scene to add this mesh to.
  70136. * @param diameter Diameter of trailing mesh. Default is 1.
  70137. * @param length Length of trailing mesh. Default is 60.
  70138. * @param autoStart Automatically start trailing mesh. Default true.
  70139. */
  70140. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70141. /**
  70142. * "TrailMesh"
  70143. * @returns "TrailMesh"
  70144. */
  70145. getClassName(): string;
  70146. private _createMesh;
  70147. /**
  70148. * Start trailing mesh.
  70149. */
  70150. start(): void;
  70151. /**
  70152. * Stop trailing mesh.
  70153. */
  70154. stop(): void;
  70155. /**
  70156. * Update trailing mesh geometry.
  70157. */
  70158. update(): void;
  70159. /**
  70160. * Returns a new TrailMesh object.
  70161. * @param name is a string, the name given to the new mesh
  70162. * @param newGenerator use new generator object for cloned trail mesh
  70163. * @returns a new mesh
  70164. */
  70165. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70166. /**
  70167. * Serializes this trail mesh
  70168. * @param serializationObject object to write serialization to
  70169. */
  70170. serialize(serializationObject: any): void;
  70171. /**
  70172. * Parses a serialized trail mesh
  70173. * @param parsedMesh the serialized mesh
  70174. * @param scene the scene to create the trail mesh in
  70175. * @returns the created trail mesh
  70176. */
  70177. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70178. }
  70179. }
  70180. declare module BABYLON {
  70181. /**
  70182. * Class containing static functions to help procedurally build meshes
  70183. */
  70184. export class TiledBoxBuilder {
  70185. /**
  70186. * Creates a box mesh
  70187. * 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)
  70188. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70190. * * 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
  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 box mesh
  70196. */
  70197. static CreateTiledBox(name: string, options: {
  70198. pattern?: number;
  70199. width?: number;
  70200. height?: number;
  70201. depth?: number;
  70202. tileSize?: number;
  70203. tileWidth?: number;
  70204. tileHeight?: number;
  70205. alignHorizontal?: number;
  70206. alignVertical?: number;
  70207. faceUV?: Vector4[];
  70208. faceColors?: Color4[];
  70209. sideOrientation?: number;
  70210. updatable?: 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 TorusKnotBuilder {
  70219. /**
  70220. * Creates a torus knot mesh
  70221. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70222. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70223. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70224. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70226. * * 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
  70227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70228. * @param name defines the name of the mesh
  70229. * @param options defines the options used to create the mesh
  70230. * @param scene defines the hosting scene
  70231. * @returns the torus knot mesh
  70232. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70233. */
  70234. static CreateTorusKnot(name: string, options: {
  70235. radius?: number;
  70236. tube?: number;
  70237. radialSegments?: number;
  70238. tubularSegments?: number;
  70239. p?: number;
  70240. q?: number;
  70241. updatable?: boolean;
  70242. sideOrientation?: number;
  70243. frontUVs?: Vector4;
  70244. backUVs?: Vector4;
  70245. }, scene: any): Mesh;
  70246. }
  70247. }
  70248. declare module BABYLON {
  70249. /**
  70250. * Polygon
  70251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70252. */
  70253. export class Polygon {
  70254. /**
  70255. * Creates a rectangle
  70256. * @param xmin bottom X coord
  70257. * @param ymin bottom Y coord
  70258. * @param xmax top X coord
  70259. * @param ymax top Y coord
  70260. * @returns points that make the resulting rectangle
  70261. */
  70262. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70263. /**
  70264. * Creates a circle
  70265. * @param radius radius of circle
  70266. * @param cx scale in x
  70267. * @param cy scale in y
  70268. * @param numberOfSides number of sides that make up the circle
  70269. * @returns points that make the resulting circle
  70270. */
  70271. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70272. /**
  70273. * Creates a polygon from input string
  70274. * @param input Input polygon data
  70275. * @returns the parsed points
  70276. */
  70277. static Parse(input: string): Vector2[];
  70278. /**
  70279. * Starts building a polygon from x and y coordinates
  70280. * @param x x coordinate
  70281. * @param y y coordinate
  70282. * @returns the started path2
  70283. */
  70284. static StartingAt(x: number, y: number): Path2;
  70285. }
  70286. /**
  70287. * Builds a polygon
  70288. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70289. */
  70290. export class PolygonMeshBuilder {
  70291. private _points;
  70292. private _outlinepoints;
  70293. private _holes;
  70294. private _name;
  70295. private _scene;
  70296. private _epoints;
  70297. private _eholes;
  70298. private _addToepoint;
  70299. /**
  70300. * Babylon reference to the earcut plugin.
  70301. */
  70302. bjsEarcut: any;
  70303. /**
  70304. * Creates a PolygonMeshBuilder
  70305. * @param name name of the builder
  70306. * @param contours Path of the polygon
  70307. * @param scene scene to add to when creating the mesh
  70308. * @param earcutInjection can be used to inject your own earcut reference
  70309. */
  70310. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70311. /**
  70312. * Adds a hole within the polygon
  70313. * @param hole Array of points defining the hole
  70314. * @returns this
  70315. */
  70316. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70317. /**
  70318. * Creates the polygon
  70319. * @param updatable If the mesh should be updatable
  70320. * @param depth The depth of the mesh created
  70321. * @param smoothingThreshold Dot product threshold for smoothed normals
  70322. * @returns the created mesh
  70323. */
  70324. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70325. /**
  70326. * Creates the polygon
  70327. * @param depth The depth of the mesh created
  70328. * @param smoothingThreshold Dot product threshold for smoothed normals
  70329. * @returns the created VertexData
  70330. */
  70331. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70332. /**
  70333. * Adds a side to the polygon
  70334. * @param positions points that make the polygon
  70335. * @param normals normals of the polygon
  70336. * @param uvs uvs of the polygon
  70337. * @param indices indices of the polygon
  70338. * @param bounds bounds of the polygon
  70339. * @param points points of the polygon
  70340. * @param depth depth of the polygon
  70341. * @param flip flip of the polygon
  70342. */
  70343. private addSide;
  70344. }
  70345. }
  70346. declare module BABYLON {
  70347. /**
  70348. * Class containing static functions to help procedurally build meshes
  70349. */
  70350. export class PolygonBuilder {
  70351. /**
  70352. * Creates a polygon mesh
  70353. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70354. * * 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
  70355. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70357. * * 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)
  70358. * * Remember you can only change the shape positions, not their number when updating a polygon
  70359. * @param name defines the name of the mesh
  70360. * @param options defines the options used to create the mesh
  70361. * @param scene defines the hosting scene
  70362. * @param earcutInjection can be used to inject your own earcut reference
  70363. * @returns the polygon mesh
  70364. */
  70365. static CreatePolygon(name: string, options: {
  70366. shape: Vector3[];
  70367. holes?: Vector3[][];
  70368. depth?: number;
  70369. smoothingThreshold?: number;
  70370. faceUV?: Vector4[];
  70371. faceColors?: Color4[];
  70372. updatable?: boolean;
  70373. sideOrientation?: number;
  70374. frontUVs?: Vector4;
  70375. backUVs?: Vector4;
  70376. wrap?: boolean;
  70377. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70378. /**
  70379. * Creates an extruded polygon mesh, with depth in the Y direction.
  70380. * * 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)
  70381. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70382. * @param name defines the name of the mesh
  70383. * @param options defines the options used to create the mesh
  70384. * @param scene defines the hosting scene
  70385. * @param earcutInjection can be used to inject your own earcut reference
  70386. * @returns the polygon mesh
  70387. */
  70388. static ExtrudePolygon(name: string, options: {
  70389. shape: Vector3[];
  70390. holes?: Vector3[][];
  70391. depth?: number;
  70392. faceUV?: Vector4[];
  70393. faceColors?: Color4[];
  70394. updatable?: boolean;
  70395. sideOrientation?: number;
  70396. frontUVs?: Vector4;
  70397. backUVs?: Vector4;
  70398. wrap?: boolean;
  70399. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70400. }
  70401. }
  70402. declare module BABYLON {
  70403. /**
  70404. * Class containing static functions to help procedurally build meshes
  70405. */
  70406. export class LatheBuilder {
  70407. /**
  70408. * Creates lathe mesh.
  70409. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70410. * * 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
  70411. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70412. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70413. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70414. * * 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
  70415. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70416. * * 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
  70417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70418. * * 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
  70419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70421. * @param name defines the name of the mesh
  70422. * @param options defines the options used to create the mesh
  70423. * @param scene defines the hosting scene
  70424. * @returns the lathe mesh
  70425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70426. */
  70427. static CreateLathe(name: string, options: {
  70428. shape: Vector3[];
  70429. radius?: number;
  70430. tessellation?: number;
  70431. clip?: number;
  70432. arc?: number;
  70433. closed?: boolean;
  70434. updatable?: boolean;
  70435. sideOrientation?: number;
  70436. frontUVs?: Vector4;
  70437. backUVs?: Vector4;
  70438. cap?: number;
  70439. invertUV?: boolean;
  70440. }, scene?: Nullable<Scene>): Mesh;
  70441. }
  70442. }
  70443. declare module BABYLON {
  70444. /**
  70445. * Class containing static functions to help procedurally build meshes
  70446. */
  70447. export class TiledPlaneBuilder {
  70448. /**
  70449. * Creates a tiled plane mesh
  70450. * * The parameter `pattern` will, depending on value, do nothing or
  70451. * * * flip (reflect about central vertical) alternate tiles across and up
  70452. * * * flip every tile on alternate rows
  70453. * * * rotate (180 degs) alternate tiles across and up
  70454. * * * rotate every tile on alternate rows
  70455. * * * flip and rotate alternate tiles across and up
  70456. * * * flip and rotate every tile on alternate rows
  70457. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70458. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70459. * * 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
  70460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70461. * * 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)
  70462. * * 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)
  70463. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70464. * @param name defines the name of the mesh
  70465. * @param options defines the options used to create the mesh
  70466. * @param scene defines the hosting scene
  70467. * @returns the box mesh
  70468. */
  70469. static CreateTiledPlane(name: string, options: {
  70470. pattern?: number;
  70471. tileSize?: number;
  70472. tileWidth?: number;
  70473. tileHeight?: number;
  70474. size?: number;
  70475. width?: number;
  70476. height?: number;
  70477. alignHorizontal?: number;
  70478. alignVertical?: number;
  70479. sideOrientation?: number;
  70480. frontUVs?: Vector4;
  70481. backUVs?: Vector4;
  70482. updatable?: boolean;
  70483. }, scene?: Nullable<Scene>): Mesh;
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /**
  70488. * Class containing static functions to help procedurally build meshes
  70489. */
  70490. export class TubeBuilder {
  70491. /**
  70492. * Creates a tube mesh.
  70493. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70494. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70495. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70496. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70497. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70498. * * 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)
  70499. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70500. * * 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
  70501. * * 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
  70502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70503. * * 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
  70504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70506. * @param name defines the name of the mesh
  70507. * @param options defines the options used to create the mesh
  70508. * @param scene defines the hosting scene
  70509. * @returns the tube mesh
  70510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70511. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70512. */
  70513. static CreateTube(name: string, options: {
  70514. path: Vector3[];
  70515. radius?: number;
  70516. tessellation?: number;
  70517. radiusFunction?: {
  70518. (i: number, distance: number): number;
  70519. };
  70520. cap?: number;
  70521. arc?: number;
  70522. updatable?: boolean;
  70523. sideOrientation?: number;
  70524. frontUVs?: Vector4;
  70525. backUVs?: Vector4;
  70526. instance?: Mesh;
  70527. invertUV?: boolean;
  70528. }, scene?: Nullable<Scene>): Mesh;
  70529. }
  70530. }
  70531. declare module BABYLON {
  70532. /**
  70533. * Class containing static functions to help procedurally build meshes
  70534. */
  70535. export class IcoSphereBuilder {
  70536. /**
  70537. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70538. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70539. * * 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`)
  70540. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70541. * * 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
  70542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70543. * * 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
  70544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70545. * @param name defines the name of the mesh
  70546. * @param options defines the options used to create the mesh
  70547. * @param scene defines the hosting scene
  70548. * @returns the icosahedron mesh
  70549. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70550. */
  70551. static CreateIcoSphere(name: string, options: {
  70552. radius?: number;
  70553. radiusX?: number;
  70554. radiusY?: number;
  70555. radiusZ?: number;
  70556. flat?: boolean;
  70557. subdivisions?: number;
  70558. sideOrientation?: number;
  70559. frontUVs?: Vector4;
  70560. backUVs?: Vector4;
  70561. updatable?: boolean;
  70562. }, scene?: Nullable<Scene>): Mesh;
  70563. }
  70564. }
  70565. declare module BABYLON {
  70566. /**
  70567. * Class containing static functions to help procedurally build meshes
  70568. */
  70569. export class DecalBuilder {
  70570. /**
  70571. * Creates a decal mesh.
  70572. * 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
  70573. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70574. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70575. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70576. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70577. * @param name defines the name of the mesh
  70578. * @param sourceMesh defines the mesh where the decal must be applied
  70579. * @param options defines the options used to create the mesh
  70580. * @param scene defines the hosting scene
  70581. * @returns the decal mesh
  70582. * @see https://doc.babylonjs.com/how_to/decals
  70583. */
  70584. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70585. position?: Vector3;
  70586. normal?: Vector3;
  70587. size?: Vector3;
  70588. angle?: number;
  70589. }): Mesh;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /**
  70594. * Class containing static functions to help procedurally build meshes
  70595. */
  70596. export class MeshBuilder {
  70597. /**
  70598. * Creates a box mesh
  70599. * * The parameter `size` sets the size (float) of each box side (default 1)
  70600. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70601. * * 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)
  70602. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70604. * * 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
  70605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70606. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70607. * @param name defines the name of the mesh
  70608. * @param options defines the options used to create the mesh
  70609. * @param scene defines the hosting scene
  70610. * @returns the box mesh
  70611. */
  70612. static CreateBox(name: string, options: {
  70613. size?: number;
  70614. width?: number;
  70615. height?: number;
  70616. depth?: number;
  70617. faceUV?: Vector4[];
  70618. faceColors?: Color4[];
  70619. sideOrientation?: number;
  70620. frontUVs?: Vector4;
  70621. backUVs?: Vector4;
  70622. wrap?: boolean;
  70623. topBaseAt?: number;
  70624. bottomBaseAt?: number;
  70625. updatable?: boolean;
  70626. }, scene?: Nullable<Scene>): Mesh;
  70627. /**
  70628. * Creates a tiled box mesh
  70629. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70631. * @param name defines the name of the mesh
  70632. * @param options defines the options used to create the mesh
  70633. * @param scene defines the hosting scene
  70634. * @returns the tiled box mesh
  70635. */
  70636. static CreateTiledBox(name: string, options: {
  70637. pattern?: number;
  70638. size?: number;
  70639. width?: number;
  70640. height?: number;
  70641. depth: number;
  70642. tileSize?: number;
  70643. tileWidth?: number;
  70644. tileHeight?: number;
  70645. faceUV?: Vector4[];
  70646. faceColors?: Color4[];
  70647. alignHorizontal?: number;
  70648. alignVertical?: number;
  70649. sideOrientation?: number;
  70650. updatable?: boolean;
  70651. }, scene?: Nullable<Scene>): Mesh;
  70652. /**
  70653. * Creates a sphere mesh
  70654. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70655. * * 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`)
  70656. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70657. * * 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
  70658. * * 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)
  70659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70660. * * 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
  70661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70662. * @param name defines the name of the mesh
  70663. * @param options defines the options used to create the mesh
  70664. * @param scene defines the hosting scene
  70665. * @returns the sphere mesh
  70666. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70667. */
  70668. static CreateSphere(name: string, options: {
  70669. segments?: number;
  70670. diameter?: number;
  70671. diameterX?: number;
  70672. diameterY?: number;
  70673. diameterZ?: number;
  70674. arc?: number;
  70675. slice?: number;
  70676. sideOrientation?: number;
  70677. frontUVs?: Vector4;
  70678. backUVs?: Vector4;
  70679. updatable?: boolean;
  70680. }, scene?: Nullable<Scene>): Mesh;
  70681. /**
  70682. * Creates a plane polygonal mesh. By default, this is a disc
  70683. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70684. * * 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
  70685. * * 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
  70686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70687. * * 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
  70688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70689. * @param name defines the name of the mesh
  70690. * @param options defines the options used to create the mesh
  70691. * @param scene defines the hosting scene
  70692. * @returns the plane polygonal mesh
  70693. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70694. */
  70695. static CreateDisc(name: string, options: {
  70696. radius?: number;
  70697. tessellation?: number;
  70698. arc?: number;
  70699. updatable?: boolean;
  70700. sideOrientation?: number;
  70701. frontUVs?: Vector4;
  70702. backUVs?: Vector4;
  70703. }, scene?: Nullable<Scene>): Mesh;
  70704. /**
  70705. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70706. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70707. * * 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`)
  70708. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70709. * * 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
  70710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70711. * * 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
  70712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70713. * @param name defines the name of the mesh
  70714. * @param options defines the options used to create the mesh
  70715. * @param scene defines the hosting scene
  70716. * @returns the icosahedron mesh
  70717. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70718. */
  70719. static CreateIcoSphere(name: string, options: {
  70720. radius?: number;
  70721. radiusX?: number;
  70722. radiusY?: number;
  70723. radiusZ?: number;
  70724. flat?: boolean;
  70725. subdivisions?: number;
  70726. sideOrientation?: number;
  70727. frontUVs?: Vector4;
  70728. backUVs?: Vector4;
  70729. updatable?: boolean;
  70730. }, scene?: Nullable<Scene>): Mesh;
  70731. /**
  70732. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70733. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70734. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70735. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70736. * * 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
  70737. * * 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
  70738. * * 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
  70739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70740. * * 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
  70741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70742. * * 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
  70743. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70744. * * 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
  70745. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70747. * @param name defines the name of the mesh
  70748. * @param options defines the options used to create the mesh
  70749. * @param scene defines the hosting scene
  70750. * @returns the ribbon mesh
  70751. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70753. */
  70754. static CreateRibbon(name: string, options: {
  70755. pathArray: Vector3[][];
  70756. closeArray?: boolean;
  70757. closePath?: boolean;
  70758. offset?: number;
  70759. updatable?: boolean;
  70760. sideOrientation?: number;
  70761. frontUVs?: Vector4;
  70762. backUVs?: Vector4;
  70763. instance?: Mesh;
  70764. invertUV?: boolean;
  70765. uvs?: Vector2[];
  70766. colors?: Color4[];
  70767. }, scene?: Nullable<Scene>): Mesh;
  70768. /**
  70769. * Creates a cylinder or a cone mesh
  70770. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70771. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70772. * * 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.
  70773. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70774. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70775. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70776. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70777. * * 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).
  70778. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70779. * * 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).
  70780. * * 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
  70781. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70782. * * 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
  70783. * * 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.
  70784. * * If `enclose` is false, a ring surface is one element.
  70785. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70786. * * 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
  70787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70788. * * 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
  70789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70790. * @param name defines the name of the mesh
  70791. * @param options defines the options used to create the mesh
  70792. * @param scene defines the hosting scene
  70793. * @returns the cylinder mesh
  70794. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70795. */
  70796. static CreateCylinder(name: string, options: {
  70797. height?: number;
  70798. diameterTop?: number;
  70799. diameterBottom?: number;
  70800. diameter?: number;
  70801. tessellation?: number;
  70802. subdivisions?: number;
  70803. arc?: number;
  70804. faceColors?: Color4[];
  70805. faceUV?: Vector4[];
  70806. updatable?: boolean;
  70807. hasRings?: boolean;
  70808. enclose?: boolean;
  70809. cap?: number;
  70810. sideOrientation?: number;
  70811. frontUVs?: Vector4;
  70812. backUVs?: Vector4;
  70813. }, scene?: Nullable<Scene>): Mesh;
  70814. /**
  70815. * Creates a torus mesh
  70816. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70817. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70818. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70820. * * 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
  70821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70822. * @param name defines the name of the mesh
  70823. * @param options defines the options used to create the mesh
  70824. * @param scene defines the hosting scene
  70825. * @returns the torus mesh
  70826. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70827. */
  70828. static CreateTorus(name: string, options: {
  70829. diameter?: number;
  70830. thickness?: number;
  70831. tessellation?: number;
  70832. updatable?: boolean;
  70833. sideOrientation?: number;
  70834. frontUVs?: Vector4;
  70835. backUVs?: Vector4;
  70836. }, scene?: Nullable<Scene>): Mesh;
  70837. /**
  70838. * Creates a torus knot mesh
  70839. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70840. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70841. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70842. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70844. * * 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
  70845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70846. * @param name defines the name of the mesh
  70847. * @param options defines the options used to create the mesh
  70848. * @param scene defines the hosting scene
  70849. * @returns the torus knot mesh
  70850. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70851. */
  70852. static CreateTorusKnot(name: string, options: {
  70853. radius?: number;
  70854. tube?: number;
  70855. radialSegments?: number;
  70856. tubularSegments?: number;
  70857. p?: number;
  70858. q?: number;
  70859. updatable?: boolean;
  70860. sideOrientation?: number;
  70861. frontUVs?: Vector4;
  70862. backUVs?: Vector4;
  70863. }, scene?: Nullable<Scene>): Mesh;
  70864. /**
  70865. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70866. * * 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
  70867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70868. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70869. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70870. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70871. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70872. * * 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
  70873. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70876. * @param name defines the name of the new line system
  70877. * @param options defines the options used to create the line system
  70878. * @param scene defines the hosting scene
  70879. * @returns a new line system mesh
  70880. */
  70881. static CreateLineSystem(name: string, options: {
  70882. lines: Vector3[][];
  70883. updatable?: boolean;
  70884. instance?: Nullable<LinesMesh>;
  70885. colors?: Nullable<Color4[][]>;
  70886. useVertexAlpha?: boolean;
  70887. }, scene: Nullable<Scene>): LinesMesh;
  70888. /**
  70889. * Creates a line mesh
  70890. * 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
  70891. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70892. * * The parameter `points` is an array successive Vector3
  70893. * * 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
  70894. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70895. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70896. * * When updating an instance, remember that only point positions can change, not the number of points
  70897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70899. * @param name defines the name of the new line system
  70900. * @param options defines the options used to create the line system
  70901. * @param scene defines the hosting scene
  70902. * @returns a new line mesh
  70903. */
  70904. static CreateLines(name: string, options: {
  70905. points: Vector3[];
  70906. updatable?: boolean;
  70907. instance?: Nullable<LinesMesh>;
  70908. colors?: Color4[];
  70909. useVertexAlpha?: boolean;
  70910. }, scene?: Nullable<Scene>): LinesMesh;
  70911. /**
  70912. * Creates a dashed line mesh
  70913. * * 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
  70914. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70915. * * The parameter `points` is an array successive Vector3
  70916. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70917. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70918. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70919. * * 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
  70920. * * When updating an instance, remember that only point positions can change, not the number of points
  70921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70922. * @param name defines the name of the mesh
  70923. * @param options defines the options used to create the mesh
  70924. * @param scene defines the hosting scene
  70925. * @returns the dashed line mesh
  70926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70927. */
  70928. static CreateDashedLines(name: string, options: {
  70929. points: Vector3[];
  70930. dashSize?: number;
  70931. gapSize?: number;
  70932. dashNb?: number;
  70933. updatable?: boolean;
  70934. instance?: LinesMesh;
  70935. }, scene?: Nullable<Scene>): LinesMesh;
  70936. /**
  70937. * 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.
  70938. * * 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.
  70939. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70940. * * 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.
  70941. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70942. * * 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
  70943. * * 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
  70944. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70946. * * 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
  70947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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. * @param name defines the name of the mesh
  70950. * @param options defines the options used to create the mesh
  70951. * @param scene defines the hosting scene
  70952. * @returns the extruded shape mesh
  70953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70955. */
  70956. static ExtrudeShape(name: string, options: {
  70957. shape: Vector3[];
  70958. path: Vector3[];
  70959. scale?: number;
  70960. rotation?: number;
  70961. cap?: number;
  70962. updatable?: boolean;
  70963. sideOrientation?: number;
  70964. frontUVs?: Vector4;
  70965. backUVs?: Vector4;
  70966. instance?: Mesh;
  70967. invertUV?: boolean;
  70968. }, scene?: Nullable<Scene>): Mesh;
  70969. /**
  70970. * Creates an custom extruded shape mesh.
  70971. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70972. * * 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.
  70973. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70974. * * 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
  70975. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70976. * * 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
  70977. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70978. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70979. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70980. * * 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
  70981. * * 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
  70982. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70984. * * 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
  70985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70987. * @param name defines the name of the mesh
  70988. * @param options defines the options used to create the mesh
  70989. * @param scene defines the hosting scene
  70990. * @returns the custom extruded shape mesh
  70991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70992. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70994. */
  70995. static ExtrudeShapeCustom(name: string, options: {
  70996. shape: Vector3[];
  70997. path: Vector3[];
  70998. scaleFunction?: any;
  70999. rotationFunction?: any;
  71000. ribbonCloseArray?: boolean;
  71001. ribbonClosePath?: boolean;
  71002. cap?: number;
  71003. updatable?: boolean;
  71004. sideOrientation?: number;
  71005. frontUVs?: Vector4;
  71006. backUVs?: Vector4;
  71007. instance?: Mesh;
  71008. invertUV?: boolean;
  71009. }, scene?: Nullable<Scene>): Mesh;
  71010. /**
  71011. * Creates lathe mesh.
  71012. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  71013. * * 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
  71014. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71015. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71016. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71017. * * 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
  71018. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71019. * * 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
  71020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71021. * * 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
  71022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71024. * @param name defines the name of the mesh
  71025. * @param options defines the options used to create the mesh
  71026. * @param scene defines the hosting scene
  71027. * @returns the lathe mesh
  71028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71029. */
  71030. static CreateLathe(name: string, options: {
  71031. shape: Vector3[];
  71032. radius?: number;
  71033. tessellation?: number;
  71034. clip?: number;
  71035. arc?: number;
  71036. closed?: boolean;
  71037. updatable?: boolean;
  71038. sideOrientation?: number;
  71039. frontUVs?: Vector4;
  71040. backUVs?: Vector4;
  71041. cap?: number;
  71042. invertUV?: boolean;
  71043. }, scene?: Nullable<Scene>): Mesh;
  71044. /**
  71045. * Creates a tiled plane mesh
  71046. * * You can set a limited pattern arrangement with the tiles
  71047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71048. * * 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
  71049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71050. * @param name defines the name of the mesh
  71051. * @param options defines the options used to create the mesh
  71052. * @param scene defines the hosting scene
  71053. * @returns the plane mesh
  71054. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71055. */
  71056. static CreateTiledPlane(name: string, options: {
  71057. pattern?: number;
  71058. tileSize?: number;
  71059. tileWidth?: number;
  71060. tileHeight?: number;
  71061. size?: number;
  71062. width?: number;
  71063. height?: number;
  71064. alignHorizontal?: number;
  71065. alignVertical?: number;
  71066. sideOrientation?: number;
  71067. frontUVs?: Vector4;
  71068. backUVs?: Vector4;
  71069. updatable?: boolean;
  71070. }, scene?: Nullable<Scene>): Mesh;
  71071. /**
  71072. * Creates a plane mesh
  71073. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71074. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71075. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71077. * * 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
  71078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71079. * @param name defines the name of the mesh
  71080. * @param options defines the options used to create the mesh
  71081. * @param scene defines the hosting scene
  71082. * @returns the plane mesh
  71083. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71084. */
  71085. static CreatePlane(name: string, options: {
  71086. size?: number;
  71087. width?: number;
  71088. height?: number;
  71089. sideOrientation?: number;
  71090. frontUVs?: Vector4;
  71091. backUVs?: Vector4;
  71092. updatable?: boolean;
  71093. sourcePlane?: Plane;
  71094. }, scene?: Nullable<Scene>): Mesh;
  71095. /**
  71096. * Creates a ground mesh
  71097. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71098. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71100. * @param name defines the name of the mesh
  71101. * @param options defines the options used to create the mesh
  71102. * @param scene defines the hosting scene
  71103. * @returns the ground mesh
  71104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71105. */
  71106. static CreateGround(name: string, options: {
  71107. width?: number;
  71108. height?: number;
  71109. subdivisions?: number;
  71110. subdivisionsX?: number;
  71111. subdivisionsY?: number;
  71112. updatable?: boolean;
  71113. }, scene?: Nullable<Scene>): Mesh;
  71114. /**
  71115. * Creates a tiled ground mesh
  71116. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71117. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71118. * * 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
  71119. * * 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
  71120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71121. * @param name defines the name of the mesh
  71122. * @param options defines the options used to create the mesh
  71123. * @param scene defines the hosting scene
  71124. * @returns the tiled ground mesh
  71125. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71126. */
  71127. static CreateTiledGround(name: string, options: {
  71128. xmin: number;
  71129. zmin: number;
  71130. xmax: number;
  71131. zmax: number;
  71132. subdivisions?: {
  71133. w: number;
  71134. h: number;
  71135. };
  71136. precision?: {
  71137. w: number;
  71138. h: number;
  71139. };
  71140. updatable?: boolean;
  71141. }, scene?: Nullable<Scene>): Mesh;
  71142. /**
  71143. * Creates a ground mesh from a height map
  71144. * * The parameter `url` sets the URL of the height map image resource.
  71145. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71146. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71147. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71148. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71149. * * 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.
  71150. * * 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).
  71151. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71153. * @param name defines the name of the mesh
  71154. * @param url defines the url to the height map
  71155. * @param options defines the options used to create the mesh
  71156. * @param scene defines the hosting scene
  71157. * @returns the ground mesh
  71158. * @see https://doc.babylonjs.com/babylon101/height_map
  71159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71160. */
  71161. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71162. width?: number;
  71163. height?: number;
  71164. subdivisions?: number;
  71165. minHeight?: number;
  71166. maxHeight?: number;
  71167. colorFilter?: Color3;
  71168. alphaFilter?: number;
  71169. updatable?: boolean;
  71170. onReady?: (mesh: GroundMesh) => void;
  71171. }, scene?: Nullable<Scene>): GroundMesh;
  71172. /**
  71173. * Creates a polygon mesh
  71174. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71175. * * 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
  71176. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71178. * * 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)
  71179. * * Remember you can only change the shape positions, not their number when updating a polygon
  71180. * @param name defines the name of the mesh
  71181. * @param options defines the options used to create the mesh
  71182. * @param scene defines the hosting scene
  71183. * @param earcutInjection can be used to inject your own earcut reference
  71184. * @returns the polygon mesh
  71185. */
  71186. static CreatePolygon(name: string, options: {
  71187. shape: Vector3[];
  71188. holes?: Vector3[][];
  71189. depth?: number;
  71190. faceUV?: Vector4[];
  71191. faceColors?: Color4[];
  71192. updatable?: boolean;
  71193. sideOrientation?: number;
  71194. frontUVs?: Vector4;
  71195. backUVs?: Vector4;
  71196. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71197. /**
  71198. * Creates an extruded polygon mesh, with depth in the Y direction.
  71199. * * 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)
  71200. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71201. * @param name defines the name of the mesh
  71202. * @param options defines the options used to create the mesh
  71203. * @param scene defines the hosting scene
  71204. * @param earcutInjection can be used to inject your own earcut reference
  71205. * @returns the polygon mesh
  71206. */
  71207. static ExtrudePolygon(name: string, options: {
  71208. shape: Vector3[];
  71209. holes?: Vector3[][];
  71210. depth?: number;
  71211. faceUV?: Vector4[];
  71212. faceColors?: Color4[];
  71213. updatable?: boolean;
  71214. sideOrientation?: number;
  71215. frontUVs?: Vector4;
  71216. backUVs?: Vector4;
  71217. wrap?: boolean;
  71218. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71219. /**
  71220. * Creates a tube mesh.
  71221. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71222. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71223. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71224. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71225. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71226. * * 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)
  71227. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71228. * * 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
  71229. * * 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
  71230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71231. * * 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
  71232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71234. * @param name defines the name of the mesh
  71235. * @param options defines the options used to create the mesh
  71236. * @param scene defines the hosting scene
  71237. * @returns the tube mesh
  71238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71239. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71240. */
  71241. static CreateTube(name: string, options: {
  71242. path: Vector3[];
  71243. radius?: number;
  71244. tessellation?: number;
  71245. radiusFunction?: {
  71246. (i: number, distance: number): number;
  71247. };
  71248. cap?: number;
  71249. arc?: number;
  71250. updatable?: boolean;
  71251. sideOrientation?: number;
  71252. frontUVs?: Vector4;
  71253. backUVs?: Vector4;
  71254. instance?: Mesh;
  71255. invertUV?: boolean;
  71256. }, scene?: Nullable<Scene>): Mesh;
  71257. /**
  71258. * Creates a polyhedron mesh
  71259. * * 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
  71260. * * The parameter `size` (positive float, default 1) sets the polygon size
  71261. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71262. * * 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`
  71263. * * 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
  71264. * * 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)`)
  71265. * * 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
  71266. * * 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
  71267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71268. * * 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
  71269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71270. * @param name defines the name of the mesh
  71271. * @param options defines the options used to create the mesh
  71272. * @param scene defines the hosting scene
  71273. * @returns the polyhedron mesh
  71274. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71275. */
  71276. static CreatePolyhedron(name: string, options: {
  71277. type?: number;
  71278. size?: number;
  71279. sizeX?: number;
  71280. sizeY?: number;
  71281. sizeZ?: number;
  71282. custom?: any;
  71283. faceUV?: Vector4[];
  71284. faceColors?: Color4[];
  71285. flat?: boolean;
  71286. updatable?: boolean;
  71287. sideOrientation?: number;
  71288. frontUVs?: Vector4;
  71289. backUVs?: Vector4;
  71290. }, scene?: Nullable<Scene>): Mesh;
  71291. /**
  71292. * Creates a decal mesh.
  71293. * 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
  71294. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71295. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71296. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71297. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71298. * @param name defines the name of the mesh
  71299. * @param sourceMesh defines the mesh where the decal must be applied
  71300. * @param options defines the options used to create the mesh
  71301. * @param scene defines the hosting scene
  71302. * @returns the decal mesh
  71303. * @see https://doc.babylonjs.com/how_to/decals
  71304. */
  71305. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71306. position?: Vector3;
  71307. normal?: Vector3;
  71308. size?: Vector3;
  71309. angle?: number;
  71310. }): Mesh;
  71311. /**
  71312. * Creates a Capsule Mesh
  71313. * @param name defines the name of the mesh.
  71314. * @param options the constructors options used to shape the mesh.
  71315. * @param scene defines the scene the mesh is scoped to.
  71316. * @returns the capsule mesh
  71317. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71318. */
  71319. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71320. }
  71321. }
  71322. declare module BABYLON {
  71323. /**
  71324. * A simplifier interface for future simplification implementations
  71325. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71326. */
  71327. export interface ISimplifier {
  71328. /**
  71329. * Simplification of a given mesh according to the given settings.
  71330. * Since this requires computation, it is assumed that the function runs async.
  71331. * @param settings The settings of the simplification, including quality and distance
  71332. * @param successCallback A callback that will be called after the mesh was simplified.
  71333. * @param errorCallback in case of an error, this callback will be called. optional.
  71334. */
  71335. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71336. }
  71337. /**
  71338. * Expected simplification settings.
  71339. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71340. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71341. */
  71342. export interface ISimplificationSettings {
  71343. /**
  71344. * Gets or sets the expected quality
  71345. */
  71346. quality: number;
  71347. /**
  71348. * Gets or sets the distance when this optimized version should be used
  71349. */
  71350. distance: number;
  71351. /**
  71352. * Gets an already optimized mesh
  71353. */
  71354. optimizeMesh?: boolean;
  71355. }
  71356. /**
  71357. * Class used to specify simplification options
  71358. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71359. */
  71360. export class SimplificationSettings implements ISimplificationSettings {
  71361. /** expected quality */
  71362. quality: number;
  71363. /** distance when this optimized version should be used */
  71364. distance: number;
  71365. /** already optimized mesh */
  71366. optimizeMesh?: boolean | undefined;
  71367. /**
  71368. * Creates a SimplificationSettings
  71369. * @param quality expected quality
  71370. * @param distance distance when this optimized version should be used
  71371. * @param optimizeMesh already optimized mesh
  71372. */
  71373. constructor(
  71374. /** expected quality */
  71375. quality: number,
  71376. /** distance when this optimized version should be used */
  71377. distance: number,
  71378. /** already optimized mesh */
  71379. optimizeMesh?: boolean | undefined);
  71380. }
  71381. /**
  71382. * Interface used to define a simplification task
  71383. */
  71384. export interface ISimplificationTask {
  71385. /**
  71386. * Array of settings
  71387. */
  71388. settings: Array<ISimplificationSettings>;
  71389. /**
  71390. * Simplification type
  71391. */
  71392. simplificationType: SimplificationType;
  71393. /**
  71394. * Mesh to simplify
  71395. */
  71396. mesh: Mesh;
  71397. /**
  71398. * Callback called on success
  71399. */
  71400. successCallback?: () => void;
  71401. /**
  71402. * Defines if parallel processing can be used
  71403. */
  71404. parallelProcessing: boolean;
  71405. }
  71406. /**
  71407. * Queue used to order the simplification tasks
  71408. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71409. */
  71410. export class SimplificationQueue {
  71411. private _simplificationArray;
  71412. /**
  71413. * Gets a boolean indicating that the process is still running
  71414. */
  71415. running: boolean;
  71416. /**
  71417. * Creates a new queue
  71418. */
  71419. constructor();
  71420. /**
  71421. * Adds a new simplification task
  71422. * @param task defines a task to add
  71423. */
  71424. addTask(task: ISimplificationTask): void;
  71425. /**
  71426. * Execute next task
  71427. */
  71428. executeNext(): void;
  71429. /**
  71430. * Execute a simplification task
  71431. * @param task defines the task to run
  71432. */
  71433. runSimplification(task: ISimplificationTask): void;
  71434. private getSimplifier;
  71435. }
  71436. /**
  71437. * The implemented types of simplification
  71438. * At the moment only Quadratic Error Decimation is implemented
  71439. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71440. */
  71441. export enum SimplificationType {
  71442. /** Quadratic error decimation */
  71443. QUADRATIC = 0
  71444. }
  71445. /**
  71446. * An implementation of the Quadratic Error simplification algorithm.
  71447. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71448. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71449. * @author RaananW
  71450. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71451. */
  71452. export class QuadraticErrorSimplification implements ISimplifier {
  71453. private _mesh;
  71454. private triangles;
  71455. private vertices;
  71456. private references;
  71457. private _reconstructedMesh;
  71458. /** Gets or sets the number pf sync iterations */
  71459. syncIterations: number;
  71460. /** Gets or sets the aggressiveness of the simplifier */
  71461. aggressiveness: number;
  71462. /** Gets or sets the number of allowed iterations for decimation */
  71463. decimationIterations: number;
  71464. /** Gets or sets the espilon to use for bounding box computation */
  71465. boundingBoxEpsilon: number;
  71466. /**
  71467. * Creates a new QuadraticErrorSimplification
  71468. * @param _mesh defines the target mesh
  71469. */
  71470. constructor(_mesh: Mesh);
  71471. /**
  71472. * Simplification of a given mesh according to the given settings.
  71473. * Since this requires computation, it is assumed that the function runs async.
  71474. * @param settings The settings of the simplification, including quality and distance
  71475. * @param successCallback A callback that will be called after the mesh was simplified.
  71476. */
  71477. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71478. private runDecimation;
  71479. private initWithMesh;
  71480. private init;
  71481. private reconstructMesh;
  71482. private initDecimatedMesh;
  71483. private isFlipped;
  71484. private updateTriangles;
  71485. private identifyBorder;
  71486. private updateMesh;
  71487. private vertexError;
  71488. private calculateError;
  71489. }
  71490. }
  71491. declare module BABYLON {
  71492. interface Scene {
  71493. /** @hidden (Backing field) */
  71494. _simplificationQueue: SimplificationQueue;
  71495. /**
  71496. * Gets or sets the simplification queue attached to the scene
  71497. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71498. */
  71499. simplificationQueue: SimplificationQueue;
  71500. }
  71501. interface Mesh {
  71502. /**
  71503. * Simplify the mesh according to the given array of settings.
  71504. * Function will return immediately and will simplify async
  71505. * @param settings a collection of simplification settings
  71506. * @param parallelProcessing should all levels calculate parallel or one after the other
  71507. * @param simplificationType the type of simplification to run
  71508. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71509. * @returns the current mesh
  71510. */
  71511. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71512. }
  71513. /**
  71514. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71515. * created in a scene
  71516. */
  71517. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71518. /**
  71519. * The component name helpfull to identify the component in the list of scene components.
  71520. */
  71521. readonly name: string;
  71522. /**
  71523. * The scene the component belongs to.
  71524. */
  71525. scene: Scene;
  71526. /**
  71527. * Creates a new instance of the component for the given scene
  71528. * @param scene Defines the scene to register the component in
  71529. */
  71530. constructor(scene: Scene);
  71531. /**
  71532. * Registers the component in a given scene
  71533. */
  71534. register(): void;
  71535. /**
  71536. * Rebuilds the elements related to this component in case of
  71537. * context lost for instance.
  71538. */
  71539. rebuild(): void;
  71540. /**
  71541. * Disposes the component and the associated resources
  71542. */
  71543. dispose(): void;
  71544. private _beforeCameraUpdate;
  71545. }
  71546. }
  71547. declare module BABYLON {
  71548. interface Mesh {
  71549. /**
  71550. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71551. */
  71552. thinInstanceEnablePicking: boolean;
  71553. /**
  71554. * Creates a new thin instance
  71555. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71556. * @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
  71557. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71558. */
  71559. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71560. /**
  71561. * Adds the transformation (matrix) of the current mesh as a thin instance
  71562. * @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
  71563. * @returns the thin instance index number
  71564. */
  71565. thinInstanceAddSelf(refresh: boolean): number;
  71566. /**
  71567. * Registers a custom attribute to be used with thin instances
  71568. * @param kind name of the attribute
  71569. * @param stride size in floats of the attribute
  71570. */
  71571. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71572. /**
  71573. * Sets the matrix of a thin instance
  71574. * @param index index of the thin instance
  71575. * @param matrix matrix to set
  71576. * @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
  71577. */
  71578. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71579. /**
  71580. * Sets the value of a custom attribute for a thin instance
  71581. * @param kind name of the attribute
  71582. * @param index index of the thin instance
  71583. * @param value value to set
  71584. * @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
  71585. */
  71586. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71587. /**
  71588. * 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.
  71589. */
  71590. thinInstanceCount: number;
  71591. /**
  71592. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71593. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71594. * @param buffer buffer to set
  71595. * @param stride size in floats of each value of the buffer
  71596. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71597. */
  71598. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71599. /**
  71600. * Gets the list of world matrices
  71601. * @return an array containing all the world matrices from the thin instances
  71602. */
  71603. thinInstanceGetWorldMatrices(): Matrix[];
  71604. /**
  71605. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71606. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71607. */
  71608. thinInstanceBufferUpdated(kind: string): void;
  71609. /**
  71610. * Applies a partial update to a buffer directly on the GPU
  71611. * 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
  71612. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71613. * @param data the data to set in the GPU buffer
  71614. * @param offset the offset in the GPU buffer where to update the data
  71615. */
  71616. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71617. /**
  71618. * Refreshes the bounding info, taking into account all the thin instances defined
  71619. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71620. */
  71621. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71622. /** @hidden */
  71623. _thinInstanceInitializeUserStorage(): void;
  71624. /** @hidden */
  71625. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71626. /** @hidden */
  71627. _userThinInstanceBuffersStorage: {
  71628. data: {
  71629. [key: string]: Float32Array;
  71630. };
  71631. sizes: {
  71632. [key: string]: number;
  71633. };
  71634. vertexBuffers: {
  71635. [key: string]: Nullable<VertexBuffer>;
  71636. };
  71637. strides: {
  71638. [key: string]: number;
  71639. };
  71640. };
  71641. }
  71642. }
  71643. declare module BABYLON {
  71644. /**
  71645. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71646. */
  71647. export interface INavigationEnginePlugin {
  71648. /**
  71649. * plugin name
  71650. */
  71651. name: string;
  71652. /**
  71653. * Creates a navigation mesh
  71654. * @param meshes array of all the geometry used to compute the navigation mesh
  71655. * @param parameters bunch of parameters used to filter geometry
  71656. */
  71657. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71658. /**
  71659. * Create a navigation mesh debug mesh
  71660. * @param scene is where the mesh will be added
  71661. * @returns debug display mesh
  71662. */
  71663. createDebugNavMesh(scene: Scene): Mesh;
  71664. /**
  71665. * Get a navigation mesh constrained position, closest to the parameter position
  71666. * @param position world position
  71667. * @returns the closest point to position constrained by the navigation mesh
  71668. */
  71669. getClosestPoint(position: Vector3): Vector3;
  71670. /**
  71671. * Get a navigation mesh constrained position, closest to the parameter position
  71672. * @param position world position
  71673. * @param result output the closest point to position constrained by the navigation mesh
  71674. */
  71675. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71676. /**
  71677. * Get a navigation mesh constrained position, within a particular radius
  71678. * @param position world position
  71679. * @param maxRadius the maximum distance to the constrained world position
  71680. * @returns the closest point to position constrained by the navigation mesh
  71681. */
  71682. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71683. /**
  71684. * Get a navigation mesh constrained position, within a particular radius
  71685. * @param position world position
  71686. * @param maxRadius the maximum distance to the constrained world position
  71687. * @param result output the closest point to position constrained by the navigation mesh
  71688. */
  71689. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71690. /**
  71691. * Compute the final position from a segment made of destination-position
  71692. * @param position world position
  71693. * @param destination world position
  71694. * @returns the resulting point along the navmesh
  71695. */
  71696. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71697. /**
  71698. * Compute the final position from a segment made of destination-position
  71699. * @param position world position
  71700. * @param destination world position
  71701. * @param result output the resulting point along the navmesh
  71702. */
  71703. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71704. /**
  71705. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71706. * @param start world position
  71707. * @param end world position
  71708. * @returns array containing world position composing the path
  71709. */
  71710. computePath(start: Vector3, end: Vector3): Vector3[];
  71711. /**
  71712. * If this plugin is supported
  71713. * @returns true if plugin is supported
  71714. */
  71715. isSupported(): boolean;
  71716. /**
  71717. * Create a new Crowd so you can add agents
  71718. * @param maxAgents the maximum agent count in the crowd
  71719. * @param maxAgentRadius the maximum radius an agent can have
  71720. * @param scene to attach the crowd to
  71721. * @returns the crowd you can add agents to
  71722. */
  71723. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71724. /**
  71725. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71726. * The queries will try to find a solution within those bounds
  71727. * default is (1,1,1)
  71728. * @param extent x,y,z value that define the extent around the queries point of reference
  71729. */
  71730. setDefaultQueryExtent(extent: Vector3): void;
  71731. /**
  71732. * Get the Bounding box extent specified by setDefaultQueryExtent
  71733. * @returns the box extent values
  71734. */
  71735. getDefaultQueryExtent(): Vector3;
  71736. /**
  71737. * build the navmesh from a previously saved state using getNavmeshData
  71738. * @param data the Uint8Array returned by getNavmeshData
  71739. */
  71740. buildFromNavmeshData(data: Uint8Array): void;
  71741. /**
  71742. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71743. * @returns data the Uint8Array that can be saved and reused
  71744. */
  71745. getNavmeshData(): Uint8Array;
  71746. /**
  71747. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71748. * @param result output the box extent values
  71749. */
  71750. getDefaultQueryExtentToRef(result: Vector3): void;
  71751. /**
  71752. * Set the time step of the navigation tick update.
  71753. * Default is 1/60.
  71754. * A value of 0 will disable fixed time update
  71755. * @param newTimeStep the new timestep to apply to this world.
  71756. */
  71757. setTimeStep(newTimeStep: number): void;
  71758. /**
  71759. * Get the time step of the navigation tick update.
  71760. * @returns the current time step
  71761. */
  71762. getTimeStep(): number;
  71763. /**
  71764. * If delta time in navigation tick update is greater than the time step
  71765. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71766. * they will be discarded.
  71767. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71768. * @param newStepCount the maximum number of iterations
  71769. */
  71770. setMaximumSubStepCount(newStepCount: number): void;
  71771. /**
  71772. * Get the maximum number of iterations per navigation tick update
  71773. * @returns the maximum number of iterations
  71774. */
  71775. getMaximumSubStepCount(): number;
  71776. /**
  71777. * Release all resources
  71778. */
  71779. dispose(): void;
  71780. }
  71781. /**
  71782. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71783. */
  71784. export interface ICrowd {
  71785. /**
  71786. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71787. * You can attach anything to that node. The node position is updated in the scene update tick.
  71788. * @param pos world position that will be constrained by the navigation mesh
  71789. * @param parameters agent parameters
  71790. * @param transform hooked to the agent that will be update by the scene
  71791. * @returns agent index
  71792. */
  71793. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71794. /**
  71795. * Returns the agent position in world space
  71796. * @param index agent index returned by addAgent
  71797. * @returns world space position
  71798. */
  71799. getAgentPosition(index: number): Vector3;
  71800. /**
  71801. * Gets the agent position result in world space
  71802. * @param index agent index returned by addAgent
  71803. * @param result output world space position
  71804. */
  71805. getAgentPositionToRef(index: number, result: Vector3): void;
  71806. /**
  71807. * Gets the agent velocity in world space
  71808. * @param index agent index returned by addAgent
  71809. * @returns world space velocity
  71810. */
  71811. getAgentVelocity(index: number): Vector3;
  71812. /**
  71813. * Gets the agent velocity result in world space
  71814. * @param index agent index returned by addAgent
  71815. * @param result output world space velocity
  71816. */
  71817. getAgentVelocityToRef(index: number, result: Vector3): void;
  71818. /**
  71819. * Gets the agent next target point on the path
  71820. * @param index agent index returned by addAgent
  71821. * @returns world space position
  71822. */
  71823. getAgentNextTargetPath(index: number): Vector3;
  71824. /**
  71825. * Gets the agent state
  71826. * @param index agent index returned by addAgent
  71827. * @returns agent state
  71828. */
  71829. getAgentState(index: number): number;
  71830. /**
  71831. * returns true if the agent in over an off mesh link connection
  71832. * @param index agent index returned by addAgent
  71833. * @returns true if over an off mesh link connection
  71834. */
  71835. overOffmeshConnection(index: number): boolean;
  71836. /**
  71837. * Gets the agent next target point on the path
  71838. * @param index agent index returned by addAgent
  71839. * @param result output world space position
  71840. */
  71841. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71842. /**
  71843. * remove a particular agent previously created
  71844. * @param index agent index returned by addAgent
  71845. */
  71846. removeAgent(index: number): void;
  71847. /**
  71848. * get the list of all agents attached to this crowd
  71849. * @returns list of agent indices
  71850. */
  71851. getAgents(): number[];
  71852. /**
  71853. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71854. * @param deltaTime in seconds
  71855. */
  71856. update(deltaTime: number): void;
  71857. /**
  71858. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71859. * @param index agent index returned by addAgent
  71860. * @param destination targeted world position
  71861. */
  71862. agentGoto(index: number, destination: Vector3): void;
  71863. /**
  71864. * Teleport the agent to a new position
  71865. * @param index agent index returned by addAgent
  71866. * @param destination targeted world position
  71867. */
  71868. agentTeleport(index: number, destination: Vector3): void;
  71869. /**
  71870. * Update agent parameters
  71871. * @param index agent index returned by addAgent
  71872. * @param parameters agent parameters
  71873. */
  71874. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71875. /**
  71876. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71877. * The queries will try to find a solution within those bounds
  71878. * default is (1,1,1)
  71879. * @param extent x,y,z value that define the extent around the queries point of reference
  71880. */
  71881. setDefaultQueryExtent(extent: Vector3): void;
  71882. /**
  71883. * Get the Bounding box extent specified by setDefaultQueryExtent
  71884. * @returns the box extent values
  71885. */
  71886. getDefaultQueryExtent(): Vector3;
  71887. /**
  71888. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71889. * @param result output the box extent values
  71890. */
  71891. getDefaultQueryExtentToRef(result: Vector3): void;
  71892. /**
  71893. * Release all resources
  71894. */
  71895. dispose(): void;
  71896. }
  71897. /**
  71898. * Configures an agent
  71899. */
  71900. export interface IAgentParameters {
  71901. /**
  71902. * Agent radius. [Limit: >= 0]
  71903. */
  71904. radius: number;
  71905. /**
  71906. * Agent height. [Limit: > 0]
  71907. */
  71908. height: number;
  71909. /**
  71910. * Maximum allowed acceleration. [Limit: >= 0]
  71911. */
  71912. maxAcceleration: number;
  71913. /**
  71914. * Maximum allowed speed. [Limit: >= 0]
  71915. */
  71916. maxSpeed: number;
  71917. /**
  71918. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71919. */
  71920. collisionQueryRange: number;
  71921. /**
  71922. * The path visibility optimization range. [Limit: > 0]
  71923. */
  71924. pathOptimizationRange: number;
  71925. /**
  71926. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71927. */
  71928. separationWeight: number;
  71929. }
  71930. /**
  71931. * Configures the navigation mesh creation
  71932. */
  71933. export interface INavMeshParameters {
  71934. /**
  71935. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71936. */
  71937. cs: number;
  71938. /**
  71939. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71940. */
  71941. ch: number;
  71942. /**
  71943. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71944. */
  71945. walkableSlopeAngle: number;
  71946. /**
  71947. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71948. * be considered walkable. [Limit: >= 3] [Units: vx]
  71949. */
  71950. walkableHeight: number;
  71951. /**
  71952. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71953. */
  71954. walkableClimb: number;
  71955. /**
  71956. * The distance to erode/shrink the walkable area of the heightfield away from
  71957. * obstructions. [Limit: >=0] [Units: vx]
  71958. */
  71959. walkableRadius: number;
  71960. /**
  71961. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71962. */
  71963. maxEdgeLen: number;
  71964. /**
  71965. * The maximum distance a simplified contour's border edges should deviate
  71966. * the original raw contour. [Limit: >=0] [Units: vx]
  71967. */
  71968. maxSimplificationError: number;
  71969. /**
  71970. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71971. */
  71972. minRegionArea: number;
  71973. /**
  71974. * Any regions with a span count smaller than this value will, if possible,
  71975. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71976. */
  71977. mergeRegionArea: number;
  71978. /**
  71979. * The maximum number of vertices allowed for polygons generated during the
  71980. * contour to polygon conversion process. [Limit: >= 3]
  71981. */
  71982. maxVertsPerPoly: number;
  71983. /**
  71984. * Sets the sampling distance to use when generating the detail mesh.
  71985. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71986. */
  71987. detailSampleDist: number;
  71988. /**
  71989. * The maximum distance the detail mesh surface should deviate from heightfield
  71990. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71991. */
  71992. detailSampleMaxError: number;
  71993. }
  71994. }
  71995. declare module BABYLON {
  71996. /**
  71997. * RecastJS navigation plugin
  71998. */
  71999. export class RecastJSPlugin implements INavigationEnginePlugin {
  72000. /**
  72001. * Reference to the Recast library
  72002. */
  72003. bjsRECAST: any;
  72004. /**
  72005. * plugin name
  72006. */
  72007. name: string;
  72008. /**
  72009. * the first navmesh created. We might extend this to support multiple navmeshes
  72010. */
  72011. navMesh: any;
  72012. private _maximumSubStepCount;
  72013. private _timeStep;
  72014. /**
  72015. * Initializes the recastJS plugin
  72016. * @param recastInjection can be used to inject your own recast reference
  72017. */
  72018. constructor(recastInjection?: any);
  72019. /**
  72020. * Set the time step of the navigation tick update.
  72021. * Default is 1/60.
  72022. * A value of 0 will disable fixed time update
  72023. * @param newTimeStep the new timestep to apply to this world.
  72024. */
  72025. setTimeStep(newTimeStep?: number): void;
  72026. /**
  72027. * Get the time step of the navigation tick update.
  72028. * @returns the current time step
  72029. */
  72030. getTimeStep(): number;
  72031. /**
  72032. * If delta time in navigation tick update is greater than the time step
  72033. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72034. * they will be discarded.
  72035. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72036. * @param newStepCount the maximum number of iterations
  72037. */
  72038. setMaximumSubStepCount(newStepCount?: number): void;
  72039. /**
  72040. * Get the maximum number of iterations per navigation tick update
  72041. * @returns the maximum number of iterations
  72042. */
  72043. getMaximumSubStepCount(): number;
  72044. /**
  72045. * Creates a navigation mesh
  72046. * @param meshes array of all the geometry used to compute the navigation mesh
  72047. * @param parameters bunch of parameters used to filter geometry
  72048. */
  72049. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72050. /**
  72051. * Create a navigation mesh debug mesh
  72052. * @param scene is where the mesh will be added
  72053. * @returns debug display mesh
  72054. */
  72055. createDebugNavMesh(scene: Scene): Mesh;
  72056. /**
  72057. * Get a navigation mesh constrained position, closest to the parameter position
  72058. * @param position world position
  72059. * @returns the closest point to position constrained by the navigation mesh
  72060. */
  72061. getClosestPoint(position: Vector3): Vector3;
  72062. /**
  72063. * Get a navigation mesh constrained position, closest to the parameter position
  72064. * @param position world position
  72065. * @param result output the closest point to position constrained by the navigation mesh
  72066. */
  72067. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72068. /**
  72069. * Get a navigation mesh constrained position, within a particular radius
  72070. * @param position world position
  72071. * @param maxRadius the maximum distance to the constrained world position
  72072. * @returns the closest point to position constrained by the navigation mesh
  72073. */
  72074. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72075. /**
  72076. * Get a navigation mesh constrained position, within a particular radius
  72077. * @param position world position
  72078. * @param maxRadius the maximum distance to the constrained world position
  72079. * @param result output the closest point to position constrained by the navigation mesh
  72080. */
  72081. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72082. /**
  72083. * Compute the final position from a segment made of destination-position
  72084. * @param position world position
  72085. * @param destination world position
  72086. * @returns the resulting point along the navmesh
  72087. */
  72088. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72089. /**
  72090. * Compute the final position from a segment made of destination-position
  72091. * @param position world position
  72092. * @param destination world position
  72093. * @param result output the resulting point along the navmesh
  72094. */
  72095. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72096. /**
  72097. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72098. * @param start world position
  72099. * @param end world position
  72100. * @returns array containing world position composing the path
  72101. */
  72102. computePath(start: Vector3, end: Vector3): Vector3[];
  72103. /**
  72104. * Create a new Crowd so you can add agents
  72105. * @param maxAgents the maximum agent count in the crowd
  72106. * @param maxAgentRadius the maximum radius an agent can have
  72107. * @param scene to attach the crowd to
  72108. * @returns the crowd you can add agents to
  72109. */
  72110. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72111. /**
  72112. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72113. * The queries will try to find a solution within those bounds
  72114. * default is (1,1,1)
  72115. * @param extent x,y,z value that define the extent around the queries point of reference
  72116. */
  72117. setDefaultQueryExtent(extent: Vector3): void;
  72118. /**
  72119. * Get the Bounding box extent specified by setDefaultQueryExtent
  72120. * @returns the box extent values
  72121. */
  72122. getDefaultQueryExtent(): Vector3;
  72123. /**
  72124. * build the navmesh from a previously saved state using getNavmeshData
  72125. * @param data the Uint8Array returned by getNavmeshData
  72126. */
  72127. buildFromNavmeshData(data: Uint8Array): void;
  72128. /**
  72129. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72130. * @returns data the Uint8Array that can be saved and reused
  72131. */
  72132. getNavmeshData(): Uint8Array;
  72133. /**
  72134. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72135. * @param result output the box extent values
  72136. */
  72137. getDefaultQueryExtentToRef(result: Vector3): void;
  72138. /**
  72139. * Disposes
  72140. */
  72141. dispose(): void;
  72142. /**
  72143. * If this plugin is supported
  72144. * @returns true if plugin is supported
  72145. */
  72146. isSupported(): boolean;
  72147. }
  72148. /**
  72149. * Recast detour crowd implementation
  72150. */
  72151. export class RecastJSCrowd implements ICrowd {
  72152. /**
  72153. * Recast/detour plugin
  72154. */
  72155. bjsRECASTPlugin: RecastJSPlugin;
  72156. /**
  72157. * Link to the detour crowd
  72158. */
  72159. recastCrowd: any;
  72160. /**
  72161. * One transform per agent
  72162. */
  72163. transforms: TransformNode[];
  72164. /**
  72165. * All agents created
  72166. */
  72167. agents: number[];
  72168. /**
  72169. * Link to the scene is kept to unregister the crowd from the scene
  72170. */
  72171. private _scene;
  72172. /**
  72173. * Observer for crowd updates
  72174. */
  72175. private _onBeforeAnimationsObserver;
  72176. /**
  72177. * Constructor
  72178. * @param plugin recastJS plugin
  72179. * @param maxAgents the maximum agent count in the crowd
  72180. * @param maxAgentRadius the maximum radius an agent can have
  72181. * @param scene to attach the crowd to
  72182. * @returns the crowd you can add agents to
  72183. */
  72184. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72185. /**
  72186. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72187. * You can attach anything to that node. The node position is updated in the scene update tick.
  72188. * @param pos world position that will be constrained by the navigation mesh
  72189. * @param parameters agent parameters
  72190. * @param transform hooked to the agent that will be update by the scene
  72191. * @returns agent index
  72192. */
  72193. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72194. /**
  72195. * Returns the agent position in world space
  72196. * @param index agent index returned by addAgent
  72197. * @returns world space position
  72198. */
  72199. getAgentPosition(index: number): Vector3;
  72200. /**
  72201. * Returns the agent position result in world space
  72202. * @param index agent index returned by addAgent
  72203. * @param result output world space position
  72204. */
  72205. getAgentPositionToRef(index: number, result: Vector3): void;
  72206. /**
  72207. * Returns the agent velocity in world space
  72208. * @param index agent index returned by addAgent
  72209. * @returns world space velocity
  72210. */
  72211. getAgentVelocity(index: number): Vector3;
  72212. /**
  72213. * Returns the agent velocity result in world space
  72214. * @param index agent index returned by addAgent
  72215. * @param result output world space velocity
  72216. */
  72217. getAgentVelocityToRef(index: number, result: Vector3): void;
  72218. /**
  72219. * Returns the agent next target point on the path
  72220. * @param index agent index returned by addAgent
  72221. * @returns world space position
  72222. */
  72223. getAgentNextTargetPath(index: number): Vector3;
  72224. /**
  72225. * Returns the agent next target point on the path
  72226. * @param index agent index returned by addAgent
  72227. * @param result output world space position
  72228. */
  72229. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72230. /**
  72231. * Gets the agent state
  72232. * @param index agent index returned by addAgent
  72233. * @returns agent state
  72234. */
  72235. getAgentState(index: number): number;
  72236. /**
  72237. * returns true if the agent in over an off mesh link connection
  72238. * @param index agent index returned by addAgent
  72239. * @returns true if over an off mesh link connection
  72240. */
  72241. overOffmeshConnection(index: number): boolean;
  72242. /**
  72243. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72244. * @param index agent index returned by addAgent
  72245. * @param destination targeted world position
  72246. */
  72247. agentGoto(index: number, destination: Vector3): void;
  72248. /**
  72249. * Teleport the agent to a new position
  72250. * @param index agent index returned by addAgent
  72251. * @param destination targeted world position
  72252. */
  72253. agentTeleport(index: number, destination: Vector3): void;
  72254. /**
  72255. * Update agent parameters
  72256. * @param index agent index returned by addAgent
  72257. * @param parameters agent parameters
  72258. */
  72259. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72260. /**
  72261. * remove a particular agent previously created
  72262. * @param index agent index returned by addAgent
  72263. */
  72264. removeAgent(index: number): void;
  72265. /**
  72266. * get the list of all agents attached to this crowd
  72267. * @returns list of agent indices
  72268. */
  72269. getAgents(): number[];
  72270. /**
  72271. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72272. * @param deltaTime in seconds
  72273. */
  72274. update(deltaTime: number): void;
  72275. /**
  72276. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72277. * The queries will try to find a solution within those bounds
  72278. * default is (1,1,1)
  72279. * @param extent x,y,z value that define the extent around the queries point of reference
  72280. */
  72281. setDefaultQueryExtent(extent: Vector3): void;
  72282. /**
  72283. * Get the Bounding box extent specified by setDefaultQueryExtent
  72284. * @returns the box extent values
  72285. */
  72286. getDefaultQueryExtent(): Vector3;
  72287. /**
  72288. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72289. * @param result output the box extent values
  72290. */
  72291. getDefaultQueryExtentToRef(result: Vector3): void;
  72292. /**
  72293. * Release all resources
  72294. */
  72295. dispose(): void;
  72296. }
  72297. }
  72298. declare module BABYLON {
  72299. /**
  72300. * Class used to enable access to IndexedDB
  72301. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72302. */
  72303. export class Database implements IOfflineProvider {
  72304. private _callbackManifestChecked;
  72305. private _currentSceneUrl;
  72306. private _db;
  72307. private _enableSceneOffline;
  72308. private _enableTexturesOffline;
  72309. private _manifestVersionFound;
  72310. private _mustUpdateRessources;
  72311. private _hasReachedQuota;
  72312. private _isSupported;
  72313. private _idbFactory;
  72314. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72315. private static IsUASupportingBlobStorage;
  72316. /**
  72317. * Gets a boolean indicating if Database storage is enabled (off by default)
  72318. */
  72319. static IDBStorageEnabled: boolean;
  72320. /**
  72321. * Gets a boolean indicating if scene must be saved in the database
  72322. */
  72323. get enableSceneOffline(): boolean;
  72324. /**
  72325. * Gets a boolean indicating if textures must be saved in the database
  72326. */
  72327. get enableTexturesOffline(): boolean;
  72328. /**
  72329. * Creates a new Database
  72330. * @param urlToScene defines the url to load the scene
  72331. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72332. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72333. */
  72334. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72335. private static _ParseURL;
  72336. private static _ReturnFullUrlLocation;
  72337. private _checkManifestFile;
  72338. /**
  72339. * Open the database and make it available
  72340. * @param successCallback defines the callback to call on success
  72341. * @param errorCallback defines the callback to call on error
  72342. */
  72343. open(successCallback: () => void, errorCallback: () => void): void;
  72344. /**
  72345. * Loads an image from the database
  72346. * @param url defines the url to load from
  72347. * @param image defines the target DOM image
  72348. */
  72349. loadImage(url: string, image: HTMLImageElement): void;
  72350. private _loadImageFromDBAsync;
  72351. private _saveImageIntoDBAsync;
  72352. private _checkVersionFromDB;
  72353. private _loadVersionFromDBAsync;
  72354. private _saveVersionIntoDBAsync;
  72355. /**
  72356. * Loads a file from database
  72357. * @param url defines the URL to load from
  72358. * @param sceneLoaded defines a callback to call on success
  72359. * @param progressCallBack defines a callback to call when progress changed
  72360. * @param errorCallback defines a callback to call on error
  72361. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72362. */
  72363. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72364. private _loadFileAsync;
  72365. private _saveFileAsync;
  72366. /**
  72367. * Validates if xhr data is correct
  72368. * @param xhr defines the request to validate
  72369. * @param dataType defines the expected data type
  72370. * @returns true if data is correct
  72371. */
  72372. private static _ValidateXHRData;
  72373. }
  72374. }
  72375. declare module BABYLON {
  72376. /** @hidden */
  72377. export var gpuUpdateParticlesPixelShader: {
  72378. name: string;
  72379. shader: string;
  72380. };
  72381. }
  72382. declare module BABYLON {
  72383. /** @hidden */
  72384. export var gpuUpdateParticlesVertexShader: {
  72385. name: string;
  72386. shader: string;
  72387. };
  72388. }
  72389. declare module BABYLON {
  72390. /** @hidden */
  72391. export var clipPlaneFragmentDeclaration2: {
  72392. name: string;
  72393. shader: string;
  72394. };
  72395. }
  72396. declare module BABYLON {
  72397. /** @hidden */
  72398. export var gpuRenderParticlesPixelShader: {
  72399. name: string;
  72400. shader: string;
  72401. };
  72402. }
  72403. declare module BABYLON {
  72404. /** @hidden */
  72405. export var clipPlaneVertexDeclaration2: {
  72406. name: string;
  72407. shader: string;
  72408. };
  72409. }
  72410. declare module BABYLON {
  72411. /** @hidden */
  72412. export var gpuRenderParticlesVertexShader: {
  72413. name: string;
  72414. shader: string;
  72415. };
  72416. }
  72417. declare module BABYLON {
  72418. /**
  72419. * This represents a GPU particle system in Babylon
  72420. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72421. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72422. */
  72423. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72424. /**
  72425. * The layer mask we are rendering the particles through.
  72426. */
  72427. layerMask: number;
  72428. private _capacity;
  72429. private _activeCount;
  72430. private _currentActiveCount;
  72431. private _accumulatedCount;
  72432. private _renderEffect;
  72433. private _updateEffect;
  72434. private _buffer0;
  72435. private _buffer1;
  72436. private _spriteBuffer;
  72437. private _updateVAO;
  72438. private _renderVAO;
  72439. private _targetIndex;
  72440. private _sourceBuffer;
  72441. private _targetBuffer;
  72442. private _currentRenderId;
  72443. private _started;
  72444. private _stopped;
  72445. private _timeDelta;
  72446. private _randomTexture;
  72447. private _randomTexture2;
  72448. private _attributesStrideSize;
  72449. private _updateEffectOptions;
  72450. private _randomTextureSize;
  72451. private _actualFrame;
  72452. private _customEffect;
  72453. private readonly _rawTextureWidth;
  72454. /**
  72455. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72456. */
  72457. static get IsSupported(): boolean;
  72458. /**
  72459. * An event triggered when the system is disposed.
  72460. */
  72461. onDisposeObservable: Observable<IParticleSystem>;
  72462. /**
  72463. * An event triggered when the system is stopped
  72464. */
  72465. onStoppedObservable: Observable<IParticleSystem>;
  72466. /**
  72467. * Gets the maximum number of particles active at the same time.
  72468. * @returns The max number of active particles.
  72469. */
  72470. getCapacity(): number;
  72471. /**
  72472. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72473. * to override the particles.
  72474. */
  72475. forceDepthWrite: boolean;
  72476. /**
  72477. * Gets or set the number of active particles
  72478. */
  72479. get activeParticleCount(): number;
  72480. set activeParticleCount(value: number);
  72481. private _preWarmDone;
  72482. /**
  72483. * Specifies if the particles are updated in emitter local space or world space.
  72484. */
  72485. isLocal: boolean;
  72486. /** Gets or sets a matrix to use to compute projection */
  72487. defaultProjectionMatrix: Matrix;
  72488. /**
  72489. * Is this system ready to be used/rendered
  72490. * @return true if the system is ready
  72491. */
  72492. isReady(): boolean;
  72493. /**
  72494. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72495. * @returns True if it has been started, otherwise false.
  72496. */
  72497. isStarted(): boolean;
  72498. /**
  72499. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72500. * @returns True if it has been stopped, otherwise false.
  72501. */
  72502. isStopped(): boolean;
  72503. /**
  72504. * Gets a boolean indicating that the system is stopping
  72505. * @returns true if the system is currently stopping
  72506. */
  72507. isStopping(): boolean;
  72508. /**
  72509. * Gets the number of particles active at the same time.
  72510. * @returns The number of active particles.
  72511. */
  72512. getActiveCount(): number;
  72513. /**
  72514. * Starts the particle system and begins to emit
  72515. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72516. */
  72517. start(delay?: number): void;
  72518. /**
  72519. * Stops the particle system.
  72520. */
  72521. stop(): void;
  72522. /**
  72523. * Remove all active particles
  72524. */
  72525. reset(): void;
  72526. /**
  72527. * Returns the string "GPUParticleSystem"
  72528. * @returns a string containing the class name
  72529. */
  72530. getClassName(): string;
  72531. /**
  72532. * Gets the custom effect used to render the particles
  72533. * @param blendMode Blend mode for which the effect should be retrieved
  72534. * @returns The effect
  72535. */
  72536. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72537. /**
  72538. * Sets the custom effect used to render the particles
  72539. * @param effect The effect to set
  72540. * @param blendMode Blend mode for which the effect should be set
  72541. */
  72542. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72543. /** @hidden */
  72544. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72545. /**
  72546. * Observable that will be called just before the particles are drawn
  72547. */
  72548. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72549. /**
  72550. * Gets the name of the particle vertex shader
  72551. */
  72552. get vertexShaderName(): string;
  72553. private _colorGradientsTexture;
  72554. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72555. /**
  72556. * Adds a new color gradient
  72557. * @param gradient defines the gradient to use (between 0 and 1)
  72558. * @param color1 defines the color to affect to the specified gradient
  72559. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72560. * @returns the current particle system
  72561. */
  72562. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72563. private _refreshColorGradient;
  72564. /** Force the system to rebuild all gradients that need to be resync */
  72565. forceRefreshGradients(): void;
  72566. /**
  72567. * Remove a specific color gradient
  72568. * @param gradient defines the gradient to remove
  72569. * @returns the current particle system
  72570. */
  72571. removeColorGradient(gradient: number): GPUParticleSystem;
  72572. private _angularSpeedGradientsTexture;
  72573. private _sizeGradientsTexture;
  72574. private _velocityGradientsTexture;
  72575. private _limitVelocityGradientsTexture;
  72576. private _dragGradientsTexture;
  72577. private _addFactorGradient;
  72578. /**
  72579. * Adds a new size gradient
  72580. * @param gradient defines the gradient to use (between 0 and 1)
  72581. * @param factor defines the size factor to affect to the specified gradient
  72582. * @returns the current particle system
  72583. */
  72584. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72585. /**
  72586. * Remove a specific size gradient
  72587. * @param gradient defines the gradient to remove
  72588. * @returns the current particle system
  72589. */
  72590. removeSizeGradient(gradient: number): GPUParticleSystem;
  72591. private _refreshFactorGradient;
  72592. /**
  72593. * Adds a new angular speed gradient
  72594. * @param gradient defines the gradient to use (between 0 and 1)
  72595. * @param factor defines the angular speed to affect to the specified gradient
  72596. * @returns the current particle system
  72597. */
  72598. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72599. /**
  72600. * Remove a specific angular speed gradient
  72601. * @param gradient defines the gradient to remove
  72602. * @returns the current particle system
  72603. */
  72604. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72605. /**
  72606. * Adds a new velocity gradient
  72607. * @param gradient defines the gradient to use (between 0 and 1)
  72608. * @param factor defines the velocity to affect to the specified gradient
  72609. * @returns the current particle system
  72610. */
  72611. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72612. /**
  72613. * Remove a specific velocity gradient
  72614. * @param gradient defines the gradient to remove
  72615. * @returns the current particle system
  72616. */
  72617. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72618. /**
  72619. * Adds a new limit velocity gradient
  72620. * @param gradient defines the gradient to use (between 0 and 1)
  72621. * @param factor defines the limit velocity value to affect to the specified gradient
  72622. * @returns the current particle system
  72623. */
  72624. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72625. /**
  72626. * Remove a specific limit velocity gradient
  72627. * @param gradient defines the gradient to remove
  72628. * @returns the current particle system
  72629. */
  72630. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72631. /**
  72632. * Adds a new drag gradient
  72633. * @param gradient defines the gradient to use (between 0 and 1)
  72634. * @param factor defines the drag value to affect to the specified gradient
  72635. * @returns the current particle system
  72636. */
  72637. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72638. /**
  72639. * Remove a specific drag gradient
  72640. * @param gradient defines the gradient to remove
  72641. * @returns the current particle system
  72642. */
  72643. removeDragGradient(gradient: number): GPUParticleSystem;
  72644. /**
  72645. * Not supported by GPUParticleSystem
  72646. * @param gradient defines the gradient to use (between 0 and 1)
  72647. * @param factor defines the emit rate value to affect to the specified gradient
  72648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72649. * @returns the current particle system
  72650. */
  72651. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72652. /**
  72653. * Not supported by GPUParticleSystem
  72654. * @param gradient defines the gradient to remove
  72655. * @returns the current particle system
  72656. */
  72657. removeEmitRateGradient(gradient: number): IParticleSystem;
  72658. /**
  72659. * Not supported by GPUParticleSystem
  72660. * @param gradient defines the gradient to use (between 0 and 1)
  72661. * @param factor defines the start size value to affect to the specified gradient
  72662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72663. * @returns the current particle system
  72664. */
  72665. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72666. /**
  72667. * Not supported by GPUParticleSystem
  72668. * @param gradient defines the gradient to remove
  72669. * @returns the current particle system
  72670. */
  72671. removeStartSizeGradient(gradient: number): IParticleSystem;
  72672. /**
  72673. * Not supported by GPUParticleSystem
  72674. * @param gradient defines the gradient to use (between 0 and 1)
  72675. * @param min defines the color remap minimal range
  72676. * @param max defines the color remap maximal range
  72677. * @returns the current particle system
  72678. */
  72679. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72680. /**
  72681. * Not supported by GPUParticleSystem
  72682. * @param gradient defines the gradient to remove
  72683. * @returns the current particle system
  72684. */
  72685. removeColorRemapGradient(): IParticleSystem;
  72686. /**
  72687. * Not supported by GPUParticleSystem
  72688. * @param gradient defines the gradient to use (between 0 and 1)
  72689. * @param min defines the alpha remap minimal range
  72690. * @param max defines the alpha remap maximal range
  72691. * @returns the current particle system
  72692. */
  72693. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72694. /**
  72695. * Not supported by GPUParticleSystem
  72696. * @param gradient defines the gradient to remove
  72697. * @returns the current particle system
  72698. */
  72699. removeAlphaRemapGradient(): IParticleSystem;
  72700. /**
  72701. * Not supported by GPUParticleSystem
  72702. * @param gradient defines the gradient to use (between 0 and 1)
  72703. * @param color defines the color to affect to the specified gradient
  72704. * @returns the current particle system
  72705. */
  72706. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72707. /**
  72708. * Not supported by GPUParticleSystem
  72709. * @param gradient defines the gradient to remove
  72710. * @returns the current particle system
  72711. */
  72712. removeRampGradient(): IParticleSystem;
  72713. /**
  72714. * Not supported by GPUParticleSystem
  72715. * @returns the list of ramp gradients
  72716. */
  72717. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72718. /**
  72719. * Not supported by GPUParticleSystem
  72720. * Gets or sets a boolean indicating that ramp gradients must be used
  72721. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72722. */
  72723. get useRampGradients(): boolean;
  72724. set useRampGradients(value: boolean);
  72725. /**
  72726. * Not supported by GPUParticleSystem
  72727. * @param gradient defines the gradient to use (between 0 and 1)
  72728. * @param factor defines the life time factor to affect to the specified gradient
  72729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72730. * @returns the current particle system
  72731. */
  72732. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72733. /**
  72734. * Not supported by GPUParticleSystem
  72735. * @param gradient defines the gradient to remove
  72736. * @returns the current particle system
  72737. */
  72738. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72739. /**
  72740. * Instantiates a GPU particle system.
  72741. * 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.
  72742. * @param name The name of the particle system
  72743. * @param options The options used to create the system
  72744. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72745. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72746. * @param customEffect a custom effect used to change the way particles are rendered by default
  72747. */
  72748. constructor(name: string, options: Partial<{
  72749. capacity: number;
  72750. randomTextureSize: number;
  72751. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72752. protected _reset(): void;
  72753. private _createUpdateVAO;
  72754. private _createRenderVAO;
  72755. private _initialize;
  72756. /** @hidden */
  72757. _recreateUpdateEffect(): void;
  72758. private _getEffect;
  72759. /**
  72760. * Fill the defines array according to the current settings of the particle system
  72761. * @param defines Array to be updated
  72762. * @param blendMode blend mode to take into account when updating the array
  72763. */
  72764. fillDefines(defines: Array<string>, blendMode?: number): void;
  72765. /**
  72766. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72767. * @param uniforms Uniforms array to fill
  72768. * @param attributes Attributes array to fill
  72769. * @param samplers Samplers array to fill
  72770. */
  72771. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72772. /** @hidden */
  72773. _recreateRenderEffect(): Effect;
  72774. /**
  72775. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72776. * @param preWarm defines if we are in the pre-warmimg phase
  72777. */
  72778. animate(preWarm?: boolean): void;
  72779. private _createFactorGradientTexture;
  72780. private _createSizeGradientTexture;
  72781. private _createAngularSpeedGradientTexture;
  72782. private _createVelocityGradientTexture;
  72783. private _createLimitVelocityGradientTexture;
  72784. private _createDragGradientTexture;
  72785. private _createColorGradientTexture;
  72786. /**
  72787. * Renders the particle system in its current state
  72788. * @param preWarm defines if the system should only update the particles but not render them
  72789. * @returns the current number of particles
  72790. */
  72791. render(preWarm?: boolean): number;
  72792. /**
  72793. * Rebuilds the particle system
  72794. */
  72795. rebuild(): void;
  72796. private _releaseBuffers;
  72797. private _releaseVAOs;
  72798. /**
  72799. * Disposes the particle system and free the associated resources
  72800. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72801. */
  72802. dispose(disposeTexture?: boolean): void;
  72803. /**
  72804. * Clones the particle system.
  72805. * @param name The name of the cloned object
  72806. * @param newEmitter The new emitter to use
  72807. * @returns the cloned particle system
  72808. */
  72809. clone(name: string, newEmitter: any): GPUParticleSystem;
  72810. /**
  72811. * Serializes the particle system to a JSON object
  72812. * @param serializeTexture defines if the texture must be serialized as well
  72813. * @returns the JSON object
  72814. */
  72815. serialize(serializeTexture?: boolean): any;
  72816. /**
  72817. * Parses a JSON object to create a GPU particle system.
  72818. * @param parsedParticleSystem The JSON object to parse
  72819. * @param sceneOrEngine The scene or the engine to create the particle system in
  72820. * @param rootUrl The root url to use to load external dependencies like texture
  72821. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72822. * @returns the parsed GPU particle system
  72823. */
  72824. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72825. }
  72826. }
  72827. declare module BABYLON {
  72828. /**
  72829. * Represents a set of particle systems working together to create a specific effect
  72830. */
  72831. export class ParticleSystemSet implements IDisposable {
  72832. /**
  72833. * Gets or sets base Assets URL
  72834. */
  72835. static BaseAssetsUrl: string;
  72836. private _emitterCreationOptions;
  72837. private _emitterNode;
  72838. /**
  72839. * Gets the particle system list
  72840. */
  72841. systems: IParticleSystem[];
  72842. /**
  72843. * Gets the emitter node used with this set
  72844. */
  72845. get emitterNode(): Nullable<TransformNode>;
  72846. /**
  72847. * Creates a new emitter mesh as a sphere
  72848. * @param options defines the options used to create the sphere
  72849. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72850. * @param scene defines the hosting scene
  72851. */
  72852. setEmitterAsSphere(options: {
  72853. diameter: number;
  72854. segments: number;
  72855. color: Color3;
  72856. }, renderingGroupId: number, scene: Scene): void;
  72857. /**
  72858. * Starts all particle systems of the set
  72859. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72860. */
  72861. start(emitter?: AbstractMesh): void;
  72862. /**
  72863. * Release all associated resources
  72864. */
  72865. dispose(): void;
  72866. /**
  72867. * Serialize the set into a JSON compatible object
  72868. * @param serializeTexture defines if the texture must be serialized as well
  72869. * @returns a JSON compatible representation of the set
  72870. */
  72871. serialize(serializeTexture?: boolean): any;
  72872. /**
  72873. * Parse a new ParticleSystemSet from a serialized source
  72874. * @param data defines a JSON compatible representation of the set
  72875. * @param scene defines the hosting scene
  72876. * @param gpu defines if we want GPU particles or CPU particles
  72877. * @returns a new ParticleSystemSet
  72878. */
  72879. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72880. }
  72881. }
  72882. declare module BABYLON {
  72883. /**
  72884. * This class is made for on one-liner static method to help creating particle system set.
  72885. */
  72886. export class ParticleHelper {
  72887. /**
  72888. * Gets or sets base Assets URL
  72889. */
  72890. static BaseAssetsUrl: string;
  72891. /** Define the Url to load snippets */
  72892. static SnippetUrl: string;
  72893. /**
  72894. * Create a default particle system that you can tweak
  72895. * @param emitter defines the emitter to use
  72896. * @param capacity defines the system capacity (default is 500 particles)
  72897. * @param scene defines the hosting scene
  72898. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72899. * @returns the new Particle system
  72900. */
  72901. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72902. /**
  72903. * This is the main static method (one-liner) of this helper to create different particle systems
  72904. * @param type This string represents the type to the particle system to create
  72905. * @param scene The scene where the particle system should live
  72906. * @param gpu If the system will use gpu
  72907. * @returns the ParticleSystemSet created
  72908. */
  72909. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72910. /**
  72911. * Static function used to export a particle system to a ParticleSystemSet variable.
  72912. * Please note that the emitter shape is not exported
  72913. * @param systems defines the particle systems to export
  72914. * @returns the created particle system set
  72915. */
  72916. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72917. /**
  72918. * Creates a particle system from a snippet saved in a remote file
  72919. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72920. * @param url defines the url to load from
  72921. * @param scene defines the hosting scene
  72922. * @param gpu If the system will use gpu
  72923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72924. * @returns a promise that will resolve to the new particle system
  72925. */
  72926. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72927. /**
  72928. * Creates a particle system from a snippet saved by the particle system editor
  72929. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72930. * @param scene defines the hosting scene
  72931. * @param gpu If the system will use gpu
  72932. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72933. * @returns a promise that will resolve to the new particle system
  72934. */
  72935. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72936. }
  72937. }
  72938. declare module BABYLON {
  72939. interface Engine {
  72940. /**
  72941. * Create an effect to use with particle systems.
  72942. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72943. * the particle system for which you want to create a custom effect in the last parameter
  72944. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72945. * @param uniformsNames defines a list of attribute names
  72946. * @param samplers defines an array of string used to represent textures
  72947. * @param defines defines the string containing the defines to use to compile the shaders
  72948. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72949. * @param onCompiled defines a function to call when the effect creation is successful
  72950. * @param onError defines a function to call when the effect creation has failed
  72951. * @param particleSystem the particle system you want to create the effect for
  72952. * @returns the new Effect
  72953. */
  72954. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72955. }
  72956. interface Mesh {
  72957. /**
  72958. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72959. * @returns an array of IParticleSystem
  72960. */
  72961. getEmittedParticleSystems(): IParticleSystem[];
  72962. /**
  72963. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72964. * @returns an array of IParticleSystem
  72965. */
  72966. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72967. }
  72968. }
  72969. declare module BABYLON {
  72970. /** Defines the 4 color options */
  72971. export enum PointColor {
  72972. /** color value */
  72973. Color = 2,
  72974. /** uv value */
  72975. UV = 1,
  72976. /** random value */
  72977. Random = 0,
  72978. /** stated value */
  72979. Stated = 3
  72980. }
  72981. /**
  72982. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72983. * 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.
  72984. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72985. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72986. *
  72987. * Full documentation here : TO BE ENTERED
  72988. */
  72989. export class PointsCloudSystem implements IDisposable {
  72990. /**
  72991. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72992. * Example : var p = SPS.particles[i];
  72993. */
  72994. particles: CloudPoint[];
  72995. /**
  72996. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72997. */
  72998. nbParticles: number;
  72999. /**
  73000. * This a counter for your own usage. It's not set by any SPS functions.
  73001. */
  73002. counter: number;
  73003. /**
  73004. * The PCS name. This name is also given to the underlying mesh.
  73005. */
  73006. name: string;
  73007. /**
  73008. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  73009. */
  73010. mesh: Mesh;
  73011. /**
  73012. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73013. * Please read :
  73014. */
  73015. vars: any;
  73016. /**
  73017. * @hidden
  73018. */
  73019. _size: number;
  73020. private _scene;
  73021. private _promises;
  73022. private _positions;
  73023. private _indices;
  73024. private _normals;
  73025. private _colors;
  73026. private _uvs;
  73027. private _indices32;
  73028. private _positions32;
  73029. private _colors32;
  73030. private _uvs32;
  73031. private _updatable;
  73032. private _isVisibilityBoxLocked;
  73033. private _alwaysVisible;
  73034. private _groups;
  73035. private _groupCounter;
  73036. private _computeParticleColor;
  73037. private _computeParticleTexture;
  73038. private _computeParticleRotation;
  73039. private _computeBoundingBox;
  73040. private _isReady;
  73041. /**
  73042. * Creates a PCS (Points Cloud System) object
  73043. * @param name (String) is the PCS name, this will be the underlying mesh name
  73044. * @param pointSize (number) is the size for each point
  73045. * @param scene (Scene) is the scene in which the PCS is added
  73046. * @param options defines the options of the PCS e.g.
  73047. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73048. */
  73049. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73050. updatable?: boolean;
  73051. });
  73052. /**
  73053. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73054. * If no points were added to the PCS, the returned mesh is just a single point.
  73055. * @returns a promise for the created mesh
  73056. */
  73057. buildMeshAsync(): Promise<Mesh>;
  73058. /**
  73059. * @hidden
  73060. */
  73061. private _buildMesh;
  73062. private _addParticle;
  73063. private _randomUnitVector;
  73064. private _getColorIndicesForCoord;
  73065. private _setPointsColorOrUV;
  73066. private _colorFromTexture;
  73067. private _calculateDensity;
  73068. /**
  73069. * Adds points to the PCS in random positions within a unit sphere
  73070. * @param nb (positive integer) the number of particles to be created from this model
  73071. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73072. * @returns the number of groups in the system
  73073. */
  73074. addPoints(nb: number, pointFunction?: any): number;
  73075. /**
  73076. * Adds points to the PCS from the surface of the model shape
  73077. * @param mesh is any Mesh object that will be used as a surface model for the points
  73078. * @param nb (positive integer) the number of particles to be created from this model
  73079. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73080. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73081. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73082. * @returns the number of groups in the system
  73083. */
  73084. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73085. /**
  73086. * Adds points to the PCS inside the model shape
  73087. * @param mesh is any Mesh object that will be used as a surface model for the points
  73088. * @param nb (positive integer) the number of particles to be created from this model
  73089. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73090. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73091. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73092. * @returns the number of groups in the system
  73093. */
  73094. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73095. /**
  73096. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73097. * This method calls `updateParticle()` for each particle of the SPS.
  73098. * For an animated SPS, it is usually called within the render loop.
  73099. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73100. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73101. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73102. * @returns the PCS.
  73103. */
  73104. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73105. /**
  73106. * Disposes the PCS.
  73107. */
  73108. dispose(): void;
  73109. /**
  73110. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73111. * doc :
  73112. * @returns the PCS.
  73113. */
  73114. refreshVisibleSize(): PointsCloudSystem;
  73115. /**
  73116. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73117. * @param size the size (float) of the visibility box
  73118. * note : this doesn't lock the PCS mesh bounding box.
  73119. * doc :
  73120. */
  73121. setVisibilityBox(size: number): void;
  73122. /**
  73123. * Gets whether the PCS is always visible or not
  73124. * doc :
  73125. */
  73126. get isAlwaysVisible(): boolean;
  73127. /**
  73128. * Sets the PCS as always visible or not
  73129. * doc :
  73130. */
  73131. set isAlwaysVisible(val: boolean);
  73132. /**
  73133. * Tells to `setParticles()` to compute the particle rotations or not
  73134. * Default value : false. The PCS is faster when it's set to false
  73135. * Note : particle rotations are only applied to parent particles
  73136. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73137. */
  73138. set computeParticleRotation(val: boolean);
  73139. /**
  73140. * Tells to `setParticles()` to compute the particle colors or not.
  73141. * Default value : true. The PCS is faster when it's set to false.
  73142. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73143. */
  73144. set computeParticleColor(val: boolean);
  73145. set computeParticleTexture(val: boolean);
  73146. /**
  73147. * Gets if `setParticles()` computes the particle colors or not.
  73148. * Default value : false. The PCS is faster when it's set to false.
  73149. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73150. */
  73151. get computeParticleColor(): boolean;
  73152. /**
  73153. * Gets if `setParticles()` computes the particle textures or not.
  73154. * Default value : false. The PCS is faster when it's set to false.
  73155. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73156. */
  73157. get computeParticleTexture(): boolean;
  73158. /**
  73159. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73160. */
  73161. set computeBoundingBox(val: boolean);
  73162. /**
  73163. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73164. */
  73165. get computeBoundingBox(): boolean;
  73166. /**
  73167. * This function does nothing. It may be overwritten to set all the particle first values.
  73168. * The PCS doesn't call this function, you may have to call it by your own.
  73169. * doc :
  73170. */
  73171. initParticles(): void;
  73172. /**
  73173. * This function does nothing. It may be overwritten to recycle a particle
  73174. * The PCS doesn't call this function, you can to call it
  73175. * doc :
  73176. * @param particle The particle to recycle
  73177. * @returns the recycled particle
  73178. */
  73179. recycleParticle(particle: CloudPoint): CloudPoint;
  73180. /**
  73181. * Updates a particle : this function should be overwritten by the user.
  73182. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73183. * doc :
  73184. * @example : just set a particle position or velocity and recycle conditions
  73185. * @param particle The particle to update
  73186. * @returns the updated particle
  73187. */
  73188. updateParticle(particle: CloudPoint): CloudPoint;
  73189. /**
  73190. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73191. * This does nothing and may be overwritten by the user.
  73192. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73193. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73194. * @param update the boolean update value actually passed to setParticles()
  73195. */
  73196. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73197. /**
  73198. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73199. * This will be passed three parameters.
  73200. * This does nothing and may be overwritten by the user.
  73201. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73202. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73203. * @param update the boolean update value actually passed to setParticles()
  73204. */
  73205. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. /**
  73210. * Represents one particle of a points cloud system.
  73211. */
  73212. export class CloudPoint {
  73213. /**
  73214. * particle global index
  73215. */
  73216. idx: number;
  73217. /**
  73218. * The color of the particle
  73219. */
  73220. color: Nullable<Color4>;
  73221. /**
  73222. * The world space position of the particle.
  73223. */
  73224. position: Vector3;
  73225. /**
  73226. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73227. */
  73228. rotation: Vector3;
  73229. /**
  73230. * The world space rotation quaternion of the particle.
  73231. */
  73232. rotationQuaternion: Nullable<Quaternion>;
  73233. /**
  73234. * The uv of the particle.
  73235. */
  73236. uv: Nullable<Vector2>;
  73237. /**
  73238. * The current speed of the particle.
  73239. */
  73240. velocity: Vector3;
  73241. /**
  73242. * The pivot point in the particle local space.
  73243. */
  73244. pivot: Vector3;
  73245. /**
  73246. * Must the particle be translated from its pivot point in its local space ?
  73247. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73248. * Default : false
  73249. */
  73250. translateFromPivot: boolean;
  73251. /**
  73252. * Index of this particle in the global "positions" array (Internal use)
  73253. * @hidden
  73254. */
  73255. _pos: number;
  73256. /**
  73257. * @hidden Index of this particle in the global "indices" array (Internal use)
  73258. */
  73259. _ind: number;
  73260. /**
  73261. * Group this particle belongs to
  73262. */
  73263. _group: PointsGroup;
  73264. /**
  73265. * Group id of this particle
  73266. */
  73267. groupId: number;
  73268. /**
  73269. * Index of the particle in its group id (Internal use)
  73270. */
  73271. idxInGroup: number;
  73272. /**
  73273. * @hidden Particle BoundingInfo object (Internal use)
  73274. */
  73275. _boundingInfo: BoundingInfo;
  73276. /**
  73277. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73278. */
  73279. _pcs: PointsCloudSystem;
  73280. /**
  73281. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73282. */
  73283. _stillInvisible: boolean;
  73284. /**
  73285. * @hidden Last computed particle rotation matrix
  73286. */
  73287. _rotationMatrix: number[];
  73288. /**
  73289. * Parent particle Id, if any.
  73290. * Default null.
  73291. */
  73292. parentId: Nullable<number>;
  73293. /**
  73294. * @hidden Internal global position in the PCS.
  73295. */
  73296. _globalPosition: Vector3;
  73297. /**
  73298. * Creates a Point Cloud object.
  73299. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73300. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73301. * @param group (PointsGroup) is the group the particle belongs to
  73302. * @param groupId (integer) is the group identifier in the PCS.
  73303. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73304. * @param pcs defines the PCS it is associated to
  73305. */
  73306. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73307. /**
  73308. * get point size
  73309. */
  73310. get size(): Vector3;
  73311. /**
  73312. * Set point size
  73313. */
  73314. set size(scale: Vector3);
  73315. /**
  73316. * Legacy support, changed quaternion to rotationQuaternion
  73317. */
  73318. get quaternion(): Nullable<Quaternion>;
  73319. /**
  73320. * Legacy support, changed quaternion to rotationQuaternion
  73321. */
  73322. set quaternion(q: Nullable<Quaternion>);
  73323. /**
  73324. * Returns a boolean. True if the particle intersects a mesh, else false
  73325. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73326. * @param target is the object (point or mesh) what the intersection is computed against
  73327. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73328. * @returns true if it intersects
  73329. */
  73330. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73331. /**
  73332. * get the rotation matrix of the particle
  73333. * @hidden
  73334. */
  73335. getRotationMatrix(m: Matrix): void;
  73336. }
  73337. /**
  73338. * Represents a group of points in a points cloud system
  73339. * * PCS internal tool, don't use it manually.
  73340. */
  73341. export class PointsGroup {
  73342. /**
  73343. * The group id
  73344. * @hidden
  73345. */
  73346. groupID: number;
  73347. /**
  73348. * image data for group (internal use)
  73349. * @hidden
  73350. */
  73351. _groupImageData: Nullable<ArrayBufferView>;
  73352. /**
  73353. * Image Width (internal use)
  73354. * @hidden
  73355. */
  73356. _groupImgWidth: number;
  73357. /**
  73358. * Image Height (internal use)
  73359. * @hidden
  73360. */
  73361. _groupImgHeight: number;
  73362. /**
  73363. * Custom position function (internal use)
  73364. * @hidden
  73365. */
  73366. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73367. /**
  73368. * density per facet for surface points
  73369. * @hidden
  73370. */
  73371. _groupDensity: number[];
  73372. /**
  73373. * Only when points are colored by texture carries pointer to texture list array
  73374. * @hidden
  73375. */
  73376. _textureNb: number;
  73377. /**
  73378. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73379. * PCS internal tool, don't use it manually.
  73380. * @hidden
  73381. */
  73382. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73383. }
  73384. }
  73385. declare module BABYLON {
  73386. interface Scene {
  73387. /** @hidden (Backing field) */
  73388. _physicsEngine: Nullable<IPhysicsEngine>;
  73389. /** @hidden */
  73390. _physicsTimeAccumulator: number;
  73391. /**
  73392. * Gets the current physics engine
  73393. * @returns a IPhysicsEngine or null if none attached
  73394. */
  73395. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73396. /**
  73397. * Enables physics to the current scene
  73398. * @param gravity defines the scene's gravity for the physics engine
  73399. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73400. * @return a boolean indicating if the physics engine was initialized
  73401. */
  73402. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73403. /**
  73404. * Disables and disposes the physics engine associated with the scene
  73405. */
  73406. disablePhysicsEngine(): void;
  73407. /**
  73408. * Gets a boolean indicating if there is an active physics engine
  73409. * @returns a boolean indicating if there is an active physics engine
  73410. */
  73411. isPhysicsEnabled(): boolean;
  73412. /**
  73413. * Deletes a physics compound impostor
  73414. * @param compound defines the compound to delete
  73415. */
  73416. deleteCompoundImpostor(compound: any): void;
  73417. /**
  73418. * An event triggered when physic simulation is about to be run
  73419. */
  73420. onBeforePhysicsObservable: Observable<Scene>;
  73421. /**
  73422. * An event triggered when physic simulation has been done
  73423. */
  73424. onAfterPhysicsObservable: Observable<Scene>;
  73425. }
  73426. interface AbstractMesh {
  73427. /** @hidden */
  73428. _physicsImpostor: Nullable<PhysicsImpostor>;
  73429. /**
  73430. * Gets or sets impostor used for physic simulation
  73431. * @see https://doc.babylonjs.com/features/physics_engine
  73432. */
  73433. physicsImpostor: Nullable<PhysicsImpostor>;
  73434. /**
  73435. * Gets the current physics impostor
  73436. * @see https://doc.babylonjs.com/features/physics_engine
  73437. * @returns a physics impostor or null
  73438. */
  73439. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73440. /** Apply a physic impulse to the mesh
  73441. * @param force defines the force to apply
  73442. * @param contactPoint defines where to apply the force
  73443. * @returns the current mesh
  73444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73445. */
  73446. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73447. /**
  73448. * Creates a physic joint between two meshes
  73449. * @param otherMesh defines the other mesh to use
  73450. * @param pivot1 defines the pivot to use on this mesh
  73451. * @param pivot2 defines the pivot to use on the other mesh
  73452. * @param options defines additional options (can be plugin dependent)
  73453. * @returns the current mesh
  73454. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73455. */
  73456. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73457. /** @hidden */
  73458. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73459. }
  73460. /**
  73461. * Defines the physics engine scene component responsible to manage a physics engine
  73462. */
  73463. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73464. /**
  73465. * The component name helpful to identify the component in the list of scene components.
  73466. */
  73467. readonly name: string;
  73468. /**
  73469. * The scene the component belongs to.
  73470. */
  73471. scene: Scene;
  73472. /**
  73473. * Creates a new instance of the component for the given scene
  73474. * @param scene Defines the scene to register the component in
  73475. */
  73476. constructor(scene: Scene);
  73477. /**
  73478. * Registers the component in a given scene
  73479. */
  73480. register(): void;
  73481. /**
  73482. * Rebuilds the elements related to this component in case of
  73483. * context lost for instance.
  73484. */
  73485. rebuild(): void;
  73486. /**
  73487. * Disposes the component and the associated resources
  73488. */
  73489. dispose(): void;
  73490. }
  73491. }
  73492. declare module BABYLON {
  73493. /**
  73494. * A helper for physics simulations
  73495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73496. */
  73497. export class PhysicsHelper {
  73498. private _scene;
  73499. private _physicsEngine;
  73500. /**
  73501. * Initializes the Physics helper
  73502. * @param scene Babylon.js scene
  73503. */
  73504. constructor(scene: Scene);
  73505. /**
  73506. * Applies a radial explosion impulse
  73507. * @param origin the origin of the explosion
  73508. * @param radiusOrEventOptions the radius or the options of radial explosion
  73509. * @param strength the explosion strength
  73510. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73511. * @returns A physics radial explosion event, or null
  73512. */
  73513. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73514. /**
  73515. * Applies a radial explosion force
  73516. * @param origin the origin of the explosion
  73517. * @param radiusOrEventOptions the radius or the options of radial explosion
  73518. * @param strength the explosion strength
  73519. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73520. * @returns A physics radial explosion event, or null
  73521. */
  73522. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73523. /**
  73524. * Creates a gravitational field
  73525. * @param origin the origin of the explosion
  73526. * @param radiusOrEventOptions the radius or the options of radial explosion
  73527. * @param strength the explosion strength
  73528. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73529. * @returns A physics gravitational field event, or null
  73530. */
  73531. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73532. /**
  73533. * Creates a physics updraft event
  73534. * @param origin the origin of the updraft
  73535. * @param radiusOrEventOptions the radius or the options of the updraft
  73536. * @param strength the strength of the updraft
  73537. * @param height the height of the updraft
  73538. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73539. * @returns A physics updraft event, or null
  73540. */
  73541. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73542. /**
  73543. * Creates a physics vortex event
  73544. * @param origin the of the vortex
  73545. * @param radiusOrEventOptions the radius or the options of the vortex
  73546. * @param strength the strength of the vortex
  73547. * @param height the height of the vortex
  73548. * @returns a Physics vortex event, or null
  73549. * A physics vortex event or null
  73550. */
  73551. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73552. }
  73553. /**
  73554. * Represents a physics radial explosion event
  73555. */
  73556. class PhysicsRadialExplosionEvent {
  73557. private _scene;
  73558. private _options;
  73559. private _sphere;
  73560. private _dataFetched;
  73561. /**
  73562. * Initializes a radial explosion event
  73563. * @param _scene BabylonJS scene
  73564. * @param _options The options for the vortex event
  73565. */
  73566. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73567. /**
  73568. * Returns the data related to the radial explosion event (sphere).
  73569. * @returns The radial explosion event data
  73570. */
  73571. getData(): PhysicsRadialExplosionEventData;
  73572. /**
  73573. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73574. * @param impostor A physics imposter
  73575. * @param origin the origin of the explosion
  73576. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73577. */
  73578. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73579. /**
  73580. * Triggers affected impostors callbacks
  73581. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73582. */
  73583. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73584. /**
  73585. * Disposes the sphere.
  73586. * @param force Specifies if the sphere should be disposed by force
  73587. */
  73588. dispose(force?: boolean): void;
  73589. /*** Helpers ***/
  73590. private _prepareSphere;
  73591. private _intersectsWithSphere;
  73592. }
  73593. /**
  73594. * Represents a gravitational field event
  73595. */
  73596. class PhysicsGravitationalFieldEvent {
  73597. private _physicsHelper;
  73598. private _scene;
  73599. private _origin;
  73600. private _options;
  73601. private _tickCallback;
  73602. private _sphere;
  73603. private _dataFetched;
  73604. /**
  73605. * Initializes the physics gravitational field event
  73606. * @param _physicsHelper A physics helper
  73607. * @param _scene BabylonJS scene
  73608. * @param _origin The origin position of the gravitational field event
  73609. * @param _options The options for the vortex event
  73610. */
  73611. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73612. /**
  73613. * Returns the data related to the gravitational field event (sphere).
  73614. * @returns A gravitational field event
  73615. */
  73616. getData(): PhysicsGravitationalFieldEventData;
  73617. /**
  73618. * Enables the gravitational field.
  73619. */
  73620. enable(): void;
  73621. /**
  73622. * Disables the gravitational field.
  73623. */
  73624. disable(): void;
  73625. /**
  73626. * Disposes the sphere.
  73627. * @param force The force to dispose from the gravitational field event
  73628. */
  73629. dispose(force?: boolean): void;
  73630. private _tick;
  73631. }
  73632. /**
  73633. * Represents a physics updraft event
  73634. */
  73635. class PhysicsUpdraftEvent {
  73636. private _scene;
  73637. private _origin;
  73638. private _options;
  73639. private _physicsEngine;
  73640. private _originTop;
  73641. private _originDirection;
  73642. private _tickCallback;
  73643. private _cylinder;
  73644. private _cylinderPosition;
  73645. private _dataFetched;
  73646. /**
  73647. * Initializes the physics updraft event
  73648. * @param _scene BabylonJS scene
  73649. * @param _origin The origin position of the updraft
  73650. * @param _options The options for the updraft event
  73651. */
  73652. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73653. /**
  73654. * Returns the data related to the updraft event (cylinder).
  73655. * @returns A physics updraft event
  73656. */
  73657. getData(): PhysicsUpdraftEventData;
  73658. /**
  73659. * Enables the updraft.
  73660. */
  73661. enable(): void;
  73662. /**
  73663. * Disables the updraft.
  73664. */
  73665. disable(): void;
  73666. /**
  73667. * Disposes the cylinder.
  73668. * @param force Specifies if the updraft should be disposed by force
  73669. */
  73670. dispose(force?: boolean): void;
  73671. private getImpostorHitData;
  73672. private _tick;
  73673. /*** Helpers ***/
  73674. private _prepareCylinder;
  73675. private _intersectsWithCylinder;
  73676. }
  73677. /**
  73678. * Represents a physics vortex event
  73679. */
  73680. class PhysicsVortexEvent {
  73681. private _scene;
  73682. private _origin;
  73683. private _options;
  73684. private _physicsEngine;
  73685. private _originTop;
  73686. private _tickCallback;
  73687. private _cylinder;
  73688. private _cylinderPosition;
  73689. private _dataFetched;
  73690. /**
  73691. * Initializes the physics vortex event
  73692. * @param _scene The BabylonJS scene
  73693. * @param _origin The origin position of the vortex
  73694. * @param _options The options for the vortex event
  73695. */
  73696. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73697. /**
  73698. * Returns the data related to the vortex event (cylinder).
  73699. * @returns The physics vortex event data
  73700. */
  73701. getData(): PhysicsVortexEventData;
  73702. /**
  73703. * Enables the vortex.
  73704. */
  73705. enable(): void;
  73706. /**
  73707. * Disables the cortex.
  73708. */
  73709. disable(): void;
  73710. /**
  73711. * Disposes the sphere.
  73712. * @param force
  73713. */
  73714. dispose(force?: boolean): void;
  73715. private getImpostorHitData;
  73716. private _tick;
  73717. /*** Helpers ***/
  73718. private _prepareCylinder;
  73719. private _intersectsWithCylinder;
  73720. }
  73721. /**
  73722. * Options fot the radial explosion event
  73723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73724. */
  73725. export class PhysicsRadialExplosionEventOptions {
  73726. /**
  73727. * The radius of the sphere for the radial explosion.
  73728. */
  73729. radius: number;
  73730. /**
  73731. * The strength of the explosion.
  73732. */
  73733. strength: number;
  73734. /**
  73735. * The strength of the force in correspondence to the distance of the affected object
  73736. */
  73737. falloff: PhysicsRadialImpulseFalloff;
  73738. /**
  73739. * Sphere options for the radial explosion.
  73740. */
  73741. sphere: {
  73742. segments: number;
  73743. diameter: number;
  73744. };
  73745. /**
  73746. * Sphere options for the radial explosion.
  73747. */
  73748. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73749. }
  73750. /**
  73751. * Options fot the updraft event
  73752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73753. */
  73754. export class PhysicsUpdraftEventOptions {
  73755. /**
  73756. * The radius of the cylinder for the vortex
  73757. */
  73758. radius: number;
  73759. /**
  73760. * The strength of the updraft.
  73761. */
  73762. strength: number;
  73763. /**
  73764. * The height of the cylinder for the updraft.
  73765. */
  73766. height: number;
  73767. /**
  73768. * The mode for the the updraft.
  73769. */
  73770. updraftMode: PhysicsUpdraftMode;
  73771. }
  73772. /**
  73773. * Options fot the vortex event
  73774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73775. */
  73776. export class PhysicsVortexEventOptions {
  73777. /**
  73778. * The radius of the cylinder for the vortex
  73779. */
  73780. radius: number;
  73781. /**
  73782. * The strength of the vortex.
  73783. */
  73784. strength: number;
  73785. /**
  73786. * The height of the cylinder for the vortex.
  73787. */
  73788. height: number;
  73789. /**
  73790. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73791. */
  73792. centripetalForceThreshold: number;
  73793. /**
  73794. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73795. */
  73796. centripetalForceMultiplier: number;
  73797. /**
  73798. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73799. */
  73800. centrifugalForceMultiplier: number;
  73801. /**
  73802. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73803. */
  73804. updraftForceMultiplier: number;
  73805. }
  73806. /**
  73807. * The strength of the force in correspondence to the distance of the affected object
  73808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73809. */
  73810. export enum PhysicsRadialImpulseFalloff {
  73811. /** Defines that impulse is constant in strength across it's whole radius */
  73812. Constant = 0,
  73813. /** Defines that impulse gets weaker if it's further from the origin */
  73814. Linear = 1
  73815. }
  73816. /**
  73817. * The strength of the force in correspondence to the distance of the affected object
  73818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73819. */
  73820. export enum PhysicsUpdraftMode {
  73821. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73822. Center = 0,
  73823. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73824. Perpendicular = 1
  73825. }
  73826. /**
  73827. * Interface for a physics hit data
  73828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73829. */
  73830. export interface PhysicsHitData {
  73831. /**
  73832. * The force applied at the contact point
  73833. */
  73834. force: Vector3;
  73835. /**
  73836. * The contact point
  73837. */
  73838. contactPoint: Vector3;
  73839. /**
  73840. * The distance from the origin to the contact point
  73841. */
  73842. distanceFromOrigin: number;
  73843. }
  73844. /**
  73845. * Interface for radial explosion event data
  73846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73847. */
  73848. export interface PhysicsRadialExplosionEventData {
  73849. /**
  73850. * A sphere used for the radial explosion event
  73851. */
  73852. sphere: Mesh;
  73853. }
  73854. /**
  73855. * Interface for gravitational field event data
  73856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73857. */
  73858. export interface PhysicsGravitationalFieldEventData {
  73859. /**
  73860. * A sphere mesh used for the gravitational field event
  73861. */
  73862. sphere: Mesh;
  73863. }
  73864. /**
  73865. * Interface for updraft event data
  73866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73867. */
  73868. export interface PhysicsUpdraftEventData {
  73869. /**
  73870. * A cylinder used for the updraft event
  73871. */
  73872. cylinder: Mesh;
  73873. }
  73874. /**
  73875. * Interface for vortex event data
  73876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73877. */
  73878. export interface PhysicsVortexEventData {
  73879. /**
  73880. * A cylinder used for the vortex event
  73881. */
  73882. cylinder: Mesh;
  73883. }
  73884. /**
  73885. * Interface for an affected physics impostor
  73886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73887. */
  73888. export interface PhysicsAffectedImpostorWithData {
  73889. /**
  73890. * The impostor affected by the effect
  73891. */
  73892. impostor: PhysicsImpostor;
  73893. /**
  73894. * The data about the hit/force from the explosion
  73895. */
  73896. hitData: PhysicsHitData;
  73897. }
  73898. }
  73899. declare module BABYLON {
  73900. /** @hidden */
  73901. export var blackAndWhitePixelShader: {
  73902. name: string;
  73903. shader: string;
  73904. };
  73905. }
  73906. declare module BABYLON {
  73907. /**
  73908. * Post process used to render in black and white
  73909. */
  73910. export class BlackAndWhitePostProcess extends PostProcess {
  73911. /**
  73912. * Linear about to convert he result to black and white (default: 1)
  73913. */
  73914. degree: number;
  73915. /**
  73916. * Gets a string identifying the name of the class
  73917. * @returns "BlackAndWhitePostProcess" string
  73918. */
  73919. getClassName(): string;
  73920. /**
  73921. * Creates a black and white post process
  73922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73923. * @param name The name of the effect.
  73924. * @param options The required width/height ratio to downsize to before computing the render pass.
  73925. * @param camera The camera to apply the render pass to.
  73926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73927. * @param engine The engine which the post process will be applied. (default: current engine)
  73928. * @param reusable If the post process can be reused on the same frame. (default: false)
  73929. */
  73930. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73931. /** @hidden */
  73932. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73933. }
  73934. }
  73935. declare module BABYLON {
  73936. /**
  73937. * This represents a set of one or more post processes in Babylon.
  73938. * A post process can be used to apply a shader to a texture after it is rendered.
  73939. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73940. */
  73941. export class PostProcessRenderEffect {
  73942. private _postProcesses;
  73943. private _getPostProcesses;
  73944. private _singleInstance;
  73945. private _cameras;
  73946. private _indicesForCamera;
  73947. /**
  73948. * Name of the effect
  73949. * @hidden
  73950. */
  73951. _name: string;
  73952. /**
  73953. * Instantiates a post process render effect.
  73954. * A post process can be used to apply a shader to a texture after it is rendered.
  73955. * @param engine The engine the effect is tied to
  73956. * @param name The name of the effect
  73957. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73958. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73959. */
  73960. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73961. /**
  73962. * Checks if all the post processes in the effect are supported.
  73963. */
  73964. get isSupported(): boolean;
  73965. /**
  73966. * Updates the current state of the effect
  73967. * @hidden
  73968. */
  73969. _update(): void;
  73970. /**
  73971. * Attaches the effect on cameras
  73972. * @param cameras The camera to attach to.
  73973. * @hidden
  73974. */
  73975. _attachCameras(cameras: Camera): void;
  73976. /**
  73977. * Attaches the effect on cameras
  73978. * @param cameras The camera to attach to.
  73979. * @hidden
  73980. */
  73981. _attachCameras(cameras: Camera[]): void;
  73982. /**
  73983. * Detaches the effect on cameras
  73984. * @param cameras The camera to detach from.
  73985. * @hidden
  73986. */
  73987. _detachCameras(cameras: Camera): void;
  73988. /**
  73989. * Detaches the effect on cameras
  73990. * @param cameras The camera to detach from.
  73991. * @hidden
  73992. */
  73993. _detachCameras(cameras: Camera[]): void;
  73994. /**
  73995. * Enables the effect on given cameras
  73996. * @param cameras The camera to enable.
  73997. * @hidden
  73998. */
  73999. _enable(cameras: Camera): void;
  74000. /**
  74001. * Enables the effect on given cameras
  74002. * @param cameras The camera to enable.
  74003. * @hidden
  74004. */
  74005. _enable(cameras: Nullable<Camera[]>): void;
  74006. /**
  74007. * Disables the effect on the given cameras
  74008. * @param cameras The camera to disable.
  74009. * @hidden
  74010. */
  74011. _disable(cameras: Camera): void;
  74012. /**
  74013. * Disables the effect on the given cameras
  74014. * @param cameras The camera to disable.
  74015. * @hidden
  74016. */
  74017. _disable(cameras: Nullable<Camera[]>): void;
  74018. /**
  74019. * Gets a list of the post processes contained in the effect.
  74020. * @param camera The camera to get the post processes on.
  74021. * @returns The list of the post processes in the effect.
  74022. */
  74023. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74024. }
  74025. }
  74026. declare module BABYLON {
  74027. /** @hidden */
  74028. export var extractHighlightsPixelShader: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * 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.
  74036. */
  74037. export class ExtractHighlightsPostProcess extends PostProcess {
  74038. /**
  74039. * The luminance threshold, pixels below this value will be set to black.
  74040. */
  74041. threshold: number;
  74042. /** @hidden */
  74043. _exposure: number;
  74044. /**
  74045. * Post process which has the input texture to be used when performing highlight extraction
  74046. * @hidden
  74047. */
  74048. _inputPostProcess: Nullable<PostProcess>;
  74049. /**
  74050. * Gets a string identifying the name of the class
  74051. * @returns "ExtractHighlightsPostProcess" string
  74052. */
  74053. getClassName(): string;
  74054. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74055. }
  74056. }
  74057. declare module BABYLON {
  74058. /** @hidden */
  74059. export var bloomMergePixelShader: {
  74060. name: string;
  74061. shader: string;
  74062. };
  74063. }
  74064. declare module BABYLON {
  74065. /**
  74066. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74067. */
  74068. export class BloomMergePostProcess extends PostProcess {
  74069. /** Weight of the bloom to be added to the original input. */
  74070. weight: number;
  74071. /**
  74072. * Gets a string identifying the name of the class
  74073. * @returns "BloomMergePostProcess" string
  74074. */
  74075. getClassName(): string;
  74076. /**
  74077. * Creates a new instance of @see BloomMergePostProcess
  74078. * @param name The name of the effect.
  74079. * @param originalFromInput Post process which's input will be used for the merge.
  74080. * @param blurred Blurred highlights post process which's output will be used.
  74081. * @param weight Weight of the bloom to be added to the original input.
  74082. * @param options The required width/height ratio to downsize to before computing the render pass.
  74083. * @param camera The camera to apply the render pass to.
  74084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74085. * @param engine The engine which the post process will be applied. (default: current engine)
  74086. * @param reusable If the post process can be reused on the same frame. (default: false)
  74087. * @param textureType Type of textures used when performing the post process. (default: 0)
  74088. * @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)
  74089. */
  74090. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74091. /** Weight of the bloom to be added to the original input. */
  74092. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74093. }
  74094. }
  74095. declare module BABYLON {
  74096. /**
  74097. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74098. */
  74099. export class BloomEffect extends PostProcessRenderEffect {
  74100. private bloomScale;
  74101. /**
  74102. * @hidden Internal
  74103. */
  74104. _effects: Array<PostProcess>;
  74105. /**
  74106. * @hidden Internal
  74107. */
  74108. _downscale: ExtractHighlightsPostProcess;
  74109. private _blurX;
  74110. private _blurY;
  74111. private _merge;
  74112. /**
  74113. * The luminance threshold to find bright areas of the image to bloom.
  74114. */
  74115. get threshold(): number;
  74116. set threshold(value: number);
  74117. /**
  74118. * The strength of the bloom.
  74119. */
  74120. get weight(): number;
  74121. set weight(value: number);
  74122. /**
  74123. * Specifies the size of the bloom blur kernel, relative to the final output size
  74124. */
  74125. get kernel(): number;
  74126. set kernel(value: number);
  74127. /**
  74128. * Creates a new instance of @see BloomEffect
  74129. * @param scene The scene the effect belongs to.
  74130. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74131. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74132. * @param bloomWeight The the strength of bloom.
  74133. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74134. * @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)
  74135. */
  74136. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74137. /**
  74138. * Disposes each of the internal effects for a given camera.
  74139. * @param camera The camera to dispose the effect on.
  74140. */
  74141. disposeEffects(camera: Camera): void;
  74142. /**
  74143. * @hidden Internal
  74144. */
  74145. _updateEffects(): void;
  74146. /**
  74147. * Internal
  74148. * @returns if all the contained post processes are ready.
  74149. * @hidden
  74150. */
  74151. _isReady(): boolean;
  74152. }
  74153. }
  74154. declare module BABYLON {
  74155. /** @hidden */
  74156. export var chromaticAberrationPixelShader: {
  74157. name: string;
  74158. shader: string;
  74159. };
  74160. }
  74161. declare module BABYLON {
  74162. /**
  74163. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74164. */
  74165. export class ChromaticAberrationPostProcess extends PostProcess {
  74166. /**
  74167. * The amount of separation of rgb channels (default: 30)
  74168. */
  74169. aberrationAmount: number;
  74170. /**
  74171. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74172. */
  74173. radialIntensity: number;
  74174. /**
  74175. * The normalized direction in which the rgb channels should be separated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  74176. */
  74177. direction: Vector2;
  74178. /**
  74179. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corner] (default: Vector2(0.5 ,0.5))
  74180. */
  74181. centerPosition: Vector2;
  74182. /** The width of the screen to apply the effect on */
  74183. screenWidth: number;
  74184. /** The height of the screen to apply the effect on */
  74185. screenHeight: number;
  74186. /**
  74187. * Gets a string identifying the name of the class
  74188. * @returns "ChromaticAberrationPostProcess" string
  74189. */
  74190. getClassName(): string;
  74191. /**
  74192. * Creates a new instance ChromaticAberrationPostProcess
  74193. * @param name The name of the effect.
  74194. * @param screenWidth The width of the screen to apply the effect on.
  74195. * @param screenHeight The height of the screen to apply the effect on.
  74196. * @param options The required width/height ratio to downsize to before computing the render pass.
  74197. * @param camera The camera to apply the render pass to.
  74198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74199. * @param engine The engine which the post process will be applied. (default: current engine)
  74200. * @param reusable If the post process can be reused on the same frame. (default: false)
  74201. * @param textureType Type of textures used when performing the post process. (default: 0)
  74202. * @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)
  74203. */
  74204. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74205. /** @hidden */
  74206. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74207. }
  74208. }
  74209. declare module BABYLON {
  74210. /** @hidden */
  74211. export var circleOfConfusionPixelShader: {
  74212. name: string;
  74213. shader: string;
  74214. };
  74215. }
  74216. declare module BABYLON {
  74217. /**
  74218. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74219. */
  74220. export class CircleOfConfusionPostProcess extends PostProcess {
  74221. /**
  74222. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  74223. */
  74224. lensSize: number;
  74225. /**
  74226. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74227. */
  74228. fStop: number;
  74229. /**
  74230. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74231. */
  74232. focusDistance: number;
  74233. /**
  74234. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74235. */
  74236. focalLength: number;
  74237. /**
  74238. * Gets a string identifying the name of the class
  74239. * @returns "CircleOfConfusionPostProcess" string
  74240. */
  74241. getClassName(): string;
  74242. private _depthTexture;
  74243. /**
  74244. * Creates a new instance CircleOfConfusionPostProcess
  74245. * @param name The name of the effect.
  74246. * @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.
  74247. * @param options The required width/height ratio to downsize to before computing the render pass.
  74248. * @param camera The camera to apply the render pass to.
  74249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74250. * @param engine The engine which the post process will be applied. (default: current engine)
  74251. * @param reusable If the post process can be reused on the same frame. (default: false)
  74252. * @param textureType Type of textures used when performing the post process. (default: 0)
  74253. * @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)
  74254. */
  74255. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74256. /**
  74257. * 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.
  74258. */
  74259. set depthTexture(value: RenderTargetTexture);
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /** @hidden */
  74264. export var colorCorrectionPixelShader: {
  74265. name: string;
  74266. shader: string;
  74267. };
  74268. }
  74269. declare module BABYLON {
  74270. /**
  74271. *
  74272. * This post-process allows the modification of rendered colors by using
  74273. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74274. *
  74275. * The object needs to be provided an url to a texture containing the color
  74276. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74277. * Use an image editing software to tweak the LUT to match your needs.
  74278. *
  74279. * For an example of a color LUT, see here:
  74280. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74281. * For explanations on color grading, see here:
  74282. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74283. *
  74284. */
  74285. export class ColorCorrectionPostProcess extends PostProcess {
  74286. private _colorTableTexture;
  74287. /**
  74288. * Gets the color table url used to create the LUT texture
  74289. */
  74290. colorTableUrl: string;
  74291. /**
  74292. * Gets a string identifying the name of the class
  74293. * @returns "ColorCorrectionPostProcess" string
  74294. */
  74295. getClassName(): string;
  74296. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74297. /** @hidden */
  74298. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /** @hidden */
  74303. export var convolutionPixelShader: {
  74304. name: string;
  74305. shader: string;
  74306. };
  74307. }
  74308. declare module BABYLON {
  74309. /**
  74310. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74311. * input texture to perform effects such as edge detection or sharpening
  74312. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74313. */
  74314. export class ConvolutionPostProcess extends PostProcess {
  74315. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74316. kernel: number[];
  74317. /**
  74318. * Gets a string identifying the name of the class
  74319. * @returns "ConvolutionPostProcess" string
  74320. */
  74321. getClassName(): string;
  74322. /**
  74323. * Creates a new instance ConvolutionPostProcess
  74324. * @param name The name of the effect.
  74325. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74326. * @param options The required width/height ratio to downsize to before computing the render pass.
  74327. * @param camera The camera to apply the render pass to.
  74328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74329. * @param engine The engine which the post process will be applied. (default: current engine)
  74330. * @param reusable If the post process can be reused on the same frame. (default: false)
  74331. * @param textureType Type of textures used when performing the post process. (default: 0)
  74332. */
  74333. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74334. /** @hidden */
  74335. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74336. /**
  74337. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74338. */
  74339. static EdgeDetect0Kernel: number[];
  74340. /**
  74341. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74342. */
  74343. static EdgeDetect1Kernel: number[];
  74344. /**
  74345. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74346. */
  74347. static EdgeDetect2Kernel: number[];
  74348. /**
  74349. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74350. */
  74351. static SharpenKernel: number[];
  74352. /**
  74353. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74354. */
  74355. static EmbossKernel: number[];
  74356. /**
  74357. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74358. */
  74359. static GaussianKernel: number[];
  74360. }
  74361. }
  74362. declare module BABYLON {
  74363. /**
  74364. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74365. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74366. * based on samples that have a large difference in distance than the center pixel.
  74367. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74368. */
  74369. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74370. /**
  74371. * The direction the blur should be applied
  74372. */
  74373. direction: Vector2;
  74374. /**
  74375. * Gets a string identifying the name of the class
  74376. * @returns "DepthOfFieldBlurPostProcess" string
  74377. */
  74378. getClassName(): string;
  74379. /**
  74380. * Creates a new instance CircleOfConfusionPostProcess
  74381. * @param name The name of the effect.
  74382. * @param scene The scene the effect belongs to.
  74383. * @param direction The direction the blur should be applied.
  74384. * @param kernel The size of the kernel used to blur.
  74385. * @param options The required width/height ratio to downsize to before computing the render pass.
  74386. * @param camera The camera to apply the render pass to.
  74387. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74388. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74390. * @param engine The engine which the post process will be applied. (default: current engine)
  74391. * @param reusable If the post process can be reused on the same frame. (default: false)
  74392. * @param textureType Type of textures used when performing the post process. (default: 0)
  74393. * @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)
  74394. */
  74395. 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);
  74396. }
  74397. }
  74398. declare module BABYLON {
  74399. /** @hidden */
  74400. export var depthOfFieldMergePixelShader: {
  74401. name: string;
  74402. shader: string;
  74403. };
  74404. }
  74405. declare module BABYLON {
  74406. /**
  74407. * Options to be set when merging outputs from the default pipeline.
  74408. */
  74409. export class DepthOfFieldMergePostProcessOptions {
  74410. /**
  74411. * The original image to merge on top of
  74412. */
  74413. originalFromInput: PostProcess;
  74414. /**
  74415. * Parameters to perform the merge of the depth of field effect
  74416. */
  74417. depthOfField?: {
  74418. circleOfConfusion: PostProcess;
  74419. blurSteps: Array<PostProcess>;
  74420. };
  74421. /**
  74422. * Parameters to perform the merge of bloom effect
  74423. */
  74424. bloom?: {
  74425. blurred: PostProcess;
  74426. weight: number;
  74427. };
  74428. }
  74429. /**
  74430. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74431. */
  74432. export class DepthOfFieldMergePostProcess extends PostProcess {
  74433. private blurSteps;
  74434. /**
  74435. * Gets a string identifying the name of the class
  74436. * @returns "DepthOfFieldMergePostProcess" string
  74437. */
  74438. getClassName(): string;
  74439. /**
  74440. * Creates a new instance of DepthOfFieldMergePostProcess
  74441. * @param name The name of the effect.
  74442. * @param originalFromInput Post process which's input will be used for the merge.
  74443. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74444. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74445. * @param options The required width/height ratio to downsize to before computing the render pass.
  74446. * @param camera The camera to apply the render pass to.
  74447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74448. * @param engine The engine which the post process will be applied. (default: current engine)
  74449. * @param reusable If the post process can be reused on the same frame. (default: false)
  74450. * @param textureType Type of textures used when performing the post process. (default: 0)
  74451. * @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)
  74452. */
  74453. 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);
  74454. /**
  74455. * Updates the effect with the current post process compile time values and recompiles the shader.
  74456. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74457. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74458. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74459. * @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
  74460. * @param onCompiled Called when the shader has been compiled.
  74461. * @param onError Called if there is an error when compiling a shader.
  74462. */
  74463. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74464. }
  74465. }
  74466. declare module BABYLON {
  74467. /**
  74468. * Specifies the level of max blur that should be applied when using the depth of field effect
  74469. */
  74470. export enum DepthOfFieldEffectBlurLevel {
  74471. /**
  74472. * Subtle blur
  74473. */
  74474. Low = 0,
  74475. /**
  74476. * Medium blur
  74477. */
  74478. Medium = 1,
  74479. /**
  74480. * Large blur
  74481. */
  74482. High = 2
  74483. }
  74484. /**
  74485. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74486. */
  74487. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74488. private _circleOfConfusion;
  74489. /**
  74490. * @hidden Internal, blurs from high to low
  74491. */
  74492. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74493. private _depthOfFieldBlurY;
  74494. private _dofMerge;
  74495. /**
  74496. * @hidden Internal post processes in depth of field effect
  74497. */
  74498. _effects: Array<PostProcess>;
  74499. /**
  74500. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74501. */
  74502. set focalLength(value: number);
  74503. get focalLength(): number;
  74504. /**
  74505. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74506. */
  74507. set fStop(value: number);
  74508. get fStop(): number;
  74509. /**
  74510. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74511. */
  74512. set focusDistance(value: number);
  74513. get focusDistance(): number;
  74514. /**
  74515. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  74516. */
  74517. set lensSize(value: number);
  74518. get lensSize(): number;
  74519. /**
  74520. * Creates a new instance DepthOfFieldEffect
  74521. * @param scene The scene the effect belongs to.
  74522. * @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.
  74523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74524. * @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)
  74525. */
  74526. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74527. /**
  74528. * Get the current class name of the current effect
  74529. * @returns "DepthOfFieldEffect"
  74530. */
  74531. getClassName(): string;
  74532. /**
  74533. * 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.
  74534. */
  74535. set depthTexture(value: RenderTargetTexture);
  74536. /**
  74537. * Disposes each of the internal effects for a given camera.
  74538. * @param camera The camera to dispose the effect on.
  74539. */
  74540. disposeEffects(camera: Camera): void;
  74541. /**
  74542. * @hidden Internal
  74543. */
  74544. _updateEffects(): void;
  74545. /**
  74546. * Internal
  74547. * @returns if all the contained post processes are ready.
  74548. * @hidden
  74549. */
  74550. _isReady(): boolean;
  74551. }
  74552. }
  74553. declare module BABYLON {
  74554. /** @hidden */
  74555. export var displayPassPixelShader: {
  74556. name: string;
  74557. shader: string;
  74558. };
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * DisplayPassPostProcess which produces an output the same as it's input
  74563. */
  74564. export class DisplayPassPostProcess extends PostProcess {
  74565. /**
  74566. * Gets a string identifying the name of the class
  74567. * @returns "DisplayPassPostProcess" string
  74568. */
  74569. getClassName(): string;
  74570. /**
  74571. * Creates the DisplayPassPostProcess
  74572. * @param name The name of the effect.
  74573. * @param options The required width/height ratio to downsize to before computing the render pass.
  74574. * @param camera The camera to apply the render pass to.
  74575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74576. * @param engine The engine which the post process will be applied. (default: current engine)
  74577. * @param reusable If the post process can be reused on the same frame. (default: false)
  74578. */
  74579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74580. /** @hidden */
  74581. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74582. }
  74583. }
  74584. declare module BABYLON {
  74585. /** @hidden */
  74586. export var filterPixelShader: {
  74587. name: string;
  74588. shader: string;
  74589. };
  74590. }
  74591. declare module BABYLON {
  74592. /**
  74593. * Applies a kernel filter to the image
  74594. */
  74595. export class FilterPostProcess extends PostProcess {
  74596. /** The matrix to be applied to the image */
  74597. kernelMatrix: Matrix;
  74598. /**
  74599. * Gets a string identifying the name of the class
  74600. * @returns "FilterPostProcess" string
  74601. */
  74602. getClassName(): string;
  74603. /**
  74604. *
  74605. * @param name The name of the effect.
  74606. * @param kernelMatrix The matrix to be applied to the image
  74607. * @param options The required width/height ratio to downsize to before computing the render pass.
  74608. * @param camera The camera to apply the render pass to.
  74609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74610. * @param engine The engine which the post process will be applied. (default: current engine)
  74611. * @param reusable If the post process can be reused on the same frame. (default: false)
  74612. */
  74613. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74614. /** @hidden */
  74615. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74616. }
  74617. }
  74618. declare module BABYLON {
  74619. /** @hidden */
  74620. export var fxaaPixelShader: {
  74621. name: string;
  74622. shader: string;
  74623. };
  74624. }
  74625. declare module BABYLON {
  74626. /** @hidden */
  74627. export var fxaaVertexShader: {
  74628. name: string;
  74629. shader: string;
  74630. };
  74631. }
  74632. declare module BABYLON {
  74633. /**
  74634. * Fxaa post process
  74635. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74636. */
  74637. export class FxaaPostProcess extends PostProcess {
  74638. /**
  74639. * Gets a string identifying the name of the class
  74640. * @returns "FxaaPostProcess" string
  74641. */
  74642. getClassName(): string;
  74643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74644. private _getDefines;
  74645. /** @hidden */
  74646. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74647. }
  74648. }
  74649. declare module BABYLON {
  74650. /** @hidden */
  74651. export var grainPixelShader: {
  74652. name: string;
  74653. shader: string;
  74654. };
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * The GrainPostProcess adds noise to the image at mid luminance levels
  74659. */
  74660. export class GrainPostProcess extends PostProcess {
  74661. /**
  74662. * The intensity of the grain added (default: 30)
  74663. */
  74664. intensity: number;
  74665. /**
  74666. * If the grain should be randomized on every frame
  74667. */
  74668. animated: boolean;
  74669. /**
  74670. * Gets a string identifying the name of the class
  74671. * @returns "GrainPostProcess" string
  74672. */
  74673. getClassName(): string;
  74674. /**
  74675. * Creates a new instance of @see GrainPostProcess
  74676. * @param name The name of the effect.
  74677. * @param options The required width/height ratio to downsize to before computing the render pass.
  74678. * @param camera The camera to apply the render pass to.
  74679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74680. * @param engine The engine which the post process will be applied. (default: current engine)
  74681. * @param reusable If the post process can be reused on the same frame. (default: false)
  74682. * @param textureType Type of textures used when performing the post process. (default: 0)
  74683. * @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)
  74684. */
  74685. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74686. /** @hidden */
  74687. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /** @hidden */
  74692. export var highlightsPixelShader: {
  74693. name: string;
  74694. shader: string;
  74695. };
  74696. }
  74697. declare module BABYLON {
  74698. /**
  74699. * Extracts highlights from the image
  74700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74701. */
  74702. export class HighlightsPostProcess extends PostProcess {
  74703. /**
  74704. * Gets a string identifying the name of the class
  74705. * @returns "HighlightsPostProcess" string
  74706. */
  74707. getClassName(): string;
  74708. /**
  74709. * Extracts highlights from the image
  74710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74711. * @param name The name of the effect.
  74712. * @param options The required width/height ratio to downsize to before computing the render pass.
  74713. * @param camera The camera to apply the render pass to.
  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. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74718. */
  74719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74720. }
  74721. }
  74722. declare module BABYLON {
  74723. /**
  74724. * Contains all parameters needed for the prepass to perform
  74725. * motion blur
  74726. */
  74727. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74728. /**
  74729. * Is motion blur enabled
  74730. */
  74731. enabled: boolean;
  74732. /**
  74733. * Name of the configuration
  74734. */
  74735. name: string;
  74736. /**
  74737. * Textures that should be present in the MRT for this effect to work
  74738. */
  74739. readonly texturesRequired: number[];
  74740. }
  74741. }
  74742. declare module BABYLON {
  74743. interface Scene {
  74744. /** @hidden (Backing field) */
  74745. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74746. /**
  74747. * Gets or Sets the current geometry buffer associated to the scene.
  74748. */
  74749. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74750. /**
  74751. * Enables a GeometryBufferRender and associates it with the scene
  74752. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74753. * @returns the GeometryBufferRenderer
  74754. */
  74755. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74756. /**
  74757. * Disables the GeometryBufferRender associated with the scene
  74758. */
  74759. disableGeometryBufferRenderer(): void;
  74760. }
  74761. /**
  74762. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74763. * in several rendering techniques.
  74764. */
  74765. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74766. /**
  74767. * The component name helpful to identify the component in the list of scene components.
  74768. */
  74769. readonly name: string;
  74770. /**
  74771. * The scene the component belongs to.
  74772. */
  74773. scene: Scene;
  74774. /**
  74775. * Creates a new instance of the component for the given scene
  74776. * @param scene Defines the scene to register the component in
  74777. */
  74778. constructor(scene: Scene);
  74779. /**
  74780. * Registers the component in a given scene
  74781. */
  74782. register(): void;
  74783. /**
  74784. * Rebuilds the elements related to this component in case of
  74785. * context lost for instance.
  74786. */
  74787. rebuild(): void;
  74788. /**
  74789. * Disposes the component and the associated resources
  74790. */
  74791. dispose(): void;
  74792. private _gatherRenderTargets;
  74793. }
  74794. }
  74795. declare module BABYLON {
  74796. /** @hidden */
  74797. export var motionBlurPixelShader: {
  74798. name: string;
  74799. shader: string;
  74800. };
  74801. }
  74802. declare module BABYLON {
  74803. /**
  74804. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74805. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74806. * As an example, all you have to do is to create the post-process:
  74807. * var mb = new BABYLON.MotionBlurPostProcess(
  74808. * 'mb', // The name of the effect.
  74809. * scene, // The scene containing the objects to blur according to their velocity.
  74810. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74811. * camera // The camera to apply the render pass to.
  74812. * );
  74813. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74814. */
  74815. export class MotionBlurPostProcess extends PostProcess {
  74816. /**
  74817. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74818. */
  74819. motionStrength: number;
  74820. /**
  74821. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74822. */
  74823. get motionBlurSamples(): number;
  74824. /**
  74825. * Sets the number of iterations to be used for motion blur quality
  74826. */
  74827. set motionBlurSamples(samples: number);
  74828. private _motionBlurSamples;
  74829. /**
  74830. * Gets whether or not the motion blur post-process is in object based mode.
  74831. */
  74832. get isObjectBased(): boolean;
  74833. /**
  74834. * Sets whether or not the motion blur post-process is in object based mode.
  74835. */
  74836. set isObjectBased(value: boolean);
  74837. private _isObjectBased;
  74838. private _forceGeometryBuffer;
  74839. private _geometryBufferRenderer;
  74840. private _prePassRenderer;
  74841. private _invViewProjection;
  74842. private _previousViewProjection;
  74843. /**
  74844. * Gets a string identifying the name of the class
  74845. * @returns "MotionBlurPostProcess" string
  74846. */
  74847. getClassName(): string;
  74848. /**
  74849. * Creates a new instance MotionBlurPostProcess
  74850. * @param name The name of the effect.
  74851. * @param scene The scene containing the objects to blur according to their velocity.
  74852. * @param options The required width/height ratio to downsize to before computing the render pass.
  74853. * @param camera The camera to apply the render pass to.
  74854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74855. * @param engine The engine which the post process will be applied. (default: current engine)
  74856. * @param reusable If the post process can be reused on the same frame. (default: false)
  74857. * @param textureType Type of textures used when performing the post process. (default: 0)
  74858. * @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)
  74859. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74860. */
  74861. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74862. /**
  74863. * Excludes the given skinned mesh from computing bones velocities.
  74864. * 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.
  74865. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74866. */
  74867. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74868. /**
  74869. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74870. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74871. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74872. */
  74873. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74874. /**
  74875. * Disposes the post process.
  74876. * @param camera The camera to dispose the post process on.
  74877. */
  74878. dispose(camera?: Camera): void;
  74879. /**
  74880. * Called on the mode changed (object based or screen based).
  74881. */
  74882. private _applyMode;
  74883. /**
  74884. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74885. */
  74886. private _onApplyObjectBased;
  74887. /**
  74888. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74889. */
  74890. private _onApplyScreenBased;
  74891. /**
  74892. * Called on the effect must be updated (changed mode, samples count, etc.).
  74893. */
  74894. private _updateEffect;
  74895. /** @hidden */
  74896. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74897. }
  74898. }
  74899. declare module BABYLON {
  74900. /** @hidden */
  74901. export var refractionPixelShader: {
  74902. name: string;
  74903. shader: string;
  74904. };
  74905. }
  74906. declare module BABYLON {
  74907. /**
  74908. * Post process which applies a refraction texture
  74909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74910. */
  74911. export class RefractionPostProcess extends PostProcess {
  74912. private _refTexture;
  74913. private _ownRefractionTexture;
  74914. /** the base color of the refraction (used to taint the rendering) */
  74915. color: Color3;
  74916. /** simulated refraction depth */
  74917. depth: number;
  74918. /** the coefficient of the base color (0 to remove base color tainting) */
  74919. colorLevel: number;
  74920. /** Gets the url used to load the refraction texture */
  74921. refractionTextureUrl: string;
  74922. /**
  74923. * Gets or sets the refraction texture
  74924. * Please note that you are responsible for disposing the texture if you set it manually
  74925. */
  74926. get refractionTexture(): Texture;
  74927. set refractionTexture(value: Texture);
  74928. /**
  74929. * Gets a string identifying the name of the class
  74930. * @returns "RefractionPostProcess" string
  74931. */
  74932. getClassName(): string;
  74933. /**
  74934. * Initializes the RefractionPostProcess
  74935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74936. * @param name The name of the effect.
  74937. * @param refractionTextureUrl Url of the refraction texture to use
  74938. * @param color the base color of the refraction (used to taint the rendering)
  74939. * @param depth simulated refraction depth
  74940. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74941. * @param camera The camera to apply the render pass to.
  74942. * @param options The required width/height ratio to downsize to before computing the render pass.
  74943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74944. * @param engine The engine which the post process will be applied. (default: current engine)
  74945. * @param reusable If the post process can be reused on the same frame. (default: false)
  74946. */
  74947. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74948. /**
  74949. * Disposes of the post process
  74950. * @param camera Camera to dispose post process on
  74951. */
  74952. dispose(camera: Camera): void;
  74953. /** @hidden */
  74954. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74955. }
  74956. }
  74957. declare module BABYLON {
  74958. /** @hidden */
  74959. export var sharpenPixelShader: {
  74960. name: string;
  74961. shader: string;
  74962. };
  74963. }
  74964. declare module BABYLON {
  74965. /**
  74966. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74968. */
  74969. export class SharpenPostProcess extends PostProcess {
  74970. /**
  74971. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74972. */
  74973. colorAmount: number;
  74974. /**
  74975. * How much sharpness should be applied (default: 0.3)
  74976. */
  74977. edgeAmount: number;
  74978. /**
  74979. * Gets a string identifying the name of the class
  74980. * @returns "SharpenPostProcess" string
  74981. */
  74982. getClassName(): string;
  74983. /**
  74984. * Creates a new instance ConvolutionPostProcess
  74985. * @param name The name of the effect.
  74986. * @param options The required width/height ratio to downsize to before computing the render pass.
  74987. * @param camera The camera to apply the render pass to.
  74988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74989. * @param engine The engine which the post process will be applied. (default: current engine)
  74990. * @param reusable If the post process can be reused on the same frame. (default: false)
  74991. * @param textureType Type of textures used when performing the post process. (default: 0)
  74992. * @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)
  74993. */
  74994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74995. /** @hidden */
  74996. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74997. }
  74998. }
  74999. declare module BABYLON {
  75000. /**
  75001. * PostProcessRenderPipeline
  75002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75003. */
  75004. export class PostProcessRenderPipeline {
  75005. private engine;
  75006. private _renderEffects;
  75007. private _renderEffectsForIsolatedPass;
  75008. /**
  75009. * List of inspectable custom properties (used by the Inspector)
  75010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75011. */
  75012. inspectableCustomProperties: IInspectable[];
  75013. /**
  75014. * @hidden
  75015. */
  75016. protected _cameras: Camera[];
  75017. /** @hidden */
  75018. _name: string;
  75019. /**
  75020. * Gets pipeline name
  75021. */
  75022. get name(): string;
  75023. /** Gets the list of attached cameras */
  75024. get cameras(): Camera[];
  75025. /**
  75026. * Initializes a PostProcessRenderPipeline
  75027. * @param engine engine to add the pipeline to
  75028. * @param name name of the pipeline
  75029. */
  75030. constructor(engine: Engine, name: string);
  75031. /**
  75032. * Gets the class name
  75033. * @returns "PostProcessRenderPipeline"
  75034. */
  75035. getClassName(): string;
  75036. /**
  75037. * If all the render effects in the pipeline are supported
  75038. */
  75039. get isSupported(): boolean;
  75040. /**
  75041. * Adds an effect to the pipeline
  75042. * @param renderEffect the effect to add
  75043. */
  75044. addEffect(renderEffect: PostProcessRenderEffect): void;
  75045. /** @hidden */
  75046. _rebuild(): void;
  75047. /** @hidden */
  75048. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75049. /** @hidden */
  75050. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75051. /** @hidden */
  75052. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75053. /** @hidden */
  75054. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75055. /** @hidden */
  75056. _attachCameras(cameras: Camera, unique: boolean): void;
  75057. /** @hidden */
  75058. _attachCameras(cameras: Camera[], unique: boolean): void;
  75059. /** @hidden */
  75060. _detachCameras(cameras: Camera): void;
  75061. /** @hidden */
  75062. _detachCameras(cameras: Nullable<Camera[]>): void;
  75063. /** @hidden */
  75064. _update(): void;
  75065. /** @hidden */
  75066. _reset(): void;
  75067. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75068. /**
  75069. * Sets the required values to the prepass renderer.
  75070. * @param prePassRenderer defines the prepass renderer to setup.
  75071. * @returns true if the pre pass is needed.
  75072. */
  75073. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75074. /**
  75075. * Disposes of the pipeline
  75076. */
  75077. dispose(): void;
  75078. }
  75079. }
  75080. declare module BABYLON {
  75081. /**
  75082. * PostProcessRenderPipelineManager class
  75083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75084. */
  75085. export class PostProcessRenderPipelineManager {
  75086. private _renderPipelines;
  75087. /**
  75088. * Initializes a PostProcessRenderPipelineManager
  75089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75090. */
  75091. constructor();
  75092. /**
  75093. * Gets the list of supported render pipelines
  75094. */
  75095. get supportedPipelines(): PostProcessRenderPipeline[];
  75096. /**
  75097. * Adds a pipeline to the manager
  75098. * @param renderPipeline The pipeline to add
  75099. */
  75100. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75101. /**
  75102. * Attaches a camera to the pipeline
  75103. * @param renderPipelineName The name of the pipeline to attach to
  75104. * @param cameras the camera to attach
  75105. * @param unique if the camera can be attached multiple times to the pipeline
  75106. */
  75107. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75108. /**
  75109. * Detaches a camera from the pipeline
  75110. * @param renderPipelineName The name of the pipeline to detach from
  75111. * @param cameras the camera to detach
  75112. */
  75113. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75114. /**
  75115. * Enables an effect by name on a pipeline
  75116. * @param renderPipelineName the name of the pipeline to enable the effect in
  75117. * @param renderEffectName the name of the effect to enable
  75118. * @param cameras the cameras that the effect should be enabled on
  75119. */
  75120. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75121. /**
  75122. * Disables an effect by name on a pipeline
  75123. * @param renderPipelineName the name of the pipeline to disable the effect in
  75124. * @param renderEffectName the name of the effect to disable
  75125. * @param cameras the cameras that the effect should be disabled on
  75126. */
  75127. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75128. /**
  75129. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75130. */
  75131. update(): void;
  75132. /** @hidden */
  75133. _rebuild(): void;
  75134. /**
  75135. * Disposes of the manager and pipelines
  75136. */
  75137. dispose(): void;
  75138. }
  75139. }
  75140. declare module BABYLON {
  75141. interface Scene {
  75142. /** @hidden (Backing field) */
  75143. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75144. /**
  75145. * Gets the postprocess render pipeline manager
  75146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75147. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75148. */
  75149. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75150. }
  75151. /**
  75152. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75153. */
  75154. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75155. /**
  75156. * The component name helpful to identify the component in the list of scene components.
  75157. */
  75158. readonly name: string;
  75159. /**
  75160. * The scene the component belongs to.
  75161. */
  75162. scene: Scene;
  75163. /**
  75164. * Creates a new instance of the component for the given scene
  75165. * @param scene Defines the scene to register the component in
  75166. */
  75167. constructor(scene: Scene);
  75168. /**
  75169. * Registers the component in a given scene
  75170. */
  75171. register(): void;
  75172. /**
  75173. * Rebuilds the elements related to this component in case of
  75174. * context lost for instance.
  75175. */
  75176. rebuild(): void;
  75177. /**
  75178. * Disposes the component and the associated resources
  75179. */
  75180. dispose(): void;
  75181. private _gatherRenderTargets;
  75182. }
  75183. }
  75184. declare module BABYLON {
  75185. /**
  75186. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75187. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75188. */
  75189. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75190. private _scene;
  75191. private _camerasToBeAttached;
  75192. /**
  75193. * ID of the sharpen post process,
  75194. */
  75195. private readonly SharpenPostProcessId;
  75196. /**
  75197. * @ignore
  75198. * ID of the image processing post process;
  75199. */
  75200. readonly ImageProcessingPostProcessId: string;
  75201. /**
  75202. * @ignore
  75203. * ID of the Fast Approximate Anti-Aliasing post process;
  75204. */
  75205. readonly FxaaPostProcessId: string;
  75206. /**
  75207. * ID of the chromatic aberration post process,
  75208. */
  75209. private readonly ChromaticAberrationPostProcessId;
  75210. /**
  75211. * ID of the grain post process
  75212. */
  75213. private readonly GrainPostProcessId;
  75214. /**
  75215. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75216. */
  75217. sharpen: SharpenPostProcess;
  75218. private _sharpenEffect;
  75219. private bloom;
  75220. /**
  75221. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75222. */
  75223. depthOfField: DepthOfFieldEffect;
  75224. /**
  75225. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75226. */
  75227. fxaa: FxaaPostProcess;
  75228. /**
  75229. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75230. */
  75231. imageProcessing: ImageProcessingPostProcess;
  75232. /**
  75233. * Chromatic aberration post process which will shift rgb colors in the image
  75234. */
  75235. chromaticAberration: ChromaticAberrationPostProcess;
  75236. private _chromaticAberrationEffect;
  75237. /**
  75238. * Grain post process which add noise to the image
  75239. */
  75240. grain: GrainPostProcess;
  75241. private _grainEffect;
  75242. /**
  75243. * Glow post process which adds a glow to emissive areas of the image
  75244. */
  75245. private _glowLayer;
  75246. /**
  75247. * Animations which can be used to tweak settings over a period of time
  75248. */
  75249. animations: Animation[];
  75250. private _imageProcessingConfigurationObserver;
  75251. private _sharpenEnabled;
  75252. private _bloomEnabled;
  75253. private _depthOfFieldEnabled;
  75254. private _depthOfFieldBlurLevel;
  75255. private _fxaaEnabled;
  75256. private _imageProcessingEnabled;
  75257. private _defaultPipelineTextureType;
  75258. private _bloomScale;
  75259. private _chromaticAberrationEnabled;
  75260. private _grainEnabled;
  75261. private _buildAllowed;
  75262. /**
  75263. * This is triggered each time the pipeline has been built.
  75264. */
  75265. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75266. /**
  75267. * Gets active scene
  75268. */
  75269. get scene(): Scene;
  75270. /**
  75271. * Enable or disable the sharpen process from the pipeline
  75272. */
  75273. set sharpenEnabled(enabled: boolean);
  75274. get sharpenEnabled(): boolean;
  75275. private _resizeObserver;
  75276. private _hardwareScaleLevel;
  75277. private _bloomKernel;
  75278. /**
  75279. * Specifies the size of the bloom blur kernel, relative to the final output size
  75280. */
  75281. get bloomKernel(): number;
  75282. set bloomKernel(value: number);
  75283. /**
  75284. * Specifies the weight of the bloom in the final rendering
  75285. */
  75286. private _bloomWeight;
  75287. /**
  75288. * Specifies the luma threshold for the area that will be blurred by the bloom
  75289. */
  75290. private _bloomThreshold;
  75291. private _hdr;
  75292. /**
  75293. * The strength of the bloom.
  75294. */
  75295. set bloomWeight(value: number);
  75296. get bloomWeight(): number;
  75297. /**
  75298. * The strength of the bloom.
  75299. */
  75300. set bloomThreshold(value: number);
  75301. get bloomThreshold(): number;
  75302. /**
  75303. * The scale of the bloom, lower value will provide better performance.
  75304. */
  75305. set bloomScale(value: number);
  75306. get bloomScale(): number;
  75307. /**
  75308. * Enable or disable the bloom from the pipeline
  75309. */
  75310. set bloomEnabled(enabled: boolean);
  75311. get bloomEnabled(): boolean;
  75312. private _rebuildBloom;
  75313. /**
  75314. * If the depth of field is enabled.
  75315. */
  75316. get depthOfFieldEnabled(): boolean;
  75317. set depthOfFieldEnabled(enabled: boolean);
  75318. /**
  75319. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75320. */
  75321. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75322. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75323. /**
  75324. * If the anti aliasing is enabled.
  75325. */
  75326. set fxaaEnabled(enabled: boolean);
  75327. get fxaaEnabled(): boolean;
  75328. private _samples;
  75329. /**
  75330. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75331. */
  75332. set samples(sampleCount: number);
  75333. get samples(): number;
  75334. /**
  75335. * If image processing is enabled.
  75336. */
  75337. set imageProcessingEnabled(enabled: boolean);
  75338. get imageProcessingEnabled(): boolean;
  75339. /**
  75340. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75341. */
  75342. set glowLayerEnabled(enabled: boolean);
  75343. get glowLayerEnabled(): boolean;
  75344. /**
  75345. * Gets the glow layer (or null if not defined)
  75346. */
  75347. get glowLayer(): Nullable<GlowLayer>;
  75348. /**
  75349. * Enable or disable the chromaticAberration process from the pipeline
  75350. */
  75351. set chromaticAberrationEnabled(enabled: boolean);
  75352. get chromaticAberrationEnabled(): boolean;
  75353. /**
  75354. * Enable or disable the grain process from the pipeline
  75355. */
  75356. set grainEnabled(enabled: boolean);
  75357. get grainEnabled(): boolean;
  75358. /**
  75359. * @constructor
  75360. * @param name - The rendering pipeline name (default: "")
  75361. * @param hdr - If high dynamic range textures should be used (default: true)
  75362. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75363. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75364. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75365. */
  75366. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75367. /**
  75368. * Get the class name
  75369. * @returns "DefaultRenderingPipeline"
  75370. */
  75371. getClassName(): string;
  75372. /**
  75373. * Force the compilation of the entire pipeline.
  75374. */
  75375. prepare(): void;
  75376. private _hasCleared;
  75377. private _prevPostProcess;
  75378. private _prevPrevPostProcess;
  75379. private _setAutoClearAndTextureSharing;
  75380. private _depthOfFieldSceneObserver;
  75381. private _buildPipeline;
  75382. private _disposePostProcesses;
  75383. /**
  75384. * Adds a camera to the pipeline
  75385. * @param camera the camera to be added
  75386. */
  75387. addCamera(camera: Camera): void;
  75388. /**
  75389. * Removes a camera from the pipeline
  75390. * @param camera the camera to remove
  75391. */
  75392. removeCamera(camera: Camera): void;
  75393. /**
  75394. * Dispose of the pipeline and stop all post processes
  75395. */
  75396. dispose(): void;
  75397. /**
  75398. * Serialize the rendering pipeline (Used when exporting)
  75399. * @returns the serialized object
  75400. */
  75401. serialize(): any;
  75402. /**
  75403. * Parse the serialized pipeline
  75404. * @param source Source pipeline.
  75405. * @param scene The scene to load the pipeline to.
  75406. * @param rootUrl The URL of the serialized pipeline.
  75407. * @returns An instantiated pipeline from the serialized object.
  75408. */
  75409. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75410. }
  75411. }
  75412. declare module BABYLON {
  75413. /** @hidden */
  75414. export var lensHighlightsPixelShader: {
  75415. name: string;
  75416. shader: string;
  75417. };
  75418. }
  75419. declare module BABYLON {
  75420. /** @hidden */
  75421. export var depthOfFieldPixelShader: {
  75422. name: string;
  75423. shader: string;
  75424. };
  75425. }
  75426. declare module BABYLON {
  75427. /**
  75428. * BABYLON.JS Chromatic Aberration GLSL Shader
  75429. * Author: Olivier Guyot
  75430. * Separates very slightly R, G and B colors on the edges of the screen
  75431. * Inspired by Francois Tarlier & Martins Upitis
  75432. */
  75433. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75434. /**
  75435. * @ignore
  75436. * The chromatic aberration PostProcess id in the pipeline
  75437. */
  75438. LensChromaticAberrationEffect: string;
  75439. /**
  75440. * @ignore
  75441. * The highlights enhancing PostProcess id in the pipeline
  75442. */
  75443. HighlightsEnhancingEffect: string;
  75444. /**
  75445. * @ignore
  75446. * The depth-of-field PostProcess id in the pipeline
  75447. */
  75448. LensDepthOfFieldEffect: string;
  75449. private _scene;
  75450. private _depthTexture;
  75451. private _grainTexture;
  75452. private _chromaticAberrationPostProcess;
  75453. private _highlightsPostProcess;
  75454. private _depthOfFieldPostProcess;
  75455. private _edgeBlur;
  75456. private _grainAmount;
  75457. private _chromaticAberration;
  75458. private _distortion;
  75459. private _highlightsGain;
  75460. private _highlightsThreshold;
  75461. private _dofDistance;
  75462. private _dofAperture;
  75463. private _dofDarken;
  75464. private _dofPentagon;
  75465. private _blurNoise;
  75466. /**
  75467. * @constructor
  75468. *
  75469. * Effect parameters are as follow:
  75470. * {
  75471. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75472. * edge_blur: number; // from 0 to x (1 for realism)
  75473. * distortion: number; // from 0 to x (1 for realism)
  75474. * grain_amount: number; // from 0 to 1
  75475. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75476. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75477. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75478. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75479. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75480. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75481. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75482. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75483. * }
  75484. * Note: if an effect parameter is unset, effect is disabled
  75485. *
  75486. * @param name The rendering pipeline name
  75487. * @param parameters - An object containing all parameters (see above)
  75488. * @param scene The scene linked to this pipeline
  75489. * @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)
  75490. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75491. */
  75492. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75493. /**
  75494. * Get the class name
  75495. * @returns "LensRenderingPipeline"
  75496. */
  75497. getClassName(): string;
  75498. /**
  75499. * Gets associated scene
  75500. */
  75501. get scene(): Scene;
  75502. /**
  75503. * Gets or sets the edge blur
  75504. */
  75505. get edgeBlur(): number;
  75506. set edgeBlur(value: number);
  75507. /**
  75508. * Gets or sets the grain amount
  75509. */
  75510. get grainAmount(): number;
  75511. set grainAmount(value: number);
  75512. /**
  75513. * Gets or sets the chromatic aberration amount
  75514. */
  75515. get chromaticAberration(): number;
  75516. set chromaticAberration(value: number);
  75517. /**
  75518. * Gets or sets the depth of field aperture
  75519. */
  75520. get dofAperture(): number;
  75521. set dofAperture(value: number);
  75522. /**
  75523. * Gets or sets the edge distortion
  75524. */
  75525. get edgeDistortion(): number;
  75526. set edgeDistortion(value: number);
  75527. /**
  75528. * Gets or sets the depth of field distortion
  75529. */
  75530. get dofDistortion(): number;
  75531. set dofDistortion(value: number);
  75532. /**
  75533. * Gets or sets the darken out of focus amount
  75534. */
  75535. get darkenOutOfFocus(): number;
  75536. set darkenOutOfFocus(value: number);
  75537. /**
  75538. * Gets or sets a boolean indicating if blur noise is enabled
  75539. */
  75540. get blurNoise(): boolean;
  75541. set blurNoise(value: boolean);
  75542. /**
  75543. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75544. */
  75545. get pentagonBokeh(): boolean;
  75546. set pentagonBokeh(value: boolean);
  75547. /**
  75548. * Gets or sets the highlight grain amount
  75549. */
  75550. get highlightsGain(): number;
  75551. set highlightsGain(value: number);
  75552. /**
  75553. * Gets or sets the highlight threshold
  75554. */
  75555. get highlightsThreshold(): number;
  75556. set highlightsThreshold(value: number);
  75557. /**
  75558. * Sets the amount of blur at the edges
  75559. * @param amount blur amount
  75560. */
  75561. setEdgeBlur(amount: number): void;
  75562. /**
  75563. * Sets edge blur to 0
  75564. */
  75565. disableEdgeBlur(): void;
  75566. /**
  75567. * Sets the amount of grain
  75568. * @param amount Amount of grain
  75569. */
  75570. setGrainAmount(amount: number): void;
  75571. /**
  75572. * Set grain amount to 0
  75573. */
  75574. disableGrain(): void;
  75575. /**
  75576. * Sets the chromatic aberration amount
  75577. * @param amount amount of chromatic aberration
  75578. */
  75579. setChromaticAberration(amount: number): void;
  75580. /**
  75581. * Sets chromatic aberration amount to 0
  75582. */
  75583. disableChromaticAberration(): void;
  75584. /**
  75585. * Sets the EdgeDistortion amount
  75586. * @param amount amount of EdgeDistortion
  75587. */
  75588. setEdgeDistortion(amount: number): void;
  75589. /**
  75590. * Sets edge distortion to 0
  75591. */
  75592. disableEdgeDistortion(): void;
  75593. /**
  75594. * Sets the FocusDistance amount
  75595. * @param amount amount of FocusDistance
  75596. */
  75597. setFocusDistance(amount: number): void;
  75598. /**
  75599. * Disables depth of field
  75600. */
  75601. disableDepthOfField(): void;
  75602. /**
  75603. * Sets the Aperture amount
  75604. * @param amount amount of Aperture
  75605. */
  75606. setAperture(amount: number): void;
  75607. /**
  75608. * Sets the DarkenOutOfFocus amount
  75609. * @param amount amount of DarkenOutOfFocus
  75610. */
  75611. setDarkenOutOfFocus(amount: number): void;
  75612. private _pentagonBokehIsEnabled;
  75613. /**
  75614. * Creates a pentagon bokeh effect
  75615. */
  75616. enablePentagonBokeh(): void;
  75617. /**
  75618. * Disables the pentagon bokeh effect
  75619. */
  75620. disablePentagonBokeh(): void;
  75621. /**
  75622. * Enables noise blur
  75623. */
  75624. enableNoiseBlur(): void;
  75625. /**
  75626. * Disables noise blur
  75627. */
  75628. disableNoiseBlur(): void;
  75629. /**
  75630. * Sets the HighlightsGain amount
  75631. * @param amount amount of HighlightsGain
  75632. */
  75633. setHighlightsGain(amount: number): void;
  75634. /**
  75635. * Sets the HighlightsThreshold amount
  75636. * @param amount amount of HighlightsThreshold
  75637. */
  75638. setHighlightsThreshold(amount: number): void;
  75639. /**
  75640. * Disables highlights
  75641. */
  75642. disableHighlights(): void;
  75643. /**
  75644. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75645. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75646. */
  75647. dispose(disableDepthRender?: boolean): void;
  75648. private _createChromaticAberrationPostProcess;
  75649. private _createHighlightsPostProcess;
  75650. private _createDepthOfFieldPostProcess;
  75651. private _createGrainTexture;
  75652. }
  75653. }
  75654. declare module BABYLON {
  75655. /**
  75656. * Contains all parameters needed for the prepass to perform
  75657. * screen space subsurface scattering
  75658. */
  75659. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75660. /**
  75661. * Is subsurface enabled
  75662. */
  75663. enabled: boolean;
  75664. /**
  75665. * Name of the configuration
  75666. */
  75667. name: string;
  75668. /**
  75669. * Textures that should be present in the MRT for this effect to work
  75670. */
  75671. readonly texturesRequired: number[];
  75672. }
  75673. }
  75674. declare module BABYLON {
  75675. /** @hidden */
  75676. export var ssao2PixelShader: {
  75677. name: string;
  75678. shader: string;
  75679. };
  75680. }
  75681. declare module BABYLON {
  75682. /** @hidden */
  75683. export var ssaoCombinePixelShader: {
  75684. name: string;
  75685. shader: string;
  75686. };
  75687. }
  75688. declare module BABYLON {
  75689. /**
  75690. * Render pipeline to produce ssao effect
  75691. */
  75692. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75693. /**
  75694. * @ignore
  75695. * The PassPostProcess id in the pipeline that contains the original scene color
  75696. */
  75697. SSAOOriginalSceneColorEffect: string;
  75698. /**
  75699. * @ignore
  75700. * The SSAO PostProcess id in the pipeline
  75701. */
  75702. SSAORenderEffect: string;
  75703. /**
  75704. * @ignore
  75705. * The horizontal blur PostProcess id in the pipeline
  75706. */
  75707. SSAOBlurHRenderEffect: string;
  75708. /**
  75709. * @ignore
  75710. * The vertical blur PostProcess id in the pipeline
  75711. */
  75712. SSAOBlurVRenderEffect: string;
  75713. /**
  75714. * @ignore
  75715. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75716. */
  75717. SSAOCombineRenderEffect: string;
  75718. /**
  75719. * The output strength of the SSAO post-process. Default value is 1.0.
  75720. */
  75721. totalStrength: number;
  75722. /**
  75723. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75724. */
  75725. maxZ: number;
  75726. /**
  75727. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75728. */
  75729. minZAspect: number;
  75730. private _samples;
  75731. /**
  75732. * Number of samples used for the SSAO calculations. Default value is 8
  75733. */
  75734. set samples(n: number);
  75735. get samples(): number;
  75736. private _textureSamples;
  75737. /**
  75738. * Number of samples to use for antialiasing
  75739. */
  75740. set textureSamples(n: number);
  75741. get textureSamples(): number;
  75742. /**
  75743. * Force rendering the geometry through geometry buffer
  75744. */
  75745. private _forceGeometryBuffer;
  75746. /**
  75747. * Ratio object used for SSAO ratio and blur ratio
  75748. */
  75749. private _ratio;
  75750. /**
  75751. * Dynamically generated sphere sampler.
  75752. */
  75753. private _sampleSphere;
  75754. /**
  75755. * Blur filter offsets
  75756. */
  75757. private _samplerOffsets;
  75758. private _expensiveBlur;
  75759. /**
  75760. * If bilateral blur should be used
  75761. */
  75762. set expensiveBlur(b: boolean);
  75763. get expensiveBlur(): boolean;
  75764. /**
  75765. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75766. */
  75767. radius: number;
  75768. /**
  75769. * The base color of the SSAO post-process
  75770. * The final result is "base + ssao" between [0, 1]
  75771. */
  75772. base: number;
  75773. /**
  75774. * Support test.
  75775. */
  75776. static get IsSupported(): boolean;
  75777. private _scene;
  75778. private _randomTexture;
  75779. private _originalColorPostProcess;
  75780. private _ssaoPostProcess;
  75781. private _blurHPostProcess;
  75782. private _blurVPostProcess;
  75783. private _ssaoCombinePostProcess;
  75784. private _prePassRenderer;
  75785. /**
  75786. * Gets active scene
  75787. */
  75788. get scene(): Scene;
  75789. /**
  75790. * @constructor
  75791. * @param name The rendering pipeline name
  75792. * @param scene The scene linked to this pipeline
  75793. * @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 }
  75794. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75795. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75796. */
  75797. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75798. /**
  75799. * Get the class name
  75800. * @returns "SSAO2RenderingPipeline"
  75801. */
  75802. getClassName(): string;
  75803. /**
  75804. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75805. */
  75806. dispose(disableGeometryBufferRenderer?: boolean): void;
  75807. private _createBlurPostProcess;
  75808. /** @hidden */
  75809. _rebuild(): void;
  75810. private _bits;
  75811. private _radicalInverse_VdC;
  75812. private _hammersley;
  75813. private _hemisphereSample_uniform;
  75814. private _generateHemisphere;
  75815. private _getDefinesForSSAO;
  75816. private static readonly ORTHO_DEPTH_PROJECTION;
  75817. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75818. private _createSSAOPostProcess;
  75819. private _createSSAOCombinePostProcess;
  75820. private _createRandomTexture;
  75821. /**
  75822. * Serialize the rendering pipeline (Used when exporting)
  75823. * @returns the serialized object
  75824. */
  75825. serialize(): any;
  75826. /**
  75827. * Parse the serialized pipeline
  75828. * @param source Source pipeline.
  75829. * @param scene The scene to load the pipeline to.
  75830. * @param rootUrl The URL of the serialized pipeline.
  75831. * @returns An instantiated pipeline from the serialized object.
  75832. */
  75833. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75834. }
  75835. }
  75836. declare module BABYLON {
  75837. /** @hidden */
  75838. export var ssaoPixelShader: {
  75839. name: string;
  75840. shader: string;
  75841. };
  75842. }
  75843. declare module BABYLON {
  75844. /**
  75845. * Render pipeline to produce ssao effect
  75846. */
  75847. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75848. /**
  75849. * @ignore
  75850. * The PassPostProcess id in the pipeline that contains the original scene color
  75851. */
  75852. SSAOOriginalSceneColorEffect: string;
  75853. /**
  75854. * @ignore
  75855. * The SSAO PostProcess id in the pipeline
  75856. */
  75857. SSAORenderEffect: string;
  75858. /**
  75859. * @ignore
  75860. * The horizontal blur PostProcess id in the pipeline
  75861. */
  75862. SSAOBlurHRenderEffect: string;
  75863. /**
  75864. * @ignore
  75865. * The vertical blur PostProcess id in the pipeline
  75866. */
  75867. SSAOBlurVRenderEffect: string;
  75868. /**
  75869. * @ignore
  75870. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75871. */
  75872. SSAOCombineRenderEffect: string;
  75873. /**
  75874. * The output strength of the SSAO post-process. Default value is 1.0.
  75875. */
  75876. totalStrength: number;
  75877. /**
  75878. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75879. */
  75880. radius: number;
  75881. /**
  75882. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75883. * Must not be equal to fallOff and superior to fallOff.
  75884. * Default value is 0.0075
  75885. */
  75886. area: number;
  75887. /**
  75888. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75889. * Must not be equal to area and inferior to area.
  75890. * Default value is 0.000001
  75891. */
  75892. fallOff: number;
  75893. /**
  75894. * The base color of the SSAO post-process
  75895. * The final result is "base + ssao" between [0, 1]
  75896. */
  75897. base: number;
  75898. private _scene;
  75899. private _depthTexture;
  75900. private _randomTexture;
  75901. private _originalColorPostProcess;
  75902. private _ssaoPostProcess;
  75903. private _blurHPostProcess;
  75904. private _blurVPostProcess;
  75905. private _ssaoCombinePostProcess;
  75906. private _firstUpdate;
  75907. /**
  75908. * Gets active scene
  75909. */
  75910. get scene(): Scene;
  75911. /**
  75912. * @constructor
  75913. * @param name - The rendering pipeline name
  75914. * @param scene - The scene linked to this pipeline
  75915. * @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 }
  75916. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75917. */
  75918. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75919. /**
  75920. * Get the class name
  75921. * @returns "SSAORenderingPipeline"
  75922. */
  75923. getClassName(): string;
  75924. /**
  75925. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75926. */
  75927. dispose(disableDepthRender?: boolean): void;
  75928. private _createBlurPostProcess;
  75929. /** @hidden */
  75930. _rebuild(): void;
  75931. private _createSSAOPostProcess;
  75932. private _createSSAOCombinePostProcess;
  75933. private _createRandomTexture;
  75934. }
  75935. }
  75936. declare module BABYLON {
  75937. /**
  75938. * Contains all parameters needed for the prepass to perform
  75939. * screen space reflections
  75940. */
  75941. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75942. /**
  75943. * Is ssr enabled
  75944. */
  75945. enabled: boolean;
  75946. /**
  75947. * Name of the configuration
  75948. */
  75949. name: string;
  75950. /**
  75951. * Textures that should be present in the MRT for this effect to work
  75952. */
  75953. readonly texturesRequired: number[];
  75954. }
  75955. }
  75956. declare module BABYLON {
  75957. /** @hidden */
  75958. export var screenSpaceReflectionPixelShader: {
  75959. name: string;
  75960. shader: string;
  75961. };
  75962. }
  75963. declare module BABYLON {
  75964. /**
  75965. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75966. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75967. */
  75968. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75969. /**
  75970. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75971. */
  75972. threshold: number;
  75973. /**
  75974. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75975. */
  75976. strength: number;
  75977. /**
  75978. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75979. */
  75980. reflectionSpecularFalloffExponent: number;
  75981. /**
  75982. * 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]
  75983. */
  75984. step: number;
  75985. /**
  75986. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75987. */
  75988. roughnessFactor: number;
  75989. private _forceGeometryBuffer;
  75990. private _geometryBufferRenderer;
  75991. private _prePassRenderer;
  75992. private _enableSmoothReflections;
  75993. private _reflectionSamples;
  75994. private _smoothSteps;
  75995. /**
  75996. * Gets a string identifying the name of the class
  75997. * @returns "ScreenSpaceReflectionPostProcess" string
  75998. */
  75999. getClassName(): string;
  76000. /**
  76001. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76002. * @param name The name of the effect.
  76003. * @param scene The scene containing the objects to calculate reflections.
  76004. * @param options The required width/height ratio to downsize to before computing the render pass.
  76005. * @param camera The camera to apply the render pass to.
  76006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76007. * @param engine The engine which the post process will be applied. (default: current engine)
  76008. * @param reusable If the post process can be reused on the same frame. (default: false)
  76009. * @param textureType Type of textures used when performing the post process. (default: 0)
  76010. * @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)
  76011. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76012. */
  76013. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76014. /**
  76015. * Gets whether or not smoothing reflections is enabled.
  76016. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76017. */
  76018. get enableSmoothReflections(): boolean;
  76019. /**
  76020. * Sets whether or not smoothing reflections is enabled.
  76021. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76022. */
  76023. set enableSmoothReflections(enabled: boolean);
  76024. /**
  76025. * Gets the number of samples taken while computing reflections. More samples count is high,
  76026. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76027. */
  76028. get reflectionSamples(): number;
  76029. /**
  76030. * Sets the number of samples taken while computing reflections. More samples count is high,
  76031. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76032. */
  76033. set reflectionSamples(samples: number);
  76034. /**
  76035. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76036. * more the post-process will require GPU power and can generate a drop in FPS.
  76037. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76038. */
  76039. get smoothSteps(): number;
  76040. set smoothSteps(steps: number);
  76041. private _updateEffectDefines;
  76042. /** @hidden */
  76043. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76044. }
  76045. }
  76046. declare module BABYLON {
  76047. /** @hidden */
  76048. export var standardPixelShader: {
  76049. name: string;
  76050. shader: string;
  76051. };
  76052. }
  76053. declare module BABYLON {
  76054. /**
  76055. * Standard rendering pipeline
  76056. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76057. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76058. */
  76059. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76060. /**
  76061. * Public members
  76062. */
  76063. /**
  76064. * Post-process which contains the original scene color before the pipeline applies all the effects
  76065. */
  76066. originalPostProcess: Nullable<PostProcess>;
  76067. /**
  76068. * Post-process used to down scale an image x4
  76069. */
  76070. downSampleX4PostProcess: Nullable<PostProcess>;
  76071. /**
  76072. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76073. */
  76074. brightPassPostProcess: Nullable<PostProcess>;
  76075. /**
  76076. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76077. */
  76078. blurHPostProcesses: PostProcess[];
  76079. /**
  76080. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76081. */
  76082. blurVPostProcesses: PostProcess[];
  76083. /**
  76084. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76085. */
  76086. textureAdderPostProcess: Nullable<PostProcess>;
  76087. /**
  76088. * Post-process used to create volumetric lighting effect
  76089. */
  76090. volumetricLightPostProcess: Nullable<PostProcess>;
  76091. /**
  76092. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76093. */
  76094. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76095. /**
  76096. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76097. */
  76098. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76099. /**
  76100. * Post-process used to merge the volumetric light effect and the real scene color
  76101. */
  76102. volumetricLightMergePostProces: Nullable<PostProcess>;
  76103. /**
  76104. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76105. */
  76106. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76107. /**
  76108. * Base post-process used to calculate the average luminance of the final image for HDR
  76109. */
  76110. luminancePostProcess: Nullable<PostProcess>;
  76111. /**
  76112. * Post-processes used to create down sample post-processes in order to get
  76113. * the average luminance of the final image for HDR
  76114. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76115. */
  76116. luminanceDownSamplePostProcesses: PostProcess[];
  76117. /**
  76118. * Post-process used to create a HDR effect (light adaptation)
  76119. */
  76120. hdrPostProcess: Nullable<PostProcess>;
  76121. /**
  76122. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76123. */
  76124. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76125. /**
  76126. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76127. */
  76128. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76129. /**
  76130. * Post-process used to merge the final HDR post-process and the real scene color
  76131. */
  76132. hdrFinalPostProcess: Nullable<PostProcess>;
  76133. /**
  76134. * Post-process used to create a lens flare effect
  76135. */
  76136. lensFlarePostProcess: Nullable<PostProcess>;
  76137. /**
  76138. * Post-process that merges the result of the lens flare post-process and the real scene color
  76139. */
  76140. lensFlareComposePostProcess: Nullable<PostProcess>;
  76141. /**
  76142. * Post-process used to create a motion blur effect
  76143. */
  76144. motionBlurPostProcess: Nullable<PostProcess>;
  76145. /**
  76146. * Post-process used to create a depth of field effect
  76147. */
  76148. depthOfFieldPostProcess: Nullable<PostProcess>;
  76149. /**
  76150. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76151. */
  76152. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76153. /**
  76154. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76155. */
  76156. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76157. /**
  76158. * Represents the brightness threshold in order to configure the illuminated surfaces
  76159. */
  76160. brightThreshold: number;
  76161. /**
  76162. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76163. */
  76164. blurWidth: number;
  76165. /**
  76166. * Sets if the blur for highlighted surfaces must be only horizontal
  76167. */
  76168. horizontalBlur: boolean;
  76169. /**
  76170. * Gets the overall exposure used by the pipeline
  76171. */
  76172. get exposure(): number;
  76173. /**
  76174. * Sets the overall exposure used by the pipeline
  76175. */
  76176. set exposure(value: number);
  76177. /**
  76178. * Texture used typically to simulate "dirty" on camera lens
  76179. */
  76180. lensTexture: Nullable<Texture>;
  76181. /**
  76182. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76183. */
  76184. volumetricLightCoefficient: number;
  76185. /**
  76186. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76187. */
  76188. volumetricLightPower: number;
  76189. /**
  76190. * Used the set the blur intensity to smooth the volumetric lights
  76191. */
  76192. volumetricLightBlurScale: number;
  76193. /**
  76194. * Light (spot or directional) used to generate the volumetric lights rays
  76195. * The source light must have a shadow generate so the pipeline can get its
  76196. * depth map
  76197. */
  76198. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76199. /**
  76200. * For eye adaptation, represents the minimum luminance the eye can see
  76201. */
  76202. hdrMinimumLuminance: number;
  76203. /**
  76204. * For eye adaptation, represents the decrease luminance speed
  76205. */
  76206. hdrDecreaseRate: number;
  76207. /**
  76208. * For eye adaptation, represents the increase luminance speed
  76209. */
  76210. hdrIncreaseRate: number;
  76211. /**
  76212. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76213. */
  76214. get hdrAutoExposure(): boolean;
  76215. /**
  76216. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76217. */
  76218. set hdrAutoExposure(value: boolean);
  76219. /**
  76220. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76221. */
  76222. lensColorTexture: Nullable<Texture>;
  76223. /**
  76224. * The overall strengh for the lens flare effect
  76225. */
  76226. lensFlareStrength: number;
  76227. /**
  76228. * Dispersion coefficient for lens flare ghosts
  76229. */
  76230. lensFlareGhostDispersal: number;
  76231. /**
  76232. * Main lens flare halo width
  76233. */
  76234. lensFlareHaloWidth: number;
  76235. /**
  76236. * Based on the lens distortion effect, defines how much the lens flare result
  76237. * is distorted
  76238. */
  76239. lensFlareDistortionStrength: number;
  76240. /**
  76241. * Configures the blur intensity used for for lens flare (halo)
  76242. */
  76243. lensFlareBlurWidth: number;
  76244. /**
  76245. * Lens star texture must be used to simulate rays on the flares and is available
  76246. * in the documentation
  76247. */
  76248. lensStarTexture: Nullable<Texture>;
  76249. /**
  76250. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76251. * flare effect by taking account of the dirt texture
  76252. */
  76253. lensFlareDirtTexture: Nullable<Texture>;
  76254. /**
  76255. * Represents the focal length for the depth of field effect
  76256. */
  76257. depthOfFieldDistance: number;
  76258. /**
  76259. * Represents the blur intensity for the blurred part of the depth of field effect
  76260. */
  76261. depthOfFieldBlurWidth: number;
  76262. /**
  76263. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76264. */
  76265. get motionStrength(): number;
  76266. /**
  76267. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76268. */
  76269. set motionStrength(strength: number);
  76270. /**
  76271. * Gets whether or not the motion blur post-process is object based or screen based.
  76272. */
  76273. get objectBasedMotionBlur(): boolean;
  76274. /**
  76275. * Sets whether or not the motion blur post-process should be object based or screen based
  76276. */
  76277. set objectBasedMotionBlur(value: boolean);
  76278. /**
  76279. * List of animations for the pipeline (IAnimatable implementation)
  76280. */
  76281. animations: Animation[];
  76282. /**
  76283. * Private members
  76284. */
  76285. private _scene;
  76286. private _currentDepthOfFieldSource;
  76287. private _basePostProcess;
  76288. private _fixedExposure;
  76289. private _currentExposure;
  76290. private _hdrAutoExposure;
  76291. private _hdrCurrentLuminance;
  76292. private _motionStrength;
  76293. private _isObjectBasedMotionBlur;
  76294. private _floatTextureType;
  76295. private _camerasToBeAttached;
  76296. private _ratio;
  76297. private _bloomEnabled;
  76298. private _depthOfFieldEnabled;
  76299. private _vlsEnabled;
  76300. private _lensFlareEnabled;
  76301. private _hdrEnabled;
  76302. private _motionBlurEnabled;
  76303. private _fxaaEnabled;
  76304. private _screenSpaceReflectionsEnabled;
  76305. private _motionBlurSamples;
  76306. private _volumetricLightStepsCount;
  76307. private _samples;
  76308. /**
  76309. * @ignore
  76310. * Specifies if the bloom pipeline is enabled
  76311. */
  76312. get BloomEnabled(): boolean;
  76313. set BloomEnabled(enabled: boolean);
  76314. /**
  76315. * @ignore
  76316. * Specifies if the depth of field pipeline is enabled
  76317. */
  76318. get DepthOfFieldEnabled(): boolean;
  76319. set DepthOfFieldEnabled(enabled: boolean);
  76320. /**
  76321. * @ignore
  76322. * Specifies if the lens flare pipeline is enabled
  76323. */
  76324. get LensFlareEnabled(): boolean;
  76325. set LensFlareEnabled(enabled: boolean);
  76326. /**
  76327. * @ignore
  76328. * Specifies if the HDR pipeline is enabled
  76329. */
  76330. get HDREnabled(): boolean;
  76331. set HDREnabled(enabled: boolean);
  76332. /**
  76333. * @ignore
  76334. * Specifies if the volumetric lights scattering effect is enabled
  76335. */
  76336. get VLSEnabled(): boolean;
  76337. set VLSEnabled(enabled: boolean);
  76338. /**
  76339. * @ignore
  76340. * Specifies if the motion blur effect is enabled
  76341. */
  76342. get MotionBlurEnabled(): boolean;
  76343. set MotionBlurEnabled(enabled: boolean);
  76344. /**
  76345. * Specifies if anti-aliasing is enabled
  76346. */
  76347. get fxaaEnabled(): boolean;
  76348. set fxaaEnabled(enabled: boolean);
  76349. /**
  76350. * Specifies if screen space reflections are enabled.
  76351. */
  76352. get screenSpaceReflectionsEnabled(): boolean;
  76353. set screenSpaceReflectionsEnabled(enabled: boolean);
  76354. /**
  76355. * Specifies the number of steps used to calculate the volumetric lights
  76356. * Typically in interval [50, 200]
  76357. */
  76358. get volumetricLightStepsCount(): number;
  76359. set volumetricLightStepsCount(count: number);
  76360. /**
  76361. * Specifies the number of samples used for the motion blur effect
  76362. * Typically in interval [16, 64]
  76363. */
  76364. get motionBlurSamples(): number;
  76365. set motionBlurSamples(samples: number);
  76366. /**
  76367. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76368. */
  76369. get samples(): number;
  76370. set samples(sampleCount: number);
  76371. /**
  76372. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76373. * @constructor
  76374. * @param name The rendering pipeline name
  76375. * @param scene The scene linked to this pipeline
  76376. * @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)
  76377. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76378. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76379. */
  76380. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76381. private _buildPipeline;
  76382. private _createDownSampleX4PostProcess;
  76383. private _createBrightPassPostProcess;
  76384. private _createBlurPostProcesses;
  76385. private _createTextureAdderPostProcess;
  76386. private _createVolumetricLightPostProcess;
  76387. private _createLuminancePostProcesses;
  76388. private _createHdrPostProcess;
  76389. private _createLensFlarePostProcess;
  76390. private _createDepthOfFieldPostProcess;
  76391. private _createMotionBlurPostProcess;
  76392. private _getDepthTexture;
  76393. private _disposePostProcesses;
  76394. /**
  76395. * Dispose of the pipeline and stop all post processes
  76396. */
  76397. dispose(): void;
  76398. /**
  76399. * Serialize the rendering pipeline (Used when exporting)
  76400. * @returns the serialized object
  76401. */
  76402. serialize(): any;
  76403. /**
  76404. * Parse the serialized pipeline
  76405. * @param source Source pipeline.
  76406. * @param scene The scene to load the pipeline to.
  76407. * @param rootUrl The URL of the serialized pipeline.
  76408. * @returns An instantiated pipeline from the serialized object.
  76409. */
  76410. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76411. /**
  76412. * Luminance steps
  76413. */
  76414. static LuminanceSteps: number;
  76415. }
  76416. }
  76417. declare module BABYLON {
  76418. /** @hidden */
  76419. export var tonemapPixelShader: {
  76420. name: string;
  76421. shader: string;
  76422. };
  76423. }
  76424. declare module BABYLON {
  76425. /** Defines operator used for tonemapping */
  76426. export enum TonemappingOperator {
  76427. /** Hable */
  76428. Hable = 0,
  76429. /** Reinhard */
  76430. Reinhard = 1,
  76431. /** HejiDawson */
  76432. HejiDawson = 2,
  76433. /** Photographic */
  76434. Photographic = 3
  76435. }
  76436. /**
  76437. * Defines a post process to apply tone mapping
  76438. */
  76439. export class TonemapPostProcess extends PostProcess {
  76440. private _operator;
  76441. /** Defines the required exposure adjustment */
  76442. exposureAdjustment: number;
  76443. /**
  76444. * Gets a string identifying the name of the class
  76445. * @returns "TonemapPostProcess" string
  76446. */
  76447. getClassName(): string;
  76448. /**
  76449. * Creates a new TonemapPostProcess
  76450. * @param name defines the name of the postprocess
  76451. * @param _operator defines the operator to use
  76452. * @param exposureAdjustment defines the required exposure adjustement
  76453. * @param camera defines the camera to use (can be null)
  76454. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76455. * @param engine defines the hosting engine (can be ignore if camera is set)
  76456. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76457. */
  76458. constructor(name: string, _operator: TonemappingOperator,
  76459. /** Defines the required exposure adjustment */
  76460. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76461. }
  76462. }
  76463. declare module BABYLON {
  76464. /** @hidden */
  76465. export var volumetricLightScatteringPixelShader: {
  76466. name: string;
  76467. shader: string;
  76468. };
  76469. }
  76470. declare module BABYLON {
  76471. /** @hidden */
  76472. export var volumetricLightScatteringPassVertexShader: {
  76473. name: string;
  76474. shader: string;
  76475. };
  76476. }
  76477. declare module BABYLON {
  76478. /** @hidden */
  76479. export var volumetricLightScatteringPassPixelShader: {
  76480. name: string;
  76481. shader: string;
  76482. };
  76483. }
  76484. declare module BABYLON {
  76485. /**
  76486. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76487. */
  76488. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76489. private _volumetricLightScatteringPass;
  76490. private _volumetricLightScatteringRTT;
  76491. private _viewPort;
  76492. private _screenCoordinates;
  76493. private _cachedDefines;
  76494. /**
  76495. * If not undefined, the mesh position is computed from the attached node position
  76496. */
  76497. attachedNode: {
  76498. position: Vector3;
  76499. };
  76500. /**
  76501. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76502. */
  76503. customMeshPosition: Vector3;
  76504. /**
  76505. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76506. */
  76507. useCustomMeshPosition: boolean;
  76508. /**
  76509. * If the post-process should inverse the light scattering direction
  76510. */
  76511. invert: boolean;
  76512. /**
  76513. * The internal mesh used by the post-process
  76514. */
  76515. mesh: Mesh;
  76516. /**
  76517. * @hidden
  76518. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76519. */
  76520. get useDiffuseColor(): boolean;
  76521. set useDiffuseColor(useDiffuseColor: boolean);
  76522. /**
  76523. * Array containing the excluded meshes not rendered in the internal pass
  76524. */
  76525. excludedMeshes: AbstractMesh[];
  76526. /**
  76527. * Controls the overall intensity of the post-process
  76528. */
  76529. exposure: number;
  76530. /**
  76531. * Dissipates each sample's contribution in range [0, 1]
  76532. */
  76533. decay: number;
  76534. /**
  76535. * Controls the overall intensity of each sample
  76536. */
  76537. weight: number;
  76538. /**
  76539. * Controls the density of each sample
  76540. */
  76541. density: number;
  76542. /**
  76543. * @constructor
  76544. * @param name The post-process name
  76545. * @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)
  76546. * @param camera The camera that the post-process will be attached to
  76547. * @param mesh The mesh used to create the light scattering
  76548. * @param samples The post-process quality, default 100
  76549. * @param samplingModeThe post-process filtering mode
  76550. * @param engine The babylon engine
  76551. * @param reusable If the post-process is reusable
  76552. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76553. */
  76554. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76555. /**
  76556. * Returns the string "VolumetricLightScatteringPostProcess"
  76557. * @returns "VolumetricLightScatteringPostProcess"
  76558. */
  76559. getClassName(): string;
  76560. private _isReady;
  76561. /**
  76562. * Sets the new light position for light scattering effect
  76563. * @param position The new custom light position
  76564. */
  76565. setCustomMeshPosition(position: Vector3): void;
  76566. /**
  76567. * Returns the light position for light scattering effect
  76568. * @return Vector3 The custom light position
  76569. */
  76570. getCustomMeshPosition(): Vector3;
  76571. /**
  76572. * Disposes the internal assets and detaches the post-process from the camera
  76573. */
  76574. dispose(camera: Camera): void;
  76575. /**
  76576. * Returns the render target texture used by the post-process
  76577. * @return the render target texture used by the post-process
  76578. */
  76579. getPass(): RenderTargetTexture;
  76580. private _meshExcluded;
  76581. private _createPass;
  76582. private _updateMeshScreenCoordinates;
  76583. /**
  76584. * Creates a default mesh for the Volumeric Light Scattering post-process
  76585. * @param name The mesh name
  76586. * @param scene The scene where to create the mesh
  76587. * @return the default mesh
  76588. */
  76589. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76590. }
  76591. }
  76592. declare module BABYLON {
  76593. /** @hidden */
  76594. export var screenSpaceCurvaturePixelShader: {
  76595. name: string;
  76596. shader: string;
  76597. };
  76598. }
  76599. declare module BABYLON {
  76600. /**
  76601. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76602. */
  76603. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76604. /**
  76605. * Defines how much ridge the curvature effect displays.
  76606. */
  76607. ridge: number;
  76608. /**
  76609. * Defines how much valley the curvature effect displays.
  76610. */
  76611. valley: number;
  76612. private _geometryBufferRenderer;
  76613. /**
  76614. * Gets a string identifying the name of the class
  76615. * @returns "ScreenSpaceCurvaturePostProcess" string
  76616. */
  76617. getClassName(): string;
  76618. /**
  76619. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76620. * @param name The name of the effect.
  76621. * @param scene The scene containing the objects to blur according to their velocity.
  76622. * @param options The required width/height ratio to downsize to before computing the render pass.
  76623. * @param camera The camera to apply the render pass to.
  76624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76625. * @param engine The engine which the post process will be applied. (default: current engine)
  76626. * @param reusable If the post process can be reused on the same frame. (default: false)
  76627. * @param textureType Type of textures used when performing the post process. (default: 0)
  76628. * @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)
  76629. */
  76630. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76631. /**
  76632. * Support test.
  76633. */
  76634. static get IsSupported(): boolean;
  76635. /** @hidden */
  76636. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. interface Scene {
  76641. /** @hidden (Backing field) */
  76642. _boundingBoxRenderer: BoundingBoxRenderer;
  76643. /** @hidden (Backing field) */
  76644. _forceShowBoundingBoxes: boolean;
  76645. /**
  76646. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76647. */
  76648. forceShowBoundingBoxes: boolean;
  76649. /**
  76650. * Gets the bounding box renderer associated with the scene
  76651. * @returns a BoundingBoxRenderer
  76652. */
  76653. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76654. }
  76655. interface AbstractMesh {
  76656. /** @hidden (Backing field) */
  76657. _showBoundingBox: boolean;
  76658. /**
  76659. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76660. */
  76661. showBoundingBox: boolean;
  76662. }
  76663. /**
  76664. * Component responsible of rendering the bounding box of the meshes in a scene.
  76665. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76666. */
  76667. export class BoundingBoxRenderer implements ISceneComponent {
  76668. /**
  76669. * The component name helpful to identify the component in the list of scene components.
  76670. */
  76671. readonly name: string;
  76672. /**
  76673. * The scene the component belongs to.
  76674. */
  76675. scene: Scene;
  76676. /**
  76677. * Color of the bounding box lines placed in front of an object
  76678. */
  76679. frontColor: Color3;
  76680. /**
  76681. * Color of the bounding box lines placed behind an object
  76682. */
  76683. backColor: Color3;
  76684. /**
  76685. * Defines if the renderer should show the back lines or not
  76686. */
  76687. showBackLines: boolean;
  76688. /**
  76689. * Observable raised before rendering a bounding box
  76690. */
  76691. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76692. /**
  76693. * Observable raised after rendering a bounding box
  76694. */
  76695. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76696. /**
  76697. * Observable raised after resources are created
  76698. */
  76699. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76700. /**
  76701. * When false, no bounding boxes will be rendered
  76702. */
  76703. enabled: boolean;
  76704. /**
  76705. * @hidden
  76706. */
  76707. renderList: SmartArray<BoundingBox>;
  76708. private _colorShader;
  76709. private _vertexBuffers;
  76710. private _indexBuffer;
  76711. private _fillIndexBuffer;
  76712. private _fillIndexData;
  76713. /**
  76714. * Instantiates a new bounding box renderer in a scene.
  76715. * @param scene the scene the renderer renders in
  76716. */
  76717. constructor(scene: Scene);
  76718. /**
  76719. * Registers the component in a given scene
  76720. */
  76721. register(): void;
  76722. private _evaluateSubMesh;
  76723. private _preActiveMesh;
  76724. private _prepareResources;
  76725. private _createIndexBuffer;
  76726. /**
  76727. * Rebuilds the elements related to this component in case of
  76728. * context lost for instance.
  76729. */
  76730. rebuild(): void;
  76731. /**
  76732. * @hidden
  76733. */
  76734. reset(): void;
  76735. /**
  76736. * Render the bounding boxes of a specific rendering group
  76737. * @param renderingGroupId defines the rendering group to render
  76738. */
  76739. render(renderingGroupId: number): void;
  76740. /**
  76741. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76742. * @param mesh Define the mesh to render the occlusion bounding box for
  76743. */
  76744. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76745. /**
  76746. * Dispose and release the resources attached to this renderer.
  76747. */
  76748. dispose(): void;
  76749. }
  76750. }
  76751. declare module BABYLON {
  76752. interface Scene {
  76753. /** @hidden (Backing field) */
  76754. _depthRenderer: {
  76755. [id: string]: DepthRenderer;
  76756. };
  76757. /**
  76758. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76759. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76760. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76761. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76762. * @returns the created depth renderer
  76763. */
  76764. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76765. /**
  76766. * Disables a depth renderer for a given camera
  76767. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76768. */
  76769. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76770. }
  76771. /**
  76772. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76773. * in several rendering techniques.
  76774. */
  76775. export class DepthRendererSceneComponent implements ISceneComponent {
  76776. /**
  76777. * The component name helpful to identify the component in the list of scene components.
  76778. */
  76779. readonly name: string;
  76780. /**
  76781. * The scene the component belongs to.
  76782. */
  76783. scene: Scene;
  76784. /**
  76785. * Creates a new instance of the component for the given scene
  76786. * @param scene Defines the scene to register the component in
  76787. */
  76788. constructor(scene: Scene);
  76789. /**
  76790. * Registers the component in a given scene
  76791. */
  76792. register(): void;
  76793. /**
  76794. * Rebuilds the elements related to this component in case of
  76795. * context lost for instance.
  76796. */
  76797. rebuild(): void;
  76798. /**
  76799. * Disposes the component and the associated resources
  76800. */
  76801. dispose(): void;
  76802. private _gatherRenderTargets;
  76803. private _gatherActiveCameraRenderTargets;
  76804. }
  76805. }
  76806. declare module BABYLON {
  76807. interface AbstractScene {
  76808. /** @hidden (Backing field) */
  76809. _prePassRenderer: Nullable<PrePassRenderer>;
  76810. /**
  76811. * Gets or Sets the current prepass renderer associated to the scene.
  76812. */
  76813. prePassRenderer: Nullable<PrePassRenderer>;
  76814. /**
  76815. * Enables the prepass and associates it with the scene
  76816. * @returns the PrePassRenderer
  76817. */
  76818. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76819. /**
  76820. * Disables the prepass associated with the scene
  76821. */
  76822. disablePrePassRenderer(): void;
  76823. }
  76824. interface RenderTargetTexture {
  76825. /** @hidden */
  76826. _prePassRenderTarget: PrePassRenderTarget;
  76827. }
  76828. /**
  76829. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76830. * in several rendering techniques.
  76831. */
  76832. export class PrePassRendererSceneComponent implements ISceneComponent {
  76833. /**
  76834. * The component name helpful to identify the component in the list of scene components.
  76835. */
  76836. readonly name: string;
  76837. /**
  76838. * The scene the component belongs to.
  76839. */
  76840. scene: Scene;
  76841. /**
  76842. * Creates a new instance of the component for the given scene
  76843. * @param scene Defines the scene to register the component in
  76844. */
  76845. constructor(scene: Scene);
  76846. /**
  76847. * Registers the component in a given scene
  76848. */
  76849. register(): void;
  76850. private _beforeRenderTargetDraw;
  76851. private _afterRenderTargetDraw;
  76852. private _beforeRenderTargetClearStage;
  76853. private _beforeCameraDraw;
  76854. private _afterCameraDraw;
  76855. private _beforeClearStage;
  76856. private _beforeRenderingMeshStage;
  76857. private _afterRenderingMeshStage;
  76858. /**
  76859. * Rebuilds the elements related to this component in case of
  76860. * context lost for instance.
  76861. */
  76862. rebuild(): void;
  76863. /**
  76864. * Disposes the component and the associated resources
  76865. */
  76866. dispose(): void;
  76867. }
  76868. }
  76869. declare module BABYLON {
  76870. /** @hidden */
  76871. export var fibonacci: {
  76872. name: string;
  76873. shader: string;
  76874. };
  76875. }
  76876. declare module BABYLON {
  76877. /** @hidden */
  76878. export var diffusionProfile: {
  76879. name: string;
  76880. shader: string;
  76881. };
  76882. }
  76883. declare module BABYLON {
  76884. /** @hidden */
  76885. export var subSurfaceScatteringPixelShader: {
  76886. name: string;
  76887. shader: string;
  76888. };
  76889. }
  76890. declare module BABYLON {
  76891. /**
  76892. * Sub surface scattering post process
  76893. */
  76894. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76895. /**
  76896. * Gets a string identifying the name of the class
  76897. * @returns "SubSurfaceScatteringPostProcess" string
  76898. */
  76899. getClassName(): string;
  76900. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76901. }
  76902. }
  76903. declare module BABYLON {
  76904. /**
  76905. * Contains all parameters needed for the prepass to perform
  76906. * screen space subsurface scattering
  76907. */
  76908. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76909. /** @hidden */
  76910. static _SceneComponentInitialization: (scene: Scene) => void;
  76911. private _ssDiffusionS;
  76912. private _ssFilterRadii;
  76913. private _ssDiffusionD;
  76914. /**
  76915. * Post process to attach for screen space subsurface scattering
  76916. */
  76917. postProcess: SubSurfaceScatteringPostProcess;
  76918. /**
  76919. * Diffusion profile color for subsurface scattering
  76920. */
  76921. get ssDiffusionS(): number[];
  76922. /**
  76923. * Diffusion profile max color channel value for subsurface scattering
  76924. */
  76925. get ssDiffusionD(): number[];
  76926. /**
  76927. * Diffusion profile filter radius for subsurface scattering
  76928. */
  76929. get ssFilterRadii(): number[];
  76930. /**
  76931. * Is subsurface enabled
  76932. */
  76933. enabled: boolean;
  76934. /**
  76935. * Does the output of this prepass need to go through imageprocessing
  76936. */
  76937. needsImageProcessing: boolean;
  76938. /**
  76939. * Name of the configuration
  76940. */
  76941. name: string;
  76942. /**
  76943. * Diffusion profile colors for subsurface scattering
  76944. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76945. * See ...
  76946. * Note that you can only store up to 5 of them
  76947. */
  76948. ssDiffusionProfileColors: Color3[];
  76949. /**
  76950. * Defines the ratio real world => scene units.
  76951. * Used for subsurface scattering
  76952. */
  76953. metersPerUnit: number;
  76954. /**
  76955. * Textures that should be present in the MRT for this effect to work
  76956. */
  76957. readonly texturesRequired: number[];
  76958. private _scene;
  76959. /**
  76960. * Builds a subsurface configuration object
  76961. * @param scene The scene
  76962. */
  76963. constructor(scene: Scene);
  76964. /**
  76965. * Adds a new diffusion profile.
  76966. * Useful for more realistic subsurface scattering on diverse materials.
  76967. * @param color The color of the diffusion profile. Should be the average color of the material.
  76968. * @return The index of the diffusion profile for the material subsurface configuration
  76969. */
  76970. addDiffusionProfile(color: Color3): number;
  76971. /**
  76972. * Creates the sss post process
  76973. * @return The created post process
  76974. */
  76975. createPostProcess(): SubSurfaceScatteringPostProcess;
  76976. /**
  76977. * Deletes all diffusion profiles.
  76978. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76979. */
  76980. clearAllDiffusionProfiles(): void;
  76981. /**
  76982. * Disposes this object
  76983. */
  76984. dispose(): void;
  76985. /**
  76986. * @hidden
  76987. * https://zero-radiance.github.io/post/sampling-diffusion/
  76988. *
  76989. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76990. * ------------------------------------------------------------------------------------
  76991. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76992. * PDF[r, phi, s] = r * R[r, phi, s]
  76993. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76994. * ------------------------------------------------------------------------------------
  76995. * We importance sample the color channel with the widest scattering distance.
  76996. */
  76997. getDiffusionProfileParameters(color: Color3): number;
  76998. /**
  76999. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77000. * 'u' is the random number (the value of the CDF): [0, 1).
  77001. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77002. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77003. */
  77004. private _sampleBurleyDiffusionProfile;
  77005. }
  77006. }
  77007. declare module BABYLON {
  77008. interface AbstractScene {
  77009. /** @hidden (Backing field) */
  77010. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77011. /**
  77012. * Gets or Sets the current prepass renderer associated to the scene.
  77013. */
  77014. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77015. /**
  77016. * Enables the subsurface effect for prepass
  77017. * @returns the SubSurfaceConfiguration
  77018. */
  77019. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77020. /**
  77021. * Disables the subsurface effect for prepass
  77022. */
  77023. disableSubSurfaceForPrePass(): void;
  77024. }
  77025. /**
  77026. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77027. * in several rendering techniques.
  77028. */
  77029. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77030. /**
  77031. * The component name helpful to identify the component in the list of scene components.
  77032. */
  77033. readonly name: string;
  77034. /**
  77035. * The scene the component belongs to.
  77036. */
  77037. scene: Scene;
  77038. /**
  77039. * Creates a new instance of the component for the given scene
  77040. * @param scene Defines the scene to register the component in
  77041. */
  77042. constructor(scene: Scene);
  77043. /**
  77044. * Registers the component in a given scene
  77045. */
  77046. register(): void;
  77047. /**
  77048. * Serializes the component data to the specified json object
  77049. * @param serializationObject The object to serialize to
  77050. */
  77051. serialize(serializationObject: any): void;
  77052. /**
  77053. * Adds all the elements from the container to the scene
  77054. * @param container the container holding the elements
  77055. */
  77056. addFromContainer(container: AbstractScene): void;
  77057. /**
  77058. * Removes all the elements in the container from the scene
  77059. * @param container contains the elements to remove
  77060. * @param dispose if the removed element should be disposed (default: false)
  77061. */
  77062. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77063. /**
  77064. * Rebuilds the elements related to this component in case of
  77065. * context lost for instance.
  77066. */
  77067. rebuild(): void;
  77068. /**
  77069. * Disposes the component and the associated resources
  77070. */
  77071. dispose(): void;
  77072. }
  77073. }
  77074. declare module BABYLON {
  77075. /** @hidden */
  77076. export var outlinePixelShader: {
  77077. name: string;
  77078. shader: string;
  77079. };
  77080. }
  77081. declare module BABYLON {
  77082. /** @hidden */
  77083. export var outlineVertexShader: {
  77084. name: string;
  77085. shader: string;
  77086. };
  77087. }
  77088. declare module BABYLON {
  77089. interface Scene {
  77090. /** @hidden */
  77091. _outlineRenderer: OutlineRenderer;
  77092. /**
  77093. * Gets the outline renderer associated with the scene
  77094. * @returns a OutlineRenderer
  77095. */
  77096. getOutlineRenderer(): OutlineRenderer;
  77097. }
  77098. interface AbstractMesh {
  77099. /** @hidden (Backing field) */
  77100. _renderOutline: boolean;
  77101. /**
  77102. * Gets or sets a boolean indicating if the outline must be rendered as well
  77103. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77104. */
  77105. renderOutline: boolean;
  77106. /** @hidden (Backing field) */
  77107. _renderOverlay: boolean;
  77108. /**
  77109. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77110. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77111. */
  77112. renderOverlay: boolean;
  77113. }
  77114. /**
  77115. * This class is responsible to draw the outline/overlay of meshes.
  77116. * It should not be used directly but through the available method on mesh.
  77117. */
  77118. export class OutlineRenderer implements ISceneComponent {
  77119. /**
  77120. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77121. */
  77122. private static _StencilReference;
  77123. /**
  77124. * The name of the component. Each component must have a unique name.
  77125. */
  77126. name: string;
  77127. /**
  77128. * The scene the component belongs to.
  77129. */
  77130. scene: Scene;
  77131. /**
  77132. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77133. */
  77134. zOffset: number;
  77135. private _engine;
  77136. private _effect;
  77137. private _cachedDefines;
  77138. private _savedDepthWrite;
  77139. /**
  77140. * Instantiates a new outline renderer. (There could be only one per scene).
  77141. * @param scene Defines the scene it belongs to
  77142. */
  77143. constructor(scene: Scene);
  77144. /**
  77145. * Register the component to one instance of a scene.
  77146. */
  77147. register(): void;
  77148. /**
  77149. * Rebuilds the elements related to this component in case of
  77150. * context lost for instance.
  77151. */
  77152. rebuild(): void;
  77153. /**
  77154. * Disposes the component and the associated resources.
  77155. */
  77156. dispose(): void;
  77157. /**
  77158. * Renders the outline in the canvas.
  77159. * @param subMesh Defines the sumesh to render
  77160. * @param batch Defines the batch of meshes in case of instances
  77161. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77162. */
  77163. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77164. /**
  77165. * Returns whether or not the outline renderer is ready for a given submesh.
  77166. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77167. * @param subMesh Defines the submesh to check readiness for
  77168. * @param useInstances Defines whether wee are trying to render instances or not
  77169. * @returns true if ready otherwise false
  77170. */
  77171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77172. private _beforeRenderingMesh;
  77173. private _afterRenderingMesh;
  77174. }
  77175. }
  77176. declare module BABYLON {
  77177. /**
  77178. * Defines the basic options interface of a Sprite Frame Source Size.
  77179. */
  77180. export interface ISpriteJSONSpriteSourceSize {
  77181. /**
  77182. * number of the original width of the Frame
  77183. */
  77184. w: number;
  77185. /**
  77186. * number of the original height of the Frame
  77187. */
  77188. h: number;
  77189. }
  77190. /**
  77191. * Defines the basic options interface of a Sprite Frame Data.
  77192. */
  77193. export interface ISpriteJSONSpriteFrameData {
  77194. /**
  77195. * number of the x offset of the Frame
  77196. */
  77197. x: number;
  77198. /**
  77199. * number of the y offset of the Frame
  77200. */
  77201. y: number;
  77202. /**
  77203. * number of the width of the Frame
  77204. */
  77205. w: number;
  77206. /**
  77207. * number of the height of the Frame
  77208. */
  77209. h: number;
  77210. }
  77211. /**
  77212. * Defines the basic options interface of a JSON Sprite.
  77213. */
  77214. export interface ISpriteJSONSprite {
  77215. /**
  77216. * string name of the Frame
  77217. */
  77218. filename: string;
  77219. /**
  77220. * ISpriteJSONSpriteFrame basic object of the frame data
  77221. */
  77222. frame: ISpriteJSONSpriteFrameData;
  77223. /**
  77224. * boolean to flag is the frame was rotated.
  77225. */
  77226. rotated: boolean;
  77227. /**
  77228. * boolean to flag is the frame was trimmed.
  77229. */
  77230. trimmed: boolean;
  77231. /**
  77232. * ISpriteJSONSpriteFrame basic object of the source data
  77233. */
  77234. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77235. /**
  77236. * ISpriteJSONSpriteFrame basic object of the source data
  77237. */
  77238. sourceSize: ISpriteJSONSpriteSourceSize;
  77239. }
  77240. /**
  77241. * Defines the basic options interface of a JSON atlas.
  77242. */
  77243. export interface ISpriteJSONAtlas {
  77244. /**
  77245. * Array of objects that contain the frame data.
  77246. */
  77247. frames: Array<ISpriteJSONSprite>;
  77248. /**
  77249. * object basic object containing the sprite meta data.
  77250. */
  77251. meta?: object;
  77252. }
  77253. }
  77254. declare module BABYLON {
  77255. /** @hidden */
  77256. export var spriteMapPixelShader: {
  77257. name: string;
  77258. shader: string;
  77259. };
  77260. }
  77261. declare module BABYLON {
  77262. /** @hidden */
  77263. export var spriteMapVertexShader: {
  77264. name: string;
  77265. shader: string;
  77266. };
  77267. }
  77268. declare module BABYLON {
  77269. /**
  77270. * Defines the basic options interface of a SpriteMap
  77271. */
  77272. export interface ISpriteMapOptions {
  77273. /**
  77274. * Vector2 of the number of cells in the grid.
  77275. */
  77276. stageSize?: Vector2;
  77277. /**
  77278. * Vector2 of the size of the output plane in World Units.
  77279. */
  77280. outputSize?: Vector2;
  77281. /**
  77282. * Vector3 of the position of the output plane in World Units.
  77283. */
  77284. outputPosition?: Vector3;
  77285. /**
  77286. * Vector3 of the rotation of the output plane.
  77287. */
  77288. outputRotation?: Vector3;
  77289. /**
  77290. * number of layers that the system will reserve in resources.
  77291. */
  77292. layerCount?: number;
  77293. /**
  77294. * number of max animation frames a single cell will reserve in resources.
  77295. */
  77296. maxAnimationFrames?: number;
  77297. /**
  77298. * number cell index of the base tile when the system compiles.
  77299. */
  77300. baseTile?: number;
  77301. /**
  77302. * boolean flip the sprite after its been repositioned by the framing data.
  77303. */
  77304. flipU?: boolean;
  77305. /**
  77306. * Vector3 scalar of the global RGB values of the SpriteMap.
  77307. */
  77308. colorMultiply?: Vector3;
  77309. }
  77310. /**
  77311. * Defines the IDisposable interface in order to be cleanable from resources.
  77312. */
  77313. export interface ISpriteMap extends IDisposable {
  77314. /**
  77315. * String name of the SpriteMap.
  77316. */
  77317. name: string;
  77318. /**
  77319. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77320. */
  77321. atlasJSON: ISpriteJSONAtlas;
  77322. /**
  77323. * Texture of the SpriteMap.
  77324. */
  77325. spriteSheet: Texture;
  77326. /**
  77327. * The parameters to initialize the SpriteMap with.
  77328. */
  77329. options: ISpriteMapOptions;
  77330. }
  77331. /**
  77332. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77333. */
  77334. export class SpriteMap implements ISpriteMap {
  77335. /** The Name of the spriteMap */
  77336. name: string;
  77337. /** The JSON file with the frame and meta data */
  77338. atlasJSON: ISpriteJSONAtlas;
  77339. /** The systems Sprite Sheet Texture */
  77340. spriteSheet: Texture;
  77341. /** Arguments passed with the Constructor */
  77342. options: ISpriteMapOptions;
  77343. /** Public Sprite Storage array, parsed from atlasJSON */
  77344. sprites: Array<ISpriteJSONSprite>;
  77345. /** Returns the Number of Sprites in the System */
  77346. get spriteCount(): number;
  77347. /** Returns the Position of Output Plane*/
  77348. get position(): Vector3;
  77349. /** Returns the Position of Output Plane*/
  77350. set position(v: Vector3);
  77351. /** Returns the Rotation of Output Plane*/
  77352. get rotation(): Vector3;
  77353. /** Returns the Rotation of Output Plane*/
  77354. set rotation(v: Vector3);
  77355. /** Sets the AnimationMap*/
  77356. get animationMap(): RawTexture;
  77357. /** Sets the AnimationMap*/
  77358. set animationMap(v: RawTexture);
  77359. /** Scene that the SpriteMap was created in */
  77360. private _scene;
  77361. /** Texture Buffer of Float32 that holds tile frame data*/
  77362. private _frameMap;
  77363. /** Texture Buffers of Float32 that holds tileMap data*/
  77364. private _tileMaps;
  77365. /** Texture Buffer of Float32 that holds Animation Data*/
  77366. private _animationMap;
  77367. /** Custom ShaderMaterial Central to the System*/
  77368. private _material;
  77369. /** Custom ShaderMaterial Central to the System*/
  77370. private _output;
  77371. /** Systems Time Ticker*/
  77372. private _time;
  77373. /**
  77374. * Creates a new SpriteMap
  77375. * @param name defines the SpriteMaps Name
  77376. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77377. * @param spriteSheet is the Texture that the Sprites are on.
  77378. * @param options a basic deployment configuration
  77379. * @param scene The Scene that the map is deployed on
  77380. */
  77381. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77382. /**
  77383. * Returns tileID location
  77384. * @returns Vector2 the cell position ID
  77385. */
  77386. getTileID(): Vector2;
  77387. /**
  77388. * Gets the UV location of the mouse over the SpriteMap.
  77389. * @returns Vector2 the UV position of the mouse interaction
  77390. */
  77391. getMousePosition(): Vector2;
  77392. /**
  77393. * Creates the "frame" texture Buffer
  77394. * -------------------------------------
  77395. * Structure of frames
  77396. * "filename": "Falling-Water-2.png",
  77397. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77398. * "rotated": true,
  77399. * "trimmed": true,
  77400. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77401. * "sourceSize": {"w":32,"h":32}
  77402. * @returns RawTexture of the frameMap
  77403. */
  77404. private _createFrameBuffer;
  77405. /**
  77406. * Creates the tileMap texture Buffer
  77407. * @param buffer normally and array of numbers, or a false to generate from scratch
  77408. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77409. * @returns RawTexture of the tileMap
  77410. */
  77411. private _createTileBuffer;
  77412. /**
  77413. * Modifies the data of the tileMaps
  77414. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77415. * @param pos is the iVector2 Coordinates of the Tile
  77416. * @param tile The SpriteIndex of the new Tile
  77417. */
  77418. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77419. /**
  77420. * Creates the animationMap texture Buffer
  77421. * @param buffer normally and array of numbers, or a false to generate from scratch
  77422. * @returns RawTexture of the animationMap
  77423. */
  77424. private _createTileAnimationBuffer;
  77425. /**
  77426. * Modifies the data of the animationMap
  77427. * @param cellID is the Index of the Sprite
  77428. * @param _frame is the target Animation frame
  77429. * @param toCell is the Target Index of the next frame of the animation
  77430. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77431. * @param speed is a global scalar of the time variable on the map.
  77432. */
  77433. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77434. /**
  77435. * Exports the .tilemaps file
  77436. */
  77437. saveTileMaps(): void;
  77438. /**
  77439. * Imports the .tilemaps file
  77440. * @param url of the .tilemaps file
  77441. */
  77442. loadTileMaps(url: string): void;
  77443. /**
  77444. * Release associated resources
  77445. */
  77446. dispose(): void;
  77447. }
  77448. }
  77449. declare module BABYLON {
  77450. /**
  77451. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77452. * @see https://doc.babylonjs.com/babylon101/sprites
  77453. */
  77454. export class SpritePackedManager extends SpriteManager {
  77455. /** defines the packed manager's name */
  77456. name: string;
  77457. /**
  77458. * Creates a new sprite manager from a packed sprite sheet
  77459. * @param name defines the manager's name
  77460. * @param imgUrl defines the sprite sheet url
  77461. * @param capacity defines the maximum allowed number of sprites
  77462. * @param scene defines the hosting scene
  77463. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77464. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77465. * @param samplingMode defines the sampling mode to use with spritesheet
  77466. * @param fromPacked set to true; do not alter
  77467. */
  77468. constructor(
  77469. /** defines the packed manager's name */
  77470. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77471. }
  77472. }
  77473. declare module BABYLON {
  77474. /**
  77475. * Defines the list of states available for a task inside a AssetsManager
  77476. */
  77477. export enum AssetTaskState {
  77478. /**
  77479. * Initialization
  77480. */
  77481. INIT = 0,
  77482. /**
  77483. * Running
  77484. */
  77485. RUNNING = 1,
  77486. /**
  77487. * Done
  77488. */
  77489. DONE = 2,
  77490. /**
  77491. * Error
  77492. */
  77493. ERROR = 3
  77494. }
  77495. /**
  77496. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77497. */
  77498. export abstract class AbstractAssetTask {
  77499. /**
  77500. * Task name
  77501. */ name: string;
  77502. /**
  77503. * Callback called when the task is successful
  77504. */
  77505. onSuccess: (task: any) => void;
  77506. /**
  77507. * Callback called when the task is not successful
  77508. */
  77509. onError: (task: any, message?: string, exception?: any) => void;
  77510. /**
  77511. * Creates a new AssetsManager
  77512. * @param name defines the name of the task
  77513. */
  77514. constructor(
  77515. /**
  77516. * Task name
  77517. */ name: string);
  77518. private _isCompleted;
  77519. private _taskState;
  77520. private _errorObject;
  77521. /**
  77522. * Get if the task is completed
  77523. */
  77524. get isCompleted(): boolean;
  77525. /**
  77526. * Gets the current state of the task
  77527. */
  77528. get taskState(): AssetTaskState;
  77529. /**
  77530. * Gets the current error object (if task is in error)
  77531. */
  77532. get errorObject(): {
  77533. message?: string;
  77534. exception?: any;
  77535. };
  77536. /**
  77537. * Internal only
  77538. * @hidden
  77539. */
  77540. _setErrorObject(message?: string, exception?: any): void;
  77541. /**
  77542. * Execute the current task
  77543. * @param scene defines the scene where you want your assets to be loaded
  77544. * @param onSuccess is a callback called when the task is successfully executed
  77545. * @param onError is a callback called if an error occurs
  77546. */
  77547. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77548. /**
  77549. * Execute the current task
  77550. * @param scene defines the scene where you want your assets to be loaded
  77551. * @param onSuccess is a callback called when the task is successfully executed
  77552. * @param onError is a callback called if an error occurs
  77553. */
  77554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77555. /**
  77556. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77557. * This can be used with failed tasks that have the reason for failure fixed.
  77558. */
  77559. reset(): void;
  77560. private onErrorCallback;
  77561. private onDoneCallback;
  77562. }
  77563. /**
  77564. * Define the interface used by progress events raised during assets loading
  77565. */
  77566. export interface IAssetsProgressEvent {
  77567. /**
  77568. * Defines the number of remaining tasks to process
  77569. */
  77570. remainingCount: number;
  77571. /**
  77572. * Defines the total number of tasks
  77573. */
  77574. totalCount: number;
  77575. /**
  77576. * Defines the task that was just processed
  77577. */
  77578. task: AbstractAssetTask;
  77579. }
  77580. /**
  77581. * Class used to share progress information about assets loading
  77582. */
  77583. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77584. /**
  77585. * Defines the number of remaining tasks to process
  77586. */
  77587. remainingCount: number;
  77588. /**
  77589. * Defines the total number of tasks
  77590. */
  77591. totalCount: number;
  77592. /**
  77593. * Defines the task that was just processed
  77594. */
  77595. task: AbstractAssetTask;
  77596. /**
  77597. * Creates a AssetsProgressEvent
  77598. * @param remainingCount defines the number of remaining tasks to process
  77599. * @param totalCount defines the total number of tasks
  77600. * @param task defines the task that was just processed
  77601. */
  77602. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77603. }
  77604. /**
  77605. * Define a task used by AssetsManager to load assets into a container
  77606. */
  77607. export class ContainerAssetTask extends AbstractAssetTask {
  77608. /**
  77609. * Defines the name of the task
  77610. */
  77611. name: string;
  77612. /**
  77613. * Defines the list of mesh's names you want to load
  77614. */
  77615. meshesNames: any;
  77616. /**
  77617. * Defines the root url to use as a base to load your meshes and associated resources
  77618. */
  77619. rootUrl: string;
  77620. /**
  77621. * Defines the filename or File of the scene to load from
  77622. */
  77623. sceneFilename: string | File;
  77624. /**
  77625. * Get the loaded asset container
  77626. */
  77627. loadedContainer: AssetContainer;
  77628. /**
  77629. * Gets the list of loaded meshes
  77630. */
  77631. loadedMeshes: Array<AbstractMesh>;
  77632. /**
  77633. * Gets the list of loaded particle systems
  77634. */
  77635. loadedParticleSystems: Array<IParticleSystem>;
  77636. /**
  77637. * Gets the list of loaded skeletons
  77638. */
  77639. loadedSkeletons: Array<Skeleton>;
  77640. /**
  77641. * Gets the list of loaded animation groups
  77642. */
  77643. loadedAnimationGroups: Array<AnimationGroup>;
  77644. /**
  77645. * Callback called when the task is successful
  77646. */
  77647. onSuccess: (task: ContainerAssetTask) => void;
  77648. /**
  77649. * Callback called when the task is successful
  77650. */
  77651. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77652. /**
  77653. * Creates a new ContainerAssetTask
  77654. * @param name defines the name of the task
  77655. * @param meshesNames defines the list of mesh's names you want to load
  77656. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77657. * @param sceneFilename defines the filename or File of the scene to load from
  77658. */
  77659. constructor(
  77660. /**
  77661. * Defines the name of the task
  77662. */
  77663. name: string,
  77664. /**
  77665. * Defines the list of mesh's names you want to load
  77666. */
  77667. meshesNames: any,
  77668. /**
  77669. * Defines the root url to use as a base to load your meshes and associated resources
  77670. */
  77671. rootUrl: string,
  77672. /**
  77673. * Defines the filename or File of the scene to load from
  77674. */
  77675. sceneFilename: string | File);
  77676. /**
  77677. * Execute the current task
  77678. * @param scene defines the scene where you want your assets to be loaded
  77679. * @param onSuccess is a callback called when the task is successfully executed
  77680. * @param onError is a callback called if an error occurs
  77681. */
  77682. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77683. }
  77684. /**
  77685. * Define a task used by AssetsManager to load meshes
  77686. */
  77687. export class MeshAssetTask extends AbstractAssetTask {
  77688. /**
  77689. * Defines the name of the task
  77690. */
  77691. name: string;
  77692. /**
  77693. * Defines the list of mesh's names you want to load
  77694. */
  77695. meshesNames: any;
  77696. /**
  77697. * Defines the root url to use as a base to load your meshes and associated resources
  77698. */
  77699. rootUrl: string;
  77700. /**
  77701. * Defines the filename or File of the scene to load from
  77702. */
  77703. sceneFilename: string | File;
  77704. /**
  77705. * Gets the list of loaded meshes
  77706. */
  77707. loadedMeshes: Array<AbstractMesh>;
  77708. /**
  77709. * Gets the list of loaded particle systems
  77710. */
  77711. loadedParticleSystems: Array<IParticleSystem>;
  77712. /**
  77713. * Gets the list of loaded skeletons
  77714. */
  77715. loadedSkeletons: Array<Skeleton>;
  77716. /**
  77717. * Gets the list of loaded animation groups
  77718. */
  77719. loadedAnimationGroups: Array<AnimationGroup>;
  77720. /**
  77721. * Callback called when the task is successful
  77722. */
  77723. onSuccess: (task: MeshAssetTask) => void;
  77724. /**
  77725. * Callback called when the task is successful
  77726. */
  77727. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77728. /**
  77729. * Creates a new MeshAssetTask
  77730. * @param name defines the name of the task
  77731. * @param meshesNames defines the list of mesh's names you want to load
  77732. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77733. * @param sceneFilename defines the filename or File of the scene to load from
  77734. */
  77735. constructor(
  77736. /**
  77737. * Defines the name of the task
  77738. */
  77739. name: string,
  77740. /**
  77741. * Defines the list of mesh's names you want to load
  77742. */
  77743. meshesNames: any,
  77744. /**
  77745. * Defines the root url to use as a base to load your meshes and associated resources
  77746. */
  77747. rootUrl: string,
  77748. /**
  77749. * Defines the filename or File of the scene to load from
  77750. */
  77751. sceneFilename: string | File);
  77752. /**
  77753. * Execute the current task
  77754. * @param scene defines the scene where you want your assets to be loaded
  77755. * @param onSuccess is a callback called when the task is successfully executed
  77756. * @param onError is a callback called if an error occurs
  77757. */
  77758. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77759. }
  77760. /**
  77761. * Define a task used by AssetsManager to load text content
  77762. */
  77763. export class TextFileAssetTask extends AbstractAssetTask {
  77764. /**
  77765. * Defines the name of the task
  77766. */
  77767. name: string;
  77768. /**
  77769. * Defines the location of the file to load
  77770. */
  77771. url: string;
  77772. /**
  77773. * Gets the loaded text string
  77774. */
  77775. text: string;
  77776. /**
  77777. * Callback called when the task is successful
  77778. */
  77779. onSuccess: (task: TextFileAssetTask) => void;
  77780. /**
  77781. * Callback called when the task is successful
  77782. */
  77783. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77784. /**
  77785. * Creates a new TextFileAssetTask object
  77786. * @param name defines the name of the task
  77787. * @param url defines the location of the file to load
  77788. */
  77789. constructor(
  77790. /**
  77791. * Defines the name of the task
  77792. */
  77793. name: string,
  77794. /**
  77795. * Defines the location of the file to load
  77796. */
  77797. url: string);
  77798. /**
  77799. * Execute the current task
  77800. * @param scene defines the scene where you want your assets to be loaded
  77801. * @param onSuccess is a callback called when the task is successfully executed
  77802. * @param onError is a callback called if an error occurs
  77803. */
  77804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77805. }
  77806. /**
  77807. * Define a task used by AssetsManager to load binary data
  77808. */
  77809. export class BinaryFileAssetTask extends AbstractAssetTask {
  77810. /**
  77811. * Defines the name of the task
  77812. */
  77813. name: string;
  77814. /**
  77815. * Defines the location of the file to load
  77816. */
  77817. url: string;
  77818. /**
  77819. * Gets the lodaded data (as an array buffer)
  77820. */
  77821. data: ArrayBuffer;
  77822. /**
  77823. * Callback called when the task is successful
  77824. */
  77825. onSuccess: (task: BinaryFileAssetTask) => void;
  77826. /**
  77827. * Callback called when the task is successful
  77828. */
  77829. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77830. /**
  77831. * Creates a new BinaryFileAssetTask object
  77832. * @param name defines the name of the new task
  77833. * @param url defines the location of the file to load
  77834. */
  77835. constructor(
  77836. /**
  77837. * Defines the name of the task
  77838. */
  77839. name: string,
  77840. /**
  77841. * Defines the location of the file to load
  77842. */
  77843. url: string);
  77844. /**
  77845. * Execute the current task
  77846. * @param scene defines the scene where you want your assets to be loaded
  77847. * @param onSuccess is a callback called when the task is successfully executed
  77848. * @param onError is a callback called if an error occurs
  77849. */
  77850. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77851. }
  77852. /**
  77853. * Define a task used by AssetsManager to load images
  77854. */
  77855. export class ImageAssetTask extends AbstractAssetTask {
  77856. /**
  77857. * Defines the name of the task
  77858. */
  77859. name: string;
  77860. /**
  77861. * Defines the location of the image to load
  77862. */
  77863. url: string;
  77864. /**
  77865. * Gets the loaded images
  77866. */
  77867. image: HTMLImageElement;
  77868. /**
  77869. * Callback called when the task is successful
  77870. */
  77871. onSuccess: (task: ImageAssetTask) => void;
  77872. /**
  77873. * Callback called when the task is successful
  77874. */
  77875. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77876. /**
  77877. * Creates a new ImageAssetTask
  77878. * @param name defines the name of the task
  77879. * @param url defines the location of the image to load
  77880. */
  77881. constructor(
  77882. /**
  77883. * Defines the name of the task
  77884. */
  77885. name: string,
  77886. /**
  77887. * Defines the location of the image to load
  77888. */
  77889. url: string);
  77890. /**
  77891. * Execute the current task
  77892. * @param scene defines the scene where you want your assets to be loaded
  77893. * @param onSuccess is a callback called when the task is successfully executed
  77894. * @param onError is a callback called if an error occurs
  77895. */
  77896. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77897. }
  77898. /**
  77899. * Defines the interface used by texture loading tasks
  77900. */
  77901. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77902. /**
  77903. * Gets the loaded texture
  77904. */
  77905. texture: TEX;
  77906. }
  77907. /**
  77908. * Define a task used by AssetsManager to load 2D textures
  77909. */
  77910. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77911. /**
  77912. * Defines the name of the task
  77913. */
  77914. name: string;
  77915. /**
  77916. * Defines the location of the file to load
  77917. */
  77918. url: string;
  77919. /**
  77920. * Defines if mipmap should not be generated (default is false)
  77921. */
  77922. noMipmap?: boolean | undefined;
  77923. /**
  77924. * Defines if texture must be inverted on Y axis (default is true)
  77925. */
  77926. invertY: boolean;
  77927. /**
  77928. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77929. */
  77930. samplingMode: number;
  77931. /**
  77932. * Gets the loaded texture
  77933. */
  77934. texture: Texture;
  77935. /**
  77936. * Callback called when the task is successful
  77937. */
  77938. onSuccess: (task: TextureAssetTask) => void;
  77939. /**
  77940. * Callback called when the task is successful
  77941. */
  77942. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77943. /**
  77944. * Creates a new TextureAssetTask object
  77945. * @param name defines the name of the task
  77946. * @param url defines the location of the file to load
  77947. * @param noMipmap defines if mipmap should not be generated (default is false)
  77948. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77949. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77950. */
  77951. constructor(
  77952. /**
  77953. * Defines the name of the task
  77954. */
  77955. name: string,
  77956. /**
  77957. * Defines the location of the file to load
  77958. */
  77959. url: string,
  77960. /**
  77961. * Defines if mipmap should not be generated (default is false)
  77962. */
  77963. noMipmap?: boolean | undefined,
  77964. /**
  77965. * Defines if texture must be inverted on Y axis (default is true)
  77966. */
  77967. invertY?: boolean,
  77968. /**
  77969. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77970. */
  77971. samplingMode?: number);
  77972. /**
  77973. * Execute the current task
  77974. * @param scene defines the scene where you want your assets to be loaded
  77975. * @param onSuccess is a callback called when the task is successfully executed
  77976. * @param onError is a callback called if an error occurs
  77977. */
  77978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77979. }
  77980. /**
  77981. * Define a task used by AssetsManager to load cube textures
  77982. */
  77983. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77984. /**
  77985. * Defines the name of the task
  77986. */
  77987. name: string;
  77988. /**
  77989. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77990. */
  77991. url: string;
  77992. /**
  77993. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77994. */
  77995. extensions?: string[] | undefined;
  77996. /**
  77997. * Defines if mipmaps should not be generated (default is false)
  77998. */
  77999. noMipmap?: boolean | undefined;
  78000. /**
  78001. * Defines the explicit list of files (undefined by default)
  78002. */
  78003. files?: string[] | undefined;
  78004. /**
  78005. * Gets the loaded texture
  78006. */
  78007. texture: CubeTexture;
  78008. /**
  78009. * Callback called when the task is successful
  78010. */
  78011. onSuccess: (task: CubeTextureAssetTask) => void;
  78012. /**
  78013. * Callback called when the task is successful
  78014. */
  78015. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78016. /**
  78017. * Creates a new CubeTextureAssetTask
  78018. * @param name defines the name of the task
  78019. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78020. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78021. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78022. * @param files defines the explicit list of files (undefined by default)
  78023. */
  78024. constructor(
  78025. /**
  78026. * Defines the name of the task
  78027. */
  78028. name: string,
  78029. /**
  78030. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78031. */
  78032. url: string,
  78033. /**
  78034. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78035. */
  78036. extensions?: string[] | undefined,
  78037. /**
  78038. * Defines if mipmaps should not be generated (default is false)
  78039. */
  78040. noMipmap?: boolean | undefined,
  78041. /**
  78042. * Defines the explicit list of files (undefined by default)
  78043. */
  78044. files?: string[] | undefined);
  78045. /**
  78046. * Execute the current task
  78047. * @param scene defines the scene where you want your assets to be loaded
  78048. * @param onSuccess is a callback called when the task is successfully executed
  78049. * @param onError is a callback called if an error occurs
  78050. */
  78051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78052. }
  78053. /**
  78054. * Define a task used by AssetsManager to load HDR cube textures
  78055. */
  78056. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78057. /**
  78058. * Defines the name of the task
  78059. */
  78060. name: string;
  78061. /**
  78062. * Defines the location of the file to load
  78063. */
  78064. url: string;
  78065. /**
  78066. * Defines the desired size (the more it increases the longer the generation will be)
  78067. */
  78068. size: number;
  78069. /**
  78070. * Defines if mipmaps should not be generated (default is false)
  78071. */
  78072. noMipmap: boolean;
  78073. /**
  78074. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78075. */
  78076. generateHarmonics: boolean;
  78077. /**
  78078. * 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)
  78079. */
  78080. gammaSpace: boolean;
  78081. /**
  78082. * Internal Use Only
  78083. */
  78084. reserved: boolean;
  78085. /**
  78086. * Gets the loaded texture
  78087. */
  78088. texture: HDRCubeTexture;
  78089. /**
  78090. * Callback called when the task is successful
  78091. */
  78092. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78093. /**
  78094. * Callback called when the task is successful
  78095. */
  78096. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78097. /**
  78098. * Creates a new HDRCubeTextureAssetTask object
  78099. * @param name defines the name of the task
  78100. * @param url defines the location of the file to load
  78101. * @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.
  78102. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78103. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78104. * @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)
  78105. * @param reserved Internal use only
  78106. */
  78107. constructor(
  78108. /**
  78109. * Defines the name of the task
  78110. */
  78111. name: string,
  78112. /**
  78113. * Defines the location of the file to load
  78114. */
  78115. url: string,
  78116. /**
  78117. * Defines the desired size (the more it increases the longer the generation will be)
  78118. */
  78119. size: number,
  78120. /**
  78121. * Defines if mipmaps should not be generated (default is false)
  78122. */
  78123. noMipmap?: boolean,
  78124. /**
  78125. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78126. */
  78127. generateHarmonics?: boolean,
  78128. /**
  78129. * 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)
  78130. */
  78131. gammaSpace?: boolean,
  78132. /**
  78133. * Internal Use Only
  78134. */
  78135. reserved?: boolean);
  78136. /**
  78137. * Execute the current task
  78138. * @param scene defines the scene where you want your assets to be loaded
  78139. * @param onSuccess is a callback called when the task is successfully executed
  78140. * @param onError is a callback called if an error occurs
  78141. */
  78142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78143. }
  78144. /**
  78145. * Define a task used by AssetsManager to load Equirectangular cube textures
  78146. */
  78147. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78148. /**
  78149. * Defines the name of the task
  78150. */
  78151. name: string;
  78152. /**
  78153. * Defines the location of the file to load
  78154. */
  78155. url: string;
  78156. /**
  78157. * Defines the desired size (the more it increases the longer the generation will be)
  78158. */
  78159. size: number;
  78160. /**
  78161. * Defines if mipmaps should not be generated (default is false)
  78162. */
  78163. noMipmap: boolean;
  78164. /**
  78165. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78166. * but the standard material would require them in Gamma space) (default is true)
  78167. */
  78168. gammaSpace: boolean;
  78169. /**
  78170. * Gets the loaded texture
  78171. */
  78172. texture: EquiRectangularCubeTexture;
  78173. /**
  78174. * Callback called when the task is successful
  78175. */
  78176. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78177. /**
  78178. * Callback called when the task is successful
  78179. */
  78180. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78181. /**
  78182. * Creates a new EquiRectangularCubeTextureAssetTask object
  78183. * @param name defines the name of the task
  78184. * @param url defines the location of the file to load
  78185. * @param size defines the desired size (the more it increases the longer the generation will be)
  78186. * If the size is omitted this implies you are using a preprocessed cubemap.
  78187. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78188. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78189. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78190. * (default is true)
  78191. */
  78192. constructor(
  78193. /**
  78194. * Defines the name of the task
  78195. */
  78196. name: string,
  78197. /**
  78198. * Defines the location of the file to load
  78199. */
  78200. url: string,
  78201. /**
  78202. * Defines the desired size (the more it increases the longer the generation will be)
  78203. */
  78204. size: number,
  78205. /**
  78206. * Defines if mipmaps should not be generated (default is false)
  78207. */
  78208. noMipmap?: boolean,
  78209. /**
  78210. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78211. * but the standard material would require them in Gamma space) (default is true)
  78212. */
  78213. gammaSpace?: boolean);
  78214. /**
  78215. * Execute the current task
  78216. * @param scene defines the scene where you want your assets to be loaded
  78217. * @param onSuccess is a callback called when the task is successfully executed
  78218. * @param onError is a callback called if an error occurs
  78219. */
  78220. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78221. }
  78222. /**
  78223. * This class can be used to easily import assets into a scene
  78224. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78225. */
  78226. export class AssetsManager {
  78227. private _scene;
  78228. private _isLoading;
  78229. protected _tasks: AbstractAssetTask[];
  78230. protected _waitingTasksCount: number;
  78231. protected _totalTasksCount: number;
  78232. /**
  78233. * Callback called when all tasks are processed
  78234. */
  78235. onFinish: (tasks: AbstractAssetTask[]) => void;
  78236. /**
  78237. * Callback called when a task is successful
  78238. */
  78239. onTaskSuccess: (task: AbstractAssetTask) => void;
  78240. /**
  78241. * Callback called when a task had an error
  78242. */
  78243. onTaskError: (task: AbstractAssetTask) => void;
  78244. /**
  78245. * Callback called when a task is done (whatever the result is)
  78246. */
  78247. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78248. /**
  78249. * Observable called when all tasks are processed
  78250. */
  78251. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78252. /**
  78253. * Observable called when a task had an error
  78254. */
  78255. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78256. /**
  78257. * Observable called when all tasks were executed
  78258. */
  78259. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78260. /**
  78261. * Observable called when a task is done (whatever the result is)
  78262. */
  78263. onProgressObservable: Observable<IAssetsProgressEvent>;
  78264. /**
  78265. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78266. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78267. */
  78268. useDefaultLoadingScreen: boolean;
  78269. /**
  78270. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78271. * when all assets have been downloaded.
  78272. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78273. */
  78274. autoHideLoadingUI: boolean;
  78275. /**
  78276. * Creates a new AssetsManager
  78277. * @param scene defines the scene to work on
  78278. */
  78279. constructor(scene: Scene);
  78280. /**
  78281. * Add a ContainerAssetTask to the list of active tasks
  78282. * @param taskName defines the name of the new task
  78283. * @param meshesNames defines the name of meshes to load
  78284. * @param rootUrl defines the root url to use to locate files
  78285. * @param sceneFilename defines the filename of the scene file
  78286. * @returns a new ContainerAssetTask object
  78287. */
  78288. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78289. /**
  78290. * Add a MeshAssetTask to the list of active tasks
  78291. * @param taskName defines the name of the new task
  78292. * @param meshesNames defines the name of meshes to load
  78293. * @param rootUrl defines the root url to use to locate files
  78294. * @param sceneFilename defines the filename of the scene file
  78295. * @returns a new MeshAssetTask object
  78296. */
  78297. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78298. /**
  78299. * Add a TextFileAssetTask to the list of active tasks
  78300. * @param taskName defines the name of the new task
  78301. * @param url defines the url of the file to load
  78302. * @returns a new TextFileAssetTask object
  78303. */
  78304. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78305. /**
  78306. * Add a BinaryFileAssetTask to the list of active tasks
  78307. * @param taskName defines the name of the new task
  78308. * @param url defines the url of the file to load
  78309. * @returns a new BinaryFileAssetTask object
  78310. */
  78311. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78312. /**
  78313. * Add a ImageAssetTask to the list of active tasks
  78314. * @param taskName defines the name of the new task
  78315. * @param url defines the url of the file to load
  78316. * @returns a new ImageAssetTask object
  78317. */
  78318. addImageTask(taskName: string, url: string): ImageAssetTask;
  78319. /**
  78320. * Add a TextureAssetTask to the list of active tasks
  78321. * @param taskName defines the name of the new task
  78322. * @param url defines the url of the file to load
  78323. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78324. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78325. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78326. * @returns a new TextureAssetTask object
  78327. */
  78328. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78329. /**
  78330. * Add a CubeTextureAssetTask to the list of active tasks
  78331. * @param taskName defines the name of the new task
  78332. * @param url defines the url of the file to load
  78333. * @param extensions defines the extension to use to load the cube map (can be null)
  78334. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78335. * @param files defines the list of files to load (can be null)
  78336. * @returns a new CubeTextureAssetTask object
  78337. */
  78338. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78339. /**
  78340. *
  78341. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78342. * @param taskName defines the name of the new task
  78343. * @param url defines the url of the file to load
  78344. * @param size defines the size you want for the cubemap (can be null)
  78345. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78346. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78347. * @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)
  78348. * @param reserved Internal use only
  78349. * @returns a new HDRCubeTextureAssetTask object
  78350. */
  78351. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78352. /**
  78353. *
  78354. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78355. * @param taskName defines the name of the new task
  78356. * @param url defines the url of the file to load
  78357. * @param size defines the size you want for the cubemap (can be null)
  78358. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78359. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78360. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78361. * @returns a new EquiRectangularCubeTextureAssetTask object
  78362. */
  78363. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78364. /**
  78365. * Remove a task from the assets manager.
  78366. * @param task the task to remove
  78367. */
  78368. removeTask(task: AbstractAssetTask): void;
  78369. private _decreaseWaitingTasksCount;
  78370. private _runTask;
  78371. /**
  78372. * Reset the AssetsManager and remove all tasks
  78373. * @return the current instance of the AssetsManager
  78374. */
  78375. reset(): AssetsManager;
  78376. /**
  78377. * Start the loading process
  78378. * @return the current instance of the AssetsManager
  78379. */
  78380. load(): AssetsManager;
  78381. /**
  78382. * Start the loading process as an async operation
  78383. * @return a promise returning the list of failed tasks
  78384. */
  78385. loadAsync(): Promise<void>;
  78386. }
  78387. }
  78388. declare module BABYLON {
  78389. /**
  78390. * Wrapper class for promise with external resolve and reject.
  78391. */
  78392. export class Deferred<T> {
  78393. /**
  78394. * The promise associated with this deferred object.
  78395. */
  78396. readonly promise: Promise<T>;
  78397. private _resolve;
  78398. private _reject;
  78399. /**
  78400. * The resolve method of the promise associated with this deferred object.
  78401. */
  78402. get resolve(): (value: T | PromiseLike<T>) => void;
  78403. /**
  78404. * The reject method of the promise associated with this deferred object.
  78405. */
  78406. get reject(): (reason?: any) => void;
  78407. /**
  78408. * Constructor for this deferred object.
  78409. */
  78410. constructor();
  78411. }
  78412. }
  78413. declare module BABYLON {
  78414. /**
  78415. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78416. */
  78417. export class MeshExploder {
  78418. private _centerMesh;
  78419. private _meshes;
  78420. private _meshesOrigins;
  78421. private _toCenterVectors;
  78422. private _scaledDirection;
  78423. private _newPosition;
  78424. private _centerPosition;
  78425. /**
  78426. * Explodes meshes from a center mesh.
  78427. * @param meshes The meshes to explode.
  78428. * @param centerMesh The mesh to be center of explosion.
  78429. */
  78430. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78431. private _setCenterMesh;
  78432. /**
  78433. * Get class name
  78434. * @returns "MeshExploder"
  78435. */
  78436. getClassName(): string;
  78437. /**
  78438. * "Exploded meshes"
  78439. * @returns Array of meshes with the centerMesh at index 0.
  78440. */
  78441. getMeshes(): Array<Mesh>;
  78442. /**
  78443. * Explodes meshes giving a specific direction
  78444. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78445. */
  78446. explode(direction?: number): void;
  78447. }
  78448. }
  78449. declare module BABYLON {
  78450. /**
  78451. * Class used to help managing file picking and drag'n'drop
  78452. */
  78453. export class FilesInput {
  78454. /**
  78455. * List of files ready to be loaded
  78456. */
  78457. static get FilesToLoad(): {
  78458. [key: string]: File;
  78459. };
  78460. /**
  78461. * Callback called when a file is processed
  78462. */
  78463. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78464. /**
  78465. * Function used when loading the scene file
  78466. */
  78467. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78468. private _engine;
  78469. private _currentScene;
  78470. private _sceneLoadedCallback;
  78471. private _progressCallback;
  78472. private _additionalRenderLoopLogicCallback;
  78473. private _textureLoadingCallback;
  78474. private _startingProcessingFilesCallback;
  78475. private _onReloadCallback;
  78476. private _errorCallback;
  78477. private _elementToMonitor;
  78478. private _sceneFileToLoad;
  78479. private _filesToLoad;
  78480. /**
  78481. * Creates a new FilesInput
  78482. * @param engine defines the rendering engine
  78483. * @param scene defines the hosting scene
  78484. * @param sceneLoadedCallback callback called when scene is loaded
  78485. * @param progressCallback callback called to track progress
  78486. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78487. * @param textureLoadingCallback callback called when a texture is loading
  78488. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78489. * @param onReloadCallback callback called when a reload is requested
  78490. * @param errorCallback callback call if an error occurs
  78491. */
  78492. 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>);
  78493. private _dragEnterHandler;
  78494. private _dragOverHandler;
  78495. private _dropHandler;
  78496. /**
  78497. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78498. * @param elementToMonitor defines the DOM element to track
  78499. */
  78500. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78501. /** Gets the current list of files to load */
  78502. get filesToLoad(): File[];
  78503. /**
  78504. * Release all associated resources
  78505. */
  78506. dispose(): void;
  78507. private renderFunction;
  78508. private drag;
  78509. private drop;
  78510. private _traverseFolder;
  78511. private _processFiles;
  78512. /**
  78513. * Load files from a drop event
  78514. * @param event defines the drop event to use as source
  78515. */
  78516. loadFiles(event: any): void;
  78517. private _processReload;
  78518. /**
  78519. * Reload the current scene from the loaded files
  78520. */
  78521. reload(): void;
  78522. }
  78523. }
  78524. declare module BABYLON {
  78525. /**
  78526. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78527. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78528. */
  78529. export class SceneOptimization {
  78530. /**
  78531. * Defines the priority of this optimization (0 by default which means first in the list)
  78532. */
  78533. priority: number;
  78534. /**
  78535. * Gets a string describing the action executed by the current optimization
  78536. * @returns description string
  78537. */
  78538. getDescription(): string;
  78539. /**
  78540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78541. * @param scene defines the current scene where to apply this optimization
  78542. * @param optimizer defines the current optimizer
  78543. * @returns true if everything that can be done was applied
  78544. */
  78545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78546. /**
  78547. * Creates the SceneOptimization object
  78548. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78549. * @param desc defines the description associated with the optimization
  78550. */
  78551. constructor(
  78552. /**
  78553. * Defines the priority of this optimization (0 by default which means first in the list)
  78554. */
  78555. priority?: number);
  78556. }
  78557. /**
  78558. * Defines an optimization used to reduce the size of render target textures
  78559. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78560. */
  78561. export class TextureOptimization extends SceneOptimization {
  78562. /**
  78563. * Defines the priority of this optimization (0 by default which means first in the list)
  78564. */
  78565. priority: number;
  78566. /**
  78567. * 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
  78568. */
  78569. maximumSize: number;
  78570. /**
  78571. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78572. */
  78573. step: number;
  78574. /**
  78575. * Gets a string describing the action executed by the current optimization
  78576. * @returns description string
  78577. */
  78578. getDescription(): string;
  78579. /**
  78580. * Creates the TextureOptimization object
  78581. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78582. * @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
  78583. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78584. */
  78585. constructor(
  78586. /**
  78587. * Defines the priority of this optimization (0 by default which means first in the list)
  78588. */
  78589. priority?: number,
  78590. /**
  78591. * 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
  78592. */
  78593. maximumSize?: number,
  78594. /**
  78595. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78596. */
  78597. step?: number);
  78598. /**
  78599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78600. * @param scene defines the current scene where to apply this optimization
  78601. * @param optimizer defines the current optimizer
  78602. * @returns true if everything that can be done was applied
  78603. */
  78604. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78605. }
  78606. /**
  78607. * Defines an optimization used to increase or decrease the rendering resolution
  78608. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78609. */
  78610. export class HardwareScalingOptimization extends SceneOptimization {
  78611. /**
  78612. * Defines the priority of this optimization (0 by default which means first in the list)
  78613. */
  78614. priority: number;
  78615. /**
  78616. * Defines the maximum scale to use (2 by default)
  78617. */
  78618. maximumScale: number;
  78619. /**
  78620. * Defines the step to use between two passes (0.5 by default)
  78621. */
  78622. step: number;
  78623. private _currentScale;
  78624. private _directionOffset;
  78625. /**
  78626. * Gets a string describing the action executed by the current optimization
  78627. * @return description string
  78628. */
  78629. getDescription(): string;
  78630. /**
  78631. * Creates the HardwareScalingOptimization object
  78632. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78633. * @param maximumScale defines the maximum scale to use (2 by default)
  78634. * @param step defines the step to use between two passes (0.5 by default)
  78635. */
  78636. constructor(
  78637. /**
  78638. * Defines the priority of this optimization (0 by default which means first in the list)
  78639. */
  78640. priority?: number,
  78641. /**
  78642. * Defines the maximum scale to use (2 by default)
  78643. */
  78644. maximumScale?: number,
  78645. /**
  78646. * Defines the step to use between two passes (0.5 by default)
  78647. */
  78648. step?: number);
  78649. /**
  78650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78651. * @param scene defines the current scene where to apply this optimization
  78652. * @param optimizer defines the current optimizer
  78653. * @returns true if everything that can be done was applied
  78654. */
  78655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78656. }
  78657. /**
  78658. * Defines an optimization used to remove shadows
  78659. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78660. */
  78661. export class ShadowsOptimization extends SceneOptimization {
  78662. /**
  78663. * Gets a string describing the action executed by the current optimization
  78664. * @return description string
  78665. */
  78666. getDescription(): string;
  78667. /**
  78668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78669. * @param scene defines the current scene where to apply this optimization
  78670. * @param optimizer defines the current optimizer
  78671. * @returns true if everything that can be done was applied
  78672. */
  78673. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78674. }
  78675. /**
  78676. * Defines an optimization used to turn post-processes off
  78677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78678. */
  78679. export class PostProcessesOptimization extends SceneOptimization {
  78680. /**
  78681. * Gets a string describing the action executed by the current optimization
  78682. * @return description string
  78683. */
  78684. getDescription(): string;
  78685. /**
  78686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78687. * @param scene defines the current scene where to apply this optimization
  78688. * @param optimizer defines the current optimizer
  78689. * @returns true if everything that can be done was applied
  78690. */
  78691. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78692. }
  78693. /**
  78694. * Defines an optimization used to turn lens flares off
  78695. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78696. */
  78697. export class LensFlaresOptimization extends SceneOptimization {
  78698. /**
  78699. * Gets a string describing the action executed by the current optimization
  78700. * @return description string
  78701. */
  78702. getDescription(): string;
  78703. /**
  78704. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78705. * @param scene defines the current scene where to apply this optimization
  78706. * @param optimizer defines the current optimizer
  78707. * @returns true if everything that can be done was applied
  78708. */
  78709. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78710. }
  78711. /**
  78712. * Defines an optimization based on user defined callback.
  78713. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78714. */
  78715. export class CustomOptimization extends SceneOptimization {
  78716. /**
  78717. * Callback called to apply the custom optimization.
  78718. */
  78719. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78720. /**
  78721. * Callback called to get custom description
  78722. */
  78723. onGetDescription: () => string;
  78724. /**
  78725. * Gets a string describing the action executed by the current optimization
  78726. * @returns description string
  78727. */
  78728. getDescription(): string;
  78729. /**
  78730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78731. * @param scene defines the current scene where to apply this optimization
  78732. * @param optimizer defines the current optimizer
  78733. * @returns true if everything that can be done was applied
  78734. */
  78735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78736. }
  78737. /**
  78738. * Defines an optimization used to turn particles off
  78739. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78740. */
  78741. export class ParticlesOptimization extends SceneOptimization {
  78742. /**
  78743. * Gets a string describing the action executed by the current optimization
  78744. * @return description string
  78745. */
  78746. getDescription(): string;
  78747. /**
  78748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78749. * @param scene defines the current scene where to apply this optimization
  78750. * @param optimizer defines the current optimizer
  78751. * @returns true if everything that can be done was applied
  78752. */
  78753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78754. }
  78755. /**
  78756. * Defines an optimization used to turn render targets off
  78757. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78758. */
  78759. export class RenderTargetsOptimization extends SceneOptimization {
  78760. /**
  78761. * Gets a string describing the action executed by the current optimization
  78762. * @return description string
  78763. */
  78764. getDescription(): string;
  78765. /**
  78766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78767. * @param scene defines the current scene where to apply this optimization
  78768. * @param optimizer defines the current optimizer
  78769. * @returns true if everything that can be done was applied
  78770. */
  78771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78772. }
  78773. /**
  78774. * Defines an optimization used to merge meshes with compatible materials
  78775. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78776. */
  78777. export class MergeMeshesOptimization extends SceneOptimization {
  78778. private static _UpdateSelectionTree;
  78779. /**
  78780. * Gets or sets a boolean which defines if optimization octree has to be updated
  78781. */
  78782. static get UpdateSelectionTree(): boolean;
  78783. /**
  78784. * Gets or sets a boolean which defines if optimization octree has to be updated
  78785. */
  78786. static set UpdateSelectionTree(value: boolean);
  78787. /**
  78788. * Gets a string describing the action executed by the current optimization
  78789. * @return description string
  78790. */
  78791. getDescription(): string;
  78792. private _canBeMerged;
  78793. /**
  78794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78795. * @param scene defines the current scene where to apply this optimization
  78796. * @param optimizer defines the current optimizer
  78797. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78798. * @returns true if everything that can be done was applied
  78799. */
  78800. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78801. }
  78802. /**
  78803. * Defines a list of options used by SceneOptimizer
  78804. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78805. */
  78806. export class SceneOptimizerOptions {
  78807. /**
  78808. * Defines the target frame rate to reach (60 by default)
  78809. */
  78810. targetFrameRate: number;
  78811. /**
  78812. * Defines the interval between two checks (2000ms by default)
  78813. */
  78814. trackerDuration: number;
  78815. /**
  78816. * Gets the list of optimizations to apply
  78817. */
  78818. optimizations: SceneOptimization[];
  78819. /**
  78820. * Creates a new list of options used by SceneOptimizer
  78821. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78822. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78823. */
  78824. constructor(
  78825. /**
  78826. * Defines the target frame rate to reach (60 by default)
  78827. */
  78828. targetFrameRate?: number,
  78829. /**
  78830. * Defines the interval between two checks (2000ms by default)
  78831. */
  78832. trackerDuration?: number);
  78833. /**
  78834. * Add a new optimization
  78835. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78836. * @returns the current SceneOptimizerOptions
  78837. */
  78838. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78839. /**
  78840. * Add a new custom optimization
  78841. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78842. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78843. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78844. * @returns the current SceneOptimizerOptions
  78845. */
  78846. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78847. /**
  78848. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78849. * @param targetFrameRate defines the target frame rate (60 by default)
  78850. * @returns a SceneOptimizerOptions object
  78851. */
  78852. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78853. /**
  78854. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78855. * @param targetFrameRate defines the target frame rate (60 by default)
  78856. * @returns a SceneOptimizerOptions object
  78857. */
  78858. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78859. /**
  78860. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78861. * @param targetFrameRate defines the target frame rate (60 by default)
  78862. * @returns a SceneOptimizerOptions object
  78863. */
  78864. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78865. }
  78866. /**
  78867. * Class used to run optimizations in order to reach a target frame rate
  78868. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78869. */
  78870. export class SceneOptimizer implements IDisposable {
  78871. private _isRunning;
  78872. private _options;
  78873. private _scene;
  78874. private _currentPriorityLevel;
  78875. private _targetFrameRate;
  78876. private _trackerDuration;
  78877. private _currentFrameRate;
  78878. private _sceneDisposeObserver;
  78879. private _improvementMode;
  78880. /**
  78881. * Defines an observable called when the optimizer reaches the target frame rate
  78882. */
  78883. onSuccessObservable: Observable<SceneOptimizer>;
  78884. /**
  78885. * Defines an observable called when the optimizer enables an optimization
  78886. */
  78887. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78888. /**
  78889. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78890. */
  78891. onFailureObservable: Observable<SceneOptimizer>;
  78892. /**
  78893. * Gets a boolean indicating if the optimizer is in improvement mode
  78894. */
  78895. get isInImprovementMode(): boolean;
  78896. /**
  78897. * Gets the current priority level (0 at start)
  78898. */
  78899. get currentPriorityLevel(): number;
  78900. /**
  78901. * Gets the current frame rate checked by the SceneOptimizer
  78902. */
  78903. get currentFrameRate(): number;
  78904. /**
  78905. * Gets or sets the current target frame rate (60 by default)
  78906. */
  78907. get targetFrameRate(): number;
  78908. /**
  78909. * Gets or sets the current target frame rate (60 by default)
  78910. */
  78911. set targetFrameRate(value: number);
  78912. /**
  78913. * Gets or sets the current interval between two checks (every 2000ms by default)
  78914. */
  78915. get trackerDuration(): number;
  78916. /**
  78917. * Gets or sets the current interval between two checks (every 2000ms by default)
  78918. */
  78919. set trackerDuration(value: number);
  78920. /**
  78921. * Gets the list of active optimizations
  78922. */
  78923. get optimizations(): SceneOptimization[];
  78924. /**
  78925. * Creates a new SceneOptimizer
  78926. * @param scene defines the scene to work on
  78927. * @param options defines the options to use with the SceneOptimizer
  78928. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78929. * @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)
  78930. */
  78931. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78932. /**
  78933. * Stops the current optimizer
  78934. */
  78935. stop(): void;
  78936. /**
  78937. * Reset the optimizer to initial step (current priority level = 0)
  78938. */
  78939. reset(): void;
  78940. /**
  78941. * Start the optimizer. By default it will try to reach a specific framerate
  78942. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78943. */
  78944. start(): void;
  78945. private _checkCurrentState;
  78946. /**
  78947. * Release all resources
  78948. */
  78949. dispose(): void;
  78950. /**
  78951. * Helper function to create a SceneOptimizer with one single line of code
  78952. * @param scene defines the scene to work on
  78953. * @param options defines the options to use with the SceneOptimizer
  78954. * @param onSuccess defines a callback to call on success
  78955. * @param onFailure defines a callback to call on failure
  78956. * @returns the new SceneOptimizer object
  78957. */
  78958. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78959. }
  78960. }
  78961. declare module BABYLON {
  78962. /**
  78963. * Class used to serialize a scene into a string
  78964. */
  78965. export class SceneSerializer {
  78966. /**
  78967. * Clear cache used by a previous serialization
  78968. */
  78969. static ClearCache(): void;
  78970. /**
  78971. * Serialize a scene into a JSON compatible object
  78972. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78973. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78974. * @param scene defines the scene to serialize
  78975. * @returns a JSON compatible object
  78976. */
  78977. static Serialize(scene: Scene): any;
  78978. private static _Serialize;
  78979. /**
  78980. * Serialize a scene into a JSON compatible object
  78981. * @param scene defines the scene to serialize
  78982. * @returns a JSON promise compatible object
  78983. */
  78984. static SerializeAsync(scene: Scene): Promise<any>;
  78985. private static _CollectPromises;
  78986. /**
  78987. * Serialize a mesh into a JSON compatible object
  78988. * @param toSerialize defines the mesh to serialize
  78989. * @param withParents defines if parents must be serialized as well
  78990. * @param withChildren defines if children must be serialized as well
  78991. * @returns a JSON compatible object
  78992. */
  78993. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78994. }
  78995. }
  78996. declare module BABYLON {
  78997. /**
  78998. * This represents the different options available for the video capture.
  78999. */
  79000. export interface VideoRecorderOptions {
  79001. /** Defines the mime type of the video. */
  79002. mimeType: string;
  79003. /** Defines the FPS the video should be recorded at. */
  79004. fps: number;
  79005. /** Defines the chunk size for the recording data. */
  79006. recordChunckSize: number;
  79007. /** The audio tracks to attach to the recording. */
  79008. audioTracks?: MediaStreamTrack[];
  79009. }
  79010. /**
  79011. * This can help with recording videos from BabylonJS.
  79012. * This is based on the available WebRTC functionalities of the browser.
  79013. *
  79014. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79015. */
  79016. export class VideoRecorder {
  79017. private static readonly _defaultOptions;
  79018. /**
  79019. * Returns whether or not the VideoRecorder is available in your browser.
  79020. * @param engine Defines the Babylon Engine.
  79021. * @returns true if supported otherwise false.
  79022. */
  79023. static IsSupported(engine: Engine): boolean;
  79024. private readonly _options;
  79025. private _canvas;
  79026. private _mediaRecorder;
  79027. private _recordedChunks;
  79028. private _fileName;
  79029. private _resolve;
  79030. private _reject;
  79031. /**
  79032. * True when a recording is already in progress.
  79033. */
  79034. get isRecording(): boolean;
  79035. /**
  79036. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79037. * @param engine Defines the BabylonJS Engine you wish to record.
  79038. * @param options Defines options that can be used to customize the capture.
  79039. */
  79040. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79041. /**
  79042. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79043. */
  79044. stopRecording(): void;
  79045. /**
  79046. * Starts recording the canvas for a max duration specified in parameters.
  79047. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79048. * If null no automatic download will start and you can rely on the promise to get the data back.
  79049. * @param maxDuration Defines the maximum recording time in seconds.
  79050. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79051. * @return A promise callback at the end of the recording with the video data in Blob.
  79052. */
  79053. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79054. /**
  79055. * Releases internal resources used during the recording.
  79056. */
  79057. dispose(): void;
  79058. private _handleDataAvailable;
  79059. private _handleError;
  79060. private _handleStop;
  79061. }
  79062. }
  79063. declare module BABYLON {
  79064. /**
  79065. * Class containing a set of static utilities functions for screenshots
  79066. */
  79067. export class ScreenshotTools {
  79068. /**
  79069. * Captures a screenshot of the current rendering
  79070. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79071. * @param engine defines the rendering engine
  79072. * @param camera defines the source camera
  79073. * @param size This parameter can be set to a single number or to an object with the
  79074. * following (optional) properties: precision, width, height. If a single number is passed,
  79075. * it will be used for both width and height. If an object is passed, the screenshot size
  79076. * will be derived from the parameters. The precision property is a multiplier allowing
  79077. * rendering at a higher or lower resolution
  79078. * @param successCallback defines the callback receives a single parameter which contains the
  79079. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79080. * src parameter of an <img> to display it
  79081. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79082. * Check your browser for supported MIME types
  79083. * @param forceDownload force the system to download the image even if a successCallback is provided
  79084. */
  79085. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79086. /**
  79087. * Captures a screenshot of the current rendering
  79088. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79089. * @param engine defines the rendering engine
  79090. * @param camera defines the source camera
  79091. * @param size This parameter can be set to a single number or to an object with the
  79092. * following (optional) properties: precision, width, height. If a single number is passed,
  79093. * it will be used for both width and height. If an object is passed, the screenshot size
  79094. * will be derived from the parameters. The precision property is a multiplier allowing
  79095. * rendering at a higher or lower resolution
  79096. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79097. * Check your browser for supported MIME types
  79098. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79099. * to the src parameter of an <img> to display it
  79100. */
  79101. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79102. /**
  79103. * 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)
  79104. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79105. * @param engine defines the rendering engine
  79106. * @param camera defines the source camera
  79107. * @param width defines the expected width
  79108. * @param height defines the expected height
  79109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79110. * Check your browser for supported MIME types
  79111. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79112. * to the src parameter of an <img> to display it
  79113. */
  79114. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79115. /**
  79116. * Generates an image screenshot from the specified camera.
  79117. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79118. * @param engine The engine to use for rendering
  79119. * @param camera The camera to use for rendering
  79120. * @param size This parameter can be set to a single number or to an object with the
  79121. * following (optional) properties: precision, width, height. If a single number is passed,
  79122. * it will be used for both width and height. If an object is passed, the screenshot size
  79123. * will be derived from the parameters. The precision property is a multiplier allowing
  79124. * rendering at a higher or lower resolution
  79125. * @param successCallback The callback receives a single parameter which contains the
  79126. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79127. * src parameter of an <img> to display it
  79128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79129. * Check your browser for supported MIME types
  79130. * @param samples Texture samples (default: 1)
  79131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79132. * @param fileName A name for for the downloaded file.
  79133. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79134. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79135. */
  79136. 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;
  79137. /**
  79138. * Generates an image screenshot from the specified camera.
  79139. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79140. * @param engine The engine to use for rendering
  79141. * @param camera The camera to use for rendering
  79142. * @param size This parameter can be set to a single number or to an object with the
  79143. * following (optional) properties: precision, width, height. If a single number is passed,
  79144. * it will be used for both width and height. If an object is passed, the screenshot size
  79145. * will be derived from the parameters. The precision property is a multiplier allowing
  79146. * rendering at a higher or lower resolution
  79147. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79148. * Check your browser for supported MIME types
  79149. * @param samples Texture samples (default: 1)
  79150. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79151. * @param fileName A name for for the downloaded file.
  79152. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79153. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79154. * to the src parameter of an <img> to display it
  79155. */
  79156. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79157. /**
  79158. * Gets height and width for screenshot size
  79159. * @private
  79160. */
  79161. private static _getScreenshotSize;
  79162. }
  79163. }
  79164. declare module BABYLON {
  79165. /**
  79166. * Interface for a data buffer
  79167. */
  79168. export interface IDataBuffer {
  79169. /**
  79170. * Reads bytes from the data buffer.
  79171. * @param byteOffset The byte offset to read
  79172. * @param byteLength The byte length to read
  79173. * @returns A promise that resolves when the bytes are read
  79174. */
  79175. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79176. /**
  79177. * The byte length of the buffer.
  79178. */
  79179. readonly byteLength: number;
  79180. }
  79181. /**
  79182. * Utility class for reading from a data buffer
  79183. */
  79184. export class DataReader {
  79185. /**
  79186. * The data buffer associated with this data reader.
  79187. */
  79188. readonly buffer: IDataBuffer;
  79189. /**
  79190. * The current byte offset from the beginning of the data buffer.
  79191. */
  79192. byteOffset: number;
  79193. private _dataView;
  79194. private _dataByteOffset;
  79195. /**
  79196. * Constructor
  79197. * @param buffer The buffer to read
  79198. */
  79199. constructor(buffer: IDataBuffer);
  79200. /**
  79201. * Loads the given byte length.
  79202. * @param byteLength The byte length to load
  79203. * @returns A promise that resolves when the load is complete
  79204. */
  79205. loadAsync(byteLength: number): Promise<void>;
  79206. /**
  79207. * Read a unsigned 32-bit integer from the currently loaded data range.
  79208. * @returns The 32-bit integer read
  79209. */
  79210. readUint32(): number;
  79211. /**
  79212. * Read a byte array from the currently loaded data range.
  79213. * @param byteLength The byte length to read
  79214. * @returns The byte array read
  79215. */
  79216. readUint8Array(byteLength: number): Uint8Array;
  79217. /**
  79218. * Read a string from the currently loaded data range.
  79219. * @param byteLength The byte length to read
  79220. * @returns The string read
  79221. */
  79222. readString(byteLength: number): string;
  79223. /**
  79224. * Skips the given byte length the currently loaded data range.
  79225. * @param byteLength The byte length to skip
  79226. */
  79227. skipBytes(byteLength: number): void;
  79228. }
  79229. }
  79230. declare module BABYLON {
  79231. /**
  79232. * Class for storing data to local storage if available or in-memory storage otherwise
  79233. */
  79234. export class DataStorage {
  79235. private static _Storage;
  79236. private static _GetStorage;
  79237. /**
  79238. * Reads a string from the data storage
  79239. * @param key The key to read
  79240. * @param defaultValue The value if the key doesn't exist
  79241. * @returns The string value
  79242. */
  79243. static ReadString(key: string, defaultValue: string): string;
  79244. /**
  79245. * Writes a string to the data storage
  79246. * @param key The key to write
  79247. * @param value The value to write
  79248. */
  79249. static WriteString(key: string, value: string): void;
  79250. /**
  79251. * Reads a boolean from the data storage
  79252. * @param key The key to read
  79253. * @param defaultValue The value if the key doesn't exist
  79254. * @returns The boolean value
  79255. */
  79256. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79257. /**
  79258. * Writes a boolean to the data storage
  79259. * @param key The key to write
  79260. * @param value The value to write
  79261. */
  79262. static WriteBoolean(key: string, value: boolean): void;
  79263. /**
  79264. * Reads a number from the data storage
  79265. * @param key The key to read
  79266. * @param defaultValue The value if the key doesn't exist
  79267. * @returns The number value
  79268. */
  79269. static ReadNumber(key: string, defaultValue: number): number;
  79270. /**
  79271. * Writes a number to the data storage
  79272. * @param key The key to write
  79273. * @param value The value to write
  79274. */
  79275. static WriteNumber(key: string, value: number): void;
  79276. }
  79277. }
  79278. declare module BABYLON {
  79279. /**
  79280. * Class used to record delta files between 2 scene states
  79281. */
  79282. export class SceneRecorder {
  79283. private _trackedScene;
  79284. private _savedJSON;
  79285. /**
  79286. * Track a given scene. This means the current scene state will be considered the original state
  79287. * @param scene defines the scene to track
  79288. */
  79289. track(scene: Scene): void;
  79290. /**
  79291. * Get the delta between current state and original state
  79292. * @returns a any containing the delta
  79293. */
  79294. getDelta(): any;
  79295. private _compareArray;
  79296. private _compareObjects;
  79297. private _compareCollections;
  79298. private static GetShadowGeneratorById;
  79299. /**
  79300. * Apply a given delta to a given scene
  79301. * @param deltaJSON defines the JSON containing the delta
  79302. * @param scene defines the scene to apply the delta to
  79303. */
  79304. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79305. private static _ApplyPropertiesToEntity;
  79306. private static _ApplyDeltaForEntity;
  79307. }
  79308. }
  79309. declare module BABYLON {
  79310. /**
  79311. * A 3D trajectory consisting of an order list of vectors describing a
  79312. * path of motion through 3D space.
  79313. */
  79314. export class Trajectory {
  79315. private _points;
  79316. private readonly _segmentLength;
  79317. /**
  79318. * Serialize to JSON.
  79319. * @returns serialized JSON string
  79320. */
  79321. serialize(): string;
  79322. /**
  79323. * Deserialize from JSON.
  79324. * @param json serialized JSON string
  79325. * @returns deserialized Trajectory
  79326. */
  79327. static Deserialize(json: string): Trajectory;
  79328. /**
  79329. * Create a new empty Trajectory.
  79330. * @param segmentLength radius of discretization for Trajectory points
  79331. */
  79332. constructor(segmentLength?: number);
  79333. /**
  79334. * Get the length of the Trajectory.
  79335. * @returns length of the Trajectory
  79336. */
  79337. getLength(): number;
  79338. /**
  79339. * Append a new point to the Trajectory.
  79340. * NOTE: This implementation has many allocations.
  79341. * @param point point to append to the Trajectory
  79342. */
  79343. add(point: DeepImmutable<Vector3>): void;
  79344. /**
  79345. * Create a new Trajectory with a segment length chosen to make it
  79346. * probable that the new Trajectory will have a specified number of
  79347. * segments. This operation is imprecise.
  79348. * @param targetResolution number of segments desired
  79349. * @returns new Trajectory with approximately the requested number of segments
  79350. */
  79351. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79352. /**
  79353. * Convert Trajectory segments into tokenized representation. This
  79354. * representation is an array of numbers where each nth number is the
  79355. * index of the token which is most similar to the nth segment of the
  79356. * Trajectory.
  79357. * @param tokens list of vectors which serve as discrete tokens
  79358. * @returns list of indices of most similar token per segment
  79359. */
  79360. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79361. private static _forwardDir;
  79362. private static _inverseFromVec;
  79363. private static _upDir;
  79364. private static _fromToVec;
  79365. private static _lookMatrix;
  79366. /**
  79367. * Transform the rotation (i.e., direction) of a segment to isolate
  79368. * the relative transformation represented by the segment. This operation
  79369. * may or may not succeed due to singularities in the equations that define
  79370. * motion relativity in this context.
  79371. * @param priorVec the origin of the prior segment
  79372. * @param fromVec the origin of the current segment
  79373. * @param toVec the destination of the current segment
  79374. * @param result reference to output variable
  79375. * @returns whether or not transformation was successful
  79376. */
  79377. private static _transformSegmentDirToRef;
  79378. private static _bestMatch;
  79379. private static _score;
  79380. private static _bestScore;
  79381. /**
  79382. * Determine which token vector is most similar to the
  79383. * segment vector.
  79384. * @param segment segment vector
  79385. * @param tokens token vector list
  79386. * @returns index of the most similar token to the segment
  79387. */
  79388. private static _tokenizeSegment;
  79389. }
  79390. /**
  79391. * Class representing a set of known, named trajectories to which Trajectories can be
  79392. * added and using which Trajectories can be recognized.
  79393. */
  79394. export class TrajectoryClassifier {
  79395. private _maximumAllowableMatchCost;
  79396. private _vector3Alphabet;
  79397. private _levenshteinAlphabet;
  79398. private _nameToDescribedTrajectory;
  79399. /**
  79400. * Serialize to JSON.
  79401. * @returns JSON serialization
  79402. */
  79403. serialize(): string;
  79404. /**
  79405. * Deserialize from JSON.
  79406. * @param json JSON serialization
  79407. * @returns deserialized TrajectorySet
  79408. */
  79409. static Deserialize(json: string): TrajectoryClassifier;
  79410. /**
  79411. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79412. * VERY naive, need to be generating these things from known
  79413. * sets. Better version later, probably eliminating this one.
  79414. * @returns auto-generated TrajectorySet
  79415. */
  79416. static Generate(): TrajectoryClassifier;
  79417. private constructor();
  79418. /**
  79419. * Add a new Trajectory to the set with a given name.
  79420. * @param trajectory new Trajectory to be added
  79421. * @param classification name to which to add the Trajectory
  79422. */
  79423. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79424. /**
  79425. * Remove a known named trajectory and all Trajectories associated with it.
  79426. * @param classification name to remove
  79427. * @returns whether anything was removed
  79428. */
  79429. deleteClassification(classification: string): boolean;
  79430. /**
  79431. * Attempt to recognize a Trajectory from among all the classifications
  79432. * already known to the classifier.
  79433. * @param trajectory Trajectory to be recognized
  79434. * @returns classification of Trajectory if recognized, null otherwise
  79435. */
  79436. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79437. }
  79438. }
  79439. declare module BABYLON {
  79440. /**
  79441. * An interface for all Hit test features
  79442. */
  79443. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79444. /**
  79445. * Triggered when new babylon (transformed) hit test results are available
  79446. */
  79447. onHitTestResultObservable: Observable<T[]>;
  79448. }
  79449. /**
  79450. * Options used for hit testing
  79451. */
  79452. export interface IWebXRLegacyHitTestOptions {
  79453. /**
  79454. * Only test when user interacted with the scene. Default - hit test every frame
  79455. */
  79456. testOnPointerDownOnly?: boolean;
  79457. /**
  79458. * The node to use to transform the local results to world coordinates
  79459. */
  79460. worldParentNode?: TransformNode;
  79461. }
  79462. /**
  79463. * Interface defining the babylon result of raycasting/hit-test
  79464. */
  79465. export interface IWebXRLegacyHitResult {
  79466. /**
  79467. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79468. */
  79469. transformationMatrix: Matrix;
  79470. /**
  79471. * The native hit test result
  79472. */
  79473. xrHitResult: XRHitResult | XRHitTestResult;
  79474. }
  79475. /**
  79476. * The currently-working hit-test module.
  79477. * Hit test (or Ray-casting) is used to interact with the real world.
  79478. * For further information read here - https://github.com/immersive-web/hit-test
  79479. */
  79480. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79481. /**
  79482. * options to use when constructing this feature
  79483. */
  79484. readonly options: IWebXRLegacyHitTestOptions;
  79485. private _direction;
  79486. private _mat;
  79487. private _onSelectEnabled;
  79488. private _origin;
  79489. /**
  79490. * The module's name
  79491. */
  79492. static readonly Name: string;
  79493. /**
  79494. * The (Babylon) version of this module.
  79495. * This is an integer representing the implementation version.
  79496. * This number does not correspond to the WebXR specs version
  79497. */
  79498. static readonly Version: number;
  79499. /**
  79500. * Populated with the last native XR Hit Results
  79501. */
  79502. lastNativeXRHitResults: XRHitResult[];
  79503. /**
  79504. * Triggered when new babylon (transformed) hit test results are available
  79505. */
  79506. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79507. /**
  79508. * Creates a new instance of the (legacy version) hit test feature
  79509. * @param _xrSessionManager an instance of WebXRSessionManager
  79510. * @param options options to use when constructing this feature
  79511. */
  79512. constructor(_xrSessionManager: WebXRSessionManager,
  79513. /**
  79514. * options to use when constructing this feature
  79515. */
  79516. options?: IWebXRLegacyHitTestOptions);
  79517. /**
  79518. * execute a hit test with an XR Ray
  79519. *
  79520. * @param xrSession a native xrSession that will execute this hit test
  79521. * @param xrRay the ray (position and direction) to use for ray-casting
  79522. * @param referenceSpace native XR reference space to use for the hit-test
  79523. * @param filter filter function that will filter the results
  79524. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79525. */
  79526. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79527. /**
  79528. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79529. * @param event the (select) event to use to select with
  79530. * @param referenceSpace the reference space to use for this hit test
  79531. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79532. */
  79533. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79534. /**
  79535. * attach this feature
  79536. * Will usually be called by the features manager
  79537. *
  79538. * @returns true if successful.
  79539. */
  79540. attach(): boolean;
  79541. /**
  79542. * detach this feature.
  79543. * Will usually be called by the features manager
  79544. *
  79545. * @returns true if successful.
  79546. */
  79547. detach(): boolean;
  79548. /**
  79549. * Dispose this feature and all of the resources attached
  79550. */
  79551. dispose(): void;
  79552. protected _onXRFrame(frame: XRFrame): void;
  79553. private _onHitTestResults;
  79554. private _onSelect;
  79555. }
  79556. }
  79557. declare module BABYLON {
  79558. /**
  79559. * Options used for hit testing (version 2)
  79560. */
  79561. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79562. /**
  79563. * Do not create a permanent hit test. Will usually be used when only
  79564. * transient inputs are needed.
  79565. */
  79566. disablePermanentHitTest?: boolean;
  79567. /**
  79568. * Enable transient (for example touch-based) hit test inspections
  79569. */
  79570. enableTransientHitTest?: boolean;
  79571. /**
  79572. * Offset ray for the permanent hit test
  79573. */
  79574. offsetRay?: Vector3;
  79575. /**
  79576. * Offset ray for the transient hit test
  79577. */
  79578. transientOffsetRay?: Vector3;
  79579. /**
  79580. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79581. */
  79582. useReferenceSpace?: boolean;
  79583. /**
  79584. * Override the default entity type(s) of the hit-test result
  79585. */
  79586. entityTypes?: XRHitTestTrackableType[];
  79587. }
  79588. /**
  79589. * Interface defining the babylon result of hit-test
  79590. */
  79591. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79592. /**
  79593. * The input source that generated this hit test (if transient)
  79594. */
  79595. inputSource?: XRInputSource;
  79596. /**
  79597. * Is this a transient hit test
  79598. */
  79599. isTransient?: boolean;
  79600. /**
  79601. * Position of the hit test result
  79602. */
  79603. position: Vector3;
  79604. /**
  79605. * Rotation of the hit test result
  79606. */
  79607. rotationQuaternion: Quaternion;
  79608. /**
  79609. * The native hit test result
  79610. */
  79611. xrHitResult: XRHitTestResult;
  79612. }
  79613. /**
  79614. * The currently-working hit-test module.
  79615. * Hit test (or Ray-casting) is used to interact with the real world.
  79616. * For further information read here - https://github.com/immersive-web/hit-test
  79617. *
  79618. * Tested on chrome (mobile) 80.
  79619. */
  79620. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79621. /**
  79622. * options to use when constructing this feature
  79623. */
  79624. readonly options: IWebXRHitTestOptions;
  79625. private _tmpMat;
  79626. private _tmpPos;
  79627. private _tmpQuat;
  79628. private _transientXrHitTestSource;
  79629. private _xrHitTestSource;
  79630. private initHitTestSource;
  79631. /**
  79632. * The module's name
  79633. */
  79634. static readonly Name: string;
  79635. /**
  79636. * The (Babylon) version of this module.
  79637. * This is an integer representing the implementation version.
  79638. * This number does not correspond to the WebXR specs version
  79639. */
  79640. static readonly Version: number;
  79641. /**
  79642. * When set to true, each hit test will have its own position/rotation objects
  79643. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79644. * the developers will clone them or copy them as they see fit.
  79645. */
  79646. autoCloneTransformation: boolean;
  79647. /**
  79648. * Triggered when new babylon (transformed) hit test results are available
  79649. * Note - this will be called when results come back from the device. It can be an empty array!!
  79650. */
  79651. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79652. /**
  79653. * Use this to temporarily pause hit test checks.
  79654. */
  79655. paused: boolean;
  79656. /**
  79657. * Creates a new instance of the hit test feature
  79658. * @param _xrSessionManager an instance of WebXRSessionManager
  79659. * @param options options to use when constructing this feature
  79660. */
  79661. constructor(_xrSessionManager: WebXRSessionManager,
  79662. /**
  79663. * options to use when constructing this feature
  79664. */
  79665. options?: IWebXRHitTestOptions);
  79666. /**
  79667. * attach this feature
  79668. * Will usually be called by the features manager
  79669. *
  79670. * @returns true if successful.
  79671. */
  79672. attach(): boolean;
  79673. /**
  79674. * detach this feature.
  79675. * Will usually be called by the features manager
  79676. *
  79677. * @returns true if successful.
  79678. */
  79679. detach(): boolean;
  79680. /**
  79681. * Dispose this feature and all of the resources attached
  79682. */
  79683. dispose(): void;
  79684. protected _onXRFrame(frame: XRFrame): void;
  79685. private _processWebXRHitTestResult;
  79686. }
  79687. }
  79688. declare module BABYLON {
  79689. /**
  79690. * Configuration options of the anchor system
  79691. */
  79692. export interface IWebXRAnchorSystemOptions {
  79693. /**
  79694. * a node that will be used to convert local to world coordinates
  79695. */
  79696. worldParentNode?: TransformNode;
  79697. /**
  79698. * If set to true a reference of the created anchors will be kept until the next session starts
  79699. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79700. */
  79701. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79702. }
  79703. /**
  79704. * A babylon container for an XR Anchor
  79705. */
  79706. export interface IWebXRAnchor {
  79707. /**
  79708. * A babylon-assigned ID for this anchor
  79709. */
  79710. id: number;
  79711. /**
  79712. * Transformation matrix to apply to an object attached to this anchor
  79713. */
  79714. transformationMatrix: Matrix;
  79715. /**
  79716. * The native anchor object
  79717. */
  79718. xrAnchor: XRAnchor;
  79719. /**
  79720. * if defined, this object will be constantly updated by the anchor's position and rotation
  79721. */
  79722. attachedNode?: TransformNode;
  79723. /**
  79724. * Remove this anchor from the scene
  79725. */
  79726. remove(): void;
  79727. }
  79728. /**
  79729. * An implementation of the anchor system for WebXR.
  79730. * For further information see https://github.com/immersive-web/anchors/
  79731. */
  79732. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79733. private _options;
  79734. private _lastFrameDetected;
  79735. private _trackedAnchors;
  79736. private _referenceSpaceForFrameAnchors;
  79737. private _futureAnchors;
  79738. /**
  79739. * The module's name
  79740. */
  79741. static readonly Name: string;
  79742. /**
  79743. * The (Babylon) version of this module.
  79744. * This is an integer representing the implementation version.
  79745. * This number does not correspond to the WebXR specs version
  79746. */
  79747. static readonly Version: number;
  79748. /**
  79749. * Observers registered here will be executed when a new anchor was added to the session
  79750. */
  79751. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79752. /**
  79753. * Observers registered here will be executed when an anchor was removed from the session
  79754. */
  79755. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79756. /**
  79757. * Observers registered here will be executed when an existing anchor updates
  79758. * This can execute N times every frame
  79759. */
  79760. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79761. /**
  79762. * Set the reference space to use for anchor creation, when not using a hit test.
  79763. * Will default to the session's reference space if not defined
  79764. */
  79765. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79766. /**
  79767. * constructs a new anchor system
  79768. * @param _xrSessionManager an instance of WebXRSessionManager
  79769. * @param _options configuration object for this feature
  79770. */
  79771. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79772. private _tmpVector;
  79773. private _tmpQuaternion;
  79774. private _populateTmpTransformation;
  79775. /**
  79776. * Create a new anchor point using a hit test result at a specific point in the scene
  79777. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79778. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79779. *
  79780. * @param hitTestResult The hit test result to use for this anchor creation
  79781. * @param position an optional position offset for this anchor
  79782. * @param rotationQuaternion an optional rotation offset for this anchor
  79783. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79784. */
  79785. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79786. /**
  79787. * Add a new anchor at a specific position and rotation
  79788. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79789. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79790. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79791. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79792. *
  79793. * @param position the position in which to add an anchor
  79794. * @param rotationQuaternion an optional rotation for the anchor transformation
  79795. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79796. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79797. */
  79798. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79799. /**
  79800. * Get the list of anchors currently being tracked by the system
  79801. */
  79802. get anchors(): IWebXRAnchor[];
  79803. /**
  79804. * detach this feature.
  79805. * Will usually be called by the features manager
  79806. *
  79807. * @returns true if successful.
  79808. */
  79809. detach(): boolean;
  79810. /**
  79811. * Dispose this feature and all of the resources attached
  79812. */
  79813. dispose(): void;
  79814. protected _onXRFrame(frame: XRFrame): void;
  79815. /**
  79816. * avoiding using Array.find for global support.
  79817. * @param xrAnchor the plane to find in the array
  79818. */
  79819. private _findIndexInAnchorArray;
  79820. private _updateAnchorWithXRFrame;
  79821. private _createAnchorAtTransformation;
  79822. }
  79823. }
  79824. declare module BABYLON {
  79825. /**
  79826. * Options used in the plane detector module
  79827. */
  79828. export interface IWebXRPlaneDetectorOptions {
  79829. /**
  79830. * The node to use to transform the local results to world coordinates
  79831. */
  79832. worldParentNode?: TransformNode;
  79833. /**
  79834. * If set to true a reference of the created planes will be kept until the next session starts
  79835. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79836. */
  79837. doNotRemovePlanesOnSessionEnded?: boolean;
  79838. /**
  79839. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79840. */
  79841. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79842. }
  79843. /**
  79844. * A babylon interface for a WebXR plane.
  79845. * A Plane is actually a polygon, built from N points in space
  79846. *
  79847. * Supported in chrome 79, not supported in canary 81 ATM
  79848. */
  79849. export interface IWebXRPlane {
  79850. /**
  79851. * a babylon-assigned ID for this polygon
  79852. */
  79853. id: number;
  79854. /**
  79855. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79856. */
  79857. polygonDefinition: Array<Vector3>;
  79858. /**
  79859. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79860. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79861. */
  79862. transformationMatrix: Matrix;
  79863. /**
  79864. * the native xr-plane object
  79865. */
  79866. xrPlane: XRPlane;
  79867. }
  79868. /**
  79869. * The plane detector is used to detect planes in the real world when in AR
  79870. * For more information see https://github.com/immersive-web/real-world-geometry/
  79871. */
  79872. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79873. private _options;
  79874. private _detectedPlanes;
  79875. private _enabled;
  79876. private _lastFrameDetected;
  79877. /**
  79878. * The module's name
  79879. */
  79880. static readonly Name: string;
  79881. /**
  79882. * The (Babylon) version of this module.
  79883. * This is an integer representing the implementation version.
  79884. * This number does not correspond to the WebXR specs version
  79885. */
  79886. static readonly Version: number;
  79887. /**
  79888. * Observers registered here will be executed when a new plane was added to the session
  79889. */
  79890. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79891. /**
  79892. * Observers registered here will be executed when a plane is no longer detected in the session
  79893. */
  79894. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79895. /**
  79896. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79897. * This can execute N times every frame
  79898. */
  79899. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79900. /**
  79901. * construct a new Plane Detector
  79902. * @param _xrSessionManager an instance of xr Session manager
  79903. * @param _options configuration to use when constructing this feature
  79904. */
  79905. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79906. /**
  79907. * detach this feature.
  79908. * Will usually be called by the features manager
  79909. *
  79910. * @returns true if successful.
  79911. */
  79912. detach(): boolean;
  79913. /**
  79914. * Dispose this feature and all of the resources attached
  79915. */
  79916. dispose(): void;
  79917. /**
  79918. * Check if the needed objects are defined.
  79919. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79920. */
  79921. isCompatible(): boolean;
  79922. protected _onXRFrame(frame: XRFrame): void;
  79923. private _init;
  79924. private _updatePlaneWithXRPlane;
  79925. /**
  79926. * avoiding using Array.find for global support.
  79927. * @param xrPlane the plane to find in the array
  79928. */
  79929. private _findIndexInPlaneArray;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /**
  79934. * Options interface for the background remover plugin
  79935. */
  79936. export interface IWebXRBackgroundRemoverOptions {
  79937. /**
  79938. * Further background meshes to disable when entering AR
  79939. */
  79940. backgroundMeshes?: AbstractMesh[];
  79941. /**
  79942. * flags to configure the removal of the environment helper.
  79943. * If not set, the entire background will be removed. If set, flags should be set as well.
  79944. */
  79945. environmentHelperRemovalFlags?: {
  79946. /**
  79947. * Should the skybox be removed (default false)
  79948. */
  79949. skyBox?: boolean;
  79950. /**
  79951. * Should the ground be removed (default false)
  79952. */
  79953. ground?: boolean;
  79954. };
  79955. /**
  79956. * don't disable the environment helper
  79957. */
  79958. ignoreEnvironmentHelper?: boolean;
  79959. }
  79960. /**
  79961. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79962. */
  79963. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79964. /**
  79965. * read-only options to be used in this module
  79966. */
  79967. readonly options: IWebXRBackgroundRemoverOptions;
  79968. /**
  79969. * The module's name
  79970. */
  79971. static readonly Name: string;
  79972. /**
  79973. * The (Babylon) version of this module.
  79974. * This is an integer representing the implementation version.
  79975. * This number does not correspond to the WebXR specs version
  79976. */
  79977. static readonly Version: number;
  79978. /**
  79979. * registered observers will be triggered when the background state changes
  79980. */
  79981. onBackgroundStateChangedObservable: Observable<boolean>;
  79982. /**
  79983. * constructs a new background remover module
  79984. * @param _xrSessionManager the session manager for this module
  79985. * @param options read-only options to be used in this module
  79986. */
  79987. constructor(_xrSessionManager: WebXRSessionManager,
  79988. /**
  79989. * read-only options to be used in this module
  79990. */
  79991. options?: IWebXRBackgroundRemoverOptions);
  79992. /**
  79993. * attach this feature
  79994. * Will usually be called by the features manager
  79995. *
  79996. * @returns true if successful.
  79997. */
  79998. attach(): boolean;
  79999. /**
  80000. * detach this feature.
  80001. * Will usually be called by the features manager
  80002. *
  80003. * @returns true if successful.
  80004. */
  80005. detach(): boolean;
  80006. /**
  80007. * Dispose this feature and all of the resources attached
  80008. */
  80009. dispose(): void;
  80010. protected _onXRFrame(_xrFrame: XRFrame): void;
  80011. private _setBackgroundState;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /**
  80016. * Options for the controller physics feature
  80017. */
  80018. export class IWebXRControllerPhysicsOptions {
  80019. /**
  80020. * Should the headset get its own impostor
  80021. */
  80022. enableHeadsetImpostor?: boolean;
  80023. /**
  80024. * Optional parameters for the headset impostor
  80025. */
  80026. headsetImpostorParams?: {
  80027. /**
  80028. * The type of impostor to create. Default is sphere
  80029. */
  80030. impostorType: number;
  80031. /**
  80032. * the size of the impostor. Defaults to 10cm
  80033. */
  80034. impostorSize?: number | {
  80035. width: number;
  80036. height: number;
  80037. depth: number;
  80038. };
  80039. /**
  80040. * Friction definitions
  80041. */
  80042. friction?: number;
  80043. /**
  80044. * Restitution
  80045. */
  80046. restitution?: number;
  80047. };
  80048. /**
  80049. * The physics properties of the future impostors
  80050. */
  80051. physicsProperties?: {
  80052. /**
  80053. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80054. * Note that this requires a physics engine that supports mesh impostors!
  80055. */
  80056. useControllerMesh?: boolean;
  80057. /**
  80058. * The type of impostor to create. Default is sphere
  80059. */
  80060. impostorType?: number;
  80061. /**
  80062. * the size of the impostor. Defaults to 10cm
  80063. */
  80064. impostorSize?: number | {
  80065. width: number;
  80066. height: number;
  80067. depth: number;
  80068. };
  80069. /**
  80070. * Friction definitions
  80071. */
  80072. friction?: number;
  80073. /**
  80074. * Restitution
  80075. */
  80076. restitution?: number;
  80077. };
  80078. /**
  80079. * the xr input to use with this pointer selection
  80080. */
  80081. xrInput: WebXRInput;
  80082. }
  80083. /**
  80084. * Add physics impostor to your webxr controllers,
  80085. * including naive calculation of their linear and angular velocity
  80086. */
  80087. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80088. private readonly _options;
  80089. private _attachController;
  80090. private _controllers;
  80091. private _debugMode;
  80092. private _delta;
  80093. private _headsetImpostor?;
  80094. private _headsetMesh?;
  80095. private _lastTimestamp;
  80096. private _tmpQuaternion;
  80097. private _tmpVector;
  80098. /**
  80099. * The module's name
  80100. */
  80101. static readonly Name: string;
  80102. /**
  80103. * The (Babylon) version of this module.
  80104. * This is an integer representing the implementation version.
  80105. * This number does not correspond to the webxr specs version
  80106. */
  80107. static readonly Version: number;
  80108. /**
  80109. * Construct a new Controller Physics Feature
  80110. * @param _xrSessionManager the corresponding xr session manager
  80111. * @param _options options to create this feature with
  80112. */
  80113. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80114. /**
  80115. * @hidden
  80116. * enable debugging - will show console outputs and the impostor mesh
  80117. */
  80118. _enablePhysicsDebug(): void;
  80119. /**
  80120. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80121. * @param xrController the controller to add
  80122. */
  80123. addController(xrController: WebXRInputSource): void;
  80124. /**
  80125. * attach this feature
  80126. * Will usually be called by the features manager
  80127. *
  80128. * @returns true if successful.
  80129. */
  80130. attach(): boolean;
  80131. /**
  80132. * detach this feature.
  80133. * Will usually be called by the features manager
  80134. *
  80135. * @returns true if successful.
  80136. */
  80137. detach(): boolean;
  80138. /**
  80139. * Get the headset impostor, if enabled
  80140. * @returns the impostor
  80141. */
  80142. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80143. /**
  80144. * Get the physics impostor of a specific controller.
  80145. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80146. * @param controller the controller or the controller id of which to get the impostor
  80147. * @returns the impostor or null
  80148. */
  80149. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80150. /**
  80151. * Update the physics properties provided in the constructor
  80152. * @param newProperties the new properties object
  80153. */
  80154. setPhysicsProperties(newProperties: {
  80155. impostorType?: number;
  80156. impostorSize?: number | {
  80157. width: number;
  80158. height: number;
  80159. depth: number;
  80160. };
  80161. friction?: number;
  80162. restitution?: number;
  80163. }): void;
  80164. protected _onXRFrame(_xrFrame: any): void;
  80165. private _detachController;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /**
  80170. * A babylon interface for a "WebXR" feature point.
  80171. * Represents the position and confidence value of a given feature point.
  80172. */
  80173. export interface IWebXRFeaturePoint {
  80174. /**
  80175. * Represents the position of the feature point in world space.
  80176. */
  80177. position: Vector3;
  80178. /**
  80179. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80180. */
  80181. confidenceValue: number;
  80182. }
  80183. /**
  80184. * The feature point system is used to detect feature points from real world geometry.
  80185. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80186. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80187. */
  80188. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80189. private _enabled;
  80190. private _featurePointCloud;
  80191. /**
  80192. * The module's name
  80193. */
  80194. static readonly Name: string;
  80195. /**
  80196. * The (Babylon) version of this module.
  80197. * This is an integer representing the implementation version.
  80198. * This number does not correspond to the WebXR specs version
  80199. */
  80200. static readonly Version: number;
  80201. /**
  80202. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80203. * Will notify the observers about which feature points have been added.
  80204. */
  80205. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80206. /**
  80207. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80208. * Will notify the observers about which feature points have been updated.
  80209. */
  80210. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80211. /**
  80212. * The current feature point cloud maintained across frames.
  80213. */
  80214. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80215. /**
  80216. * construct the feature point system
  80217. * @param _xrSessionManager an instance of xr Session manager
  80218. */
  80219. constructor(_xrSessionManager: WebXRSessionManager);
  80220. /**
  80221. * Detach this feature.
  80222. * Will usually be called by the features manager
  80223. *
  80224. * @returns true if successful.
  80225. */
  80226. detach(): boolean;
  80227. /**
  80228. * Dispose this feature and all of the resources attached
  80229. */
  80230. dispose(): void;
  80231. /**
  80232. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80233. */
  80234. protected _onXRFrame(frame: XRFrame): void;
  80235. /**
  80236. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80237. */
  80238. private _init;
  80239. }
  80240. }
  80241. declare module BABYLON {
  80242. /**
  80243. * Configuration interface for the hand tracking feature
  80244. */
  80245. export interface IWebXRHandTrackingOptions {
  80246. /**
  80247. * The xrInput that will be used as source for new hands
  80248. */
  80249. xrInput: WebXRInput;
  80250. /**
  80251. * Configuration object for the joint meshes
  80252. */
  80253. jointMeshes?: {
  80254. /**
  80255. * Should the meshes created be invisible (defaults to false)
  80256. */
  80257. invisible?: boolean;
  80258. /**
  80259. * A source mesh to be used to create instances. Defaults to a sphere.
  80260. * This mesh will be the source for all other (25) meshes.
  80261. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80262. */
  80263. sourceMesh?: Mesh;
  80264. /**
  80265. * This function will be called after a mesh was created for a specific joint.
  80266. * Using this function you can either manipulate the instance or return a new mesh.
  80267. * When returning a new mesh the instance created before will be disposed
  80268. */
  80269. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80270. /**
  80271. * Should the source mesh stay visible. Defaults to false
  80272. */
  80273. keepOriginalVisible?: boolean;
  80274. /**
  80275. * Scale factor for all instances (defaults to 2)
  80276. */
  80277. scaleFactor?: number;
  80278. /**
  80279. * Should each instance have its own physics impostor
  80280. */
  80281. enablePhysics?: boolean;
  80282. /**
  80283. * If enabled, override default physics properties
  80284. */
  80285. physicsProps?: {
  80286. friction?: number;
  80287. restitution?: number;
  80288. impostorType?: number;
  80289. };
  80290. /**
  80291. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80292. */
  80293. disableDefaultHandMesh?: boolean;
  80294. /**
  80295. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80296. */
  80297. handMeshes?: {
  80298. right: AbstractMesh;
  80299. left: AbstractMesh;
  80300. };
  80301. /**
  80302. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  80303. */
  80304. leftHandedSystemMeshes?: boolean;
  80305. /**
  80306. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80307. */
  80308. rigMapping?: {
  80309. right: string[];
  80310. left: string[];
  80311. };
  80312. };
  80313. }
  80314. /**
  80315. * Parts of the hands divided to writs and finger names
  80316. */
  80317. export const enum HandPart {
  80318. /**
  80319. * HandPart - Wrist
  80320. */
  80321. WRIST = "wrist",
  80322. /**
  80323. * HandPart - The Thumb
  80324. */
  80325. THUMB = "thumb",
  80326. /**
  80327. * HandPart - Index finger
  80328. */
  80329. INDEX = "index",
  80330. /**
  80331. * HandPart - Middle finger
  80332. */
  80333. MIDDLE = "middle",
  80334. /**
  80335. * HandPart - Ring finger
  80336. */
  80337. RING = "ring",
  80338. /**
  80339. * HandPart - Little finger
  80340. */
  80341. LITTLE = "little"
  80342. }
  80343. /**
  80344. * Representing a single hand (with its corresponding native XRHand object)
  80345. */
  80346. export class WebXRHand implements IDisposable {
  80347. /** the controller to which the hand correlates */
  80348. readonly xrController: WebXRInputSource;
  80349. /** the meshes to be used to track the hand joints */
  80350. readonly trackedMeshes: AbstractMesh[];
  80351. private _handMesh?;
  80352. private _rigMapping?;
  80353. private _leftHandedMeshes?;
  80354. private _scene;
  80355. private _defaultHandMesh;
  80356. private _transformNodeMapping;
  80357. private _boneMapping;
  80358. private _useBones;
  80359. /**
  80360. * Hand-parts definition (key is HandPart)
  80361. */
  80362. handPartsDefinition: {
  80363. [key: string]: number[];
  80364. };
  80365. /**
  80366. * Observers will be triggered when the mesh for this hand was initialized.
  80367. */
  80368. onHandMeshReadyObservable: Observable<WebXRHand>;
  80369. /**
  80370. * Populate the HandPartsDefinition object.
  80371. * This is called as a side effect since certain browsers don't have XRHand defined.
  80372. */
  80373. private generateHandPartsDefinition;
  80374. /**
  80375. * Construct a new hand object
  80376. * @param xrController the controller to which the hand correlates
  80377. * @param trackedMeshes the meshes to be used to track the hand joints
  80378. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80379. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80380. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80381. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  80382. */
  80383. constructor(
  80384. /** the controller to which the hand correlates */
  80385. xrController: WebXRInputSource,
  80386. /** the meshes to be used to track the hand joints */
  80387. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _leftHandedMeshes?: boolean | undefined);
  80388. /**
  80389. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80390. */
  80391. get handMesh(): AbstractMesh | undefined;
  80392. /**
  80393. * Update this hand from the latest xr frame
  80394. * @param xrFrame xrFrame to update from
  80395. * @param referenceSpace The current viewer reference space
  80396. * @param scaleFactor optional scale factor for the meshes
  80397. */
  80398. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80399. /**
  80400. * Get meshes of part of the hand
  80401. * @param part the part of hand to get
  80402. * @returns An array of meshes that correlate to the hand part requested
  80403. */
  80404. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80405. /**
  80406. * Dispose this Hand object
  80407. */
  80408. dispose(): void;
  80409. private _generateDefaultHandMesh;
  80410. }
  80411. /**
  80412. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80413. */
  80414. export class WebXRHandTracking extends WebXRAbstractFeature {
  80415. /**
  80416. * options to use when constructing this feature
  80417. */
  80418. readonly options: IWebXRHandTrackingOptions;
  80419. private static _idCounter;
  80420. /**
  80421. * The module's name
  80422. */
  80423. static readonly Name: string;
  80424. /**
  80425. * The (Babylon) version of this module.
  80426. * This is an integer representing the implementation version.
  80427. * This number does not correspond to the WebXR specs version
  80428. */
  80429. static readonly Version: number;
  80430. /**
  80431. * This observable will notify registered observers when a new hand object was added and initialized
  80432. */
  80433. onHandAddedObservable: Observable<WebXRHand>;
  80434. /**
  80435. * This observable will notify its observers right before the hand object is disposed
  80436. */
  80437. onHandRemovedObservable: Observable<WebXRHand>;
  80438. private _hands;
  80439. /**
  80440. * Creates a new instance of the hit test feature
  80441. * @param _xrSessionManager an instance of WebXRSessionManager
  80442. * @param options options to use when constructing this feature
  80443. */
  80444. constructor(_xrSessionManager: WebXRSessionManager,
  80445. /**
  80446. * options to use when constructing this feature
  80447. */
  80448. options: IWebXRHandTrackingOptions);
  80449. /**
  80450. * Check if the needed objects are defined.
  80451. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80452. */
  80453. isCompatible(): boolean;
  80454. /**
  80455. * attach this feature
  80456. * Will usually be called by the features manager
  80457. *
  80458. * @returns true if successful.
  80459. */
  80460. attach(): boolean;
  80461. /**
  80462. * detach this feature.
  80463. * Will usually be called by the features manager
  80464. *
  80465. * @returns true if successful.
  80466. */
  80467. detach(): boolean;
  80468. /**
  80469. * Dispose this feature and all of the resources attached
  80470. */
  80471. dispose(): void;
  80472. /**
  80473. * Get the hand object according to the controller id
  80474. * @param controllerId the controller id to which we want to get the hand
  80475. * @returns null if not found or the WebXRHand object if found
  80476. */
  80477. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80478. /**
  80479. * Get a hand object according to the requested handedness
  80480. * @param handedness the handedness to request
  80481. * @returns null if not found or the WebXRHand object if found
  80482. */
  80483. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80484. protected _onXRFrame(_xrFrame: XRFrame): void;
  80485. private _attachHand;
  80486. private _detachHand;
  80487. }
  80488. }
  80489. declare module BABYLON {
  80490. /**
  80491. * Options used in the mesh detector module
  80492. */
  80493. export interface IWebXRMeshDetectorOptions {
  80494. /**
  80495. * The node to use to transform the local results to world coordinates
  80496. */
  80497. worldParentNode?: TransformNode;
  80498. /**
  80499. * If set to true a reference of the created meshes will be kept until the next session starts
  80500. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80501. */
  80502. doNotRemoveMeshesOnSessionEnded?: boolean;
  80503. /**
  80504. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80505. */
  80506. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80507. /**
  80508. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80509. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80510. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80511. */
  80512. convertCoordinateSystems?: boolean;
  80513. }
  80514. /**
  80515. * A babylon interface for a XR mesh's vertex data.
  80516. *
  80517. * Currently not supported by WebXR, available only with BabylonNative
  80518. */
  80519. export interface IWebXRVertexData {
  80520. /**
  80521. * A babylon-assigned ID for this mesh
  80522. */
  80523. id: number;
  80524. /**
  80525. * Data required for constructing a mesh in Babylon.js.
  80526. */
  80527. xrMesh: XRMesh;
  80528. /**
  80529. * The node to use to transform the local results to world coordinates.
  80530. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80531. */
  80532. worldParentNode?: TransformNode;
  80533. /**
  80534. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80535. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80536. */
  80537. positions?: Float32Array;
  80538. /**
  80539. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80540. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80541. */
  80542. indices?: Uint32Array;
  80543. /**
  80544. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80545. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80546. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80547. */
  80548. normals?: Float32Array;
  80549. /**
  80550. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80551. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80552. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80553. */
  80554. transformationMatrix?: Matrix;
  80555. }
  80556. /**
  80557. * The mesh detector is used to detect meshes in the real world when in AR
  80558. */
  80559. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80560. private _options;
  80561. private _detectedMeshes;
  80562. /**
  80563. * The module's name
  80564. */
  80565. static readonly Name: string;
  80566. /**
  80567. * The (Babylon) version of this module.
  80568. * This is an integer representing the implementation version.
  80569. * This number does not correspond to the WebXR specs version
  80570. */
  80571. static readonly Version: number;
  80572. /**
  80573. * Observers registered here will be executed when a new mesh was added to the session
  80574. */
  80575. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80576. /**
  80577. * Observers registered here will be executed when a mesh is no longer detected in the session
  80578. */
  80579. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80580. /**
  80581. * Observers registered here will be executed when an existing mesh updates
  80582. */
  80583. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80584. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80585. detach(): boolean;
  80586. dispose(): void;
  80587. protected _onXRFrame(frame: XRFrame): void;
  80588. private _init;
  80589. private _updateVertexDataWithXRMesh;
  80590. }
  80591. }
  80592. declare module BABYLON {
  80593. /**
  80594. * Options interface for the background remover plugin
  80595. */
  80596. export interface IWebXRImageTrackingOptions {
  80597. /**
  80598. * A required array with images to track
  80599. */
  80600. images: {
  80601. /**
  80602. * The source of the image. can be a URL or an image bitmap
  80603. */
  80604. src: string | ImageBitmap;
  80605. /**
  80606. * The estimated width in the real world (in meters)
  80607. */
  80608. estimatedRealWorldWidth: number;
  80609. }[];
  80610. }
  80611. /**
  80612. * An object representing an image tracked by the system
  80613. */
  80614. export interface IWebXRTrackedImage {
  80615. /**
  80616. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80617. */
  80618. id: number;
  80619. /**
  80620. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80621. */
  80622. emulated?: boolean;
  80623. /**
  80624. * Just in case it is needed - the image bitmap that is being tracked
  80625. */
  80626. originalBitmap: ImageBitmap;
  80627. /**
  80628. * The native XR result image tracking result, untouched
  80629. */
  80630. xrTrackingResult?: XRImageTrackingResult;
  80631. /**
  80632. * Width in real world (meters)
  80633. */
  80634. realWorldWidth?: number;
  80635. /**
  80636. * A transformation matrix of this current image in the current reference space.
  80637. */
  80638. transformationMatrix: Matrix;
  80639. /**
  80640. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80641. */
  80642. ratio?: number;
  80643. }
  80644. /**
  80645. * Image tracking for immersive AR sessions.
  80646. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80647. */
  80648. export class WebXRImageTracking extends WebXRAbstractFeature {
  80649. /**
  80650. * read-only options to be used in this module
  80651. */
  80652. readonly options: IWebXRImageTrackingOptions;
  80653. /**
  80654. * The module's name
  80655. */
  80656. static readonly Name: string;
  80657. /**
  80658. * The (Babylon) version of this module.
  80659. * This is an integer representing the implementation version.
  80660. * This number does not correspond to the WebXR specs version
  80661. */
  80662. static readonly Version: number;
  80663. /**
  80664. * This will be triggered if the underlying system deems an image untrackable.
  80665. * The index is the index of the image from the array used to initialize the feature.
  80666. */
  80667. onUntrackableImageFoundObservable: Observable<number>;
  80668. /**
  80669. * An image was deemed trackable, and the system will start tracking it.
  80670. */
  80671. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80672. /**
  80673. * The image was found and its state was updated.
  80674. */
  80675. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80676. private _trackedImages;
  80677. private _originalTrackingRequest;
  80678. /**
  80679. * constructs the image tracking feature
  80680. * @param _xrSessionManager the session manager for this module
  80681. * @param options read-only options to be used in this module
  80682. */
  80683. constructor(_xrSessionManager: WebXRSessionManager,
  80684. /**
  80685. * read-only options to be used in this module
  80686. */
  80687. options: IWebXRImageTrackingOptions);
  80688. /**
  80689. * attach this feature
  80690. * Will usually be called by the features manager
  80691. *
  80692. * @returns true if successful.
  80693. */
  80694. attach(): boolean;
  80695. /**
  80696. * detach this feature.
  80697. * Will usually be called by the features manager
  80698. *
  80699. * @returns true if successful.
  80700. */
  80701. detach(): boolean;
  80702. /**
  80703. * Check if the needed objects are defined.
  80704. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80705. */
  80706. isCompatible(): boolean;
  80707. /**
  80708. * Get a tracked image by its ID.
  80709. *
  80710. * @param id the id of the image to load (position in the init array)
  80711. * @returns a trackable image, if exists in this location
  80712. */
  80713. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80714. /**
  80715. * Dispose this feature and all of the resources attached
  80716. */
  80717. dispose(): void;
  80718. /**
  80719. * Extends the session init object if needed
  80720. * @returns augmentation object fo the xr session init object.
  80721. */
  80722. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80723. protected _onXRFrame(_xrFrame: XRFrame): void;
  80724. private _init;
  80725. }
  80726. }
  80727. declare module BABYLON {
  80728. /**
  80729. * The motion controller class for all microsoft mixed reality controllers
  80730. */
  80731. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80732. protected readonly _mapping: {
  80733. defaultButton: {
  80734. valueNodeName: string;
  80735. unpressedNodeName: string;
  80736. pressedNodeName: string;
  80737. };
  80738. defaultAxis: {
  80739. valueNodeName: string;
  80740. minNodeName: string;
  80741. maxNodeName: string;
  80742. };
  80743. buttons: {
  80744. "xr-standard-trigger": {
  80745. rootNodeName: string;
  80746. componentProperty: string;
  80747. states: string[];
  80748. };
  80749. "xr-standard-squeeze": {
  80750. rootNodeName: string;
  80751. componentProperty: string;
  80752. states: string[];
  80753. };
  80754. "xr-standard-touchpad": {
  80755. rootNodeName: string;
  80756. labelAnchorNodeName: string;
  80757. touchPointNodeName: string;
  80758. };
  80759. "xr-standard-thumbstick": {
  80760. rootNodeName: string;
  80761. componentProperty: string;
  80762. states: string[];
  80763. };
  80764. };
  80765. axes: {
  80766. "xr-standard-touchpad": {
  80767. "x-axis": {
  80768. rootNodeName: string;
  80769. };
  80770. "y-axis": {
  80771. rootNodeName: string;
  80772. };
  80773. };
  80774. "xr-standard-thumbstick": {
  80775. "x-axis": {
  80776. rootNodeName: string;
  80777. };
  80778. "y-axis": {
  80779. rootNodeName: string;
  80780. };
  80781. };
  80782. };
  80783. };
  80784. /**
  80785. * The base url used to load the left and right controller models
  80786. */
  80787. static MODEL_BASE_URL: string;
  80788. /**
  80789. * The name of the left controller model file
  80790. */
  80791. static MODEL_LEFT_FILENAME: string;
  80792. /**
  80793. * The name of the right controller model file
  80794. */
  80795. static MODEL_RIGHT_FILENAME: string;
  80796. profileId: string;
  80797. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80798. protected _getFilenameAndPath(): {
  80799. filename: string;
  80800. path: string;
  80801. };
  80802. protected _getModelLoadingConstraints(): boolean;
  80803. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80804. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80805. protected _updateModel(): void;
  80806. }
  80807. }
  80808. declare module BABYLON {
  80809. /**
  80810. * The motion controller class for oculus touch (quest, rift).
  80811. * This class supports legacy mapping as well the standard xr mapping
  80812. */
  80813. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80814. private _forceLegacyControllers;
  80815. private _modelRootNode;
  80816. /**
  80817. * The base url used to load the left and right controller models
  80818. */
  80819. static MODEL_BASE_URL: string;
  80820. /**
  80821. * The name of the left controller model file
  80822. */
  80823. static MODEL_LEFT_FILENAME: string;
  80824. /**
  80825. * The name of the right controller model file
  80826. */
  80827. static MODEL_RIGHT_FILENAME: string;
  80828. /**
  80829. * Base Url for the Quest controller model.
  80830. */
  80831. static QUEST_MODEL_BASE_URL: string;
  80832. profileId: string;
  80833. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80834. protected _getFilenameAndPath(): {
  80835. filename: string;
  80836. path: string;
  80837. };
  80838. protected _getModelLoadingConstraints(): boolean;
  80839. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80840. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80841. protected _updateModel(): void;
  80842. /**
  80843. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80844. * between the touch and touch 2.
  80845. */
  80846. private _isQuest;
  80847. }
  80848. }
  80849. declare module BABYLON {
  80850. /**
  80851. * The motion controller class for the standard HTC-Vive controllers
  80852. */
  80853. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80854. private _modelRootNode;
  80855. /**
  80856. * The base url used to load the left and right controller models
  80857. */
  80858. static MODEL_BASE_URL: string;
  80859. /**
  80860. * File name for the controller model.
  80861. */
  80862. static MODEL_FILENAME: string;
  80863. profileId: string;
  80864. /**
  80865. * Create a new Vive motion controller object
  80866. * @param scene the scene to use to create this controller
  80867. * @param gamepadObject the corresponding gamepad object
  80868. * @param handedness the handedness of the controller
  80869. */
  80870. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80871. protected _getFilenameAndPath(): {
  80872. filename: string;
  80873. path: string;
  80874. };
  80875. protected _getModelLoadingConstraints(): boolean;
  80876. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80877. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80878. protected _updateModel(): void;
  80879. }
  80880. }
  80881. declare module BABYLON {
  80882. /** @hidden */
  80883. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  80884. private static _Cache;
  80885. protected _getRenderPipeline(param: {
  80886. token: any;
  80887. pipeline: Nullable<GPURenderPipeline>;
  80888. }): void;
  80889. protected _setRenderPipeline(param: {
  80890. token: any;
  80891. pipeline: Nullable<GPURenderPipeline>;
  80892. }): void;
  80893. }
  80894. }
  80895. declare module BABYLON {
  80896. /** @hidden */
  80897. export var blurPixelShader: {
  80898. name: string;
  80899. shader: string;
  80900. };
  80901. }
  80902. declare module BABYLON {
  80903. /** @hidden */
  80904. export var pointCloudVertexDeclaration: {
  80905. name: string;
  80906. shader: string;
  80907. };
  80908. }
  80909. // Mixins
  80910. interface Window {
  80911. mozIndexedDB: IDBFactory;
  80912. webkitIndexedDB: IDBFactory;
  80913. msIndexedDB: IDBFactory;
  80914. webkitURL: typeof URL;
  80915. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80916. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80917. WebGLRenderingContext: WebGLRenderingContext;
  80918. MSGesture: MSGesture;
  80919. CANNON: any;
  80920. AudioContext: AudioContext;
  80921. webkitAudioContext: AudioContext;
  80922. PointerEvent: any;
  80923. Math: Math;
  80924. Uint8Array: Uint8ArrayConstructor;
  80925. Float32Array: Float32ArrayConstructor;
  80926. mozURL: typeof URL;
  80927. msURL: typeof URL;
  80928. VRFrameData: any; // WebVR, from specs 1.1
  80929. DracoDecoderModule: any;
  80930. setImmediate(handler: (...args: any[]) => void): number;
  80931. }
  80932. interface HTMLCanvasElement {
  80933. requestPointerLock(): void;
  80934. msRequestPointerLock?(): void;
  80935. mozRequestPointerLock?(): void;
  80936. webkitRequestPointerLock?(): void;
  80937. /** Track whether a record is in progress */
  80938. isRecording: boolean;
  80939. /** Capture Stream method defined by some browsers */
  80940. captureStream(fps?: number): MediaStream;
  80941. }
  80942. interface CanvasRenderingContext2D {
  80943. msImageSmoothingEnabled: boolean;
  80944. }
  80945. interface MouseEvent {
  80946. mozMovementX: number;
  80947. mozMovementY: number;
  80948. webkitMovementX: number;
  80949. webkitMovementY: number;
  80950. msMovementX: number;
  80951. msMovementY: number;
  80952. }
  80953. interface Navigator {
  80954. mozGetVRDevices: (any: any) => any;
  80955. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80956. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80957. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80958. webkitGetGamepads(): Gamepad[];
  80959. msGetGamepads(): Gamepad[];
  80960. webkitGamepads(): Gamepad[];
  80961. }
  80962. interface HTMLVideoElement {
  80963. mozSrcObject: any;
  80964. }
  80965. interface Math {
  80966. fround(x: number): number;
  80967. imul(a: number, b: number): number;
  80968. log2(x: number): number;
  80969. }
  80970. interface WebGLRenderingContext {
  80971. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80972. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80973. vertexAttribDivisor(index: number, divisor: number): void;
  80974. createVertexArray(): any;
  80975. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80976. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80977. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80978. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80979. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80980. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80981. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80982. // Queries
  80983. createQuery(): WebGLQuery;
  80984. deleteQuery(query: WebGLQuery): void;
  80985. beginQuery(target: number, query: WebGLQuery): void;
  80986. endQuery(target: number): void;
  80987. getQueryParameter(query: WebGLQuery, pname: number): any;
  80988. getQuery(target: number, pname: number): any;
  80989. MAX_SAMPLES: number;
  80990. RGBA8: number;
  80991. READ_FRAMEBUFFER: number;
  80992. DRAW_FRAMEBUFFER: number;
  80993. UNIFORM_BUFFER: number;
  80994. HALF_FLOAT_OES: number;
  80995. RGBA16F: number;
  80996. RGBA32F: number;
  80997. R32F: number;
  80998. RG32F: number;
  80999. RGB32F: number;
  81000. R16F: number;
  81001. RG16F: number;
  81002. RGB16F: number;
  81003. RED: number;
  81004. RG: number;
  81005. R8: number;
  81006. RG8: number;
  81007. UNSIGNED_INT_24_8: number;
  81008. DEPTH24_STENCIL8: number;
  81009. MIN: number;
  81010. MAX: number;
  81011. /* Multiple Render Targets */
  81012. drawBuffers(buffers: number[]): void;
  81013. readBuffer(src: number): void;
  81014. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  81015. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  81016. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  81017. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  81018. // Occlusion Query
  81019. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81020. ANY_SAMPLES_PASSED: number;
  81021. QUERY_RESULT_AVAILABLE: number;
  81022. QUERY_RESULT: number;
  81023. }
  81024. interface WebGLProgram {
  81025. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  81026. }
  81027. interface EXT_disjoint_timer_query {
  81028. QUERY_COUNTER_BITS_EXT: number;
  81029. TIME_ELAPSED_EXT: number;
  81030. TIMESTAMP_EXT: number;
  81031. GPU_DISJOINT_EXT: number;
  81032. QUERY_RESULT_EXT: number;
  81033. QUERY_RESULT_AVAILABLE_EXT: number;
  81034. queryCounterEXT(query: WebGLQuery, target: number): void;
  81035. createQueryEXT(): WebGLQuery;
  81036. beginQueryEXT(target: number, query: WebGLQuery): void;
  81037. endQueryEXT(target: number): void;
  81038. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81039. deleteQueryEXT(query: WebGLQuery): void;
  81040. }
  81041. interface WebGLUniformLocation {
  81042. _currentState: any;
  81043. }
  81044. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81045. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81046. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81047. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81048. interface WebGLRenderingContext {
  81049. readonly RASTERIZER_DISCARD: number;
  81050. readonly DEPTH_COMPONENT24: number;
  81051. readonly TEXTURE_3D: number;
  81052. readonly TEXTURE_2D_ARRAY: number;
  81053. readonly TEXTURE_COMPARE_FUNC: number;
  81054. readonly TEXTURE_COMPARE_MODE: number;
  81055. readonly COMPARE_REF_TO_TEXTURE: number;
  81056. readonly TEXTURE_WRAP_R: number;
  81057. readonly HALF_FLOAT: number;
  81058. readonly RGB8: number;
  81059. readonly RED_INTEGER: number;
  81060. readonly RG_INTEGER: number;
  81061. readonly RGB_INTEGER: number;
  81062. readonly RGBA_INTEGER: number;
  81063. readonly R8_SNORM: number;
  81064. readonly RG8_SNORM: number;
  81065. readonly RGB8_SNORM: number;
  81066. readonly RGBA8_SNORM: number;
  81067. readonly R8I: number;
  81068. readonly RG8I: number;
  81069. readonly RGB8I: number;
  81070. readonly RGBA8I: number;
  81071. readonly R8UI: number;
  81072. readonly RG8UI: number;
  81073. readonly RGB8UI: number;
  81074. readonly RGBA8UI: number;
  81075. readonly R16I: number;
  81076. readonly RG16I: number;
  81077. readonly RGB16I: number;
  81078. readonly RGBA16I: number;
  81079. readonly R16UI: number;
  81080. readonly RG16UI: number;
  81081. readonly RGB16UI: number;
  81082. readonly RGBA16UI: number;
  81083. readonly R32I: number;
  81084. readonly RG32I: number;
  81085. readonly RGB32I: number;
  81086. readonly RGBA32I: number;
  81087. readonly R32UI: number;
  81088. readonly RG32UI: number;
  81089. readonly RGB32UI: number;
  81090. readonly RGBA32UI: number;
  81091. readonly RGB10_A2UI: number;
  81092. readonly R11F_G11F_B10F: number;
  81093. readonly RGB9_E5: number;
  81094. readonly RGB10_A2: number;
  81095. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81096. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81097. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81098. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81099. readonly DEPTH_COMPONENT32F: number;
  81100. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81101. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81102. 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;
  81103. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81104. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81105. readonly TRANSFORM_FEEDBACK: number;
  81106. readonly INTERLEAVED_ATTRIBS: number;
  81107. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81108. createTransformFeedback(): WebGLTransformFeedback;
  81109. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81110. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81111. beginTransformFeedback(primitiveMode: number): void;
  81112. endTransformFeedback(): void;
  81113. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81114. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81115. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81116. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81117. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81118. }
  81119. interface ImageBitmap {
  81120. readonly width: number;
  81121. readonly height: number;
  81122. close(): void;
  81123. }
  81124. interface WebGLQuery extends WebGLObject {
  81125. }
  81126. declare var WebGLQuery: {
  81127. prototype: WebGLQuery;
  81128. new(): WebGLQuery;
  81129. };
  81130. interface WebGLSampler extends WebGLObject {
  81131. }
  81132. declare var WebGLSampler: {
  81133. prototype: WebGLSampler;
  81134. new(): WebGLSampler;
  81135. };
  81136. interface WebGLSync extends WebGLObject {
  81137. }
  81138. declare var WebGLSync: {
  81139. prototype: WebGLSync;
  81140. new(): WebGLSync;
  81141. };
  81142. interface WebGLTransformFeedback extends WebGLObject {
  81143. }
  81144. declare var WebGLTransformFeedback: {
  81145. prototype: WebGLTransformFeedback;
  81146. new(): WebGLTransformFeedback;
  81147. };
  81148. interface WebGLVertexArrayObject extends WebGLObject {
  81149. }
  81150. declare var WebGLVertexArrayObject: {
  81151. prototype: WebGLVertexArrayObject;
  81152. new(): WebGLVertexArrayObject;
  81153. };
  81154. interface Navigator {
  81155. readonly gpu: GPU | undefined;
  81156. }
  81157. interface GPUColorDict {
  81158. a: number;
  81159. b: number;
  81160. g: number;
  81161. r: number;
  81162. }
  81163. type GPUColor = [number, number, number, number] | GPUColorDict;
  81164. interface GPUOrigin2DDict {
  81165. x?: number;
  81166. y?: number;
  81167. }
  81168. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81169. interface GPUOrigin3DDict {
  81170. x?: number;
  81171. y?: number;
  81172. z?: number;
  81173. }
  81174. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81175. interface GPUExtent3DDict {
  81176. width: number;
  81177. height: number;
  81178. depth: number;
  81179. }
  81180. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81181. type GPUBindingResource =
  81182. | GPUSampler
  81183. | GPUTextureView
  81184. | GPUBufferBinding;
  81185. type GPUExtensionName =
  81186. | "texture-compression-bc"
  81187. | "timestamp-query"
  81188. | "pipeline-statistics-query"
  81189. | "depth-clamping"
  81190. | "depth24unorm-stencil8"
  81191. | "depth32float-stencil8";
  81192. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81193. type GPUBindingType =
  81194. | "uniform-buffer"
  81195. | "storage-buffer"
  81196. | "readonly-storage-buffer"
  81197. | "sampler"
  81198. | "comparison-sampler"
  81199. | "sampled-texture"
  81200. | "readonly-storage-texture"
  81201. | "writeonly-storage-texture";
  81202. type GPUBlendFactor =
  81203. | "zero"
  81204. | "one"
  81205. | "src-color"
  81206. | "one-minus-src-color"
  81207. | "src-alpha"
  81208. | "one-minus-src-alpha"
  81209. | "dst-color"
  81210. | "one-minus-dst-color"
  81211. | "dst-alpha"
  81212. | "one-minus-dst-alpha"
  81213. | "src-alpha-saturated"
  81214. | "blend-color"
  81215. | "one-minus-blend-color";
  81216. type GPUBlendOperation =
  81217. | "add"
  81218. | "subtract"
  81219. | "reverse-subtract"
  81220. | "min"
  81221. | "max";
  81222. type GPUCompareFunction =
  81223. | "never"
  81224. | "less"
  81225. | "equal"
  81226. | "less-equal"
  81227. | "greater"
  81228. | "not-equal"
  81229. | "greater-equal"
  81230. | "always";
  81231. type GPUCullMode = "none" | "front" | "back";
  81232. type GPUFilterMode = "nearest" | "linear";
  81233. type GPUFrontFace = "ccw" | "cw";
  81234. type GPUIndexFormat = "uint16" | "uint32";
  81235. type GPUInputStepMode = "vertex" | "instance";
  81236. type GPULoadOp = "load";
  81237. type GPUPrimitiveTopology =
  81238. | "point-list"
  81239. | "line-list"
  81240. | "line-strip"
  81241. | "triangle-list"
  81242. | "triangle-strip";
  81243. type GPUStencilOperation =
  81244. | "keep"
  81245. | "zero"
  81246. | "replace"
  81247. | "invert"
  81248. | "increment-clamp"
  81249. | "decrement-clamp"
  81250. | "increment-wrap"
  81251. | "decrement-wrap";
  81252. type GPUStoreOp = "store" | "clear";
  81253. type GPUTextureDimension = "1d" | "2d" | "3d";
  81254. type GPUTextureFormat =
  81255. | "r8unorm"
  81256. | "r8snorm"
  81257. | "r8uint"
  81258. | "r8sint"
  81259. | "r16uint"
  81260. | "r16sint"
  81261. | "r16float"
  81262. | "rg8unorm"
  81263. | "rg8snorm"
  81264. | "rg8uint"
  81265. | "rg8sint"
  81266. | "r32uint"
  81267. | "r32sint"
  81268. | "r32float"
  81269. | "rg16uint"
  81270. | "rg16sint"
  81271. | "rg16float"
  81272. | "rgba8unorm"
  81273. | "rgba8unorm-srgb"
  81274. | "rgba8snorm"
  81275. | "rgba8uint"
  81276. | "rgba8sint"
  81277. | "bgra8unorm"
  81278. | "bgra8unorm-srgb"
  81279. | "rgb9e5ufloat"
  81280. | "rgb10a2unorm"
  81281. | "rg11b10ufloat"
  81282. | "rg32uint"
  81283. | "rg32sint"
  81284. | "rg32float"
  81285. | "rgba16uint"
  81286. | "rgba16sint"
  81287. | "rgba16float"
  81288. | "rgba32uint"
  81289. | "rgba32sint"
  81290. | "rgba32float"
  81291. | "stencil8"
  81292. | "depth16unorm"
  81293. | "depth24plus"
  81294. | "depth24plus-stencil8"
  81295. | "depth32float"
  81296. | "bc1-rgba-unorm"
  81297. | "bc1-rgba-unorm-srgb"
  81298. | "bc2-rgba-unorm"
  81299. | "bc2-rgba-unorm-srgb"
  81300. | "bc3-rgba-unorm"
  81301. | "bc3-rgba-unorm-srgb"
  81302. | "bc4-r-unorm"
  81303. | "bc4-r-snorm"
  81304. | "bc5-rg-unorm"
  81305. | "bc5-rg-snorm"
  81306. | "bc6h-rgb-ufloat"
  81307. | "bc6h-rgb-float"
  81308. | "bc7-rgba-unorm"
  81309. | "bc7-rgba-unorm-srgb"
  81310. | "depth24unorm-stencil8"
  81311. | "depth32float-stencil8";
  81312. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81313. type GPUTextureViewDimension =
  81314. | "1d"
  81315. | "2d"
  81316. | "2d-array"
  81317. | "cube"
  81318. | "cube-array"
  81319. | "3d";
  81320. type GPUVertexFormat =
  81321. | "uchar2"
  81322. | "uchar4"
  81323. | "char2"
  81324. | "char4"
  81325. | "uchar2norm"
  81326. | "uchar4norm"
  81327. | "char2norm"
  81328. | "char4norm"
  81329. | "ushort2"
  81330. | "ushort4"
  81331. | "short2"
  81332. | "short4"
  81333. | "ushort2norm"
  81334. | "ushort4norm"
  81335. | "short2norm"
  81336. | "short4norm"
  81337. | "half2"
  81338. | "half4"
  81339. | "float"
  81340. | "float2"
  81341. | "float3"
  81342. | "float4"
  81343. | "uint"
  81344. | "uint2"
  81345. | "uint3"
  81346. | "uint4"
  81347. | "int"
  81348. | "int2"
  81349. | "int3"
  81350. | "int4";
  81351. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81352. type GPUBufferUsageFlags = number;
  81353. type GPUColorWriteFlags = number;
  81354. type GPUShaderStageFlags = number;
  81355. type GPUTextureUsageFlags = number;
  81356. type GPUMapModeFlags = number;
  81357. interface GPUBindGroupEntry {
  81358. binding: number;
  81359. resource: GPUBindingResource;
  81360. }
  81361. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81362. layout: GPUBindGroupLayout;
  81363. entries: Iterable<GPUBindGroupEntry>;
  81364. }
  81365. interface GPUBindGroupLayoutEntry {
  81366. binding: number;
  81367. visibility: GPUShaderStageFlags;
  81368. type: GPUBindingType;
  81369. hasDynamicOffset?: boolean;
  81370. minBufferBindingSize?: number;
  81371. viewDimension?: GPUTextureViewDimension;
  81372. textureComponentType?: GPUTextureComponentType;
  81373. storageTextureFormat?: GPUTextureFormat;
  81374. }
  81375. interface GPUBindGroupLayoutDescriptor
  81376. extends GPUObjectDescriptorBase {
  81377. entries: Iterable<GPUBindGroupLayoutEntry>;
  81378. }
  81379. interface GPUBlendDescriptor {
  81380. dstFactor?: GPUBlendFactor;
  81381. operation?: GPUBlendOperation;
  81382. srcFactor?: GPUBlendFactor;
  81383. }
  81384. interface GPUColorStateDescriptor {
  81385. format: GPUTextureFormat;
  81386. alphaBlend?: GPUBlendDescriptor;
  81387. colorBlend?: GPUBlendDescriptor;
  81388. writeMask?: GPUColorWriteFlags;
  81389. }
  81390. interface GPUBufferBinding {
  81391. buffer: GPUBuffer;
  81392. offset?: number;
  81393. size?: number;
  81394. }
  81395. interface GPUTextureDataLayout {
  81396. offset?: number;
  81397. bytesPerRow: number;
  81398. rowsPerImage?: number;
  81399. }
  81400. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81401. buffer: GPUBuffer;
  81402. }
  81403. interface GPUTextureCopyView {
  81404. texture: GPUTexture;
  81405. mipLevel?: number;
  81406. origin?: GPUOrigin3D;
  81407. }
  81408. interface GPUImageBitmapCopyView {
  81409. imageBitmap: ImageBitmap;
  81410. origin?: GPUOrigin2D;
  81411. }
  81412. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81413. size: number;
  81414. usage: GPUBufferUsageFlags;
  81415. mappedAtCreation?: boolean;
  81416. }
  81417. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81418. label?: string;
  81419. measureExecutionTime?: boolean;
  81420. }
  81421. interface GPUComputePipelineDescriptor
  81422. extends GPUPipelineDescriptorBase {
  81423. computeStage: GPUProgrammableStageDescriptor;
  81424. }
  81425. interface GPUDepthStencilStateDescriptor {
  81426. format: GPUTextureFormat;
  81427. depthWriteEnabled?: boolean;
  81428. depthCompare?: GPUCompareFunction;
  81429. stencilFront?: GPUStencilStateFaceDescriptor;
  81430. stencilBack?: GPUStencilStateFaceDescriptor;
  81431. stencilReadMask?: number;
  81432. stencilWriteMask?: number;
  81433. }
  81434. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81435. extensions?: Iterable<GPUExtensionName>;
  81436. limits?: GPULimits;
  81437. }
  81438. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81439. initialValue?: number;
  81440. label?: string;
  81441. signalQueue?: GPUQueue;
  81442. }
  81443. interface GPUVertexAttributeDescriptor {
  81444. format: GPUVertexFormat;
  81445. offset: number;
  81446. shaderLocation: number;
  81447. }
  81448. interface GPUVertexBufferLayoutDescriptor {
  81449. arrayStride: number;
  81450. stepMode?: GPUInputStepMode;
  81451. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81452. }
  81453. interface GPUVertexStateDescriptor {
  81454. indexFormat?: GPUIndexFormat;
  81455. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81456. }
  81457. interface GPULimits {
  81458. maxBindGroups?: number;
  81459. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81460. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81461. maxSampledTexturesPerShaderStage?: number;
  81462. maxSamplersPerShaderStage?: number;
  81463. maxStorageBuffersPerShaderStage?: number;
  81464. maxStorageTexturesPerShaderStage?: number;
  81465. maxUniformBuffersPerShaderStage?: number;
  81466. maxUniformBufferBindingSize?: number;
  81467. }
  81468. interface GPUPipelineDescriptorBase {
  81469. label?: string;
  81470. layout?: GPUPipelineLayout;
  81471. }
  81472. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81473. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81474. }
  81475. interface GPUProgrammableStageDescriptor {
  81476. module: GPUShaderModule;
  81477. entryPoint: string;
  81478. }
  81479. interface GPURasterizationStateDescriptor {
  81480. frontFace?: GPUFrontFace;
  81481. cullMode?: GPUCullMode;
  81482. clampDepth?: boolean;
  81483. depthBias?: number;
  81484. depthBiasSlopeScale?: number;
  81485. depthBiasClamp?: number;
  81486. }
  81487. interface GPURenderPassColorAttachmentDescriptor {
  81488. attachment: GPUTextureView;
  81489. resolveTarget?: GPUTextureView;
  81490. loadValue: GPULoadOp | GPUColor;
  81491. storeOp?: GPUStoreOp;
  81492. }
  81493. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81494. attachment: GPUTextureView;
  81495. depthLoadValue: GPULoadOp | number;
  81496. depthStoreOp: GPUStoreOp;
  81497. depthReadOnly?: boolean;
  81498. stencilLoadValue: GPULoadOp | number;
  81499. stencilStoreOp: GPUStoreOp;
  81500. stencilReadOnly?: boolean;
  81501. }
  81502. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81503. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81504. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81505. }
  81506. interface GPURenderPipelineDescriptor
  81507. extends GPUPipelineDescriptorBase {
  81508. vertexStage: GPUProgrammableStageDescriptor;
  81509. fragmentStage?: GPUProgrammableStageDescriptor;
  81510. primitiveTopology: GPUPrimitiveTopology;
  81511. rasterizationState?: GPURasterizationStateDescriptor;
  81512. colorStates: Iterable<GPUColorStateDescriptor>;
  81513. depthStencilState?: GPUDepthStencilStateDescriptor;
  81514. vertexState?: GPUVertexStateDescriptor;
  81515. sampleCount?: number;
  81516. sampleMask?: number;
  81517. alphaToCoverageEnabled?: boolean;
  81518. }
  81519. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81520. addressModeU?: GPUAddressMode;
  81521. addressModeV?: GPUAddressMode;
  81522. addressModeW?: GPUAddressMode;
  81523. magFilter?: GPUFilterMode;
  81524. minFilter?: GPUFilterMode;
  81525. mipmapFilter?: GPUFilterMode;
  81526. lodMinClamp?: number;
  81527. lodMaxClamp?: number;
  81528. compare?: GPUCompareFunction;
  81529. maxAnisotropy?: number;
  81530. }
  81531. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81532. code: Uint32Array | string;
  81533. label?: string;
  81534. sourceMap?: object;
  81535. }
  81536. interface GPUStencilStateFaceDescriptor {
  81537. compare?: GPUCompareFunction;
  81538. depthFailOp?: GPUStencilOperation;
  81539. passOp?: GPUStencilOperation;
  81540. failOp?: GPUStencilOperation;
  81541. }
  81542. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81543. device: GPUDevice;
  81544. format: GPUTextureFormat;
  81545. usage?: GPUTextureUsageFlags;
  81546. }
  81547. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81548. size: GPUExtent3D;
  81549. mipLevelCount?: number;
  81550. sampleCount?: number;
  81551. dimension?: GPUTextureDimension;
  81552. format: GPUTextureFormat;
  81553. usage: GPUTextureUsageFlags;
  81554. }
  81555. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81556. format?: GPUTextureFormat;
  81557. dimension?: GPUTextureViewDimension;
  81558. aspect?: GPUTextureAspect;
  81559. baseArrayLayer?: number;
  81560. baseMipLevel?: number;
  81561. arrayLayerCount?: number;
  81562. mipLevelCount?: number;
  81563. }
  81564. declare class GPUAdapter {
  81565. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81566. private __brand: void;
  81567. readonly name: string;
  81568. readonly extensions: GPUExtensionName[];
  81569. readonly limits: Required<GPULimits>;
  81570. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81571. }
  81572. declare class GPUBindGroup implements GPUObjectBase {
  81573. private __brand: void;
  81574. label: string | undefined;
  81575. }
  81576. declare class GPUBindGroupLayout implements GPUObjectBase {
  81577. private __brand: void;
  81578. label: string | undefined;
  81579. }
  81580. declare class GPUBuffer implements GPUObjectBase {
  81581. private __brand: void;
  81582. label: string | undefined;
  81583. destroy(): void;
  81584. unmap(): void;
  81585. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81586. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81587. }
  81588. declare class GPUCommandBuffer implements GPUObjectBase {
  81589. private __brand: void;
  81590. label: string | undefined;
  81591. readonly executionTime: Promise<number>;
  81592. }
  81593. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81594. declare class GPUCommandEncoder implements GPUObjectBase {
  81595. private __brand: void;
  81596. label: string | undefined;
  81597. beginComputePass(
  81598. descriptor?: GPUComputePassDescriptor
  81599. ): GPUComputePassEncoder;
  81600. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81601. copyBufferToBuffer(
  81602. source: GPUBuffer,
  81603. sourceOffset: number,
  81604. destination: GPUBuffer,
  81605. destinationOffset: number,
  81606. size: number
  81607. ): void;
  81608. copyBufferToTexture(
  81609. source: GPUBufferCopyView,
  81610. destination: GPUTextureCopyView,
  81611. copySize: GPUExtent3D
  81612. ): void;
  81613. copyTextureToBuffer(
  81614. source: GPUTextureCopyView,
  81615. destination: GPUBufferCopyView,
  81616. copySize: GPUExtent3D
  81617. ): void;
  81618. copyTextureToTexture(
  81619. source: GPUTextureCopyView,
  81620. destination: GPUTextureCopyView,
  81621. copySize: GPUExtent3D
  81622. ): void;
  81623. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81624. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81625. popDebugGroup(): void;
  81626. pushDebugGroup(groupLabel: string): void;
  81627. insertDebugMarker(markerLabel: string): void;
  81628. }
  81629. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81630. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81631. private __brand: void;
  81632. label: string | undefined;
  81633. setBindGroup(
  81634. index: number,
  81635. bindGroup: GPUBindGroup,
  81636. dynamicOffsets?: Iterable<number>
  81637. ): void;
  81638. popDebugGroup(): void;
  81639. pushDebugGroup(groupLabel: string): void;
  81640. insertDebugMarker(markerLabel: string): void;
  81641. setPipeline(pipeline: GPUComputePipeline): void;
  81642. dispatch(x: number, y?: number, z?: number): void;
  81643. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81644. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81645. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81646. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81647. endPass(): void;
  81648. }
  81649. declare class GPUComputePipeline implements GPUPipelineBase {
  81650. private __brand: void;
  81651. label: string | undefined;
  81652. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81653. }
  81654. interface GPUObjectBase {
  81655. label: string | undefined;
  81656. }
  81657. interface GPUObjectDescriptorBase {
  81658. label?: string;
  81659. }
  81660. // SwapChain / CanvasContext
  81661. declare class GPUCanvasContext {
  81662. private __brand: void;
  81663. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81664. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81665. }
  81666. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81667. private __brand: void;
  81668. label: string | undefined;
  81669. readonly adapter: GPUAdapter;
  81670. readonly extensions: GPUExtensionName[];
  81671. readonly limits: Required<GPULimits>;
  81672. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81673. createBindGroupLayout(
  81674. descriptor: GPUBindGroupLayoutDescriptor
  81675. ): GPUBindGroupLayout;
  81676. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81677. createPipelineLayout(
  81678. descriptor: GPUPipelineLayoutDescriptor
  81679. ): GPUPipelineLayout;
  81680. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81681. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81682. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81683. createComputePipeline(
  81684. descriptor: GPUComputePipelineDescriptor
  81685. ): GPUComputePipeline;
  81686. createRenderPipeline(
  81687. descriptor: GPURenderPipelineDescriptor
  81688. ): GPURenderPipeline;
  81689. createReadyComputePipeline(
  81690. descriptor: GPUComputePipelineDescriptor
  81691. ): Promise<GPUComputePipeline>;
  81692. createReadyRenderPipeline(
  81693. descriptor: GPURenderPipelineDescriptor
  81694. ): Promise<GPURenderPipeline>;
  81695. createCommandEncoder(
  81696. descriptor?: GPUCommandEncoderDescriptor
  81697. ): GPUCommandEncoder;
  81698. createRenderBundleEncoder(
  81699. descriptor: GPURenderBundleEncoderDescriptor
  81700. ): GPURenderBundleEncoder;
  81701. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81702. defaultQueue: GPUQueue;
  81703. pushErrorScope(filter: GPUErrorFilter): void;
  81704. popErrorScope(): Promise<GPUError | null>;
  81705. onuncapturederror: Event | undefined;
  81706. readonly lost: Promise<GPUDeviceLostInfo>;
  81707. }
  81708. declare class GPUFence implements GPUObjectBase {
  81709. private __brand: void;
  81710. label: string | undefined;
  81711. getCompletedValue(): number;
  81712. onCompletion(completionValue: number): Promise<void>;
  81713. }
  81714. interface GPUPipelineBase extends GPUObjectBase {
  81715. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81716. }
  81717. declare class GPUPipelineLayout implements GPUObjectBase {
  81718. private __brand: void;
  81719. label: string | undefined;
  81720. }
  81721. interface GPUProgrammablePassEncoder {
  81722. setBindGroup(
  81723. index: number,
  81724. bindGroup: GPUBindGroup,
  81725. dynamicOffsets?: Iterable<number>
  81726. ): void;
  81727. popDebugGroup(): void;
  81728. pushDebugGroup(groupLabel: string): void;
  81729. insertDebugMarker(markerLabel: string): void;
  81730. }
  81731. declare class GPUQueue implements GPUObjectBase {
  81732. private __brand: void;
  81733. label: string | undefined;
  81734. signal(fence: GPUFence, signalValue: number): void;
  81735. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81736. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81737. writeBuffer(buffer: GPUBuffer,
  81738. bufferOffset: number,
  81739. data: BufferSource | ArrayBuffer,
  81740. dataOffset?: number,
  81741. size?: number): void;
  81742. writeTexture(destination: GPUTextureCopyView,
  81743. data: BufferSource | ArrayBuffer,
  81744. dataLayout: GPUTextureDataLayout,
  81745. size: GPUExtent3D): void;
  81746. copyImageBitmapToTexture(
  81747. source: GPUImageBitmapCopyView,
  81748. destination: GPUTextureCopyView,
  81749. copySize: GPUExtent3D
  81750. ): void;
  81751. }
  81752. type GPUQueryType =
  81753. | "occlusion"
  81754. | "timestamp"
  81755. | "pipeline-statistics";
  81756. type GPUPipelineStatisticName =
  81757. | "vertex-shader-invocations"
  81758. | "clipper-invocations"
  81759. | "clipper-primitives-out"
  81760. | "fragment-shader-invocations"
  81761. | "compute-shader-invocations";
  81762. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81763. type: GPUQueryType;
  81764. count: number;
  81765. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81766. }
  81767. declare class GPUQuerySet implements GPUObjectBase {
  81768. private __brand: void;
  81769. label: string | undefined;
  81770. destroy(): void;
  81771. }
  81772. interface GPURenderEncoderBase {
  81773. setPipeline(pipeline: GPURenderPipeline): void;
  81774. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81775. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81776. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81777. draw(
  81778. vertexCount: number,
  81779. instanceCount?: number,
  81780. firstVertex?: number,
  81781. firstInstance?: number
  81782. ): void;
  81783. drawIndexed(
  81784. indexCount: number,
  81785. instanceCount?: number,
  81786. firstIndex?: number,
  81787. baseVertex?: number,
  81788. firstInstance?: number
  81789. ): void;
  81790. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81791. drawIndexedIndirect(
  81792. indirectBuffer: GPUBuffer,
  81793. indirectOffset: number
  81794. ): void;
  81795. }
  81796. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81797. private __brand: void;
  81798. label: string | undefined;
  81799. setBindGroup(
  81800. index: number,
  81801. bindGroup: GPUBindGroup,
  81802. dynamicOffsets?: Iterable<number>
  81803. ): void;
  81804. popDebugGroup(): void;
  81805. pushDebugGroup(groupLabel: string): void;
  81806. insertDebugMarker(markerLabel: string): void;
  81807. setPipeline(pipeline: GPURenderPipeline): void;
  81808. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81809. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81810. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81811. draw(
  81812. vertexCount: number,
  81813. instanceCount?: number,
  81814. firstVertex?: number,
  81815. firstInstance?: number
  81816. ): void;
  81817. drawIndexed(
  81818. indexCount: number,
  81819. instanceCount?: number,
  81820. firstIndex?: number,
  81821. baseVertex?: number,
  81822. firstInstance?: number
  81823. ): void;
  81824. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81825. drawIndexedIndirect(
  81826. indirectBuffer: GPUBuffer,
  81827. indirectOffset: number
  81828. ): void;
  81829. setViewport(
  81830. x: number,
  81831. y: number,
  81832. width: number,
  81833. height: number,
  81834. minDepth: number,
  81835. maxDepth: number
  81836. ): void;
  81837. setScissorRect(x: number, y: number, width: number, height: number): void;
  81838. setBlendColor(color: GPUColor): void;
  81839. setStencilReference(reference: number): void;
  81840. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81841. beginOcclusionQuery(queryIndex: number): void;
  81842. endOcclusionQuery(): void;
  81843. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81844. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81845. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81846. endPass(): void;
  81847. }
  81848. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81849. declare class GPURenderBundle implements GPUObjectBase {
  81850. private __brand: void;
  81851. label: string | undefined;
  81852. }
  81853. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81854. private __brand: void;
  81855. label: string | undefined;
  81856. setBindGroup(
  81857. index: number,
  81858. bindGroup: GPUBindGroup,
  81859. dynamicOffsets?: Iterable<number>
  81860. ): void;
  81861. popDebugGroup(): void;
  81862. pushDebugGroup(groupLabel: string): void;
  81863. insertDebugMarker(markerLabel: string): void;
  81864. setPipeline(pipeline: GPURenderPipeline): void;
  81865. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81866. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81867. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81868. draw(
  81869. vertexCount: number,
  81870. instanceCount?: number,
  81871. firstVertex?: number,
  81872. firstInstance?: number
  81873. ): void;
  81874. drawIndexed(
  81875. indexCount: number,
  81876. instanceCount?: number,
  81877. firstIndex?: number,
  81878. baseVertex?: number,
  81879. firstInstance?: number
  81880. ): void;
  81881. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81882. drawIndexedIndirect(
  81883. indirectBuffer: GPUBuffer,
  81884. indirectOffset: number
  81885. ): void;
  81886. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81887. }
  81888. interface GPURenderBundleEncoderDescriptor
  81889. extends GPUObjectDescriptorBase {
  81890. colorFormats: Iterable<GPUTextureFormat>;
  81891. depthStencilFormat?: GPUTextureFormat;
  81892. sampleCount?: number;
  81893. }
  81894. declare class GPURenderPipeline implements GPUPipelineBase {
  81895. private __brand: void;
  81896. label: string | undefined;
  81897. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81898. }
  81899. declare class GPUSampler implements GPUObjectBase {
  81900. private __brand: void;
  81901. label: string | undefined;
  81902. }
  81903. type GPUCompilationMessageType =
  81904. | "error"
  81905. | "warning"
  81906. | "info";
  81907. interface GPUCompilationMessage {
  81908. readonly message: string;
  81909. readonly type: GPUCompilationMessageType;
  81910. readonly lineNum: number;
  81911. readonly linePos: number;
  81912. }
  81913. interface GPUCompilationInfo {
  81914. readonly messages: readonly GPUCompilationMessage[];
  81915. }
  81916. declare class GPUShaderModule implements GPUObjectBase {
  81917. private __brand: void;
  81918. label: string | undefined;
  81919. compilationInfo(): Promise<GPUCompilationInfo>;
  81920. }
  81921. declare class GPUSwapChain implements GPUObjectBase {
  81922. private __brand: void;
  81923. label: string | undefined;
  81924. getCurrentTexture(): GPUTexture;
  81925. }
  81926. declare class GPUTexture implements GPUObjectBase {
  81927. private __brand: void;
  81928. label: string | undefined;
  81929. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81930. destroy(): void;
  81931. }
  81932. declare class GPUTextureView implements GPUObjectBase {
  81933. private __brand: void;
  81934. label: string | undefined;
  81935. }
  81936. type GPUPowerPreference = "low-power" | "high-performance";
  81937. interface GPURequestAdapterOptions {
  81938. powerPreference?: GPUPowerPreference;
  81939. }
  81940. declare class GPU {
  81941. private __brand: void;
  81942. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81943. }
  81944. // ****************************************************************************
  81945. // ERROR SCOPES
  81946. // ****************************************************************************
  81947. type GPUErrorFilter = "out-of-memory" | "validation";
  81948. declare class GPUOutOfMemoryError {
  81949. private __brand: void;
  81950. constructor();
  81951. }
  81952. declare class GPUValidationError {
  81953. private __brand: void;
  81954. constructor(message: string);
  81955. readonly message: string;
  81956. }
  81957. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81958. // ****************************************************************************
  81959. // TELEMETRY
  81960. // ****************************************************************************
  81961. declare class GPUUncapturedErrorEvent extends Event {
  81962. private __brand: void;
  81963. constructor(
  81964. type: string,
  81965. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81966. );
  81967. readonly error: GPUError;
  81968. }
  81969. interface GPUUncapturedErrorEventInit extends EventInit {
  81970. error: GPUError;
  81971. }
  81972. declare class GPUDeviceLostInfo {
  81973. private __brand: void;
  81974. readonly message: string;
  81975. }
  81976. // Type definitions for WebVR API
  81977. // Project: https://w3c.github.io/webvr/
  81978. // Definitions by: six a <https://github.com/lostfictions>
  81979. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81980. interface VRDisplay extends EventTarget {
  81981. /**
  81982. * Dictionary of capabilities describing the VRDisplay.
  81983. */
  81984. readonly capabilities: VRDisplayCapabilities;
  81985. /**
  81986. * z-depth defining the far plane of the eye view frustum
  81987. * enables mapping of values in the render target depth
  81988. * attachment to scene coordinates. Initially set to 10000.0.
  81989. */
  81990. depthFar: number;
  81991. /**
  81992. * z-depth defining the near plane of the eye view frustum
  81993. * enables mapping of values in the render target depth
  81994. * attachment to scene coordinates. Initially set to 0.01.
  81995. */
  81996. depthNear: number;
  81997. /**
  81998. * An identifier for this distinct VRDisplay. Used as an
  81999. * association point in the Gamepad API.
  82000. */
  82001. readonly displayId: number;
  82002. /**
  82003. * A display name, a user-readable name identifying it.
  82004. */
  82005. readonly displayName: string;
  82006. readonly isConnected: boolean;
  82007. readonly isPresenting: boolean;
  82008. /**
  82009. * If this VRDisplay supports room-scale experiences, the optional
  82010. * stage attribute contains details on the room-scale parameters.
  82011. */
  82012. readonly stageParameters: VRStageParameters | null;
  82013. /**
  82014. * Passing the value returned by `requestAnimationFrame` to
  82015. * `cancelAnimationFrame` will unregister the callback.
  82016. * @param handle Define the hanle of the request to cancel
  82017. */
  82018. cancelAnimationFrame(handle: number): void;
  82019. /**
  82020. * Stops presenting to the VRDisplay.
  82021. * @returns a promise to know when it stopped
  82022. */
  82023. exitPresent(): Promise<void>;
  82024. /**
  82025. * Return the current VREyeParameters for the given eye.
  82026. * @param whichEye Define the eye we want the parameter for
  82027. * @returns the eye parameters
  82028. */
  82029. getEyeParameters(whichEye: string): VREyeParameters;
  82030. /**
  82031. * Populates the passed VRFrameData with the information required to render
  82032. * the current frame.
  82033. * @param frameData Define the data structure to populate
  82034. * @returns true if ok otherwise false
  82035. */
  82036. getFrameData(frameData: VRFrameData): boolean;
  82037. /**
  82038. * Get the layers currently being presented.
  82039. * @returns the list of VR layers
  82040. */
  82041. getLayers(): VRLayer[];
  82042. /**
  82043. * Return a VRPose containing the future predicted pose of the VRDisplay
  82044. * when the current frame will be presented. The value returned will not
  82045. * change until JavaScript has returned control to the browser.
  82046. *
  82047. * The VRPose will contain the position, orientation, velocity,
  82048. * and acceleration of each of these properties.
  82049. * @returns the pose object
  82050. */
  82051. getPose(): VRPose;
  82052. /**
  82053. * Return the current instantaneous pose of the VRDisplay, with no
  82054. * prediction applied.
  82055. * @returns the current instantaneous pose
  82056. */
  82057. getImmediatePose(): VRPose;
  82058. /**
  82059. * The callback passed to `requestAnimationFrame` will be called
  82060. * any time a new frame should be rendered. When the VRDisplay is
  82061. * presenting the callback will be called at the native refresh
  82062. * rate of the HMD. When not presenting this function acts
  82063. * identically to how window.requestAnimationFrame acts. Content should
  82064. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82065. * asynchronously from other displays and at differing refresh rates.
  82066. * @param callback Define the action to run next frame
  82067. * @returns the request handle it
  82068. */
  82069. requestAnimationFrame(callback: FrameRequestCallback): number;
  82070. /**
  82071. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82072. * Repeat calls while already presenting will update the VRLayers being displayed.
  82073. * @param layers Define the list of layer to present
  82074. * @returns a promise to know when the request has been fulfilled
  82075. */
  82076. requestPresent(layers: VRLayer[]): Promise<void>;
  82077. /**
  82078. * Reset the pose for this display, treating its current position and
  82079. * orientation as the "origin/zero" values. VRPose.position,
  82080. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82081. * updated when calling resetPose(). This should be called in only
  82082. * sitting-space experiences.
  82083. */
  82084. resetPose(): void;
  82085. /**
  82086. * The VRLayer provided to the VRDisplay will be captured and presented
  82087. * in the HMD. Calling this function has the same effect on the source
  82088. * canvas as any other operation that uses its source image, and canvases
  82089. * created without preserveDrawingBuffer set to true will be cleared.
  82090. * @param pose Define the pose to submit
  82091. */
  82092. submitFrame(pose?: VRPose): void;
  82093. }
  82094. declare var VRDisplay: {
  82095. prototype: VRDisplay;
  82096. new(): VRDisplay;
  82097. };
  82098. interface VRLayer {
  82099. leftBounds?: number[] | Float32Array | null;
  82100. rightBounds?: number[] | Float32Array | null;
  82101. source?: HTMLCanvasElement | null;
  82102. }
  82103. interface VRDisplayCapabilities {
  82104. readonly canPresent: boolean;
  82105. readonly hasExternalDisplay: boolean;
  82106. readonly hasOrientation: boolean;
  82107. readonly hasPosition: boolean;
  82108. readonly maxLayers: number;
  82109. }
  82110. interface VREyeParameters {
  82111. /** @deprecated */
  82112. readonly fieldOfView: VRFieldOfView;
  82113. readonly offset: Float32Array;
  82114. readonly renderHeight: number;
  82115. readonly renderWidth: number;
  82116. }
  82117. interface VRFieldOfView {
  82118. readonly downDegrees: number;
  82119. readonly leftDegrees: number;
  82120. readonly rightDegrees: number;
  82121. readonly upDegrees: number;
  82122. }
  82123. interface VRFrameData {
  82124. readonly leftProjectionMatrix: Float32Array;
  82125. readonly leftViewMatrix: Float32Array;
  82126. readonly pose: VRPose;
  82127. readonly rightProjectionMatrix: Float32Array;
  82128. readonly rightViewMatrix: Float32Array;
  82129. readonly timestamp: number;
  82130. }
  82131. interface VRPose {
  82132. readonly angularAcceleration: Float32Array | null;
  82133. readonly angularVelocity: Float32Array | null;
  82134. readonly linearAcceleration: Float32Array | null;
  82135. readonly linearVelocity: Float32Array | null;
  82136. readonly orientation: Float32Array | null;
  82137. readonly position: Float32Array | null;
  82138. readonly timestamp: number;
  82139. }
  82140. interface VRStageParameters {
  82141. sittingToStandingTransform?: Float32Array;
  82142. sizeX?: number;
  82143. sizeY?: number;
  82144. }
  82145. interface Navigator {
  82146. getVRDisplays(): Promise<VRDisplay[]>;
  82147. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82148. }
  82149. interface Window {
  82150. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82151. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82152. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82153. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82154. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82155. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82156. }
  82157. interface Gamepad {
  82158. readonly displayId: number;
  82159. }
  82160. /**
  82161. * Available session modes
  82162. */
  82163. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82164. /**
  82165. * Reference space types
  82166. */
  82167. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82168. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82169. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82170. /**
  82171. * Handedness types
  82172. */
  82173. type XRHandedness = "none" | "left" | "right";
  82174. /**
  82175. * InputSource target ray modes
  82176. */
  82177. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82178. /**
  82179. * Eye types
  82180. */
  82181. type XREye = "none" | "left" | "right";
  82182. /**
  82183. * Type of XR events available
  82184. */
  82185. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82186. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82187. type XRPlaneSet = Set<XRPlane>;
  82188. type XRAnchorSet = Set<XRAnchor>;
  82189. type XREventHandler = (callback: any) => void;
  82190. interface XRLayer extends EventTarget {}
  82191. interface XRSessionInit {
  82192. optionalFeatures?: string[];
  82193. requiredFeatures?: string[];
  82194. trackedImages?: XRTrackedImageInit[];
  82195. }
  82196. interface XRSessionEvent extends Event {
  82197. readonly session: XRSession;
  82198. }
  82199. interface XRSystem {
  82200. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82201. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82202. }
  82203. interface XRViewport {
  82204. readonly x: number;
  82205. readonly y: number;
  82206. readonly width: number;
  82207. readonly height: number;
  82208. }
  82209. interface XRWebGLLayerInit {
  82210. antialias?: boolean;
  82211. depth?: boolean;
  82212. stencil?: boolean;
  82213. alpha?: boolean;
  82214. multiview?: boolean;
  82215. framebufferScaleFactor?: number;
  82216. }
  82217. declare class XRWebGLLayer {
  82218. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82219. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82220. readonly antialias: boolean;
  82221. readonly framebuffer: WebGLFramebuffer;
  82222. readonly framebufferWidth: number;
  82223. readonly framebufferHeight: number;
  82224. readonly ignoreDepthValues: boolean;
  82225. getViewport: (view: XRView) => XRViewport;
  82226. }
  82227. // tslint:disable-next-line no-empty-interface
  82228. interface XRSpace extends EventTarget {}
  82229. interface XRRenderState {
  82230. readonly baseLayer?: XRWebGLLayer;
  82231. readonly depthFar: number;
  82232. readonly depthNear: number;
  82233. readonly inlineVerticalFieldOfView?: number;
  82234. }
  82235. interface XRRenderStateInit extends XRRenderState {
  82236. baseLayer: XRWebGLLayer;
  82237. depthFar: number;
  82238. depthNear: number;
  82239. inlineVerticalFieldOfView?: number;
  82240. layers?: XRLayer[];
  82241. }
  82242. interface XRReferenceSpace extends XRSpace {
  82243. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82244. onreset: XREventHandler;
  82245. }
  82246. interface XRBoundedReferenceSpace extends XRSpace {
  82247. readonly boundsGeometry: DOMPointReadOnly[];
  82248. }
  82249. interface XRInputSource {
  82250. readonly handedness: XRHandedness;
  82251. readonly targetRayMode: XRTargetRayMode;
  82252. readonly targetRaySpace: XRSpace;
  82253. readonly gripSpace?: XRSpace;
  82254. readonly gamepad?: Gamepad;
  82255. readonly profiles: Array<string>;
  82256. readonly hand?: XRHand;
  82257. }
  82258. interface XRPose {
  82259. readonly transform: XRRigidTransform;
  82260. readonly emulatedPosition: boolean;
  82261. }
  82262. interface XRWorldInformation {
  82263. detectedPlanes?: XRPlaneSet;
  82264. }
  82265. interface XRFrame {
  82266. readonly session: XRSession;
  82267. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82268. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82269. // AR
  82270. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82271. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82272. // Anchors
  82273. trackedAnchors?: XRAnchorSet;
  82274. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82275. // World geometries
  82276. worldInformation?: XRWorldInformation;
  82277. // Hand tracking
  82278. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82279. // Image tracking
  82280. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82281. }
  82282. interface XRInputSourceEvent extends Event {
  82283. readonly frame: XRFrame;
  82284. readonly inputSource: XRInputSource;
  82285. }
  82286. type XRInputSourceArray = XRInputSource[];
  82287. interface XRSession {
  82288. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82289. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82290. /**
  82291. * Returns a list of this session's XRInputSources, each representing an input device
  82292. * used to control the camera and/or scene.
  82293. */
  82294. readonly inputSources: Array<XRInputSource>;
  82295. /**
  82296. * object which contains options affecting how the imagery is rendered.
  82297. * This includes things such as the near and far clipping planes
  82298. */
  82299. readonly renderState: XRRenderState;
  82300. readonly visibilityState: XRVisibilityState;
  82301. /**
  82302. * Removes a callback from the animation frame painting callback from
  82303. * XRSession's set of animation frame rendering callbacks, given the
  82304. * identifying handle returned by a previous call to requestAnimationFrame().
  82305. */
  82306. cancelAnimationFrame: (handle: number) => void;
  82307. /**
  82308. * Ends the WebXR session. Returns a promise which resolves when the
  82309. * session has been shut down.
  82310. */
  82311. end(): Promise<void>;
  82312. /**
  82313. * Schedules the specified method to be called the next time the user agent
  82314. * is working on rendering an animation frame for the WebXR device. Returns an
  82315. * integer value which can be used to identify the request for the purposes of
  82316. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82317. * to the Window.requestAnimationFrame() method.
  82318. */
  82319. requestAnimationFrame: XRFrameRequestCallback;
  82320. /**
  82321. * Requests that a new XRReferenceSpace of the specified type be created.
  82322. * Returns a promise which resolves with the XRReferenceSpace or
  82323. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82324. * the requested space type isn't supported by the device.
  82325. */
  82326. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82327. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82328. onend: XREventHandler;
  82329. oninputsourceschange: XREventHandler;
  82330. onselect: XREventHandler;
  82331. onselectstart: XREventHandler;
  82332. onselectend: XREventHandler;
  82333. onsqueeze: XREventHandler;
  82334. onsqueezestart: XREventHandler;
  82335. onsqueezeend: XREventHandler;
  82336. onvisibilitychange: XREventHandler;
  82337. // hit test
  82338. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82339. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82340. // legacy AR hit test
  82341. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82342. // legacy plane detection
  82343. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82344. // image tracking
  82345. getTrackedImageScores?(): XRImageTrackingScore[];
  82346. }
  82347. interface XRViewerPose extends XRPose {
  82348. readonly views: Array<XRView>;
  82349. }
  82350. declare class XRRigidTransform {
  82351. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82352. position: DOMPointReadOnly;
  82353. orientation: DOMPointReadOnly;
  82354. matrix: Float32Array;
  82355. inverse: XRRigidTransform;
  82356. }
  82357. interface XRView {
  82358. readonly eye: XREye;
  82359. readonly projectionMatrix: Float32Array;
  82360. readonly transform: XRRigidTransform;
  82361. readonly recommendedViewportScale?: number;
  82362. requestViewportScale(scale: number): void;
  82363. }
  82364. interface XRInputSourceChangeEvent extends Event {
  82365. session: XRSession;
  82366. removed: Array<XRInputSource>;
  82367. added: Array<XRInputSource>;
  82368. }
  82369. // Experimental/Draft features
  82370. declare class XRRay {
  82371. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82372. origin: DOMPointReadOnly;
  82373. direction: DOMPointReadOnly;
  82374. matrix: Float32Array;
  82375. }
  82376. declare enum XRHitTestTrackableType {
  82377. "point",
  82378. "plane",
  82379. "mesh",
  82380. }
  82381. interface XRHitResult {
  82382. hitMatrix: Float32Array;
  82383. }
  82384. interface XRTransientInputHitTestResult {
  82385. readonly inputSource: XRInputSource;
  82386. readonly results: Array<XRHitTestResult>;
  82387. }
  82388. interface XRHitTestResult {
  82389. getPose(baseSpace: XRSpace): XRPose | undefined;
  82390. // When anchor system is enabled
  82391. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82392. }
  82393. interface XRHitTestSource {
  82394. cancel(): void;
  82395. }
  82396. interface XRTransientInputHitTestSource {
  82397. cancel(): void;
  82398. }
  82399. interface XRHitTestOptionsInit {
  82400. space: XRSpace;
  82401. entityTypes?: Array<XRHitTestTrackableType>;
  82402. offsetRay?: XRRay;
  82403. }
  82404. interface XRTransientInputHitTestOptionsInit {
  82405. profile: string;
  82406. entityTypes?: Array<XRHitTestTrackableType>;
  82407. offsetRay?: XRRay;
  82408. }
  82409. interface XRAnchor {
  82410. anchorSpace: XRSpace;
  82411. delete(): void;
  82412. }
  82413. interface XRPlane {
  82414. orientation: "Horizontal" | "Vertical";
  82415. planeSpace: XRSpace;
  82416. polygon: Array<DOMPointReadOnly>;
  82417. lastChangedTime: number;
  82418. }
  82419. interface XRJointSpace extends XRSpace {}
  82420. interface XRJointPose extends XRPose {
  82421. radius: number | undefined;
  82422. }
  82423. interface XRHand extends Iterable<XRJointSpace> {
  82424. readonly length: number;
  82425. [index: number]: XRJointSpace;
  82426. readonly WRIST: number;
  82427. readonly THUMB_METACARPAL: number;
  82428. readonly THUMB_PHALANX_PROXIMAL: number;
  82429. readonly THUMB_PHALANX_DISTAL: number;
  82430. readonly THUMB_PHALANX_TIP: number;
  82431. readonly INDEX_METACARPAL: number;
  82432. readonly INDEX_PHALANX_PROXIMAL: number;
  82433. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82434. readonly INDEX_PHALANX_DISTAL: number;
  82435. readonly INDEX_PHALANX_TIP: number;
  82436. readonly MIDDLE_METACARPAL: number;
  82437. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82438. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82439. readonly MIDDLE_PHALANX_DISTAL: number;
  82440. readonly MIDDLE_PHALANX_TIP: number;
  82441. readonly RING_METACARPAL: number;
  82442. readonly RING_PHALANX_PROXIMAL: number;
  82443. readonly RING_PHALANX_INTERMEDIATE: number;
  82444. readonly RING_PHALANX_DISTAL: number;
  82445. readonly RING_PHALANX_TIP: number;
  82446. readonly LITTLE_METACARPAL: number;
  82447. readonly LITTLE_PHALANX_PROXIMAL: number;
  82448. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82449. readonly LITTLE_PHALANX_DISTAL: number;
  82450. readonly LITTLE_PHALANX_TIP: number;
  82451. }
  82452. type XRImageTrackingState = "tracked" | "emulated";
  82453. type XRImageTrackingScore = "untrackable" | "trackable";
  82454. interface XRTrackedImageInit {
  82455. image: ImageBitmap;
  82456. widthInMeters: number;
  82457. }
  82458. interface XRImageTrackingResult {
  82459. readonly imageSpace: XRSpace;
  82460. readonly index: number;
  82461. readonly trackingState: XRImageTrackingState;
  82462. readonly measuredWidthInMeters: number;
  82463. }
  82464. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82465. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82466. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82467. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82468. interface XRSceneObject {
  82469. type: XRSceneObjectType;
  82470. }
  82471. interface XRFieldOfView {
  82472. angleLeft: number;
  82473. angleRight: number;
  82474. angleUp: number;
  82475. angleDown: number;
  82476. }
  82477. interface XRFrustum {
  82478. position: DOMPointReadOnly;
  82479. orientation: DOMPointReadOnly;
  82480. fieldOfView: XRFieldOfView;
  82481. farDistance: number;
  82482. }
  82483. interface XRPlane {
  82484. parentSceneObject?: XRSceneObject;
  82485. }
  82486. interface XRMesh {
  82487. meshSpace: XRSpace;
  82488. positions: Float32Array;
  82489. indices: Uint32Array;
  82490. normals?: Float32Array;
  82491. lastChangedTime: number;
  82492. parentSceneObject?: XRSceneObject;
  82493. }
  82494. interface XRFrustumDetectionBoundary {
  82495. type: "frustum";
  82496. frustum: XRFrustum;
  82497. }
  82498. interface XRSphereDetectionBoundary {
  82499. type: "sphere";
  82500. radius: number;
  82501. }
  82502. interface XRBoxDetectionBoundary {
  82503. type: "box";
  82504. extent: DOMPointReadOnly;
  82505. }
  82506. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82507. interface XRGeometryDetectorOptions {
  82508. detectionBoundary?: XRDetectionBoundary;
  82509. updateInterval?: number;
  82510. }
  82511. interface XRSession {
  82512. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82513. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82514. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82515. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82516. }
  82517. interface XRFrame {
  82518. featurePointCloud?: Array<number>;
  82519. }
  82520. type XRMeshSet = Set<XRMesh>;
  82521. interface XRWorldInformation {
  82522. detectedMeshes?: XRMeshSet;
  82523. }
  82524. /**
  82525. * @ignore
  82526. */
  82527. declare module BABYLON.GLTF2.Exporter {
  82528. }
  82529. /**
  82530. * @ignore
  82531. */
  82532. declare module BABYLON.GLTF1 {
  82533. }
  82534. declare module BABYLON.GUI {
  82535. /**
  82536. * Interface used to define a control that can receive focus
  82537. */
  82538. export interface IFocusableControl {
  82539. /**
  82540. * Function called when the control receives the focus
  82541. */
  82542. onFocus(): void;
  82543. /**
  82544. * Function called when the control loses the focus
  82545. */
  82546. onBlur(): void;
  82547. /**
  82548. * Function called to let the control handle keyboard events
  82549. * @param evt defines the current keyboard event
  82550. */
  82551. processKeyboard(evt: KeyboardEvent): void;
  82552. /**
  82553. * Function called to get the list of controls that should not steal the focus from this control
  82554. * @returns an array of controls
  82555. */
  82556. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82557. /**
  82558. * Function to focus the control programmatically
  82559. */
  82560. focus(): void;
  82561. /**
  82562. * Function to unfocus the control programmatically
  82563. */
  82564. blur(): void;
  82565. }
  82566. }
  82567. declare module BABYLON.GUI {
  82568. /**
  82569. * Class used to specific a value and its associated unit
  82570. */
  82571. export class ValueAndUnit {
  82572. /** defines the unit to store */
  82573. unit: number;
  82574. /** defines a boolean indicating if the value can be negative */
  82575. negativeValueAllowed: boolean;
  82576. private _value;
  82577. private _originalUnit;
  82578. /**
  82579. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82580. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82581. */
  82582. ignoreAdaptiveScaling: boolean;
  82583. /**
  82584. * Creates a new ValueAndUnit
  82585. * @param value defines the value to store
  82586. * @param unit defines the unit to store
  82587. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82588. */
  82589. constructor(value: number,
  82590. /** defines the unit to store */
  82591. unit?: number,
  82592. /** defines a boolean indicating if the value can be negative */
  82593. negativeValueAllowed?: boolean);
  82594. /** Gets a boolean indicating if the value is a percentage */
  82595. get isPercentage(): boolean;
  82596. /** Gets a boolean indicating if the value is store as pixel */
  82597. get isPixel(): boolean;
  82598. /** Gets direct internal value */
  82599. get internalValue(): number;
  82600. /**
  82601. * Gets value as pixel
  82602. * @param host defines the root host
  82603. * @param refValue defines the reference value for percentages
  82604. * @returns the value as pixel
  82605. */
  82606. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82607. /**
  82608. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82609. * @param value defines the value to store
  82610. * @param unit defines the unit to store
  82611. * @returns the current ValueAndUnit
  82612. */
  82613. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82614. /**
  82615. * Gets the value accordingly to its unit
  82616. * @param host defines the root host
  82617. * @returns the value
  82618. */
  82619. getValue(host: AdvancedDynamicTexture): number;
  82620. /**
  82621. * Gets a string representation of the value
  82622. * @param host defines the root host
  82623. * @param decimals defines an optional number of decimals to display
  82624. * @returns a string
  82625. */
  82626. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82627. /**
  82628. * Store a value parsed from a string
  82629. * @param source defines the source string
  82630. * @returns true if the value was successfully parsed
  82631. */
  82632. fromString(source: string | number): boolean;
  82633. private static _Regex;
  82634. private static _UNITMODE_PERCENTAGE;
  82635. private static _UNITMODE_PIXEL;
  82636. /** UNITMODE_PERCENTAGE */
  82637. static get UNITMODE_PERCENTAGE(): number;
  82638. /** UNITMODE_PIXEL */
  82639. static get UNITMODE_PIXEL(): number;
  82640. }
  82641. }
  82642. declare module BABYLON.GUI {
  82643. /**
  82644. * Define a style used by control to automatically setup properties based on a template.
  82645. * Only support font related properties so far
  82646. */
  82647. export class Style implements BABYLON.IDisposable {
  82648. private _fontFamily;
  82649. private _fontStyle;
  82650. private _fontWeight;
  82651. /** @hidden */
  82652. _host: AdvancedDynamicTexture;
  82653. /** @hidden */
  82654. _fontSize: ValueAndUnit;
  82655. /**
  82656. * BABYLON.Observable raised when the style values are changed
  82657. */
  82658. onChangedObservable: BABYLON.Observable<Style>;
  82659. /**
  82660. * Creates a new style object
  82661. * @param host defines the AdvancedDynamicTexture which hosts this style
  82662. */
  82663. constructor(host: AdvancedDynamicTexture);
  82664. /**
  82665. * Gets or sets the font size
  82666. */
  82667. get fontSize(): string | number;
  82668. set fontSize(value: string | number);
  82669. /**
  82670. * Gets or sets the font family
  82671. */
  82672. get fontFamily(): string;
  82673. set fontFamily(value: string);
  82674. /**
  82675. * Gets or sets the font style
  82676. */
  82677. get fontStyle(): string;
  82678. set fontStyle(value: string);
  82679. /** Gets or sets font weight */
  82680. get fontWeight(): string;
  82681. set fontWeight(value: string);
  82682. /** Dispose all associated resources */
  82683. dispose(): void;
  82684. }
  82685. }
  82686. declare module BABYLON.GUI {
  82687. /**
  82688. * Class used to transport BABYLON.Vector2 information for pointer events
  82689. */
  82690. export class Vector2WithInfo extends BABYLON.Vector2 {
  82691. /** defines the current mouse button index */
  82692. buttonIndex: number;
  82693. /**
  82694. * Creates a new Vector2WithInfo
  82695. * @param source defines the vector2 data to transport
  82696. * @param buttonIndex defines the current mouse button index
  82697. */
  82698. constructor(source: BABYLON.Vector2,
  82699. /** defines the current mouse button index */
  82700. buttonIndex?: number);
  82701. }
  82702. /** Class used to provide 2D matrix features */
  82703. export class Matrix2D {
  82704. /** Gets the internal array of 6 floats used to store matrix data */
  82705. m: Float32Array;
  82706. /**
  82707. * Creates a new matrix
  82708. * @param m00 defines value for (0, 0)
  82709. * @param m01 defines value for (0, 1)
  82710. * @param m10 defines value for (1, 0)
  82711. * @param m11 defines value for (1, 1)
  82712. * @param m20 defines value for (2, 0)
  82713. * @param m21 defines value for (2, 1)
  82714. */
  82715. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82716. /**
  82717. * Fills the matrix from direct values
  82718. * @param m00 defines value for (0, 0)
  82719. * @param m01 defines value for (0, 1)
  82720. * @param m10 defines value for (1, 0)
  82721. * @param m11 defines value for (1, 1)
  82722. * @param m20 defines value for (2, 0)
  82723. * @param m21 defines value for (2, 1)
  82724. * @returns the current modified matrix
  82725. */
  82726. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82727. /**
  82728. * Gets matrix determinant
  82729. * @returns the determinant
  82730. */
  82731. determinant(): number;
  82732. /**
  82733. * Inverses the matrix and stores it in a target matrix
  82734. * @param result defines the target matrix
  82735. * @returns the current matrix
  82736. */
  82737. invertToRef(result: Matrix2D): Matrix2D;
  82738. /**
  82739. * Multiplies the current matrix with another one
  82740. * @param other defines the second operand
  82741. * @param result defines the target matrix
  82742. * @returns the current matrix
  82743. */
  82744. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82745. /**
  82746. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82747. * @param x defines the x coordinate to transform
  82748. * @param y defines the x coordinate to transform
  82749. * @param result defines the target vector2
  82750. * @returns the current matrix
  82751. */
  82752. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82753. /**
  82754. * Creates an identity matrix
  82755. * @returns a new matrix
  82756. */
  82757. static Identity(): Matrix2D;
  82758. /**
  82759. * Creates a translation matrix and stores it in a target matrix
  82760. * @param x defines the x coordinate of the translation
  82761. * @param y defines the y coordinate of the translation
  82762. * @param result defines the target matrix
  82763. */
  82764. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82765. /**
  82766. * Creates a scaling matrix and stores it in a target matrix
  82767. * @param x defines the x coordinate of the scaling
  82768. * @param y defines the y coordinate of the scaling
  82769. * @param result defines the target matrix
  82770. */
  82771. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82772. /**
  82773. * Creates a rotation matrix and stores it in a target matrix
  82774. * @param angle defines the rotation angle
  82775. * @param result defines the target matrix
  82776. */
  82777. static RotationToRef(angle: number, result: Matrix2D): void;
  82778. private static _TempPreTranslationMatrix;
  82779. private static _TempPostTranslationMatrix;
  82780. private static _TempRotationMatrix;
  82781. private static _TempScalingMatrix;
  82782. private static _TempCompose0;
  82783. private static _TempCompose1;
  82784. private static _TempCompose2;
  82785. /**
  82786. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82787. * @param tx defines the x coordinate of the translation
  82788. * @param ty defines the y coordinate of the translation
  82789. * @param angle defines the rotation angle
  82790. * @param scaleX defines the x coordinate of the scaling
  82791. * @param scaleY defines the y coordinate of the scaling
  82792. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82793. * @param result defines the target matrix
  82794. */
  82795. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82796. }
  82797. }
  82798. declare module BABYLON.GUI {
  82799. /**
  82800. * Class used to store 2D control sizes
  82801. */
  82802. export class Measure {
  82803. /** defines left coordinate */
  82804. left: number;
  82805. /** defines top coordinate */
  82806. top: number;
  82807. /** defines width dimension */
  82808. width: number;
  82809. /** defines height dimension */
  82810. height: number;
  82811. /**
  82812. * Creates a new measure
  82813. * @param left defines left coordinate
  82814. * @param top defines top coordinate
  82815. * @param width defines width dimension
  82816. * @param height defines height dimension
  82817. */
  82818. constructor(
  82819. /** defines left coordinate */
  82820. left: number,
  82821. /** defines top coordinate */
  82822. top: number,
  82823. /** defines width dimension */
  82824. width: number,
  82825. /** defines height dimension */
  82826. height: number);
  82827. /**
  82828. * Copy from another measure
  82829. * @param other defines the other measure to copy from
  82830. */
  82831. copyFrom(other: Measure): void;
  82832. /**
  82833. * Copy from a group of 4 floats
  82834. * @param left defines left coordinate
  82835. * @param top defines top coordinate
  82836. * @param width defines width dimension
  82837. * @param height defines height dimension
  82838. */
  82839. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82840. /**
  82841. * Computes the axis aligned bounding box measure for two given measures
  82842. * @param a Input measure
  82843. * @param b Input measure
  82844. * @param result the resulting bounding measure
  82845. */
  82846. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82847. /**
  82848. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82849. * @param transform the matrix to transform the measure before computing the AABB
  82850. * @param addX number to add to left
  82851. * @param addY number to add to top
  82852. * @param addWidth number to add to width
  82853. * @param addHeight number to add to height
  82854. * @param result the resulting AABB
  82855. */
  82856. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82857. /**
  82858. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82859. * @param transform the matrix to transform the measure before computing the AABB
  82860. * @param result the resulting AABB
  82861. */
  82862. transformToRef(transform: Matrix2D, result: Measure): void;
  82863. /**
  82864. * Check equality between this measure and another one
  82865. * @param other defines the other measures
  82866. * @returns true if both measures are equals
  82867. */
  82868. isEqualsTo(other: Measure): boolean;
  82869. /**
  82870. * Creates an empty measure
  82871. * @returns a new measure
  82872. */
  82873. static Empty(): Measure;
  82874. }
  82875. }
  82876. declare module BABYLON.GUI {
  82877. /**
  82878. * Class used to create texture to support 2D GUI elements
  82879. * @see https://doc.babylonjs.com/how_to/gui
  82880. */
  82881. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82882. /** Define the Uurl to load snippets */
  82883. static SnippetUrl: string;
  82884. /** Snippet ID if the content was created from the snippet server */
  82885. snippetId: string;
  82886. private _isDirty;
  82887. private _renderObserver;
  82888. private _resizeObserver;
  82889. private _preKeyboardObserver;
  82890. private _pointerMoveObserver;
  82891. private _pointerObserver;
  82892. private _canvasPointerOutObserver;
  82893. private _canvasBlurObserver;
  82894. private _background;
  82895. /** @hidden */
  82896. _rootContainer: Container;
  82897. /** @hidden */
  82898. _lastPickedControl: Control;
  82899. /** @hidden */
  82900. _lastControlOver: {
  82901. [pointerId: number]: Control;
  82902. };
  82903. /** @hidden */
  82904. _lastControlDown: {
  82905. [pointerId: number]: Control;
  82906. };
  82907. /** @hidden */
  82908. _capturingControl: {
  82909. [pointerId: number]: Control;
  82910. };
  82911. /** @hidden */
  82912. _shouldBlockPointer: boolean;
  82913. /** @hidden */
  82914. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82915. /** @hidden */
  82916. _linkedControls: Control[];
  82917. private _isFullscreen;
  82918. private _fullscreenViewport;
  82919. private _idealWidth;
  82920. private _idealHeight;
  82921. private _useSmallestIdeal;
  82922. private _renderAtIdealSize;
  82923. private _focusedControl;
  82924. private _blockNextFocusCheck;
  82925. private _renderScale;
  82926. private _rootElement;
  82927. private _cursorChanged;
  82928. private _defaultMousePointerId;
  82929. /** @hidden */
  82930. _numLayoutCalls: number;
  82931. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82932. get numLayoutCalls(): number;
  82933. /** @hidden */
  82934. _numRenderCalls: number;
  82935. /** Gets the number of render calls made the last time the ADT has been rendered */
  82936. get numRenderCalls(): number;
  82937. /**
  82938. * Define type to string to ensure compatibility across browsers
  82939. * Safari doesn't support DataTransfer constructor
  82940. */
  82941. private _clipboardData;
  82942. /**
  82943. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82944. */
  82945. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82946. /**
  82947. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82948. */
  82949. onControlPickedObservable: BABYLON.Observable<Control>;
  82950. /**
  82951. * BABYLON.Observable event triggered before layout is evaluated
  82952. */
  82953. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82954. /**
  82955. * BABYLON.Observable event triggered after the layout was evaluated
  82956. */
  82957. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82958. /**
  82959. * BABYLON.Observable event triggered before the texture is rendered
  82960. */
  82961. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82962. /**
  82963. * BABYLON.Observable event triggered after the texture was rendered
  82964. */
  82965. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82966. /**
  82967. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82968. */
  82969. premulAlpha: boolean;
  82970. /**
  82971. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82972. */
  82973. applyYInversionOnUpdate: boolean;
  82974. /**
  82975. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82976. * Useful when you want more antialiasing
  82977. */
  82978. get renderScale(): number;
  82979. set renderScale(value: number);
  82980. /** Gets or sets the background color */
  82981. get background(): string;
  82982. set background(value: string);
  82983. /**
  82984. * Gets or sets the ideal width used to design controls.
  82985. * The GUI will then rescale everything accordingly
  82986. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82987. */
  82988. get idealWidth(): number;
  82989. set idealWidth(value: number);
  82990. /**
  82991. * Gets or sets the ideal height used to design controls.
  82992. * The GUI will then rescale everything accordingly
  82993. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82994. */
  82995. get idealHeight(): number;
  82996. set idealHeight(value: number);
  82997. /**
  82998. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82999. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83000. */
  83001. get useSmallestIdeal(): boolean;
  83002. set useSmallestIdeal(value: boolean);
  83003. /**
  83004. * Gets or sets a boolean indicating if adaptive scaling must be used
  83005. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83006. */
  83007. get renderAtIdealSize(): boolean;
  83008. set renderAtIdealSize(value: boolean);
  83009. /**
  83010. * Gets the ratio used when in "ideal mode"
  83011. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  83012. * */
  83013. get idealRatio(): number;
  83014. /**
  83015. * Gets the underlying layer used to render the texture when in fullscreen mode
  83016. */
  83017. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  83018. /**
  83019. * Gets the root container control
  83020. */
  83021. get rootContainer(): Container;
  83022. /**
  83023. * Returns an array containing the root container.
  83024. * This is mostly used to let the Inspector introspects the ADT
  83025. * @returns an array containing the rootContainer
  83026. */
  83027. getChildren(): Array<Container>;
  83028. /**
  83029. * Will return all controls that are inside this texture
  83030. * @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
  83031. * @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
  83032. * @return all child controls
  83033. */
  83034. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83035. /**
  83036. * Gets or sets the current focused control
  83037. */
  83038. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83039. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83040. /**
  83041. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83042. */
  83043. get isForeground(): boolean;
  83044. set isForeground(value: boolean);
  83045. /**
  83046. * Gets or set information about clipboardData
  83047. */
  83048. get clipboardData(): string;
  83049. set clipboardData(value: string);
  83050. /**
  83051. * Creates a new AdvancedDynamicTexture
  83052. * @param name defines the name of the texture
  83053. * @param width defines the width of the texture
  83054. * @param height defines the height of the texture
  83055. * @param scene defines the hosting scene
  83056. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83057. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83058. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83059. */
  83060. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83061. /**
  83062. * Get the current class name of the texture useful for serialization or dynamic coding.
  83063. * @returns "AdvancedDynamicTexture"
  83064. */
  83065. getClassName(): string;
  83066. /**
  83067. * Function used to execute a function on all controls
  83068. * @param func defines the function to execute
  83069. * @param container defines the container where controls belong. If null the root container will be used
  83070. */
  83071. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83072. private _useInvalidateRectOptimization;
  83073. /**
  83074. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83075. */
  83076. get useInvalidateRectOptimization(): boolean;
  83077. set useInvalidateRectOptimization(value: boolean);
  83078. private _invalidatedRectangle;
  83079. /**
  83080. * Invalidates a rectangle area on the gui texture
  83081. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83082. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83083. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83084. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83085. */
  83086. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83087. /**
  83088. * Marks the texture as dirty forcing a complete update
  83089. */
  83090. markAsDirty(): void;
  83091. /**
  83092. * Helper function used to create a new style
  83093. * @returns a new style
  83094. * @see https://doc.babylonjs.com/how_to/gui#styles
  83095. */
  83096. createStyle(): Style;
  83097. /**
  83098. * Adds a new control to the root container
  83099. * @param control defines the control to add
  83100. * @returns the current texture
  83101. */
  83102. addControl(control: Control): AdvancedDynamicTexture;
  83103. /**
  83104. * Removes a control from the root container
  83105. * @param control defines the control to remove
  83106. * @returns the current texture
  83107. */
  83108. removeControl(control: Control): AdvancedDynamicTexture;
  83109. /**
  83110. * Release all resources
  83111. */
  83112. dispose(): void;
  83113. private _onResize;
  83114. /** @hidden */
  83115. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83116. /**
  83117. * Get screen coordinates for a vector3
  83118. * @param position defines the position to project
  83119. * @param worldMatrix defines the world matrix to use
  83120. * @returns the projected position
  83121. */
  83122. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83123. /**
  83124. * Get screen coordinates for a vector3
  83125. * @param position defines the position to project
  83126. * @param worldMatrix defines the world matrix to use
  83127. * @returns the projected position with Z
  83128. */
  83129. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83130. private _checkUpdate;
  83131. private _clearMeasure;
  83132. private _render;
  83133. /** @hidden */
  83134. _changeCursor(cursor: string): void;
  83135. /** @hidden */
  83136. _registerLastControlDown(control: Control, pointerId: number): void;
  83137. private _doPicking;
  83138. /** @hidden */
  83139. _cleanControlAfterRemovalFromList(list: {
  83140. [pointerId: number]: Control;
  83141. }, control: Control): void;
  83142. /** @hidden */
  83143. _cleanControlAfterRemoval(control: Control): void;
  83144. /** Attach to all scene events required to support pointer events */
  83145. attach(): void;
  83146. /** @hidden */
  83147. private onClipboardCopy;
  83148. /** @hidden */
  83149. private onClipboardCut;
  83150. /** @hidden */
  83151. private onClipboardPaste;
  83152. /**
  83153. * Register the clipboard Events onto the canvas
  83154. */
  83155. registerClipboardEvents(): void;
  83156. /**
  83157. * Unregister the clipboard Events from the canvas
  83158. */
  83159. unRegisterClipboardEvents(): void;
  83160. /**
  83161. * Connect the texture to a hosting mesh to enable interactions
  83162. * @param mesh defines the mesh to attach to
  83163. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83164. */
  83165. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83166. /**
  83167. * Move the focus to a specific control
  83168. * @param control defines the control which will receive the focus
  83169. */
  83170. moveFocusToControl(control: IFocusableControl): void;
  83171. private _manageFocus;
  83172. private _attachToOnPointerOut;
  83173. private _attachToOnBlur;
  83174. /**
  83175. * Serializes the entire GUI system
  83176. * @returns an object with the JSON serialized data
  83177. */
  83178. serializeContent(): any;
  83179. /**
  83180. * Recreate the content of the ADT from a JSON object
  83181. * @param serializedObject define the JSON serialized object to restore from
  83182. */
  83183. parseContent(serializedObject: any): void;
  83184. /**
  83185. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83186. * @param snippetId defines the snippet to load
  83187. * @returns a promise that will resolve on success
  83188. */
  83189. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83190. /**
  83191. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83192. * @param mesh defines the mesh which will receive the texture
  83193. * @param width defines the texture width (1024 by default)
  83194. * @param height defines the texture height (1024 by default)
  83195. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83196. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83197. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83198. * @returns a new AdvancedDynamicTexture
  83199. */
  83200. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83201. /**
  83202. * 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
  83203. * @param mesh defines the mesh which will receive the texture
  83204. * @param width defines the texture width (1024 by default)
  83205. * @param height defines the texture height (1024 by default)
  83206. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83207. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83208. * @returns a new AdvancedDynamicTexture
  83209. */
  83210. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83211. /**
  83212. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83213. * In this mode the texture will rely on a layer for its rendering.
  83214. * This allows it to be treated like any other layer.
  83215. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83216. * LayerMask is set through advancedTexture.layer.layerMask
  83217. * @param name defines name for the texture
  83218. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83219. * @param scene defines the hsoting scene
  83220. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83221. * @returns a new AdvancedDynamicTexture
  83222. */
  83223. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83224. }
  83225. }
  83226. declare module BABYLON.GUI {
  83227. /**
  83228. * Root class used for all 2D controls
  83229. * @see https://doc.babylonjs.com/how_to/gui#controls
  83230. */
  83231. export class Control {
  83232. /** defines the name of the control */
  83233. name?: string | undefined;
  83234. /**
  83235. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83236. */
  83237. static AllowAlphaInheritance: boolean;
  83238. private _alpha;
  83239. private _alphaSet;
  83240. private _zIndex;
  83241. /** @hidden */
  83242. _host: AdvancedDynamicTexture;
  83243. /** Gets or sets the control parent */
  83244. parent: BABYLON.Nullable<Container>;
  83245. /** @hidden */
  83246. _currentMeasure: Measure;
  83247. private _fontFamily;
  83248. private _fontStyle;
  83249. private _fontWeight;
  83250. private _fontSize;
  83251. private _font;
  83252. /** @hidden */
  83253. _width: ValueAndUnit;
  83254. /** @hidden */
  83255. _height: ValueAndUnit;
  83256. /** @hidden */
  83257. protected _fontOffset: {
  83258. ascent: number;
  83259. height: number;
  83260. descent: number;
  83261. };
  83262. private _color;
  83263. private _style;
  83264. private _styleObserver;
  83265. /** @hidden */
  83266. protected _horizontalAlignment: number;
  83267. /** @hidden */
  83268. protected _verticalAlignment: number;
  83269. /** @hidden */
  83270. protected _isDirty: boolean;
  83271. /** @hidden */
  83272. protected _wasDirty: boolean;
  83273. /** @hidden */
  83274. _tempParentMeasure: Measure;
  83275. /** @hidden */
  83276. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83277. /** @hidden */
  83278. protected _cachedParentMeasure: Measure;
  83279. private _paddingLeft;
  83280. private _paddingRight;
  83281. private _paddingTop;
  83282. private _paddingBottom;
  83283. /** @hidden */
  83284. _left: ValueAndUnit;
  83285. /** @hidden */
  83286. _top: ValueAndUnit;
  83287. private _scaleX;
  83288. private _scaleY;
  83289. private _rotation;
  83290. private _transformCenterX;
  83291. private _transformCenterY;
  83292. /** @hidden */
  83293. _transformMatrix: Matrix2D;
  83294. /** @hidden */
  83295. protected _invertTransformMatrix: Matrix2D;
  83296. /** @hidden */
  83297. protected _transformedPosition: BABYLON.Vector2;
  83298. private _isMatrixDirty;
  83299. private _cachedOffsetX;
  83300. private _cachedOffsetY;
  83301. private _isVisible;
  83302. private _isHighlighted;
  83303. /** @hidden */
  83304. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83305. private _fontSet;
  83306. private _dummyVector2;
  83307. private _downCount;
  83308. private _enterCount;
  83309. private _doNotRender;
  83310. private _downPointerIds;
  83311. protected _isEnabled: boolean;
  83312. protected _disabledColor: string;
  83313. protected _disabledColorItem: string;
  83314. /** @hidden */
  83315. protected _rebuildLayout: boolean;
  83316. /** @hidden */
  83317. _customData: any;
  83318. /** @hidden */
  83319. _isClipped: boolean;
  83320. /** @hidden */
  83321. _automaticSize: boolean;
  83322. /** @hidden */
  83323. _tag: any;
  83324. /**
  83325. * 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
  83326. */
  83327. uniqueId: number;
  83328. /**
  83329. * Gets or sets an object used to store user defined information for the node
  83330. */
  83331. metadata: any;
  83332. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83333. isHitTestVisible: boolean;
  83334. /** Gets or sets a boolean indicating if the control can block pointer events */
  83335. isPointerBlocker: boolean;
  83336. /** Gets or sets a boolean indicating if the control can be focusable */
  83337. isFocusInvisible: boolean;
  83338. /**
  83339. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83340. * 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
  83341. */
  83342. clipChildren: boolean;
  83343. /**
  83344. * Gets or sets a boolean indicating that control content must be clipped
  83345. * 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
  83346. */
  83347. clipContent: boolean;
  83348. /**
  83349. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83350. */
  83351. useBitmapCache: boolean;
  83352. private _cacheData;
  83353. private _shadowOffsetX;
  83354. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83355. get shadowOffsetX(): number;
  83356. set shadowOffsetX(value: number);
  83357. private _shadowOffsetY;
  83358. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83359. get shadowOffsetY(): number;
  83360. set shadowOffsetY(value: number);
  83361. private _shadowBlur;
  83362. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83363. get shadowBlur(): number;
  83364. set shadowBlur(value: number);
  83365. private _shadowColor;
  83366. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83367. get shadowColor(): string;
  83368. set shadowColor(value: string);
  83369. /** Gets or sets the cursor to use when the control is hovered */
  83370. hoverCursor: string;
  83371. /** @hidden */
  83372. protected _linkOffsetX: ValueAndUnit;
  83373. /** @hidden */
  83374. protected _linkOffsetY: ValueAndUnit;
  83375. /** Gets the control type name */
  83376. get typeName(): string;
  83377. /**
  83378. * Get the current class name of the control.
  83379. * @returns current class name
  83380. */
  83381. getClassName(): string;
  83382. /**
  83383. * An event triggered when pointer wheel is scrolled
  83384. */
  83385. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83386. /**
  83387. * An event triggered when the pointer move over the control.
  83388. */
  83389. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83390. /**
  83391. * An event triggered when the pointer move out of the control.
  83392. */
  83393. onPointerOutObservable: BABYLON.Observable<Control>;
  83394. /**
  83395. * An event triggered when the pointer taps the control
  83396. */
  83397. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83398. /**
  83399. * An event triggered when pointer up
  83400. */
  83401. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83402. /**
  83403. * An event triggered when a control is clicked on
  83404. */
  83405. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83406. /**
  83407. * An event triggered when pointer enters the control
  83408. */
  83409. onPointerEnterObservable: BABYLON.Observable<Control>;
  83410. /**
  83411. * An event triggered when the control is marked as dirty
  83412. */
  83413. onDirtyObservable: BABYLON.Observable<Control>;
  83414. /**
  83415. * An event triggered before drawing the control
  83416. */
  83417. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83418. /**
  83419. * An event triggered after the control was drawn
  83420. */
  83421. onAfterDrawObservable: BABYLON.Observable<Control>;
  83422. /**
  83423. * An event triggered when the control has been disposed
  83424. */
  83425. onDisposeObservable: BABYLON.Observable<Control>;
  83426. /**
  83427. * Get the hosting AdvancedDynamicTexture
  83428. */
  83429. get host(): AdvancedDynamicTexture;
  83430. /** Gets or set information about font offsets (used to render and align text) */
  83431. get fontOffset(): {
  83432. ascent: number;
  83433. height: number;
  83434. descent: number;
  83435. };
  83436. set fontOffset(offset: {
  83437. ascent: number;
  83438. height: number;
  83439. descent: number;
  83440. });
  83441. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83442. get alpha(): number;
  83443. set alpha(value: number);
  83444. /**
  83445. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83446. */
  83447. get isHighlighted(): boolean;
  83448. set isHighlighted(value: boolean);
  83449. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83450. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83451. */
  83452. get scaleX(): number;
  83453. set scaleX(value: number);
  83454. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83455. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83456. */
  83457. get scaleY(): number;
  83458. set scaleY(value: number);
  83459. /** Gets or sets the rotation angle (0 by default)
  83460. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83461. */
  83462. get rotation(): number;
  83463. set rotation(value: number);
  83464. /** Gets or sets the transformation center on Y axis (0 by default)
  83465. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83466. */
  83467. get transformCenterY(): number;
  83468. set transformCenterY(value: number);
  83469. /** Gets or sets the transformation center on X axis (0 by default)
  83470. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83471. */
  83472. get transformCenterX(): number;
  83473. set transformCenterX(value: number);
  83474. /**
  83475. * Gets or sets the horizontal alignment
  83476. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83477. */
  83478. get horizontalAlignment(): number;
  83479. set horizontalAlignment(value: number);
  83480. /**
  83481. * Gets or sets the vertical alignment
  83482. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83483. */
  83484. get verticalAlignment(): number;
  83485. set verticalAlignment(value: number);
  83486. /**
  83487. * Gets or sets a fixed ratio for this control.
  83488. * When different from 0, the ratio is used to compute the "second" dimension.
  83489. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83490. * second dimension is computed as first dimension * fixedRatio
  83491. */
  83492. fixedRatio: number;
  83493. private _fixedRatioMasterIsWidth;
  83494. /**
  83495. * Gets or sets control width
  83496. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83497. */
  83498. get width(): string | number;
  83499. set width(value: string | number);
  83500. /**
  83501. * Gets or sets the control width in pixel
  83502. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83503. */
  83504. get widthInPixels(): number;
  83505. set widthInPixels(value: number);
  83506. /**
  83507. * Gets or sets control height
  83508. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83509. */
  83510. get height(): string | number;
  83511. set height(value: string | number);
  83512. /**
  83513. * Gets or sets control height in pixel
  83514. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83515. */
  83516. get heightInPixels(): number;
  83517. set heightInPixels(value: number);
  83518. /** Gets or set font family */
  83519. get fontFamily(): string;
  83520. set fontFamily(value: string);
  83521. /** Gets or sets font style */
  83522. get fontStyle(): string;
  83523. set fontStyle(value: string);
  83524. /** Gets or sets font weight */
  83525. get fontWeight(): string;
  83526. set fontWeight(value: string);
  83527. /**
  83528. * Gets or sets style
  83529. * @see https://doc.babylonjs.com/how_to/gui#styles
  83530. */
  83531. get style(): BABYLON.Nullable<Style>;
  83532. set style(value: BABYLON.Nullable<Style>);
  83533. /** @hidden */
  83534. get _isFontSizeInPercentage(): boolean;
  83535. /** Gets or sets font size in pixels */
  83536. get fontSizeInPixels(): number;
  83537. set fontSizeInPixels(value: number);
  83538. /** Gets or sets font size */
  83539. get fontSize(): string | number;
  83540. set fontSize(value: string | number);
  83541. /** Gets or sets foreground color */
  83542. get color(): string;
  83543. set color(value: string);
  83544. /** Gets or sets z index which is used to reorder controls on the z axis */
  83545. get zIndex(): number;
  83546. set zIndex(value: number);
  83547. /** Gets or sets a boolean indicating if the control can be rendered */
  83548. get notRenderable(): boolean;
  83549. set notRenderable(value: boolean);
  83550. /** Gets or sets a boolean indicating if the control is visible */
  83551. get isVisible(): boolean;
  83552. set isVisible(value: boolean);
  83553. /** Gets a boolean indicating that the control needs to update its rendering */
  83554. get isDirty(): boolean;
  83555. /**
  83556. * Gets the current linked mesh (or null if none)
  83557. */
  83558. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83559. /**
  83560. * Gets or sets a value indicating the padding to use on the left of the control
  83561. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83562. */
  83563. get paddingLeft(): string | number;
  83564. set paddingLeft(value: string | number);
  83565. /**
  83566. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83567. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83568. */
  83569. get paddingLeftInPixels(): number;
  83570. set paddingLeftInPixels(value: number);
  83571. /**
  83572. * Gets or sets a value indicating the padding to use on the right of the control
  83573. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83574. */
  83575. get paddingRight(): string | number;
  83576. set paddingRight(value: string | number);
  83577. /**
  83578. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83579. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83580. */
  83581. get paddingRightInPixels(): number;
  83582. set paddingRightInPixels(value: number);
  83583. /**
  83584. * Gets or sets a value indicating the padding to use on the top of the control
  83585. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83586. */
  83587. get paddingTop(): string | number;
  83588. set paddingTop(value: string | number);
  83589. /**
  83590. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83591. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83592. */
  83593. get paddingTopInPixels(): number;
  83594. set paddingTopInPixels(value: number);
  83595. /**
  83596. * Gets or sets a value indicating the padding to use on the bottom of the control
  83597. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83598. */
  83599. get paddingBottom(): string | number;
  83600. set paddingBottom(value: string | number);
  83601. /**
  83602. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83603. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83604. */
  83605. get paddingBottomInPixels(): number;
  83606. set paddingBottomInPixels(value: number);
  83607. /**
  83608. * Gets or sets a value indicating the left coordinate of the control
  83609. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83610. */
  83611. get left(): string | number;
  83612. set left(value: string | number);
  83613. /**
  83614. * Gets or sets a value indicating the left coordinate in pixels of the control
  83615. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83616. */
  83617. get leftInPixels(): number;
  83618. set leftInPixels(value: number);
  83619. /**
  83620. * Gets or sets a value indicating the top coordinate of the control
  83621. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83622. */
  83623. get top(): string | number;
  83624. set top(value: string | number);
  83625. /**
  83626. * Gets or sets a value indicating the top coordinate in pixels of the control
  83627. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83628. */
  83629. get topInPixels(): number;
  83630. set topInPixels(value: number);
  83631. /**
  83632. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83633. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83634. */
  83635. get linkOffsetX(): string | number;
  83636. set linkOffsetX(value: string | number);
  83637. /**
  83638. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83639. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83640. */
  83641. get linkOffsetXInPixels(): number;
  83642. set linkOffsetXInPixels(value: number);
  83643. /**
  83644. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83645. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83646. */
  83647. get linkOffsetY(): string | number;
  83648. set linkOffsetY(value: string | number);
  83649. /**
  83650. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83651. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83652. */
  83653. get linkOffsetYInPixels(): number;
  83654. set linkOffsetYInPixels(value: number);
  83655. /** Gets the center coordinate on X axis */
  83656. get centerX(): number;
  83657. /** Gets the center coordinate on Y axis */
  83658. get centerY(): number;
  83659. /** Gets or sets if control is Enabled */
  83660. get isEnabled(): boolean;
  83661. set isEnabled(value: boolean);
  83662. /** Gets or sets background color of control if it's disabled */
  83663. get disabledColor(): string;
  83664. set disabledColor(value: string);
  83665. /** Gets or sets front color of control if it's disabled */
  83666. get disabledColorItem(): string;
  83667. set disabledColorItem(value: string);
  83668. /**
  83669. * Creates a new control
  83670. * @param name defines the name of the control
  83671. */
  83672. constructor(
  83673. /** defines the name of the control */
  83674. name?: string | undefined);
  83675. /** @hidden */
  83676. protected _getTypeName(): string;
  83677. /**
  83678. * Gets the first ascendant in the hierarchy of the given type
  83679. * @param className defines the required type
  83680. * @returns the ascendant or null if not found
  83681. */
  83682. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83683. /** @hidden */
  83684. _resetFontCache(): void;
  83685. /**
  83686. * Determines if a container is an ascendant of the current control
  83687. * @param container defines the container to look for
  83688. * @returns true if the container is one of the ascendant of the control
  83689. */
  83690. isAscendant(container: Control): boolean;
  83691. /**
  83692. * Gets coordinates in local control space
  83693. * @param globalCoordinates defines the coordinates to transform
  83694. * @returns the new coordinates in local space
  83695. */
  83696. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83697. /**
  83698. * Gets coordinates in local control space
  83699. * @param globalCoordinates defines the coordinates to transform
  83700. * @param result defines the target vector2 where to store the result
  83701. * @returns the current control
  83702. */
  83703. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83704. /**
  83705. * Gets coordinates in parent local control space
  83706. * @param globalCoordinates defines the coordinates to transform
  83707. * @returns the new coordinates in parent local space
  83708. */
  83709. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83710. /**
  83711. * Move the current control to a vector3 position projected onto the screen.
  83712. * @param position defines the target position
  83713. * @param scene defines the hosting scene
  83714. */
  83715. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83716. /**
  83717. * Will store all controls that have this control as ascendant in a given array
  83718. * @param results defines the array where to store the descendants
  83719. * @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
  83720. * @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
  83721. */
  83722. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83723. /**
  83724. * Will return all controls that have this control as ascendant
  83725. * @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
  83726. * @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
  83727. * @return all child controls
  83728. */
  83729. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83730. /**
  83731. * Link current control with a target mesh
  83732. * @param mesh defines the mesh to link with
  83733. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83734. */
  83735. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83736. /**
  83737. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83738. * @param { string | number} paddingTop - The value of the top padding.
  83739. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83740. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83741. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83742. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83743. */
  83744. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83745. /**
  83746. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83747. * @param { number} paddingTop - The value in pixels of the top padding.
  83748. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83749. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83750. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83751. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83752. */
  83753. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83754. /** @hidden */
  83755. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83756. /** @hidden */
  83757. _offsetLeft(offset: number): void;
  83758. /** @hidden */
  83759. _offsetTop(offset: number): void;
  83760. /** @hidden */
  83761. _markMatrixAsDirty(): void;
  83762. /** @hidden */
  83763. _flagDescendantsAsMatrixDirty(): void;
  83764. /** @hidden */
  83765. _intersectsRect(rect: Measure): boolean;
  83766. /** @hidden */
  83767. protected invalidateRect(): void;
  83768. /** @hidden */
  83769. _markAsDirty(force?: boolean): void;
  83770. /** @hidden */
  83771. _markAllAsDirty(): void;
  83772. /** @hidden */
  83773. _link(host: AdvancedDynamicTexture): void;
  83774. /** @hidden */
  83775. protected _transform(context?: CanvasRenderingContext2D): void;
  83776. /** @hidden */
  83777. _renderHighlight(context: CanvasRenderingContext2D): void;
  83778. /** @hidden */
  83779. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83780. /** @hidden */
  83781. protected _applyStates(context: CanvasRenderingContext2D): void;
  83782. /** @hidden */
  83783. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83784. /** @hidden */
  83785. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83786. protected _evaluateClippingState(parentMeasure: Measure): void;
  83787. /** @hidden */
  83788. _measure(): void;
  83789. /** @hidden */
  83790. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83791. /** @hidden */
  83792. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83793. /** @hidden */
  83794. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83795. /** @hidden */
  83796. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83797. private static _ClipMeasure;
  83798. private _tmpMeasureA;
  83799. private _clip;
  83800. /** @hidden */
  83801. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83802. /** @hidden */
  83803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83804. /**
  83805. * Tests if a given coordinates belong to the current control
  83806. * @param x defines x coordinate to test
  83807. * @param y defines y coordinate to test
  83808. * @returns true if the coordinates are inside the control
  83809. */
  83810. contains(x: number, y: number): boolean;
  83811. /** @hidden */
  83812. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83813. /** @hidden */
  83814. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83815. /** @hidden */
  83816. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83817. /** @hidden */
  83818. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83819. /** @hidden */
  83820. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83821. /** @hidden */
  83822. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83823. /** @hidden */
  83824. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83825. /** @hidden */
  83826. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83827. /** @hidden */
  83828. _onCanvasBlur(): void;
  83829. /** @hidden */
  83830. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83831. private _prepareFont;
  83832. /**
  83833. * Serializes the current control
  83834. * @param serializationObject defined the JSON serialized object
  83835. */
  83836. serialize(serializationObject: any): void;
  83837. /** @hidden */
  83838. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83839. /** Releases associated resources */
  83840. dispose(): void;
  83841. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83842. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83843. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83844. private static _VERTICAL_ALIGNMENT_TOP;
  83845. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83846. private static _VERTICAL_ALIGNMENT_CENTER;
  83847. /** HORIZONTAL_ALIGNMENT_LEFT */
  83848. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83849. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83850. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83851. /** HORIZONTAL_ALIGNMENT_CENTER */
  83852. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83853. /** VERTICAL_ALIGNMENT_TOP */
  83854. static get VERTICAL_ALIGNMENT_TOP(): number;
  83855. /** VERTICAL_ALIGNMENT_BOTTOM */
  83856. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83857. /** VERTICAL_ALIGNMENT_CENTER */
  83858. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83859. private static _FontHeightSizes;
  83860. /** @hidden */
  83861. static _GetFontOffset(font: string): {
  83862. ascent: number;
  83863. height: number;
  83864. descent: number;
  83865. };
  83866. /**
  83867. * Creates a Control from parsed data
  83868. * @param serializedObject defines parsed data
  83869. * @param host defines the hosting AdvancedDynamicTexture
  83870. * @returns a new Control
  83871. */
  83872. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83873. /**
  83874. * Creates a stack panel that can be used to render headers
  83875. * @param control defines the control to associate with the header
  83876. * @param text defines the text of the header
  83877. * @param size defines the size of the header
  83878. * @param options defines options used to configure the header
  83879. * @returns a new StackPanel
  83880. * @ignore
  83881. * @hidden
  83882. */
  83883. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83884. isHorizontal: boolean;
  83885. controlFirst: boolean;
  83886. }) => any;
  83887. /** @hidden */
  83888. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83889. }
  83890. }
  83891. declare module BABYLON.GUI {
  83892. /**
  83893. * Root class for 2D containers
  83894. * @see https://doc.babylonjs.com/how_to/gui#containers
  83895. */
  83896. export class Container extends Control {
  83897. name?: string | undefined;
  83898. /** @hidden */
  83899. _children: Control[];
  83900. /** @hidden */
  83901. protected _measureForChildren: Measure;
  83902. /** @hidden */
  83903. protected _background: string;
  83904. /** @hidden */
  83905. protected _adaptWidthToChildren: boolean;
  83906. /** @hidden */
  83907. protected _adaptHeightToChildren: boolean;
  83908. /**
  83909. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83910. */
  83911. logLayoutCycleErrors: boolean;
  83912. /**
  83913. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83914. */
  83915. maxLayoutCycle: number;
  83916. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83917. get adaptHeightToChildren(): boolean;
  83918. set adaptHeightToChildren(value: boolean);
  83919. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83920. get adaptWidthToChildren(): boolean;
  83921. set adaptWidthToChildren(value: boolean);
  83922. /** Gets or sets background color */
  83923. get background(): string;
  83924. set background(value: string);
  83925. /** Gets the list of children */
  83926. get children(): Control[];
  83927. /**
  83928. * Creates a new Container
  83929. * @param name defines the name of the container
  83930. */
  83931. constructor(name?: string | undefined);
  83932. protected _getTypeName(): string;
  83933. _flagDescendantsAsMatrixDirty(): void;
  83934. /**
  83935. * Gets a child using its name
  83936. * @param name defines the child name to look for
  83937. * @returns the child control if found
  83938. */
  83939. getChildByName(name: string): BABYLON.Nullable<Control>;
  83940. /**
  83941. * Gets a child using its type and its name
  83942. * @param name defines the child name to look for
  83943. * @param type defines the child type to look for
  83944. * @returns the child control if found
  83945. */
  83946. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83947. /**
  83948. * Search for a specific control in children
  83949. * @param control defines the control to look for
  83950. * @returns true if the control is in child list
  83951. */
  83952. containsControl(control: Control): boolean;
  83953. /**
  83954. * Adds a new control to the current container
  83955. * @param control defines the control to add
  83956. * @returns the current container
  83957. */
  83958. addControl(control: BABYLON.Nullable<Control>): Container;
  83959. /**
  83960. * Removes all controls from the current container
  83961. * @returns the current container
  83962. */
  83963. clearControls(): Container;
  83964. /**
  83965. * Removes a control from the current container
  83966. * @param control defines the control to remove
  83967. * @returns the current container
  83968. */
  83969. removeControl(control: Control): Container;
  83970. /** @hidden */
  83971. _reOrderControl(control: Control): void;
  83972. /** @hidden */
  83973. _offsetLeft(offset: number): void;
  83974. /** @hidden */
  83975. _offsetTop(offset: number): void;
  83976. /** @hidden */
  83977. _markAllAsDirty(): void;
  83978. /** @hidden */
  83979. protected _localDraw(context: CanvasRenderingContext2D): void;
  83980. /** @hidden */
  83981. _link(host: AdvancedDynamicTexture): void;
  83982. /** @hidden */
  83983. protected _beforeLayout(): void;
  83984. /** @hidden */
  83985. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83986. /** @hidden */
  83987. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83988. protected _postMeasure(): void;
  83989. /** @hidden */
  83990. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83991. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83992. /** @hidden */
  83993. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83994. /** @hidden */
  83995. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83996. /**
  83997. * Serializes the current control
  83998. * @param serializationObject defined the JSON serialized object
  83999. */
  84000. serialize(serializationObject: any): void;
  84001. /** Releases associated resources */
  84002. dispose(): void;
  84003. /** @hidden */
  84004. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84005. }
  84006. }
  84007. declare module BABYLON.GUI {
  84008. /** Class used to create rectangle container */
  84009. export class Rectangle extends Container {
  84010. name?: string | undefined;
  84011. private _thickness;
  84012. private _cornerRadius;
  84013. /** Gets or sets border thickness */
  84014. get thickness(): number;
  84015. set thickness(value: number);
  84016. /** Gets or sets the corner radius angle */
  84017. get cornerRadius(): number;
  84018. set cornerRadius(value: number);
  84019. /**
  84020. * Creates a new Rectangle
  84021. * @param name defines the control name
  84022. */
  84023. constructor(name?: string | undefined);
  84024. protected _getTypeName(): string;
  84025. protected _localDraw(context: CanvasRenderingContext2D): void;
  84026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84027. private _drawRoundedRect;
  84028. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84029. }
  84030. }
  84031. declare module BABYLON.GUI {
  84032. /**
  84033. * Enum that determines the text-wrapping mode to use.
  84034. */
  84035. export enum TextWrapping {
  84036. /**
  84037. * Clip the text when it's larger than Control.width; this is the default mode.
  84038. */
  84039. Clip = 0,
  84040. /**
  84041. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84042. */
  84043. WordWrap = 1,
  84044. /**
  84045. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84046. */
  84047. Ellipsis = 2
  84048. }
  84049. /**
  84050. * Class used to create text block control
  84051. */
  84052. export class TextBlock extends Control {
  84053. /**
  84054. * Defines the name of the control
  84055. */
  84056. name?: string | undefined;
  84057. private _text;
  84058. private _textWrapping;
  84059. private _textHorizontalAlignment;
  84060. private _textVerticalAlignment;
  84061. private _lines;
  84062. private _resizeToFit;
  84063. private _lineSpacing;
  84064. private _outlineWidth;
  84065. private _outlineColor;
  84066. private _underline;
  84067. private _lineThrough;
  84068. /**
  84069. * An event triggered after the text is changed
  84070. */
  84071. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84072. /**
  84073. * An event triggered after the text was broken up into lines
  84074. */
  84075. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84076. /**
  84077. * Function used to split a string into words. By default, a string is split at each space character found
  84078. */
  84079. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84080. /**
  84081. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84082. */
  84083. get lines(): any[];
  84084. /**
  84085. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84086. */
  84087. get resizeToFit(): boolean;
  84088. /**
  84089. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84090. */
  84091. set resizeToFit(value: boolean);
  84092. /**
  84093. * Gets or sets a boolean indicating if text must be wrapped
  84094. */
  84095. get textWrapping(): TextWrapping | boolean;
  84096. /**
  84097. * Gets or sets a boolean indicating if text must be wrapped
  84098. */
  84099. set textWrapping(value: TextWrapping | boolean);
  84100. /**
  84101. * Gets or sets text to display
  84102. */
  84103. get text(): string;
  84104. /**
  84105. * Gets or sets text to display
  84106. */
  84107. set text(value: string);
  84108. /**
  84109. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84110. */
  84111. get textHorizontalAlignment(): number;
  84112. /**
  84113. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84114. */
  84115. set textHorizontalAlignment(value: number);
  84116. /**
  84117. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84118. */
  84119. get textVerticalAlignment(): number;
  84120. /**
  84121. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84122. */
  84123. set textVerticalAlignment(value: number);
  84124. /**
  84125. * Gets or sets line spacing value
  84126. */
  84127. set lineSpacing(value: string | number);
  84128. /**
  84129. * Gets or sets line spacing value
  84130. */
  84131. get lineSpacing(): string | number;
  84132. /**
  84133. * Gets or sets outlineWidth of the text to display
  84134. */
  84135. get outlineWidth(): number;
  84136. /**
  84137. * Gets or sets outlineWidth of the text to display
  84138. */
  84139. set outlineWidth(value: number);
  84140. /**
  84141. * Gets or sets a boolean indicating that text must have underline
  84142. */
  84143. get underline(): boolean;
  84144. /**
  84145. * Gets or sets a boolean indicating that text must have underline
  84146. */
  84147. set underline(value: boolean);
  84148. /**
  84149. * Gets or sets an boolean indicating that text must be crossed out
  84150. */
  84151. get lineThrough(): boolean;
  84152. /**
  84153. * Gets or sets an boolean indicating that text must be crossed out
  84154. */
  84155. set lineThrough(value: boolean);
  84156. /**
  84157. * Gets or sets outlineColor of the text to display
  84158. */
  84159. get outlineColor(): string;
  84160. /**
  84161. * Gets or sets outlineColor of the text to display
  84162. */
  84163. set outlineColor(value: string);
  84164. /**
  84165. * Creates a new TextBlock object
  84166. * @param name defines the name of the control
  84167. * @param text defines the text to display (emptry string by default)
  84168. */
  84169. constructor(
  84170. /**
  84171. * Defines the name of the control
  84172. */
  84173. name?: string | undefined, text?: string);
  84174. protected _getTypeName(): string;
  84175. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84176. private _drawText;
  84177. /** @hidden */
  84178. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84179. protected _applyStates(context: CanvasRenderingContext2D): void;
  84180. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84181. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84182. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84183. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84184. protected _renderLines(context: CanvasRenderingContext2D): void;
  84185. /**
  84186. * Given a width constraint applied on the text block, find the expected height
  84187. * @returns expected height
  84188. */
  84189. computeExpectedHeight(): number;
  84190. dispose(): void;
  84191. }
  84192. }
  84193. declare module BABYLON.GUI {
  84194. /**
  84195. * Class used to create 2D images
  84196. */
  84197. export class Image extends Control {
  84198. name?: string | undefined;
  84199. private _workingCanvas;
  84200. private _domImage;
  84201. private _imageWidth;
  84202. private _imageHeight;
  84203. private _loaded;
  84204. private _stretch;
  84205. private _source;
  84206. private _autoScale;
  84207. private _sourceLeft;
  84208. private _sourceTop;
  84209. private _sourceWidth;
  84210. private _sourceHeight;
  84211. private _svgAttributesComputationCompleted;
  84212. private _isSVG;
  84213. private _cellWidth;
  84214. private _cellHeight;
  84215. private _cellId;
  84216. private _populateNinePatchSlicesFromImage;
  84217. private _sliceLeft;
  84218. private _sliceRight;
  84219. private _sliceTop;
  84220. private _sliceBottom;
  84221. private _detectPointerOnOpaqueOnly;
  84222. private _imageDataCache;
  84223. /**
  84224. * BABYLON.Observable notified when the content is loaded
  84225. */
  84226. onImageLoadedObservable: BABYLON.Observable<Image>;
  84227. /**
  84228. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84229. */
  84230. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84231. /**
  84232. * Gets a boolean indicating that the content is loaded
  84233. */
  84234. get isLoaded(): boolean;
  84235. /**
  84236. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84237. */
  84238. get populateNinePatchSlicesFromImage(): boolean;
  84239. set populateNinePatchSlicesFromImage(value: boolean);
  84240. /**
  84241. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84242. * Beware using this as this will comsume more memory as the image has to be stored twice
  84243. */
  84244. get detectPointerOnOpaqueOnly(): boolean;
  84245. set detectPointerOnOpaqueOnly(value: boolean);
  84246. /**
  84247. * Gets or sets the left value for slicing (9-patch)
  84248. */
  84249. get sliceLeft(): number;
  84250. set sliceLeft(value: number);
  84251. /**
  84252. * Gets or sets the right value for slicing (9-patch)
  84253. */
  84254. get sliceRight(): number;
  84255. set sliceRight(value: number);
  84256. /**
  84257. * Gets or sets the top value for slicing (9-patch)
  84258. */
  84259. get sliceTop(): number;
  84260. set sliceTop(value: number);
  84261. /**
  84262. * Gets or sets the bottom value for slicing (9-patch)
  84263. */
  84264. get sliceBottom(): number;
  84265. set sliceBottom(value: number);
  84266. /**
  84267. * Gets or sets the left coordinate in the source image
  84268. */
  84269. get sourceLeft(): number;
  84270. set sourceLeft(value: number);
  84271. /**
  84272. * Gets or sets the top coordinate in the source image
  84273. */
  84274. get sourceTop(): number;
  84275. set sourceTop(value: number);
  84276. /**
  84277. * Gets or sets the width to capture in the source image
  84278. */
  84279. get sourceWidth(): number;
  84280. set sourceWidth(value: number);
  84281. /**
  84282. * Gets or sets the height to capture in the source image
  84283. */
  84284. get sourceHeight(): number;
  84285. set sourceHeight(value: number);
  84286. /** Indicates if the format of the image is SVG */
  84287. get isSVG(): boolean;
  84288. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84289. get svgAttributesComputationCompleted(): boolean;
  84290. /**
  84291. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84292. * @see https://doc.babylonjs.com/how_to/gui#image
  84293. */
  84294. get autoScale(): boolean;
  84295. set autoScale(value: boolean);
  84296. /** Gets or sets the streching mode used by the image */
  84297. get stretch(): number;
  84298. set stretch(value: number);
  84299. /** @hidden */
  84300. _rotate90(n: number, preserveProperties?: boolean): Image;
  84301. private _handleRotationForSVGImage;
  84302. private _rotate90SourceProperties;
  84303. /**
  84304. * Gets or sets the internal DOM image used to render the control
  84305. */
  84306. set domImage(value: HTMLImageElement);
  84307. get domImage(): HTMLImageElement;
  84308. private _onImageLoaded;
  84309. private _extractNinePatchSliceDataFromImage;
  84310. /**
  84311. * Gets the image source url
  84312. */
  84313. get source(): BABYLON.Nullable<string>;
  84314. /**
  84315. * Gets or sets image source url
  84316. */
  84317. set source(value: BABYLON.Nullable<string>);
  84318. /**
  84319. * Checks for svg document with icon id present
  84320. */
  84321. private _svgCheck;
  84322. /**
  84323. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84324. * given external svg file and icon id
  84325. */
  84326. private _getSVGAttribs;
  84327. /**
  84328. * Gets or sets the cell width to use when animation sheet is enabled
  84329. * @see https://doc.babylonjs.com/how_to/gui#image
  84330. */
  84331. get cellWidth(): number;
  84332. set cellWidth(value: number);
  84333. /**
  84334. * Gets or sets the cell height to use when animation sheet is enabled
  84335. * @see https://doc.babylonjs.com/how_to/gui#image
  84336. */
  84337. get cellHeight(): number;
  84338. set cellHeight(value: number);
  84339. /**
  84340. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84341. * @see https://doc.babylonjs.com/how_to/gui#image
  84342. */
  84343. get cellId(): number;
  84344. set cellId(value: number);
  84345. /**
  84346. * Creates a new Image
  84347. * @param name defines the control name
  84348. * @param url defines the image url
  84349. */
  84350. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84351. /**
  84352. * Tests if a given coordinates belong to the current control
  84353. * @param x defines x coordinate to test
  84354. * @param y defines y coordinate to test
  84355. * @returns true if the coordinates are inside the control
  84356. */
  84357. contains(x: number, y: number): boolean;
  84358. protected _getTypeName(): string;
  84359. /** Force the control to synchronize with its content */
  84360. synchronizeSizeWithContent(): void;
  84361. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84362. private _prepareWorkingCanvasForOpaqueDetection;
  84363. private _drawImage;
  84364. _draw(context: CanvasRenderingContext2D): void;
  84365. private _renderCornerPatch;
  84366. private _renderNinePatch;
  84367. dispose(): void;
  84368. /** STRETCH_NONE */
  84369. static readonly STRETCH_NONE: number;
  84370. /** STRETCH_FILL */
  84371. static readonly STRETCH_FILL: number;
  84372. /** STRETCH_UNIFORM */
  84373. static readonly STRETCH_UNIFORM: number;
  84374. /** STRETCH_EXTEND */
  84375. static readonly STRETCH_EXTEND: number;
  84376. /** NINE_PATCH */
  84377. static readonly STRETCH_NINE_PATCH: number;
  84378. }
  84379. }
  84380. declare module BABYLON.GUI {
  84381. /**
  84382. * Class used to create 2D buttons
  84383. */
  84384. export class Button extends Rectangle {
  84385. name?: string | undefined;
  84386. /**
  84387. * Function called to generate a pointer enter animation
  84388. */
  84389. pointerEnterAnimation: () => void;
  84390. /**
  84391. * Function called to generate a pointer out animation
  84392. */
  84393. pointerOutAnimation: () => void;
  84394. /**
  84395. * Function called to generate a pointer down animation
  84396. */
  84397. pointerDownAnimation: () => void;
  84398. /**
  84399. * Function called to generate a pointer up animation
  84400. */
  84401. pointerUpAnimation: () => void;
  84402. /**
  84403. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84404. */
  84405. delegatePickingToChildren: boolean;
  84406. private _image;
  84407. /**
  84408. * Returns the image part of the button (if any)
  84409. */
  84410. get image(): BABYLON.Nullable<Image>;
  84411. private _textBlock;
  84412. /**
  84413. * Returns the image part of the button (if any)
  84414. */
  84415. get textBlock(): BABYLON.Nullable<TextBlock>;
  84416. /**
  84417. * Creates a new Button
  84418. * @param name defines the name of the button
  84419. */
  84420. constructor(name?: string | undefined);
  84421. protected _getTypeName(): string;
  84422. /** @hidden */
  84423. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84424. /** @hidden */
  84425. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84426. /** @hidden */
  84427. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84428. /** @hidden */
  84429. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84430. /** @hidden */
  84431. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84432. /**
  84433. * Creates a new button made with an image and a text
  84434. * @param name defines the name of the button
  84435. * @param text defines the text of the button
  84436. * @param imageUrl defines the url of the image
  84437. * @returns a new Button
  84438. */
  84439. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84440. /**
  84441. * Creates a new button made with an image
  84442. * @param name defines the name of the button
  84443. * @param imageUrl defines the url of the image
  84444. * @returns a new Button
  84445. */
  84446. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84447. /**
  84448. * Creates a new button made with a text
  84449. * @param name defines the name of the button
  84450. * @param text defines the text of the button
  84451. * @returns a new Button
  84452. */
  84453. static CreateSimpleButton(name: string, text: string): Button;
  84454. /**
  84455. * Creates a new button made with an image and a centered text
  84456. * @param name defines the name of the button
  84457. * @param text defines the text of the button
  84458. * @param imageUrl defines the url of the image
  84459. * @returns a new Button
  84460. */
  84461. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84462. }
  84463. }
  84464. declare module BABYLON.GUI {
  84465. /**
  84466. * Class used to create a 2D stack panel container
  84467. */
  84468. export class StackPanel extends Container {
  84469. name?: string | undefined;
  84470. private _isVertical;
  84471. private _manualWidth;
  84472. private _manualHeight;
  84473. private _doNotTrackManualChanges;
  84474. /**
  84475. * Gets or sets a boolean indicating that layou warnings should be ignored
  84476. */
  84477. ignoreLayoutWarnings: boolean;
  84478. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84479. get isVertical(): boolean;
  84480. set isVertical(value: boolean);
  84481. /**
  84482. * Gets or sets panel width.
  84483. * This value should not be set when in horizontal mode as it will be computed automatically
  84484. */
  84485. set width(value: string | number);
  84486. get width(): string | number;
  84487. /**
  84488. * Gets or sets panel height.
  84489. * This value should not be set when in vertical mode as it will be computed automatically
  84490. */
  84491. set height(value: string | number);
  84492. get height(): string | number;
  84493. /**
  84494. * Creates a new StackPanel
  84495. * @param name defines control name
  84496. */
  84497. constructor(name?: string | undefined);
  84498. protected _getTypeName(): string;
  84499. /** @hidden */
  84500. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84501. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84502. protected _postMeasure(): void;
  84503. /**
  84504. * Serializes the current control
  84505. * @param serializationObject defined the JSON serialized object
  84506. */
  84507. serialize(serializationObject: any): void;
  84508. /** @hidden */
  84509. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84510. }
  84511. }
  84512. declare module BABYLON.GUI {
  84513. /**
  84514. * Class used to represent a 2D checkbox
  84515. */
  84516. export class Checkbox extends Control {
  84517. name?: string | undefined;
  84518. private _isChecked;
  84519. private _background;
  84520. private _checkSizeRatio;
  84521. private _thickness;
  84522. /** Gets or sets border thickness */
  84523. get thickness(): number;
  84524. set thickness(value: number);
  84525. /**
  84526. * BABYLON.Observable raised when isChecked property changes
  84527. */
  84528. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84529. /** Gets or sets a value indicating the ratio between overall size and check size */
  84530. get checkSizeRatio(): number;
  84531. set checkSizeRatio(value: number);
  84532. /** Gets or sets background color */
  84533. get background(): string;
  84534. set background(value: string);
  84535. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84536. get isChecked(): boolean;
  84537. set isChecked(value: boolean);
  84538. /**
  84539. * Creates a new CheckBox
  84540. * @param name defines the control name
  84541. */
  84542. constructor(name?: string | undefined);
  84543. protected _getTypeName(): string;
  84544. /** @hidden */
  84545. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84546. /** @hidden */
  84547. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84548. /**
  84549. * Utility function to easily create a checkbox with a header
  84550. * @param title defines the label to use for the header
  84551. * @param onValueChanged defines the callback to call when value changes
  84552. * @returns a StackPanel containing the checkbox and a textBlock
  84553. */
  84554. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84555. }
  84556. }
  84557. declare module BABYLON.GUI {
  84558. /**
  84559. * Class used to store key control properties
  84560. */
  84561. export class KeyPropertySet {
  84562. /** Width */
  84563. width?: string;
  84564. /** Height */
  84565. height?: string;
  84566. /** Left padding */
  84567. paddingLeft?: string;
  84568. /** Right padding */
  84569. paddingRight?: string;
  84570. /** Top padding */
  84571. paddingTop?: string;
  84572. /** Bottom padding */
  84573. paddingBottom?: string;
  84574. /** Foreground color */
  84575. color?: string;
  84576. /** Background color */
  84577. background?: string;
  84578. }
  84579. /**
  84580. * Class used to create virtual keyboard
  84581. */
  84582. export class VirtualKeyboard extends StackPanel {
  84583. /** BABYLON.Observable raised when a key is pressed */
  84584. onKeyPressObservable: BABYLON.Observable<string>;
  84585. /** Gets or sets default key button width */
  84586. defaultButtonWidth: string;
  84587. /** Gets or sets default key button height */
  84588. defaultButtonHeight: string;
  84589. /** Gets or sets default key button left padding */
  84590. defaultButtonPaddingLeft: string;
  84591. /** Gets or sets default key button right padding */
  84592. defaultButtonPaddingRight: string;
  84593. /** Gets or sets default key button top padding */
  84594. defaultButtonPaddingTop: string;
  84595. /** Gets or sets default key button bottom padding */
  84596. defaultButtonPaddingBottom: string;
  84597. /** Gets or sets default key button foreground color */
  84598. defaultButtonColor: string;
  84599. /** Gets or sets default key button background color */
  84600. defaultButtonBackground: string;
  84601. /** Gets or sets shift button foreground color */
  84602. shiftButtonColor: string;
  84603. /** Gets or sets shift button thickness*/
  84604. selectedShiftThickness: number;
  84605. /** Gets shift key state */
  84606. shiftState: number;
  84607. protected _getTypeName(): string;
  84608. private _createKey;
  84609. /**
  84610. * Adds a new row of keys
  84611. * @param keys defines the list of keys to add
  84612. * @param propertySets defines the associated property sets
  84613. */
  84614. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84615. /**
  84616. * Set the shift key to a specific state
  84617. * @param shiftState defines the new shift state
  84618. */
  84619. applyShiftState(shiftState: number): void;
  84620. private _currentlyConnectedInputText;
  84621. private _connectedInputTexts;
  84622. private _onKeyPressObserver;
  84623. /** Gets the input text control currently attached to the keyboard */
  84624. get connectedInputText(): BABYLON.Nullable<InputText>;
  84625. /**
  84626. * Connects the keyboard with an input text control
  84627. *
  84628. * @param input defines the target control
  84629. */
  84630. connect(input: InputText): void;
  84631. /**
  84632. * Disconnects the keyboard from connected InputText controls
  84633. *
  84634. * @param input optionally defines a target control, otherwise all are disconnected
  84635. */
  84636. disconnect(input?: InputText): void;
  84637. private _removeConnectedInputObservables;
  84638. /**
  84639. * Release all resources
  84640. */
  84641. dispose(): void;
  84642. /**
  84643. * Creates a new keyboard using a default layout
  84644. *
  84645. * @param name defines control name
  84646. * @returns a new VirtualKeyboard
  84647. */
  84648. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84649. }
  84650. }
  84651. declare module BABYLON.GUI {
  84652. /** @hidden */
  84653. export class TextWrapper {
  84654. private _text;
  84655. private _characters;
  84656. get text(): string;
  84657. set text(txt: string);
  84658. get length(): number;
  84659. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84660. charAt(idx: number): string;
  84661. substr(from: number, length?: number): string;
  84662. substring(from: number, to?: number): string;
  84663. isWord(index: number): boolean;
  84664. }
  84665. }
  84666. declare module BABYLON.GUI {
  84667. /**
  84668. * Class used to create input text control
  84669. */
  84670. export class InputText extends Control implements IFocusableControl {
  84671. name?: string | undefined;
  84672. private _textWrapper;
  84673. private _placeholderText;
  84674. private _background;
  84675. private _focusedBackground;
  84676. private _focusedColor;
  84677. private _placeholderColor;
  84678. private _thickness;
  84679. private _margin;
  84680. private _autoStretchWidth;
  84681. private _maxWidth;
  84682. private _isFocused;
  84683. private _blinkTimeout;
  84684. private _blinkIsEven;
  84685. private _cursorOffset;
  84686. private _scrollLeft;
  84687. private _textWidth;
  84688. private _clickedCoordinate;
  84689. private _deadKey;
  84690. private _addKey;
  84691. private _currentKey;
  84692. private _isTextHighlightOn;
  84693. private _textHighlightColor;
  84694. private _highligherOpacity;
  84695. private _highlightedText;
  84696. private _startHighlightIndex;
  84697. private _endHighlightIndex;
  84698. private _cursorIndex;
  84699. private _onFocusSelectAll;
  84700. private _isPointerDown;
  84701. private _onClipboardObserver;
  84702. private _onPointerDblTapObserver;
  84703. /** @hidden */
  84704. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84705. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84706. promptMessage: string;
  84707. /** Force disable prompt on mobile device */
  84708. disableMobilePrompt: boolean;
  84709. /** BABYLON.Observable raised when the text changes */
  84710. onTextChangedObservable: BABYLON.Observable<InputText>;
  84711. /** BABYLON.Observable raised just before an entered character is to be added */
  84712. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84713. /** BABYLON.Observable raised when the control gets the focus */
  84714. onFocusObservable: BABYLON.Observable<InputText>;
  84715. /** BABYLON.Observable raised when the control loses the focus */
  84716. onBlurObservable: BABYLON.Observable<InputText>;
  84717. /**Observable raised when the text is highlighted */
  84718. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84719. /**Observable raised when copy event is triggered */
  84720. onTextCopyObservable: BABYLON.Observable<InputText>;
  84721. /** BABYLON.Observable raised when cut event is triggered */
  84722. onTextCutObservable: BABYLON.Observable<InputText>;
  84723. /** BABYLON.Observable raised when paste event is triggered */
  84724. onTextPasteObservable: BABYLON.Observable<InputText>;
  84725. /** BABYLON.Observable raised when a key event was processed */
  84726. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84727. /** Gets or sets the maximum width allowed by the control */
  84728. get maxWidth(): string | number;
  84729. /** Gets the maximum width allowed by the control in pixels */
  84730. get maxWidthInPixels(): number;
  84731. set maxWidth(value: string | number);
  84732. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84733. get highligherOpacity(): number;
  84734. set highligherOpacity(value: number);
  84735. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84736. get onFocusSelectAll(): boolean;
  84737. set onFocusSelectAll(value: boolean);
  84738. /** Gets or sets the text hightlight color */
  84739. get textHighlightColor(): string;
  84740. set textHighlightColor(value: string);
  84741. /** Gets or sets control margin */
  84742. get margin(): string;
  84743. /** Gets control margin in pixels */
  84744. get marginInPixels(): number;
  84745. set margin(value: string);
  84746. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84747. get autoStretchWidth(): boolean;
  84748. set autoStretchWidth(value: boolean);
  84749. /** Gets or sets border thickness */
  84750. get thickness(): number;
  84751. set thickness(value: number);
  84752. /** Gets or sets the background color when focused */
  84753. get focusedBackground(): string;
  84754. set focusedBackground(value: string);
  84755. /** Gets or sets the background color when focused */
  84756. get focusedColor(): string;
  84757. set focusedColor(value: string);
  84758. /** Gets or sets the background color */
  84759. get background(): string;
  84760. set background(value: string);
  84761. /** Gets or sets the placeholder color */
  84762. get placeholderColor(): string;
  84763. set placeholderColor(value: string);
  84764. /** Gets or sets the text displayed when the control is empty */
  84765. get placeholderText(): string;
  84766. set placeholderText(value: string);
  84767. /** Gets or sets the dead key flag */
  84768. get deadKey(): boolean;
  84769. set deadKey(flag: boolean);
  84770. /** Gets or sets the highlight text */
  84771. get highlightedText(): string;
  84772. set highlightedText(text: string);
  84773. /** Gets or sets if the current key should be added */
  84774. get addKey(): boolean;
  84775. set addKey(flag: boolean);
  84776. /** Gets or sets the value of the current key being entered */
  84777. get currentKey(): string;
  84778. set currentKey(key: string);
  84779. /** Gets or sets the text displayed in the control */
  84780. get text(): string;
  84781. set text(value: string);
  84782. private _textHasChanged;
  84783. /** Gets or sets control width */
  84784. get width(): string | number;
  84785. set width(value: string | number);
  84786. /**
  84787. * Creates a new InputText
  84788. * @param name defines the control name
  84789. * @param text defines the text of the control
  84790. */
  84791. constructor(name?: string | undefined, text?: string);
  84792. /** @hidden */
  84793. onBlur(): void;
  84794. /** @hidden */
  84795. onFocus(): void;
  84796. /**
  84797. * Function to focus an inputText programmatically
  84798. */
  84799. focus(): void;
  84800. /**
  84801. * Function to unfocus an inputText programmatically
  84802. */
  84803. blur(): void;
  84804. protected _getTypeName(): string;
  84805. /**
  84806. * Function called to get the list of controls that should not steal the focus from this control
  84807. * @returns an array of controls
  84808. */
  84809. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84810. /** @hidden */
  84811. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84812. /** @hidden */
  84813. private _updateValueFromCursorIndex;
  84814. /** @hidden */
  84815. private _processDblClick;
  84816. /** @hidden */
  84817. private _selectAllText;
  84818. /**
  84819. * Handles the keyboard event
  84820. * @param evt Defines the KeyboardEvent
  84821. */
  84822. processKeyboard(evt: KeyboardEvent): void;
  84823. /** @hidden */
  84824. private _onCopyText;
  84825. /** @hidden */
  84826. private _onCutText;
  84827. /** @hidden */
  84828. private _onPasteText;
  84829. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  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): void;
  84833. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84834. dispose(): void;
  84835. }
  84836. }
  84837. declare module BABYLON.GUI {
  84838. /**
  84839. * Class used to create a 2D grid container
  84840. */
  84841. export class Grid extends Container {
  84842. name?: string | undefined;
  84843. private _rowDefinitions;
  84844. private _columnDefinitions;
  84845. private _cells;
  84846. private _childControls;
  84847. /**
  84848. * Gets the number of columns
  84849. */
  84850. get columnCount(): number;
  84851. /**
  84852. * Gets the number of rows
  84853. */
  84854. get rowCount(): number;
  84855. /** Gets the list of children */
  84856. get children(): Control[];
  84857. /** Gets the list of cells (e.g. the containers) */
  84858. get cells(): {
  84859. [key: string]: Container;
  84860. };
  84861. /**
  84862. * Gets the definition of a specific row
  84863. * @param index defines the index of the row
  84864. * @returns the row definition
  84865. */
  84866. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84867. /**
  84868. * Gets the definition of a specific column
  84869. * @param index defines the index of the column
  84870. * @returns the column definition
  84871. */
  84872. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84873. /**
  84874. * Adds a new row to the grid
  84875. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84876. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84877. * @returns the current grid
  84878. */
  84879. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84880. /**
  84881. * Adds a new column to the grid
  84882. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84883. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84884. * @returns the current grid
  84885. */
  84886. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84887. /**
  84888. * Update a row definition
  84889. * @param index defines the index of the row to update
  84890. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84891. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84892. * @returns the current grid
  84893. */
  84894. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84895. /**
  84896. * Update a column definition
  84897. * @param index defines the index of the column to update
  84898. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84899. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84900. * @returns the current grid
  84901. */
  84902. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84903. /**
  84904. * Gets the list of children stored in a specific cell
  84905. * @param row defines the row to check
  84906. * @param column defines the column to check
  84907. * @returns the list of controls
  84908. */
  84909. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84910. /**
  84911. * Gets a string representing the child cell info (row x column)
  84912. * @param child defines the control to get info from
  84913. * @returns a string containing the child cell info (row x column)
  84914. */
  84915. getChildCellInfo(child: Control): string;
  84916. private _removeCell;
  84917. private _offsetCell;
  84918. /**
  84919. * Remove a column definition at specified index
  84920. * @param index defines the index of the column to remove
  84921. * @returns the current grid
  84922. */
  84923. removeColumnDefinition(index: number): Grid;
  84924. /**
  84925. * Remove a row definition at specified index
  84926. * @param index defines the index of the row to remove
  84927. * @returns the current grid
  84928. */
  84929. removeRowDefinition(index: number): Grid;
  84930. /**
  84931. * Adds a new control to the current grid
  84932. * @param control defines the control to add
  84933. * @param row defines the row where to add the control (0 by default)
  84934. * @param column defines the column where to add the control (0 by default)
  84935. * @returns the current grid
  84936. */
  84937. addControl(control: Control, row?: number, column?: number): Grid;
  84938. /**
  84939. * Removes a control from the current container
  84940. * @param control defines the control to remove
  84941. * @returns the current container
  84942. */
  84943. removeControl(control: Control): Container;
  84944. /**
  84945. * Creates a new Grid
  84946. * @param name defines control name
  84947. */
  84948. constructor(name?: string | undefined);
  84949. protected _getTypeName(): string;
  84950. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84951. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84952. _flagDescendantsAsMatrixDirty(): void;
  84953. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84954. /** Releases associated resources */
  84955. dispose(): void;
  84956. }
  84957. }
  84958. declare module BABYLON.GUI {
  84959. /** Class used to create color pickers */
  84960. export class ColorPicker extends Control {
  84961. name?: string | undefined;
  84962. private static _Epsilon;
  84963. private _colorWheelCanvas;
  84964. private _value;
  84965. private _tmpColor;
  84966. private _pointerStartedOnSquare;
  84967. private _pointerStartedOnWheel;
  84968. private _squareLeft;
  84969. private _squareTop;
  84970. private _squareSize;
  84971. private _h;
  84972. private _s;
  84973. private _v;
  84974. private _lastPointerDownID;
  84975. /**
  84976. * BABYLON.Observable raised when the value changes
  84977. */
  84978. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84979. /** Gets or sets the color of the color picker */
  84980. get value(): BABYLON.Color3;
  84981. set value(value: BABYLON.Color3);
  84982. /**
  84983. * Gets or sets control width
  84984. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84985. */
  84986. get width(): string | number;
  84987. set width(value: string | number);
  84988. /**
  84989. * Gets or sets control height
  84990. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84991. */
  84992. get height(): string | number;
  84993. /** Gets or sets control height */
  84994. set height(value: string | number);
  84995. /** Gets or sets control size */
  84996. get size(): string | number;
  84997. set size(value: string | number);
  84998. /**
  84999. * Creates a new ColorPicker
  85000. * @param name defines the control name
  85001. */
  85002. constructor(name?: string | undefined);
  85003. protected _getTypeName(): string;
  85004. /** @hidden */
  85005. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85006. private _updateSquareProps;
  85007. private _drawGradientSquare;
  85008. private _drawCircle;
  85009. private _createColorWheelCanvas;
  85010. /** @hidden */
  85011. _draw(context: CanvasRenderingContext2D): void;
  85012. private _pointerIsDown;
  85013. private _updateValueFromPointer;
  85014. private _isPointOnSquare;
  85015. private _isPointOnWheel;
  85016. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85017. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85018. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85019. _onCanvasBlur(): void;
  85020. /**
  85021. * This function expands the color picker by creating a color picker dialog with manual
  85022. * color value input and the ability to save colors into an array to be used later in
  85023. * subsequent launches of the dialogue.
  85024. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  85025. * @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.
  85026. * @returns picked color as a hex string and the saved colors array as hex strings.
  85027. */
  85028. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  85029. pickerWidth?: string;
  85030. pickerHeight?: string;
  85031. headerHeight?: string;
  85032. lastColor?: string;
  85033. swatchLimit?: number;
  85034. numSwatchesPerLine?: number;
  85035. savedColors?: Array<string>;
  85036. }): Promise<{
  85037. savedColors?: string[];
  85038. pickedColor: string;
  85039. }>;
  85040. }
  85041. }
  85042. declare module BABYLON.GUI {
  85043. /** Class used to create 2D ellipse containers */
  85044. export class Ellipse extends Container {
  85045. name?: string | undefined;
  85046. private _thickness;
  85047. /** Gets or sets border thickness */
  85048. get thickness(): number;
  85049. set thickness(value: number);
  85050. /**
  85051. * Creates a new Ellipse
  85052. * @param name defines the control name
  85053. */
  85054. constructor(name?: string | undefined);
  85055. protected _getTypeName(): string;
  85056. protected _localDraw(context: CanvasRenderingContext2D): void;
  85057. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85058. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85059. }
  85060. }
  85061. declare module BABYLON.GUI {
  85062. /**
  85063. * Class used to create a focusable button that can easily handle keyboard events
  85064. */
  85065. export class FocusableButton extends Button implements IFocusableControl {
  85066. name?: string | undefined;
  85067. /** Highlight color when button is focused */
  85068. focusedColor: BABYLON.Nullable<string>;
  85069. private _isFocused;
  85070. private _unfocusedColor;
  85071. /** BABYLON.Observable raised when the control gets the focus */
  85072. onFocusObservable: BABYLON.Observable<Button>;
  85073. /** BABYLON.Observable raised when the control loses the focus */
  85074. onBlurObservable: BABYLON.Observable<Button>;
  85075. /** BABYLON.Observable raised when a key event was processed */
  85076. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  85077. constructor(name?: string | undefined);
  85078. /** @hidden */
  85079. onBlur(): void;
  85080. /** @hidden */
  85081. onFocus(): void;
  85082. /**
  85083. * Function called to get the list of controls that should not steal the focus from this control
  85084. * @returns an array of controls
  85085. */
  85086. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85087. /**
  85088. * Function to focus a button programmatically
  85089. */
  85090. focus(): void;
  85091. /**
  85092. * Function to unfocus a button programmatically
  85093. */
  85094. blur(): void;
  85095. /**
  85096. * Handles the keyboard event
  85097. * @param evt Defines the KeyboardEvent
  85098. */
  85099. processKeyboard(evt: KeyboardEvent): void;
  85100. /** @hidden */
  85101. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85102. /** @hidden */
  85103. displose(): void;
  85104. }
  85105. }
  85106. declare module BABYLON.GUI {
  85107. /**
  85108. * Class used to create a password control
  85109. */
  85110. export class InputPassword extends InputText {
  85111. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85112. }
  85113. }
  85114. declare module BABYLON.GUI {
  85115. /** Class used to render 2D lines */
  85116. export class Line extends Control {
  85117. name?: string | undefined;
  85118. private _lineWidth;
  85119. private _x1;
  85120. private _y1;
  85121. private _x2;
  85122. private _y2;
  85123. private _dash;
  85124. private _connectedControl;
  85125. private _connectedControlDirtyObserver;
  85126. /** Gets or sets the dash pattern */
  85127. get dash(): Array<number>;
  85128. set dash(value: Array<number>);
  85129. /** Gets or sets the control connected with the line end */
  85130. get connectedControl(): Control;
  85131. set connectedControl(value: Control);
  85132. /** Gets or sets start coordinates on X axis */
  85133. get x1(): string | number;
  85134. set x1(value: string | number);
  85135. /** Gets or sets start coordinates on Y axis */
  85136. get y1(): string | number;
  85137. set y1(value: string | number);
  85138. /** Gets or sets end coordinates on X axis */
  85139. get x2(): string | number;
  85140. set x2(value: string | number);
  85141. /** Gets or sets end coordinates on Y axis */
  85142. get y2(): string | number;
  85143. set y2(value: string | number);
  85144. /** Gets or sets line width */
  85145. get lineWidth(): number;
  85146. set lineWidth(value: number);
  85147. /** Gets or sets horizontal alignment */
  85148. set horizontalAlignment(value: number);
  85149. /** Gets or sets vertical alignment */
  85150. set verticalAlignment(value: number);
  85151. private get _effectiveX2();
  85152. private get _effectiveY2();
  85153. /**
  85154. * Creates a new Line
  85155. * @param name defines the control name
  85156. */
  85157. constructor(name?: string | undefined);
  85158. protected _getTypeName(): string;
  85159. _draw(context: CanvasRenderingContext2D): void;
  85160. _measure(): void;
  85161. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85162. /**
  85163. * Move one end of the line given 3D cartesian coordinates.
  85164. * @param position Targeted world position
  85165. * @param scene BABYLON.Scene
  85166. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85167. */
  85168. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85169. /**
  85170. * Move one end of the line to a position in screen absolute space.
  85171. * @param projectedPosition Position in screen absolute space (X, Y)
  85172. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85173. */
  85174. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85175. }
  85176. }
  85177. declare module BABYLON.GUI {
  85178. /**
  85179. * Class used to store a point for a MultiLine object.
  85180. * The point can be pure 2D coordinates, a mesh or a control
  85181. */
  85182. export class MultiLinePoint {
  85183. private _multiLine;
  85184. private _x;
  85185. private _y;
  85186. private _control;
  85187. private _mesh;
  85188. private _controlObserver;
  85189. private _meshObserver;
  85190. /** @hidden */
  85191. _point: BABYLON.Vector3;
  85192. /**
  85193. * Creates a new MultiLinePoint
  85194. * @param multiLine defines the source MultiLine object
  85195. */
  85196. constructor(multiLine: MultiLine);
  85197. /** Gets or sets x coordinate */
  85198. get x(): string | number;
  85199. set x(value: string | number);
  85200. /** Gets or sets y coordinate */
  85201. get y(): string | number;
  85202. set y(value: string | number);
  85203. /** Gets or sets the control associated with this point */
  85204. get control(): BABYLON.Nullable<Control>;
  85205. set control(value: BABYLON.Nullable<Control>);
  85206. /** Gets or sets the mesh associated with this point */
  85207. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85208. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85209. /** Resets links */
  85210. resetLinks(): void;
  85211. /**
  85212. * Gets a translation vector with Z component
  85213. * @returns the translation vector
  85214. */
  85215. translate(): BABYLON.Vector3;
  85216. private _translatePoint;
  85217. /** Release associated resources */
  85218. dispose(): void;
  85219. }
  85220. }
  85221. declare module BABYLON.GUI {
  85222. /**
  85223. * Class used to create multi line control
  85224. */
  85225. export class MultiLine extends Control {
  85226. name?: string | undefined;
  85227. private _lineWidth;
  85228. private _dash;
  85229. private _points;
  85230. private _minX;
  85231. private _minY;
  85232. private _maxX;
  85233. private _maxY;
  85234. /**
  85235. * Creates a new MultiLine
  85236. * @param name defines the control name
  85237. */
  85238. constructor(name?: string | undefined);
  85239. /** Gets or sets dash pattern */
  85240. get dash(): Array<number>;
  85241. set dash(value: Array<number>);
  85242. /**
  85243. * Gets point stored at specified index
  85244. * @param index defines the index to look for
  85245. * @returns the requested point if found
  85246. */
  85247. getAt(index: number): MultiLinePoint;
  85248. /** Function called when a point is updated */
  85249. onPointUpdate: () => void;
  85250. /**
  85251. * Adds new points to the point collection
  85252. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85253. * @returns the list of created MultiLinePoint
  85254. */
  85255. add(...items: (AbstractMesh | Control | {
  85256. x: string | number;
  85257. y: string | number;
  85258. })[]): MultiLinePoint[];
  85259. /**
  85260. * Adds a new point to the point collection
  85261. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85262. * @returns the created MultiLinePoint
  85263. */
  85264. push(item?: (AbstractMesh | Control | {
  85265. x: string | number;
  85266. y: string | number;
  85267. })): MultiLinePoint;
  85268. /**
  85269. * Remove a specific value or point from the active point collection
  85270. * @param value defines the value or point to remove
  85271. */
  85272. remove(value: number | MultiLinePoint): void;
  85273. /**
  85274. * Resets this object to initial state (no point)
  85275. */
  85276. reset(): void;
  85277. /**
  85278. * Resets all links
  85279. */
  85280. resetLinks(): void;
  85281. /** Gets or sets line width */
  85282. get lineWidth(): number;
  85283. set lineWidth(value: number);
  85284. set horizontalAlignment(value: number);
  85285. set verticalAlignment(value: number);
  85286. protected _getTypeName(): string;
  85287. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85288. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85289. _measure(): void;
  85290. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85291. dispose(): void;
  85292. }
  85293. }
  85294. declare module BABYLON.GUI {
  85295. /**
  85296. * Class used to create radio button controls
  85297. */
  85298. export class RadioButton extends Control {
  85299. name?: string | undefined;
  85300. private _isChecked;
  85301. private _background;
  85302. private _checkSizeRatio;
  85303. private _thickness;
  85304. /** Gets or sets border thickness */
  85305. get thickness(): number;
  85306. set thickness(value: number);
  85307. /** Gets or sets group name */
  85308. group: string;
  85309. /** BABYLON.Observable raised when isChecked is changed */
  85310. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85311. /** Gets or sets a value indicating the ratio between overall size and check size */
  85312. get checkSizeRatio(): number;
  85313. set checkSizeRatio(value: number);
  85314. /** Gets or sets background color */
  85315. get background(): string;
  85316. set background(value: string);
  85317. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85318. get isChecked(): boolean;
  85319. set isChecked(value: boolean);
  85320. /**
  85321. * Creates a new RadioButton
  85322. * @param name defines the control name
  85323. */
  85324. constructor(name?: string | undefined);
  85325. protected _getTypeName(): string;
  85326. _draw(context: CanvasRenderingContext2D): void;
  85327. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85328. /**
  85329. * Utility function to easily create a radio button with a header
  85330. * @param title defines the label to use for the header
  85331. * @param group defines the group to use for the radio button
  85332. * @param isChecked defines the initial state of the radio button
  85333. * @param onValueChanged defines the callback to call when value changes
  85334. * @returns a StackPanel containing the radio button and a textBlock
  85335. */
  85336. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85337. }
  85338. }
  85339. declare module BABYLON.GUI {
  85340. /**
  85341. * Class used to create slider controls
  85342. */
  85343. export class BaseSlider extends Control {
  85344. name?: string | undefined;
  85345. protected _thumbWidth: ValueAndUnit;
  85346. private _minimum;
  85347. private _maximum;
  85348. private _value;
  85349. private _isVertical;
  85350. protected _barOffset: ValueAndUnit;
  85351. private _isThumbClamped;
  85352. protected _displayThumb: boolean;
  85353. private _step;
  85354. private _lastPointerDownID;
  85355. protected _effectiveBarOffset: number;
  85356. protected _renderLeft: number;
  85357. protected _renderTop: number;
  85358. protected _renderWidth: number;
  85359. protected _renderHeight: number;
  85360. protected _backgroundBoxLength: number;
  85361. protected _backgroundBoxThickness: number;
  85362. protected _effectiveThumbThickness: number;
  85363. /** BABYLON.Observable raised when the sldier value changes */
  85364. onValueChangedObservable: BABYLON.Observable<number>;
  85365. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85366. get displayThumb(): boolean;
  85367. set displayThumb(value: boolean);
  85368. /** Gets or sets a step to apply to values (0 by default) */
  85369. get step(): number;
  85370. set step(value: number);
  85371. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85372. get barOffset(): string | number;
  85373. /** Gets main bar offset in pixels*/
  85374. get barOffsetInPixels(): number;
  85375. set barOffset(value: string | number);
  85376. /** Gets or sets thumb width */
  85377. get thumbWidth(): string | number;
  85378. /** Gets thumb width in pixels */
  85379. get thumbWidthInPixels(): number;
  85380. set thumbWidth(value: string | number);
  85381. /** Gets or sets minimum value */
  85382. get minimum(): number;
  85383. set minimum(value: number);
  85384. /** Gets or sets maximum value */
  85385. get maximum(): number;
  85386. set maximum(value: number);
  85387. /** Gets or sets current value */
  85388. get value(): number;
  85389. set value(value: number);
  85390. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85391. get isVertical(): boolean;
  85392. set isVertical(value: boolean);
  85393. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85394. get isThumbClamped(): boolean;
  85395. set isThumbClamped(value: boolean);
  85396. /**
  85397. * Creates a new BaseSlider
  85398. * @param name defines the control name
  85399. */
  85400. constructor(name?: string | undefined);
  85401. protected _getTypeName(): string;
  85402. protected _getThumbPosition(): number;
  85403. protected _getThumbThickness(type: string): number;
  85404. protected _prepareRenderingData(type: string): void;
  85405. private _pointerIsDown;
  85406. /** @hidden */
  85407. protected _updateValueFromPointer(x: number, y: number): void;
  85408. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85409. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85410. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85411. _onCanvasBlur(): void;
  85412. }
  85413. }
  85414. declare module BABYLON.GUI {
  85415. /**
  85416. * Class used to create slider controls
  85417. */
  85418. export class Slider extends BaseSlider {
  85419. name?: string | undefined;
  85420. private _background;
  85421. private _borderColor;
  85422. private _thumbColor;
  85423. private _isThumbCircle;
  85424. protected _displayValueBar: boolean;
  85425. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85426. get displayValueBar(): boolean;
  85427. set displayValueBar(value: boolean);
  85428. /** Gets or sets border color */
  85429. get borderColor(): string;
  85430. set borderColor(value: string);
  85431. /** Gets or sets background color */
  85432. get background(): string;
  85433. set background(value: string);
  85434. /** Gets or sets thumb's color */
  85435. get thumbColor(): string;
  85436. set thumbColor(value: string);
  85437. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85438. get isThumbCircle(): boolean;
  85439. set isThumbCircle(value: boolean);
  85440. /**
  85441. * Creates a new Slider
  85442. * @param name defines the control name
  85443. */
  85444. constructor(name?: string | undefined);
  85445. protected _getTypeName(): string;
  85446. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85447. }
  85448. }
  85449. declare module BABYLON.GUI {
  85450. /** Class used to create a RadioGroup
  85451. * which contains groups of radio buttons
  85452. */
  85453. export class SelectorGroup {
  85454. /** name of SelectorGroup */
  85455. name: string;
  85456. private _groupPanel;
  85457. private _selectors;
  85458. private _groupHeader;
  85459. /**
  85460. * Creates a new SelectorGroup
  85461. * @param name of group, used as a group heading
  85462. */
  85463. constructor(
  85464. /** name of SelectorGroup */
  85465. name: string);
  85466. /** Gets the groupPanel of the SelectorGroup */
  85467. get groupPanel(): StackPanel;
  85468. /** Gets the selectors array */
  85469. get selectors(): StackPanel[];
  85470. /** Gets and sets the group header */
  85471. get header(): string;
  85472. set header(label: string);
  85473. /** @hidden */
  85474. private _addGroupHeader;
  85475. /** @hidden*/
  85476. _getSelector(selectorNb: number): StackPanel | undefined;
  85477. /** Removes the selector at the given position
  85478. * @param selectorNb the position of the selector within the group
  85479. */
  85480. removeSelector(selectorNb: number): void;
  85481. }
  85482. /** Class used to create a CheckboxGroup
  85483. * which contains groups of checkbox buttons
  85484. */
  85485. export class CheckboxGroup extends SelectorGroup {
  85486. /** Adds a checkbox as a control
  85487. * @param text is the label for the selector
  85488. * @param func is the function called when the Selector is checked
  85489. * @param checked is true when Selector is checked
  85490. */
  85491. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85492. /** @hidden */
  85493. _setSelectorLabel(selectorNb: number, label: string): void;
  85494. /** @hidden */
  85495. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85496. /** @hidden */
  85497. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85498. /** @hidden */
  85499. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85500. }
  85501. /** Class used to create a RadioGroup
  85502. * which contains groups of radio buttons
  85503. */
  85504. export class RadioGroup extends SelectorGroup {
  85505. private _selectNb;
  85506. /** Adds a radio button as a control
  85507. * @param label is the label for the selector
  85508. * @param func is the function called when the Selector is checked
  85509. * @param checked is true when Selector is checked
  85510. */
  85511. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85512. /** @hidden */
  85513. _setSelectorLabel(selectorNb: number, label: string): void;
  85514. /** @hidden */
  85515. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85516. /** @hidden */
  85517. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85518. /** @hidden */
  85519. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85520. }
  85521. /** Class used to create a SliderGroup
  85522. * which contains groups of slider buttons
  85523. */
  85524. export class SliderGroup extends SelectorGroup {
  85525. /**
  85526. * Adds a slider to the SelectorGroup
  85527. * @param label is the label for the SliderBar
  85528. * @param func is the function called when the Slider moves
  85529. * @param unit is a string describing the units used, eg degrees or metres
  85530. * @param min is the minimum value for the Slider
  85531. * @param max is the maximum value for the Slider
  85532. * @param value is the start value for the Slider between min and max
  85533. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85534. */
  85535. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85536. /** @hidden */
  85537. _setSelectorLabel(selectorNb: number, label: string): void;
  85538. /** @hidden */
  85539. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85540. /** @hidden */
  85541. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85542. /** @hidden */
  85543. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85544. }
  85545. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85546. * @see https://doc.babylonjs.com/how_to/selector
  85547. */
  85548. export class SelectionPanel extends Rectangle {
  85549. /** name of SelectionPanel */
  85550. name: string;
  85551. /** an array of SelectionGroups */
  85552. groups: SelectorGroup[];
  85553. private _panel;
  85554. private _buttonColor;
  85555. private _buttonBackground;
  85556. private _headerColor;
  85557. private _barColor;
  85558. private _barHeight;
  85559. private _spacerHeight;
  85560. private _labelColor;
  85561. private _groups;
  85562. private _bars;
  85563. /**
  85564. * Creates a new SelectionPanel
  85565. * @param name of SelectionPanel
  85566. * @param groups is an array of SelectionGroups
  85567. */
  85568. constructor(
  85569. /** name of SelectionPanel */
  85570. name: string,
  85571. /** an array of SelectionGroups */
  85572. groups?: SelectorGroup[]);
  85573. protected _getTypeName(): string;
  85574. /** Gets the (stack) panel of the SelectionPanel */
  85575. get panel(): StackPanel;
  85576. /** Gets or sets the headerColor */
  85577. get headerColor(): string;
  85578. set headerColor(color: string);
  85579. private _setHeaderColor;
  85580. /** Gets or sets the button color */
  85581. get buttonColor(): string;
  85582. set buttonColor(color: string);
  85583. private _setbuttonColor;
  85584. /** Gets or sets the label color */
  85585. get labelColor(): string;
  85586. set labelColor(color: string);
  85587. private _setLabelColor;
  85588. /** Gets or sets the button background */
  85589. get buttonBackground(): string;
  85590. set buttonBackground(color: string);
  85591. private _setButtonBackground;
  85592. /** Gets or sets the color of separator bar */
  85593. get barColor(): string;
  85594. set barColor(color: string);
  85595. private _setBarColor;
  85596. /** Gets or sets the height of separator bar */
  85597. get barHeight(): string;
  85598. set barHeight(value: string);
  85599. private _setBarHeight;
  85600. /** Gets or sets the height of spacers*/
  85601. get spacerHeight(): string;
  85602. set spacerHeight(value: string);
  85603. private _setSpacerHeight;
  85604. /** Adds a bar between groups */
  85605. private _addSpacer;
  85606. /** Add a group to the selection panel
  85607. * @param group is the selector group to add
  85608. */
  85609. addGroup(group: SelectorGroup): void;
  85610. /** Remove the group from the given position
  85611. * @param groupNb is the position of the group in the list
  85612. */
  85613. removeGroup(groupNb: number): void;
  85614. /** Change a group header label
  85615. * @param label is the new group header label
  85616. * @param groupNb is the number of the group to relabel
  85617. * */
  85618. setHeaderName(label: string, groupNb: number): void;
  85619. /** Change selector label to the one given
  85620. * @param label is the new selector label
  85621. * @param groupNb is the number of the groupcontaining the selector
  85622. * @param selectorNb is the number of the selector within a group to relabel
  85623. * */
  85624. relabel(label: string, groupNb: number, selectorNb: number): void;
  85625. /** For a given group position remove the selector at the given position
  85626. * @param groupNb is the number of the group to remove the selector from
  85627. * @param selectorNb is the number of the selector within the group
  85628. */
  85629. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85630. /** For a given group position of correct type add a checkbox button
  85631. * @param groupNb is the number of the group to remove the selector from
  85632. * @param label is the label for the selector
  85633. * @param func is the function called when the Selector is checked
  85634. * @param checked is true when Selector is checked
  85635. */
  85636. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85637. /** For a given group position of correct type add a radio button
  85638. * @param groupNb is the number of the group to remove the selector from
  85639. * @param label is the label for the selector
  85640. * @param func is the function called when the Selector is checked
  85641. * @param checked is true when Selector is checked
  85642. */
  85643. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85644. /**
  85645. * For a given slider group add a slider
  85646. * @param groupNb is the number of the group to add the slider to
  85647. * @param label is the label for the Slider
  85648. * @param func is the function called when the Slider moves
  85649. * @param unit is a string describing the units used, eg degrees or metres
  85650. * @param min is the minimum value for the Slider
  85651. * @param max is the maximum value for the Slider
  85652. * @param value is the start value for the Slider between min and max
  85653. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85654. */
  85655. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85656. }
  85657. }
  85658. declare module BABYLON.GUI {
  85659. /**
  85660. * Class used to hold a the container for ScrollViewer
  85661. * @hidden
  85662. */
  85663. export class _ScrollViewerWindow extends Container {
  85664. parentClientWidth: number;
  85665. parentClientHeight: number;
  85666. private _freezeControls;
  85667. private _parentMeasure;
  85668. private _oldLeft;
  85669. private _oldTop;
  85670. get freezeControls(): boolean;
  85671. set freezeControls(value: boolean);
  85672. private _bucketWidth;
  85673. private _bucketHeight;
  85674. private _buckets;
  85675. private _bucketLen;
  85676. get bucketWidth(): number;
  85677. get bucketHeight(): number;
  85678. setBucketSizes(width: number, height: number): void;
  85679. private _useBuckets;
  85680. private _makeBuckets;
  85681. private _dispatchInBuckets;
  85682. private _updateMeasures;
  85683. private _updateChildrenMeasures;
  85684. private _restoreMeasures;
  85685. /**
  85686. * Creates a new ScrollViewerWindow
  85687. * @param name of ScrollViewerWindow
  85688. */
  85689. constructor(name?: string);
  85690. protected _getTypeName(): string;
  85691. /** @hidden */
  85692. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85693. /** @hidden */
  85694. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85695. private _scrollChildren;
  85696. private _scrollChildrenWithBuckets;
  85697. /** @hidden */
  85698. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85699. protected _postMeasure(): void;
  85700. }
  85701. }
  85702. declare module BABYLON.GUI {
  85703. /**
  85704. * Class used to create slider controls
  85705. */
  85706. export class ScrollBar extends BaseSlider {
  85707. name?: string | undefined;
  85708. private _background;
  85709. private _borderColor;
  85710. private _tempMeasure;
  85711. /** Gets or sets border color */
  85712. get borderColor(): string;
  85713. set borderColor(value: string);
  85714. /** Gets or sets background color */
  85715. get background(): string;
  85716. set background(value: string);
  85717. /**
  85718. * Creates a new Slider
  85719. * @param name defines the control name
  85720. */
  85721. constructor(name?: string | undefined);
  85722. protected _getTypeName(): string;
  85723. protected _getThumbThickness(): number;
  85724. _draw(context: CanvasRenderingContext2D): void;
  85725. private _first;
  85726. private _originX;
  85727. private _originY;
  85728. /** @hidden */
  85729. protected _updateValueFromPointer(x: number, y: number): void;
  85730. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85731. }
  85732. }
  85733. declare module BABYLON.GUI {
  85734. /**
  85735. * Class used to create slider controls
  85736. */
  85737. export class ImageScrollBar extends BaseSlider {
  85738. name?: string | undefined;
  85739. private _backgroundBaseImage;
  85740. private _backgroundImage;
  85741. private _thumbImage;
  85742. private _thumbBaseImage;
  85743. private _thumbLength;
  85744. private _thumbHeight;
  85745. private _barImageHeight;
  85746. private _tempMeasure;
  85747. /** Number of 90° rotation to apply on the images when in vertical mode */
  85748. num90RotationInVerticalMode: number;
  85749. /**
  85750. * Gets or sets the image used to render the background for horizontal bar
  85751. */
  85752. get backgroundImage(): Image;
  85753. set backgroundImage(value: Image);
  85754. /**
  85755. * Gets or sets the image used to render the thumb
  85756. */
  85757. get thumbImage(): Image;
  85758. set thumbImage(value: Image);
  85759. /**
  85760. * Gets or sets the length of the thumb
  85761. */
  85762. get thumbLength(): number;
  85763. set thumbLength(value: number);
  85764. /**
  85765. * Gets or sets the height of the thumb
  85766. */
  85767. get thumbHeight(): number;
  85768. set thumbHeight(value: number);
  85769. /**
  85770. * Gets or sets the height of the bar image
  85771. */
  85772. get barImageHeight(): number;
  85773. set barImageHeight(value: number);
  85774. /**
  85775. * Creates a new ImageScrollBar
  85776. * @param name defines the control name
  85777. */
  85778. constructor(name?: string | undefined);
  85779. protected _getTypeName(): string;
  85780. protected _getThumbThickness(): number;
  85781. _draw(context: CanvasRenderingContext2D): void;
  85782. private _first;
  85783. private _originX;
  85784. private _originY;
  85785. /** @hidden */
  85786. protected _updateValueFromPointer(x: number, y: number): void;
  85787. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85788. }
  85789. }
  85790. declare module BABYLON.GUI {
  85791. /**
  85792. * Class used to hold a viewer window and sliders in a grid
  85793. */
  85794. export class ScrollViewer extends Rectangle {
  85795. private _grid;
  85796. private _horizontalBarSpace;
  85797. private _verticalBarSpace;
  85798. private _dragSpace;
  85799. private _horizontalBar;
  85800. private _verticalBar;
  85801. private _barColor;
  85802. private _barBackground;
  85803. private _barImage;
  85804. private _horizontalBarImage;
  85805. private _verticalBarImage;
  85806. private _barBackgroundImage;
  85807. private _horizontalBarBackgroundImage;
  85808. private _verticalBarBackgroundImage;
  85809. private _barSize;
  85810. private _window;
  85811. private _pointerIsOver;
  85812. private _wheelPrecision;
  85813. private _onWheelObserver;
  85814. private _clientWidth;
  85815. private _clientHeight;
  85816. private _useImageBar;
  85817. private _thumbLength;
  85818. private _thumbHeight;
  85819. private _barImageHeight;
  85820. private _horizontalBarImageHeight;
  85821. private _verticalBarImageHeight;
  85822. private _oldWindowContentsWidth;
  85823. private _oldWindowContentsHeight;
  85824. /**
  85825. * Gets the horizontal scrollbar
  85826. */
  85827. get horizontalBar(): ScrollBar | ImageScrollBar;
  85828. /**
  85829. * Gets the vertical scrollbar
  85830. */
  85831. get verticalBar(): ScrollBar | ImageScrollBar;
  85832. /**
  85833. * Adds a new control to the current container
  85834. * @param control defines the control to add
  85835. * @returns the current container
  85836. */
  85837. addControl(control: BABYLON.Nullable<Control>): Container;
  85838. /**
  85839. * Removes a control from the current container
  85840. * @param control defines the control to remove
  85841. * @returns the current container
  85842. */
  85843. removeControl(control: Control): Container;
  85844. /** Gets the list of children */
  85845. get children(): Control[];
  85846. _flagDescendantsAsMatrixDirty(): void;
  85847. /**
  85848. * Freezes or unfreezes the controls in the window.
  85849. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85850. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85851. */
  85852. get freezeControls(): boolean;
  85853. set freezeControls(value: boolean);
  85854. /** Gets the bucket width */
  85855. get bucketWidth(): number;
  85856. /** Gets the bucket height */
  85857. get bucketHeight(): number;
  85858. /**
  85859. * Sets the bucket sizes.
  85860. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85861. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85862. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85863. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85864. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85865. * used), that's why it is not enabled by default.
  85866. * @param width width of the bucket
  85867. * @param height height of the bucket
  85868. */
  85869. setBucketSizes(width: number, height: number): void;
  85870. private _forceHorizontalBar;
  85871. private _forceVerticalBar;
  85872. /**
  85873. * Forces the horizontal scroll bar to be displayed
  85874. */
  85875. get forceHorizontalBar(): boolean;
  85876. set forceHorizontalBar(value: boolean);
  85877. /**
  85878. * Forces the vertical scroll bar to be displayed
  85879. */
  85880. get forceVerticalBar(): boolean;
  85881. set forceVerticalBar(value: boolean);
  85882. /**
  85883. * Creates a new ScrollViewer
  85884. * @param name of ScrollViewer
  85885. */
  85886. constructor(name?: string, isImageBased?: boolean);
  85887. /** Reset the scroll viewer window to initial size */
  85888. resetWindow(): void;
  85889. protected _getTypeName(): string;
  85890. private _buildClientSizes;
  85891. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85892. protected _postMeasure(): void;
  85893. /**
  85894. * Gets or sets the mouse wheel precision
  85895. * from 0 to 1 with a default value of 0.05
  85896. * */
  85897. get wheelPrecision(): number;
  85898. set wheelPrecision(value: number);
  85899. /** Gets or sets the scroll bar container background color */
  85900. get scrollBackground(): string;
  85901. set scrollBackground(color: string);
  85902. /** Gets or sets the bar color */
  85903. get barColor(): string;
  85904. set barColor(color: string);
  85905. /** Gets or sets the bar image */
  85906. get thumbImage(): Image;
  85907. set thumbImage(value: Image);
  85908. /** Gets or sets the horizontal bar image */
  85909. get horizontalThumbImage(): Image;
  85910. set horizontalThumbImage(value: Image);
  85911. /** Gets or sets the vertical bar image */
  85912. get verticalThumbImage(): Image;
  85913. set verticalThumbImage(value: Image);
  85914. /** Gets or sets the size of the bar */
  85915. get barSize(): number;
  85916. set barSize(value: number);
  85917. /** Gets or sets the length of the thumb */
  85918. get thumbLength(): number;
  85919. set thumbLength(value: number);
  85920. /** Gets or sets the height of the thumb */
  85921. get thumbHeight(): number;
  85922. set thumbHeight(value: number);
  85923. /** Gets or sets the height of the bar image */
  85924. get barImageHeight(): number;
  85925. set barImageHeight(value: number);
  85926. /** Gets or sets the height of the horizontal bar image */
  85927. get horizontalBarImageHeight(): number;
  85928. set horizontalBarImageHeight(value: number);
  85929. /** Gets or sets the height of the vertical bar image */
  85930. get verticalBarImageHeight(): number;
  85931. set verticalBarImageHeight(value: number);
  85932. /** Gets or sets the bar background */
  85933. get barBackground(): string;
  85934. set barBackground(color: string);
  85935. /** Gets or sets the bar background image */
  85936. get barImage(): Image;
  85937. set barImage(value: Image);
  85938. /** Gets or sets the horizontal bar background image */
  85939. get horizontalBarImage(): Image;
  85940. set horizontalBarImage(value: Image);
  85941. /** Gets or sets the vertical bar background image */
  85942. get verticalBarImage(): Image;
  85943. set verticalBarImage(value: Image);
  85944. private _setWindowPosition;
  85945. /** @hidden */
  85946. private _updateScroller;
  85947. _link(host: AdvancedDynamicTexture): void;
  85948. /** @hidden */
  85949. private _addBar;
  85950. /** @hidden */
  85951. private _attachWheel;
  85952. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85953. /** Releases associated resources */
  85954. dispose(): void;
  85955. }
  85956. }
  85957. declare module BABYLON.GUI {
  85958. /**
  85959. * Class used to create toggle buttons
  85960. */
  85961. export class ToggleButton extends Rectangle {
  85962. name?: string | undefined;
  85963. /**
  85964. * Function called to generate the toActive animation
  85965. */
  85966. toActiveAnimation: () => void;
  85967. /**
  85968. * Function called to generate the toInactive animation
  85969. */
  85970. toInactiveAnimation: () => void;
  85971. /**
  85972. * Function called to generate a pointer enter animation when the toggle button is active.
  85973. */
  85974. pointerEnterActiveAnimation: () => void;
  85975. /**
  85976. * Function called to generate a pointer out animation when the toggle button is active.
  85977. */
  85978. pointerOutActiveAnimation: () => void;
  85979. /**
  85980. * Function called to generate a pointer down animation when the toggle button is active.
  85981. */
  85982. pointerDownActiveAnimation: () => void;
  85983. /**
  85984. * Function called to generate a pointer up animation when the toggle button is active.
  85985. */
  85986. pointerUpActiveAnimation: () => void;
  85987. /**
  85988. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85989. */
  85990. pointerEnterInactiveAnimation: () => void;
  85991. /**
  85992. * Function called to generate a pointer out animation when the toggle button is inactive.
  85993. */
  85994. pointerOutInactiveAnimation: () => void;
  85995. /**
  85996. * Function called to generate a pointer down animation when the toggle button is inactive.
  85997. */
  85998. pointerDownInactiveAnimation: () => void;
  85999. /**
  86000. * Function called to generate a pointer up animation when the toggle button is inactive.
  86001. */
  86002. pointerUpInactiveAnimation: () => void;
  86003. /** BABYLON.Observable raised when isActive is changed */
  86004. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  86005. /**
  86006. * 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
  86007. */
  86008. delegatePickingToChildren: boolean;
  86009. private _image;
  86010. /**
  86011. * Returns the ToggleButton's image control if it exists
  86012. */
  86013. get image(): BABYLON.Nullable<Image>;
  86014. private _textBlock;
  86015. /**
  86016. * Returns the ToggleButton's child TextBlock control if it exists
  86017. */
  86018. get textBlock(): BABYLON.Nullable<TextBlock>;
  86019. private _group;
  86020. /** Gets or sets group name this toggle button belongs to */
  86021. get group(): string;
  86022. set group(value: string);
  86023. private _isActive;
  86024. /** Gets or sets a boolean indicating if the toogle button is active or not */
  86025. get isActive(): boolean;
  86026. set isActive(value: boolean);
  86027. /**
  86028. * Creates a new ToggleButton
  86029. * @param name defines the control name
  86030. * @param group defines the toggle group this toggle belongs to
  86031. */
  86032. constructor(name?: string | undefined, group?: string);
  86033. protected _getTypeName(): string;
  86034. /** @hidden */
  86035. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86036. /** @hidden */
  86037. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86038. /** @hidden */
  86039. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86040. /** @hidden */
  86041. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86042. /** @hidden */
  86043. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86044. }
  86045. }
  86046. declare module BABYLON.GUI {
  86047. /** Class used to render a grid */
  86048. export class DisplayGrid extends Control {
  86049. name?: string | undefined;
  86050. private _cellWidth;
  86051. private _cellHeight;
  86052. private _minorLineTickness;
  86053. private _minorLineColor;
  86054. private _majorLineTickness;
  86055. private _majorLineColor;
  86056. private _majorLineFrequency;
  86057. private _background;
  86058. private _displayMajorLines;
  86059. private _displayMinorLines;
  86060. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86061. get displayMinorLines(): boolean;
  86062. set displayMinorLines(value: boolean);
  86063. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86064. get displayMajorLines(): boolean;
  86065. set displayMajorLines(value: boolean);
  86066. /** Gets or sets background color (Black by default) */
  86067. get background(): string;
  86068. set background(value: string);
  86069. /** Gets or sets the width of each cell (20 by default) */
  86070. get cellWidth(): number;
  86071. set cellWidth(value: number);
  86072. /** Gets or sets the height of each cell (20 by default) */
  86073. get cellHeight(): number;
  86074. set cellHeight(value: number);
  86075. /** Gets or sets the tickness of minor lines (1 by default) */
  86076. get minorLineTickness(): number;
  86077. set minorLineTickness(value: number);
  86078. /** Gets or sets the color of minor lines (DarkGray by default) */
  86079. get minorLineColor(): string;
  86080. set minorLineColor(value: string);
  86081. /** Gets or sets the tickness of major lines (2 by default) */
  86082. get majorLineTickness(): number;
  86083. set majorLineTickness(value: number);
  86084. /** Gets or sets the color of major lines (White by default) */
  86085. get majorLineColor(): string;
  86086. set majorLineColor(value: string);
  86087. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86088. get majorLineFrequency(): number;
  86089. set majorLineFrequency(value: number);
  86090. /**
  86091. * Creates a new GridDisplayRectangle
  86092. * @param name defines the control name
  86093. */
  86094. constructor(name?: string | undefined);
  86095. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86096. protected _getTypeName(): string;
  86097. }
  86098. }
  86099. declare module BABYLON.GUI {
  86100. /**
  86101. * Class used to create slider controls based on images
  86102. */
  86103. export class ImageBasedSlider extends BaseSlider {
  86104. name?: string | undefined;
  86105. private _backgroundImage;
  86106. private _thumbImage;
  86107. private _valueBarImage;
  86108. private _tempMeasure;
  86109. get displayThumb(): boolean;
  86110. set displayThumb(value: boolean);
  86111. /**
  86112. * Gets or sets the image used to render the background
  86113. */
  86114. get backgroundImage(): Image;
  86115. set backgroundImage(value: Image);
  86116. /**
  86117. * Gets or sets the image used to render the value bar
  86118. */
  86119. get valueBarImage(): Image;
  86120. set valueBarImage(value: Image);
  86121. /**
  86122. * Gets or sets the image used to render the thumb
  86123. */
  86124. get thumbImage(): Image;
  86125. set thumbImage(value: Image);
  86126. /**
  86127. * Creates a new ImageBasedSlider
  86128. * @param name defines the control name
  86129. */
  86130. constructor(name?: string | undefined);
  86131. protected _getTypeName(): string;
  86132. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86133. }
  86134. }
  86135. declare module BABYLON.GUI {
  86136. /**
  86137. * Forcing an export so that this code will execute
  86138. * @hidden
  86139. */
  86140. const name = "Statics";
  86141. }
  86142. declare module BABYLON.GUI {
  86143. /**
  86144. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86145. */
  86146. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86147. /**
  86148. * Define the instrumented AdvancedDynamicTexture.
  86149. */
  86150. texture: AdvancedDynamicTexture;
  86151. private _captureRenderTime;
  86152. private _renderTime;
  86153. private _captureLayoutTime;
  86154. private _layoutTime;
  86155. private _onBeginRenderObserver;
  86156. private _onEndRenderObserver;
  86157. private _onBeginLayoutObserver;
  86158. private _onEndLayoutObserver;
  86159. /**
  86160. * Gets the perf counter used to capture render time
  86161. */
  86162. get renderTimeCounter(): BABYLON.PerfCounter;
  86163. /**
  86164. * Gets the perf counter used to capture layout time
  86165. */
  86166. get layoutTimeCounter(): BABYLON.PerfCounter;
  86167. /**
  86168. * Enable or disable the render time capture
  86169. */
  86170. get captureRenderTime(): boolean;
  86171. set captureRenderTime(value: boolean);
  86172. /**
  86173. * Enable or disable the layout time capture
  86174. */
  86175. get captureLayoutTime(): boolean;
  86176. set captureLayoutTime(value: boolean);
  86177. /**
  86178. * Instantiates a new advanced dynamic texture instrumentation.
  86179. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86180. * @param texture Defines the AdvancedDynamicTexture to instrument
  86181. */
  86182. constructor(
  86183. /**
  86184. * Define the instrumented AdvancedDynamicTexture.
  86185. */
  86186. texture: AdvancedDynamicTexture);
  86187. /**
  86188. * Dispose and release associated resources.
  86189. */
  86190. dispose(): void;
  86191. }
  86192. }
  86193. declare module BABYLON.GUI {
  86194. /**
  86195. * Class used to load GUI via XML.
  86196. */
  86197. export class XmlLoader {
  86198. private _nodes;
  86199. private _nodeTypes;
  86200. private _isLoaded;
  86201. private _objectAttributes;
  86202. private _parentClass;
  86203. /**
  86204. * Create a new xml loader
  86205. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86206. */
  86207. constructor(parentClass?: null);
  86208. private _getChainElement;
  86209. private _getClassAttribute;
  86210. private _createGuiElement;
  86211. private _parseGrid;
  86212. private _parseElement;
  86213. private _prepareSourceElement;
  86214. private _parseElementsFromSource;
  86215. private _parseXml;
  86216. /**
  86217. * Gets if the loading has finished.
  86218. * @returns whether the loading has finished or not
  86219. */
  86220. isLoaded(): boolean;
  86221. /**
  86222. * Gets a loaded node / control by id.
  86223. * @param id the Controls id set in the xml
  86224. * @returns element of type Control
  86225. */
  86226. getNodeById(id: string): any;
  86227. /**
  86228. * Gets all loaded nodes / controls
  86229. * @returns Array of controls
  86230. */
  86231. getNodes(): any;
  86232. /**
  86233. * Initiates the xml layout loading
  86234. * @param xmlFile defines the xml layout to load
  86235. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86236. * @param callback defines the callback called on layout load.
  86237. */
  86238. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86239. }
  86240. }
  86241. declare module BABYLON.GUI {
  86242. /**
  86243. * Class used to create containers for controls
  86244. */
  86245. export class Container3D extends Control3D {
  86246. private _blockLayout;
  86247. /**
  86248. * Gets the list of child controls
  86249. */
  86250. protected _children: Control3D[];
  86251. /**
  86252. * Gets the list of child controls
  86253. */
  86254. get children(): Array<Control3D>;
  86255. /**
  86256. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86257. * This is helpful to optimize layout operation when adding multiple children in a row
  86258. */
  86259. get blockLayout(): boolean;
  86260. set blockLayout(value: boolean);
  86261. /**
  86262. * Creates a new container
  86263. * @param name defines the container name
  86264. */
  86265. constructor(name?: string);
  86266. /**
  86267. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86268. * @returns the current container
  86269. */
  86270. updateLayout(): Container3D;
  86271. /**
  86272. * Gets a boolean indicating if the given control is in the children of this control
  86273. * @param control defines the control to check
  86274. * @returns true if the control is in the child list
  86275. */
  86276. containsControl(control: Control3D): boolean;
  86277. /**
  86278. * Adds a control to the children of this control
  86279. * @param control defines the control to add
  86280. * @returns the current container
  86281. */
  86282. addControl(control: Control3D): Container3D;
  86283. /**
  86284. * This function will be called everytime a new control is added
  86285. */
  86286. protected _arrangeChildren(): void;
  86287. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86288. /**
  86289. * Removes a control from the children of this control
  86290. * @param control defines the control to remove
  86291. * @returns the current container
  86292. */
  86293. removeControl(control: Control3D): Container3D;
  86294. protected _getTypeName(): string;
  86295. /**
  86296. * Releases all associated resources
  86297. */
  86298. dispose(): void;
  86299. /** Control rotation will remain unchanged */
  86300. static readonly UNSET_ORIENTATION: number;
  86301. /** Control will rotate to make it look at sphere central axis */
  86302. static readonly FACEORIGIN_ORIENTATION: number;
  86303. /** Control will rotate to make it look back at sphere central axis */
  86304. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86305. /** Control will rotate to look at z axis (0, 0, 1) */
  86306. static readonly FACEFORWARD_ORIENTATION: number;
  86307. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86308. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86309. }
  86310. }
  86311. declare module BABYLON.GUI {
  86312. /**
  86313. * Class used to manage 3D user interface
  86314. * @see https://doc.babylonjs.com/how_to/gui3d
  86315. */
  86316. export class GUI3DManager implements BABYLON.IDisposable {
  86317. private _scene;
  86318. private _sceneDisposeObserver;
  86319. private _utilityLayer;
  86320. private _rootContainer;
  86321. private _pointerObserver;
  86322. private _pointerOutObserver;
  86323. /** @hidden */
  86324. _lastPickedControl: Control3D;
  86325. /** @hidden */
  86326. _lastControlOver: {
  86327. [pointerId: number]: Control3D;
  86328. };
  86329. /** @hidden */
  86330. _lastControlDown: {
  86331. [pointerId: number]: Control3D;
  86332. };
  86333. /**
  86334. * BABYLON.Observable raised when the point picked by the pointer events changed
  86335. */
  86336. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86337. /** @hidden */
  86338. _sharedMaterials: {
  86339. [key: string]: BABYLON.Material;
  86340. };
  86341. /** Gets the hosting scene */
  86342. get scene(): BABYLON.Scene;
  86343. /** Gets associated utility layer */
  86344. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86345. /**
  86346. * Creates a new GUI3DManager
  86347. * @param scene
  86348. */
  86349. constructor(scene?: BABYLON.Scene);
  86350. private _handlePointerOut;
  86351. private _doPicking;
  86352. /**
  86353. * Gets the root container
  86354. */
  86355. get rootContainer(): Container3D;
  86356. /**
  86357. * Gets a boolean indicating if the given control is in the root child list
  86358. * @param control defines the control to check
  86359. * @returns true if the control is in the root child list
  86360. */
  86361. containsControl(control: Control3D): boolean;
  86362. /**
  86363. * Adds a control to the root child list
  86364. * @param control defines the control to add
  86365. * @returns the current manager
  86366. */
  86367. addControl(control: Control3D): GUI3DManager;
  86368. /**
  86369. * Removes a control from the root child list
  86370. * @param control defines the control to remove
  86371. * @returns the current container
  86372. */
  86373. removeControl(control: Control3D): GUI3DManager;
  86374. /**
  86375. * Releases all associated resources
  86376. */
  86377. dispose(): void;
  86378. }
  86379. }
  86380. declare module BABYLON.GUI {
  86381. /**
  86382. * Class used to transport BABYLON.Vector3 information for pointer events
  86383. */
  86384. export class Vector3WithInfo extends BABYLON.Vector3 {
  86385. /** defines the current mouse button index */
  86386. buttonIndex: number;
  86387. /**
  86388. * Creates a new Vector3WithInfo
  86389. * @param source defines the vector3 data to transport
  86390. * @param buttonIndex defines the current mouse button index
  86391. */
  86392. constructor(source: BABYLON.Vector3,
  86393. /** defines the current mouse button index */
  86394. buttonIndex?: number);
  86395. }
  86396. }
  86397. declare module BABYLON.GUI {
  86398. /**
  86399. * Class used as base class for controls
  86400. */
  86401. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86402. /** Defines the control name */
  86403. name?: string | undefined;
  86404. /** @hidden */
  86405. _host: GUI3DManager;
  86406. private _node;
  86407. private _downCount;
  86408. private _enterCount;
  86409. private _downPointerIds;
  86410. private _isVisible;
  86411. /** Gets or sets the control position in world space */
  86412. get position(): BABYLON.Vector3;
  86413. set position(value: BABYLON.Vector3);
  86414. /** Gets or sets the control scaling in world space */
  86415. get scaling(): BABYLON.Vector3;
  86416. set scaling(value: BABYLON.Vector3);
  86417. /** Callback used to start pointer enter animation */
  86418. pointerEnterAnimation: () => void;
  86419. /** Callback used to start pointer out animation */
  86420. pointerOutAnimation: () => void;
  86421. /** Callback used to start pointer down animation */
  86422. pointerDownAnimation: () => void;
  86423. /** Callback used to start pointer up animation */
  86424. pointerUpAnimation: () => void;
  86425. /**
  86426. * An event triggered when the pointer move over the control
  86427. */
  86428. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86429. /**
  86430. * An event triggered when the pointer move out of the control
  86431. */
  86432. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86433. /**
  86434. * An event triggered when the pointer taps the control
  86435. */
  86436. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86437. /**
  86438. * An event triggered when pointer is up
  86439. */
  86440. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86441. /**
  86442. * An event triggered when a control is clicked on (with a mouse)
  86443. */
  86444. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86445. /**
  86446. * An event triggered when pointer enters the control
  86447. */
  86448. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86449. /**
  86450. * Gets or sets the parent container
  86451. */
  86452. parent: BABYLON.Nullable<Container3D>;
  86453. private _behaviors;
  86454. /**
  86455. * Gets the list of attached behaviors
  86456. * @see https://doc.babylonjs.com/features/behaviour
  86457. */
  86458. get behaviors(): BABYLON.Behavior<Control3D>[];
  86459. /**
  86460. * Attach a behavior to the control
  86461. * @see https://doc.babylonjs.com/features/behaviour
  86462. * @param behavior defines the behavior to attach
  86463. * @returns the current control
  86464. */
  86465. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86466. /**
  86467. * Remove an attached behavior
  86468. * @see https://doc.babylonjs.com/features/behaviour
  86469. * @param behavior defines the behavior to attach
  86470. * @returns the current control
  86471. */
  86472. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86473. /**
  86474. * Gets an attached behavior by name
  86475. * @param name defines the name of the behavior to look for
  86476. * @see https://doc.babylonjs.com/features/behaviour
  86477. * @returns null if behavior was not found else the requested behavior
  86478. */
  86479. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86480. /** Gets or sets a boolean indicating if the control is visible */
  86481. get isVisible(): boolean;
  86482. set isVisible(value: boolean);
  86483. /**
  86484. * Creates a new control
  86485. * @param name defines the control name
  86486. */
  86487. constructor(
  86488. /** Defines the control name */
  86489. name?: string | undefined);
  86490. /**
  86491. * Gets a string representing the class name
  86492. */
  86493. get typeName(): string;
  86494. /**
  86495. * Get the current class name of the control.
  86496. * @returns current class name
  86497. */
  86498. getClassName(): string;
  86499. protected _getTypeName(): string;
  86500. /**
  86501. * Gets the transform node used by this control
  86502. */
  86503. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86504. /**
  86505. * Gets the mesh used to render this control
  86506. */
  86507. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86508. /**
  86509. * Link the control as child of the given node
  86510. * @param node defines the node to link to. Use null to unlink the control
  86511. * @returns the current control
  86512. */
  86513. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86514. /** @hidden **/
  86515. _prepareNode(scene: BABYLON.Scene): void;
  86516. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86517. /**
  86518. * Node creation.
  86519. * Can be overriden by children
  86520. * @param scene defines the scene where the node must be attached
  86521. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86522. */
  86523. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86524. /**
  86525. * Affect a material to the given mesh
  86526. * @param mesh defines the mesh which will represent the control
  86527. */
  86528. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86529. /** @hidden */
  86530. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86531. /** @hidden */
  86532. _onPointerEnter(target: Control3D): boolean;
  86533. /** @hidden */
  86534. _onPointerOut(target: Control3D): void;
  86535. /** @hidden */
  86536. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86537. /** @hidden */
  86538. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86539. /** @hidden */
  86540. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86541. /** @hidden */
  86542. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86543. /** @hidden */
  86544. _disposeNode(): void;
  86545. /**
  86546. * Releases all associated resources
  86547. */
  86548. dispose(): void;
  86549. }
  86550. }
  86551. declare module BABYLON.GUI {
  86552. /**
  86553. * Class used as a root to all buttons
  86554. */
  86555. export class AbstractButton3D extends Control3D {
  86556. /**
  86557. * Creates a new button
  86558. * @param name defines the control name
  86559. */
  86560. constructor(name?: string);
  86561. protected _getTypeName(): string;
  86562. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86563. }
  86564. }
  86565. declare module BABYLON.GUI {
  86566. /**
  86567. * Class used to create a button in 3D
  86568. */
  86569. export class Button3D extends AbstractButton3D {
  86570. /** @hidden */
  86571. protected _currentMaterial: BABYLON.Material;
  86572. private _facadeTexture;
  86573. private _content;
  86574. private _contentResolution;
  86575. private _contentScaleRatio;
  86576. /**
  86577. * Gets or sets the texture resolution used to render content (512 by default)
  86578. */
  86579. get contentResolution(): BABYLON.int;
  86580. set contentResolution(value: BABYLON.int);
  86581. /**
  86582. * Gets or sets the texture scale ratio used to render content (2 by default)
  86583. */
  86584. get contentScaleRatio(): number;
  86585. set contentScaleRatio(value: number);
  86586. protected _disposeFacadeTexture(): void;
  86587. protected _resetContent(): void;
  86588. /**
  86589. * Creates a new button
  86590. * @param name defines the control name
  86591. */
  86592. constructor(name?: string);
  86593. /**
  86594. * Gets or sets the GUI 2D content used to display the button's facade
  86595. */
  86596. get content(): Control;
  86597. set content(value: Control);
  86598. /**
  86599. * Apply the facade texture (created from the content property).
  86600. * This function can be overloaded by child classes
  86601. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86602. */
  86603. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86604. protected _getTypeName(): string;
  86605. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86606. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86607. /**
  86608. * Releases all associated resources
  86609. */
  86610. dispose(): void;
  86611. }
  86612. }
  86613. declare module BABYLON.GUI {
  86614. /**
  86615. * Abstract class used to create a container panel deployed on the surface of a volume
  86616. */
  86617. export abstract class VolumeBasedPanel extends Container3D {
  86618. private _columns;
  86619. private _rows;
  86620. private _rowThenColum;
  86621. private _orientation;
  86622. protected _cellWidth: number;
  86623. protected _cellHeight: number;
  86624. /**
  86625. * Gets or sets the distance between elements
  86626. */
  86627. margin: number;
  86628. /**
  86629. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86630. * | Value | Type | Description |
  86631. * | ----- | ----------------------------------- | ----------- |
  86632. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86633. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86634. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86635. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86636. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86637. */
  86638. get orientation(): number;
  86639. set orientation(value: number);
  86640. /**
  86641. * Gets or sets the number of columns requested (10 by default).
  86642. * The panel will automatically compute the number of rows based on number of child controls.
  86643. */
  86644. get columns(): BABYLON.int;
  86645. set columns(value: BABYLON.int);
  86646. /**
  86647. * Gets or sets a the number of rows requested.
  86648. * The panel will automatically compute the number of columns based on number of child controls.
  86649. */
  86650. get rows(): BABYLON.int;
  86651. set rows(value: BABYLON.int);
  86652. /**
  86653. * Creates new VolumeBasedPanel
  86654. */
  86655. constructor();
  86656. protected _arrangeChildren(): void;
  86657. /** Child classes must implement this function to provide correct control positioning */
  86658. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86659. /** Child classes can implement this function to provide additional processing */
  86660. protected _finalProcessing(): void;
  86661. }
  86662. }
  86663. declare module BABYLON.GUI {
  86664. /**
  86665. * Class used to create a container panel deployed on the surface of a cylinder
  86666. */
  86667. export class CylinderPanel extends VolumeBasedPanel {
  86668. private _radius;
  86669. /**
  86670. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86671. */
  86672. get radius(): BABYLON.float;
  86673. set radius(value: BABYLON.float);
  86674. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86675. private _cylindricalMapping;
  86676. }
  86677. }
  86678. declare module BABYLON.GUI {
  86679. /** @hidden */
  86680. export var fluentVertexShader: {
  86681. name: string;
  86682. shader: string;
  86683. };
  86684. }
  86685. declare module BABYLON.GUI {
  86686. /** @hidden */
  86687. export var fluentPixelShader: {
  86688. name: string;
  86689. shader: string;
  86690. };
  86691. }
  86692. declare module BABYLON.GUI {
  86693. /** @hidden */
  86694. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86695. INNERGLOW: boolean;
  86696. BORDER: boolean;
  86697. HOVERLIGHT: boolean;
  86698. TEXTURE: boolean;
  86699. constructor();
  86700. }
  86701. /**
  86702. * Class used to render controls with fluent desgin
  86703. */
  86704. export class FluentMaterial extends BABYLON.PushMaterial {
  86705. /**
  86706. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86707. */
  86708. innerGlowColorIntensity: number;
  86709. /**
  86710. * Gets or sets the inner glow color (white by default)
  86711. */
  86712. innerGlowColor: BABYLON.Color3;
  86713. /**
  86714. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86715. */
  86716. albedoColor: BABYLON.Color3;
  86717. /**
  86718. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86719. */
  86720. renderBorders: boolean;
  86721. /**
  86722. * Gets or sets border width (default is 0.5)
  86723. */
  86724. borderWidth: number;
  86725. /**
  86726. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86727. */
  86728. edgeSmoothingValue: number;
  86729. /**
  86730. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86731. */
  86732. borderMinValue: number;
  86733. /**
  86734. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86735. */
  86736. renderHoverLight: boolean;
  86737. /**
  86738. * Gets or sets the radius used to render the hover light (default is 1.0)
  86739. */
  86740. hoverRadius: number;
  86741. /**
  86742. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86743. */
  86744. hoverColor: BABYLON.Color4;
  86745. /**
  86746. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86747. */
  86748. hoverPosition: BABYLON.Vector3;
  86749. private _albedoTexture;
  86750. /** Gets or sets the texture to use for albedo color */
  86751. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86752. /**
  86753. * Creates a new Fluent material
  86754. * @param name defines the name of the material
  86755. * @param scene defines the hosting scene
  86756. */
  86757. constructor(name: string, scene: BABYLON.Scene);
  86758. needAlphaBlending(): boolean;
  86759. needAlphaTesting(): boolean;
  86760. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86761. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86763. getActiveTextures(): BABYLON.BaseTexture[];
  86764. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86765. dispose(forceDisposeEffect?: boolean): void;
  86766. clone(name: string): FluentMaterial;
  86767. serialize(): any;
  86768. getClassName(): string;
  86769. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86770. }
  86771. }
  86772. declare module BABYLON.GUI {
  86773. /**
  86774. * Class used to create a holographic button in 3D
  86775. */
  86776. export class HolographicButton extends Button3D {
  86777. private _backPlate;
  86778. private _textPlate;
  86779. private _frontPlate;
  86780. private _text;
  86781. private _imageUrl;
  86782. private _shareMaterials;
  86783. private _frontMaterial;
  86784. private _backMaterial;
  86785. private _plateMaterial;
  86786. private _pickedPointObserver;
  86787. private _tooltipFade;
  86788. private _tooltipTextBlock;
  86789. private _tooltipTexture;
  86790. private _tooltipMesh;
  86791. private _tooltipHoverObserver;
  86792. private _tooltipOutObserver;
  86793. private _disposeTooltip;
  86794. /**
  86795. * Rendering ground id of all the mesh in the button
  86796. */
  86797. set renderingGroupId(id: number);
  86798. get renderingGroupId(): number;
  86799. /**
  86800. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86801. */
  86802. set tooltipText(text: BABYLON.Nullable<string>);
  86803. get tooltipText(): BABYLON.Nullable<string>;
  86804. /**
  86805. * Gets or sets text for the button
  86806. */
  86807. get text(): string;
  86808. set text(value: string);
  86809. /**
  86810. * Gets or sets the image url for the button
  86811. */
  86812. get imageUrl(): string;
  86813. set imageUrl(value: string);
  86814. /**
  86815. * Gets the back material used by this button
  86816. */
  86817. get backMaterial(): FluentMaterial;
  86818. /**
  86819. * Gets the front material used by this button
  86820. */
  86821. get frontMaterial(): FluentMaterial;
  86822. /**
  86823. * Gets the plate material used by this button
  86824. */
  86825. get plateMaterial(): BABYLON.StandardMaterial;
  86826. /**
  86827. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86828. */
  86829. get shareMaterials(): boolean;
  86830. /**
  86831. * Creates a new button
  86832. * @param name defines the control name
  86833. */
  86834. constructor(name?: string, shareMaterials?: boolean);
  86835. protected _getTypeName(): string;
  86836. private _rebuildContent;
  86837. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86838. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86839. private _createBackMaterial;
  86840. private _createFrontMaterial;
  86841. private _createPlateMaterial;
  86842. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86843. /**
  86844. * Releases all associated resources
  86845. */
  86846. dispose(): void;
  86847. }
  86848. }
  86849. declare module BABYLON.GUI {
  86850. /**
  86851. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86852. */
  86853. export class MeshButton3D extends Button3D {
  86854. /** @hidden */
  86855. protected _currentMesh: BABYLON.Mesh;
  86856. /**
  86857. * Creates a new 3D button based on a mesh
  86858. * @param mesh mesh to become a 3D button
  86859. * @param name defines the control name
  86860. */
  86861. constructor(mesh: BABYLON.Mesh, name?: string);
  86862. protected _getTypeName(): string;
  86863. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86864. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86865. }
  86866. }
  86867. declare module BABYLON.GUI {
  86868. /**
  86869. * Class used to create a container panel deployed on the surface of a plane
  86870. */
  86871. export class PlanePanel extends VolumeBasedPanel {
  86872. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86873. }
  86874. }
  86875. declare module BABYLON.GUI {
  86876. /**
  86877. * Class used to create a container panel where items get randomized planar mapping
  86878. */
  86879. export class ScatterPanel extends VolumeBasedPanel {
  86880. private _iteration;
  86881. /**
  86882. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86883. */
  86884. get iteration(): BABYLON.float;
  86885. set iteration(value: BABYLON.float);
  86886. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86887. private _scatterMapping;
  86888. protected _finalProcessing(): void;
  86889. }
  86890. }
  86891. declare module BABYLON.GUI {
  86892. /**
  86893. * Class used to create a container panel deployed on the surface of a sphere
  86894. */
  86895. export class SpherePanel extends VolumeBasedPanel {
  86896. private _radius;
  86897. /**
  86898. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86899. */
  86900. get radius(): BABYLON.float;
  86901. set radius(value: BABYLON.float);
  86902. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86903. private _sphericalMapping;
  86904. }
  86905. }
  86906. declare module BABYLON.GUI {
  86907. /**
  86908. * Class used to create a stack panel in 3D on XY plane
  86909. */
  86910. export class StackPanel3D extends Container3D {
  86911. private _isVertical;
  86912. /**
  86913. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86914. */
  86915. get isVertical(): boolean;
  86916. set isVertical(value: boolean);
  86917. /**
  86918. * Gets or sets the distance between elements
  86919. */
  86920. margin: number;
  86921. /**
  86922. * Creates new StackPanel
  86923. * @param isVertical
  86924. */
  86925. constructor(isVertical?: boolean);
  86926. protected _arrangeChildren(): void;
  86927. }
  86928. }
  86929. declare module BABYLON {
  86930. /**
  86931. * Configuration for glTF validation
  86932. */
  86933. export interface IGLTFValidationConfiguration {
  86934. /**
  86935. * The url of the glTF validator.
  86936. */
  86937. url: string;
  86938. }
  86939. /**
  86940. * glTF validation
  86941. */
  86942. export class GLTFValidation {
  86943. /**
  86944. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86945. */
  86946. static Configuration: IGLTFValidationConfiguration;
  86947. private static _LoadScriptPromise;
  86948. /**
  86949. * Validate a glTF asset using the glTF-Validator.
  86950. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86951. * @param rootUrl The root url for the glTF
  86952. * @param fileName The file name for the glTF
  86953. * @param getExternalResource The callback to get external resources for the glTF validator
  86954. * @returns A promise that resolves with the glTF validation results once complete
  86955. */
  86956. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86957. }
  86958. }
  86959. declare module BABYLON {
  86960. /**
  86961. * Mode that determines the coordinate system to use.
  86962. */
  86963. export enum GLTFLoaderCoordinateSystemMode {
  86964. /**
  86965. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86966. */
  86967. AUTO = 0,
  86968. /**
  86969. * Sets the useRightHandedSystem flag on the scene.
  86970. */
  86971. FORCE_RIGHT_HANDED = 1
  86972. }
  86973. /**
  86974. * Mode that determines what animations will start.
  86975. */
  86976. export enum GLTFLoaderAnimationStartMode {
  86977. /**
  86978. * No animation will start.
  86979. */
  86980. NONE = 0,
  86981. /**
  86982. * The first animation will start.
  86983. */
  86984. FIRST = 1,
  86985. /**
  86986. * All animations will start.
  86987. */
  86988. ALL = 2
  86989. }
  86990. /**
  86991. * Interface that contains the data for the glTF asset.
  86992. */
  86993. export interface IGLTFLoaderData {
  86994. /**
  86995. * The object that represents the glTF JSON.
  86996. */
  86997. json: Object;
  86998. /**
  86999. * The BIN chunk of a binary glTF.
  87000. */
  87001. bin: Nullable<IDataBuffer>;
  87002. }
  87003. /**
  87004. * Interface for extending the loader.
  87005. */
  87006. export interface IGLTFLoaderExtension {
  87007. /**
  87008. * The name of this extension.
  87009. */
  87010. readonly name: string;
  87011. /**
  87012. * Defines whether this extension is enabled.
  87013. */
  87014. enabled: boolean;
  87015. /**
  87016. * Defines the order of this extension.
  87017. * The loader sorts the extensions using these values when loading.
  87018. */
  87019. order?: number;
  87020. }
  87021. /**
  87022. * Loader state.
  87023. */
  87024. export enum GLTFLoaderState {
  87025. /**
  87026. * The asset is loading.
  87027. */
  87028. LOADING = 0,
  87029. /**
  87030. * The asset is ready for rendering.
  87031. */
  87032. READY = 1,
  87033. /**
  87034. * The asset is completely loaded.
  87035. */
  87036. COMPLETE = 2
  87037. }
  87038. /** @hidden */
  87039. export interface IGLTFLoader extends IDisposable {
  87040. readonly state: Nullable<GLTFLoaderState>;
  87041. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87042. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87043. }
  87044. /**
  87045. * File loader for loading glTF files into a scene.
  87046. */
  87047. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87048. /** @hidden */
  87049. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87050. /** @hidden */
  87051. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87052. /**
  87053. * Raised when the asset has been parsed
  87054. */
  87055. onParsedObservable: Observable<IGLTFLoaderData>;
  87056. private _onParsedObserver;
  87057. /**
  87058. * Raised when the asset has been parsed
  87059. */
  87060. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87061. /**
  87062. * 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.
  87063. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87064. * Defaults to true.
  87065. * @hidden
  87066. */
  87067. static IncrementalLoading: boolean;
  87068. /**
  87069. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87070. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87071. * @hidden
  87072. */
  87073. static HomogeneousCoordinates: boolean;
  87074. /**
  87075. * The coordinate system mode. Defaults to AUTO.
  87076. */
  87077. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87078. /**
  87079. * The animation start mode. Defaults to FIRST.
  87080. */
  87081. animationStartMode: GLTFLoaderAnimationStartMode;
  87082. /**
  87083. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87084. */
  87085. compileMaterials: boolean;
  87086. /**
  87087. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87088. */
  87089. useClipPlane: boolean;
  87090. /**
  87091. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87092. */
  87093. compileShadowGenerators: boolean;
  87094. /**
  87095. * Defines if the Alpha blended materials are only applied as coverage.
  87096. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87097. * If true, no extra effects are applied to transparent pixels.
  87098. */
  87099. transparencyAsCoverage: boolean;
  87100. /**
  87101. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87102. * Enabling will disable offline support and glTF validator.
  87103. * Defaults to false.
  87104. */
  87105. useRangeRequests: boolean;
  87106. /**
  87107. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87108. */
  87109. createInstances: boolean;
  87110. /**
  87111. * 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.
  87112. */
  87113. alwaysComputeBoundingBox: boolean;
  87114. /**
  87115. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87116. */
  87117. loadAllMaterials: boolean;
  87118. /**
  87119. * Function called before loading a url referenced by the asset.
  87120. */
  87121. preprocessUrlAsync: (url: string) => Promise<string>;
  87122. /**
  87123. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87124. * 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, ...)
  87125. */
  87126. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87127. private _onMeshLoadedObserver;
  87128. /**
  87129. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87130. * 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, ...)
  87131. */
  87132. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87133. /**
  87134. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87135. */
  87136. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87137. private _onTextureLoadedObserver;
  87138. /**
  87139. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87140. */
  87141. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87142. /**
  87143. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87144. */
  87145. readonly onMaterialLoadedObservable: Observable<Material>;
  87146. private _onMaterialLoadedObserver;
  87147. /**
  87148. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87149. */
  87150. set onMaterialLoaded(callback: (material: Material) => void);
  87151. /**
  87152. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87153. */
  87154. readonly onCameraLoadedObservable: Observable<Camera>;
  87155. private _onCameraLoadedObserver;
  87156. /**
  87157. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87158. */
  87159. set onCameraLoaded(callback: (camera: Camera) => void);
  87160. /**
  87161. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87162. * For assets with LODs, raised when all of the LODs are complete.
  87163. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87164. */
  87165. readonly onCompleteObservable: Observable<void>;
  87166. private _onCompleteObserver;
  87167. /**
  87168. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87169. * For assets with LODs, raised when all of the LODs are complete.
  87170. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87171. */
  87172. set onComplete(callback: () => void);
  87173. /**
  87174. * Observable raised when an error occurs.
  87175. */
  87176. readonly onErrorObservable: Observable<any>;
  87177. private _onErrorObserver;
  87178. /**
  87179. * Callback raised when an error occurs.
  87180. */
  87181. set onError(callback: (reason: any) => void);
  87182. /**
  87183. * Observable raised after the loader is disposed.
  87184. */
  87185. readonly onDisposeObservable: Observable<void>;
  87186. private _onDisposeObserver;
  87187. /**
  87188. * Callback raised after the loader is disposed.
  87189. */
  87190. set onDispose(callback: () => void);
  87191. /**
  87192. * Observable raised after a loader extension is created.
  87193. * Set additional options for a loader extension in this event.
  87194. */
  87195. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87196. private _onExtensionLoadedObserver;
  87197. /**
  87198. * Callback raised after a loader extension is created.
  87199. */
  87200. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87201. /**
  87202. * Defines if the loader logging is enabled.
  87203. */
  87204. get loggingEnabled(): boolean;
  87205. set loggingEnabled(value: boolean);
  87206. /**
  87207. * Defines if the loader should capture performance counters.
  87208. */
  87209. get capturePerformanceCounters(): boolean;
  87210. set capturePerformanceCounters(value: boolean);
  87211. /**
  87212. * Defines if the loader should validate the asset.
  87213. */
  87214. validate: boolean;
  87215. /**
  87216. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87217. */
  87218. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87219. private _onValidatedObserver;
  87220. /**
  87221. * Callback raised after a loader extension is created.
  87222. */
  87223. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87224. private _loader;
  87225. private _progressCallback?;
  87226. private _requests;
  87227. private static magicBase64Encoded;
  87228. /**
  87229. * Name of the loader ("gltf")
  87230. */
  87231. name: string;
  87232. /** @hidden */
  87233. extensions: ISceneLoaderPluginExtensions;
  87234. /**
  87235. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87236. */
  87237. dispose(): void;
  87238. /** @hidden */
  87239. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87240. /** @hidden */
  87241. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87242. /** @hidden */
  87243. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87244. /** @hidden */
  87245. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87246. /** @hidden */
  87247. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87248. /** @hidden */
  87249. canDirectLoad(data: string): boolean;
  87250. /** @hidden */
  87251. directLoad(scene: Scene, data: string): Promise<any>;
  87252. /**
  87253. * The callback that allows custom handling of the root url based on the response url.
  87254. * @param rootUrl the original root url
  87255. * @param responseURL the response url if available
  87256. * @returns the new root url
  87257. */
  87258. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87259. /** @hidden */
  87260. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87261. /**
  87262. * The loader state or null if the loader is not active.
  87263. */
  87264. get loaderState(): Nullable<GLTFLoaderState>;
  87265. /**
  87266. * Returns a promise that resolves when the asset is completely loaded.
  87267. * @returns a promise that resolves when the asset is completely loaded.
  87268. */
  87269. whenCompleteAsync(): Promise<void>;
  87270. /** @hidden */
  87271. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87272. /** @hidden */
  87273. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87274. private _onProgress;
  87275. private _validate;
  87276. private _getLoader;
  87277. private _parseJson;
  87278. private _unpackBinaryAsync;
  87279. private _unpackBinaryV1Async;
  87280. private _unpackBinaryV2Async;
  87281. private static _parseVersion;
  87282. private static _compareVersion;
  87283. private static readonly _logSpaces;
  87284. private _logIndentLevel;
  87285. private _loggingEnabled;
  87286. /** @hidden */
  87287. _log: (message: string) => void;
  87288. /** @hidden */
  87289. _logOpen(message: string): void;
  87290. /** @hidden */
  87291. _logClose(): void;
  87292. private _logEnabled;
  87293. private _logDisabled;
  87294. private _capturePerformanceCounters;
  87295. /** @hidden */
  87296. _startPerformanceCounter: (counterName: string) => void;
  87297. /** @hidden */
  87298. _endPerformanceCounter: (counterName: string) => void;
  87299. private _startPerformanceCounterEnabled;
  87300. private _startPerformanceCounterDisabled;
  87301. private _endPerformanceCounterEnabled;
  87302. private _endPerformanceCounterDisabled;
  87303. }
  87304. }
  87305. declare module BABYLON.GLTF1 {
  87306. /**
  87307. * Enums
  87308. * @hidden
  87309. */
  87310. export enum EComponentType {
  87311. BYTE = 5120,
  87312. UNSIGNED_BYTE = 5121,
  87313. SHORT = 5122,
  87314. UNSIGNED_SHORT = 5123,
  87315. FLOAT = 5126
  87316. }
  87317. /** @hidden */
  87318. export enum EShaderType {
  87319. FRAGMENT = 35632,
  87320. VERTEX = 35633
  87321. }
  87322. /** @hidden */
  87323. export enum EParameterType {
  87324. BYTE = 5120,
  87325. UNSIGNED_BYTE = 5121,
  87326. SHORT = 5122,
  87327. UNSIGNED_SHORT = 5123,
  87328. INT = 5124,
  87329. UNSIGNED_INT = 5125,
  87330. FLOAT = 5126,
  87331. FLOAT_VEC2 = 35664,
  87332. FLOAT_VEC3 = 35665,
  87333. FLOAT_VEC4 = 35666,
  87334. INT_VEC2 = 35667,
  87335. INT_VEC3 = 35668,
  87336. INT_VEC4 = 35669,
  87337. BOOL = 35670,
  87338. BOOL_VEC2 = 35671,
  87339. BOOL_VEC3 = 35672,
  87340. BOOL_VEC4 = 35673,
  87341. FLOAT_MAT2 = 35674,
  87342. FLOAT_MAT3 = 35675,
  87343. FLOAT_MAT4 = 35676,
  87344. SAMPLER_2D = 35678
  87345. }
  87346. /** @hidden */
  87347. export enum ETextureWrapMode {
  87348. CLAMP_TO_EDGE = 33071,
  87349. MIRRORED_REPEAT = 33648,
  87350. REPEAT = 10497
  87351. }
  87352. /** @hidden */
  87353. export enum ETextureFilterType {
  87354. NEAREST = 9728,
  87355. LINEAR = 9728,
  87356. NEAREST_MIPMAP_NEAREST = 9984,
  87357. LINEAR_MIPMAP_NEAREST = 9985,
  87358. NEAREST_MIPMAP_LINEAR = 9986,
  87359. LINEAR_MIPMAP_LINEAR = 9987
  87360. }
  87361. /** @hidden */
  87362. export enum ETextureFormat {
  87363. ALPHA = 6406,
  87364. RGB = 6407,
  87365. RGBA = 6408,
  87366. LUMINANCE = 6409,
  87367. LUMINANCE_ALPHA = 6410
  87368. }
  87369. /** @hidden */
  87370. export enum ECullingType {
  87371. FRONT = 1028,
  87372. BACK = 1029,
  87373. FRONT_AND_BACK = 1032
  87374. }
  87375. /** @hidden */
  87376. export enum EBlendingFunction {
  87377. ZERO = 0,
  87378. ONE = 1,
  87379. SRC_COLOR = 768,
  87380. ONE_MINUS_SRC_COLOR = 769,
  87381. DST_COLOR = 774,
  87382. ONE_MINUS_DST_COLOR = 775,
  87383. SRC_ALPHA = 770,
  87384. ONE_MINUS_SRC_ALPHA = 771,
  87385. DST_ALPHA = 772,
  87386. ONE_MINUS_DST_ALPHA = 773,
  87387. CONSTANT_COLOR = 32769,
  87388. ONE_MINUS_CONSTANT_COLOR = 32770,
  87389. CONSTANT_ALPHA = 32771,
  87390. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87391. SRC_ALPHA_SATURATE = 776
  87392. }
  87393. /** @hidden */
  87394. export interface IGLTFProperty {
  87395. extensions?: {
  87396. [key: string]: any;
  87397. };
  87398. extras?: Object;
  87399. }
  87400. /** @hidden */
  87401. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87402. name?: string;
  87403. }
  87404. /** @hidden */
  87405. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87406. bufferView: string;
  87407. byteOffset: number;
  87408. byteStride: number;
  87409. count: number;
  87410. type: string;
  87411. componentType: EComponentType;
  87412. max?: number[];
  87413. min?: number[];
  87414. name?: string;
  87415. }
  87416. /** @hidden */
  87417. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87418. buffer: string;
  87419. byteOffset: number;
  87420. byteLength: number;
  87421. byteStride: number;
  87422. target?: number;
  87423. }
  87424. /** @hidden */
  87425. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87426. uri: string;
  87427. byteLength?: number;
  87428. type?: string;
  87429. }
  87430. /** @hidden */
  87431. export interface IGLTFShader extends IGLTFChildRootProperty {
  87432. uri: string;
  87433. type: EShaderType;
  87434. }
  87435. /** @hidden */
  87436. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87437. attributes: string[];
  87438. fragmentShader: string;
  87439. vertexShader: string;
  87440. }
  87441. /** @hidden */
  87442. export interface IGLTFTechniqueParameter {
  87443. type: number;
  87444. count?: number;
  87445. semantic?: string;
  87446. node?: string;
  87447. value?: number | boolean | string | Array<any>;
  87448. source?: string;
  87449. babylonValue?: any;
  87450. }
  87451. /** @hidden */
  87452. export interface IGLTFTechniqueCommonProfile {
  87453. lightingModel: string;
  87454. texcoordBindings: Object;
  87455. parameters?: Array<any>;
  87456. }
  87457. /** @hidden */
  87458. export interface IGLTFTechniqueStatesFunctions {
  87459. blendColor?: number[];
  87460. blendEquationSeparate?: number[];
  87461. blendFuncSeparate?: number[];
  87462. colorMask: boolean[];
  87463. cullFace: number[];
  87464. }
  87465. /** @hidden */
  87466. export interface IGLTFTechniqueStates {
  87467. enable: number[];
  87468. functions: IGLTFTechniqueStatesFunctions;
  87469. }
  87470. /** @hidden */
  87471. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87472. parameters: {
  87473. [key: string]: IGLTFTechniqueParameter;
  87474. };
  87475. program: string;
  87476. attributes: {
  87477. [key: string]: string;
  87478. };
  87479. uniforms: {
  87480. [key: string]: string;
  87481. };
  87482. states: IGLTFTechniqueStates;
  87483. }
  87484. /** @hidden */
  87485. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87486. technique?: string;
  87487. values: string[];
  87488. }
  87489. /** @hidden */
  87490. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87491. attributes: {
  87492. [key: string]: string;
  87493. };
  87494. indices: string;
  87495. material: string;
  87496. mode?: number;
  87497. }
  87498. /** @hidden */
  87499. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87500. primitives: IGLTFMeshPrimitive[];
  87501. }
  87502. /** @hidden */
  87503. export interface IGLTFImage extends IGLTFChildRootProperty {
  87504. uri: string;
  87505. }
  87506. /** @hidden */
  87507. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87508. magFilter?: number;
  87509. minFilter?: number;
  87510. wrapS?: number;
  87511. wrapT?: number;
  87512. }
  87513. /** @hidden */
  87514. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87515. sampler: string;
  87516. source: string;
  87517. format?: ETextureFormat;
  87518. internalFormat?: ETextureFormat;
  87519. target?: number;
  87520. type?: number;
  87521. babylonTexture?: Texture;
  87522. }
  87523. /** @hidden */
  87524. export interface IGLTFAmbienLight {
  87525. color?: number[];
  87526. }
  87527. /** @hidden */
  87528. export interface IGLTFDirectionalLight {
  87529. color?: number[];
  87530. }
  87531. /** @hidden */
  87532. export interface IGLTFPointLight {
  87533. color?: number[];
  87534. constantAttenuation?: number;
  87535. linearAttenuation?: number;
  87536. quadraticAttenuation?: number;
  87537. }
  87538. /** @hidden */
  87539. export interface IGLTFSpotLight {
  87540. color?: number[];
  87541. constantAttenuation?: number;
  87542. fallOfAngle?: number;
  87543. fallOffExponent?: number;
  87544. linearAttenuation?: number;
  87545. quadraticAttenuation?: number;
  87546. }
  87547. /** @hidden */
  87548. export interface IGLTFLight extends IGLTFChildRootProperty {
  87549. type: string;
  87550. }
  87551. /** @hidden */
  87552. export interface IGLTFCameraOrthographic {
  87553. xmag: number;
  87554. ymag: number;
  87555. zfar: number;
  87556. znear: number;
  87557. }
  87558. /** @hidden */
  87559. export interface IGLTFCameraPerspective {
  87560. aspectRatio: number;
  87561. yfov: number;
  87562. zfar: number;
  87563. znear: number;
  87564. }
  87565. /** @hidden */
  87566. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87567. type: string;
  87568. }
  87569. /** @hidden */
  87570. export interface IGLTFAnimationChannelTarget {
  87571. id: string;
  87572. path: string;
  87573. }
  87574. /** @hidden */
  87575. export interface IGLTFAnimationChannel {
  87576. sampler: string;
  87577. target: IGLTFAnimationChannelTarget;
  87578. }
  87579. /** @hidden */
  87580. export interface IGLTFAnimationSampler {
  87581. input: string;
  87582. output: string;
  87583. interpolation?: string;
  87584. }
  87585. /** @hidden */
  87586. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87587. channels?: IGLTFAnimationChannel[];
  87588. parameters?: {
  87589. [key: string]: string;
  87590. };
  87591. samplers?: {
  87592. [key: string]: IGLTFAnimationSampler;
  87593. };
  87594. }
  87595. /** @hidden */
  87596. export interface IGLTFNodeInstanceSkin {
  87597. skeletons: string[];
  87598. skin: string;
  87599. meshes: string[];
  87600. }
  87601. /** @hidden */
  87602. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87603. bindShapeMatrix: number[];
  87604. inverseBindMatrices: string;
  87605. jointNames: string[];
  87606. babylonSkeleton?: Skeleton;
  87607. }
  87608. /** @hidden */
  87609. export interface IGLTFNode extends IGLTFChildRootProperty {
  87610. camera?: string;
  87611. children: string[];
  87612. skin?: string;
  87613. jointName?: string;
  87614. light?: string;
  87615. matrix: number[];
  87616. mesh?: string;
  87617. meshes?: string[];
  87618. rotation?: number[];
  87619. scale?: number[];
  87620. translation?: number[];
  87621. babylonNode?: Node;
  87622. }
  87623. /** @hidden */
  87624. export interface IGLTFScene extends IGLTFChildRootProperty {
  87625. nodes: string[];
  87626. }
  87627. /** @hidden */
  87628. export interface IGLTFRuntime {
  87629. extensions: {
  87630. [key: string]: any;
  87631. };
  87632. accessors: {
  87633. [key: string]: IGLTFAccessor;
  87634. };
  87635. buffers: {
  87636. [key: string]: IGLTFBuffer;
  87637. };
  87638. bufferViews: {
  87639. [key: string]: IGLTFBufferView;
  87640. };
  87641. meshes: {
  87642. [key: string]: IGLTFMesh;
  87643. };
  87644. lights: {
  87645. [key: string]: IGLTFLight;
  87646. };
  87647. cameras: {
  87648. [key: string]: IGLTFCamera;
  87649. };
  87650. nodes: {
  87651. [key: string]: IGLTFNode;
  87652. };
  87653. images: {
  87654. [key: string]: IGLTFImage;
  87655. };
  87656. textures: {
  87657. [key: string]: IGLTFTexture;
  87658. };
  87659. shaders: {
  87660. [key: string]: IGLTFShader;
  87661. };
  87662. programs: {
  87663. [key: string]: IGLTFProgram;
  87664. };
  87665. samplers: {
  87666. [key: string]: IGLTFSampler;
  87667. };
  87668. techniques: {
  87669. [key: string]: IGLTFTechnique;
  87670. };
  87671. materials: {
  87672. [key: string]: IGLTFMaterial;
  87673. };
  87674. animations: {
  87675. [key: string]: IGLTFAnimation;
  87676. };
  87677. skins: {
  87678. [key: string]: IGLTFSkins;
  87679. };
  87680. currentScene?: Object;
  87681. scenes: {
  87682. [key: string]: IGLTFScene;
  87683. };
  87684. extensionsUsed: string[];
  87685. extensionsRequired?: string[];
  87686. buffersCount: number;
  87687. shaderscount: number;
  87688. scene: Scene;
  87689. rootUrl: string;
  87690. loadedBufferCount: number;
  87691. loadedBufferViews: {
  87692. [name: string]: ArrayBufferView;
  87693. };
  87694. loadedShaderCount: number;
  87695. importOnlyMeshes: boolean;
  87696. importMeshesNames?: string[];
  87697. dummyNodes: Node[];
  87698. forAssetContainer: boolean;
  87699. }
  87700. /** @hidden */
  87701. export interface INodeToRoot {
  87702. bone: Bone;
  87703. node: IGLTFNode;
  87704. id: string;
  87705. }
  87706. /** @hidden */
  87707. export interface IJointNode {
  87708. node: IGLTFNode;
  87709. id: string;
  87710. }
  87711. }
  87712. declare module BABYLON.GLTF1 {
  87713. /**
  87714. * Utils functions for GLTF
  87715. * @hidden
  87716. */
  87717. export class GLTFUtils {
  87718. /**
  87719. * Sets the given "parameter" matrix
  87720. * @param scene: the Scene object
  87721. * @param source: the source node where to pick the matrix
  87722. * @param parameter: the GLTF technique parameter
  87723. * @param uniformName: the name of the shader's uniform
  87724. * @param shaderMaterial: the shader material
  87725. */
  87726. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87727. /**
  87728. * Sets the given "parameter" matrix
  87729. * @param shaderMaterial: the shader material
  87730. * @param uniform: the name of the shader's uniform
  87731. * @param value: the value of the uniform
  87732. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87733. */
  87734. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87735. /**
  87736. * Returns the wrap mode of the texture
  87737. * @param mode: the mode value
  87738. */
  87739. static GetWrapMode(mode: number): number;
  87740. /**
  87741. * Returns the byte stride giving an accessor
  87742. * @param accessor: the GLTF accessor objet
  87743. */
  87744. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87745. /**
  87746. * Returns the texture filter mode giving a mode value
  87747. * @param mode: the filter mode value
  87748. */
  87749. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87750. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87751. /**
  87752. * Returns a buffer from its accessor
  87753. * @param gltfRuntime: the GLTF runtime
  87754. * @param accessor: the GLTF accessor
  87755. */
  87756. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87757. /**
  87758. * Decodes a buffer view into a string
  87759. * @param view: the buffer view
  87760. */
  87761. static DecodeBufferToText(view: ArrayBufferView): string;
  87762. /**
  87763. * Returns the default material of gltf. Related to
  87764. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87765. * @param scene: the Babylon.js scene
  87766. */
  87767. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87768. private static _DefaultMaterial;
  87769. }
  87770. }
  87771. declare module BABYLON.GLTF1 {
  87772. /**
  87773. * Implementation of the base glTF spec
  87774. * @hidden
  87775. */
  87776. export class GLTFLoaderBase {
  87777. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87778. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87779. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87780. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87781. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87782. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87783. }
  87784. /**
  87785. * glTF V1 Loader
  87786. * @hidden
  87787. */
  87788. export class GLTFLoader implements IGLTFLoader {
  87789. static Extensions: {
  87790. [name: string]: GLTFLoaderExtension;
  87791. };
  87792. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87793. state: Nullable<GLTFLoaderState>;
  87794. dispose(): void;
  87795. private _importMeshAsync;
  87796. /**
  87797. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87798. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87799. * @param scene the scene the meshes should be added to
  87800. * @param forAssetContainer defines if the entities must be stored in the scene
  87801. * @param data gltf data containing information of the meshes in a loaded file
  87802. * @param rootUrl root url to load from
  87803. * @param onProgress event that fires when loading progress has occured
  87804. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87805. */
  87806. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87807. private _loadAsync;
  87808. /**
  87809. * Imports all objects from a loaded gltf file and adds them to the scene
  87810. * @param scene the scene the objects should be added to
  87811. * @param data gltf data containing information of the meshes in a loaded file
  87812. * @param rootUrl root url to load from
  87813. * @param onProgress event that fires when loading progress has occured
  87814. * @returns a promise which completes when objects have been loaded to the scene
  87815. */
  87816. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87817. private _loadShadersAsync;
  87818. private _loadBuffersAsync;
  87819. private _createNodes;
  87820. }
  87821. /** @hidden */
  87822. export abstract class GLTFLoaderExtension {
  87823. private _name;
  87824. constructor(name: string);
  87825. get name(): string;
  87826. /**
  87827. * Defines an override for loading the runtime
  87828. * Return true to stop further extensions from loading the runtime
  87829. */
  87830. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87831. /**
  87832. * Defines an onverride for creating gltf runtime
  87833. * Return true to stop further extensions from creating the runtime
  87834. */
  87835. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87836. /**
  87837. * Defines an override for loading buffers
  87838. * Return true to stop further extensions from loading this buffer
  87839. */
  87840. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87841. /**
  87842. * Defines an override for loading texture buffers
  87843. * Return true to stop further extensions from loading this texture data
  87844. */
  87845. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87846. /**
  87847. * Defines an override for creating textures
  87848. * Return true to stop further extensions from loading this texture
  87849. */
  87850. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87851. /**
  87852. * Defines an override for loading shader strings
  87853. * Return true to stop further extensions from loading this shader data
  87854. */
  87855. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87856. /**
  87857. * Defines an override for loading materials
  87858. * Return true to stop further extensions from loading this material
  87859. */
  87860. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87861. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87862. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87863. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87864. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87865. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87866. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87867. private static LoadTextureBufferAsync;
  87868. private static CreateTextureAsync;
  87869. private static ApplyExtensions;
  87870. }
  87871. }
  87872. declare module BABYLON.GLTF1 {
  87873. /** @hidden */
  87874. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87875. private _bin;
  87876. constructor();
  87877. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87878. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87879. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87880. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87881. }
  87882. }
  87883. declare module BABYLON.GLTF1 {
  87884. /** @hidden */
  87885. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87886. constructor();
  87887. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87888. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87889. private _loadTexture;
  87890. }
  87891. }
  87892. declare module BABYLON.GLTF2.Loader {
  87893. /**
  87894. * Loader interface with an index field.
  87895. */
  87896. export interface IArrayItem {
  87897. /**
  87898. * The index of this item in the array.
  87899. */
  87900. index: number;
  87901. }
  87902. /**
  87903. * Loader interface with additional members.
  87904. */
  87905. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87906. /** @hidden */
  87907. _data?: Promise<ArrayBufferView>;
  87908. /** @hidden */
  87909. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87910. }
  87911. /**
  87912. * Loader interface with additional members.
  87913. */
  87914. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87915. }
  87916. /** @hidden */
  87917. export interface _IAnimationSamplerData {
  87918. input: Float32Array;
  87919. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87920. output: Float32Array;
  87921. }
  87922. /**
  87923. * Loader interface with additional members.
  87924. */
  87925. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87926. /** @hidden */
  87927. _data?: Promise<_IAnimationSamplerData>;
  87928. }
  87929. /**
  87930. * Loader interface with additional members.
  87931. */
  87932. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87933. channels: IAnimationChannel[];
  87934. samplers: IAnimationSampler[];
  87935. /** @hidden */
  87936. _babylonAnimationGroup?: AnimationGroup;
  87937. }
  87938. /**
  87939. * Loader interface with additional members.
  87940. */
  87941. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87942. /** @hidden */
  87943. _data?: Promise<ArrayBufferView>;
  87944. }
  87945. /**
  87946. * Loader interface with additional members.
  87947. */
  87948. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87949. /** @hidden */
  87950. _data?: Promise<ArrayBufferView>;
  87951. /** @hidden */
  87952. _babylonBuffer?: Promise<Buffer>;
  87953. }
  87954. /**
  87955. * Loader interface with additional members.
  87956. */
  87957. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87958. }
  87959. /**
  87960. * Loader interface with additional members.
  87961. */
  87962. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87963. /** @hidden */
  87964. _data?: Promise<ArrayBufferView>;
  87965. }
  87966. /**
  87967. * Loader interface with additional members.
  87968. */
  87969. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87970. }
  87971. /**
  87972. * Loader interface with additional members.
  87973. */
  87974. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87975. }
  87976. /**
  87977. * Loader interface with additional members.
  87978. */
  87979. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87980. baseColorTexture?: ITextureInfo;
  87981. metallicRoughnessTexture?: ITextureInfo;
  87982. }
  87983. /**
  87984. * Loader interface with additional members.
  87985. */
  87986. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87987. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87988. normalTexture?: IMaterialNormalTextureInfo;
  87989. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87990. emissiveTexture?: ITextureInfo;
  87991. /** @hidden */
  87992. _data?: {
  87993. [babylonDrawMode: number]: {
  87994. babylonMaterial: Material;
  87995. babylonMeshes: AbstractMesh[];
  87996. promise: Promise<void>;
  87997. };
  87998. };
  87999. }
  88000. /**
  88001. * Loader interface with additional members.
  88002. */
  88003. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  88004. primitives: IMeshPrimitive[];
  88005. }
  88006. /**
  88007. * Loader interface with additional members.
  88008. */
  88009. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  88010. /** @hidden */
  88011. _instanceData?: {
  88012. babylonSourceMesh: Mesh;
  88013. promise: Promise<any>;
  88014. };
  88015. }
  88016. /**
  88017. * Loader interface with additional members.
  88018. */
  88019. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  88020. /**
  88021. * The parent glTF node.
  88022. */
  88023. parent?: INode;
  88024. /** @hidden */
  88025. _babylonTransformNode?: TransformNode;
  88026. /** @hidden */
  88027. _primitiveBabylonMeshes?: AbstractMesh[];
  88028. /** @hidden */
  88029. _babylonBones?: Bone[];
  88030. /** @hidden */
  88031. _numMorphTargets?: number;
  88032. }
  88033. /** @hidden */
  88034. export interface _ISamplerData {
  88035. noMipMaps: boolean;
  88036. samplingMode: number;
  88037. wrapU: number;
  88038. wrapV: number;
  88039. }
  88040. /**
  88041. * Loader interface with additional members.
  88042. */
  88043. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88044. /** @hidden */
  88045. _data?: _ISamplerData;
  88046. }
  88047. /**
  88048. * Loader interface with additional members.
  88049. */
  88050. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88051. }
  88052. /**
  88053. * Loader interface with additional members.
  88054. */
  88055. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88056. /** @hidden */
  88057. _data?: {
  88058. babylonSkeleton: Skeleton;
  88059. promise: Promise<void>;
  88060. };
  88061. }
  88062. /**
  88063. * Loader interface with additional members.
  88064. */
  88065. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88066. /** @hidden */
  88067. _textureInfo: ITextureInfo;
  88068. }
  88069. /**
  88070. * Loader interface with additional members.
  88071. */
  88072. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88073. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88074. nonColorData?: boolean;
  88075. }
  88076. /**
  88077. * Loader interface with additional members.
  88078. */
  88079. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88080. accessors?: IAccessor[];
  88081. animations?: IAnimation[];
  88082. buffers?: IBuffer[];
  88083. bufferViews?: IBufferView[];
  88084. cameras?: ICamera[];
  88085. images?: IImage[];
  88086. materials?: IMaterial[];
  88087. meshes?: IMesh[];
  88088. nodes?: INode[];
  88089. samplers?: ISampler[];
  88090. scenes?: IScene[];
  88091. skins?: ISkin[];
  88092. textures?: ITexture[];
  88093. }
  88094. }
  88095. declare module BABYLON.GLTF2 {
  88096. /**
  88097. * Interface for a glTF loader extension.
  88098. */
  88099. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88100. /**
  88101. * Called after the loader state changes to LOADING.
  88102. */
  88103. onLoading?(): void;
  88104. /**
  88105. * Called after the loader state changes to READY.
  88106. */
  88107. onReady?(): void;
  88108. /**
  88109. * Define this method to modify the default behavior when loading scenes.
  88110. * @param context The context when loading the asset
  88111. * @param scene The glTF scene property
  88112. * @returns A promise that resolves when the load is complete or null if not handled
  88113. */
  88114. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88115. /**
  88116. * Define this method to modify the default behavior when loading nodes.
  88117. * @param context The context when loading the asset
  88118. * @param node The glTF node property
  88119. * @param assign A function called synchronously after parsing the glTF properties
  88120. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88121. */
  88122. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88123. /**
  88124. * Define this method to modify the default behavior when loading cameras.
  88125. * @param context The context when loading the asset
  88126. * @param camera The glTF camera property
  88127. * @param assign A function called synchronously after parsing the glTF properties
  88128. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88129. */
  88130. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88131. /**
  88132. * @hidden
  88133. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88134. * @param context The context when loading the asset
  88135. * @param primitive The glTF mesh primitive property
  88136. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88137. */
  88138. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88139. /**
  88140. * @hidden
  88141. * Define this method to modify the default behavior when loading data for mesh primitives.
  88142. * @param context The context when loading the asset
  88143. * @param name The mesh name when loading the asset
  88144. * @param node The glTF node when loading the asset
  88145. * @param mesh The glTF mesh when loading the asset
  88146. * @param primitive The glTF mesh primitive property
  88147. * @param assign A function called synchronously after parsing the glTF properties
  88148. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88149. */
  88150. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88151. /**
  88152. * @hidden
  88153. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88154. * @param context The context when loading the asset
  88155. * @param material The glTF material property
  88156. * @param assign A function called synchronously after parsing the glTF properties
  88157. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88158. */
  88159. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88160. /**
  88161. * Define this method to modify the default behavior when creating materials.
  88162. * @param context The context when loading the asset
  88163. * @param material The glTF material property
  88164. * @param babylonDrawMode The draw mode for the Babylon material
  88165. * @returns The Babylon material or null if not handled
  88166. */
  88167. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88168. /**
  88169. * Define this method to modify the default behavior when loading material properties.
  88170. * @param context The context when loading the asset
  88171. * @param material The glTF material property
  88172. * @param babylonMaterial The Babylon material
  88173. * @returns A promise that resolves when the load is complete or null if not handled
  88174. */
  88175. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88176. /**
  88177. * Define this method to modify the default behavior when loading texture infos.
  88178. * @param context The context when loading the asset
  88179. * @param textureInfo The glTF texture info property
  88180. * @param assign A function called synchronously after parsing the glTF properties
  88181. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88182. */
  88183. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88184. /**
  88185. * @hidden
  88186. * Define this method to modify the default behavior when loading textures.
  88187. * @param context The context when loading the asset
  88188. * @param texture The glTF texture property
  88189. * @param assign A function called synchronously after parsing the glTF properties
  88190. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88191. */
  88192. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88193. /**
  88194. * Define this method to modify the default behavior when loading animations.
  88195. * @param context The context when loading the asset
  88196. * @param animation The glTF animation property
  88197. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88198. */
  88199. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88200. /**
  88201. * @hidden
  88202. * Define this method to modify the default behavior when loading skins.
  88203. * @param context The context when loading the asset
  88204. * @param node The glTF node property
  88205. * @param skin The glTF skin property
  88206. * @returns A promise that resolves when the load is complete or null if not handled
  88207. */
  88208. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88209. /**
  88210. * @hidden
  88211. * Define this method to modify the default behavior when loading uris.
  88212. * @param context The context when loading the asset
  88213. * @param property The glTF property associated with the uri
  88214. * @param uri The uri to load
  88215. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88216. */
  88217. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88218. /**
  88219. * Define this method to modify the default behavior when loading buffer views.
  88220. * @param context The context when loading the asset
  88221. * @param bufferView The glTF buffer view property
  88222. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88223. */
  88224. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88225. /**
  88226. * Define this method to modify the default behavior when loading buffers.
  88227. * @param context The context when loading the asset
  88228. * @param buffer The glTF buffer property
  88229. * @param byteOffset The byte offset to load
  88230. * @param byteLength The byte length to load
  88231. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88232. */
  88233. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88234. }
  88235. }
  88236. declare module BABYLON.GLTF2 {
  88237. /**
  88238. * Helper class for working with arrays when loading the glTF asset
  88239. */
  88240. export class ArrayItem {
  88241. /**
  88242. * Gets an item from the given array.
  88243. * @param context The context when loading the asset
  88244. * @param array The array to get the item from
  88245. * @param index The index to the array
  88246. * @returns The array item
  88247. */
  88248. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88249. /**
  88250. * Assign an `index` field to each item of the given array.
  88251. * @param array The array of items
  88252. */
  88253. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88254. }
  88255. /**
  88256. * The glTF 2.0 loader
  88257. */
  88258. export class GLTFLoader implements IGLTFLoader {
  88259. /** @hidden */
  88260. _completePromises: Promise<any>[];
  88261. /** @hidden */
  88262. _forAssetContainer: boolean;
  88263. /** Storage */
  88264. _babylonLights: Light[];
  88265. /** @hidden */
  88266. _disableInstancedMesh: number;
  88267. private _disposed;
  88268. private _parent;
  88269. private _state;
  88270. private _extensions;
  88271. private _rootUrl;
  88272. private _fileName;
  88273. private _uniqueRootUrl;
  88274. private _gltf;
  88275. private _bin;
  88276. private _babylonScene;
  88277. private _rootBabylonMesh;
  88278. private _defaultBabylonMaterialData;
  88279. private static _RegisteredExtensions;
  88280. /**
  88281. * The default glTF sampler.
  88282. */
  88283. static readonly DefaultSampler: ISampler;
  88284. /**
  88285. * Registers a loader extension.
  88286. * @param name The name of the loader extension.
  88287. * @param factory The factory function that creates the loader extension.
  88288. */
  88289. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88290. /**
  88291. * Unregisters a loader extension.
  88292. * @param name The name of the loader extension.
  88293. * @returns A boolean indicating whether the extension has been unregistered
  88294. */
  88295. static UnregisterExtension(name: string): boolean;
  88296. /**
  88297. * The loader state.
  88298. */
  88299. get state(): Nullable<GLTFLoaderState>;
  88300. /**
  88301. * The object that represents the glTF JSON.
  88302. */
  88303. get gltf(): IGLTF;
  88304. /**
  88305. * The BIN chunk of a binary glTF.
  88306. */
  88307. get bin(): Nullable<IDataBuffer>;
  88308. /**
  88309. * The parent file loader.
  88310. */
  88311. get parent(): GLTFFileLoader;
  88312. /**
  88313. * The Babylon scene when loading the asset.
  88314. */
  88315. get babylonScene(): Scene;
  88316. /**
  88317. * The root Babylon mesh when loading the asset.
  88318. */
  88319. get rootBabylonMesh(): Mesh;
  88320. /** @hidden */
  88321. constructor(parent: GLTFFileLoader);
  88322. /** @hidden */
  88323. dispose(): void;
  88324. /** @hidden */
  88325. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88326. /** @hidden */
  88327. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88328. private _loadAsync;
  88329. private _loadData;
  88330. private _setupData;
  88331. private _loadExtensions;
  88332. private _checkExtensions;
  88333. private _setState;
  88334. private _createRootNode;
  88335. /**
  88336. * Loads a glTF scene.
  88337. * @param context The context when loading the asset
  88338. * @param scene The glTF scene property
  88339. * @returns A promise that resolves when the load is complete
  88340. */
  88341. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88342. private _forEachPrimitive;
  88343. private _getGeometries;
  88344. private _getMeshes;
  88345. private _getTransformNodes;
  88346. private _getSkeletons;
  88347. private _getAnimationGroups;
  88348. private _startAnimations;
  88349. /**
  88350. * Loads a glTF node.
  88351. * @param context The context when loading the asset
  88352. * @param node The glTF node property
  88353. * @param assign A function called synchronously after parsing the glTF properties
  88354. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88355. */
  88356. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88357. private _loadMeshAsync;
  88358. /**
  88359. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88360. * @param context The context when loading the asset
  88361. * @param name The mesh name when loading the asset
  88362. * @param node The glTF node when loading the asset
  88363. * @param mesh The glTF mesh when loading the asset
  88364. * @param primitive The glTF mesh primitive property
  88365. * @param assign A function called synchronously after parsing the glTF properties
  88366. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88367. */
  88368. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88369. private _loadVertexDataAsync;
  88370. private _createMorphTargets;
  88371. private _loadMorphTargetsAsync;
  88372. private _loadMorphTargetVertexDataAsync;
  88373. private static _LoadTransform;
  88374. private _loadSkinAsync;
  88375. private _loadBones;
  88376. private _loadBone;
  88377. private _loadSkinInverseBindMatricesDataAsync;
  88378. private _updateBoneMatrices;
  88379. private _getNodeMatrix;
  88380. /**
  88381. * Loads a glTF camera.
  88382. * @param context The context when loading the asset
  88383. * @param camera The glTF camera property
  88384. * @param assign A function called synchronously after parsing the glTF properties
  88385. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88386. */
  88387. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88388. private _loadAnimationsAsync;
  88389. /**
  88390. * Loads a glTF animation.
  88391. * @param context The context when loading the asset
  88392. * @param animation The glTF animation property
  88393. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88394. */
  88395. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88396. /**
  88397. * @hidden Loads a glTF animation channel.
  88398. * @param context The context when loading the asset
  88399. * @param animationContext The context of the animation when loading the asset
  88400. * @param animation The glTF animation property
  88401. * @param channel The glTF animation channel property
  88402. * @param babylonAnimationGroup The babylon animation group property
  88403. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88404. * @returns A void promise when the channel load is complete
  88405. */
  88406. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88407. private _loadAnimationSamplerAsync;
  88408. /**
  88409. * Loads a glTF buffer.
  88410. * @param context The context when loading the asset
  88411. * @param buffer The glTF buffer property
  88412. * @param byteOffset The byte offset to use
  88413. * @param byteLength The byte length to use
  88414. * @returns A promise that resolves with the loaded data when the load is complete
  88415. */
  88416. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88417. /**
  88418. * Loads a glTF buffer view.
  88419. * @param context The context when loading the asset
  88420. * @param bufferView The glTF buffer view property
  88421. * @returns A promise that resolves with the loaded data when the load is complete
  88422. */
  88423. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88424. private _loadAccessorAsync;
  88425. /** @hidden */
  88426. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88427. private _loadIndicesAccessorAsync;
  88428. private _loadVertexBufferViewAsync;
  88429. private _loadVertexAccessorAsync;
  88430. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88431. /** @hidden */
  88432. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88433. private _createDefaultMaterial;
  88434. /**
  88435. * Creates a Babylon material from a glTF material.
  88436. * @param context The context when loading the asset
  88437. * @param material The glTF material property
  88438. * @param babylonDrawMode The draw mode for the Babylon material
  88439. * @returns The Babylon material
  88440. */
  88441. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88442. /**
  88443. * Loads properties from a glTF material into a Babylon material.
  88444. * @param context The context when loading the asset
  88445. * @param material The glTF material property
  88446. * @param babylonMaterial The Babylon material
  88447. * @returns A promise that resolves when the load is complete
  88448. */
  88449. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88450. /**
  88451. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88452. * @param context The context when loading the asset
  88453. * @param material The glTF material property
  88454. * @param babylonMaterial The Babylon material
  88455. * @returns A promise that resolves when the load is complete
  88456. */
  88457. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88458. /**
  88459. * Loads the alpha properties from a glTF material into a Babylon material.
  88460. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88461. * @param context The context when loading the asset
  88462. * @param material The glTF material property
  88463. * @param babylonMaterial The Babylon material
  88464. */
  88465. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88466. /**
  88467. * Loads a glTF texture info.
  88468. * @param context The context when loading the asset
  88469. * @param textureInfo The glTF texture info property
  88470. * @param assign A function called synchronously after parsing the glTF properties
  88471. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88472. */
  88473. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88474. /** @hidden */
  88475. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88476. /** @hidden */
  88477. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88478. private _loadSampler;
  88479. /**
  88480. * Loads a glTF image.
  88481. * @param context The context when loading the asset
  88482. * @param image The glTF image property
  88483. * @returns A promise that resolves with the loaded data when the load is complete
  88484. */
  88485. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88486. /**
  88487. * Loads a glTF uri.
  88488. * @param context The context when loading the asset
  88489. * @param property The glTF property associated with the uri
  88490. * @param uri The base64 or relative uri
  88491. * @returns A promise that resolves with the loaded data when the load is complete
  88492. */
  88493. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88494. /**
  88495. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88496. * @param babylonObject the Babylon object with metadata
  88497. * @param pointer the JSON pointer
  88498. */
  88499. static AddPointerMetadata(babylonObject: {
  88500. metadata: any;
  88501. }, pointer: string): void;
  88502. private static _GetTextureWrapMode;
  88503. private static _GetTextureSamplingMode;
  88504. private static _GetTypedArrayConstructor;
  88505. private static _GetTypedArray;
  88506. private static _GetNumComponents;
  88507. private static _ValidateUri;
  88508. /** @hidden */
  88509. static _GetDrawMode(context: string, mode: number | undefined): number;
  88510. private _compileMaterialsAsync;
  88511. private _compileShadowGeneratorsAsync;
  88512. private _forEachExtensions;
  88513. private _applyExtensions;
  88514. private _extensionsOnLoading;
  88515. private _extensionsOnReady;
  88516. private _extensionsLoadSceneAsync;
  88517. private _extensionsLoadNodeAsync;
  88518. private _extensionsLoadCameraAsync;
  88519. private _extensionsLoadVertexDataAsync;
  88520. private _extensionsLoadMeshPrimitiveAsync;
  88521. private _extensionsLoadMaterialAsync;
  88522. private _extensionsCreateMaterial;
  88523. private _extensionsLoadMaterialPropertiesAsync;
  88524. private _extensionsLoadTextureInfoAsync;
  88525. private _extensionsLoadTextureAsync;
  88526. private _extensionsLoadAnimationAsync;
  88527. private _extensionsLoadSkinAsync;
  88528. private _extensionsLoadUriAsync;
  88529. private _extensionsLoadBufferViewAsync;
  88530. private _extensionsLoadBufferAsync;
  88531. /**
  88532. * Helper method called by a loader extension to load an glTF extension.
  88533. * @param context The context when loading the asset
  88534. * @param property The glTF property to load the extension from
  88535. * @param extensionName The name of the extension to load
  88536. * @param actionAsync The action to run
  88537. * @returns The promise returned by actionAsync or null if the extension does not exist
  88538. */
  88539. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88540. /**
  88541. * Helper method called by a loader extension to load a glTF extra.
  88542. * @param context The context when loading the asset
  88543. * @param property The glTF property to load the extra from
  88544. * @param extensionName The name of the extension to load
  88545. * @param actionAsync The action to run
  88546. * @returns The promise returned by actionAsync or null if the extra does not exist
  88547. */
  88548. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88549. /**
  88550. * Checks for presence of an extension.
  88551. * @param name The name of the extension to check
  88552. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88553. */
  88554. isExtensionUsed(name: string): boolean;
  88555. /**
  88556. * Increments the indentation level and logs a message.
  88557. * @param message The message to log
  88558. */
  88559. logOpen(message: string): void;
  88560. /**
  88561. * Decrements the indentation level.
  88562. */
  88563. logClose(): void;
  88564. /**
  88565. * Logs a message
  88566. * @param message The message to log
  88567. */
  88568. log(message: string): void;
  88569. /**
  88570. * Starts a performance counter.
  88571. * @param counterName The name of the performance counter
  88572. */
  88573. startPerformanceCounter(counterName: string): void;
  88574. /**
  88575. * Ends a performance counter.
  88576. * @param counterName The name of the performance counter
  88577. */
  88578. endPerformanceCounter(counterName: string): void;
  88579. }
  88580. }
  88581. declare module BABYLON.GLTF2.Loader.Extensions {
  88582. /** @hidden */
  88583. interface IEXTLightsImageBased_LightImageBased {
  88584. _babylonTexture?: BaseTexture;
  88585. _loaded?: Promise<void>;
  88586. }
  88587. /**
  88588. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88589. */
  88590. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88591. /**
  88592. * The name of this extension.
  88593. */
  88594. readonly name: string;
  88595. /**
  88596. * Defines whether this extension is enabled.
  88597. */
  88598. enabled: boolean;
  88599. private _loader;
  88600. private _lights?;
  88601. /** @hidden */
  88602. constructor(loader: GLTFLoader);
  88603. /** @hidden */
  88604. dispose(): void;
  88605. /** @hidden */
  88606. onLoading(): void;
  88607. /** @hidden */
  88608. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88609. private _loadLightAsync;
  88610. }
  88611. }
  88612. declare module BABYLON.GLTF2.Loader.Extensions {
  88613. /**
  88614. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88615. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88616. * !!! Experimental Extension Subject to Changes !!!
  88617. */
  88618. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88619. /**
  88620. * The name of this extension.
  88621. */
  88622. readonly name: string;
  88623. /**
  88624. * Defines whether this extension is enabled.
  88625. */
  88626. enabled: boolean;
  88627. private _loader;
  88628. /** @hidden */
  88629. constructor(loader: GLTFLoader);
  88630. /** @hidden */
  88631. dispose(): void;
  88632. /** @hidden */
  88633. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88634. }
  88635. }
  88636. declare module BABYLON.GLTF2.Loader.Extensions {
  88637. /**
  88638. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88639. *
  88640. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88641. */
  88642. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88643. /**
  88644. * The name of this extension.
  88645. */
  88646. readonly name: string;
  88647. /**
  88648. * Defines whether this extension is enabled.
  88649. */
  88650. enabled: boolean;
  88651. /**
  88652. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88653. */
  88654. static DecoderPath: string;
  88655. private _loader;
  88656. private _decoderPromise?;
  88657. /** @hidden */
  88658. constructor(loader: GLTFLoader);
  88659. /** @hidden */
  88660. dispose(): void;
  88661. /** @hidden */
  88662. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88663. }
  88664. }
  88665. declare module BABYLON.GLTF2.Loader.Extensions {
  88666. /**
  88667. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88668. */
  88669. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88670. /** The name of this extension. */
  88671. readonly name: string;
  88672. /** Defines whether this extension is enabled. */
  88673. enabled: boolean;
  88674. private _loader;
  88675. /** @hidden */
  88676. constructor(loader: GLTFLoader);
  88677. /** @hidden */
  88678. dispose(): void;
  88679. /** @hidden */
  88680. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88681. }
  88682. }
  88683. declare module BABYLON.GLTF2.Loader.Extensions {
  88684. /**
  88685. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88686. */
  88687. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88688. /**
  88689. * The name of this extension.
  88690. */
  88691. readonly name: string;
  88692. /**
  88693. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88694. */
  88695. dracoCompression?: DracoCompression;
  88696. /**
  88697. * Defines whether this extension is enabled.
  88698. */
  88699. enabled: boolean;
  88700. private _loader;
  88701. /** @hidden */
  88702. constructor(loader: GLTFLoader);
  88703. /** @hidden */
  88704. dispose(): void;
  88705. /** @hidden */
  88706. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88707. }
  88708. }
  88709. declare module BABYLON.GLTF2.Loader.Extensions {
  88710. /**
  88711. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88712. */
  88713. export class KHR_lights implements IGLTFLoaderExtension {
  88714. /**
  88715. * The name of this extension.
  88716. */
  88717. readonly name: string;
  88718. /**
  88719. * Defines whether this extension is enabled.
  88720. */
  88721. enabled: boolean;
  88722. private _loader;
  88723. private _lights?;
  88724. /** @hidden */
  88725. constructor(loader: GLTFLoader);
  88726. /** @hidden */
  88727. dispose(): void;
  88728. /** @hidden */
  88729. onLoading(): void;
  88730. /** @hidden */
  88731. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88732. }
  88733. }
  88734. declare module BABYLON.GLTF2.Loader.Extensions {
  88735. /**
  88736. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88737. */
  88738. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88739. /**
  88740. * The name of this extension.
  88741. */
  88742. readonly name: string;
  88743. /**
  88744. * Defines whether this extension is enabled.
  88745. */
  88746. enabled: boolean;
  88747. /**
  88748. * Defines a number that determines the order the extensions are applied.
  88749. */
  88750. order: number;
  88751. private _loader;
  88752. /** @hidden */
  88753. constructor(loader: GLTFLoader);
  88754. /** @hidden */
  88755. dispose(): void;
  88756. /** @hidden */
  88757. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88758. private _loadSpecularGlossinessPropertiesAsync;
  88759. }
  88760. }
  88761. declare module BABYLON.GLTF2.Loader.Extensions {
  88762. /**
  88763. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88764. */
  88765. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88766. /**
  88767. * The name of this extension.
  88768. */
  88769. readonly name: string;
  88770. /**
  88771. * Defines whether this extension is enabled.
  88772. */
  88773. enabled: boolean;
  88774. /**
  88775. * Defines a number that determines the order the extensions are applied.
  88776. */
  88777. order: number;
  88778. private _loader;
  88779. /** @hidden */
  88780. constructor(loader: GLTFLoader);
  88781. /** @hidden */
  88782. dispose(): void;
  88783. /** @hidden */
  88784. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88785. private _loadUnlitPropertiesAsync;
  88786. }
  88787. }
  88788. declare module BABYLON.GLTF2.Loader.Extensions {
  88789. /**
  88790. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88791. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88792. */
  88793. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88794. /**
  88795. * The name of this extension.
  88796. */
  88797. readonly name: string;
  88798. /**
  88799. * Defines whether this extension is enabled.
  88800. */
  88801. enabled: boolean;
  88802. /**
  88803. * Defines a number that determines the order the extensions are applied.
  88804. */
  88805. order: number;
  88806. private _loader;
  88807. /** @hidden */
  88808. constructor(loader: GLTFLoader);
  88809. /** @hidden */
  88810. dispose(): void;
  88811. /** @hidden */
  88812. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88813. private _loadClearCoatPropertiesAsync;
  88814. }
  88815. }
  88816. declare module BABYLON.GLTF2.Loader.Extensions {
  88817. /**
  88818. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88819. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88820. * !!! Experimental Extension Subject to Changes !!!
  88821. */
  88822. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88823. /**
  88824. * The name of this extension.
  88825. */
  88826. readonly name: string;
  88827. /**
  88828. * Defines whether this extension is enabled.
  88829. */
  88830. enabled: boolean;
  88831. /**
  88832. * Defines a number that determines the order the extensions are applied.
  88833. */
  88834. order: number;
  88835. private _loader;
  88836. /** @hidden */
  88837. constructor(loader: GLTFLoader);
  88838. /** @hidden */
  88839. dispose(): void;
  88840. /** @hidden */
  88841. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88842. private _loadSheenPropertiesAsync;
  88843. }
  88844. }
  88845. declare module BABYLON.GLTF2.Loader.Extensions {
  88846. /**
  88847. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88848. * !!! Experimental Extension Subject to Changes !!!
  88849. */
  88850. export class KHR_materials_specular 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. /**
  88860. * Defines a number that determines the order the extensions are applied.
  88861. */
  88862. order: number;
  88863. private _loader;
  88864. /** @hidden */
  88865. constructor(loader: GLTFLoader);
  88866. /** @hidden */
  88867. dispose(): void;
  88868. /** @hidden */
  88869. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88870. private _loadSpecularPropertiesAsync;
  88871. }
  88872. }
  88873. declare module BABYLON.GLTF2.Loader.Extensions {
  88874. /**
  88875. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88876. * !!! Experimental Extension Subject to Changes !!!
  88877. */
  88878. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88879. /**
  88880. * Default ior Value from the spec.
  88881. */
  88882. private static readonly _DEFAULT_IOR;
  88883. /**
  88884. * The name of this extension.
  88885. */
  88886. readonly name: string;
  88887. /**
  88888. * Defines whether this extension is enabled.
  88889. */
  88890. enabled: boolean;
  88891. /**
  88892. * Defines a number that determines the order the extensions are applied.
  88893. */
  88894. order: number;
  88895. private _loader;
  88896. /** @hidden */
  88897. constructor(loader: GLTFLoader);
  88898. /** @hidden */
  88899. dispose(): void;
  88900. /** @hidden */
  88901. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88902. private _loadIorPropertiesAsync;
  88903. }
  88904. }
  88905. declare module BABYLON.GLTF2.Loader.Extensions {
  88906. /**
  88907. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88908. */
  88909. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88910. /**
  88911. * The name of this extension.
  88912. */
  88913. readonly name: string;
  88914. /**
  88915. * Defines whether this extension is enabled.
  88916. */
  88917. enabled: boolean;
  88918. private _loader;
  88919. private _variants?;
  88920. /** @hidden */
  88921. constructor(loader: GLTFLoader);
  88922. /** @hidden */
  88923. dispose(): void;
  88924. /**
  88925. * Gets the list of available variant names for this asset.
  88926. * @param rootMesh The glTF root mesh
  88927. * @returns the list of all the variant names for this model
  88928. */
  88929. static GetAvailableVariants(rootMesh: Mesh): string[];
  88930. /**
  88931. * Gets the list of available variant names for this asset.
  88932. * @param rootMesh The glTF root mesh
  88933. * @returns the list of all the variant names for this model
  88934. */
  88935. getAvailableVariants(rootMesh: Mesh): string[];
  88936. /**
  88937. * Select a variant given a variant name or a list of variant names.
  88938. * @param rootMesh The glTF root mesh
  88939. * @param variantName The variant name(s) to select.
  88940. */
  88941. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88942. /**
  88943. * Select a variant given a variant name or a list of variant names.
  88944. * @param rootMesh The glTF root mesh
  88945. * @param variantName The variant name(s) to select.
  88946. */
  88947. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88948. /**
  88949. * Reset back to the original before selecting a variant.
  88950. * @param rootMesh The glTF root mesh
  88951. */
  88952. static Reset(rootMesh: Mesh): void;
  88953. /**
  88954. * Reset back to the original before selecting a variant.
  88955. * @param rootMesh The glTF root mesh
  88956. */
  88957. reset(rootMesh: Mesh): void;
  88958. /**
  88959. * Gets the last selected variant name(s) or null if original.
  88960. * @param rootMesh The glTF root mesh
  88961. * @returns The selected variant name(s).
  88962. */
  88963. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88964. /**
  88965. * Gets the last selected variant name(s) or null if original.
  88966. * @param rootMesh The glTF root mesh
  88967. * @returns The selected variant name(s).
  88968. */
  88969. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88970. private static _GetExtensionMetadata;
  88971. /** @hidden */
  88972. onLoading(): void;
  88973. /** @hidden */
  88974. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88975. }
  88976. }
  88977. declare module BABYLON.GLTF2.Loader.Extensions {
  88978. /**
  88979. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88980. */
  88981. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88982. /**
  88983. * The name of this extension.
  88984. */
  88985. readonly name: string;
  88986. /**
  88987. * Defines whether this extension is enabled.
  88988. */
  88989. enabled: boolean;
  88990. /**
  88991. * Defines a number that determines the order the extensions are applied.
  88992. */
  88993. order: number;
  88994. private _loader;
  88995. /** @hidden */
  88996. constructor(loader: GLTFLoader);
  88997. /** @hidden */
  88998. dispose(): void;
  88999. /** @hidden */
  89000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89001. private _loadTransparentPropertiesAsync;
  89002. }
  89003. }
  89004. declare module BABYLON.GLTF2.Loader.Extensions {
  89005. /**
  89006. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  89007. * !!! Experimental Extension Subject to Changes !!!
  89008. */
  89009. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  89010. /**
  89011. * The name of this extension.
  89012. */
  89013. readonly name: string;
  89014. /**
  89015. * Defines whether this extension is enabled.
  89016. */
  89017. enabled: boolean;
  89018. /**
  89019. * Defines a number that determines the order the extensions are applied.
  89020. */
  89021. order: number;
  89022. private _loader;
  89023. /** @hidden */
  89024. constructor(loader: GLTFLoader);
  89025. /** @hidden */
  89026. dispose(): void;
  89027. /** @hidden */
  89028. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89029. private _loadTranslucentPropertiesAsync;
  89030. }
  89031. }
  89032. declare module BABYLON.GLTF2.Loader.Extensions {
  89033. /**
  89034. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89035. */
  89036. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89037. /**
  89038. * The name of this extension.
  89039. */
  89040. readonly name: string;
  89041. /**
  89042. * Defines whether this extension is enabled.
  89043. */
  89044. enabled: boolean;
  89045. /** @hidden */
  89046. constructor(loader: GLTFLoader);
  89047. /** @hidden */
  89048. dispose(): void;
  89049. }
  89050. }
  89051. declare module BABYLON.GLTF2.Loader.Extensions {
  89052. /**
  89053. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89054. * !!! Experimental Extension Subject to Changes !!!
  89055. */
  89056. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89057. /** The name of this extension. */
  89058. readonly name: string;
  89059. /** Defines whether this extension is enabled. */
  89060. enabled: boolean;
  89061. private _loader;
  89062. /** @hidden */
  89063. constructor(loader: GLTFLoader);
  89064. /** @hidden */
  89065. dispose(): void;
  89066. /** @hidden */
  89067. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89068. }
  89069. }
  89070. declare module BABYLON.GLTF2.Loader.Extensions {
  89071. /**
  89072. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89073. */
  89074. export class KHR_texture_transform implements IGLTFLoaderExtension {
  89075. /**
  89076. * The name of this extension.
  89077. */
  89078. readonly name: string;
  89079. /**
  89080. * Defines whether this extension is enabled.
  89081. */
  89082. enabled: boolean;
  89083. private _loader;
  89084. /** @hidden */
  89085. constructor(loader: GLTFLoader);
  89086. /** @hidden */
  89087. dispose(): void;
  89088. /** @hidden */
  89089. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89090. }
  89091. }
  89092. declare module BABYLON.GLTF2.Loader.Extensions {
  89093. /**
  89094. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89095. * !!! Experimental Extension Subject to Changes !!!
  89096. */
  89097. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89098. /**
  89099. * The name of this extension.
  89100. */
  89101. readonly name: string;
  89102. /**
  89103. * Defines whether this extension is enabled.
  89104. */
  89105. enabled: boolean;
  89106. /**
  89107. * Defines a number that determines the order the extensions are applied.
  89108. */
  89109. order: number;
  89110. private _loader;
  89111. /** @hidden */
  89112. constructor(loader: GLTFLoader);
  89113. /** @hidden */
  89114. dispose(): void;
  89115. /**
  89116. * Called after the loader state changes to LOADING.
  89117. */
  89118. onLoading(): void;
  89119. }
  89120. }
  89121. declare module BABYLON.GLTF2.Loader.Extensions {
  89122. /**
  89123. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89124. */
  89125. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89126. /**
  89127. * The name of this extension.
  89128. */
  89129. readonly name: string;
  89130. /**
  89131. * Defines whether this extension is enabled.
  89132. */
  89133. enabled: boolean;
  89134. private _loader;
  89135. private _clips;
  89136. private _emitters;
  89137. /** @hidden */
  89138. constructor(loader: GLTFLoader);
  89139. /** @hidden */
  89140. dispose(): void;
  89141. /** @hidden */
  89142. onLoading(): void;
  89143. /** @hidden */
  89144. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89145. /** @hidden */
  89146. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89147. /** @hidden */
  89148. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89149. private _loadClipAsync;
  89150. private _loadEmitterAsync;
  89151. private _getEventAction;
  89152. private _loadAnimationEventAsync;
  89153. }
  89154. }
  89155. declare module BABYLON.GLTF2.Loader.Extensions {
  89156. /**
  89157. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89158. */
  89159. export class MSFT_lod implements IGLTFLoaderExtension {
  89160. /**
  89161. * The name of this extension.
  89162. */
  89163. readonly name: string;
  89164. /**
  89165. * Defines whether this extension is enabled.
  89166. */
  89167. enabled: boolean;
  89168. /**
  89169. * Defines a number that determines the order the extensions are applied.
  89170. */
  89171. order: number;
  89172. /**
  89173. * Maximum number of LODs to load, starting from the lowest LOD.
  89174. */
  89175. maxLODsToLoad: number;
  89176. /**
  89177. * Observable raised when all node LODs of one level are loaded.
  89178. * The event data is the index of the loaded LOD starting from zero.
  89179. * Dispose the loader to cancel the loading of the next level of LODs.
  89180. */
  89181. onNodeLODsLoadedObservable: Observable<number>;
  89182. /**
  89183. * Observable raised when all material LODs of one level are loaded.
  89184. * The event data is the index of the loaded LOD starting from zero.
  89185. * Dispose the loader to cancel the loading of the next level of LODs.
  89186. */
  89187. onMaterialLODsLoadedObservable: Observable<number>;
  89188. private _loader;
  89189. private _bufferLODs;
  89190. private _nodeIndexLOD;
  89191. private _nodeSignalLODs;
  89192. private _nodePromiseLODs;
  89193. private _nodeBufferLODs;
  89194. private _materialIndexLOD;
  89195. private _materialSignalLODs;
  89196. private _materialPromiseLODs;
  89197. private _materialBufferLODs;
  89198. /** @hidden */
  89199. constructor(loader: GLTFLoader);
  89200. /** @hidden */
  89201. dispose(): void;
  89202. /** @hidden */
  89203. onReady(): void;
  89204. /** @hidden */
  89205. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89206. /** @hidden */
  89207. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89208. /** @hidden */
  89209. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89210. /** @hidden */
  89211. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89212. /** @hidden */
  89213. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89214. private _loadBufferLOD;
  89215. /**
  89216. * Gets an array of LOD properties from lowest to highest.
  89217. */
  89218. private _getLODs;
  89219. private _disposeTransformNode;
  89220. private _disposeMaterials;
  89221. }
  89222. }
  89223. declare module BABYLON.GLTF2.Loader.Extensions {
  89224. /** @hidden */
  89225. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89226. readonly name: string;
  89227. enabled: boolean;
  89228. private _loader;
  89229. constructor(loader: GLTFLoader);
  89230. dispose(): void;
  89231. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89232. }
  89233. }
  89234. declare module BABYLON.GLTF2.Loader.Extensions {
  89235. /** @hidden */
  89236. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89237. readonly name: string;
  89238. enabled: boolean;
  89239. private _loader;
  89240. constructor(loader: GLTFLoader);
  89241. dispose(): void;
  89242. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89243. }
  89244. }
  89245. declare module BABYLON.GLTF2.Loader.Extensions {
  89246. /**
  89247. * Store glTF extras (if present) in BJS objects' metadata
  89248. */
  89249. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89250. /**
  89251. * The name of this extension.
  89252. */
  89253. readonly name: string;
  89254. /**
  89255. * Defines whether this extension is enabled.
  89256. */
  89257. enabled: boolean;
  89258. private _loader;
  89259. private _assignExtras;
  89260. /** @hidden */
  89261. constructor(loader: GLTFLoader);
  89262. /** @hidden */
  89263. dispose(): void;
  89264. /** @hidden */
  89265. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89266. /** @hidden */
  89267. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89268. /** @hidden */
  89269. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89270. }
  89271. }
  89272. declare module BABYLON {
  89273. /**
  89274. * Class reading and parsing the MTL file bundled with the obj file.
  89275. */
  89276. export class MTLFileLoader {
  89277. /**
  89278. * Invert Y-Axis of referenced textures on load
  89279. */
  89280. static INVERT_TEXTURE_Y: boolean;
  89281. /**
  89282. * All material loaded from the mtl will be set here
  89283. */
  89284. materials: StandardMaterial[];
  89285. /**
  89286. * This function will read the mtl file and create each material described inside
  89287. * This function could be improve by adding :
  89288. * -some component missing (Ni, Tf...)
  89289. * -including the specific options available
  89290. *
  89291. * @param scene defines the scene the material will be created in
  89292. * @param data defines the mtl data to parse
  89293. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89294. * @param forAssetContainer defines if the material should be registered in the scene
  89295. */
  89296. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89297. /**
  89298. * Gets the texture for the material.
  89299. *
  89300. * If the material is imported from input file,
  89301. * We sanitize the url to ensure it takes the textre from aside the material.
  89302. *
  89303. * @param rootUrl The root url to load from
  89304. * @param value The value stored in the mtl
  89305. * @return The Texture
  89306. */
  89307. private static _getTexture;
  89308. }
  89309. }
  89310. declare module BABYLON {
  89311. /**
  89312. * Options for loading OBJ/MTL files
  89313. */
  89314. type MeshLoadOptions = {
  89315. /**
  89316. * Defines if UVs are optimized by default during load.
  89317. */
  89318. OptimizeWithUV: boolean;
  89319. /**
  89320. * Defines custom scaling of UV coordinates of loaded meshes.
  89321. */
  89322. UVScaling: Vector2;
  89323. /**
  89324. * Invert model on y-axis (does a model scaling inversion)
  89325. */
  89326. InvertY: boolean;
  89327. /**
  89328. * Invert Y-Axis of referenced textures on load
  89329. */
  89330. InvertTextureY: boolean;
  89331. /**
  89332. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89333. */
  89334. ImportVertexColors: boolean;
  89335. /**
  89336. * Compute the normals for the model, even if normals are present in the file.
  89337. */
  89338. ComputeNormals: boolean;
  89339. /**
  89340. * 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.
  89341. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89342. */
  89343. OptimizeNormals: boolean;
  89344. /**
  89345. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89346. */
  89347. SkipMaterials: boolean;
  89348. /**
  89349. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89350. */
  89351. MaterialLoadingFailsSilently: boolean;
  89352. };
  89353. /**
  89354. * OBJ file type loader.
  89355. * This is a babylon scene loader plugin.
  89356. */
  89357. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89358. /**
  89359. * Defines if UVs are optimized by default during load.
  89360. */
  89361. static OPTIMIZE_WITH_UV: boolean;
  89362. /**
  89363. * Invert model on y-axis (does a model scaling inversion)
  89364. */
  89365. static INVERT_Y: boolean;
  89366. /**
  89367. * Invert Y-Axis of referenced textures on load
  89368. */
  89369. static get INVERT_TEXTURE_Y(): boolean;
  89370. static set INVERT_TEXTURE_Y(value: boolean);
  89371. /**
  89372. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89373. */
  89374. static IMPORT_VERTEX_COLORS: boolean;
  89375. /**
  89376. * Compute the normals for the model, even if normals are present in the file.
  89377. */
  89378. static COMPUTE_NORMALS: boolean;
  89379. /**
  89380. * 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.
  89381. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89382. */
  89383. static OPTIMIZE_NORMALS: boolean;
  89384. /**
  89385. * Defines custom scaling of UV coordinates of loaded meshes.
  89386. */
  89387. static UV_SCALING: Vector2;
  89388. /**
  89389. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89390. */
  89391. static SKIP_MATERIALS: boolean;
  89392. /**
  89393. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89394. *
  89395. * Defaults to true for backwards compatibility.
  89396. */
  89397. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89398. /**
  89399. * Defines the name of the plugin.
  89400. */
  89401. name: string;
  89402. /**
  89403. * Defines the extension the plugin is able to load.
  89404. */
  89405. extensions: string;
  89406. /** @hidden */
  89407. obj: RegExp;
  89408. /** @hidden */
  89409. group: RegExp;
  89410. /** @hidden */
  89411. mtllib: RegExp;
  89412. /** @hidden */
  89413. usemtl: RegExp;
  89414. /** @hidden */
  89415. smooth: RegExp;
  89416. /** @hidden */
  89417. vertexPattern: RegExp;
  89418. /** @hidden */
  89419. normalPattern: RegExp;
  89420. /** @hidden */
  89421. uvPattern: RegExp;
  89422. /** @hidden */
  89423. facePattern1: RegExp;
  89424. /** @hidden */
  89425. facePattern2: RegExp;
  89426. /** @hidden */
  89427. facePattern3: RegExp;
  89428. /** @hidden */
  89429. facePattern4: RegExp;
  89430. /** @hidden */
  89431. facePattern5: RegExp;
  89432. private _forAssetContainer;
  89433. private _meshLoadOptions;
  89434. /**
  89435. * Creates loader for .OBJ files
  89436. *
  89437. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89438. */
  89439. constructor(meshLoadOptions?: MeshLoadOptions);
  89440. private static get currentMeshLoadOptions();
  89441. /**
  89442. * Calls synchronously the MTL file attached to this obj.
  89443. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89444. * Without this function materials are not displayed in the first frame (but displayed after).
  89445. * In consequence it is impossible to get material information in your HTML file
  89446. *
  89447. * @param url The URL of the MTL file
  89448. * @param rootUrl
  89449. * @param onSuccess Callback function to be called when the MTL file is loaded
  89450. * @private
  89451. */
  89452. private _loadMTL;
  89453. /**
  89454. * Instantiates a OBJ file loader plugin.
  89455. * @returns the created plugin
  89456. */
  89457. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89458. /**
  89459. * If the data string can be loaded directly.
  89460. *
  89461. * @param data string containing the file data
  89462. * @returns if the data can be loaded directly
  89463. */
  89464. canDirectLoad(data: string): boolean;
  89465. /**
  89466. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89467. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89468. * @param scene the scene the meshes should be added to
  89469. * @param data the OBJ data to load
  89470. * @param rootUrl root url to load from
  89471. * @param onProgress event that fires when loading progress has occured
  89472. * @param fileName Defines the name of the file to load
  89473. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89474. */
  89475. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89476. /**
  89477. * Imports all objects from the loaded OBJ data and adds them to the scene
  89478. * @param scene the scene the objects should be added to
  89479. * @param data the OBJ data to load
  89480. * @param rootUrl root url to load from
  89481. * @param onProgress event that fires when loading progress has occured
  89482. * @param fileName Defines the name of the file to load
  89483. * @returns a promise which completes when objects have been loaded to the scene
  89484. */
  89485. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89486. /**
  89487. * Load into an asset container.
  89488. * @param scene The scene to load into
  89489. * @param data The data to import
  89490. * @param rootUrl The root url for scene and resources
  89491. * @param onProgress The callback when the load progresses
  89492. * @param fileName Defines the name of the file to load
  89493. * @returns The loaded asset container
  89494. */
  89495. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89496. private _optimizeNormals;
  89497. /**
  89498. * Read the OBJ file and create an Array of meshes.
  89499. * Each mesh contains all information given by the OBJ and the MTL file.
  89500. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89501. *
  89502. * @param meshesNames
  89503. * @param scene Scene The scene where are displayed the data
  89504. * @param data String The content of the obj file
  89505. * @param rootUrl String The path to the folder
  89506. * @returns Array<AbstractMesh>
  89507. * @private
  89508. */
  89509. private _parseSolid;
  89510. }
  89511. }
  89512. declare module BABYLON {
  89513. /**
  89514. * STL file type loader.
  89515. * This is a babylon scene loader plugin.
  89516. */
  89517. export class STLFileLoader implements ISceneLoaderPlugin {
  89518. /** @hidden */
  89519. solidPattern: RegExp;
  89520. /** @hidden */
  89521. facetsPattern: RegExp;
  89522. /** @hidden */
  89523. normalPattern: RegExp;
  89524. /** @hidden */
  89525. vertexPattern: RegExp;
  89526. /**
  89527. * Defines the name of the plugin.
  89528. */
  89529. name: string;
  89530. /**
  89531. * Defines the extensions the stl loader is able to load.
  89532. * force data to come in as an ArrayBuffer
  89533. * we'll convert to string if it looks like it's an ASCII .stl
  89534. */
  89535. extensions: ISceneLoaderPluginExtensions;
  89536. /**
  89537. * Import meshes into a scene.
  89538. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89539. * @param scene The scene to import into
  89540. * @param data The data to import
  89541. * @param rootUrl The root url for scene and resources
  89542. * @param meshes The meshes array to import into
  89543. * @param particleSystems The particle systems array to import into
  89544. * @param skeletons The skeletons array to import into
  89545. * @param onError The callback when import fails
  89546. * @returns True if successful or false otherwise
  89547. */
  89548. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89549. /**
  89550. * Load into a scene.
  89551. * @param scene The scene to load into
  89552. * @param data The data to import
  89553. * @param rootUrl The root url for scene and resources
  89554. * @param onError The callback when import fails
  89555. * @returns true if successful or false otherwise
  89556. */
  89557. load(scene: Scene, data: any, rootUrl: string): boolean;
  89558. /**
  89559. * Load into an asset container.
  89560. * @param scene The scene to load into
  89561. * @param data The data to import
  89562. * @param rootUrl The root url for scene and resources
  89563. * @param onError The callback when import fails
  89564. * @returns The loaded asset container
  89565. */
  89566. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89567. private _isBinary;
  89568. private _parseBinary;
  89569. private _parseASCII;
  89570. }
  89571. }
  89572. declare module BABYLON {
  89573. /**
  89574. * Class for generating OBJ data from a Babylon scene.
  89575. */
  89576. export class OBJExport {
  89577. /**
  89578. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89579. * @param mesh defines the list of meshes to serialize
  89580. * @param materials defines if materials should be exported
  89581. * @param matlibname defines the name of the associated mtl file
  89582. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89583. * @returns the OBJ content
  89584. */
  89585. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89586. /**
  89587. * Exports the material(s) of a mesh in .MTL file format (text)
  89588. * @param mesh defines the mesh to extract the material from
  89589. * @returns the mtl content
  89590. */
  89591. static MTL(mesh: Mesh): string;
  89592. }
  89593. }
  89594. declare module BABYLON {
  89595. /** @hidden */
  89596. export var __IGLTFExporterExtension: number;
  89597. /**
  89598. * Interface for extending the exporter
  89599. * @hidden
  89600. */
  89601. export interface IGLTFExporterExtension {
  89602. /**
  89603. * The name of this extension
  89604. */
  89605. readonly name: string;
  89606. /**
  89607. * Defines whether this extension is enabled
  89608. */
  89609. enabled: boolean;
  89610. /**
  89611. * Defines whether this extension is required
  89612. */
  89613. required: boolean;
  89614. }
  89615. }
  89616. declare module BABYLON.GLTF2.Exporter {
  89617. /** @hidden */
  89618. export var __IGLTFExporterExtensionV2: number;
  89619. /**
  89620. * Interface for a glTF exporter extension
  89621. * @hidden
  89622. */
  89623. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89624. /**
  89625. * Define this method to modify the default behavior before exporting a texture
  89626. * @param context The context when loading the asset
  89627. * @param babylonTexture The Babylon.js texture
  89628. * @param mimeType The mime-type of the generated image
  89629. * @returns A promise that resolves with the exported texture
  89630. */
  89631. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89632. /**
  89633. * Define this method to get notified when a texture info is created
  89634. * @param context The context when loading the asset
  89635. * @param textureInfo The glTF texture info
  89636. * @param babylonTexture The Babylon.js texture
  89637. */
  89638. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89639. /**
  89640. * Define this method to modify the default behavior when exporting texture info
  89641. * @param context The context when loading the asset
  89642. * @param meshPrimitive glTF mesh primitive
  89643. * @param babylonSubMesh Babylon submesh
  89644. * @param binaryWriter glTF serializer binary writer instance
  89645. * @returns nullable IMeshPrimitive promise
  89646. */
  89647. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89648. /**
  89649. * Define this method to modify the default behavior when exporting a node
  89650. * @param context The context when exporting the node
  89651. * @param node glTF node
  89652. * @param babylonNode BabylonJS node
  89653. * @returns nullable INode promise
  89654. */
  89655. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89656. [key: number]: number;
  89657. }): Promise<Nullable<INode>>;
  89658. /**
  89659. * Define this method to modify the default behavior when exporting a material
  89660. * @param material glTF material
  89661. * @param babylonMaterial BabylonJS material
  89662. * @returns nullable IMaterial promise
  89663. */
  89664. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89665. /**
  89666. * Define this method to return additional textures to export from a material
  89667. * @param material glTF material
  89668. * @param babylonMaterial BabylonJS material
  89669. * @returns List of textures
  89670. */
  89671. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89672. /** Gets a boolean indicating that this extension was used */
  89673. wasUsed: boolean;
  89674. /** Gets a boolean indicating that this extension is required for the file to work */
  89675. required: boolean;
  89676. /**
  89677. * Called after the exporter state changes to EXPORTING
  89678. */
  89679. onExporting?(): void;
  89680. }
  89681. }
  89682. declare module BABYLON.GLTF2.Exporter {
  89683. /**
  89684. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89685. * @hidden
  89686. */
  89687. export class _GLTFMaterialExporter {
  89688. /**
  89689. * Represents the dielectric specular values for R, G and B
  89690. */
  89691. private static readonly _DielectricSpecular;
  89692. /**
  89693. * Allows the maximum specular power to be defined for material calculations
  89694. */
  89695. private static readonly _MaxSpecularPower;
  89696. /**
  89697. * Mapping to store textures
  89698. */
  89699. private _textureMap;
  89700. /**
  89701. * Numeric tolerance value
  89702. */
  89703. private static readonly _Epsilon;
  89704. /**
  89705. * Reference to the glTF Exporter
  89706. */
  89707. private _exporter;
  89708. constructor(exporter: _Exporter);
  89709. /**
  89710. * Specifies if two colors are approximately equal in value
  89711. * @param color1 first color to compare to
  89712. * @param color2 second color to compare to
  89713. * @param epsilon threshold value
  89714. */
  89715. private static FuzzyEquals;
  89716. /**
  89717. * Gets the materials from a Babylon scene and converts them to glTF materials
  89718. * @param scene babylonjs scene
  89719. * @param mimeType texture mime type
  89720. * @param images array of images
  89721. * @param textures array of textures
  89722. * @param materials array of materials
  89723. * @param imageData mapping of texture names to base64 textures
  89724. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89725. */
  89726. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89727. /**
  89728. * Makes a copy of the glTF material without the texture parameters
  89729. * @param originalMaterial original glTF material
  89730. * @returns glTF material without texture parameters
  89731. */
  89732. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89733. /**
  89734. * Specifies if the material has any texture parameters present
  89735. * @param material glTF Material
  89736. * @returns boolean specifying if texture parameters are present
  89737. */
  89738. _hasTexturesPresent(material: IMaterial): boolean;
  89739. /**
  89740. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89741. * @param babylonStandardMaterial
  89742. * @returns glTF Metallic Roughness Material representation
  89743. */
  89744. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89745. /**
  89746. * Computes the metallic factor
  89747. * @param diffuse diffused value
  89748. * @param specular specular value
  89749. * @param oneMinusSpecularStrength one minus the specular strength
  89750. * @returns metallic value
  89751. */
  89752. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89753. /**
  89754. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89755. * @param glTFMaterial glTF material
  89756. * @param babylonMaterial Babylon material
  89757. */
  89758. private static _SetAlphaMode;
  89759. /**
  89760. * Converts a Babylon Standard Material to a glTF Material
  89761. * @param babylonStandardMaterial BJS Standard Material
  89762. * @param mimeType mime type to use for the textures
  89763. * @param images array of glTF image interfaces
  89764. * @param textures array of glTF texture interfaces
  89765. * @param materials array of glTF material interfaces
  89766. * @param imageData map of image file name to data
  89767. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89768. */
  89769. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89770. private _finishMaterial;
  89771. /**
  89772. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89773. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89774. * @param mimeType mime type to use for the textures
  89775. * @param images array of glTF image interfaces
  89776. * @param textures array of glTF texture interfaces
  89777. * @param materials array of glTF material interfaces
  89778. * @param imageData map of image file name to data
  89779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89780. */
  89781. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89782. /**
  89783. * Converts an image typed array buffer to a base64 image
  89784. * @param buffer typed array buffer
  89785. * @param width width of the image
  89786. * @param height height of the image
  89787. * @param mimeType mimetype of the image
  89788. * @returns base64 image string
  89789. */
  89790. private _createBase64FromCanvasAsync;
  89791. /**
  89792. * Generates a white texture based on the specified width and height
  89793. * @param width width of the texture in pixels
  89794. * @param height height of the texture in pixels
  89795. * @param scene babylonjs scene
  89796. * @returns white texture
  89797. */
  89798. private _createWhiteTexture;
  89799. /**
  89800. * 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
  89801. * @param texture1 first texture to resize
  89802. * @param texture2 second texture to resize
  89803. * @param scene babylonjs scene
  89804. * @returns resized textures or null
  89805. */
  89806. private _resizeTexturesToSameDimensions;
  89807. /**
  89808. * Converts an array of pixels to a Float32Array
  89809. * Throws an error if the pixel format is not supported
  89810. * @param pixels - array buffer containing pixel values
  89811. * @returns Float32 of pixels
  89812. */
  89813. private _convertPixelArrayToFloat32;
  89814. /**
  89815. * Convert Specular Glossiness Textures to Metallic Roughness
  89816. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89817. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89818. * @param diffuseTexture texture used to store diffuse information
  89819. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89820. * @param factors specular glossiness material factors
  89821. * @param mimeType the mime type to use for the texture
  89822. * @returns pbr metallic roughness interface or null
  89823. */
  89824. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89825. /**
  89826. * Converts specular glossiness material properties to metallic roughness
  89827. * @param specularGlossiness interface with specular glossiness material properties
  89828. * @returns interface with metallic roughness material properties
  89829. */
  89830. private _convertSpecularGlossinessToMetallicRoughness;
  89831. /**
  89832. * Calculates the surface reflectance, independent of lighting conditions
  89833. * @param color Color source to calculate brightness from
  89834. * @returns number representing the perceived brightness, or zero if color is undefined
  89835. */
  89836. private _getPerceivedBrightness;
  89837. /**
  89838. * Returns the maximum color component value
  89839. * @param color
  89840. * @returns maximum color component value, or zero if color is null or undefined
  89841. */
  89842. private _getMaxComponent;
  89843. /**
  89844. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89845. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89846. * @param mimeType mime type to use for the textures
  89847. * @param images array of glTF image interfaces
  89848. * @param textures array of glTF texture interfaces
  89849. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89850. * @param imageData map of image file name to data
  89851. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89852. * @returns glTF PBR Metallic Roughness factors
  89853. */
  89854. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89855. private _getGLTFTextureSampler;
  89856. private _getGLTFTextureWrapMode;
  89857. private _getGLTFTextureWrapModesSampler;
  89858. /**
  89859. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89860. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89861. * @param mimeType mime type to use for the textures
  89862. * @param images array of glTF image interfaces
  89863. * @param textures array of glTF texture interfaces
  89864. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89865. * @param imageData map of image file name to data
  89866. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89867. * @returns glTF PBR Metallic Roughness factors
  89868. */
  89869. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89870. /**
  89871. * Converts a Babylon PBR Base Material to a glTF Material
  89872. * @param babylonPBRMaterial BJS PBR Base Material
  89873. * @param mimeType mime type to use for the textures
  89874. * @param images array of glTF image interfaces
  89875. * @param textures array of glTF texture interfaces
  89876. * @param materials array of glTF material interfaces
  89877. * @param imageData map of image file name to data
  89878. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89879. */
  89880. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89881. private setMetallicRoughnessPbrMaterial;
  89882. private getPixelsFromTexture;
  89883. /**
  89884. * Extracts a texture from a Babylon texture into file data and glTF data
  89885. * @param babylonTexture Babylon texture to extract
  89886. * @param mimeType Mime Type of the babylonTexture
  89887. * @return glTF texture info, or null if the texture format is not supported
  89888. */
  89889. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89890. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89891. /**
  89892. * Builds a texture from base64 string
  89893. * @param base64Texture base64 texture string
  89894. * @param baseTextureName Name to use for the texture
  89895. * @param mimeType image mime type for the texture
  89896. * @param images array of images
  89897. * @param textures array of textures
  89898. * @param imageData map of image data
  89899. * @returns glTF texture info, or null if the texture format is not supported
  89900. */
  89901. private _getTextureInfoFromBase64;
  89902. }
  89903. }
  89904. declare module BABYLON {
  89905. /**
  89906. * Class for holding and downloading glTF file data
  89907. */
  89908. export class GLTFData {
  89909. /**
  89910. * Object which contains the file name as the key and its data as the value
  89911. */
  89912. glTFFiles: {
  89913. [fileName: string]: string | Blob;
  89914. };
  89915. /**
  89916. * Initializes the glTF file object
  89917. */
  89918. constructor();
  89919. /**
  89920. * Downloads the glTF data as files based on their names and data
  89921. */
  89922. downloadFiles(): void;
  89923. }
  89924. }
  89925. declare module BABYLON {
  89926. /**
  89927. * Holds a collection of exporter options and parameters
  89928. */
  89929. export interface IExportOptions {
  89930. /**
  89931. * Function which indicates whether a babylon node should be exported or not
  89932. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89933. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89934. */
  89935. shouldExportNode?(node: Node): boolean;
  89936. /**
  89937. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89938. * @param metadata source metadata to read from
  89939. * @returns the data to store to glTF node extras
  89940. */
  89941. metadataSelector?(metadata: any): any;
  89942. /**
  89943. * The sample rate to bake animation curves
  89944. */
  89945. animationSampleRate?: number;
  89946. /**
  89947. * Begin serialization without waiting for the scene to be ready
  89948. */
  89949. exportWithoutWaitingForScene?: boolean;
  89950. /**
  89951. * Indicates if coordinate system swapping root nodes should be included in export
  89952. */
  89953. includeCoordinateSystemConversionNodes?: boolean;
  89954. }
  89955. /**
  89956. * Class for generating glTF data from a Babylon scene.
  89957. */
  89958. export class GLTF2Export {
  89959. /**
  89960. * Exports the geometry of the scene to .gltf file format asynchronously
  89961. * @param scene Babylon scene with scene hierarchy information
  89962. * @param filePrefix File prefix to use when generating the glTF file
  89963. * @param options Exporter options
  89964. * @returns Returns an object with a .gltf file and associates texture names
  89965. * as keys and their data and paths as values
  89966. */
  89967. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89968. private static _PreExportAsync;
  89969. private static _PostExportAsync;
  89970. /**
  89971. * Exports the geometry of the scene to .glb file format asychronously
  89972. * @param scene Babylon scene with scene hierarchy information
  89973. * @param filePrefix File prefix to use when generating glb file
  89974. * @param options Exporter options
  89975. * @returns Returns an object with a .glb filename as key and data as value
  89976. */
  89977. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89978. }
  89979. }
  89980. declare module BABYLON.GLTF2.Exporter {
  89981. /**
  89982. * @hidden
  89983. */
  89984. export class _GLTFUtilities {
  89985. /**
  89986. * Creates a buffer view based on the supplied arguments
  89987. * @param bufferIndex index value of the specified buffer
  89988. * @param byteOffset byte offset value
  89989. * @param byteLength byte length of the bufferView
  89990. * @param byteStride byte distance between conequential elements
  89991. * @param name name of the buffer view
  89992. * @returns bufferView for glTF
  89993. */
  89994. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89995. /**
  89996. * Creates an accessor based on the supplied arguments
  89997. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89998. * @param name The name of the accessor
  89999. * @param type The type of the accessor
  90000. * @param componentType The datatype of components in the attribute
  90001. * @param count The number of attributes referenced by this accessor
  90002. * @param byteOffset The offset relative to the start of the bufferView in bytes
  90003. * @param min Minimum value of each component in this attribute
  90004. * @param max Maximum value of each component in this attribute
  90005. * @returns accessor for glTF
  90006. */
  90007. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  90008. /**
  90009. * Calculates the minimum and maximum values of an array of position floats
  90010. * @param positions Positions array of a mesh
  90011. * @param vertexStart Starting vertex offset to calculate min and max values
  90012. * @param vertexCount Number of vertices to check for min and max values
  90013. * @returns min number array and max number array
  90014. */
  90015. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  90016. min: number[];
  90017. max: number[];
  90018. };
  90019. /**
  90020. * Converts a new right-handed Vector3
  90021. * @param vector vector3 array
  90022. * @returns right-handed Vector3
  90023. */
  90024. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  90025. /**
  90026. * Converts a Vector3 to right-handed
  90027. * @param vector Vector3 to convert to right-handed
  90028. */
  90029. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  90030. /**
  90031. * Converts a three element number array to right-handed
  90032. * @param vector number array to convert to right-handed
  90033. */
  90034. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90035. /**
  90036. * Converts a new right-handed Vector3
  90037. * @param vector vector3 array
  90038. * @returns right-handed Vector3
  90039. */
  90040. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90041. /**
  90042. * Converts a Vector3 to right-handed
  90043. * @param vector Vector3 to convert to right-handed
  90044. */
  90045. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90046. /**
  90047. * Converts a three element number array to right-handed
  90048. * @param vector number array to convert to right-handed
  90049. */
  90050. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90051. /**
  90052. * Converts a Vector4 to right-handed
  90053. * @param vector Vector4 to convert to right-handed
  90054. */
  90055. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90056. /**
  90057. * Converts a Vector4 to right-handed
  90058. * @param vector Vector4 to convert to right-handed
  90059. */
  90060. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90061. /**
  90062. * Converts a Quaternion to right-handed
  90063. * @param quaternion Source quaternion to convert to right-handed
  90064. */
  90065. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90066. /**
  90067. * Converts a Quaternion to right-handed
  90068. * @param quaternion Source quaternion to convert to right-handed
  90069. */
  90070. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90071. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90072. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90073. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90074. }
  90075. }
  90076. declare module BABYLON.GLTF2.Exporter {
  90077. /**
  90078. * Converts Babylon Scene into glTF 2.0.
  90079. * @hidden
  90080. */
  90081. export class _Exporter {
  90082. /**
  90083. * Stores the glTF to export
  90084. */
  90085. _glTF: IGLTF;
  90086. /**
  90087. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90088. */
  90089. _bufferViews: IBufferView[];
  90090. /**
  90091. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90092. */
  90093. _accessors: IAccessor[];
  90094. /**
  90095. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90096. */
  90097. _nodes: INode[];
  90098. /**
  90099. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90100. */
  90101. private _scenes;
  90102. /**
  90103. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90104. */
  90105. private _meshes;
  90106. /**
  90107. * Stores all the generated material information, which represents the appearance of each primitive
  90108. */
  90109. _materials: IMaterial[];
  90110. _materialMap: {
  90111. [materialID: number]: number;
  90112. };
  90113. /**
  90114. * Stores all the generated texture information, which is referenced by glTF materials
  90115. */
  90116. _textures: ITexture[];
  90117. /**
  90118. * Stores all the generated image information, which is referenced by glTF textures
  90119. */
  90120. _images: IImage[];
  90121. /**
  90122. * Stores all the texture samplers
  90123. */
  90124. _samplers: ISampler[];
  90125. /**
  90126. * Stores all the generated glTF skins
  90127. */
  90128. _skins: ISkin[];
  90129. /**
  90130. * Stores all the generated animation samplers, which is referenced by glTF animations
  90131. */
  90132. /**
  90133. * Stores the animations for glTF models
  90134. */
  90135. private _animations;
  90136. /**
  90137. * Stores the total amount of bytes stored in the glTF buffer
  90138. */
  90139. private _totalByteLength;
  90140. /**
  90141. * Stores a reference to the Babylon scene containing the source geometry and material information
  90142. */
  90143. _babylonScene: Scene;
  90144. /**
  90145. * Stores a map of the image data, where the key is the file name and the value
  90146. * is the image data
  90147. */
  90148. _imageData: {
  90149. [fileName: string]: {
  90150. data: Uint8Array;
  90151. mimeType: ImageMimeType;
  90152. };
  90153. };
  90154. protected _orderedImageData: Array<{
  90155. data: Uint8Array;
  90156. mimeType: ImageMimeType;
  90157. }>;
  90158. /**
  90159. * Stores a map of the unique id of a node to its index in the node array
  90160. */
  90161. _nodeMap: {
  90162. [key: number]: number;
  90163. };
  90164. /**
  90165. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90166. */
  90167. _convertToRightHandedSystem: boolean;
  90168. /**
  90169. * Specifies if a Babylon node should be converted to right-handed on export
  90170. */
  90171. _convertToRightHandedSystemMap: {
  90172. [nodeId: number]: boolean;
  90173. };
  90174. _includeCoordinateSystemConversionNodes: boolean;
  90175. /**
  90176. * Baked animation sample rate
  90177. */
  90178. private _animationSampleRate;
  90179. private _options;
  90180. private _localEngine;
  90181. _glTFMaterialExporter: _GLTFMaterialExporter;
  90182. private _extensions;
  90183. private static _ExtensionNames;
  90184. private static _ExtensionFactories;
  90185. private _applyExtension;
  90186. private _applyExtensions;
  90187. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90188. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90189. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90190. [key: number]: number;
  90191. }): Promise<Nullable<INode>>;
  90192. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90193. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90194. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90195. private _forEachExtensions;
  90196. private _extensionsOnExporting;
  90197. /**
  90198. * Load glTF serializer extensions
  90199. */
  90200. private _loadExtensions;
  90201. /**
  90202. * Creates a glTF Exporter instance, which can accept optional exporter options
  90203. * @param babylonScene Babylon scene object
  90204. * @param options Options to modify the behavior of the exporter
  90205. */
  90206. constructor(babylonScene: Scene, options?: IExportOptions);
  90207. dispose(): void;
  90208. /**
  90209. * Registers a glTF exporter extension
  90210. * @param name Name of the extension to export
  90211. * @param factory The factory function that creates the exporter extension
  90212. */
  90213. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90214. /**
  90215. * Un-registers an exporter extension
  90216. * @param name The name fo the exporter extension
  90217. * @returns A boolean indicating whether the extension has been un-registered
  90218. */
  90219. static UnregisterExtension(name: string): boolean;
  90220. private reorderIndicesBasedOnPrimitiveMode;
  90221. /**
  90222. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90223. * clock-wise during export to glTF
  90224. * @param submesh BabylonJS submesh
  90225. * @param primitiveMode Primitive mode of the mesh
  90226. * @param sideOrientation the winding order of the submesh
  90227. * @param vertexBufferKind The type of vertex attribute
  90228. * @param meshAttributeArray The vertex attribute data
  90229. * @param byteOffset The offset to the binary data
  90230. * @param binaryWriter The binary data for the glTF file
  90231. * @param convertToRightHandedSystem Converts the values to right-handed
  90232. */
  90233. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90234. /**
  90235. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90236. * clock-wise during export to glTF
  90237. * @param submesh BabylonJS submesh
  90238. * @param primitiveMode Primitive mode of the mesh
  90239. * @param sideOrientation the winding order of the submesh
  90240. * @param vertexBufferKind The type of vertex attribute
  90241. * @param meshAttributeArray The vertex attribute data
  90242. * @param byteOffset The offset to the binary data
  90243. * @param binaryWriter The binary data for the glTF file
  90244. * @param convertToRightHandedSystem Converts the values to right-handed
  90245. */
  90246. private reorderTriangleFillMode;
  90247. /**
  90248. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90249. * clock-wise during export to glTF
  90250. * @param submesh BabylonJS submesh
  90251. * @param primitiveMode Primitive mode of the mesh
  90252. * @param sideOrientation the winding order of the submesh
  90253. * @param vertexBufferKind The type of vertex attribute
  90254. * @param meshAttributeArray The vertex attribute data
  90255. * @param byteOffset The offset to the binary data
  90256. * @param binaryWriter The binary data for the glTF file
  90257. * @param convertToRightHandedSystem Converts the values to right-handed
  90258. */
  90259. private reorderTriangleStripDrawMode;
  90260. /**
  90261. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90262. * clock-wise during export to glTF
  90263. * @param submesh BabylonJS submesh
  90264. * @param primitiveMode Primitive mode of the mesh
  90265. * @param sideOrientation the winding order of the submesh
  90266. * @param vertexBufferKind The type of vertex attribute
  90267. * @param meshAttributeArray The vertex attribute data
  90268. * @param byteOffset The offset to the binary data
  90269. * @param binaryWriter The binary data for the glTF file
  90270. * @param convertToRightHandedSystem Converts the values to right-handed
  90271. */
  90272. private reorderTriangleFanMode;
  90273. /**
  90274. * Writes the vertex attribute data to binary
  90275. * @param vertices The vertices to write to the binary writer
  90276. * @param byteOffset The offset into the binary writer to overwrite binary data
  90277. * @param vertexAttributeKind The vertex attribute type
  90278. * @param meshAttributeArray The vertex attribute data
  90279. * @param binaryWriter The writer containing the binary data
  90280. * @param convertToRightHandedSystem Converts the values to right-handed
  90281. */
  90282. private writeVertexAttributeData;
  90283. /**
  90284. * Writes mesh attribute data to a data buffer
  90285. * Returns the bytelength of the data
  90286. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90287. * @param meshAttributeArray Array containing the attribute data
  90288. * @param byteStride Specifies the space between data
  90289. * @param binaryWriter The buffer to write the binary data to
  90290. * @param convertToRightHandedSystem Converts the values to right-handed
  90291. */
  90292. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90293. /**
  90294. * Writes mesh attribute data to a data buffer
  90295. * Returns the bytelength of the data
  90296. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90297. * @param meshAttributeArray Array containing the attribute data
  90298. * @param byteStride Specifies the space between data
  90299. * @param binaryWriter The buffer to write the binary data to
  90300. * @param convertToRightHandedSystem Converts the values to right-handed
  90301. */
  90302. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90303. /**
  90304. * Generates glTF json data
  90305. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90306. * @param glTFPrefix Text to use when prefixing a glTF file
  90307. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90308. * @returns json data as string
  90309. */
  90310. private generateJSON;
  90311. /**
  90312. * Generates data for .gltf and .bin files based on the glTF prefix string
  90313. * @param glTFPrefix Text to use when prefixing a glTF file
  90314. * @param dispose Dispose the exporter
  90315. * @returns GLTFData with glTF file data
  90316. */
  90317. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90318. /**
  90319. * Creates a binary buffer for glTF
  90320. * @returns array buffer for binary data
  90321. */
  90322. private _generateBinaryAsync;
  90323. /**
  90324. * Pads the number to a multiple of 4
  90325. * @param num number to pad
  90326. * @returns padded number
  90327. */
  90328. private _getPadding;
  90329. /**
  90330. * @hidden
  90331. */
  90332. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90333. /**
  90334. * Sets the TRS for each node
  90335. * @param node glTF Node for storing the transformation data
  90336. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90337. * @param convertToRightHandedSystem Converts the values to right-handed
  90338. */
  90339. private setNodeTransformation;
  90340. private getVertexBufferFromMesh;
  90341. /**
  90342. * Creates a bufferview based on the vertices type for the Babylon mesh
  90343. * @param kind Indicates the type of vertices data
  90344. * @param componentType Indicates the numerical type used to store the data
  90345. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90346. * @param binaryWriter The buffer to write the bufferview data to
  90347. * @param convertToRightHandedSystem Converts the values to right-handed
  90348. */
  90349. private createBufferViewKind;
  90350. /**
  90351. * Creates a bufferview based on the vertices type for the Babylon mesh
  90352. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90353. * @param babylonMorphTarget the morph target to be exported
  90354. * @param binaryWriter The buffer to write the bufferview data to
  90355. * @param convertToRightHandedSystem Converts the values to right-handed
  90356. */
  90357. private setMorphTargetAttributes;
  90358. /**
  90359. * The primitive mode of the Babylon mesh
  90360. * @param babylonMesh The BabylonJS mesh
  90361. */
  90362. private getMeshPrimitiveMode;
  90363. /**
  90364. * Sets the primitive mode of the glTF mesh primitive
  90365. * @param meshPrimitive glTF mesh primitive
  90366. * @param primitiveMode The primitive mode
  90367. */
  90368. private setPrimitiveMode;
  90369. /**
  90370. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90371. * @param meshPrimitive glTF mesh primitive
  90372. * @param attributeKind vertex attribute
  90373. * @returns boolean specifying if uv coordinates are present
  90374. */
  90375. private setAttributeKind;
  90376. /**
  90377. * Sets data for the primitive attributes of each submesh
  90378. * @param mesh glTF Mesh object to store the primitive attribute information
  90379. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90380. * @param binaryWriter Buffer to write the attribute data to
  90381. * @param convertToRightHandedSystem Converts the values to right-handed
  90382. */
  90383. private setPrimitiveAttributesAsync;
  90384. /**
  90385. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90386. * @param node The node to check
  90387. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90388. */
  90389. private isBabylonCoordinateSystemConvertingNode;
  90390. /**
  90391. * Creates a glTF scene based on the array of meshes
  90392. * Returns the the total byte offset
  90393. * @param babylonScene Babylon scene to get the mesh data from
  90394. * @param binaryWriter Buffer to write binary data to
  90395. */
  90396. private createSceneAsync;
  90397. /**
  90398. * Creates a mapping of Node unique id to node index and handles animations
  90399. * @param babylonScene Babylon Scene
  90400. * @param nodes Babylon transform nodes
  90401. * @param binaryWriter Buffer to write binary data to
  90402. * @returns Node mapping of unique id to index
  90403. */
  90404. private createNodeMapAndAnimationsAsync;
  90405. /**
  90406. * Creates a glTF node from a Babylon mesh
  90407. * @param babylonMesh Source Babylon mesh
  90408. * @param binaryWriter Buffer for storing geometry data
  90409. * @param convertToRightHandedSystem Converts the values to right-handed
  90410. * @param nodeMap Node mapping of unique id to glTF node index
  90411. * @returns glTF node
  90412. */
  90413. private createNodeAsync;
  90414. /**
  90415. * Creates a glTF skin from a Babylon skeleton
  90416. * @param babylonScene Babylon Scene
  90417. * @param nodes Babylon transform nodes
  90418. * @param binaryWriter Buffer to write binary data to
  90419. * @returns Node mapping of unique id to index
  90420. */
  90421. private createSkinsAsync;
  90422. }
  90423. /**
  90424. * @hidden
  90425. *
  90426. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90427. */
  90428. export class _BinaryWriter {
  90429. /**
  90430. * Array buffer which stores all binary data
  90431. */
  90432. private _arrayBuffer;
  90433. /**
  90434. * View of the array buffer
  90435. */
  90436. private _dataView;
  90437. /**
  90438. * byte offset of data in array buffer
  90439. */
  90440. private _byteOffset;
  90441. /**
  90442. * Initialize binary writer with an initial byte length
  90443. * @param byteLength Initial byte length of the array buffer
  90444. */
  90445. constructor(byteLength: number);
  90446. /**
  90447. * Resize the array buffer to the specified byte length
  90448. * @param byteLength
  90449. */
  90450. private resizeBuffer;
  90451. /**
  90452. * Get an array buffer with the length of the byte offset
  90453. * @returns ArrayBuffer resized to the byte offset
  90454. */
  90455. getArrayBuffer(): ArrayBuffer;
  90456. /**
  90457. * Get the byte offset of the array buffer
  90458. * @returns byte offset
  90459. */
  90460. getByteOffset(): number;
  90461. /**
  90462. * Stores an UInt8 in the array buffer
  90463. * @param entry
  90464. * @param byteOffset If defined, specifies where to set the value as an offset.
  90465. */
  90466. setUInt8(entry: number, byteOffset?: number): void;
  90467. /**
  90468. * Stores an UInt16 in the array buffer
  90469. * @param entry
  90470. * @param byteOffset If defined, specifies where to set the value as an offset.
  90471. */
  90472. setUInt16(entry: number, byteOffset?: number): void;
  90473. /**
  90474. * Gets an UInt32 in the array buffer
  90475. * @param entry
  90476. * @param byteOffset If defined, specifies where to set the value as an offset.
  90477. */
  90478. getUInt32(byteOffset: number): number;
  90479. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90480. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90481. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90482. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90483. /**
  90484. * Stores a Float32 in the array buffer
  90485. * @param entry
  90486. */
  90487. setFloat32(entry: number, byteOffset?: number): void;
  90488. /**
  90489. * Stores an UInt32 in the array buffer
  90490. * @param entry
  90491. * @param byteOffset If defined, specifies where to set the value as an offset.
  90492. */
  90493. setUInt32(entry: number, byteOffset?: number): void;
  90494. }
  90495. }
  90496. declare module BABYLON.GLTF2.Exporter {
  90497. /**
  90498. * @hidden
  90499. * Interface to store animation data.
  90500. */
  90501. export interface _IAnimationData {
  90502. /**
  90503. * Keyframe data.
  90504. */
  90505. inputs: number[];
  90506. /**
  90507. * Value data.
  90508. */
  90509. outputs: number[][];
  90510. /**
  90511. * Animation interpolation data.
  90512. */
  90513. samplerInterpolation: AnimationSamplerInterpolation;
  90514. /**
  90515. * Minimum keyframe value.
  90516. */
  90517. inputsMin: number;
  90518. /**
  90519. * Maximum keyframe value.
  90520. */
  90521. inputsMax: number;
  90522. }
  90523. /**
  90524. * @hidden
  90525. */
  90526. export interface _IAnimationInfo {
  90527. /**
  90528. * The target channel for the animation
  90529. */
  90530. animationChannelTargetPath: AnimationChannelTargetPath;
  90531. /**
  90532. * The glTF accessor type for the data.
  90533. */
  90534. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90535. /**
  90536. * Specifies if quaternions should be used.
  90537. */
  90538. useQuaternion: boolean;
  90539. }
  90540. /**
  90541. * @hidden
  90542. * Utility class for generating glTF animation data from BabylonJS.
  90543. */
  90544. export class _GLTFAnimation {
  90545. /**
  90546. * @ignore
  90547. *
  90548. * Creates glTF channel animation from BabylonJS animation.
  90549. * @param babylonTransformNode - BabylonJS mesh.
  90550. * @param animation - animation.
  90551. * @param animationChannelTargetPath - The target animation channel.
  90552. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90553. * @param useQuaternion - Specifies if quaternions are used.
  90554. * @returns nullable IAnimationData
  90555. */
  90556. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90557. private static _DeduceAnimationInfo;
  90558. /**
  90559. * @ignore
  90560. * Create node animations from the transform node animations
  90561. * @param babylonNode
  90562. * @param runtimeGLTFAnimation
  90563. * @param idleGLTFAnimations
  90564. * @param nodeMap
  90565. * @param nodes
  90566. * @param binaryWriter
  90567. * @param bufferViews
  90568. * @param accessors
  90569. * @param convertToRightHandedSystem
  90570. * @param animationSampleRate
  90571. */
  90572. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90573. [key: number]: number;
  90574. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90575. /**
  90576. * @ignore
  90577. * Create individual morph animations from the mesh's morph target animation tracks
  90578. * @param babylonNode
  90579. * @param runtimeGLTFAnimation
  90580. * @param idleGLTFAnimations
  90581. * @param nodeMap
  90582. * @param nodes
  90583. * @param binaryWriter
  90584. * @param bufferViews
  90585. * @param accessors
  90586. * @param convertToRightHandedSystem
  90587. * @param animationSampleRate
  90588. */
  90589. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90590. [key: number]: number;
  90591. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90592. /**
  90593. * @ignore
  90594. * Create node and morph animations from the animation groups
  90595. * @param babylonScene
  90596. * @param glTFAnimations
  90597. * @param nodeMap
  90598. * @param nodes
  90599. * @param binaryWriter
  90600. * @param bufferViews
  90601. * @param accessors
  90602. * @param convertToRightHandedSystemMap
  90603. * @param animationSampleRate
  90604. */
  90605. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90606. [key: number]: number;
  90607. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90608. [nodeId: number]: boolean;
  90609. }, animationSampleRate: number): void;
  90610. private static AddAnimation;
  90611. /**
  90612. * Create a baked animation
  90613. * @param babylonTransformNode BabylonJS mesh
  90614. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90615. * @param animationChannelTargetPath animation target channel
  90616. * @param minFrame minimum animation frame
  90617. * @param maxFrame maximum animation frame
  90618. * @param fps frames per second of the animation
  90619. * @param inputs input key frames of the animation
  90620. * @param outputs output key frame data of the animation
  90621. * @param convertToRightHandedSystem converts the values to right-handed
  90622. * @param useQuaternion specifies if quaternions should be used
  90623. */
  90624. private static _CreateBakedAnimation;
  90625. private static _ConvertFactorToVector3OrQuaternion;
  90626. private static _SetInterpolatedValue;
  90627. /**
  90628. * Creates linear animation from the animation key frames
  90629. * @param babylonTransformNode BabylonJS mesh
  90630. * @param animation BabylonJS animation
  90631. * @param animationChannelTargetPath The target animation channel
  90632. * @param frameDelta The difference between the last and first frame of the animation
  90633. * @param inputs Array to store the key frame times
  90634. * @param outputs Array to store the key frame data
  90635. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90636. * @param useQuaternion Specifies if quaternions are used in the animation
  90637. */
  90638. private static _CreateLinearOrStepAnimation;
  90639. /**
  90640. * Creates cubic spline animation from the animation key frames
  90641. * @param babylonTransformNode BabylonJS mesh
  90642. * @param animation BabylonJS animation
  90643. * @param animationChannelTargetPath The target animation channel
  90644. * @param frameDelta The difference between the last and first frame of the animation
  90645. * @param inputs Array to store the key frame times
  90646. * @param outputs Array to store the key frame data
  90647. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90648. * @param useQuaternion Specifies if quaternions are used in the animation
  90649. */
  90650. private static _CreateCubicSplineAnimation;
  90651. private static _GetBasePositionRotationOrScale;
  90652. /**
  90653. * Adds a key frame value
  90654. * @param keyFrame
  90655. * @param animation
  90656. * @param outputs
  90657. * @param animationChannelTargetPath
  90658. * @param basePositionRotationOrScale
  90659. * @param convertToRightHandedSystem
  90660. * @param useQuaternion
  90661. */
  90662. private static _AddKeyframeValue;
  90663. /**
  90664. * Determine the interpolation based on the key frames
  90665. * @param keyFrames
  90666. * @param animationChannelTargetPath
  90667. * @param useQuaternion
  90668. */
  90669. private static _DeduceInterpolation;
  90670. /**
  90671. * Adds an input tangent or output tangent to the output data
  90672. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90673. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90674. * @param outputs The animation data by keyframe
  90675. * @param animationChannelTargetPath The target animation channel
  90676. * @param interpolation The interpolation type
  90677. * @param keyFrame The key frame with the animation data
  90678. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90679. * @param useQuaternion Specifies if quaternions are used
  90680. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90681. */
  90682. private static AddSplineTangent;
  90683. /**
  90684. * Get the minimum and maximum key frames' frame values
  90685. * @param keyFrames animation key frames
  90686. * @returns the minimum and maximum key frame value
  90687. */
  90688. private static calculateMinMaxKeyFrames;
  90689. }
  90690. }
  90691. declare module BABYLON.GLTF2.Exporter {
  90692. /** @hidden */
  90693. export var textureTransformPixelShader: {
  90694. name: string;
  90695. shader: string;
  90696. };
  90697. }
  90698. declare module BABYLON.GLTF2.Exporter.Extensions {
  90699. /**
  90700. * @hidden
  90701. */
  90702. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90703. private _recordedTextures;
  90704. /** Name of this extension */
  90705. readonly name: string;
  90706. /** Defines whether this extension is enabled */
  90707. enabled: boolean;
  90708. /** Defines whether this extension is required */
  90709. required: boolean;
  90710. /** Reference to the glTF exporter */
  90711. private _wasUsed;
  90712. constructor(exporter: _Exporter);
  90713. dispose(): void;
  90714. /** @hidden */
  90715. get wasUsed(): boolean;
  90716. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90717. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90718. /**
  90719. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90720. * @param babylonTexture
  90721. * @param offset
  90722. * @param rotation
  90723. * @param scale
  90724. * @param scene
  90725. */
  90726. private _textureTransformTextureAsync;
  90727. }
  90728. }
  90729. declare module BABYLON.GLTF2.Exporter.Extensions {
  90730. /**
  90731. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90732. */
  90733. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90734. /** The name of this extension. */
  90735. readonly name: string;
  90736. /** Defines whether this extension is enabled. */
  90737. enabled: boolean;
  90738. /** Defines whether this extension is required */
  90739. required: boolean;
  90740. /** Reference to the glTF exporter */
  90741. private _exporter;
  90742. private _lights;
  90743. /** @hidden */
  90744. constructor(exporter: _Exporter);
  90745. /** @hidden */
  90746. dispose(): void;
  90747. /** @hidden */
  90748. get wasUsed(): boolean;
  90749. /** @hidden */
  90750. onExporting(): void;
  90751. /**
  90752. * Define this method to modify the default behavior when exporting a node
  90753. * @param context The context when exporting the node
  90754. * @param node glTF node
  90755. * @param babylonNode BabylonJS node
  90756. * @param nodeMap Node mapping of unique id to glTF node index
  90757. * @returns nullable INode promise
  90758. */
  90759. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90760. [key: number]: number;
  90761. }): Promise<Nullable<INode>>;
  90762. }
  90763. }
  90764. declare module BABYLON.GLTF2.Exporter.Extensions {
  90765. /**
  90766. * @hidden
  90767. */
  90768. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90769. /** Name of this extension */
  90770. readonly name: string;
  90771. /** Defines whether this extension is enabled */
  90772. enabled: boolean;
  90773. /** Defines whether this extension is required */
  90774. required: boolean;
  90775. /** Reference to the glTF exporter */
  90776. private _textureInfos;
  90777. private _exportedTextures;
  90778. private _wasUsed;
  90779. constructor(exporter: _Exporter);
  90780. dispose(): void;
  90781. /** @hidden */
  90782. get wasUsed(): boolean;
  90783. private _getTextureIndex;
  90784. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90785. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90786. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90787. }
  90788. }
  90789. declare module BABYLON.GLTF2.Exporter.Extensions {
  90790. /**
  90791. * @hidden
  90792. */
  90793. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90794. /** Name of this extension */
  90795. readonly name: string;
  90796. /** Defines whether this extension is enabled */
  90797. enabled: boolean;
  90798. /** Defines whether this extension is required */
  90799. required: boolean;
  90800. private _wasUsed;
  90801. constructor(exporter: _Exporter);
  90802. /** @hidden */
  90803. get wasUsed(): boolean;
  90804. dispose(): void;
  90805. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90806. }
  90807. }
  90808. declare module BABYLON {
  90809. /**
  90810. * Class for generating STL data from a Babylon scene.
  90811. */
  90812. export class STLExport {
  90813. /**
  90814. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90815. * @param meshes list defines the mesh to serialize
  90816. * @param download triggers the automatic download of the file.
  90817. * @param fileName changes the downloads fileName.
  90818. * @param binary changes the STL to a binary type.
  90819. * @param isLittleEndian toggle for binary type exporter.
  90820. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90821. * @returns the STL as UTF8 string
  90822. */
  90823. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90824. }
  90825. }
  90826. declare module "babylonjs-gltf2interface" {
  90827. export = BABYLON.GLTF2;
  90828. }
  90829. /**
  90830. * Module for glTF 2.0 Interface
  90831. */
  90832. declare module BABYLON.GLTF2 {
  90833. /**
  90834. * The datatype of the components in the attribute
  90835. */
  90836. const enum AccessorComponentType {
  90837. /**
  90838. * Byte
  90839. */
  90840. BYTE = 5120,
  90841. /**
  90842. * Unsigned Byte
  90843. */
  90844. UNSIGNED_BYTE = 5121,
  90845. /**
  90846. * Short
  90847. */
  90848. SHORT = 5122,
  90849. /**
  90850. * Unsigned Short
  90851. */
  90852. UNSIGNED_SHORT = 5123,
  90853. /**
  90854. * Unsigned Int
  90855. */
  90856. UNSIGNED_INT = 5125,
  90857. /**
  90858. * Float
  90859. */
  90860. FLOAT = 5126,
  90861. }
  90862. /**
  90863. * Specifies if the attirbute is a scalar, vector, or matrix
  90864. */
  90865. const enum AccessorType {
  90866. /**
  90867. * Scalar
  90868. */
  90869. SCALAR = "SCALAR",
  90870. /**
  90871. * Vector2
  90872. */
  90873. VEC2 = "VEC2",
  90874. /**
  90875. * Vector3
  90876. */
  90877. VEC3 = "VEC3",
  90878. /**
  90879. * Vector4
  90880. */
  90881. VEC4 = "VEC4",
  90882. /**
  90883. * Matrix2x2
  90884. */
  90885. MAT2 = "MAT2",
  90886. /**
  90887. * Matrix3x3
  90888. */
  90889. MAT3 = "MAT3",
  90890. /**
  90891. * Matrix4x4
  90892. */
  90893. MAT4 = "MAT4",
  90894. }
  90895. /**
  90896. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90897. */
  90898. const enum AnimationChannelTargetPath {
  90899. /**
  90900. * Translation
  90901. */
  90902. TRANSLATION = "translation",
  90903. /**
  90904. * Rotation
  90905. */
  90906. ROTATION = "rotation",
  90907. /**
  90908. * Scale
  90909. */
  90910. SCALE = "scale",
  90911. /**
  90912. * Weights
  90913. */
  90914. WEIGHTS = "weights",
  90915. }
  90916. /**
  90917. * Interpolation algorithm
  90918. */
  90919. const enum AnimationSamplerInterpolation {
  90920. /**
  90921. * The animated values are linearly interpolated between keyframes
  90922. */
  90923. LINEAR = "LINEAR",
  90924. /**
  90925. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90926. */
  90927. STEP = "STEP",
  90928. /**
  90929. * The animation's interpolation is computed using a cubic spline with specified tangents
  90930. */
  90931. CUBICSPLINE = "CUBICSPLINE",
  90932. }
  90933. /**
  90934. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90935. */
  90936. const enum CameraType {
  90937. /**
  90938. * A perspective camera containing properties to create a perspective projection matrix
  90939. */
  90940. PERSPECTIVE = "perspective",
  90941. /**
  90942. * An orthographic camera containing properties to create an orthographic projection matrix
  90943. */
  90944. ORTHOGRAPHIC = "orthographic",
  90945. }
  90946. /**
  90947. * The mime-type of the image
  90948. */
  90949. const enum ImageMimeType {
  90950. /**
  90951. * JPEG Mime-type
  90952. */
  90953. JPEG = "image/jpeg",
  90954. /**
  90955. * PNG Mime-type
  90956. */
  90957. PNG = "image/png",
  90958. }
  90959. /**
  90960. * The alpha rendering mode of the material
  90961. */
  90962. const enum MaterialAlphaMode {
  90963. /**
  90964. * The alpha value is ignored and the rendered output is fully opaque
  90965. */
  90966. OPAQUE = "OPAQUE",
  90967. /**
  90968. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90969. */
  90970. MASK = "MASK",
  90971. /**
  90972. * 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)
  90973. */
  90974. BLEND = "BLEND",
  90975. }
  90976. /**
  90977. * The type of the primitives to render
  90978. */
  90979. const enum MeshPrimitiveMode {
  90980. /**
  90981. * Points
  90982. */
  90983. POINTS = 0,
  90984. /**
  90985. * Lines
  90986. */
  90987. LINES = 1,
  90988. /**
  90989. * Line Loop
  90990. */
  90991. LINE_LOOP = 2,
  90992. /**
  90993. * Line Strip
  90994. */
  90995. LINE_STRIP = 3,
  90996. /**
  90997. * Triangles
  90998. */
  90999. TRIANGLES = 4,
  91000. /**
  91001. * Triangle Strip
  91002. */
  91003. TRIANGLE_STRIP = 5,
  91004. /**
  91005. * Triangle Fan
  91006. */
  91007. TRIANGLE_FAN = 6,
  91008. }
  91009. /**
  91010. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91011. */
  91012. const enum TextureMagFilter {
  91013. /**
  91014. * Nearest
  91015. */
  91016. NEAREST = 9728,
  91017. /**
  91018. * Linear
  91019. */
  91020. LINEAR = 9729,
  91021. }
  91022. /**
  91023. * Minification filter. All valid values correspond to WebGL enums
  91024. */
  91025. const enum TextureMinFilter {
  91026. /**
  91027. * Nearest
  91028. */
  91029. NEAREST = 9728,
  91030. /**
  91031. * Linear
  91032. */
  91033. LINEAR = 9729,
  91034. /**
  91035. * Nearest Mip-Map Nearest
  91036. */
  91037. NEAREST_MIPMAP_NEAREST = 9984,
  91038. /**
  91039. * Linear Mipmap Nearest
  91040. */
  91041. LINEAR_MIPMAP_NEAREST = 9985,
  91042. /**
  91043. * Nearest Mipmap Linear
  91044. */
  91045. NEAREST_MIPMAP_LINEAR = 9986,
  91046. /**
  91047. * Linear Mipmap Linear
  91048. */
  91049. LINEAR_MIPMAP_LINEAR = 9987,
  91050. }
  91051. /**
  91052. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91053. */
  91054. const enum TextureWrapMode {
  91055. /**
  91056. * Clamp to Edge
  91057. */
  91058. CLAMP_TO_EDGE = 33071,
  91059. /**
  91060. * Mirrored Repeat
  91061. */
  91062. MIRRORED_REPEAT = 33648,
  91063. /**
  91064. * Repeat
  91065. */
  91066. REPEAT = 10497,
  91067. }
  91068. /**
  91069. * glTF Property
  91070. */
  91071. interface IProperty {
  91072. /**
  91073. * Dictionary object with extension-specific objects
  91074. */
  91075. extensions?: {
  91076. [key: string]: any;
  91077. };
  91078. /**
  91079. * Application-Specific data
  91080. */
  91081. extras?: any;
  91082. }
  91083. /**
  91084. * glTF Child of Root Property
  91085. */
  91086. interface IChildRootProperty extends IProperty {
  91087. /**
  91088. * The user-defined name of this object
  91089. */
  91090. name?: string;
  91091. }
  91092. /**
  91093. * Indices of those attributes that deviate from their initialization value
  91094. */
  91095. interface IAccessorSparseIndices extends IProperty {
  91096. /**
  91097. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91098. */
  91099. bufferView: number;
  91100. /**
  91101. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91102. */
  91103. byteOffset?: number;
  91104. /**
  91105. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91106. */
  91107. componentType: AccessorComponentType;
  91108. }
  91109. /**
  91110. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91111. */
  91112. interface IAccessorSparseValues extends IProperty {
  91113. /**
  91114. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91115. */
  91116. bufferView: number;
  91117. /**
  91118. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91119. */
  91120. byteOffset?: number;
  91121. }
  91122. /**
  91123. * Sparse storage of attributes that deviate from their initialization value
  91124. */
  91125. interface IAccessorSparse extends IProperty {
  91126. /**
  91127. * The number of attributes encoded in this sparse accessor
  91128. */
  91129. count: number;
  91130. /**
  91131. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91132. */
  91133. indices: IAccessorSparseIndices;
  91134. /**
  91135. * 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
  91136. */
  91137. values: IAccessorSparseValues;
  91138. }
  91139. /**
  91140. * 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
  91141. */
  91142. interface IAccessor extends IChildRootProperty {
  91143. /**
  91144. * The index of the bufferview
  91145. */
  91146. bufferView?: number;
  91147. /**
  91148. * The offset relative to the start of the bufferView in bytes
  91149. */
  91150. byteOffset?: number;
  91151. /**
  91152. * The datatype of components in the attribute
  91153. */
  91154. componentType: AccessorComponentType;
  91155. /**
  91156. * Specifies whether integer data values should be normalized
  91157. */
  91158. normalized?: boolean;
  91159. /**
  91160. * The number of attributes referenced by this accessor
  91161. */
  91162. count: number;
  91163. /**
  91164. * Specifies if the attribute is a scalar, vector, or matrix
  91165. */
  91166. type: AccessorType;
  91167. /**
  91168. * Maximum value of each component in this attribute
  91169. */
  91170. max?: number[];
  91171. /**
  91172. * Minimum value of each component in this attribute
  91173. */
  91174. min?: number[];
  91175. /**
  91176. * Sparse storage of attributes that deviate from their initialization value
  91177. */
  91178. sparse?: IAccessorSparse;
  91179. }
  91180. /**
  91181. * Targets an animation's sampler at a node's property
  91182. */
  91183. interface IAnimationChannel extends IProperty {
  91184. /**
  91185. * The index of a sampler in this animation used to compute the value for the target
  91186. */
  91187. sampler: number;
  91188. /**
  91189. * The index of the node and TRS property to target
  91190. */
  91191. target: IAnimationChannelTarget;
  91192. }
  91193. /**
  91194. * The index of the node and TRS property that an animation channel targets
  91195. */
  91196. interface IAnimationChannelTarget extends IProperty {
  91197. /**
  91198. * The index of the node to target
  91199. */
  91200. node: number;
  91201. /**
  91202. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91203. */
  91204. path: AnimationChannelTargetPath;
  91205. }
  91206. /**
  91207. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91208. */
  91209. interface IAnimationSampler extends IProperty {
  91210. /**
  91211. * The index of an accessor containing keyframe input values, e.g., time
  91212. */
  91213. input: number;
  91214. /**
  91215. * Interpolation algorithm
  91216. */
  91217. interpolation?: AnimationSamplerInterpolation;
  91218. /**
  91219. * The index of an accessor, containing keyframe output values
  91220. */
  91221. output: number;
  91222. }
  91223. /**
  91224. * A keyframe animation
  91225. */
  91226. interface IAnimation extends IChildRootProperty {
  91227. /**
  91228. * An array of channels, each of which targets an animation's sampler at a node's property
  91229. */
  91230. channels: IAnimationChannel[];
  91231. /**
  91232. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91233. */
  91234. samplers: IAnimationSampler[];
  91235. }
  91236. /**
  91237. * Metadata about the glTF asset
  91238. */
  91239. interface IAsset extends IChildRootProperty {
  91240. /**
  91241. * A copyright message suitable for display to credit the content creator
  91242. */
  91243. copyright?: string;
  91244. /**
  91245. * Tool that generated this glTF model. Useful for debugging
  91246. */
  91247. generator?: string;
  91248. /**
  91249. * The glTF version that this asset targets
  91250. */
  91251. version: string;
  91252. /**
  91253. * The minimum glTF version that this asset targets
  91254. */
  91255. minVersion?: string;
  91256. }
  91257. /**
  91258. * A buffer points to binary geometry, animation, or skins
  91259. */
  91260. interface IBuffer extends IChildRootProperty {
  91261. /**
  91262. * 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
  91263. */
  91264. uri?: string;
  91265. /**
  91266. * The length of the buffer in bytes
  91267. */
  91268. byteLength: number;
  91269. }
  91270. /**
  91271. * A view into a buffer generally representing a subset of the buffer
  91272. */
  91273. interface IBufferView extends IChildRootProperty {
  91274. /**
  91275. * The index of the buffer
  91276. */
  91277. buffer: number;
  91278. /**
  91279. * The offset into the buffer in bytes
  91280. */
  91281. byteOffset?: number;
  91282. /**
  91283. * The lenth of the bufferView in bytes
  91284. */
  91285. byteLength: number;
  91286. /**
  91287. * The stride, in bytes
  91288. */
  91289. byteStride?: number;
  91290. }
  91291. /**
  91292. * An orthographic camera containing properties to create an orthographic projection matrix
  91293. */
  91294. interface ICameraOrthographic extends IProperty {
  91295. /**
  91296. * The floating-point horizontal magnification of the view. Must not be zero
  91297. */
  91298. xmag: number;
  91299. /**
  91300. * The floating-point vertical magnification of the view. Must not be zero
  91301. */
  91302. ymag: number;
  91303. /**
  91304. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91305. */
  91306. zfar: number;
  91307. /**
  91308. * The floating-point distance to the near clipping plane
  91309. */
  91310. znear: number;
  91311. }
  91312. /**
  91313. * A perspective camera containing properties to create a perspective projection matrix
  91314. */
  91315. interface ICameraPerspective extends IProperty {
  91316. /**
  91317. * The floating-point aspect ratio of the field of view
  91318. */
  91319. aspectRatio?: number;
  91320. /**
  91321. * The floating-point vertical field of view in radians
  91322. */
  91323. yfov: number;
  91324. /**
  91325. * The floating-point distance to the far clipping plane
  91326. */
  91327. zfar?: number;
  91328. /**
  91329. * The floating-point distance to the near clipping plane
  91330. */
  91331. znear: number;
  91332. }
  91333. /**
  91334. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91335. */
  91336. interface ICamera extends IChildRootProperty {
  91337. /**
  91338. * An orthographic camera containing properties to create an orthographic projection matrix
  91339. */
  91340. orthographic?: ICameraOrthographic;
  91341. /**
  91342. * A perspective camera containing properties to create a perspective projection matrix
  91343. */
  91344. perspective?: ICameraPerspective;
  91345. /**
  91346. * Specifies if the camera uses a perspective or orthographic projection
  91347. */
  91348. type: CameraType;
  91349. }
  91350. /**
  91351. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91352. */
  91353. interface IImage extends IChildRootProperty {
  91354. /**
  91355. * 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
  91356. */
  91357. uri?: string;
  91358. /**
  91359. * The image's MIME type
  91360. */
  91361. mimeType?: ImageMimeType;
  91362. /**
  91363. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91364. */
  91365. bufferView?: number;
  91366. }
  91367. /**
  91368. * Material Normal Texture Info
  91369. */
  91370. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91371. /**
  91372. * The scalar multiplier applied to each normal vector of the normal texture
  91373. */
  91374. scale?: number;
  91375. }
  91376. /**
  91377. * Material Occlusion Texture Info
  91378. */
  91379. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91380. /**
  91381. * A scalar multiplier controlling the amount of occlusion applied
  91382. */
  91383. strength?: number;
  91384. }
  91385. /**
  91386. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91387. */
  91388. interface IMaterialPbrMetallicRoughness {
  91389. /**
  91390. * The material's base color factor
  91391. */
  91392. baseColorFactor?: number[];
  91393. /**
  91394. * The base color texture
  91395. */
  91396. baseColorTexture?: ITextureInfo;
  91397. /**
  91398. * The metalness of the material
  91399. */
  91400. metallicFactor?: number;
  91401. /**
  91402. * The roughness of the material
  91403. */
  91404. roughnessFactor?: number;
  91405. /**
  91406. * The metallic-roughness texture
  91407. */
  91408. metallicRoughnessTexture?: ITextureInfo;
  91409. }
  91410. /**
  91411. * The material appearance of a primitive
  91412. */
  91413. interface IMaterial extends IChildRootProperty {
  91414. /**
  91415. * 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
  91416. */
  91417. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91418. /**
  91419. * The normal map texture
  91420. */
  91421. normalTexture?: IMaterialNormalTextureInfo;
  91422. /**
  91423. * The occlusion map texture
  91424. */
  91425. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91426. /**
  91427. * The emissive map texture
  91428. */
  91429. emissiveTexture?: ITextureInfo;
  91430. /**
  91431. * 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
  91432. */
  91433. emissiveFactor?: number[];
  91434. /**
  91435. * The alpha rendering mode of the material
  91436. */
  91437. alphaMode?: MaterialAlphaMode;
  91438. /**
  91439. * The alpha cutoff value of the material
  91440. */
  91441. alphaCutoff?: number;
  91442. /**
  91443. * Specifies whether the material is double sided
  91444. */
  91445. doubleSided?: boolean;
  91446. }
  91447. /**
  91448. * Geometry to be rendered with the given material
  91449. */
  91450. interface IMeshPrimitive extends IProperty {
  91451. /**
  91452. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91453. */
  91454. attributes: {
  91455. [name: string]: number;
  91456. };
  91457. /**
  91458. * The index of the accessor that contains the indices
  91459. */
  91460. indices?: number;
  91461. /**
  91462. * The index of the material to apply to this primitive when rendering
  91463. */
  91464. material?: number;
  91465. /**
  91466. * The type of primitives to render. All valid values correspond to WebGL enums
  91467. */
  91468. mode?: MeshPrimitiveMode;
  91469. /**
  91470. * 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
  91471. */
  91472. targets?: {
  91473. [name: string]: number;
  91474. }[];
  91475. }
  91476. /**
  91477. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91478. */
  91479. interface IMesh extends IChildRootProperty {
  91480. /**
  91481. * An array of primitives, each defining geometry to be rendered with a material
  91482. */
  91483. primitives: IMeshPrimitive[];
  91484. /**
  91485. * Array of weights to be applied to the Morph Targets
  91486. */
  91487. weights?: number[];
  91488. }
  91489. /**
  91490. * A node in the node hierarchy
  91491. */
  91492. interface INode extends IChildRootProperty {
  91493. /**
  91494. * The index of the camera referenced by this node
  91495. */
  91496. camera?: number;
  91497. /**
  91498. * The indices of this node's children
  91499. */
  91500. children?: number[];
  91501. /**
  91502. * The index of the skin referenced by this node
  91503. */
  91504. skin?: number;
  91505. /**
  91506. * A floating-point 4x4 transformation matrix stored in column-major order
  91507. */
  91508. matrix?: number[];
  91509. /**
  91510. * The index of the mesh in this node
  91511. */
  91512. mesh?: number;
  91513. /**
  91514. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91515. */
  91516. rotation?: number[];
  91517. /**
  91518. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91519. */
  91520. scale?: number[];
  91521. /**
  91522. * The node's translation along the x, y, and z axes
  91523. */
  91524. translation?: number[];
  91525. /**
  91526. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91527. */
  91528. weights?: number[];
  91529. }
  91530. /**
  91531. * Texture sampler properties for filtering and wrapping modes
  91532. */
  91533. interface ISampler extends IChildRootProperty {
  91534. /**
  91535. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91536. */
  91537. magFilter?: TextureMagFilter;
  91538. /**
  91539. * Minification filter. All valid values correspond to WebGL enums
  91540. */
  91541. minFilter?: TextureMinFilter;
  91542. /**
  91543. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91544. */
  91545. wrapS?: TextureWrapMode;
  91546. /**
  91547. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91548. */
  91549. wrapT?: TextureWrapMode;
  91550. }
  91551. /**
  91552. * The root nodes of a scene
  91553. */
  91554. interface IScene extends IChildRootProperty {
  91555. /**
  91556. * The indices of each root node
  91557. */
  91558. nodes: number[];
  91559. }
  91560. /**
  91561. * Joints and matrices defining a skin
  91562. */
  91563. interface ISkin extends IChildRootProperty {
  91564. /**
  91565. * 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
  91566. */
  91567. inverseBindMatrices?: number;
  91568. /**
  91569. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91570. */
  91571. skeleton?: number;
  91572. /**
  91573. * 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)
  91574. */
  91575. joints: number[];
  91576. }
  91577. /**
  91578. * A texture and its sampler
  91579. */
  91580. interface ITexture extends IChildRootProperty {
  91581. /**
  91582. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91583. */
  91584. sampler?: number;
  91585. /**
  91586. * The index of the image used by this texture
  91587. */
  91588. source: number;
  91589. }
  91590. /**
  91591. * Reference to a texture
  91592. */
  91593. interface ITextureInfo extends IProperty {
  91594. /**
  91595. * The index of the texture
  91596. */
  91597. index: number;
  91598. /**
  91599. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91600. */
  91601. texCoord?: number;
  91602. }
  91603. /**
  91604. * The root object for a glTF asset
  91605. */
  91606. interface IGLTF extends IProperty {
  91607. /**
  91608. * An array of accessors. An accessor is a typed view into a bufferView
  91609. */
  91610. accessors?: IAccessor[];
  91611. /**
  91612. * An array of keyframe animations
  91613. */
  91614. animations?: IAnimation[];
  91615. /**
  91616. * Metadata about the glTF asset
  91617. */
  91618. asset: IAsset;
  91619. /**
  91620. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91621. */
  91622. buffers?: IBuffer[];
  91623. /**
  91624. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91625. */
  91626. bufferViews?: IBufferView[];
  91627. /**
  91628. * An array of cameras
  91629. */
  91630. cameras?: ICamera[];
  91631. /**
  91632. * Names of glTF extensions used somewhere in this asset
  91633. */
  91634. extensionsUsed?: string[];
  91635. /**
  91636. * Names of glTF extensions required to properly load this asset
  91637. */
  91638. extensionsRequired?: string[];
  91639. /**
  91640. * An array of images. An image defines data used to create a texture
  91641. */
  91642. images?: IImage[];
  91643. /**
  91644. * An array of materials. A material defines the appearance of a primitive
  91645. */
  91646. materials?: IMaterial[];
  91647. /**
  91648. * An array of meshes. A mesh is a set of primitives to be rendered
  91649. */
  91650. meshes?: IMesh[];
  91651. /**
  91652. * An array of nodes
  91653. */
  91654. nodes?: INode[];
  91655. /**
  91656. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91657. */
  91658. samplers?: ISampler[];
  91659. /**
  91660. * The index of the default scene
  91661. */
  91662. scene?: number;
  91663. /**
  91664. * An array of scenes
  91665. */
  91666. scenes?: IScene[];
  91667. /**
  91668. * An array of skins. A skin is defined by joints and matrices
  91669. */
  91670. skins?: ISkin[];
  91671. /**
  91672. * An array of textures
  91673. */
  91674. textures?: ITexture[];
  91675. }
  91676. /**
  91677. * The glTF validation results
  91678. * @ignore
  91679. */
  91680. interface IGLTFValidationResults {
  91681. info: {
  91682. generator: string;
  91683. hasAnimations: boolean;
  91684. hasDefaultScene: boolean;
  91685. hasMaterials: boolean;
  91686. hasMorphTargets: boolean;
  91687. hasSkins: boolean;
  91688. hasTextures: boolean;
  91689. maxAttributesUsed: number;
  91690. primitivesCount: number
  91691. };
  91692. issues: {
  91693. messages: Array<string>;
  91694. numErrors: number;
  91695. numHints: number;
  91696. numInfos: number;
  91697. numWarnings: number;
  91698. truncated: boolean
  91699. };
  91700. mimeType: string;
  91701. uri: string;
  91702. validatedAt: string;
  91703. validatorVersion: string;
  91704. }
  91705. /**
  91706. * The glTF validation options
  91707. */
  91708. interface IGLTFValidationOptions {
  91709. /** Uri to use */
  91710. uri?: string;
  91711. /** Function used to load external resources */
  91712. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91713. /** Boolean indicating that we need to validate accessor data */
  91714. validateAccessorData?: boolean;
  91715. /** max number of issues allowed */
  91716. maxIssues?: number;
  91717. /** Ignored issues */
  91718. ignoredIssues?: Array<string>;
  91719. /** Value to override severy settings */
  91720. severityOverrides?: Object;
  91721. }
  91722. /**
  91723. * The glTF validator object
  91724. * @ignore
  91725. */
  91726. interface IGLTFValidator {
  91727. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91728. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91729. }
  91730. /**
  91731. * Interfaces from the EXT_lights_image_based extension
  91732. */
  91733. /** @hidden */
  91734. interface IEXTLightsImageBased_LightReferenceImageBased {
  91735. light: number;
  91736. }
  91737. /** @hidden */
  91738. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91739. intensity: number;
  91740. rotation: number[];
  91741. specularImageSize: number;
  91742. specularImages: number[][];
  91743. irradianceCoefficients: number[][];
  91744. }
  91745. /** @hidden */
  91746. interface IEXTLightsImageBased {
  91747. lights: IEXTLightsImageBased_LightImageBased[];
  91748. }
  91749. /**
  91750. * Interfaces from the EXT_mesh_gpu_instancing extension
  91751. * !!! Experimental Extension Subject to Changes !!!
  91752. */
  91753. /** @hidden */
  91754. interface IEXTMeshGpuInstancing {
  91755. mesh?: number;
  91756. attributes: { [name: string]: number };
  91757. }
  91758. /**
  91759. * Interfaces from the KHR_draco_mesh_compression extension
  91760. */
  91761. /** @hidden */
  91762. interface IKHRDracoMeshCompression {
  91763. bufferView: number;
  91764. attributes: { [name: string]: number };
  91765. }
  91766. /**
  91767. * Interfaces from the KHR_lights_punctual extension
  91768. */
  91769. /** @hidden */
  91770. const enum IKHRLightsPunctual_LightType {
  91771. DIRECTIONAL = "directional",
  91772. POINT = "point",
  91773. SPOT = "spot"
  91774. }
  91775. /** @hidden */
  91776. interface IKHRLightsPunctual_LightReference {
  91777. light: number;
  91778. }
  91779. /** @hidden */
  91780. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91781. type: IKHRLightsPunctual_LightType;
  91782. color?: number[];
  91783. intensity?: number;
  91784. range?: number;
  91785. spot?: {
  91786. innerConeAngle?: number;
  91787. outerConeAngle?: number;
  91788. };
  91789. }
  91790. /** @hidden */
  91791. interface IKHRLightsPunctual {
  91792. lights: IKHRLightsPunctual_Light[];
  91793. }
  91794. /**
  91795. * Interfaces from the KHR_materials_clearcoat extension
  91796. * !!! Experimental Extension Subject to Changes !!!
  91797. */
  91798. /** @hidden */
  91799. interface IKHRMaterialsClearcoat {
  91800. clearcoatFactor: number;
  91801. clearcoatTexture: ITextureInfo;
  91802. clearcoatRoughnessFactor: number;
  91803. clearcoatRoughnessTexture: ITextureInfo;
  91804. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91805. }
  91806. /**
  91807. * Interfaces from the KHR_materials_ior extension
  91808. * !!! Experimental Extension Subject to Changes !!!
  91809. */
  91810. /** @hidden */
  91811. interface IKHRMaterialsIor {
  91812. ior: number;
  91813. }
  91814. /**
  91815. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91816. */
  91817. /** @hidden */
  91818. interface IKHRMaterialsPbrSpecularGlossiness {
  91819. diffuseFactor: number[];
  91820. diffuseTexture: ITextureInfo;
  91821. specularFactor: number[];
  91822. glossinessFactor: number;
  91823. specularGlossinessTexture: ITextureInfo;
  91824. }
  91825. /**
  91826. * Interfaces from the KHR_materials_sheen extension
  91827. * !!! Experimental Extension Subject to Changes !!!
  91828. */
  91829. /** @hidden */
  91830. interface IKHRMaterialsSheen {
  91831. sheenColorFactor?: number[];
  91832. sheenColorTexture?: ITextureInfo;
  91833. sheenRoughnessFactor?: number;
  91834. sheenRoughnessTexture?: ITextureInfo;
  91835. }
  91836. /**
  91837. * Interfaces from the KHR_materials_specular extension
  91838. * !!! Experimental Extension Subject to Changes !!!
  91839. */
  91840. /** @hidden */
  91841. interface IKHRMaterialsSpecular {
  91842. specularFactor: number;
  91843. specularColorFactor: number[];
  91844. specularTexture: ITextureInfo;
  91845. }
  91846. /**
  91847. * Interfaces from the KHR_materials_transmission extension
  91848. * !!! Experimental Extension Subject to Changes !!!
  91849. */
  91850. /** @hidden */
  91851. interface IKHRMaterialsTransmission {
  91852. transmissionFactor?: number;
  91853. transmissionTexture?: ITextureInfo;
  91854. }
  91855. /**
  91856. * Interfaces from the KHR_materials_translucency extension
  91857. * !!! Experimental Extension Subject to Changes !!!
  91858. */
  91859. /** @hidden */
  91860. interface IKHRMaterialsTranslucency {
  91861. translucencyFactor?: number;
  91862. translucencyTexture?: ITextureInfo;
  91863. }
  91864. /**
  91865. * Interfaces from the KHR_materials_variants extension
  91866. * !!! Experimental Extension Subject to Changes !!!
  91867. */
  91868. /** @hidden */
  91869. interface IKHRMaterialVariants_Mapping extends IProperty {
  91870. mappings: Array<{
  91871. variants: number[];
  91872. material: number;
  91873. }>;
  91874. }
  91875. /** @hidden */
  91876. interface IKHRMaterialVariants_Variant extends IProperty {
  91877. name: string;
  91878. }
  91879. /** @hidden */
  91880. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91881. variants: Array<IKHRMaterialVariants_Variant>;
  91882. }
  91883. /**
  91884. * Interfaces from the KHR_texture_basisu extension
  91885. * !!! Experimental Extension Subject to Changes !!!
  91886. */
  91887. /** @hidden */
  91888. interface IKHRTextureBasisU {
  91889. source: number;
  91890. }
  91891. /**
  91892. * Interfaces from the EXT_texture_webp extension
  91893. */
  91894. /** @hidden */
  91895. interface IEXTTextureWebP {
  91896. source: number;
  91897. }
  91898. /**
  91899. * Interfaces from the KHR_texture_transform extension
  91900. */
  91901. /** @hidden */
  91902. interface IKHRTextureTransform {
  91903. offset?: number[];
  91904. rotation?: number;
  91905. scale?: number[];
  91906. texCoord?: number;
  91907. }
  91908. /**
  91909. * Interfaces from the KHR_xmp_json_ld extension
  91910. * !!! Experimental Extension Subject to Changes !!!
  91911. */
  91912. /** @hidden */
  91913. interface IKHRXmpJsonLd_Gltf {
  91914. packets: Array<{
  91915. [key: string]: unknown;
  91916. }>;
  91917. }
  91918. /** @hidden */
  91919. interface IKHRXmpJsonLd_Node {
  91920. packet: number;
  91921. }
  91922. /**
  91923. * Interfaces from the MSFT_audio_emitter extension
  91924. */
  91925. /** @hidden */
  91926. interface IMSFTAudioEmitter_ClipReference {
  91927. clip: number;
  91928. weight?: number;
  91929. }
  91930. /** @hidden */
  91931. interface IMSFTAudioEmitter_EmittersReference {
  91932. emitters: number[];
  91933. }
  91934. /** @hidden */
  91935. const enum IMSFTAudioEmitter_DistanceModel {
  91936. linear = "linear",
  91937. inverse = "inverse",
  91938. exponential = "exponential",
  91939. }
  91940. /** @hidden */
  91941. interface IMSFTAudioEmitter_Emitter {
  91942. name?: string;
  91943. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91944. refDistance?: number;
  91945. maxDistance?: number;
  91946. rolloffFactor?: number;
  91947. innerAngle?: number;
  91948. outerAngle?: number;
  91949. loop?: boolean;
  91950. volume?: number;
  91951. clips: IMSFTAudioEmitter_ClipReference[];
  91952. }
  91953. /** @hidden */
  91954. const enum IMSFTAudioEmitter_AudioMimeType {
  91955. WAV = "audio/wav",
  91956. }
  91957. /** @hidden */
  91958. interface IMSFTAudioEmitter_Clip extends IProperty {
  91959. uri?: string;
  91960. bufferView?: number;
  91961. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91962. }
  91963. /** @hidden */
  91964. const enum IMSFTAudioEmitter_AnimationEventAction {
  91965. play = "play",
  91966. pause = "pause",
  91967. stop = "stop",
  91968. }
  91969. /** @hidden */
  91970. interface IMSFTAudioEmitter_AnimationEvent {
  91971. action: IMSFTAudioEmitter_AnimationEventAction;
  91972. emitter: number;
  91973. time: number;
  91974. startOffset?: number;
  91975. }
  91976. /**
  91977. * Interfaces from the MSFT_lod extension
  91978. */
  91979. /** @hidden */
  91980. interface IMSFTLOD {
  91981. ids: number[];
  91982. }
  91983. /**
  91984. * Interfaces from the EXT_meshopt_compression extension
  91985. */
  91986. /** @hidden */
  91987. interface IEXTMeshoptCompression {
  91988. buffer: number;
  91989. byteOffset?: number;
  91990. byteLength: number;
  91991. byteStride: number;
  91992. count: number;
  91993. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91994. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91995. }
  91996. }
  91997. declare module BABYLON {
  91998. /** @hidden */
  91999. export var cellPixelShader: {
  92000. name: string;
  92001. shader: string;
  92002. };
  92003. }
  92004. declare module BABYLON {
  92005. /** @hidden */
  92006. export var cellVertexShader: {
  92007. name: string;
  92008. shader: string;
  92009. };
  92010. }
  92011. declare module BABYLON {
  92012. export class CellMaterial extends BABYLON.PushMaterial {
  92013. private _diffuseTexture;
  92014. diffuseTexture: BABYLON.BaseTexture;
  92015. diffuseColor: BABYLON.Color3;
  92016. _computeHighLevel: boolean;
  92017. computeHighLevel: boolean;
  92018. private _disableLighting;
  92019. disableLighting: boolean;
  92020. private _maxSimultaneousLights;
  92021. maxSimultaneousLights: number;
  92022. constructor(name: string, scene: BABYLON.Scene);
  92023. needAlphaBlending(): boolean;
  92024. needAlphaTesting(): boolean;
  92025. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92026. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92027. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92028. getAnimatables(): BABYLON.IAnimatable[];
  92029. getActiveTextures(): BABYLON.BaseTexture[];
  92030. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92031. dispose(forceDisposeEffect?: boolean): void;
  92032. getClassName(): string;
  92033. clone(name: string): CellMaterial;
  92034. serialize(): any;
  92035. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92036. }
  92037. }
  92038. declare module BABYLON {
  92039. export class CustomShaderStructure {
  92040. FragmentStore: string;
  92041. VertexStore: string;
  92042. constructor();
  92043. }
  92044. export class ShaderSpecialParts {
  92045. constructor();
  92046. Fragment_Begin: string;
  92047. Fragment_Definitions: string;
  92048. Fragment_MainBegin: string;
  92049. Fragment_Custom_Diffuse: string;
  92050. Fragment_Before_Lights: string;
  92051. Fragment_Before_Fog: string;
  92052. Fragment_Custom_Alpha: string;
  92053. Fragment_Before_FragColor: string;
  92054. Vertex_Begin: string;
  92055. Vertex_Definitions: string;
  92056. Vertex_MainBegin: string;
  92057. Vertex_Before_PositionUpdated: string;
  92058. Vertex_Before_NormalUpdated: string;
  92059. Vertex_After_WorldPosComputed: string;
  92060. Vertex_MainEnd: string;
  92061. }
  92062. export class CustomMaterial extends BABYLON.StandardMaterial {
  92063. static ShaderIndexer: number;
  92064. CustomParts: ShaderSpecialParts;
  92065. _isCreatedShader: boolean;
  92066. _createdShaderName: string;
  92067. _customUniform: string[];
  92068. _newUniforms: string[];
  92069. _newUniformInstances: {
  92070. [name: string]: any;
  92071. };
  92072. _newSamplerInstances: {
  92073. [name: string]: BABYLON.Texture;
  92074. };
  92075. _customAttributes: string[];
  92076. FragmentShader: string;
  92077. VertexShader: string;
  92078. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92079. ReviewUniform(name: string, arr: string[]): string[];
  92080. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92081. constructor(name: string, scene: BABYLON.Scene);
  92082. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92083. AddAttribute(name: string): CustomMaterial;
  92084. Fragment_Begin(shaderPart: string): CustomMaterial;
  92085. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92086. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92087. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92088. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92089. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92090. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92091. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92092. Vertex_Begin(shaderPart: string): CustomMaterial;
  92093. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92094. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92095. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92096. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92097. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92098. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92099. }
  92100. }
  92101. declare module BABYLON {
  92102. export class ShaderAlebdoParts {
  92103. constructor();
  92104. Fragment_Begin: string;
  92105. Fragment_Definitions: string;
  92106. Fragment_MainBegin: string;
  92107. Fragment_Custom_Albedo: string;
  92108. Fragment_Before_Lights: string;
  92109. Fragment_Custom_MetallicRoughness: string;
  92110. Fragment_Custom_MicroSurface: string;
  92111. Fragment_Before_Fog: string;
  92112. Fragment_Custom_Alpha: string;
  92113. Fragment_Before_FragColor: string;
  92114. Vertex_Begin: string;
  92115. Vertex_Definitions: string;
  92116. Vertex_MainBegin: string;
  92117. Vertex_Before_PositionUpdated: string;
  92118. Vertex_Before_NormalUpdated: string;
  92119. Vertex_After_WorldPosComputed: string;
  92120. Vertex_MainEnd: string;
  92121. }
  92122. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92123. static ShaderIndexer: number;
  92124. CustomParts: ShaderAlebdoParts;
  92125. _isCreatedShader: boolean;
  92126. _createdShaderName: string;
  92127. _customUniform: string[];
  92128. _newUniforms: string[];
  92129. _newUniformInstances: {
  92130. [name: string]: any;
  92131. };
  92132. _newSamplerInstances: {
  92133. [name: string]: BABYLON.Texture;
  92134. };
  92135. _customAttributes: string[];
  92136. FragmentShader: string;
  92137. VertexShader: string;
  92138. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92139. ReviewUniform(name: string, arr: string[]): string[];
  92140. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92141. constructor(name: string, scene: BABYLON.Scene);
  92142. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92143. AddAttribute(name: string): PBRCustomMaterial;
  92144. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92145. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92146. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92147. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92148. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92149. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92150. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92151. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92152. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92153. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92154. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92155. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92156. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92157. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92158. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92159. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92160. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92161. }
  92162. }
  92163. declare module BABYLON {
  92164. /** @hidden */
  92165. export var firePixelShader: {
  92166. name: string;
  92167. shader: string;
  92168. };
  92169. }
  92170. declare module BABYLON {
  92171. /** @hidden */
  92172. export var fireVertexShader: {
  92173. name: string;
  92174. shader: string;
  92175. };
  92176. }
  92177. declare module BABYLON {
  92178. export class FireMaterial extends BABYLON.PushMaterial {
  92179. private _diffuseTexture;
  92180. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92181. private _distortionTexture;
  92182. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92183. private _opacityTexture;
  92184. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92185. diffuseColor: BABYLON.Color3;
  92186. speed: number;
  92187. private _scaledDiffuse;
  92188. private _lastTime;
  92189. constructor(name: string, scene: BABYLON.Scene);
  92190. needAlphaBlending(): boolean;
  92191. needAlphaTesting(): boolean;
  92192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92195. getAnimatables(): BABYLON.IAnimatable[];
  92196. getActiveTextures(): BABYLON.BaseTexture[];
  92197. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92198. getClassName(): string;
  92199. dispose(forceDisposeEffect?: boolean): void;
  92200. clone(name: string): FireMaterial;
  92201. serialize(): any;
  92202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92203. }
  92204. }
  92205. declare module BABYLON {
  92206. /** @hidden */
  92207. export var furPixelShader: {
  92208. name: string;
  92209. shader: string;
  92210. };
  92211. }
  92212. declare module BABYLON {
  92213. /** @hidden */
  92214. export var furVertexShader: {
  92215. name: string;
  92216. shader: string;
  92217. };
  92218. }
  92219. declare module BABYLON {
  92220. export class FurMaterial extends BABYLON.PushMaterial {
  92221. private _diffuseTexture;
  92222. diffuseTexture: BABYLON.BaseTexture;
  92223. private _heightTexture;
  92224. heightTexture: BABYLON.BaseTexture;
  92225. diffuseColor: BABYLON.Color3;
  92226. furLength: number;
  92227. furAngle: number;
  92228. furColor: BABYLON.Color3;
  92229. furOffset: number;
  92230. furSpacing: number;
  92231. furGravity: BABYLON.Vector3;
  92232. furSpeed: number;
  92233. furDensity: number;
  92234. furOcclusion: number;
  92235. furTexture: BABYLON.DynamicTexture;
  92236. private _disableLighting;
  92237. disableLighting: boolean;
  92238. private _maxSimultaneousLights;
  92239. maxSimultaneousLights: number;
  92240. highLevelFur: boolean;
  92241. _meshes: BABYLON.AbstractMesh[];
  92242. private _furTime;
  92243. constructor(name: string, scene: BABYLON.Scene);
  92244. get furTime(): number;
  92245. set furTime(furTime: number);
  92246. needAlphaBlending(): boolean;
  92247. needAlphaTesting(): boolean;
  92248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92249. updateFur(): void;
  92250. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92251. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92252. getAnimatables(): BABYLON.IAnimatable[];
  92253. getActiveTextures(): BABYLON.BaseTexture[];
  92254. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92255. dispose(forceDisposeEffect?: boolean): void;
  92256. clone(name: string): FurMaterial;
  92257. serialize(): any;
  92258. getClassName(): string;
  92259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92260. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92261. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92262. }
  92263. }
  92264. declare module BABYLON {
  92265. /** @hidden */
  92266. export var gradientPixelShader: {
  92267. name: string;
  92268. shader: string;
  92269. };
  92270. }
  92271. declare module BABYLON {
  92272. /** @hidden */
  92273. export var gradientVertexShader: {
  92274. name: string;
  92275. shader: string;
  92276. };
  92277. }
  92278. declare module BABYLON {
  92279. export class GradientMaterial extends BABYLON.PushMaterial {
  92280. private _maxSimultaneousLights;
  92281. maxSimultaneousLights: number;
  92282. topColor: BABYLON.Color3;
  92283. topColorAlpha: number;
  92284. bottomColor: BABYLON.Color3;
  92285. bottomColorAlpha: number;
  92286. offset: number;
  92287. scale: number;
  92288. smoothness: number;
  92289. private _disableLighting;
  92290. disableLighting: boolean;
  92291. constructor(name: string, scene: BABYLON.Scene);
  92292. needAlphaBlending(): boolean;
  92293. needAlphaTesting(): boolean;
  92294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92295. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92296. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92297. getAnimatables(): BABYLON.IAnimatable[];
  92298. dispose(forceDisposeEffect?: boolean): void;
  92299. clone(name: string): GradientMaterial;
  92300. serialize(): any;
  92301. getClassName(): string;
  92302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92303. }
  92304. }
  92305. declare module BABYLON {
  92306. /** @hidden */
  92307. export var gridPixelShader: {
  92308. name: string;
  92309. shader: string;
  92310. };
  92311. }
  92312. declare module BABYLON {
  92313. /** @hidden */
  92314. export var gridVertexShader: {
  92315. name: string;
  92316. shader: string;
  92317. };
  92318. }
  92319. declare module BABYLON {
  92320. /**
  92321. * The grid materials allows you to wrap any shape with a grid.
  92322. * Colors are customizable.
  92323. */
  92324. export class GridMaterial extends BABYLON.PushMaterial {
  92325. /**
  92326. * Main color of the grid (e.g. between lines)
  92327. */
  92328. mainColor: BABYLON.Color3;
  92329. /**
  92330. * Color of the grid lines.
  92331. */
  92332. lineColor: BABYLON.Color3;
  92333. /**
  92334. * The scale of the grid compared to unit.
  92335. */
  92336. gridRatio: number;
  92337. /**
  92338. * Allows setting an offset for the grid lines.
  92339. */
  92340. gridOffset: BABYLON.Vector3;
  92341. /**
  92342. * The frequency of thicker lines.
  92343. */
  92344. majorUnitFrequency: number;
  92345. /**
  92346. * The visibility of minor units in the grid.
  92347. */
  92348. minorUnitVisibility: number;
  92349. /**
  92350. * The grid opacity outside of the lines.
  92351. */
  92352. opacity: number;
  92353. /**
  92354. * Determine RBG output is premultiplied by alpha value.
  92355. */
  92356. preMultiplyAlpha: boolean;
  92357. private _opacityTexture;
  92358. opacityTexture: BABYLON.BaseTexture;
  92359. private _gridControl;
  92360. /**
  92361. * constructor
  92362. * @param name The name given to the material in order to identify it afterwards.
  92363. * @param scene The scene the material is used in.
  92364. */
  92365. constructor(name: string, scene: BABYLON.Scene);
  92366. /**
  92367. * Returns wehter or not the grid requires alpha blending.
  92368. */
  92369. needAlphaBlending(): boolean;
  92370. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92371. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92372. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92373. /**
  92374. * Dispose the material and its associated resources.
  92375. * @param forceDisposeEffect will also dispose the used effect when true
  92376. */
  92377. dispose(forceDisposeEffect?: boolean): void;
  92378. clone(name: string): GridMaterial;
  92379. serialize(): any;
  92380. getClassName(): string;
  92381. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92382. }
  92383. }
  92384. declare module BABYLON {
  92385. /** @hidden */
  92386. export var lavaPixelShader: {
  92387. name: string;
  92388. shader: string;
  92389. };
  92390. }
  92391. declare module BABYLON {
  92392. /** @hidden */
  92393. export var lavaVertexShader: {
  92394. name: string;
  92395. shader: string;
  92396. };
  92397. }
  92398. declare module BABYLON {
  92399. export class LavaMaterial extends BABYLON.PushMaterial {
  92400. private _diffuseTexture;
  92401. diffuseTexture: BABYLON.BaseTexture;
  92402. noiseTexture: BABYLON.BaseTexture;
  92403. fogColor: BABYLON.Color3;
  92404. speed: number;
  92405. movingSpeed: number;
  92406. lowFrequencySpeed: number;
  92407. fogDensity: number;
  92408. private _lastTime;
  92409. diffuseColor: BABYLON.Color3;
  92410. private _disableLighting;
  92411. disableLighting: boolean;
  92412. private _unlit;
  92413. unlit: boolean;
  92414. private _maxSimultaneousLights;
  92415. maxSimultaneousLights: number;
  92416. private _scaledDiffuse;
  92417. constructor(name: string, scene: BABYLON.Scene);
  92418. needAlphaBlending(): boolean;
  92419. needAlphaTesting(): boolean;
  92420. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92423. getAnimatables(): BABYLON.IAnimatable[];
  92424. getActiveTextures(): BABYLON.BaseTexture[];
  92425. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92426. dispose(forceDisposeEffect?: boolean): void;
  92427. clone(name: string): LavaMaterial;
  92428. serialize(): any;
  92429. getClassName(): string;
  92430. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92431. }
  92432. }
  92433. declare module BABYLON {
  92434. /** @hidden */
  92435. export var mixPixelShader: {
  92436. name: string;
  92437. shader: string;
  92438. };
  92439. }
  92440. declare module BABYLON {
  92441. /** @hidden */
  92442. export var mixVertexShader: {
  92443. name: string;
  92444. shader: string;
  92445. };
  92446. }
  92447. declare module BABYLON {
  92448. export class MixMaterial extends BABYLON.PushMaterial {
  92449. /**
  92450. * Mix textures
  92451. */
  92452. private _mixTexture1;
  92453. mixTexture1: BABYLON.BaseTexture;
  92454. private _mixTexture2;
  92455. mixTexture2: BABYLON.BaseTexture;
  92456. /**
  92457. * Diffuse textures
  92458. */
  92459. private _diffuseTexture1;
  92460. diffuseTexture1: BABYLON.Texture;
  92461. private _diffuseTexture2;
  92462. diffuseTexture2: BABYLON.Texture;
  92463. private _diffuseTexture3;
  92464. diffuseTexture3: BABYLON.Texture;
  92465. private _diffuseTexture4;
  92466. diffuseTexture4: BABYLON.Texture;
  92467. private _diffuseTexture5;
  92468. diffuseTexture5: BABYLON.Texture;
  92469. private _diffuseTexture6;
  92470. diffuseTexture6: BABYLON.Texture;
  92471. private _diffuseTexture7;
  92472. diffuseTexture7: BABYLON.Texture;
  92473. private _diffuseTexture8;
  92474. diffuseTexture8: BABYLON.Texture;
  92475. /**
  92476. * Uniforms
  92477. */
  92478. diffuseColor: BABYLON.Color3;
  92479. specularColor: BABYLON.Color3;
  92480. specularPower: number;
  92481. private _disableLighting;
  92482. disableLighting: boolean;
  92483. private _maxSimultaneousLights;
  92484. maxSimultaneousLights: number;
  92485. constructor(name: string, scene: BABYLON.Scene);
  92486. needAlphaBlending(): boolean;
  92487. needAlphaTesting(): boolean;
  92488. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92489. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92490. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92491. getAnimatables(): BABYLON.IAnimatable[];
  92492. getActiveTextures(): BABYLON.BaseTexture[];
  92493. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92494. dispose(forceDisposeEffect?: boolean): void;
  92495. clone(name: string): MixMaterial;
  92496. serialize(): any;
  92497. getClassName(): string;
  92498. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92499. }
  92500. }
  92501. declare module BABYLON {
  92502. /** @hidden */
  92503. export var normalPixelShader: {
  92504. name: string;
  92505. shader: string;
  92506. };
  92507. }
  92508. declare module BABYLON {
  92509. /** @hidden */
  92510. export var normalVertexShader: {
  92511. name: string;
  92512. shader: string;
  92513. };
  92514. }
  92515. declare module BABYLON {
  92516. export class NormalMaterial extends BABYLON.PushMaterial {
  92517. private _diffuseTexture;
  92518. diffuseTexture: BABYLON.BaseTexture;
  92519. diffuseColor: BABYLON.Color3;
  92520. private _disableLighting;
  92521. disableLighting: boolean;
  92522. private _maxSimultaneousLights;
  92523. maxSimultaneousLights: number;
  92524. constructor(name: string, scene: BABYLON.Scene);
  92525. needAlphaBlending(): boolean;
  92526. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92527. needAlphaTesting(): boolean;
  92528. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92529. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92530. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92531. getAnimatables(): BABYLON.IAnimatable[];
  92532. getActiveTextures(): BABYLON.BaseTexture[];
  92533. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92534. dispose(forceDisposeEffect?: boolean): void;
  92535. clone(name: string): NormalMaterial;
  92536. serialize(): any;
  92537. getClassName(): string;
  92538. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92539. }
  92540. }
  92541. declare module BABYLON {
  92542. /** @hidden */
  92543. export var shadowOnlyPixelShader: {
  92544. name: string;
  92545. shader: string;
  92546. };
  92547. }
  92548. declare module BABYLON {
  92549. /** @hidden */
  92550. export var shadowOnlyVertexShader: {
  92551. name: string;
  92552. shader: string;
  92553. };
  92554. }
  92555. declare module BABYLON {
  92556. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92557. private _activeLight;
  92558. private _needAlphaBlending;
  92559. constructor(name: string, scene: BABYLON.Scene);
  92560. shadowColor: BABYLON.Color3;
  92561. needAlphaBlending(): boolean;
  92562. needAlphaTesting(): boolean;
  92563. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92564. get activeLight(): BABYLON.IShadowLight;
  92565. set activeLight(light: BABYLON.IShadowLight);
  92566. private _getFirstShadowLightForMesh;
  92567. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92568. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92569. clone(name: string): ShadowOnlyMaterial;
  92570. serialize(): any;
  92571. getClassName(): string;
  92572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92573. }
  92574. }
  92575. declare module BABYLON {
  92576. /** @hidden */
  92577. export var simplePixelShader: {
  92578. name: string;
  92579. shader: string;
  92580. };
  92581. }
  92582. declare module BABYLON {
  92583. /** @hidden */
  92584. export var simpleVertexShader: {
  92585. name: string;
  92586. shader: string;
  92587. };
  92588. }
  92589. declare module BABYLON {
  92590. export class SimpleMaterial extends BABYLON.PushMaterial {
  92591. private _diffuseTexture;
  92592. diffuseTexture: BABYLON.BaseTexture;
  92593. diffuseColor: BABYLON.Color3;
  92594. private _disableLighting;
  92595. disableLighting: boolean;
  92596. private _maxSimultaneousLights;
  92597. maxSimultaneousLights: number;
  92598. constructor(name: string, scene: BABYLON.Scene);
  92599. needAlphaBlending(): boolean;
  92600. needAlphaTesting(): boolean;
  92601. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92602. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92603. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92604. getAnimatables(): BABYLON.IAnimatable[];
  92605. getActiveTextures(): BABYLON.BaseTexture[];
  92606. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92607. dispose(forceDisposeEffect?: boolean): void;
  92608. clone(name: string): SimpleMaterial;
  92609. serialize(): any;
  92610. getClassName(): string;
  92611. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92612. }
  92613. }
  92614. declare module BABYLON {
  92615. /** @hidden */
  92616. export var skyPixelShader: {
  92617. name: string;
  92618. shader: string;
  92619. };
  92620. }
  92621. declare module BABYLON {
  92622. /** @hidden */
  92623. export var skyVertexShader: {
  92624. name: string;
  92625. shader: string;
  92626. };
  92627. }
  92628. declare module BABYLON {
  92629. /**
  92630. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92631. * @see https://doc.babylonjs.com/extensions/sky
  92632. */
  92633. export class SkyMaterial extends BABYLON.PushMaterial {
  92634. /**
  92635. * Defines the overall luminance of sky in interval ]0, 1[.
  92636. */
  92637. luminance: number;
  92638. /**
  92639. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92640. */
  92641. turbidity: number;
  92642. /**
  92643. * Defines the sky appearance (light intensity).
  92644. */
  92645. rayleigh: number;
  92646. /**
  92647. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92648. */
  92649. mieCoefficient: number;
  92650. /**
  92651. * Defines the amount of haze particles following the Mie scattering theory.
  92652. */
  92653. mieDirectionalG: number;
  92654. /**
  92655. * Defines the distance of the sun according to the active scene camera.
  92656. */
  92657. distance: number;
  92658. /**
  92659. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92660. * "inclined".
  92661. */
  92662. inclination: number;
  92663. /**
  92664. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92665. * an object direction and a reference direction.
  92666. */
  92667. azimuth: number;
  92668. /**
  92669. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92670. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92671. */
  92672. sunPosition: BABYLON.Vector3;
  92673. /**
  92674. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92675. * .sunPosition property.
  92676. */
  92677. useSunPosition: boolean;
  92678. /**
  92679. * Defines an offset vector used to get a horizon offset.
  92680. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92681. */
  92682. cameraOffset: BABYLON.Vector3;
  92683. /**
  92684. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92685. */
  92686. up: BABYLON.Vector3;
  92687. private _cameraPosition;
  92688. private _skyOrientation;
  92689. /**
  92690. * Instantiates a new sky material.
  92691. * This material allows to create dynamic and texture free
  92692. * effects for skyboxes by taking care of the atmosphere state.
  92693. * @see https://doc.babylonjs.com/extensions/sky
  92694. * @param name Define the name of the material in the scene
  92695. * @param scene Define the scene the material belong to
  92696. */
  92697. constructor(name: string, scene: BABYLON.Scene);
  92698. /**
  92699. * Specifies if the material will require alpha blending
  92700. * @returns a boolean specifying if alpha blending is needed
  92701. */
  92702. needAlphaBlending(): boolean;
  92703. /**
  92704. * Specifies if this material should be rendered in alpha test mode
  92705. * @returns false as the sky material doesn't need alpha testing.
  92706. */
  92707. needAlphaTesting(): boolean;
  92708. /**
  92709. * Get the texture used for alpha test purpose.
  92710. * @returns null as the sky material has no texture.
  92711. */
  92712. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92713. /**
  92714. * Get if the submesh is ready to be used and all its information available.
  92715. * Child classes can use it to update shaders
  92716. * @param mesh defines the mesh to check
  92717. * @param subMesh defines which submesh to check
  92718. * @param useInstances specifies that instances should be used
  92719. * @returns a boolean indicating that the submesh is ready or not
  92720. */
  92721. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92722. /**
  92723. * Binds the submesh to this material by preparing the effect and shader to draw
  92724. * @param world defines the world transformation matrix
  92725. * @param mesh defines the mesh containing the submesh
  92726. * @param subMesh defines the submesh to bind the material to
  92727. */
  92728. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92729. /**
  92730. * Get the list of animatables in the material.
  92731. * @returns the list of animatables object used in the material
  92732. */
  92733. getAnimatables(): BABYLON.IAnimatable[];
  92734. /**
  92735. * Disposes the material
  92736. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92737. */
  92738. dispose(forceDisposeEffect?: boolean): void;
  92739. /**
  92740. * Makes a duplicate of the material, and gives it a new name
  92741. * @param name defines the new name for the duplicated material
  92742. * @returns the cloned material
  92743. */
  92744. clone(name: string): SkyMaterial;
  92745. /**
  92746. * Serializes this material in a JSON representation
  92747. * @returns the serialized material object
  92748. */
  92749. serialize(): any;
  92750. /**
  92751. * Gets the current class name of the material e.g. "SkyMaterial"
  92752. * Mainly use in serialization.
  92753. * @returns the class name
  92754. */
  92755. getClassName(): string;
  92756. /**
  92757. * Creates a sky material from parsed material data
  92758. * @param source defines the JSON representation of the material
  92759. * @param scene defines the hosting scene
  92760. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92761. * @returns a new sky material
  92762. */
  92763. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92764. }
  92765. }
  92766. declare module BABYLON {
  92767. /** @hidden */
  92768. export var terrainPixelShader: {
  92769. name: string;
  92770. shader: string;
  92771. };
  92772. }
  92773. declare module BABYLON {
  92774. /** @hidden */
  92775. export var terrainVertexShader: {
  92776. name: string;
  92777. shader: string;
  92778. };
  92779. }
  92780. declare module BABYLON {
  92781. export class TerrainMaterial extends BABYLON.PushMaterial {
  92782. private _mixTexture;
  92783. mixTexture: BABYLON.BaseTexture;
  92784. private _diffuseTexture1;
  92785. diffuseTexture1: BABYLON.Texture;
  92786. private _diffuseTexture2;
  92787. diffuseTexture2: BABYLON.Texture;
  92788. private _diffuseTexture3;
  92789. diffuseTexture3: BABYLON.Texture;
  92790. private _bumpTexture1;
  92791. bumpTexture1: BABYLON.Texture;
  92792. private _bumpTexture2;
  92793. bumpTexture2: BABYLON.Texture;
  92794. private _bumpTexture3;
  92795. bumpTexture3: BABYLON.Texture;
  92796. diffuseColor: BABYLON.Color3;
  92797. specularColor: BABYLON.Color3;
  92798. specularPower: number;
  92799. private _disableLighting;
  92800. disableLighting: boolean;
  92801. private _maxSimultaneousLights;
  92802. maxSimultaneousLights: number;
  92803. constructor(name: string, scene: BABYLON.Scene);
  92804. needAlphaBlending(): boolean;
  92805. needAlphaTesting(): boolean;
  92806. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92807. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92808. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92809. getAnimatables(): BABYLON.IAnimatable[];
  92810. getActiveTextures(): BABYLON.BaseTexture[];
  92811. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92812. dispose(forceDisposeEffect?: boolean): void;
  92813. clone(name: string): TerrainMaterial;
  92814. serialize(): any;
  92815. getClassName(): string;
  92816. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92817. }
  92818. }
  92819. declare module BABYLON {
  92820. /** @hidden */
  92821. export var triplanarPixelShader: {
  92822. name: string;
  92823. shader: string;
  92824. };
  92825. }
  92826. declare module BABYLON {
  92827. /** @hidden */
  92828. export var triplanarVertexShader: {
  92829. name: string;
  92830. shader: string;
  92831. };
  92832. }
  92833. declare module BABYLON {
  92834. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92835. mixTexture: BABYLON.BaseTexture;
  92836. private _diffuseTextureX;
  92837. diffuseTextureX: BABYLON.BaseTexture;
  92838. private _diffuseTextureY;
  92839. diffuseTextureY: BABYLON.BaseTexture;
  92840. private _diffuseTextureZ;
  92841. diffuseTextureZ: BABYLON.BaseTexture;
  92842. private _normalTextureX;
  92843. normalTextureX: BABYLON.BaseTexture;
  92844. private _normalTextureY;
  92845. normalTextureY: BABYLON.BaseTexture;
  92846. private _normalTextureZ;
  92847. normalTextureZ: BABYLON.BaseTexture;
  92848. tileSize: number;
  92849. diffuseColor: BABYLON.Color3;
  92850. specularColor: BABYLON.Color3;
  92851. specularPower: number;
  92852. private _disableLighting;
  92853. disableLighting: boolean;
  92854. private _maxSimultaneousLights;
  92855. maxSimultaneousLights: number;
  92856. constructor(name: string, scene: BABYLON.Scene);
  92857. needAlphaBlending(): boolean;
  92858. needAlphaTesting(): boolean;
  92859. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92860. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92861. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92862. getAnimatables(): BABYLON.IAnimatable[];
  92863. getActiveTextures(): BABYLON.BaseTexture[];
  92864. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92865. dispose(forceDisposeEffect?: boolean): void;
  92866. clone(name: string): TriPlanarMaterial;
  92867. serialize(): any;
  92868. getClassName(): string;
  92869. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92870. }
  92871. }
  92872. declare module BABYLON {
  92873. /** @hidden */
  92874. export var waterPixelShader: {
  92875. name: string;
  92876. shader: string;
  92877. };
  92878. }
  92879. declare module BABYLON {
  92880. /** @hidden */
  92881. export var waterVertexShader: {
  92882. name: string;
  92883. shader: string;
  92884. };
  92885. }
  92886. declare module BABYLON {
  92887. export class WaterMaterial extends BABYLON.PushMaterial {
  92888. renderTargetSize: BABYLON.Vector2;
  92889. private _bumpTexture;
  92890. bumpTexture: BABYLON.BaseTexture;
  92891. diffuseColor: BABYLON.Color3;
  92892. specularColor: BABYLON.Color3;
  92893. specularPower: number;
  92894. private _disableLighting;
  92895. disableLighting: boolean;
  92896. private _maxSimultaneousLights;
  92897. maxSimultaneousLights: number;
  92898. /**
  92899. * Defines the wind force.
  92900. */
  92901. windForce: number;
  92902. /**
  92903. * Defines the direction of the wind in the plane (X, Z).
  92904. */
  92905. windDirection: BABYLON.Vector2;
  92906. /**
  92907. * Defines the height of the waves.
  92908. */
  92909. waveHeight: number;
  92910. /**
  92911. * Defines the bump height related to the bump map.
  92912. */
  92913. bumpHeight: number;
  92914. /**
  92915. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92916. */
  92917. private _bumpSuperimpose;
  92918. bumpSuperimpose: boolean;
  92919. /**
  92920. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92921. */
  92922. private _fresnelSeparate;
  92923. fresnelSeparate: boolean;
  92924. /**
  92925. * Defines wether or not bump Wwves modify the reflection.
  92926. */
  92927. private _bumpAffectsReflection;
  92928. bumpAffectsReflection: boolean;
  92929. /**
  92930. * Defines the water color blended with the refraction (near).
  92931. */
  92932. waterColor: BABYLON.Color3;
  92933. /**
  92934. * Defines the blend factor related to the water color.
  92935. */
  92936. colorBlendFactor: number;
  92937. /**
  92938. * Defines the water color blended with the reflection (far).
  92939. */
  92940. waterColor2: BABYLON.Color3;
  92941. /**
  92942. * Defines the blend factor related to the water color (reflection, far).
  92943. */
  92944. colorBlendFactor2: number;
  92945. /**
  92946. * Defines the maximum length of a wave.
  92947. */
  92948. waveLength: number;
  92949. /**
  92950. * Defines the waves speed.
  92951. */
  92952. waveSpeed: number;
  92953. /**
  92954. * 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.
  92955. */
  92956. waveCount: number;
  92957. /**
  92958. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92959. * will avoid calculating useless pixels in the pixel shader of the water material.
  92960. */
  92961. disableClipPlane: boolean;
  92962. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92963. private _mesh;
  92964. private _refractionRTT;
  92965. private _reflectionRTT;
  92966. private _reflectionTransform;
  92967. private _lastTime;
  92968. private _lastDeltaTime;
  92969. private _useLogarithmicDepth;
  92970. private _waitingRenderList;
  92971. private _imageProcessingConfiguration;
  92972. private _imageProcessingObserver;
  92973. /**
  92974. * Gets a boolean indicating that current material needs to register RTT
  92975. */
  92976. get hasRenderTargetTextures(): boolean;
  92977. /**
  92978. * Constructor
  92979. */
  92980. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92981. get useLogarithmicDepth(): boolean;
  92982. set useLogarithmicDepth(value: boolean);
  92983. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92984. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92985. addToRenderList(node: any): void;
  92986. enableRenderTargets(enable: boolean): void;
  92987. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92988. get renderTargetsEnabled(): boolean;
  92989. needAlphaBlending(): boolean;
  92990. needAlphaTesting(): boolean;
  92991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92994. private _createRenderTargets;
  92995. getAnimatables(): BABYLON.IAnimatable[];
  92996. getActiveTextures(): BABYLON.BaseTexture[];
  92997. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92998. dispose(forceDisposeEffect?: boolean): void;
  92999. clone(name: string): WaterMaterial;
  93000. serialize(): any;
  93001. getClassName(): string;
  93002. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  93003. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  93004. }
  93005. }
  93006. declare module BABYLON {
  93007. /** @hidden */
  93008. export var asciiartPixelShader: {
  93009. name: string;
  93010. shader: string;
  93011. };
  93012. }
  93013. declare module BABYLON {
  93014. /**
  93015. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  93016. *
  93017. * It basically takes care rendering the font front the given font size to a texture.
  93018. * This is used later on in the postprocess.
  93019. */
  93020. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  93021. private _font;
  93022. private _text;
  93023. private _charSize;
  93024. /**
  93025. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93026. */
  93027. get charSize(): number;
  93028. /**
  93029. * Create a new instance of the Ascii Art FontTexture class
  93030. * @param name the name of the texture
  93031. * @param font the font to use, use the W3C CSS notation
  93032. * @param text the caracter set to use in the rendering.
  93033. * @param scene the scene that owns the texture
  93034. */
  93035. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93036. /**
  93037. * Gets the max char width of a font.
  93038. * @param font the font to use, use the W3C CSS notation
  93039. * @return the max char width
  93040. */
  93041. private getFontWidth;
  93042. /**
  93043. * Gets the max char height of a font.
  93044. * @param font the font to use, use the W3C CSS notation
  93045. * @return the max char height
  93046. */
  93047. private getFontHeight;
  93048. /**
  93049. * Clones the current AsciiArtTexture.
  93050. * @return the clone of the texture.
  93051. */
  93052. clone(): AsciiArtFontTexture;
  93053. /**
  93054. * Parses a json object representing the texture and returns an instance of it.
  93055. * @param source the source JSON representation
  93056. * @param scene the scene to create the texture for
  93057. * @return the parsed texture
  93058. */
  93059. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93060. }
  93061. /**
  93062. * Option available in the Ascii Art Post Process.
  93063. */
  93064. export interface IAsciiArtPostProcessOptions {
  93065. /**
  93066. * The font to use following the w3c font definition.
  93067. */
  93068. font?: string;
  93069. /**
  93070. * The character set to use in the postprocess.
  93071. */
  93072. characterSet?: string;
  93073. /**
  93074. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93075. * This number is defined between 0 and 1;
  93076. */
  93077. mixToTile?: number;
  93078. /**
  93079. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93080. * This number is defined between 0 and 1;
  93081. */
  93082. mixToNormal?: number;
  93083. }
  93084. /**
  93085. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93086. *
  93087. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93088. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93089. */
  93090. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93091. /**
  93092. * The font texture used to render the char in the post process.
  93093. */
  93094. private _asciiArtFontTexture;
  93095. /**
  93096. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93097. * This number is defined between 0 and 1;
  93098. */
  93099. mixToTile: number;
  93100. /**
  93101. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93102. * This number is defined between 0 and 1;
  93103. */
  93104. mixToNormal: number;
  93105. /**
  93106. * Instantiates a new Ascii Art Post Process.
  93107. * @param name the name to give to the postprocess
  93108. * @camera the camera to apply the post process to.
  93109. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93110. */
  93111. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93112. }
  93113. }
  93114. declare module BABYLON {
  93115. /** @hidden */
  93116. export var digitalrainPixelShader: {
  93117. name: string;
  93118. shader: string;
  93119. };
  93120. }
  93121. declare module BABYLON {
  93122. /**
  93123. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93124. *
  93125. * It basically takes care rendering the font front the given font size to a texture.
  93126. * This is used later on in the postprocess.
  93127. */
  93128. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93129. private _font;
  93130. private _text;
  93131. private _charSize;
  93132. /**
  93133. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93134. */
  93135. get charSize(): number;
  93136. /**
  93137. * Create a new instance of the Digital Rain FontTexture class
  93138. * @param name the name of the texture
  93139. * @param font the font to use, use the W3C CSS notation
  93140. * @param text the caracter set to use in the rendering.
  93141. * @param scene the scene that owns the texture
  93142. */
  93143. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93144. /**
  93145. * Gets the max char width of a font.
  93146. * @param font the font to use, use the W3C CSS notation
  93147. * @return the max char width
  93148. */
  93149. private getFontWidth;
  93150. /**
  93151. * Gets the max char height of a font.
  93152. * @param font the font to use, use the W3C CSS notation
  93153. * @return the max char height
  93154. */
  93155. private getFontHeight;
  93156. /**
  93157. * Clones the current DigitalRainFontTexture.
  93158. * @return the clone of the texture.
  93159. */
  93160. clone(): DigitalRainFontTexture;
  93161. /**
  93162. * Parses a json object representing the texture and returns an instance of it.
  93163. * @param source the source JSON representation
  93164. * @param scene the scene to create the texture for
  93165. * @return the parsed texture
  93166. */
  93167. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93168. }
  93169. /**
  93170. * Option available in the Digital Rain Post Process.
  93171. */
  93172. export interface IDigitalRainPostProcessOptions {
  93173. /**
  93174. * The font to use following the w3c font definition.
  93175. */
  93176. font?: string;
  93177. /**
  93178. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93179. * This number is defined between 0 and 1;
  93180. */
  93181. mixToTile?: number;
  93182. /**
  93183. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93184. * This number is defined between 0 and 1;
  93185. */
  93186. mixToNormal?: number;
  93187. }
  93188. /**
  93189. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93190. *
  93191. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93192. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93193. */
  93194. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93195. /**
  93196. * The font texture used to render the char in the post process.
  93197. */
  93198. private _digitalRainFontTexture;
  93199. /**
  93200. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93201. * This number is defined between 0 and 1;
  93202. */
  93203. mixToTile: number;
  93204. /**
  93205. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93206. * This number is defined between 0 and 1;
  93207. */
  93208. mixToNormal: number;
  93209. /**
  93210. * Instantiates a new Digital Rain Post Process.
  93211. * @param name the name to give to the postprocess
  93212. * @camera the camera to apply the post process to.
  93213. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93214. */
  93215. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93216. }
  93217. }
  93218. declare module BABYLON {
  93219. /** @hidden */
  93220. export var brickProceduralTexturePixelShader: {
  93221. name: string;
  93222. shader: string;
  93223. };
  93224. }
  93225. declare module BABYLON {
  93226. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93227. private _numberOfBricksHeight;
  93228. private _numberOfBricksWidth;
  93229. private _jointColor;
  93230. private _brickColor;
  93231. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93232. updateShaderUniforms(): void;
  93233. get numberOfBricksHeight(): number;
  93234. set numberOfBricksHeight(value: number);
  93235. get numberOfBricksWidth(): number;
  93236. set numberOfBricksWidth(value: number);
  93237. get jointColor(): BABYLON.Color3;
  93238. set jointColor(value: BABYLON.Color3);
  93239. get brickColor(): BABYLON.Color3;
  93240. set brickColor(value: BABYLON.Color3);
  93241. /**
  93242. * Serializes this brick procedural texture
  93243. * @returns a serialized brick procedural texture object
  93244. */
  93245. serialize(): any;
  93246. /**
  93247. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93248. * @param parsedTexture defines parsed texture data
  93249. * @param scene defines the current scene
  93250. * @param rootUrl defines the root URL containing brick procedural texture information
  93251. * @returns a parsed Brick Procedural BABYLON.Texture
  93252. */
  93253. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93254. }
  93255. }
  93256. declare module BABYLON {
  93257. /** @hidden */
  93258. export var cloudProceduralTexturePixelShader: {
  93259. name: string;
  93260. shader: string;
  93261. };
  93262. }
  93263. declare module BABYLON {
  93264. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93265. private _skyColor;
  93266. private _cloudColor;
  93267. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93268. updateShaderUniforms(): void;
  93269. get skyColor(): BABYLON.Color4;
  93270. set skyColor(value: BABYLON.Color4);
  93271. get cloudColor(): BABYLON.Color4;
  93272. set cloudColor(value: BABYLON.Color4);
  93273. /**
  93274. * Serializes this cloud procedural texture
  93275. * @returns a serialized cloud procedural texture object
  93276. */
  93277. serialize(): any;
  93278. /**
  93279. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93280. * @param parsedTexture defines parsed texture data
  93281. * @param scene defines the current scene
  93282. * @param rootUrl defines the root URL containing cloud procedural texture information
  93283. * @returns a parsed Cloud Procedural BABYLON.Texture
  93284. */
  93285. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93286. }
  93287. }
  93288. declare module BABYLON {
  93289. /** @hidden */
  93290. export var fireProceduralTexturePixelShader: {
  93291. name: string;
  93292. shader: string;
  93293. };
  93294. }
  93295. declare module BABYLON {
  93296. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93297. private _time;
  93298. private _speed;
  93299. private _autoGenerateTime;
  93300. private _fireColors;
  93301. private _alphaThreshold;
  93302. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93303. updateShaderUniforms(): void;
  93304. render(useCameraPostProcess?: boolean): void;
  93305. static get PurpleFireColors(): BABYLON.Color3[];
  93306. static get GreenFireColors(): BABYLON.Color3[];
  93307. static get RedFireColors(): BABYLON.Color3[];
  93308. static get BlueFireColors(): BABYLON.Color3[];
  93309. get autoGenerateTime(): boolean;
  93310. set autoGenerateTime(value: boolean);
  93311. get fireColors(): BABYLON.Color3[];
  93312. set fireColors(value: BABYLON.Color3[]);
  93313. get time(): number;
  93314. set time(value: number);
  93315. get speed(): BABYLON.Vector2;
  93316. set speed(value: BABYLON.Vector2);
  93317. get alphaThreshold(): number;
  93318. set alphaThreshold(value: number);
  93319. /**
  93320. * Serializes this fire procedural texture
  93321. * @returns a serialized fire procedural texture object
  93322. */
  93323. serialize(): any;
  93324. /**
  93325. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93326. * @param parsedTexture defines parsed texture data
  93327. * @param scene defines the current scene
  93328. * @param rootUrl defines the root URL containing fire procedural texture information
  93329. * @returns a parsed Fire Procedural BABYLON.Texture
  93330. */
  93331. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93332. }
  93333. }
  93334. declare module BABYLON {
  93335. /** @hidden */
  93336. export var grassProceduralTexturePixelShader: {
  93337. name: string;
  93338. shader: string;
  93339. };
  93340. }
  93341. declare module BABYLON {
  93342. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93343. private _grassColors;
  93344. private _groundColor;
  93345. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93346. updateShaderUniforms(): void;
  93347. get grassColors(): BABYLON.Color3[];
  93348. set grassColors(value: BABYLON.Color3[]);
  93349. get groundColor(): BABYLON.Color3;
  93350. set groundColor(value: BABYLON.Color3);
  93351. /**
  93352. * Serializes this grass procedural texture
  93353. * @returns a serialized grass procedural texture object
  93354. */
  93355. serialize(): any;
  93356. /**
  93357. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93358. * @param parsedTexture defines parsed texture data
  93359. * @param scene defines the current scene
  93360. * @param rootUrl defines the root URL containing grass procedural texture information
  93361. * @returns a parsed Grass Procedural BABYLON.Texture
  93362. */
  93363. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93364. }
  93365. }
  93366. declare module BABYLON {
  93367. /** @hidden */
  93368. export var marbleProceduralTexturePixelShader: {
  93369. name: string;
  93370. shader: string;
  93371. };
  93372. }
  93373. declare module BABYLON {
  93374. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93375. private _numberOfTilesHeight;
  93376. private _numberOfTilesWidth;
  93377. private _amplitude;
  93378. private _jointColor;
  93379. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93380. updateShaderUniforms(): void;
  93381. get numberOfTilesHeight(): number;
  93382. set numberOfTilesHeight(value: number);
  93383. get amplitude(): number;
  93384. set amplitude(value: number);
  93385. get numberOfTilesWidth(): number;
  93386. set numberOfTilesWidth(value: number);
  93387. get jointColor(): BABYLON.Color3;
  93388. set jointColor(value: BABYLON.Color3);
  93389. /**
  93390. * Serializes this marble procedural texture
  93391. * @returns a serialized marble procedural texture object
  93392. */
  93393. serialize(): any;
  93394. /**
  93395. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93396. * @param parsedTexture defines parsed texture data
  93397. * @param scene defines the current scene
  93398. * @param rootUrl defines the root URL containing marble procedural texture information
  93399. * @returns a parsed Marble Procedural BABYLON.Texture
  93400. */
  93401. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93402. }
  93403. }
  93404. declare module BABYLON {
  93405. /** @hidden */
  93406. export var normalMapProceduralTexturePixelShader: {
  93407. name: string;
  93408. shader: string;
  93409. };
  93410. }
  93411. declare module BABYLON {
  93412. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93413. private _baseTexture;
  93414. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93415. updateShaderUniforms(): void;
  93416. render(useCameraPostProcess?: boolean): void;
  93417. resize(size: any, generateMipMaps: any): void;
  93418. isReady(): boolean;
  93419. get baseTexture(): BABYLON.Texture;
  93420. set baseTexture(texture: BABYLON.Texture);
  93421. /**
  93422. * Serializes this normal map procedural texture
  93423. * @returns a serialized normal map procedural texture object
  93424. */
  93425. serialize(): any;
  93426. /**
  93427. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93428. * @param parsedTexture defines parsed texture data
  93429. * @param scene defines the current scene
  93430. * @param rootUrl defines the root URL containing normal map procedural texture information
  93431. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93432. */
  93433. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93434. }
  93435. }
  93436. declare module BABYLON {
  93437. /** @hidden */
  93438. export var perlinNoiseProceduralTexturePixelShader: {
  93439. name: string;
  93440. shader: string;
  93441. };
  93442. }
  93443. declare module BABYLON {
  93444. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93445. time: number;
  93446. timeScale: number;
  93447. translationSpeed: number;
  93448. private _currentTranslation;
  93449. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93450. updateShaderUniforms(): void;
  93451. render(useCameraPostProcess?: boolean): void;
  93452. resize(size: any, generateMipMaps: any): void;
  93453. /**
  93454. * Serializes this perlin noise procedural texture
  93455. * @returns a serialized perlin noise procedural texture object
  93456. */
  93457. serialize(): any;
  93458. /**
  93459. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93460. * @param parsedTexture defines parsed texture data
  93461. * @param scene defines the current scene
  93462. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93463. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93464. */
  93465. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93466. }
  93467. }
  93468. declare module BABYLON {
  93469. /** @hidden */
  93470. export var roadProceduralTexturePixelShader: {
  93471. name: string;
  93472. shader: string;
  93473. };
  93474. }
  93475. declare module BABYLON {
  93476. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93477. private _roadColor;
  93478. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93479. updateShaderUniforms(): void;
  93480. get roadColor(): BABYLON.Color3;
  93481. set roadColor(value: BABYLON.Color3);
  93482. /**
  93483. * Serializes this road procedural texture
  93484. * @returns a serialized road procedural texture object
  93485. */
  93486. serialize(): any;
  93487. /**
  93488. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93489. * @param parsedTexture defines parsed texture data
  93490. * @param scene defines the current scene
  93491. * @param rootUrl defines the root URL containing road procedural texture information
  93492. * @returns a parsed Road Procedural BABYLON.Texture
  93493. */
  93494. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93495. }
  93496. }
  93497. declare module BABYLON {
  93498. /** @hidden */
  93499. export var starfieldProceduralTexturePixelShader: {
  93500. name: string;
  93501. shader: string;
  93502. };
  93503. }
  93504. declare module BABYLON {
  93505. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93506. private _time;
  93507. private _alpha;
  93508. private _beta;
  93509. private _zoom;
  93510. private _formuparam;
  93511. private _stepsize;
  93512. private _tile;
  93513. private _brightness;
  93514. private _darkmatter;
  93515. private _distfading;
  93516. private _saturation;
  93517. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93518. updateShaderUniforms(): void;
  93519. get time(): number;
  93520. set time(value: number);
  93521. get alpha(): number;
  93522. set alpha(value: number);
  93523. get beta(): number;
  93524. set beta(value: number);
  93525. get formuparam(): number;
  93526. set formuparam(value: number);
  93527. get stepsize(): number;
  93528. set stepsize(value: number);
  93529. get zoom(): number;
  93530. set zoom(value: number);
  93531. get tile(): number;
  93532. set tile(value: number);
  93533. get brightness(): number;
  93534. set brightness(value: number);
  93535. get darkmatter(): number;
  93536. set darkmatter(value: number);
  93537. get distfading(): number;
  93538. set distfading(value: number);
  93539. get saturation(): number;
  93540. set saturation(value: number);
  93541. /**
  93542. * Serializes this starfield procedural texture
  93543. * @returns a serialized starfield procedural texture object
  93544. */
  93545. serialize(): any;
  93546. /**
  93547. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93548. * @param parsedTexture defines parsed texture data
  93549. * @param scene defines the current scene
  93550. * @param rootUrl defines the root URL containing startfield procedural texture information
  93551. * @returns a parsed Starfield Procedural BABYLON.Texture
  93552. */
  93553. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93554. }
  93555. }
  93556. declare module BABYLON {
  93557. /** @hidden */
  93558. export var woodProceduralTexturePixelShader: {
  93559. name: string;
  93560. shader: string;
  93561. };
  93562. }
  93563. declare module BABYLON {
  93564. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93565. private _ampScale;
  93566. private _woodColor;
  93567. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93568. updateShaderUniforms(): void;
  93569. get ampScale(): number;
  93570. set ampScale(value: number);
  93571. get woodColor(): BABYLON.Color3;
  93572. set woodColor(value: BABYLON.Color3);
  93573. /**
  93574. * Serializes this wood procedural texture
  93575. * @returns a serialized wood procedural texture object
  93576. */
  93577. serialize(): any;
  93578. /**
  93579. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93580. * @param parsedTexture defines parsed texture data
  93581. * @param scene defines the current scene
  93582. * @param rootUrl defines the root URL containing wood procedural texture information
  93583. * @returns a parsed Wood Procedural BABYLON.Texture
  93584. */
  93585. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93586. }
  93587. }