documentation.d.ts 3.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used throughout the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependencies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the resource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the resource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the resource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the resource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailed logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve normal index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1130. /**
  1131. * Constant used to retrieve albedo index in the textures array in the prepass
  1132. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1133. */
  1134. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1135. /**
  1136. * Prefixes used by the engine for custom effects
  1137. */
  1138. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1139. }
  1140. }
  1141. declare module BABYLON {
  1142. /** @hidden */
  1143. export interface HardwareTextureWrapper {
  1144. underlyingResource: any;
  1145. set(hardwareTexture: any): void;
  1146. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1147. reset(): void;
  1148. release(): void;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /**
  1153. * This represents the required contract to create a new type of texture loader.
  1154. */
  1155. export interface IInternalTextureLoader {
  1156. /**
  1157. * Defines whether the loader supports cascade loading the different faces.
  1158. */
  1159. supportCascades: boolean;
  1160. /**
  1161. * This returns if the loader support the current file information.
  1162. * @param extension defines the file extension of the file being loaded
  1163. * @param mimeType defines the optional mime type of the file being loaded
  1164. * @returns true if the loader can load the specified file
  1165. */
  1166. canLoad(extension: string, mimeType?: string): boolean;
  1167. /**
  1168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1169. * @param data contains the texture data
  1170. * @param texture defines the BabylonJS internal texture
  1171. * @param createPolynomials will be true if polynomials have been requested
  1172. * @param onLoad defines the callback to trigger once the texture is ready
  1173. * @param onError defines the callback to trigger in case of error
  1174. * @param options options to be passed to the loader
  1175. */
  1176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1177. /**
  1178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1179. * @param data contains the texture data
  1180. * @param texture defines the BabylonJS internal texture
  1181. * @param callback defines the method to call once ready to upload
  1182. * @param options options to be passed to the loader
  1183. */
  1184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /**
  1189. * @hidden
  1190. */
  1191. export interface IColor4Like {
  1192. r: float;
  1193. g: float;
  1194. b: float;
  1195. a: float;
  1196. }
  1197. /**
  1198. * @hidden
  1199. */
  1200. export interface IColor3Like {
  1201. r: float;
  1202. g: float;
  1203. b: float;
  1204. }
  1205. /**
  1206. * @hidden
  1207. */
  1208. export interface IVector4Like {
  1209. x: float;
  1210. y: float;
  1211. z: float;
  1212. w: float;
  1213. }
  1214. /**
  1215. * @hidden
  1216. */
  1217. export interface IVector3Like {
  1218. x: float;
  1219. y: float;
  1220. z: float;
  1221. }
  1222. /**
  1223. * @hidden
  1224. */
  1225. export interface IVector2Like {
  1226. x: float;
  1227. y: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IMatrixLike {
  1233. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1234. updateFlag: int;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IViewportLike {
  1240. x: float;
  1241. y: float;
  1242. width: float;
  1243. height: float;
  1244. }
  1245. /**
  1246. * @hidden
  1247. */
  1248. export interface IPlaneLike {
  1249. normal: IVector3Like;
  1250. d: float;
  1251. normalize(): void;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /**
  1256. * Class used to store and describe the pipeline context associated with an effect
  1257. */
  1258. export interface IPipelineContext {
  1259. /**
  1260. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1261. */
  1262. isAsync: boolean;
  1263. /**
  1264. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1265. */
  1266. isReady: boolean;
  1267. /** @hidden */
  1268. _name?: string;
  1269. /** @hidden */
  1270. _getVertexShaderCode(): string | null;
  1271. /** @hidden */
  1272. _getFragmentShaderCode(): string | null;
  1273. /** @hidden */
  1274. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1275. /** @hidden */
  1276. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1277. [key: string]: number;
  1278. }, uniformsNames: string[], uniforms: {
  1279. [key: string]: Nullable<WebGLUniformLocation>;
  1280. }, samplerList: string[], samplers: {
  1281. [key: string]: number;
  1282. }, attributesNames: string[], attributes: number[]): void;
  1283. /** Releases the resources associated with the pipeline. */
  1284. dispose(): void;
  1285. /**
  1286. * Sets an integer value on a uniform variable.
  1287. * @param uniformName Name of the variable.
  1288. * @param value Value to be set.
  1289. */
  1290. setInt(uniformName: string, value: number): void;
  1291. /**
  1292. * Sets an int2 value on a uniform variable.
  1293. * @param uniformName Name of the variable.
  1294. * @param x First int in int2.
  1295. * @param y Second int in int2.
  1296. */
  1297. setInt2(uniformName: string, x: number, y: number): void;
  1298. /**
  1299. * Sets an int3 value on a uniform variable.
  1300. * @param uniformName Name of the variable.
  1301. * @param x First int in int3.
  1302. * @param y Second int in int3.
  1303. * @param z Third int in int3.
  1304. */
  1305. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1306. /**
  1307. * Sets an int4 value on a uniform variable.
  1308. * @param uniformName Name of the variable.
  1309. * @param x First int in int4.
  1310. * @param y Second int in int4.
  1311. * @param z Third int in int4.
  1312. * @param w Fourth int in int4.
  1313. */
  1314. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1315. /**
  1316. * Sets an int array on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param array array to be set.
  1319. */
  1320. setIntArray(uniformName: string, array: Int32Array): void;
  1321. /**
  1322. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1323. * @param uniformName Name of the variable.
  1324. * @param array array to be set.
  1325. */
  1326. setIntArray2(uniformName: string, array: Int32Array): void;
  1327. /**
  1328. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1329. * @param uniformName Name of the variable.
  1330. * @param array array to be set.
  1331. */
  1332. setIntArray3(uniformName: string, array: Int32Array): void;
  1333. /**
  1334. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1335. * @param uniformName Name of the variable.
  1336. * @param array array to be set.
  1337. */
  1338. setIntArray4(uniformName: string, array: Int32Array): void;
  1339. /**
  1340. * Sets an array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setArray(uniformName: string, array: number[] | Float32Array): void;
  1345. /**
  1346. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1351. /**
  1352. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1357. /**
  1358. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1363. /**
  1364. * Sets matrices on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param matrices matrices to be set.
  1367. */
  1368. setMatrices(uniformName: string, matrices: Float32Array): void;
  1369. /**
  1370. * Sets matrix on a uniform variable.
  1371. * @param uniformName Name of the variable.
  1372. * @param matrix matrix to be set.
  1373. */
  1374. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1375. /**
  1376. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1377. * @param uniformName Name of the variable.
  1378. * @param matrix matrix to be set.
  1379. */
  1380. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1381. /**
  1382. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1383. * @param uniformName Name of the variable.
  1384. * @param matrix matrix to be set.
  1385. */
  1386. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1387. /**
  1388. * Sets a float on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param value value to be set.
  1391. */
  1392. setFloat(uniformName: string, value: number): void;
  1393. /**
  1394. * Sets a Vector2 on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param vector2 vector2 to be set.
  1397. */
  1398. setVector2(uniformName: string, vector2: IVector2Like): void;
  1399. /**
  1400. * Sets a float2 on a uniform variable.
  1401. * @param uniformName Name of the variable.
  1402. * @param x First float in float2.
  1403. * @param y Second float in float2.
  1404. */
  1405. setFloat2(uniformName: string, x: number, y: number): void;
  1406. /**
  1407. * Sets a Vector3 on a uniform variable.
  1408. * @param uniformName Name of the variable.
  1409. * @param vector3 Value to be set.
  1410. */
  1411. setVector3(uniformName: string, vector3: IVector3Like): void;
  1412. /**
  1413. * Sets a float3 on a uniform variable.
  1414. * @param uniformName Name of the variable.
  1415. * @param x First float in float3.
  1416. * @param y Second float in float3.
  1417. * @param z Third float in float3.
  1418. */
  1419. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1420. /**
  1421. * Sets a Vector4 on a uniform variable.
  1422. * @param uniformName Name of the variable.
  1423. * @param vector4 Value to be set.
  1424. */
  1425. setVector4(uniformName: string, vector4: IVector4Like): void;
  1426. /**
  1427. * Sets a float4 on a uniform variable.
  1428. * @param uniformName Name of the variable.
  1429. * @param x First float in float4.
  1430. * @param y Second float in float4.
  1431. * @param z Third float in float4.
  1432. * @param w Fourth float in float4.
  1433. */
  1434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1435. /**
  1436. * Sets a Color3 on a uniform variable.
  1437. * @param uniformName Name of the variable.
  1438. * @param color3 Value to be set.
  1439. */
  1440. setColor3(uniformName: string, color3: IColor3Like): void;
  1441. /**
  1442. * Sets a Color4 on a uniform variable.
  1443. * @param uniformName Name of the variable.
  1444. * @param color3 Value to be set.
  1445. * @param alpha Alpha value to be set.
  1446. */
  1447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1448. /**
  1449. * Sets a Color4 on a uniform variable
  1450. * @param uniformName defines the name of the variable
  1451. * @param color4 defines the value to be set
  1452. */
  1453. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1454. }
  1455. }
  1456. declare module BABYLON {
  1457. /**
  1458. * Class used to store gfx data (like WebGLBuffer)
  1459. */
  1460. export class DataBuffer {
  1461. private static _Counter;
  1462. /**
  1463. * Gets or sets the number of objects referencing this buffer
  1464. */
  1465. references: number;
  1466. /** Gets or sets the size of the underlying buffer */
  1467. capacity: number;
  1468. /**
  1469. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1470. */
  1471. is32Bits: boolean;
  1472. /**
  1473. * Gets the underlying buffer
  1474. */
  1475. get underlyingResource(): any;
  1476. /**
  1477. * Gets the unique id of this buffer
  1478. */
  1479. readonly uniqueId: number;
  1480. /**
  1481. * Constructs the buffer
  1482. */
  1483. constructor();
  1484. }
  1485. }
  1486. declare module BABYLON {
  1487. /** @hidden */
  1488. export interface IShaderProcessor {
  1489. attributeProcessor?: (attribute: string, preProcessors: {
  1490. [key: string]: string;
  1491. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1492. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1493. [key: string]: string;
  1494. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1496. [key: string]: string;
  1497. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1502. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1503. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1504. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1505. vertexCode: string;
  1506. fragmentCode: string;
  1507. };
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface ShaderProcessingContext {
  1513. }
  1514. /** @hidden */
  1515. export interface ProcessingOptions {
  1516. defines: string[];
  1517. indexParameters: any;
  1518. isFragment: boolean;
  1519. shouldUseHighPrecisionShader: boolean;
  1520. supportsUniformBuffers: boolean;
  1521. shadersRepository: string;
  1522. includesShadersStore: {
  1523. [key: string]: string;
  1524. };
  1525. processor: Nullable<IShaderProcessor>;
  1526. version: string;
  1527. platformName: string;
  1528. lookForClosingBracketForUniformBuffer?: boolean;
  1529. processingContext: Nullable<ShaderProcessingContext>;
  1530. }
  1531. }
  1532. declare module BABYLON {
  1533. /** @hidden */
  1534. export class ShaderCodeNode {
  1535. line: string;
  1536. children: ShaderCodeNode[];
  1537. additionalDefineKey?: string;
  1538. additionalDefineValue?: string;
  1539. isValid(preprocessors: {
  1540. [key: string]: string;
  1541. }): boolean;
  1542. process(preprocessors: {
  1543. [key: string]: string;
  1544. }, options: ProcessingOptions): string;
  1545. }
  1546. }
  1547. declare module BABYLON {
  1548. /** @hidden */
  1549. export class ShaderCodeCursor {
  1550. private _lines;
  1551. lineIndex: number;
  1552. get currentLine(): string;
  1553. get canRead(): boolean;
  1554. set lines(value: string[]);
  1555. }
  1556. }
  1557. declare module BABYLON {
  1558. /** @hidden */
  1559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1560. process(preprocessors: {
  1561. [key: string]: string;
  1562. }, options: ProcessingOptions): string;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /** @hidden */
  1567. export class ShaderDefineExpression {
  1568. isTrue(preprocessors: {
  1569. [key: string]: string;
  1570. }): boolean;
  1571. private static _OperatorPriority;
  1572. private static _Stack;
  1573. static postfixToInfix(postfix: string[]): string;
  1574. static infixToPostfix(infix: string): string[];
  1575. }
  1576. }
  1577. declare module BABYLON {
  1578. /** @hidden */
  1579. export class ShaderCodeTestNode extends ShaderCodeNode {
  1580. testExpression: ShaderDefineExpression;
  1581. isValid(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. }
  1585. }
  1586. declare module BABYLON {
  1587. /** @hidden */
  1588. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1589. define: string;
  1590. not: boolean;
  1591. constructor(define: string, not?: boolean);
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. }
  1596. }
  1597. declare module BABYLON {
  1598. /** @hidden */
  1599. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1600. leftOperand: ShaderDefineExpression;
  1601. rightOperand: ShaderDefineExpression;
  1602. isTrue(preprocessors: {
  1603. [key: string]: string;
  1604. }): boolean;
  1605. }
  1606. }
  1607. declare module BABYLON {
  1608. /** @hidden */
  1609. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1610. leftOperand: ShaderDefineExpression;
  1611. rightOperand: ShaderDefineExpression;
  1612. isTrue(preprocessors: {
  1613. [key: string]: string;
  1614. }): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /** @hidden */
  1619. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1620. define: string;
  1621. operand: string;
  1622. testValue: string;
  1623. constructor(define: string, operand: string, testValue: string);
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Class used to enable access to offline support
  1632. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1633. */
  1634. export interface IOfflineProvider {
  1635. /**
  1636. * Gets a boolean indicating if scene must be saved in the database
  1637. */
  1638. enableSceneOffline: boolean;
  1639. /**
  1640. * Gets a boolean indicating if textures must be saved in the database
  1641. */
  1642. enableTexturesOffline: boolean;
  1643. /**
  1644. * Open the offline support and make it available
  1645. * @param successCallback defines the callback to call on success
  1646. * @param errorCallback defines the callback to call on error
  1647. */
  1648. open(successCallback: () => void, errorCallback: () => void): void;
  1649. /**
  1650. * Loads an image from the offline support
  1651. * @param url defines the url to load from
  1652. * @param image defines the target DOM image
  1653. */
  1654. loadImage(url: string, image: HTMLImageElement): void;
  1655. /**
  1656. * Loads a file from offline support
  1657. * @param url defines the URL to load from
  1658. * @param sceneLoaded defines a callback to call on success
  1659. * @param progressCallBack defines a callback to call when progress changed
  1660. * @param errorCallback defines a callback to call on error
  1661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1662. */
  1663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to help managing file picking and drag'n'drop
  1669. * File Storage
  1670. */
  1671. export class FilesInputStore {
  1672. /**
  1673. * List of files ready to be loaded
  1674. */
  1675. static FilesToLoad: {
  1676. [key: string]: File;
  1677. };
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Class used to define a retry strategy when error happens while loading assets
  1683. */
  1684. export class RetryStrategy {
  1685. /**
  1686. * Function used to defines an exponential back off strategy
  1687. * @param maxRetries defines the maximum number of retries (3 by default)
  1688. * @param baseInterval defines the interval between retries
  1689. * @returns the strategy function to use
  1690. */
  1691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1692. }
  1693. }
  1694. declare module BABYLON {
  1695. /**
  1696. * @ignore
  1697. * Application error to support additional information when loading a file
  1698. */
  1699. export abstract class BaseError extends Error {
  1700. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1701. }
  1702. }
  1703. declare module BABYLON {
  1704. /** @ignore */
  1705. export class LoadFileError extends BaseError {
  1706. request?: WebRequest;
  1707. file?: File;
  1708. /**
  1709. * Creates a new LoadFileError
  1710. * @param message defines the message of the error
  1711. * @param request defines the optional web request
  1712. * @param file defines the optional file
  1713. */
  1714. constructor(message: string, object?: WebRequest | File);
  1715. }
  1716. /** @ignore */
  1717. export class RequestFileError extends BaseError {
  1718. request: WebRequest;
  1719. /**
  1720. * Creates a new LoadFileError
  1721. * @param message defines the message of the error
  1722. * @param request defines the optional web request
  1723. */
  1724. constructor(message: string, request: WebRequest);
  1725. }
  1726. /** @ignore */
  1727. export class ReadFileError extends BaseError {
  1728. file: File;
  1729. /**
  1730. * Creates a new ReadFileError
  1731. * @param message defines the message of the error
  1732. * @param file defines the optional file
  1733. */
  1734. constructor(message: string, file: File);
  1735. }
  1736. /**
  1737. * @hidden
  1738. */
  1739. export class FileTools {
  1740. /**
  1741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1742. */
  1743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1744. /**
  1745. * Gets or sets the base URL to use to load assets
  1746. */
  1747. static BaseUrl: string;
  1748. /**
  1749. * Default behaviour for cors in the application.
  1750. * It can be a string if the expected behavior is identical in the entire app.
  1751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1752. */
  1753. static CorsBehavior: string | ((url: string | string[]) => string);
  1754. /**
  1755. * Gets or sets a function used to pre-process url before using them to load assets
  1756. */
  1757. static PreprocessUrl: (url: string) => string;
  1758. /**
  1759. * Removes unwanted characters from an url
  1760. * @param url defines the url to clean
  1761. * @returns the cleaned url
  1762. */
  1763. private static _CleanUrl;
  1764. /**
  1765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1766. * @param url define the url we are trying
  1767. * @param element define the dom element where to configure the cors policy
  1768. */
  1769. static SetCorsBehavior(url: string | string[], element: {
  1770. crossOrigin: string | null;
  1771. }): void;
  1772. /**
  1773. * Loads an image as an HTMLImageElement.
  1774. * @param input url string, ArrayBuffer, or Blob to load
  1775. * @param onLoad callback called when the image successfully loads
  1776. * @param onError callback called when the image fails to load
  1777. * @param offlineProvider offline provider for caching
  1778. * @param mimeType optional mime type
  1779. * @returns the HTMLImageElement of the loaded image
  1780. */
  1781. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1782. /**
  1783. * Reads a file from a File object
  1784. * @param file defines the file to load
  1785. * @param onSuccess defines the callback to call when data is loaded
  1786. * @param onProgress defines the callback to call during loading process
  1787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1788. * @param onError defines the callback to call when an error occurs
  1789. * @returns a file request object
  1790. */
  1791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1792. /**
  1793. * Loads a file from a url
  1794. * @param url url to load
  1795. * @param onSuccess callback called when the file successfully loads
  1796. * @param onProgress callback called while file is loading (if the server supports this mode)
  1797. * @param offlineProvider defines the offline provider for caching
  1798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1799. * @param onError callback called when the file fails to load
  1800. * @returns a file request object
  1801. */
  1802. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1803. /**
  1804. * Loads a file
  1805. * @param url url to load
  1806. * @param onSuccess callback called when the file successfully loads
  1807. * @param onProgress callback called while file is loading (if the server supports this mode)
  1808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1809. * @param onError callback called when the file fails to load
  1810. * @param onOpened callback called when the web request is opened
  1811. * @returns a file request object
  1812. */
  1813. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1814. /**
  1815. * Checks if the loaded document was accessed via `file:`-Protocol.
  1816. * @returns boolean
  1817. */
  1818. static IsFileURL(): boolean;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /** @hidden */
  1823. export class ShaderProcessor {
  1824. static Initialize(options: ProcessingOptions): void;
  1825. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1826. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1827. vertexCode: string;
  1828. fragmentCode: string;
  1829. };
  1830. private static _ProcessPrecision;
  1831. private static _ExtractOperation;
  1832. private static _BuildSubExpression;
  1833. private static _BuildExpression;
  1834. private static _MoveCursorWithinIf;
  1835. private static _MoveCursor;
  1836. private static _EvaluatePreProcessors;
  1837. private static _PreparePreProcessors;
  1838. private static _ProcessShaderConversion;
  1839. private static _ProcessIncludes;
  1840. /**
  1841. * Loads a file from a url
  1842. * @param url url to load
  1843. * @param onSuccess callback called when the file successfully loads
  1844. * @param onProgress callback called while file is loading (if the server supports this mode)
  1845. * @param offlineProvider defines the offline provider for caching
  1846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1847. * @param onError callback called when the file fails to load
  1848. * @returns a file request object
  1849. * @hidden
  1850. */
  1851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1852. }
  1853. }
  1854. declare module BABYLON {
  1855. /**
  1856. * Interface used to define common properties for effect fallbacks
  1857. */
  1858. export interface IEffectFallbacks {
  1859. /**
  1860. * Removes the defines that should be removed when falling back.
  1861. * @param currentDefines defines the current define statements for the shader.
  1862. * @param effect defines the current effect we try to compile
  1863. * @returns The resulting defines with defines of the current rank removed.
  1864. */
  1865. reduce(currentDefines: string, effect: Effect): string;
  1866. /**
  1867. * Removes the fallback from the bound mesh.
  1868. */
  1869. unBindMesh(): void;
  1870. /**
  1871. * Checks to see if more fallbacks are still available.
  1872. */
  1873. hasMoreFallbacks: boolean;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Interface for the size containing width and height
  1879. */
  1880. export interface ISize {
  1881. /**
  1882. * Width
  1883. */
  1884. width: number;
  1885. /**
  1886. * Heighht
  1887. */
  1888. height: number;
  1889. }
  1890. /**
  1891. * Size containing widht and height
  1892. */
  1893. export class Size implements ISize {
  1894. /**
  1895. * Width
  1896. */
  1897. width: number;
  1898. /**
  1899. * Height
  1900. */
  1901. height: number;
  1902. /**
  1903. * Creates a Size object from the given width and height (floats).
  1904. * @param width width of the new size
  1905. * @param height height of the new size
  1906. */
  1907. constructor(width: number, height: number);
  1908. /**
  1909. * Returns a string with the Size width and height
  1910. * @returns a string with the Size width and height
  1911. */
  1912. toString(): string;
  1913. /**
  1914. * "Size"
  1915. * @returns the string "Size"
  1916. */
  1917. getClassName(): string;
  1918. /**
  1919. * Returns the Size hash code.
  1920. * @returns a hash code for a unique width and height
  1921. */
  1922. getHashCode(): number;
  1923. /**
  1924. * Updates the current size from the given one.
  1925. * @param src the given size
  1926. */
  1927. copyFrom(src: Size): void;
  1928. /**
  1929. * Updates in place the current Size from the given floats.
  1930. * @param width width of the new size
  1931. * @param height height of the new size
  1932. * @returns the updated Size.
  1933. */
  1934. copyFromFloats(width: number, height: number): Size;
  1935. /**
  1936. * Updates in place the current Size from the given floats.
  1937. * @param width width to set
  1938. * @param height height to set
  1939. * @returns the updated Size.
  1940. */
  1941. set(width: number, height: number): Size;
  1942. /**
  1943. * Multiplies the width and height by numbers
  1944. * @param w factor to multiple the width by
  1945. * @param h factor to multiple the height by
  1946. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1947. */
  1948. multiplyByFloats(w: number, h: number): Size;
  1949. /**
  1950. * Clones the size
  1951. * @returns a new Size copied from the given one.
  1952. */
  1953. clone(): Size;
  1954. /**
  1955. * True if the current Size and the given one width and height are strictly equal.
  1956. * @param other the other size to compare against
  1957. * @returns True if the current Size and the given one width and height are strictly equal.
  1958. */
  1959. equals(other: Size): boolean;
  1960. /**
  1961. * The surface of the Size : width * height (float).
  1962. */
  1963. get surface(): number;
  1964. /**
  1965. * Create a new size of zero
  1966. * @returns a new Size set to (0.0, 0.0)
  1967. */
  1968. static Zero(): Size;
  1969. /**
  1970. * Sums the width and height of two sizes
  1971. * @param otherSize size to add to this size
  1972. * @returns a new Size set as the addition result of the current Size and the given one.
  1973. */
  1974. add(otherSize: Size): Size;
  1975. /**
  1976. * Subtracts the width and height of two
  1977. * @param otherSize size to subtract to this size
  1978. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1979. */
  1980. subtract(otherSize: Size): Size;
  1981. /**
  1982. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1983. * @param start starting size to lerp between
  1984. * @param end end size to lerp between
  1985. * @param amount amount to lerp between the start and end values
  1986. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1987. */
  1988. static Lerp(start: Size, end: Size, amount: number): Size;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Base class of all the textures in babylon.
  1994. * It groups all the common properties required to work with Thin Engine.
  1995. */
  1996. export class ThinTexture {
  1997. protected _wrapU: number;
  1998. /**
  1999. * | Value | Type | Description |
  2000. * | ----- | ------------------ | ----------- |
  2001. * | 0 | CLAMP_ADDRESSMODE | |
  2002. * | 1 | WRAP_ADDRESSMODE | |
  2003. * | 2 | MIRROR_ADDRESSMODE | |
  2004. */
  2005. get wrapU(): number;
  2006. set wrapU(value: number);
  2007. protected _wrapV: number;
  2008. /**
  2009. * | Value | Type | Description |
  2010. * | ----- | ------------------ | ----------- |
  2011. * | 0 | CLAMP_ADDRESSMODE | |
  2012. * | 1 | WRAP_ADDRESSMODE | |
  2013. * | 2 | MIRROR_ADDRESSMODE | |
  2014. */
  2015. get wrapV(): number;
  2016. set wrapV(value: number);
  2017. /**
  2018. * | Value | Type | Description |
  2019. * | ----- | ------------------ | ----------- |
  2020. * | 0 | CLAMP_ADDRESSMODE | |
  2021. * | 1 | WRAP_ADDRESSMODE | |
  2022. * | 2 | MIRROR_ADDRESSMODE | |
  2023. */
  2024. wrapR: number;
  2025. /**
  2026. * With compliant hardware and browser (supporting anisotropic filtering)
  2027. * this defines the level of anisotropic filtering in the texture.
  2028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2029. */
  2030. anisotropicFilteringLevel: number;
  2031. /**
  2032. * Define the current state of the loading sequence when in delayed load mode.
  2033. */
  2034. delayLoadState: number;
  2035. /**
  2036. * How a texture is mapped.
  2037. * Unused in thin texture mode.
  2038. */
  2039. get coordinatesMode(): number;
  2040. /**
  2041. * Define if the texture is a cube texture or if false a 2d texture.
  2042. */
  2043. get isCube(): boolean;
  2044. set isCube(value: boolean);
  2045. /**
  2046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is3D(): boolean;
  2049. set is3D(value: boolean);
  2050. /**
  2051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2052. */
  2053. get is2DArray(): boolean;
  2054. set is2DArray(value: boolean);
  2055. /**
  2056. * Get the class name of the texture.
  2057. * @returns "ThinTexture"
  2058. */
  2059. getClassName(): string;
  2060. /** @hidden */
  2061. _texture: Nullable<InternalTexture>;
  2062. protected _engine: Nullable<ThinEngine>;
  2063. private _cachedSize;
  2064. private _cachedBaseSize;
  2065. /**
  2066. * Instantiates a new ThinTexture.
  2067. * Base class of all the textures in babylon.
  2068. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2069. * @param internalTexture Define the internalTexture to wrap
  2070. */
  2071. constructor(internalTexture: Nullable<InternalTexture>);
  2072. /**
  2073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2074. * @returns true if fully ready
  2075. */
  2076. isReady(): boolean;
  2077. /**
  2078. * Triggers the load sequence in delayed load mode.
  2079. */
  2080. delayLoad(): void;
  2081. /**
  2082. * Get the underlying lower level texture from Babylon.
  2083. * @returns the internal texture
  2084. */
  2085. getInternalTexture(): Nullable<InternalTexture>;
  2086. /**
  2087. * Get the size of the texture.
  2088. * @returns the texture size.
  2089. */
  2090. getSize(): ISize;
  2091. /**
  2092. * Get the base size of the texture.
  2093. * It can be different from the size if the texture has been resized for POT for instance
  2094. * @returns the base size
  2095. */
  2096. getBaseSize(): ISize;
  2097. /**
  2098. * Update the sampling mode of the texture.
  2099. * Default is Trilinear mode.
  2100. *
  2101. * | Value | Type | Description |
  2102. * | ----- | ------------------ | ----------- |
  2103. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2104. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2105. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2106. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2107. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2108. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2109. * | 7 | NEAREST_LINEAR | |
  2110. * | 8 | NEAREST_NEAREST | |
  2111. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2112. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2113. * | 11 | LINEAR_LINEAR | |
  2114. * | 12 | LINEAR_NEAREST | |
  2115. *
  2116. * > _mag_: magnification filter (close to the viewer)
  2117. * > _min_: minification filter (far from the viewer)
  2118. * > _mip_: filter used between mip map levels
  2119. *@param samplingMode Define the new sampling mode of the texture
  2120. */
  2121. updateSamplingMode(samplingMode: number): void;
  2122. /**
  2123. * Release and destroy the underlying lower level texture aka internalTexture.
  2124. */
  2125. releaseInternalTexture(): void;
  2126. /**
  2127. * Dispose the texture and release its associated resources.
  2128. */
  2129. dispose(): void;
  2130. }
  2131. }
  2132. declare module BABYLON {
  2133. /**
  2134. * Defines an array and its length.
  2135. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2136. */
  2137. export interface ISmartArrayLike<T> {
  2138. /**
  2139. * The data of the array.
  2140. */
  2141. data: Array<T>;
  2142. /**
  2143. * The active length of the array.
  2144. */
  2145. length: number;
  2146. }
  2147. /**
  2148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2149. */
  2150. export class SmartArray<T> implements ISmartArrayLike<T> {
  2151. /**
  2152. * The full set of data from the array.
  2153. */
  2154. data: Array<T>;
  2155. /**
  2156. * The active length of the array.
  2157. */
  2158. length: number;
  2159. protected _id: number;
  2160. /**
  2161. * Instantiates a Smart Array.
  2162. * @param capacity defines the default capacity of the array.
  2163. */
  2164. constructor(capacity: number);
  2165. /**
  2166. * Pushes a value at the end of the active data.
  2167. * @param value defines the object to push in the array.
  2168. */
  2169. push(value: T): void;
  2170. /**
  2171. * Iterates over the active data and apply the lambda to them.
  2172. * @param func defines the action to apply on each value.
  2173. */
  2174. forEach(func: (content: T) => void): void;
  2175. /**
  2176. * Sorts the full sets of data.
  2177. * @param compareFn defines the comparison function to apply.
  2178. */
  2179. sort(compareFn: (a: T, b: T) => number): void;
  2180. /**
  2181. * Resets the active data to an empty array.
  2182. */
  2183. reset(): void;
  2184. /**
  2185. * Releases all the data from the array as well as the array.
  2186. */
  2187. dispose(): void;
  2188. /**
  2189. * Concats the active data with a given array.
  2190. * @param array defines the data to concatenate with.
  2191. */
  2192. concat(array: any): void;
  2193. /**
  2194. * Returns the position of a value in the active data.
  2195. * @param value defines the value to find the index for
  2196. * @returns the index if found in the active data otherwise -1
  2197. */
  2198. indexOf(value: T): number;
  2199. /**
  2200. * Returns whether an element is part of the active data.
  2201. * @param value defines the value to look for
  2202. * @returns true if found in the active data otherwise false
  2203. */
  2204. contains(value: T): boolean;
  2205. private static _GlobalId;
  2206. }
  2207. /**
  2208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2209. * The data in this array can only be present once
  2210. */
  2211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2212. private _duplicateId;
  2213. /**
  2214. * Pushes a value at the end of the active data.
  2215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2216. * @param value defines the object to push in the array.
  2217. */
  2218. push(value: T): void;
  2219. /**
  2220. * Pushes a value at the end of the active data.
  2221. * If the data is already present, it won t be added again
  2222. * @param value defines the object to push in the array.
  2223. * @returns true if added false if it was already present
  2224. */
  2225. pushNoDuplicate(value: T): boolean;
  2226. /**
  2227. * Resets the active data to an empty array.
  2228. */
  2229. reset(): void;
  2230. /**
  2231. * Concats the active data with a given array.
  2232. * This ensures no duplicate will be present in the result.
  2233. * @param array defines the data to concatenate with.
  2234. */
  2235. concatWithNoDuplicate(array: any): void;
  2236. }
  2237. }
  2238. declare module BABYLON {
  2239. /**
  2240. * Class used to evaluate queries containing `and` and `or` operators
  2241. */
  2242. export class AndOrNotEvaluator {
  2243. /**
  2244. * Evaluate a query
  2245. * @param query defines the query to evaluate
  2246. * @param evaluateCallback defines the callback used to filter result
  2247. * @returns true if the query matches
  2248. */
  2249. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2250. private static _HandleParenthesisContent;
  2251. private static _SimplifyNegation;
  2252. }
  2253. }
  2254. declare module BABYLON {
  2255. /**
  2256. * Class used to store custom tags
  2257. */
  2258. export class Tags {
  2259. /**
  2260. * Adds support for tags on the given object
  2261. * @param obj defines the object to use
  2262. */
  2263. static EnableFor(obj: any): void;
  2264. /**
  2265. * Removes tags support
  2266. * @param obj defines the object to use
  2267. */
  2268. static DisableFor(obj: any): void;
  2269. /**
  2270. * Gets a boolean indicating if the given object has tags
  2271. * @param obj defines the object to use
  2272. * @returns a boolean
  2273. */
  2274. static HasTags(obj: any): boolean;
  2275. /**
  2276. * Gets the tags available on a given object
  2277. * @param obj defines the object to use
  2278. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2279. * @returns the tags
  2280. */
  2281. static GetTags(obj: any, asString?: boolean): any;
  2282. /**
  2283. * Adds tags to an object
  2284. * @param obj defines the object to use
  2285. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2286. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2287. */
  2288. static AddTagsTo(obj: any, tagsString: string): void;
  2289. /**
  2290. * @hidden
  2291. */
  2292. static _AddTagTo(obj: any, tag: string): void;
  2293. /**
  2294. * Removes specific tags from a specific object
  2295. * @param obj defines the object to use
  2296. * @param tagsString defines the tags to remove
  2297. */
  2298. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2299. /**
  2300. * @hidden
  2301. */
  2302. static _RemoveTagFrom(obj: any, tag: string): void;
  2303. /**
  2304. * Defines if tags hosted on an object match a given query
  2305. * @param obj defines the object to use
  2306. * @param tagsQuery defines the tag query
  2307. * @returns a boolean
  2308. */
  2309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2310. }
  2311. }
  2312. declare module BABYLON {
  2313. /**
  2314. * Scalar computation library
  2315. */
  2316. export class Scalar {
  2317. /**
  2318. * Two pi constants convenient for computation.
  2319. */
  2320. static TwoPi: number;
  2321. /**
  2322. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2323. * @param a number
  2324. * @param b number
  2325. * @param epsilon (default = 1.401298E-45)
  2326. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2327. */
  2328. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2329. /**
  2330. * Returns a string : the upper case translation of the number i to hexadecimal.
  2331. * @param i number
  2332. * @returns the upper case translation of the number i to hexadecimal.
  2333. */
  2334. static ToHex(i: number): string;
  2335. /**
  2336. * Returns -1 if value is negative and +1 is value is positive.
  2337. * @param value the value
  2338. * @returns the value itself if it's equal to zero.
  2339. */
  2340. static Sign(value: number): number;
  2341. /**
  2342. * Returns the value itself if it's between min and max.
  2343. * Returns min if the value is lower than min.
  2344. * Returns max if the value is greater than max.
  2345. * @param value the value to clmap
  2346. * @param min the min value to clamp to (default: 0)
  2347. * @param max the max value to clamp to (default: 1)
  2348. * @returns the clamped value
  2349. */
  2350. static Clamp(value: number, min?: number, max?: number): number;
  2351. /**
  2352. * the log2 of value.
  2353. * @param value the value to compute log2 of
  2354. * @returns the log2 of value.
  2355. */
  2356. static Log2(value: number): number;
  2357. /**
  2358. * the floor part of a log2 value.
  2359. * @param value the value to compute log2 of
  2360. * @returns the log2 of value.
  2361. */
  2362. static ILog2(value: number): number;
  2363. /**
  2364. * Loops the value, so that it is never larger than length and never smaller than 0.
  2365. *
  2366. * This is similar to the modulo operator but it works with floating point numbers.
  2367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2368. * With t = 5 and length = 2.5, the result would be 0.0.
  2369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2370. * @param value the value
  2371. * @param length the length
  2372. * @returns the looped value
  2373. */
  2374. static Repeat(value: number, length: number): number;
  2375. /**
  2376. * Normalize the value between 0.0 and 1.0 using min and max values
  2377. * @param value value to normalize
  2378. * @param min max to normalize between
  2379. * @param max min to normalize between
  2380. * @returns the normalized value
  2381. */
  2382. static Normalize(value: number, min: number, max: number): number;
  2383. /**
  2384. * Denormalize the value from 0.0 and 1.0 using min and max values
  2385. * @param normalized value to denormalize
  2386. * @param min max to denormalize between
  2387. * @param max min to denormalize between
  2388. * @returns the denormalized value
  2389. */
  2390. static Denormalize(normalized: number, min: number, max: number): number;
  2391. /**
  2392. * Calculates the shortest difference between two given angles given in degrees.
  2393. * @param current current angle in degrees
  2394. * @param target target angle in degrees
  2395. * @returns the delta
  2396. */
  2397. static DeltaAngle(current: number, target: number): number;
  2398. /**
  2399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2400. * @param tx value
  2401. * @param length length
  2402. * @returns The returned value will move back and forth between 0 and length
  2403. */
  2404. static PingPong(tx: number, length: number): number;
  2405. /**
  2406. * Interpolates between min and max with smoothing at the limits.
  2407. *
  2408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2410. * @param from from
  2411. * @param to to
  2412. * @param tx value
  2413. * @returns the smooth stepped value
  2414. */
  2415. static SmoothStep(from: number, to: number, tx: number): number;
  2416. /**
  2417. * Moves a value current towards target.
  2418. *
  2419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2420. * Negative values of maxDelta pushes the value away from target.
  2421. * @param current current value
  2422. * @param target target value
  2423. * @param maxDelta max distance to move
  2424. * @returns resulting value
  2425. */
  2426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2427. /**
  2428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2429. *
  2430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2432. * @param current current value
  2433. * @param target target value
  2434. * @param maxDelta max distance to move
  2435. * @returns resulting angle
  2436. */
  2437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2438. /**
  2439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2440. * @param start start value
  2441. * @param end target value
  2442. * @param amount amount to lerp between
  2443. * @returns the lerped value
  2444. */
  2445. static Lerp(start: number, end: number, amount: number): number;
  2446. /**
  2447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2449. * @param start start value
  2450. * @param end target value
  2451. * @param amount amount to lerp between
  2452. * @returns the lerped value
  2453. */
  2454. static LerpAngle(start: number, end: number, amount: number): number;
  2455. /**
  2456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2457. * @param a start value
  2458. * @param b target value
  2459. * @param value value between a and b
  2460. * @returns the inverseLerp value
  2461. */
  2462. static InverseLerp(a: number, b: number, value: number): number;
  2463. /**
  2464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2466. * @param value1 spline value
  2467. * @param tangent1 spline value
  2468. * @param value2 spline value
  2469. * @param tangent2 spline value
  2470. * @param amount input value
  2471. * @returns hermite result
  2472. */
  2473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2474. /**
  2475. * Returns a random float number between and min and max values
  2476. * @param min min value of random
  2477. * @param max max value of random
  2478. * @returns random value
  2479. */
  2480. static RandomRange(min: number, max: number): number;
  2481. /**
  2482. * This function returns percentage of a number in a given range.
  2483. *
  2484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2486. * @param number to convert to percentage
  2487. * @param min min range
  2488. * @param max max range
  2489. * @returns the percentage
  2490. */
  2491. static RangeToPercent(number: number, min: number, max: number): number;
  2492. /**
  2493. * This function returns number that corresponds to the percentage in a given range.
  2494. *
  2495. * PercentToRange(0.34,0,100) will return 34.
  2496. * @param percent to convert to number
  2497. * @param min min range
  2498. * @param max max range
  2499. * @returns the number
  2500. */
  2501. static PercentToRange(percent: number, min: number, max: number): number;
  2502. /**
  2503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2504. * @param angle The angle to normalize in radian.
  2505. * @return The converted angle.
  2506. */
  2507. static NormalizeRadians(angle: number): number;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Constant used to convert a value to gamma space
  2513. * @ignorenaming
  2514. */
  2515. export const ToGammaSpace: number;
  2516. /**
  2517. * Constant used to convert a value to linear space
  2518. * @ignorenaming
  2519. */
  2520. export const ToLinearSpace = 2.2;
  2521. /**
  2522. * Constant used to define the minimal number value in Babylon.js
  2523. * @ignorenaming
  2524. */
  2525. let Epsilon: number;
  2526. }
  2527. declare module BABYLON {
  2528. /**
  2529. * Class used to represent a viewport on screen
  2530. */
  2531. export class Viewport {
  2532. /** viewport left coordinate */
  2533. x: number;
  2534. /** viewport top coordinate */
  2535. y: number;
  2536. /**viewport width */
  2537. width: number;
  2538. /** viewport height */
  2539. height: number;
  2540. /**
  2541. * Creates a Viewport object located at (x, y) and sized (width, height)
  2542. * @param x defines viewport left coordinate
  2543. * @param y defines viewport top coordinate
  2544. * @param width defines the viewport width
  2545. * @param height defines the viewport height
  2546. */
  2547. constructor(
  2548. /** viewport left coordinate */
  2549. x: number,
  2550. /** viewport top coordinate */
  2551. y: number,
  2552. /**viewport width */
  2553. width: number,
  2554. /** viewport height */
  2555. height: number);
  2556. /**
  2557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2558. * @param renderWidth defines the rendering width
  2559. * @param renderHeight defines the rendering height
  2560. * @returns a new Viewport
  2561. */
  2562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2563. /**
  2564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2565. * @param renderWidth defines the rendering width
  2566. * @param renderHeight defines the rendering height
  2567. * @param ref defines the target viewport
  2568. * @returns the current viewport
  2569. */
  2570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2571. /**
  2572. * Returns a new Viewport copied from the current one
  2573. * @returns a new Viewport
  2574. */
  2575. clone(): Viewport;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Class containing a set of static utilities functions for arrays.
  2581. */
  2582. export class ArrayTools {
  2583. /**
  2584. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2585. * @param size the number of element to construct and put in the array
  2586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2587. * @returns a new array filled with new objects
  2588. */
  2589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /**
  2594. * Represents a plane by the equation ax + by + cz + d = 0
  2595. */
  2596. export class Plane {
  2597. private static _TmpMatrix;
  2598. /**
  2599. * Normal of the plane (a,b,c)
  2600. */
  2601. normal: Vector3;
  2602. /**
  2603. * d component of the plane
  2604. */
  2605. d: number;
  2606. /**
  2607. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2608. * @param a a component of the plane
  2609. * @param b b component of the plane
  2610. * @param c c component of the plane
  2611. * @param d d component of the plane
  2612. */
  2613. constructor(a: number, b: number, c: number, d: number);
  2614. /**
  2615. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2616. */
  2617. asArray(): number[];
  2618. /**
  2619. * @returns a new plane copied from the current Plane.
  2620. */
  2621. clone(): Plane;
  2622. /**
  2623. * @returns the string "Plane".
  2624. */
  2625. getClassName(): string;
  2626. /**
  2627. * @returns the Plane hash code.
  2628. */
  2629. getHashCode(): number;
  2630. /**
  2631. * Normalize the current Plane in place.
  2632. * @returns the updated Plane.
  2633. */
  2634. normalize(): Plane;
  2635. /**
  2636. * Applies a transformation the plane and returns the result
  2637. * @param transformation the transformation matrix to be applied to the plane
  2638. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2639. */
  2640. transform(transformation: DeepImmutable<Matrix>): Plane;
  2641. /**
  2642. * Compute the dot product between the point and the plane normal
  2643. * @param point point to calculate the dot product with
  2644. * @returns the dot product (float) of the point coordinates and the plane normal.
  2645. */
  2646. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2647. /**
  2648. * Updates the current Plane from the plane defined by the three given points.
  2649. * @param point1 one of the points used to contruct the plane
  2650. * @param point2 one of the points used to contruct the plane
  2651. * @param point3 one of the points used to contruct the plane
  2652. * @returns the updated Plane.
  2653. */
  2654. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2655. /**
  2656. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2657. * Note that for this function to work as expected you should make sure that:
  2658. * - direction and the plane normal are normalized
  2659. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2660. * @param direction the direction to check if the plane is facing
  2661. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2662. * @returns True if the plane is facing the given direction
  2663. */
  2664. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2665. /**
  2666. * Calculates the distance to a point
  2667. * @param point point to calculate distance to
  2668. * @returns the signed distance (float) from the given point to the Plane.
  2669. */
  2670. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Creates a plane from an array
  2673. * @param array the array to create a plane from
  2674. * @returns a new Plane from the given array.
  2675. */
  2676. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2677. /**
  2678. * Creates a plane from three points
  2679. * @param point1 point used to create the plane
  2680. * @param point2 point used to create the plane
  2681. * @param point3 point used to create the plane
  2682. * @returns a new Plane defined by the three given points.
  2683. */
  2684. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * Creates a plane from an origin point and a normal
  2687. * @param origin origin of the plane to be constructed
  2688. * @param normal normal of the plane to be constructed
  2689. * @returns a new Plane the normal vector to this plane at the given origin point.
  2690. * Note : the vector "normal" is updated because normalized.
  2691. */
  2692. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2693. /**
  2694. * Calculates the distance from a plane and a point
  2695. * @param origin origin of the plane to be constructed
  2696. * @param normal normal of the plane to be constructed
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2699. */
  2700. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. /** @hidden */
  2705. export class PerformanceConfigurator {
  2706. /** @hidden */
  2707. static MatrixUse64Bits: boolean;
  2708. /** @hidden */
  2709. static MatrixTrackPrecisionChange: boolean;
  2710. /** @hidden */
  2711. static MatrixCurrentType: any;
  2712. /** @hidden */
  2713. static MatrixTrackedMatrices: Array<any> | null;
  2714. /** @hidden */
  2715. static SetMatrixPrecision(use64bits: boolean): void;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * Class representing a vector containing 2 coordinates
  2721. */
  2722. export class Vector2 {
  2723. /** defines the first coordinate */
  2724. x: number;
  2725. /** defines the second coordinate */
  2726. y: number;
  2727. /**
  2728. * Creates a new Vector2 from the given x and y coordinates
  2729. * @param x defines the first coordinate
  2730. * @param y defines the second coordinate
  2731. */
  2732. constructor(
  2733. /** defines the first coordinate */
  2734. x?: number,
  2735. /** defines the second coordinate */
  2736. y?: number);
  2737. /**
  2738. * Gets a string with the Vector2 coordinates
  2739. * @returns a string with the Vector2 coordinates
  2740. */
  2741. toString(): string;
  2742. /**
  2743. * Gets class name
  2744. * @returns the string "Vector2"
  2745. */
  2746. getClassName(): string;
  2747. /**
  2748. * Gets current vector hash code
  2749. * @returns the Vector2 hash code as a number
  2750. */
  2751. getHashCode(): number;
  2752. /**
  2753. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2754. * @param array defines the source array
  2755. * @param index defines the offset in source array
  2756. * @returns the current Vector2
  2757. */
  2758. toArray(array: FloatArray, index?: number): Vector2;
  2759. /**
  2760. * Update the current vector from an array
  2761. * @param array defines the destination array
  2762. * @param index defines the offset in the destination array
  2763. * @returns the current Vector3
  2764. */
  2765. fromArray(array: FloatArray, index?: number): Vector2;
  2766. /**
  2767. * Copy the current vector to an array
  2768. * @returns a new array with 2 elements: the Vector2 coordinates.
  2769. */
  2770. asArray(): number[];
  2771. /**
  2772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2773. * @param source defines the source Vector2
  2774. * @returns the current updated Vector2
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2777. /**
  2778. * Sets the Vector2 coordinates with the given floats
  2779. * @param x defines the first coordinate
  2780. * @param y defines the second coordinate
  2781. * @returns the current updated Vector2
  2782. */
  2783. copyFromFloats(x: number, y: number): Vector2;
  2784. /**
  2785. * Sets the Vector2 coordinates with the given floats
  2786. * @param x defines the first coordinate
  2787. * @param y defines the second coordinate
  2788. * @returns the current updated Vector2
  2789. */
  2790. set(x: number, y: number): Vector2;
  2791. /**
  2792. * Add another vector with the current one
  2793. * @param otherVector defines the other vector
  2794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2795. */
  2796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2797. /**
  2798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2799. * @param otherVector defines the other vector
  2800. * @param result defines the target vector
  2801. * @returns the unmodified current Vector2
  2802. */
  2803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2804. /**
  2805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2806. * @param otherVector defines the other vector
  2807. * @returns the current updated Vector2
  2808. */
  2809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2810. /**
  2811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2812. * @param otherVector defines the other vector
  2813. * @returns a new Vector2
  2814. */
  2815. addVector3(otherVector: Vector3): Vector2;
  2816. /**
  2817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2818. * @param otherVector defines the other vector
  2819. * @returns a new Vector2
  2820. */
  2821. subtract(otherVector: Vector2): Vector2;
  2822. /**
  2823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2824. * @param otherVector defines the other vector
  2825. * @param result defines the target vector
  2826. * @returns the unmodified current Vector2
  2827. */
  2828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2829. /**
  2830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2831. * @param otherVector defines the other vector
  2832. * @returns the current updated Vector2
  2833. */
  2834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2835. /**
  2836. * Multiplies in place the current Vector2 coordinates by the given ones
  2837. * @param otherVector defines the other vector
  2838. * @returns the current updated Vector2
  2839. */
  2840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2841. /**
  2842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2843. * @param otherVector defines the other vector
  2844. * @returns a new Vector2
  2845. */
  2846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2847. /**
  2848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @param result defines the target vector
  2851. * @returns the unmodified current Vector2
  2852. */
  2853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2854. /**
  2855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2856. * @param x defines the first coordinate
  2857. * @param y defines the second coordinate
  2858. * @returns a new Vector2
  2859. */
  2860. multiplyByFloats(x: number, y: number): Vector2;
  2861. /**
  2862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2863. * @param otherVector defines the other vector
  2864. * @returns a new Vector2
  2865. */
  2866. divide(otherVector: Vector2): Vector2;
  2867. /**
  2868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2869. * @param otherVector defines the other vector
  2870. * @param result defines the target vector
  2871. * @returns the unmodified current Vector2
  2872. */
  2873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2874. /**
  2875. * Divides the current Vector2 coordinates by the given ones
  2876. * @param otherVector defines the other vector
  2877. * @returns the current updated Vector2
  2878. */
  2879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets a new Vector2 with current Vector2 negated coordinates
  2882. * @returns a new Vector2
  2883. */
  2884. negate(): Vector2;
  2885. /**
  2886. * Negate this vector in place
  2887. * @returns this
  2888. */
  2889. negateInPlace(): Vector2;
  2890. /**
  2891. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2892. * @param result defines the Vector3 object where to store the result
  2893. * @returns the current Vector2
  2894. */
  2895. negateToRef(result: Vector2): Vector2;
  2896. /**
  2897. * Multiply the Vector2 coordinates by scale
  2898. * @param scale defines the scaling factor
  2899. * @returns the current updated Vector2
  2900. */
  2901. scaleInPlace(scale: number): Vector2;
  2902. /**
  2903. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2904. * @param scale defines the scaling factor
  2905. * @returns a new Vector2
  2906. */
  2907. scale(scale: number): Vector2;
  2908. /**
  2909. * Scale the current Vector2 values by a factor to a given Vector2
  2910. * @param scale defines the scale factor
  2911. * @param result defines the Vector2 object where to store the result
  2912. * @returns the unmodified current Vector2
  2913. */
  2914. scaleToRef(scale: number, result: Vector2): Vector2;
  2915. /**
  2916. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2917. * @param scale defines the scale factor
  2918. * @param result defines the Vector2 object where to store the result
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2922. /**
  2923. * Gets a boolean if two vectors are equals
  2924. * @param otherVector defines the other vector
  2925. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2926. */
  2927. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2928. /**
  2929. * Gets a boolean if two vectors are equals (using an epsilon value)
  2930. * @param otherVector defines the other vector
  2931. * @param epsilon defines the minimal distance to consider equality
  2932. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2933. */
  2934. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. floor(): Vector2;
  2940. /**
  2941. * Gets a new Vector2 from current Vector2 floored values
  2942. * @returns a new Vector2
  2943. */
  2944. fract(): Vector2;
  2945. /**
  2946. * Gets the length of the vector
  2947. * @returns the vector length (float)
  2948. */
  2949. length(): number;
  2950. /**
  2951. * Gets the vector squared length
  2952. * @returns the vector squared length (float)
  2953. */
  2954. lengthSquared(): number;
  2955. /**
  2956. * Normalize the vector
  2957. * @returns the current updated Vector2
  2958. */
  2959. normalize(): Vector2;
  2960. /**
  2961. * Gets a new Vector2 copied from the Vector2
  2962. * @returns a new Vector2
  2963. */
  2964. clone(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(0, 0)
  2967. * @returns a new Vector2
  2968. */
  2969. static Zero(): Vector2;
  2970. /**
  2971. * Gets a new Vector2(1, 1)
  2972. * @returns a new Vector2
  2973. */
  2974. static One(): Vector2;
  2975. /**
  2976. * Gets a new Vector2 set from the given index element of the given array
  2977. * @param array defines the data source
  2978. * @param offset defines the offset in the data source
  2979. * @returns a new Vector2
  2980. */
  2981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2982. /**
  2983. * Sets "result" from the given index element of the given array
  2984. * @param array defines the data source
  2985. * @param offset defines the offset in the data source
  2986. * @param result defines the target vector
  2987. */
  2988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2989. /**
  2990. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2991. * @param value1 defines 1st point of control
  2992. * @param value2 defines 2nd point of control
  2993. * @param value3 defines 3rd point of control
  2994. * @param value4 defines 4th point of control
  2995. * @param amount defines the interpolation factor
  2996. * @returns a new Vector2
  2997. */
  2998. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2999. /**
  3000. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  3001. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3002. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3003. * @param value defines the value to clamp
  3004. * @param min defines the lower limit
  3005. * @param max defines the upper limit
  3006. * @returns a new Vector2
  3007. */
  3008. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3009. /**
  3010. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3011. * @param value1 defines the 1st control point
  3012. * @param tangent1 defines the outgoing tangent
  3013. * @param value2 defines the 2nd control point
  3014. * @param tangent2 defines the incoming tangent
  3015. * @param amount defines the interpolation factor
  3016. * @returns a new Vector2
  3017. */
  3018. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3019. /**
  3020. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3021. * @param start defines the start vector
  3022. * @param end defines the end vector
  3023. * @param amount defines the interpolation factor
  3024. * @returns a new Vector2
  3025. */
  3026. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3027. /**
  3028. * Gets the dot product of the vector "left" and the vector "right"
  3029. * @param left defines first vector
  3030. * @param right defines second vector
  3031. * @returns the dot product (float)
  3032. */
  3033. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3034. /**
  3035. * Returns a new Vector2 equal to the normalized given vector
  3036. * @param vector defines the vector to normalize
  3037. * @returns a new Vector2
  3038. */
  3039. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3042. * @param left defines 1st vector
  3043. * @param right defines 2nd vector
  3044. * @returns a new Vector2
  3045. */
  3046. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3047. /**
  3048. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3049. * @param left defines 1st vector
  3050. * @param right defines 2nd vector
  3051. * @returns a new Vector2
  3052. */
  3053. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3054. /**
  3055. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3056. * @param vector defines the vector to transform
  3057. * @param transformation defines the matrix to apply
  3058. * @returns a new Vector2
  3059. */
  3060. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3061. /**
  3062. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3063. * @param vector defines the vector to transform
  3064. * @param transformation defines the matrix to apply
  3065. * @param result defines the target vector
  3066. */
  3067. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3068. /**
  3069. * Determines if a given vector is included in a triangle
  3070. * @param p defines the vector to test
  3071. * @param p0 defines 1st triangle point
  3072. * @param p1 defines 2nd triangle point
  3073. * @param p2 defines 3rd triangle point
  3074. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3075. */
  3076. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3077. /**
  3078. * Gets the distance between the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns the distance between vectors
  3082. */
  3083. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3084. /**
  3085. * Returns the squared distance between the vectors "value1" and "value2"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @returns the squared distance between vectors
  3089. */
  3090. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3091. /**
  3092. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3093. * @param value1 defines first vector
  3094. * @param value2 defines second vector
  3095. * @returns a new Vector2
  3096. */
  3097. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3098. /**
  3099. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3100. * @param value1 defines first vector
  3101. * @param value2 defines second vector
  3102. * @param ref defines third vector
  3103. * @returns ref
  3104. */
  3105. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3106. /**
  3107. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3108. * @param p defines the middle point
  3109. * @param segA defines one point of the segment
  3110. * @param segB defines the other point of the segment
  3111. * @returns the shortest distance
  3112. */
  3113. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3114. }
  3115. /**
  3116. * Class used to store (x,y,z) vector representation
  3117. * A Vector3 is the main object used in 3D geometry
  3118. * It can represent etiher the coordinates of a point the space, either a direction
  3119. * Reminder: js uses a left handed forward facing system
  3120. */
  3121. export class Vector3 {
  3122. private static _UpReadOnly;
  3123. private static _ZeroReadOnly;
  3124. /** @hidden */
  3125. _x: number;
  3126. /** @hidden */
  3127. _y: number;
  3128. /** @hidden */
  3129. _z: number;
  3130. /** @hidden */
  3131. _isDirty: boolean;
  3132. /** Gets or sets the x coordinate */
  3133. get x(): number;
  3134. set x(value: number);
  3135. /** Gets or sets the y coordinate */
  3136. get y(): number;
  3137. set y(value: number);
  3138. /** Gets or sets the z coordinate */
  3139. get z(): number;
  3140. set z(value: number);
  3141. /**
  3142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3143. * @param x defines the first coordinates (on X axis)
  3144. * @param y defines the second coordinates (on Y axis)
  3145. * @param z defines the third coordinates (on Z axis)
  3146. */
  3147. constructor(x?: number, y?: number, z?: number);
  3148. /**
  3149. * Creates a string representation of the Vector3
  3150. * @returns a string with the Vector3 coordinates.
  3151. */
  3152. toString(): string;
  3153. /**
  3154. * Gets the class name
  3155. * @returns the string "Vector3"
  3156. */
  3157. getClassName(): string;
  3158. /**
  3159. * Creates the Vector3 hash code
  3160. * @returns a number which tends to be unique between Vector3 instances
  3161. */
  3162. getHashCode(): number;
  3163. /**
  3164. * Creates an array containing three elements : the coordinates of the Vector3
  3165. * @returns a new array of numbers
  3166. */
  3167. asArray(): number[];
  3168. /**
  3169. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3170. * @param array defines the destination array
  3171. * @param index defines the offset in the destination array
  3172. * @returns the current Vector3
  3173. */
  3174. toArray(array: FloatArray, index?: number): Vector3;
  3175. /**
  3176. * Update the current vector from an array
  3177. * @param array defines the destination array
  3178. * @param index defines the offset in the destination array
  3179. * @returns the current Vector3
  3180. */
  3181. fromArray(array: FloatArray, index?: number): Vector3;
  3182. /**
  3183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3185. */
  3186. toQuaternion(): Quaternion;
  3187. /**
  3188. * Adds the given vector to the current Vector3
  3189. * @param otherVector defines the second operand
  3190. * @returns the current updated Vector3
  3191. */
  3192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the given coordinates to the current Vector3
  3195. * @param x defines the x coordinate of the operand
  3196. * @param y defines the y coordinate of the operand
  3197. * @param z defines the z coordinate of the operand
  3198. * @returns the current updated Vector3
  3199. */
  3200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3201. /**
  3202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3203. * @param otherVector defines the second operand
  3204. * @returns the resulting Vector3
  3205. */
  3206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3207. /**
  3208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3209. * @param otherVector defines the second operand
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector3
  3212. */
  3213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3214. /**
  3215. * Subtract the given vector from the current Vector3
  3216. * @param otherVector defines the second operand
  3217. * @returns the current updated Vector3
  3218. */
  3219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3222. * @param otherVector defines the second operand
  3223. * @returns the resulting Vector3
  3224. */
  3225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3226. /**
  3227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3228. * @param otherVector defines the second operand
  3229. * @param result defines the Vector3 object where to store the result
  3230. * @returns the current Vector3
  3231. */
  3232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3235. * @param x defines the x coordinate of the operand
  3236. * @param y defines the y coordinate of the operand
  3237. * @param z defines the z coordinate of the operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3241. /**
  3242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @param result defines the Vector3 object where to store the result
  3247. * @returns the current Vector3
  3248. */
  3249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3250. /**
  3251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3252. * @returns a new Vector3
  3253. */
  3254. negate(): Vector3;
  3255. /**
  3256. * Negate this vector in place
  3257. * @returns this
  3258. */
  3259. negateInPlace(): Vector3;
  3260. /**
  3261. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3262. * @param result defines the Vector3 object where to store the result
  3263. * @returns the current Vector3
  3264. */
  3265. negateToRef(result: Vector3): Vector3;
  3266. /**
  3267. * Multiplies the Vector3 coordinates by the float "scale"
  3268. * @param scale defines the multiplier factor
  3269. * @returns the current updated Vector3
  3270. */
  3271. scaleInPlace(scale: number): Vector3;
  3272. /**
  3273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3274. * @param scale defines the multiplier factor
  3275. * @returns a new Vector3
  3276. */
  3277. scale(scale: number): Vector3;
  3278. /**
  3279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3280. * @param scale defines the multiplier factor
  3281. * @param result defines the Vector3 object where to store the result
  3282. * @returns the current Vector3
  3283. */
  3284. scaleToRef(scale: number, result: Vector3): Vector3;
  3285. /**
  3286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3287. * @param scale defines the scale factor
  3288. * @param result defines the Vector3 object where to store the result
  3289. * @returns the unmodified current Vector3
  3290. */
  3291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3292. /**
  3293. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3294. * @param origin defines the origin of the projection ray
  3295. * @param plane defines the plane to project to
  3296. * @returns the projected vector3
  3297. */
  3298. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3299. /**
  3300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3301. * @param origin defines the origin of the projection ray
  3302. * @param plane defines the plane to project to
  3303. * @param result defines the Vector3 where to store the result
  3304. */
  3305. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3306. /**
  3307. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3308. * @param otherVector defines the second operand
  3309. * @returns true if both vectors are equals
  3310. */
  3311. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3312. /**
  3313. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3314. * @param otherVector defines the second operand
  3315. * @param epsilon defines the minimal distance to define values as equals
  3316. * @returns true if both vectors are distant less than epsilon
  3317. */
  3318. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3319. /**
  3320. * Returns true if the current Vector3 coordinates equals the given floats
  3321. * @param x defines the x coordinate of the operand
  3322. * @param y defines the y coordinate of the operand
  3323. * @param z defines the z coordinate of the operand
  3324. * @returns true if both vectors are equals
  3325. */
  3326. equalsToFloats(x: number, y: number, z: number): boolean;
  3327. /**
  3328. * Multiplies the current Vector3 coordinates by the given ones
  3329. * @param otherVector defines the second operand
  3330. * @returns the current updated Vector3
  3331. */
  3332. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3333. /**
  3334. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3335. * @param otherVector defines the second operand
  3336. * @returns the new Vector3
  3337. */
  3338. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3339. /**
  3340. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3341. * @param otherVector defines the second operand
  3342. * @param result defines the Vector3 object where to store the result
  3343. * @returns the current Vector3
  3344. */
  3345. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3348. * @param x defines the x coordinate of the operand
  3349. * @param y defines the y coordinate of the operand
  3350. * @param z defines the z coordinate of the operand
  3351. * @returns the new Vector3
  3352. */
  3353. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3356. * @param otherVector defines the second operand
  3357. * @returns the new Vector3
  3358. */
  3359. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3360. /**
  3361. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3362. * @param otherVector defines the second operand
  3363. * @param result defines the Vector3 object where to store the result
  3364. * @returns the current Vector3
  3365. */
  3366. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3367. /**
  3368. * Divides the current Vector3 coordinates by the given ones.
  3369. * @param otherVector defines the second operand
  3370. * @returns the current updated Vector3
  3371. */
  3372. divideInPlace(otherVector: Vector3): Vector3;
  3373. /**
  3374. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3375. * @param other defines the second operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3381. * @param other defines the second operand
  3382. * @returns the current updated Vector3
  3383. */
  3384. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3385. /**
  3386. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3387. * @param x defines the x coordinate of the operand
  3388. * @param y defines the y coordinate of the operand
  3389. * @param z defines the z coordinate of the operand
  3390. * @returns the current updated Vector3
  3391. */
  3392. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3393. /**
  3394. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3395. * @param x defines the x coordinate of the operand
  3396. * @param y defines the y coordinate of the operand
  3397. * @param z defines the z coordinate of the operand
  3398. * @returns the current updated Vector3
  3399. */
  3400. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3401. /**
  3402. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3403. * Check if is non uniform within a certain amount of decimal places to account for this
  3404. * @param epsilon the amount the values can differ
  3405. * @returns if the the vector is non uniform to a certain number of decimal places
  3406. */
  3407. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3408. /**
  3409. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3410. */
  3411. get isNonUniform(): boolean;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. floor(): Vector3;
  3417. /**
  3418. * Gets a new Vector3 from current Vector3 floored values
  3419. * @returns a new Vector3
  3420. */
  3421. fract(): Vector3;
  3422. /**
  3423. * Gets the length of the Vector3
  3424. * @returns the length of the Vector3
  3425. */
  3426. length(): number;
  3427. /**
  3428. * Gets the squared length of the Vector3
  3429. * @returns squared length of the Vector3
  3430. */
  3431. lengthSquared(): number;
  3432. /**
  3433. * Normalize the current Vector3.
  3434. * Please note that this is an in place operation.
  3435. * @returns the current updated Vector3
  3436. */
  3437. normalize(): Vector3;
  3438. /**
  3439. * Reorders the x y z properties of the vector in place
  3440. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3441. * @returns the current updated vector
  3442. */
  3443. reorderInPlace(order: string): this;
  3444. /**
  3445. * Rotates the vector around 0,0,0 by a quaternion
  3446. * @param quaternion the rotation quaternion
  3447. * @param result vector to store the result
  3448. * @returns the resulting vector
  3449. */
  3450. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3451. /**
  3452. * Rotates a vector around a given point
  3453. * @param quaternion the rotation quaternion
  3454. * @param point the point to rotate around
  3455. * @param result vector to store the result
  3456. * @returns the resulting vector
  3457. */
  3458. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3459. /**
  3460. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3461. * The cross product is then orthogonal to both current and "other"
  3462. * @param other defines the right operand
  3463. * @returns the cross product
  3464. */
  3465. cross(other: Vector3): Vector3;
  3466. /**
  3467. * Normalize the current Vector3 with the given input length.
  3468. * Please note that this is an in place operation.
  3469. * @param len the length of the vector
  3470. * @returns the current updated Vector3
  3471. */
  3472. normalizeFromLength(len: number): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to a new vector
  3475. * @returns the new Vector3
  3476. */
  3477. normalizeToNew(): Vector3;
  3478. /**
  3479. * Normalize the current Vector3 to the reference
  3480. * @param reference define the Vector3 to update
  3481. * @returns the updated Vector3
  3482. */
  3483. normalizeToRef(reference: Vector3): Vector3;
  3484. /**
  3485. * Creates a new Vector3 copied from the current Vector3
  3486. * @returns the new Vector3
  3487. */
  3488. clone(): Vector3;
  3489. /**
  3490. * Copies the given vector coordinates to the current Vector3 ones
  3491. * @param source defines the source Vector3
  3492. * @returns the current updated Vector3
  3493. */
  3494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3495. /**
  3496. * Copies the given floats to the current Vector3 coordinates
  3497. * @param x defines the x coordinate of the operand
  3498. * @param y defines the y coordinate of the operand
  3499. * @param z defines the z coordinate of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number): Vector3;
  3503. /**
  3504. * Copies the given floats to the current Vector3 coordinates
  3505. * @param x defines the x coordinate of the operand
  3506. * @param y defines the y coordinate of the operand
  3507. * @param z defines the z coordinate of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. set(x: number, y: number, z: number): Vector3;
  3511. /**
  3512. * Copies the given float to the current Vector3 coordinates
  3513. * @param v defines the x, y and z coordinates of the operand
  3514. * @returns the current updated Vector3
  3515. */
  3516. setAll(v: number): Vector3;
  3517. /**
  3518. * Get the clip factor between two vectors
  3519. * @param vector0 defines the first operand
  3520. * @param vector1 defines the second operand
  3521. * @param axis defines the axis to use
  3522. * @param size defines the size along the axis
  3523. * @returns the clip factor
  3524. */
  3525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3526. /**
  3527. * Get angle between two vectors
  3528. * @param vector0 angle between vector0 and vector1
  3529. * @param vector1 angle between vector0 and vector1
  3530. * @param normal direction of the normal
  3531. * @return the angle between vector0 and vector1
  3532. */
  3533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3534. /**
  3535. * Returns a new Vector3 set from the index "offset" of the given array
  3536. * @param array defines the source array
  3537. * @param offset defines the offset in the source array
  3538. * @returns the new Vector3
  3539. */
  3540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3541. /**
  3542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3543. * @param array defines the source array
  3544. * @param offset defines the offset in the source array
  3545. * @returns the new Vector3
  3546. * @deprecated Please use FromArray instead.
  3547. */
  3548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3549. /**
  3550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3551. * @param array defines the source array
  3552. * @param offset defines the offset in the source array
  3553. * @param result defines the Vector3 where to store the result
  3554. */
  3555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3556. /**
  3557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3558. * @param array defines the source array
  3559. * @param offset defines the offset in the source array
  3560. * @param result defines the Vector3 where to store the result
  3561. * @deprecated Please use FromArrayToRef instead.
  3562. */
  3563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3564. /**
  3565. * Sets the given vector "result" with the given floats.
  3566. * @param x defines the x coordinate of the source
  3567. * @param y defines the y coordinate of the source
  3568. * @param z defines the z coordinate of the source
  3569. * @param result defines the Vector3 where to store the result
  3570. */
  3571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3572. /**
  3573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3574. * @returns a new empty Vector3
  3575. */
  3576. static Zero(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3579. * @returns a new unit Vector3
  3580. */
  3581. static One(): Vector3;
  3582. /**
  3583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3584. * @returns a new up Vector3
  3585. */
  3586. static Up(): Vector3;
  3587. /**
  3588. * Gets a up Vector3 that must not be updated
  3589. */
  3590. static get UpReadOnly(): DeepImmutable<Vector3>;
  3591. /**
  3592. * Gets a zero Vector3 that must not be updated
  3593. */
  3594. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3597. * @returns a new down Vector3
  3598. */
  3599. static Down(): Vector3;
  3600. /**
  3601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3602. * @param rightHandedSystem is the scene right-handed (negative z)
  3603. * @returns a new forward Vector3
  3604. */
  3605. static Forward(rightHandedSystem?: boolean): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3608. * @param rightHandedSystem is the scene right-handed (negative-z)
  3609. * @returns a new forward Vector3
  3610. */
  3611. static Backward(rightHandedSystem?: boolean): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3614. * @returns a new right Vector3
  3615. */
  3616. static Right(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3619. * @returns a new left Vector3
  3620. */
  3621. static Left(): Vector3;
  3622. /**
  3623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3625. * @param vector defines the Vector3 to transform
  3626. * @param transformation defines the transformation matrix
  3627. * @returns the transformed Vector3
  3628. */
  3629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3630. /**
  3631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3633. * @param vector defines the Vector3 to transform
  3634. * @param transformation defines the transformation matrix
  3635. * @param result defines the Vector3 where to store the result
  3636. */
  3637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3638. /**
  3639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3640. * This method computes tranformed coordinates only, not transformed direction vectors
  3641. * @param x define the x coordinate of the source vector
  3642. * @param y define the y coordinate of the source vector
  3643. * @param z define the z coordinate of the source vector
  3644. * @param transformation defines the transformation matrix
  3645. * @param result defines the Vector3 where to store the result
  3646. */
  3647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3648. /**
  3649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3651. * @param vector defines the Vector3 to transform
  3652. * @param transformation defines the transformation matrix
  3653. * @returns the new Vector3
  3654. */
  3655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3656. /**
  3657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @param result defines the Vector3 where to store the result
  3662. */
  3663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3664. /**
  3665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3667. * @param x define the x coordinate of the source vector
  3668. * @param y define the y coordinate of the source vector
  3669. * @param z define the z coordinate of the source vector
  3670. * @param transformation defines the transformation matrix
  3671. * @param result defines the Vector3 where to store the result
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3674. /**
  3675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3676. * @param value1 defines the first control point
  3677. * @param value2 defines the second control point
  3678. * @param value3 defines the third control point
  3679. * @param value4 defines the fourth control point
  3680. * @param amount defines the amount on the spline to use
  3681. * @returns the new Vector3
  3682. */
  3683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3684. /**
  3685. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3688. * @param value defines the current value
  3689. * @param min defines the lower range value
  3690. * @param max defines the upper range value
  3691. * @returns the new Vector3
  3692. */
  3693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3694. /**
  3695. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3698. * @param value defines the current value
  3699. * @param min defines the lower range value
  3700. * @param max defines the upper range value
  3701. * @param result defines the Vector3 where to store the result
  3702. */
  3703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3704. /**
  3705. * Checks if a given vector is inside a specific range
  3706. * @param v defines the vector to test
  3707. * @param min defines the minimum range
  3708. * @param max defines the maximum range
  3709. */
  3710. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3711. /**
  3712. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3713. * @param value1 defines the first control point
  3714. * @param tangent1 defines the first tangent vector
  3715. * @param value2 defines the second control point
  3716. * @param tangent2 defines the second tangent vector
  3717. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3718. * @returns the new Vector3
  3719. */
  3720. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3721. /**
  3722. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3723. * @param start defines the start value
  3724. * @param end defines the end value
  3725. * @param amount max defines amount between both (between 0 and 1)
  3726. * @returns the new Vector3
  3727. */
  3728. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3729. /**
  3730. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3731. * @param start defines the start value
  3732. * @param end defines the end value
  3733. * @param amount max defines amount between both (between 0 and 1)
  3734. * @param result defines the Vector3 where to store the result
  3735. */
  3736. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3737. /**
  3738. * Returns the dot product (float) between the vectors "left" and "right"
  3739. * @param left defines the left operand
  3740. * @param right defines the right operand
  3741. * @returns the dot product
  3742. */
  3743. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3744. /**
  3745. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3746. * The cross product is then orthogonal to both "left" and "right"
  3747. * @param left defines the left operand
  3748. * @param right defines the right operand
  3749. * @returns the cross product
  3750. */
  3751. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the cross product of "left" and "right"
  3754. * The cross product is then orthogonal to both "left" and "right"
  3755. * @param left defines the left operand
  3756. * @param right defines the right operand
  3757. * @param result defines the Vector3 where to store the result
  3758. */
  3759. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3760. /**
  3761. * Returns a new Vector3 as the normalization of the given vector
  3762. * @param vector defines the Vector3 to normalize
  3763. * @returns the new Vector3
  3764. */
  3765. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3766. /**
  3767. * Sets the given vector "result" with the normalization of the given first vector
  3768. * @param vector defines the Vector3 to normalize
  3769. * @param result defines the Vector3 where to store the result
  3770. */
  3771. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3772. /**
  3773. * Project a Vector3 onto screen space
  3774. * @param vector defines the Vector3 to project
  3775. * @param world defines the world matrix to use
  3776. * @param transform defines the transform (view x projection) matrix to use
  3777. * @param viewport defines the screen viewport to use
  3778. * @returns the new Vector3
  3779. */
  3780. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3781. /**
  3782. * Project a Vector3 onto screen space to reference
  3783. * @param vector defines the Vector3 to project
  3784. * @param world defines the world matrix to use
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @param viewport defines the screen viewport to use
  3787. * @param result the vector in which the screen space will be stored
  3788. * @returns the new Vector3
  3789. */
  3790. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3791. /** @hidden */
  3792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3793. /**
  3794. * Unproject from screen space to object space
  3795. * @param source defines the screen space Vector3 to use
  3796. * @param viewportWidth defines the current width of the viewport
  3797. * @param viewportHeight defines the current height of the viewport
  3798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3799. * @param transform defines the transform (view x projection) matrix to use
  3800. * @returns the new Vector3
  3801. */
  3802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3803. /**
  3804. * Unproject from screen space to object space
  3805. * @param source defines the screen space Vector3 to use
  3806. * @param viewportWidth defines the current width of the viewport
  3807. * @param viewportHeight defines the current height of the viewport
  3808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3809. * @param view defines the view matrix to use
  3810. * @param projection defines the projection matrix to use
  3811. * @returns the new Vector3
  3812. */
  3813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3814. /**
  3815. * Unproject from screen space to object space
  3816. * @param source defines the screen space Vector3 to use
  3817. * @param viewportWidth defines the current width of the viewport
  3818. * @param viewportHeight defines the current height of the viewport
  3819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3820. * @param view defines the view matrix to use
  3821. * @param projection defines the projection matrix to use
  3822. * @param result defines the Vector3 where to store the result
  3823. */
  3824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3825. /**
  3826. * Unproject from screen space to object space
  3827. * @param sourceX defines the screen space x coordinate to use
  3828. * @param sourceY defines the screen space y coordinate to use
  3829. * @param sourceZ defines the screen space z coordinate to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param view defines the view matrix to use
  3834. * @param projection defines the projection matrix to use
  3835. * @param result defines the Vector3 where to store the result
  3836. */
  3837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3838. /**
  3839. * Gets the minimal coordinate values between two Vector3
  3840. * @param left defines the first operand
  3841. * @param right defines the second operand
  3842. * @returns the new Vector3
  3843. */
  3844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3845. /**
  3846. * Gets the maximal coordinate values between two Vector3
  3847. * @param left defines the first operand
  3848. * @param right defines the second operand
  3849. * @returns the new Vector3
  3850. */
  3851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3852. /**
  3853. * Returns the distance between the vectors "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the distance
  3857. */
  3858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3859. /**
  3860. * Returns the squared distance between the vectors "value1" and "value2"
  3861. * @param value1 defines the first operand
  3862. * @param value2 defines the second operand
  3863. * @returns the squared distance
  3864. */
  3865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3866. /**
  3867. * Returns a new Vector3 located at the center between "value1" and "value2"
  3868. * @param value1 defines the first operand
  3869. * @param value2 defines the second operand
  3870. * @returns the new Vector3
  3871. */
  3872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3873. /**
  3874. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3875. * @param value1 defines first vector
  3876. * @param value2 defines second vector
  3877. * @param ref defines third vector
  3878. * @returns ref
  3879. */
  3880. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3881. /**
  3882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3884. * to something in order to rotate it from its local system to the given target system
  3885. * Note: axis1, axis2 and axis3 are normalized during this operation
  3886. * @param axis1 defines the first axis
  3887. * @param axis2 defines the second axis
  3888. * @param axis3 defines the third axis
  3889. * @returns a new Vector3
  3890. */
  3891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3892. /**
  3893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3894. * @param axis1 defines the first axis
  3895. * @param axis2 defines the second axis
  3896. * @param axis3 defines the third axis
  3897. * @param ref defines the Vector3 where to store the result
  3898. */
  3899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3900. }
  3901. /**
  3902. * Vector4 class created for EulerAngle class conversion to Quaternion
  3903. */
  3904. export class Vector4 {
  3905. /** x value of the vector */
  3906. x: number;
  3907. /** y value of the vector */
  3908. y: number;
  3909. /** z value of the vector */
  3910. z: number;
  3911. /** w value of the vector */
  3912. w: number;
  3913. /**
  3914. * Creates a Vector4 object from the given floats.
  3915. * @param x x value of the vector
  3916. * @param y y value of the vector
  3917. * @param z z value of the vector
  3918. * @param w w value of the vector
  3919. */
  3920. constructor(
  3921. /** x value of the vector */
  3922. x: number,
  3923. /** y value of the vector */
  3924. y: number,
  3925. /** z value of the vector */
  3926. z: number,
  3927. /** w value of the vector */
  3928. w: number);
  3929. /**
  3930. * Returns the string with the Vector4 coordinates.
  3931. * @returns a string containing all the vector values
  3932. */
  3933. toString(): string;
  3934. /**
  3935. * Returns the string "Vector4".
  3936. * @returns "Vector4"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Returns the Vector4 hash code.
  3941. * @returns a unique hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3946. * @returns the resulting array
  3947. */
  3948. asArray(): number[];
  3949. /**
  3950. * Populates the given array from the given index with the Vector4 coordinates.
  3951. * @param array array to populate
  3952. * @param index index of the array to start at (default: 0)
  3953. * @returns the Vector4.
  3954. */
  3955. toArray(array: FloatArray, index?: number): Vector4;
  3956. /**
  3957. * Update the current vector from an array
  3958. * @param array defines the destination array
  3959. * @param index defines the offset in the destination array
  3960. * @returns the current Vector3
  3961. */
  3962. fromArray(array: FloatArray, index?: number): Vector4;
  3963. /**
  3964. * Adds the given vector to the current Vector4.
  3965. * @param otherVector the vector to add
  3966. * @returns the updated Vector4.
  3967. */
  3968. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3969. /**
  3970. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3971. * @param otherVector the vector to add
  3972. * @returns the resulting vector
  3973. */
  3974. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3975. /**
  3976. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3977. * @param otherVector the vector to add
  3978. * @param result the vector to store the result
  3979. * @returns the current Vector4.
  3980. */
  3981. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3982. /**
  3983. * Subtract in place the given vector from the current Vector4.
  3984. * @param otherVector the vector to subtract
  3985. * @returns the updated Vector4.
  3986. */
  3987. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3988. /**
  3989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3990. * @param otherVector the vector to add
  3991. * @returns the new vector with the result
  3992. */
  3993. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3994. /**
  3995. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3996. * @param otherVector the vector to subtract
  3997. * @param result the vector to store the result
  3998. * @returns the current Vector4.
  3999. */
  4000. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4003. */
  4004. /**
  4005. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4006. * @param x value to subtract
  4007. * @param y value to subtract
  4008. * @param z value to subtract
  4009. * @param w value to subtract
  4010. * @returns new vector containing the result
  4011. */
  4012. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4013. /**
  4014. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4015. * @param x value to subtract
  4016. * @param y value to subtract
  4017. * @param z value to subtract
  4018. * @param w value to subtract
  4019. * @param result the vector to store the result in
  4020. * @returns the current Vector4.
  4021. */
  4022. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4023. /**
  4024. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4025. * @returns a new vector with the negated values
  4026. */
  4027. negate(): Vector4;
  4028. /**
  4029. * Negate this vector in place
  4030. * @returns this
  4031. */
  4032. negateInPlace(): Vector4;
  4033. /**
  4034. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4035. * @param result defines the Vector3 object where to store the result
  4036. * @returns the current Vector4
  4037. */
  4038. negateToRef(result: Vector4): Vector4;
  4039. /**
  4040. * Multiplies the current Vector4 coordinates by scale (float).
  4041. * @param scale the number to scale with
  4042. * @returns the updated Vector4.
  4043. */
  4044. scaleInPlace(scale: number): Vector4;
  4045. /**
  4046. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4047. * @param scale the number to scale with
  4048. * @returns a new vector with the result
  4049. */
  4050. scale(scale: number): Vector4;
  4051. /**
  4052. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4053. * @param scale the number to scale with
  4054. * @param result a vector to store the result in
  4055. * @returns the current Vector4.
  4056. */
  4057. scaleToRef(scale: number, result: Vector4): Vector4;
  4058. /**
  4059. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4060. * @param scale defines the scale factor
  4061. * @param result defines the Vector4 object where to store the result
  4062. * @returns the unmodified current Vector4
  4063. */
  4064. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4065. /**
  4066. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4067. * @param otherVector the vector to compare against
  4068. * @returns true if they are equal
  4069. */
  4070. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4071. /**
  4072. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4073. * @param otherVector vector to compare against
  4074. * @param epsilon (Default: very small number)
  4075. * @returns true if they are equal
  4076. */
  4077. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4078. /**
  4079. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4080. * @param x x value to compare against
  4081. * @param y y value to compare against
  4082. * @param z z value to compare against
  4083. * @param w w value to compare against
  4084. * @returns true if equal
  4085. */
  4086. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4087. /**
  4088. * Multiplies in place the current Vector4 by the given one.
  4089. * @param otherVector vector to multiple with
  4090. * @returns the updated Vector4.
  4091. */
  4092. multiplyInPlace(otherVector: Vector4): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4095. * @param otherVector vector to multiple with
  4096. * @returns resulting new vector
  4097. */
  4098. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4099. /**
  4100. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4101. * @param otherVector vector to multiple with
  4102. * @param result vector to store the result
  4103. * @returns the current Vector4.
  4104. */
  4105. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4106. /**
  4107. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4108. * @param x x value multiply with
  4109. * @param y y value multiply with
  4110. * @param z z value multiply with
  4111. * @param w w value multiply with
  4112. * @returns resulting new vector
  4113. */
  4114. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4115. /**
  4116. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4117. * @param otherVector vector to devide with
  4118. * @returns resulting new vector
  4119. */
  4120. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4121. /**
  4122. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4123. * @param otherVector vector to devide with
  4124. * @param result vector to store the result
  4125. * @returns the current Vector4.
  4126. */
  4127. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4128. /**
  4129. * Divides the current Vector3 coordinates by the given ones.
  4130. * @param otherVector vector to devide with
  4131. * @returns the updated Vector3.
  4132. */
  4133. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4134. /**
  4135. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4136. * @param other defines the second operand
  4137. * @returns the current updated Vector4
  4138. */
  4139. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4140. /**
  4141. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4142. * @param other defines the second operand
  4143. * @returns the current updated Vector4
  4144. */
  4145. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector4 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. floor(): Vector4;
  4151. /**
  4152. * Gets a new Vector4 from current Vector3 floored values
  4153. * @returns a new Vector4
  4154. */
  4155. fract(): Vector4;
  4156. /**
  4157. * Returns the Vector4 length (float).
  4158. * @returns the length
  4159. */
  4160. length(): number;
  4161. /**
  4162. * Returns the Vector4 squared length (float).
  4163. * @returns the length squared
  4164. */
  4165. lengthSquared(): number;
  4166. /**
  4167. * Normalizes in place the Vector4.
  4168. * @returns the updated Vector4.
  4169. */
  4170. normalize(): Vector4;
  4171. /**
  4172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4173. * @returns this converted to a new vector3
  4174. */
  4175. toVector3(): Vector3;
  4176. /**
  4177. * Returns a new Vector4 copied from the current one.
  4178. * @returns the new cloned vector
  4179. */
  4180. clone(): Vector4;
  4181. /**
  4182. * Updates the current Vector4 with the given one coordinates.
  4183. * @param source the source vector to copy from
  4184. * @returns the updated Vector4.
  4185. */
  4186. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4187. /**
  4188. * Updates the current Vector4 coordinates with the given floats.
  4189. * @param x float to copy from
  4190. * @param y float to copy from
  4191. * @param z float to copy from
  4192. * @param w float to copy from
  4193. * @returns the updated Vector4.
  4194. */
  4195. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4196. /**
  4197. * Updates the current Vector4 coordinates with the given floats.
  4198. * @param x float to set from
  4199. * @param y float to set from
  4200. * @param z float to set from
  4201. * @param w float to set from
  4202. * @returns the updated Vector4.
  4203. */
  4204. set(x: number, y: number, z: number, w: number): Vector4;
  4205. /**
  4206. * Copies the given float to the current Vector3 coordinates
  4207. * @param v defines the x, y, z and w coordinates of the operand
  4208. * @returns the current updated Vector3
  4209. */
  4210. setAll(v: number): Vector4;
  4211. /**
  4212. * Returns a new Vector4 set from the starting index of the given array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @returns the new vector
  4216. */
  4217. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4218. /**
  4219. * Updates the given vector "result" from the starting index of the given array.
  4220. * @param array the array to pull values from
  4221. * @param offset the offset into the array to start at
  4222. * @param result the vector to store the result in
  4223. */
  4224. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4225. /**
  4226. * Updates the given vector "result" from the starting index of the given Float32Array.
  4227. * @param array the array to pull values from
  4228. * @param offset the offset into the array to start at
  4229. * @param result the vector to store the result in
  4230. */
  4231. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4232. /**
  4233. * Updates the given vector "result" coordinates from the given floats.
  4234. * @param x float to set from
  4235. * @param y float to set from
  4236. * @param z float to set from
  4237. * @param w float to set from
  4238. * @param result the vector to the floats in
  4239. */
  4240. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4241. /**
  4242. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4243. * @returns the new vector
  4244. */
  4245. static Zero(): Vector4;
  4246. /**
  4247. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4248. * @returns the new vector
  4249. */
  4250. static One(): Vector4;
  4251. /**
  4252. * Returns a new normalized Vector4 from the given one.
  4253. * @param vector the vector to normalize
  4254. * @returns the vector
  4255. */
  4256. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4257. /**
  4258. * Updates the given vector "result" from the normalization of the given one.
  4259. * @param vector the vector to normalize
  4260. * @param result the vector to store the result in
  4261. */
  4262. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4263. /**
  4264. * Returns a vector with the minimum values from the left and right vectors
  4265. * @param left left vector to minimize
  4266. * @param right right vector to minimize
  4267. * @returns a new vector with the minimum of the left and right vector values
  4268. */
  4269. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4270. /**
  4271. * Returns a vector with the maximum values from the left and right vectors
  4272. * @param left left vector to maximize
  4273. * @param right right vector to maximize
  4274. * @returns a new vector with the maximum of the left and right vector values
  4275. */
  4276. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4277. /**
  4278. * Returns the distance (float) between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the distance between
  4280. * @param value2 value to calulate the distance between
  4281. * @return the distance between the two vectors
  4282. */
  4283. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4284. /**
  4285. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4286. * @param value1 value to calulate the distance between
  4287. * @param value2 value to calulate the distance between
  4288. * @return the distance between the two vectors squared
  4289. */
  4290. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4291. /**
  4292. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4293. * @param value1 value to calulate the center between
  4294. * @param value2 value to calulate the center between
  4295. * @return the center between the two vectors
  4296. */
  4297. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4298. /**
  4299. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4300. * @param value1 defines first vector
  4301. * @param value2 defines second vector
  4302. * @param ref defines third vector
  4303. * @returns ref
  4304. */
  4305. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4306. /**
  4307. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4308. * This methods computes transformed normalized direction vectors only.
  4309. * @param vector the vector to transform
  4310. * @param transformation the transformation matrix to apply
  4311. * @returns the new vector
  4312. */
  4313. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4314. /**
  4315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4316. * This methods computes transformed normalized direction vectors only.
  4317. * @param vector the vector to transform
  4318. * @param transformation the transformation matrix to apply
  4319. * @param result the vector to store the result in
  4320. */
  4321. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4322. /**
  4323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4324. * This methods computes transformed normalized direction vectors only.
  4325. * @param x value to transform
  4326. * @param y value to transform
  4327. * @param z value to transform
  4328. * @param w value to transform
  4329. * @param transformation the transformation matrix to apply
  4330. * @param result the vector to store the results in
  4331. */
  4332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4333. /**
  4334. * Creates a new Vector4 from a Vector3
  4335. * @param source defines the source data
  4336. * @param w defines the 4th component (default is 0)
  4337. * @returns a new Vector4
  4338. */
  4339. static FromVector3(source: Vector3, w?: number): Vector4;
  4340. }
  4341. /**
  4342. * Class used to store quaternion data
  4343. * @see https://en.wikipedia.org/wiki/Quaternion
  4344. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4345. */
  4346. export class Quaternion {
  4347. /** @hidden */
  4348. _x: number;
  4349. /** @hidden */
  4350. _y: number;
  4351. /** @hidden */
  4352. _z: number;
  4353. /** @hidden */
  4354. _w: number;
  4355. /** @hidden */
  4356. _isDirty: boolean;
  4357. /** Gets or sets the x coordinate */
  4358. get x(): number;
  4359. set x(value: number);
  4360. /** Gets or sets the y coordinate */
  4361. get y(): number;
  4362. set y(value: number);
  4363. /** Gets or sets the z coordinate */
  4364. get z(): number;
  4365. set z(value: number);
  4366. /** Gets or sets the w coordinate */
  4367. get w(): number;
  4368. set w(value: number);
  4369. /**
  4370. * Creates a new Quaternion from the given floats
  4371. * @param x defines the first component (0 by default)
  4372. * @param y defines the second component (0 by default)
  4373. * @param z defines the third component (0 by default)
  4374. * @param w defines the fourth component (1.0 by default)
  4375. */
  4376. constructor(x?: number, y?: number, z?: number, w?: number);
  4377. /**
  4378. * Gets a string representation for the current quaternion
  4379. * @returns a string with the Quaternion coordinates
  4380. */
  4381. toString(): string;
  4382. /**
  4383. * Gets the class name of the quaternion
  4384. * @returns the string "Quaternion"
  4385. */
  4386. getClassName(): string;
  4387. /**
  4388. * Gets a hash code for this quaternion
  4389. * @returns the quaternion hash code
  4390. */
  4391. getHashCode(): number;
  4392. /**
  4393. * Copy the quaternion to an array
  4394. * @returns a new array populated with 4 elements from the quaternion coordinates
  4395. */
  4396. asArray(): number[];
  4397. /**
  4398. * Check if two quaternions are equals
  4399. * @param otherQuaternion defines the second operand
  4400. * @return true if the current quaternion and the given one coordinates are strictly equals
  4401. */
  4402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4403. /**
  4404. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4405. * @param otherQuaternion defines the other quaternion
  4406. * @param epsilon defines the minimal distance to consider equality
  4407. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4408. */
  4409. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4410. /**
  4411. * Clone the current quaternion
  4412. * @returns a new quaternion copied from the current one
  4413. */
  4414. clone(): Quaternion;
  4415. /**
  4416. * Copy a quaternion to the current one
  4417. * @param other defines the other quaternion
  4418. * @returns the updated current quaternion
  4419. */
  4420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4421. /**
  4422. * Updates the current quaternion with the given float coordinates
  4423. * @param x defines the x coordinate
  4424. * @param y defines the y coordinate
  4425. * @param z defines the z coordinate
  4426. * @param w defines the w coordinate
  4427. * @returns the updated current quaternion
  4428. */
  4429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4430. /**
  4431. * Updates the current quaternion from the given float coordinates
  4432. * @param x defines the x coordinate
  4433. * @param y defines the y coordinate
  4434. * @param z defines the z coordinate
  4435. * @param w defines the w coordinate
  4436. * @returns the updated current quaternion
  4437. */
  4438. set(x: number, y: number, z: number, w: number): Quaternion;
  4439. /**
  4440. * Adds two quaternions
  4441. * @param other defines the second operand
  4442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4443. */
  4444. add(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Add a quaternion to the current one
  4447. * @param other defines the quaternion to add
  4448. * @returns the current quaternion
  4449. */
  4450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4451. /**
  4452. * Subtract two quaternions
  4453. * @param other defines the second operand
  4454. * @returns a new quaternion as the subtraction result of the given one from the current one
  4455. */
  4456. subtract(other: Quaternion): Quaternion;
  4457. /**
  4458. * Multiplies the current quaternion by a scale factor
  4459. * @param value defines the scale factor
  4460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4461. */
  4462. scale(value: number): Quaternion;
  4463. /**
  4464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4465. * @param scale defines the scale factor
  4466. * @param result defines the Quaternion object where to store the result
  4467. * @returns the unmodified current quaternion
  4468. */
  4469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4470. /**
  4471. * Multiplies in place the current quaternion by a scale factor
  4472. * @param value defines the scale factor
  4473. * @returns the current modified quaternion
  4474. */
  4475. scaleInPlace(value: number): Quaternion;
  4476. /**
  4477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4478. * @param scale defines the scale factor
  4479. * @param result defines the Quaternion object where to store the result
  4480. * @returns the unmodified current quaternion
  4481. */
  4482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4483. /**
  4484. * Multiplies two quaternions
  4485. * @param q1 defines the second operand
  4486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4487. */
  4488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4489. /**
  4490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4491. * @param q1 defines the second operand
  4492. * @param result defines the target quaternion
  4493. * @returns the current quaternion
  4494. */
  4495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4496. /**
  4497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4498. * @param q1 defines the second operand
  4499. * @returns the currentupdated quaternion
  4500. */
  4501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4502. /**
  4503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4504. * @param ref defines the target quaternion
  4505. * @returns the current quaternion
  4506. */
  4507. conjugateToRef(ref: Quaternion): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns the current updated quaternion
  4511. */
  4512. conjugateInPlace(): Quaternion;
  4513. /**
  4514. * Conjugates in place (1-q) the current quaternion
  4515. * @returns a new quaternion
  4516. */
  4517. conjugate(): Quaternion;
  4518. /**
  4519. * Gets length of current quaternion
  4520. * @returns the quaternion length (float)
  4521. */
  4522. length(): number;
  4523. /**
  4524. * Normalize in place the current quaternion
  4525. * @returns the current updated quaternion
  4526. */
  4527. normalize(): Quaternion;
  4528. /**
  4529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4530. * @param order is a reserved parameter and is ignored for now
  4531. * @returns a new Vector3 containing the Euler angles
  4532. */
  4533. toEulerAngles(order?: string): Vector3;
  4534. /**
  4535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4536. * @param result defines the vector which will be filled with the Euler angles
  4537. * @returns the current unchanged quaternion
  4538. */
  4539. toEulerAnglesToRef(result: Vector3): Quaternion;
  4540. /**
  4541. * Updates the given rotation matrix with the current quaternion values
  4542. * @param result defines the target matrix
  4543. * @returns the current unchanged quaternion
  4544. */
  4545. toRotationMatrix(result: Matrix): Quaternion;
  4546. /**
  4547. * Updates the current quaternion from the given rotation matrix values
  4548. * @param matrix defines the source matrix
  4549. * @returns the current updated quaternion
  4550. */
  4551. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4552. /**
  4553. * Creates a new quaternion from a rotation matrix
  4554. * @param matrix defines the source matrix
  4555. * @returns a new quaternion created from the given rotation matrix values
  4556. */
  4557. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4558. /**
  4559. * Updates the given quaternion with the given rotation matrix values
  4560. * @param matrix defines the source matrix
  4561. * @param result defines the target quaternion
  4562. */
  4563. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4564. /**
  4565. * Returns the dot product (float) between the quaternions "left" and "right"
  4566. * @param left defines the left operand
  4567. * @param right defines the right operand
  4568. * @returns the dot product
  4569. */
  4570. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4571. /**
  4572. * Checks if the two quaternions are close to each other
  4573. * @param quat0 defines the first quaternion to check
  4574. * @param quat1 defines the second quaternion to check
  4575. * @returns true if the two quaternions are close to each other
  4576. */
  4577. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4578. /**
  4579. * Creates an empty quaternion
  4580. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4581. */
  4582. static Zero(): Quaternion;
  4583. /**
  4584. * Inverse a given quaternion
  4585. * @param q defines the source quaternion
  4586. * @returns a new quaternion as the inverted current quaternion
  4587. */
  4588. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4589. /**
  4590. * Inverse a given quaternion
  4591. * @param q defines the source quaternion
  4592. * @param result the quaternion the result will be stored in
  4593. * @returns the result quaternion
  4594. */
  4595. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4596. /**
  4597. * Creates an identity quaternion
  4598. * @returns the identity quaternion
  4599. */
  4600. static Identity(): Quaternion;
  4601. /**
  4602. * Gets a boolean indicating if the given quaternion is identity
  4603. * @param quaternion defines the quaternion to check
  4604. * @returns true if the quaternion is identity
  4605. */
  4606. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4607. /**
  4608. * Creates a quaternion from a rotation around an axis
  4609. * @param axis defines the axis to use
  4610. * @param angle defines the angle to use
  4611. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4612. */
  4613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4614. /**
  4615. * Creates a rotation around an axis and stores it into the given quaternion
  4616. * @param axis defines the axis to use
  4617. * @param angle defines the angle to use
  4618. * @param result defines the target quaternion
  4619. * @returns the target quaternion
  4620. */
  4621. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4622. /**
  4623. * Creates a new quaternion from data stored into an array
  4624. * @param array defines the data source
  4625. * @param offset defines the offset in the source array where the data starts
  4626. * @returns a new quaternion
  4627. */
  4628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4629. /**
  4630. * Updates the given quaternion "result" from the starting index of the given array.
  4631. * @param array the array to pull values from
  4632. * @param offset the offset into the array to start at
  4633. * @param result the quaternion to store the result in
  4634. */
  4635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4636. /**
  4637. * Create a quaternion from Euler rotation angles
  4638. * @param x Pitch
  4639. * @param y Yaw
  4640. * @param z Roll
  4641. * @returns the new Quaternion
  4642. */
  4643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4644. /**
  4645. * Updates a quaternion from Euler rotation angles
  4646. * @param x Pitch
  4647. * @param y Yaw
  4648. * @param z Roll
  4649. * @param result the quaternion to store the result
  4650. * @returns the updated quaternion
  4651. */
  4652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4653. /**
  4654. * Create a quaternion from Euler rotation vector
  4655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4656. * @returns the new Quaternion
  4657. */
  4658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4659. /**
  4660. * Updates a quaternion from Euler rotation vector
  4661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4662. * @param result the quaternion to store the result
  4663. * @returns the updated quaternion
  4664. */
  4665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4666. /**
  4667. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4668. * @param vecFrom defines the direction vector from which to rotate
  4669. * @param vecTo defines the direction vector to which to rotate
  4670. * @param result the quaternion to store the result
  4671. * @returns the updated quaternion
  4672. */
  4673. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4674. /**
  4675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4676. * @param yaw defines the rotation around Y axis
  4677. * @param pitch defines the rotation around X axis
  4678. * @param roll defines the rotation around Z axis
  4679. * @returns the new quaternion
  4680. */
  4681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4682. /**
  4683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4684. * @param yaw defines the rotation around Y axis
  4685. * @param pitch defines the rotation around X axis
  4686. * @param roll defines the rotation around Z axis
  4687. * @param result defines the target quaternion
  4688. */
  4689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4690. /**
  4691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4692. * @param alpha defines the rotation around first axis
  4693. * @param beta defines the rotation around second axis
  4694. * @param gamma defines the rotation around third axis
  4695. * @returns the new quaternion
  4696. */
  4697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4700. * @param alpha defines the rotation around first axis
  4701. * @param beta defines the rotation around second axis
  4702. * @param gamma defines the rotation around third axis
  4703. * @param result defines the target quaternion
  4704. */
  4705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4706. /**
  4707. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4708. * @param axis1 defines the first axis
  4709. * @param axis2 defines the second axis
  4710. * @param axis3 defines the third axis
  4711. * @returns the new quaternion
  4712. */
  4713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4714. /**
  4715. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4716. * @param axis1 defines the first axis
  4717. * @param axis2 defines the second axis
  4718. * @param axis3 defines the third axis
  4719. * @param ref defines the target quaternion
  4720. */
  4721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4722. /**
  4723. * Interpolates between two quaternions
  4724. * @param left defines first quaternion
  4725. * @param right defines second quaternion
  4726. * @param amount defines the gradient to use
  4727. * @returns the new interpolated quaternion
  4728. */
  4729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4730. /**
  4731. * Interpolates between two quaternions and stores it into a target quaternion
  4732. * @param left defines first quaternion
  4733. * @param right defines second quaternion
  4734. * @param amount defines the gradient to use
  4735. * @param result defines the target quaternion
  4736. */
  4737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4738. /**
  4739. * Interpolate between two quaternions using Hermite interpolation
  4740. * @param value1 defines first quaternion
  4741. * @param tangent1 defines the incoming tangent
  4742. * @param value2 defines second quaternion
  4743. * @param tangent2 defines the outgoing tangent
  4744. * @param amount defines the target quaternion
  4745. * @returns the new interpolated quaternion
  4746. */
  4747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4748. }
  4749. /**
  4750. * Class used to store matrix data (4x4)
  4751. */
  4752. export class Matrix {
  4753. /**
  4754. * Gets the precision of matrix computations
  4755. */
  4756. static get Use64Bits(): boolean;
  4757. private static _updateFlagSeed;
  4758. private static _identityReadOnly;
  4759. private _isIdentity;
  4760. private _isIdentityDirty;
  4761. private _isIdentity3x2;
  4762. private _isIdentity3x2Dirty;
  4763. /**
  4764. * Gets the update flag of the matrix which is an unique number for the matrix.
  4765. * It will be incremented every time the matrix data change.
  4766. * You can use it to speed the comparison between two versions of the same matrix.
  4767. */
  4768. updateFlag: number;
  4769. private readonly _m;
  4770. /**
  4771. * Gets the internal data of the matrix
  4772. */
  4773. get m(): DeepImmutable<Float32Array | Array<number>>;
  4774. /** @hidden */
  4775. _markAsUpdated(): void;
  4776. /** @hidden */
  4777. private _updateIdentityStatus;
  4778. /**
  4779. * Creates an empty matrix (filled with zeros)
  4780. */
  4781. constructor();
  4782. /**
  4783. * Check if the current matrix is identity
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentity(): boolean;
  4787. /**
  4788. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4789. * @returns true is the matrix is the identity matrix
  4790. */
  4791. isIdentityAs3x2(): boolean;
  4792. /**
  4793. * Gets the determinant of the matrix
  4794. * @returns the matrix determinant
  4795. */
  4796. determinant(): number;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array
  4800. */
  4801. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Returns the matrix as a Float32Array or Array<number>
  4804. * @returns the matrix underlying array.
  4805. */
  4806. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4807. /**
  4808. * Inverts the current matrix in place
  4809. * @returns the current inverted matrix
  4810. */
  4811. invert(): Matrix;
  4812. /**
  4813. * Sets all the matrix elements to zero
  4814. * @returns the current matrix
  4815. */
  4816. reset(): Matrix;
  4817. /**
  4818. * Adds the current matrix with a second one
  4819. * @param other defines the matrix to add
  4820. * @returns a new matrix as the addition of the current matrix and the given one
  4821. */
  4822. add(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4825. * @param other defines the matrix to add
  4826. * @param result defines the target matrix
  4827. * @returns the current matrix
  4828. */
  4829. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4830. /**
  4831. * Adds in place the given matrix to the current matrix
  4832. * @param other defines the second operand
  4833. * @returns the current updated matrix
  4834. */
  4835. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4836. /**
  4837. * Sets the given matrix to the current inverted Matrix
  4838. * @param other defines the target matrix
  4839. * @returns the unmodified current matrix
  4840. */
  4841. invertToRef(other: Matrix): Matrix;
  4842. /**
  4843. * add a value at the specified position in the current Matrix
  4844. * @param index the index of the value within the matrix. between 0 and 15.
  4845. * @param value the value to be added
  4846. * @returns the current updated matrix
  4847. */
  4848. addAtIndex(index: number, value: number): Matrix;
  4849. /**
  4850. * mutiply the specified position in the current Matrix by a value
  4851. * @param index the index of the value within the matrix. between 0 and 15.
  4852. * @param value the value to be added
  4853. * @returns the current updated matrix
  4854. */
  4855. multiplyAtIndex(index: number, value: number): Matrix;
  4856. /**
  4857. * Inserts the translation vector (using 3 floats) in the current matrix
  4858. * @param x defines the 1st component of the translation
  4859. * @param y defines the 2nd component of the translation
  4860. * @param z defines the 3rd component of the translation
  4861. * @returns the current updated matrix
  4862. */
  4863. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4864. /**
  4865. * Adds the translation vector (using 3 floats) in the current matrix
  4866. * @param x defines the 1st component of the translation
  4867. * @param y defines the 2nd component of the translation
  4868. * @param z defines the 3rd component of the translation
  4869. * @returns the current updated matrix
  4870. */
  4871. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4872. /**
  4873. * Inserts the translation vector in the current matrix
  4874. * @param vector3 defines the translation to insert
  4875. * @returns the current updated matrix
  4876. */
  4877. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4878. /**
  4879. * Gets the translation value of the current matrix
  4880. * @returns a new Vector3 as the extracted translation from the matrix
  4881. */
  4882. getTranslation(): Vector3;
  4883. /**
  4884. * Fill a Vector3 with the extracted translation from the matrix
  4885. * @param result defines the Vector3 where to store the translation
  4886. * @returns the current matrix
  4887. */
  4888. getTranslationToRef(result: Vector3): Matrix;
  4889. /**
  4890. * Remove rotation and scaling part from the matrix
  4891. * @returns the updated matrix
  4892. */
  4893. removeRotationAndScaling(): Matrix;
  4894. /**
  4895. * Multiply two matrices
  4896. * @param other defines the second operand
  4897. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4898. */
  4899. multiply(other: DeepImmutable<Matrix>): Matrix;
  4900. /**
  4901. * Copy the current matrix from the given one
  4902. * @param other defines the source matrix
  4903. * @returns the current updated matrix
  4904. */
  4905. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4906. /**
  4907. * Populates the given array from the starting index with the current matrix values
  4908. * @param array defines the target array
  4909. * @param offset defines the offset in the target array where to start storing values
  4910. * @returns the current matrix
  4911. */
  4912. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4913. /**
  4914. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4915. * @param other defines the second operand
  4916. * @param result defines the matrix where to store the multiplication
  4917. * @returns the current matrix
  4918. */
  4919. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4920. /**
  4921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4922. * @param other defines the second operand
  4923. * @param result defines the array where to store the multiplication
  4924. * @param offset defines the offset in the target array where to start storing values
  4925. * @returns the current matrix
  4926. */
  4927. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4928. /**
  4929. * Check equality between this matrix and a second one
  4930. * @param value defines the second matrix to compare
  4931. * @returns true is the current matrix and the given one values are strictly equal
  4932. */
  4933. equals(value: DeepImmutable<Matrix>): boolean;
  4934. /**
  4935. * Clone the current matrix
  4936. * @returns a new matrix from the current matrix
  4937. */
  4938. clone(): Matrix;
  4939. /**
  4940. * Returns the name of the current matrix class
  4941. * @returns the string "Matrix"
  4942. */
  4943. getClassName(): string;
  4944. /**
  4945. * Gets the hash code of the current matrix
  4946. * @returns the hash code
  4947. */
  4948. getHashCode(): number;
  4949. /**
  4950. * Decomposes the current Matrix into a translation, rotation and scaling components
  4951. * @param scale defines the scale vector3 given as a reference to update
  4952. * @param rotation defines the rotation quaternion given as a reference to update
  4953. * @param translation defines the translation vector3 given as a reference to update
  4954. * @returns true if operation was successful
  4955. */
  4956. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4957. /**
  4958. * Gets specific row of the matrix
  4959. * @param index defines the number of the row to get
  4960. * @returns the index-th row of the current matrix as a new Vector4
  4961. */
  4962. getRow(index: number): Nullable<Vector4>;
  4963. /**
  4964. * Sets the index-th row of the current matrix to the vector4 values
  4965. * @param index defines the number of the row to set
  4966. * @param row defines the target vector4
  4967. * @returns the updated current matrix
  4968. */
  4969. setRow(index: number, row: Vector4): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix
  4972. * @returns the new transposed matrix
  4973. */
  4974. transpose(): Matrix;
  4975. /**
  4976. * Compute the transpose of the matrix and store it in a given matrix
  4977. * @param result defines the target matrix
  4978. * @returns the current matrix
  4979. */
  4980. transposeToRef(result: Matrix): Matrix;
  4981. /**
  4982. * Sets the index-th row of the current matrix with the given 4 x float values
  4983. * @param index defines the row index
  4984. * @param x defines the x component to set
  4985. * @param y defines the y component to set
  4986. * @param z defines the z component to set
  4987. * @param w defines the w component to set
  4988. * @returns the updated current matrix
  4989. */
  4990. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4991. /**
  4992. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4993. * @param scale defines the scale factor
  4994. * @returns a new matrix
  4995. */
  4996. scale(scale: number): Matrix;
  4997. /**
  4998. * Scale the current matrix values by a factor to a given result matrix
  4999. * @param scale defines the scale factor
  5000. * @param result defines the matrix to store the result
  5001. * @returns the current matrix
  5002. */
  5003. scaleToRef(scale: number, result: Matrix): Matrix;
  5004. /**
  5005. * Scale the current matrix values by a factor and add the result to a given matrix
  5006. * @param scale defines the scale factor
  5007. * @param result defines the Matrix to store the result
  5008. * @returns the current matrix
  5009. */
  5010. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5011. /**
  5012. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5013. * @param ref matrix to store the result
  5014. */
  5015. toNormalMatrix(ref: Matrix): void;
  5016. /**
  5017. * Gets only rotation part of the current matrix
  5018. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5019. */
  5020. getRotationMatrix(): Matrix;
  5021. /**
  5022. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5023. * @param result defines the target matrix to store data to
  5024. * @returns the current matrix
  5025. */
  5026. getRotationMatrixToRef(result: Matrix): Matrix;
  5027. /**
  5028. * Toggles model matrix from being right handed to left handed in place and vice versa
  5029. */
  5030. toggleModelMatrixHandInPlace(): void;
  5031. /**
  5032. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5033. */
  5034. toggleProjectionMatrixHandInPlace(): void;
  5035. /**
  5036. * Creates a matrix from an array
  5037. * @param array defines the source array
  5038. * @param offset defines an offset in the source array
  5039. * @returns a new Matrix set from the starting index of the given array
  5040. */
  5041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5042. /**
  5043. * Copy the content of an array into a given matrix
  5044. * @param array defines the source array
  5045. * @param offset defines an offset in the source array
  5046. * @param result defines the target matrix
  5047. */
  5048. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5049. /**
  5050. * Stores an array into a matrix after having multiplied each component by a given factor
  5051. * @param array defines the source array
  5052. * @param offset defines the offset in the source array
  5053. * @param scale defines the scaling factor
  5054. * @param result defines the target matrix
  5055. */
  5056. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5057. /**
  5058. * Gets an identity matrix that must not be updated
  5059. */
  5060. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5061. /**
  5062. * Stores a list of values (16) inside a given matrix
  5063. * @param initialM11 defines 1st value of 1st row
  5064. * @param initialM12 defines 2nd value of 1st row
  5065. * @param initialM13 defines 3rd value of 1st row
  5066. * @param initialM14 defines 4th value of 1st row
  5067. * @param initialM21 defines 1st value of 2nd row
  5068. * @param initialM22 defines 2nd value of 2nd row
  5069. * @param initialM23 defines 3rd value of 2nd row
  5070. * @param initialM24 defines 4th value of 2nd row
  5071. * @param initialM31 defines 1st value of 3rd row
  5072. * @param initialM32 defines 2nd value of 3rd row
  5073. * @param initialM33 defines 3rd value of 3rd row
  5074. * @param initialM34 defines 4th value of 3rd row
  5075. * @param initialM41 defines 1st value of 4th row
  5076. * @param initialM42 defines 2nd value of 4th row
  5077. * @param initialM43 defines 3rd value of 4th row
  5078. * @param initialM44 defines 4th value of 4th row
  5079. * @param result defines the target matrix
  5080. */
  5081. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5082. /**
  5083. * Creates new matrix from a list of values (16)
  5084. * @param initialM11 defines 1st value of 1st row
  5085. * @param initialM12 defines 2nd value of 1st row
  5086. * @param initialM13 defines 3rd value of 1st row
  5087. * @param initialM14 defines 4th value of 1st row
  5088. * @param initialM21 defines 1st value of 2nd row
  5089. * @param initialM22 defines 2nd value of 2nd row
  5090. * @param initialM23 defines 3rd value of 2nd row
  5091. * @param initialM24 defines 4th value of 2nd row
  5092. * @param initialM31 defines 1st value of 3rd row
  5093. * @param initialM32 defines 2nd value of 3rd row
  5094. * @param initialM33 defines 3rd value of 3rd row
  5095. * @param initialM34 defines 4th value of 3rd row
  5096. * @param initialM41 defines 1st value of 4th row
  5097. * @param initialM42 defines 2nd value of 4th row
  5098. * @param initialM43 defines 3rd value of 4th row
  5099. * @param initialM44 defines 4th value of 4th row
  5100. * @returns the new matrix
  5101. */
  5102. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5103. /**
  5104. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5105. * @param scale defines the scale vector3
  5106. * @param rotation defines the rotation quaternion
  5107. * @param translation defines the translation vector3
  5108. * @returns a new matrix
  5109. */
  5110. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5111. /**
  5112. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5113. * @param scale defines the scale vector3
  5114. * @param rotation defines the rotation quaternion
  5115. * @param translation defines the translation vector3
  5116. * @param result defines the target matrix
  5117. */
  5118. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5119. /**
  5120. * Creates a new identity matrix
  5121. * @returns a new identity matrix
  5122. */
  5123. static Identity(): Matrix;
  5124. /**
  5125. * Creates a new identity matrix and stores the result in a given matrix
  5126. * @param result defines the target matrix
  5127. */
  5128. static IdentityToRef(result: Matrix): void;
  5129. /**
  5130. * Creates a new zero matrix
  5131. * @returns a new zero matrix
  5132. */
  5133. static Zero(): Matrix;
  5134. /**
  5135. * Creates a new rotation matrix for "angle" radians around the X axis
  5136. * @param angle defines the angle (in radians) to use
  5137. * @return the new matrix
  5138. */
  5139. static RotationX(angle: number): Matrix;
  5140. /**
  5141. * Creates a new matrix as the invert of a given matrix
  5142. * @param source defines the source matrix
  5143. * @returns the new matrix
  5144. */
  5145. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5146. /**
  5147. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5148. * @param angle defines the angle (in radians) to use
  5149. * @param result defines the target matrix
  5150. */
  5151. static RotationXToRef(angle: number, result: Matrix): void;
  5152. /**
  5153. * Creates a new rotation matrix for "angle" radians around the Y axis
  5154. * @param angle defines the angle (in radians) to use
  5155. * @return the new matrix
  5156. */
  5157. static RotationY(angle: number): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5160. * @param angle defines the angle (in radians) to use
  5161. * @param result defines the target matrix
  5162. */
  5163. static RotationYToRef(angle: number, result: Matrix): void;
  5164. /**
  5165. * Creates a new rotation matrix for "angle" radians around the Z axis
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationZ(angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5172. * @param angle defines the angle (in radians) to use
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationZToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the given axis
  5178. * @param axis defines the axis to use
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5183. /**
  5184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5185. * @param axis defines the axis to use
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5190. /**
  5191. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5192. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5193. * @param from defines the vector to align
  5194. * @param to defines the vector to align to
  5195. * @param result defines the target matrix
  5196. */
  5197. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5198. /**
  5199. * Creates a rotation matrix
  5200. * @param yaw defines the yaw angle in radians (Y axis)
  5201. * @param pitch defines the pitch angle in radians (X axis)
  5202. * @param roll defines the roll angle in radians (Z axis)
  5203. * @returns the new rotation matrix
  5204. */
  5205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5206. /**
  5207. * Creates a rotation matrix and stores it in a given matrix
  5208. * @param yaw defines the yaw angle in radians (Y axis)
  5209. * @param pitch defines the pitch angle in radians (X axis)
  5210. * @param roll defines the roll angle in radians (Z axis)
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5214. /**
  5215. * Creates a scaling matrix
  5216. * @param x defines the scale factor on X axis
  5217. * @param y defines the scale factor on Y axis
  5218. * @param z defines the scale factor on Z axis
  5219. * @returns the new matrix
  5220. */
  5221. static Scaling(x: number, y: number, z: number): Matrix;
  5222. /**
  5223. * Creates a scaling matrix and stores it in a given matrix
  5224. * @param x defines the scale factor on X axis
  5225. * @param y defines the scale factor on Y axis
  5226. * @param z defines the scale factor on Z axis
  5227. * @param result defines the target matrix
  5228. */
  5229. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5230. /**
  5231. * Creates a translation matrix
  5232. * @param x defines the translation on X axis
  5233. * @param y defines the translation on Y axis
  5234. * @param z defines the translationon Z axis
  5235. * @returns the new matrix
  5236. */
  5237. static Translation(x: number, y: number, z: number): Matrix;
  5238. /**
  5239. * Creates a translation matrix and stores it in a given matrix
  5240. * @param x defines the translation on X axis
  5241. * @param y defines the translation on Y axis
  5242. * @param z defines the translationon Z axis
  5243. * @param result defines the target matrix
  5244. */
  5245. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5246. /**
  5247. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5248. * @param startValue defines the start value
  5249. * @param endValue defines the end value
  5250. * @param gradient defines the gradient factor
  5251. * @returns the new matrix
  5252. */
  5253. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5254. /**
  5255. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5256. * @param startValue defines the start value
  5257. * @param endValue defines the end value
  5258. * @param gradient defines the gradient factor
  5259. * @param result defines the Matrix object where to store data
  5260. */
  5261. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Builds a new matrix whose values are computed by:
  5264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5267. * @param startValue defines the first matrix
  5268. * @param endValue defines the second matrix
  5269. * @param gradient defines the gradient between the two matrices
  5270. * @returns the new matrix
  5271. */
  5272. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5273. /**
  5274. * Update a matrix to values which are computed by:
  5275. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5276. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5277. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5278. * @param startValue defines the first matrix
  5279. * @param endValue defines the second matrix
  5280. * @param gradient defines the gradient between the two matrices
  5281. * @param result defines the target matrix
  5282. */
  5283. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5284. /**
  5285. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5286. * This function works in left handed mode
  5287. * @param eye defines the final position of the entity
  5288. * @param target defines where the entity should look at
  5289. * @param up defines the up vector for the entity
  5290. * @returns the new matrix
  5291. */
  5292. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5293. /**
  5294. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5295. * This function works in left handed mode
  5296. * @param eye defines the final position of the entity
  5297. * @param target defines where the entity should look at
  5298. * @param up defines the up vector for the entity
  5299. * @param result defines the target matrix
  5300. */
  5301. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5302. /**
  5303. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5304. * This function works in right handed mode
  5305. * @param eye defines the final position of the entity
  5306. * @param target defines where the entity should look at
  5307. * @param up defines the up vector for the entity
  5308. * @returns the new matrix
  5309. */
  5310. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5311. /**
  5312. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5313. * This function works in right handed mode
  5314. * @param eye defines the final position of the entity
  5315. * @param target defines where the entity should look at
  5316. * @param up defines the up vector for the entity
  5317. * @param result defines the target matrix
  5318. */
  5319. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5320. /**
  5321. * Create a left-handed orthographic projection matrix
  5322. * @param width defines the viewport width
  5323. * @param height defines the viewport height
  5324. * @param znear defines the near clip plane
  5325. * @param zfar defines the far clip plane
  5326. * @returns a new matrix as a left-handed orthographic projection matrix
  5327. */
  5328. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5329. /**
  5330. * Store a left-handed orthographic projection to a given matrix
  5331. * @param width defines the viewport width
  5332. * @param height defines the viewport height
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Create a left-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a left-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a left-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a right-handed orthographic projection matrix
  5362. * @param left defines the viewport left coordinate
  5363. * @param right defines the viewport right coordinate
  5364. * @param bottom defines the viewport bottom coordinate
  5365. * @param top defines the viewport top coordinate
  5366. * @param znear defines the near clip plane
  5367. * @param zfar defines the far clip plane
  5368. * @returns a new matrix as a right-handed orthographic projection matrix
  5369. */
  5370. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5371. /**
  5372. * Stores a right-handed orthographic projection into a given matrix
  5373. * @param left defines the viewport left coordinate
  5374. * @param right defines the viewport right coordinate
  5375. * @param bottom defines the viewport bottom coordinate
  5376. * @param top defines the viewport top coordinate
  5377. * @param znear defines the near clip plane
  5378. * @param zfar defines the far clip plane
  5379. * @param result defines the target matrix
  5380. */
  5381. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5382. /**
  5383. * Creates a left-handed perspective projection matrix
  5384. * @param width defines the viewport width
  5385. * @param height defines the viewport height
  5386. * @param znear defines the near clip plane
  5387. * @param zfar defines the far clip plane
  5388. * @returns a new matrix as a left-handed perspective projection matrix
  5389. */
  5390. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5391. /**
  5392. * Creates a left-handed perspective projection matrix
  5393. * @param fov defines the horizontal field of view
  5394. * @param aspect defines the aspect ratio
  5395. * @param znear defines the near clip plane
  5396. * @param zfar defines the far clip plane
  5397. * @returns a new matrix as a left-handed perspective projection matrix
  5398. */
  5399. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5400. /**
  5401. * Stores a left-handed perspective projection into a given matrix
  5402. * @param fov defines the horizontal field of view
  5403. * @param aspect defines the aspect ratio
  5404. * @param znear defines the near clip plane
  5405. * @param zfar defines the far clip plane
  5406. * @param result defines the target matrix
  5407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5408. */
  5409. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5410. /**
  5411. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5412. * @param fov defines the horizontal field of view
  5413. * @param aspect defines the aspect ratio
  5414. * @param znear defines the near clip plane
  5415. * @param zfar not used as infinity is used as far clip
  5416. * @param result defines the target matrix
  5417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5418. */
  5419. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5420. /**
  5421. * Creates a right-handed perspective projection matrix
  5422. * @param fov defines the horizontal field of view
  5423. * @param aspect defines the aspect ratio
  5424. * @param znear defines the near clip plane
  5425. * @param zfar defines the far clip plane
  5426. * @returns a new matrix as a right-handed perspective projection matrix
  5427. */
  5428. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5429. /**
  5430. * Stores a right-handed perspective projection into a given matrix
  5431. * @param fov defines the horizontal field of view
  5432. * @param aspect defines the aspect ratio
  5433. * @param znear defines the near clip plane
  5434. * @param zfar defines the far clip plane
  5435. * @param result defines the target matrix
  5436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5437. */
  5438. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5439. /**
  5440. * Stores a right-handed perspective projection into a given matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar not used as infinity is used as far clip
  5445. * @param result defines the target matrix
  5446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5447. */
  5448. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5449. /**
  5450. * Stores a perspective projection for WebVR info a given matrix
  5451. * @param fov defines the field of view
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5456. */
  5457. static PerspectiveFovWebVRToRef(fov: {
  5458. upDegrees: number;
  5459. downDegrees: number;
  5460. leftDegrees: number;
  5461. rightDegrees: number;
  5462. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5463. /**
  5464. * Computes a complete transformation matrix
  5465. * @param viewport defines the viewport to use
  5466. * @param world defines the world matrix
  5467. * @param view defines the view matrix
  5468. * @param projection defines the projection matrix
  5469. * @param zmin defines the near clip plane
  5470. * @param zmax defines the far clip plane
  5471. * @returns the transformation matrix
  5472. */
  5473. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5474. /**
  5475. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5476. * @param matrix defines the matrix to use
  5477. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5478. */
  5479. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5480. /**
  5481. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5482. * @param matrix defines the matrix to use
  5483. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5484. */
  5485. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5486. /**
  5487. * Compute the transpose of a given matrix
  5488. * @param matrix defines the matrix to transpose
  5489. * @returns the new matrix
  5490. */
  5491. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5492. /**
  5493. * Compute the transpose of a matrix and store it in a target matrix
  5494. * @param matrix defines the matrix to transpose
  5495. * @param result defines the target matrix
  5496. */
  5497. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5498. /**
  5499. * Computes a reflection matrix from a plane
  5500. * @param plane defines the reflection plane
  5501. * @returns a new matrix
  5502. */
  5503. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5504. /**
  5505. * Computes a reflection matrix from a plane
  5506. * @param plane defines the reflection plane
  5507. * @param result defines the target matrix
  5508. */
  5509. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5510. /**
  5511. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5512. * @param xaxis defines the value of the 1st axis
  5513. * @param yaxis defines the value of the 2nd axis
  5514. * @param zaxis defines the value of the 3rd axis
  5515. * @param result defines the target matrix
  5516. */
  5517. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5518. /**
  5519. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5520. * @param quat defines the quaternion to use
  5521. * @param result defines the target matrix
  5522. */
  5523. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5524. }
  5525. /**
  5526. * @hidden
  5527. */
  5528. export class TmpVectors {
  5529. static Vector2: Vector2[];
  5530. static Vector3: Vector3[];
  5531. static Vector4: Vector4[];
  5532. static Quaternion: Quaternion[];
  5533. static Matrix: Matrix[];
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Defines potential orientation for back face culling
  5539. */
  5540. export enum Orientation {
  5541. /**
  5542. * Clockwise
  5543. */
  5544. CW = 0,
  5545. /** Counter clockwise */
  5546. CCW = 1
  5547. }
  5548. /** Class used to represent a Bezier curve */
  5549. export class BezierCurve {
  5550. /**
  5551. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5552. * @param t defines the time
  5553. * @param x1 defines the left coordinate on X axis
  5554. * @param y1 defines the left coordinate on Y axis
  5555. * @param x2 defines the right coordinate on X axis
  5556. * @param y2 defines the right coordinate on Y axis
  5557. * @returns the interpolated value
  5558. */
  5559. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5560. }
  5561. /**
  5562. * Defines angle representation
  5563. */
  5564. export class Angle {
  5565. private _radians;
  5566. /**
  5567. * Creates an Angle object of "radians" radians (float).
  5568. * @param radians the angle in radians
  5569. */
  5570. constructor(radians: number);
  5571. /**
  5572. * Get value in degrees
  5573. * @returns the Angle value in degrees (float)
  5574. */
  5575. degrees(): number;
  5576. /**
  5577. * Get value in radians
  5578. * @returns the Angle value in radians (float)
  5579. */
  5580. radians(): number;
  5581. /**
  5582. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5583. * @param a defines first point as the origin
  5584. * @param b defines point
  5585. * @returns a new Angle
  5586. */
  5587. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5588. /**
  5589. * Gets a new Angle object from the given float in radians
  5590. * @param radians defines the angle value in radians
  5591. * @returns a new Angle
  5592. */
  5593. static FromRadians(radians: number): Angle;
  5594. /**
  5595. * Gets a new Angle object from the given float in degrees
  5596. * @param degrees defines the angle value in degrees
  5597. * @returns a new Angle
  5598. */
  5599. static FromDegrees(degrees: number): Angle;
  5600. }
  5601. /**
  5602. * This represents an arc in a 2d space.
  5603. */
  5604. export class Arc2 {
  5605. /** Defines the start point of the arc */
  5606. startPoint: Vector2;
  5607. /** Defines the mid point of the arc */
  5608. midPoint: Vector2;
  5609. /** Defines the end point of the arc */
  5610. endPoint: Vector2;
  5611. /**
  5612. * Defines the center point of the arc.
  5613. */
  5614. centerPoint: Vector2;
  5615. /**
  5616. * Defines the radius of the arc.
  5617. */
  5618. radius: number;
  5619. /**
  5620. * Defines the angle of the arc (from mid point to end point).
  5621. */
  5622. angle: Angle;
  5623. /**
  5624. * Defines the start angle of the arc (from start point to middle point).
  5625. */
  5626. startAngle: Angle;
  5627. /**
  5628. * Defines the orientation of the arc (clock wise/counter clock wise).
  5629. */
  5630. orientation: Orientation;
  5631. /**
  5632. * Creates an Arc object from the three given points : start, middle and end.
  5633. * @param startPoint Defines the start point of the arc
  5634. * @param midPoint Defines the midlle point of the arc
  5635. * @param endPoint Defines the end point of the arc
  5636. */
  5637. constructor(
  5638. /** Defines the start point of the arc */
  5639. startPoint: Vector2,
  5640. /** Defines the mid point of the arc */
  5641. midPoint: Vector2,
  5642. /** Defines the end point of the arc */
  5643. endPoint: Vector2);
  5644. }
  5645. /**
  5646. * Represents a 2D path made up of multiple 2D points
  5647. */
  5648. export class Path2 {
  5649. private _points;
  5650. private _length;
  5651. /**
  5652. * If the path start and end point are the same
  5653. */
  5654. closed: boolean;
  5655. /**
  5656. * Creates a Path2 object from the starting 2D coordinates x and y.
  5657. * @param x the starting points x value
  5658. * @param y the starting points y value
  5659. */
  5660. constructor(x: number, y: number);
  5661. /**
  5662. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5663. * @param x the added points x value
  5664. * @param y the added points y value
  5665. * @returns the updated Path2.
  5666. */
  5667. addLineTo(x: number, y: number): Path2;
  5668. /**
  5669. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5670. * @param midX middle point x value
  5671. * @param midY middle point y value
  5672. * @param endX end point x value
  5673. * @param endY end point y value
  5674. * @param numberOfSegments (default: 36)
  5675. * @returns the updated Path2.
  5676. */
  5677. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5678. /**
  5679. * Closes the Path2.
  5680. * @returns the Path2.
  5681. */
  5682. close(): Path2;
  5683. /**
  5684. * Gets the sum of the distance between each sequential point in the path
  5685. * @returns the Path2 total length (float).
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Gets the points which construct the path
  5690. * @returns the Path2 internal array of points.
  5691. */
  5692. getPoints(): Vector2[];
  5693. /**
  5694. * Retreives the point at the distance aways from the starting point
  5695. * @param normalizedLengthPosition the length along the path to retreive the point from
  5696. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5697. */
  5698. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5699. /**
  5700. * Creates a new path starting from an x and y position
  5701. * @param x starting x value
  5702. * @param y starting y value
  5703. * @returns a new Path2 starting at the coordinates (x, y).
  5704. */
  5705. static StartingAt(x: number, y: number): Path2;
  5706. }
  5707. /**
  5708. * Represents a 3D path made up of multiple 3D points
  5709. */
  5710. export class Path3D {
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[];
  5715. private _curve;
  5716. private _distances;
  5717. private _tangents;
  5718. private _normals;
  5719. private _binormals;
  5720. private _raw;
  5721. private _alignTangentsWithPath;
  5722. private readonly _pointAtData;
  5723. /**
  5724. * new Path3D(path, normal, raw)
  5725. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5726. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5727. * @param path an array of Vector3, the curve axis of the Path3D
  5728. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5729. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5730. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5731. */
  5732. constructor(
  5733. /**
  5734. * an array of Vector3, the curve axis of the Path3D
  5735. */
  5736. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getCurve(): Vector3[];
  5742. /**
  5743. * Returns the Path3D array of successive Vector3 designing its curve.
  5744. * @returns the Path3D array of successive Vector3 designing its curve.
  5745. */
  5746. getPoints(): Vector3[];
  5747. /**
  5748. * @returns the computed length (float) of the path.
  5749. */
  5750. length(): number;
  5751. /**
  5752. * Returns an array populated with tangent vectors on each Path3D curve point.
  5753. * @returns an array populated with tangent vectors on each Path3D curve point.
  5754. */
  5755. getTangents(): Vector3[];
  5756. /**
  5757. * Returns an array populated with normal vectors on each Path3D curve point.
  5758. * @returns an array populated with normal vectors on each Path3D curve point.
  5759. */
  5760. getNormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with binormal vectors on each Path3D curve point.
  5763. * @returns an array populated with binormal vectors on each Path3D curve point.
  5764. */
  5765. getBinormals(): Vector3[];
  5766. /**
  5767. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5768. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5769. */
  5770. getDistances(): number[];
  5771. /**
  5772. * Returns an interpolated point along this path
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @returns a new Vector3 as the point
  5775. */
  5776. getPointAt(position: number): Vector3;
  5777. /**
  5778. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5779. * @param position the position of the point along this path, from 0.0 to 1.0
  5780. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5781. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5782. */
  5783. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5784. /**
  5785. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5786. * @param position the position of the point along this path, from 0.0 to 1.0
  5787. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5788. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5789. */
  5790. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5791. /**
  5792. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5793. * @param position the position of the point along this path, from 0.0 to 1.0
  5794. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5795. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5796. */
  5797. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5798. /**
  5799. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5800. * @param position the position of the point along this path, from 0.0 to 1.0
  5801. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5802. */
  5803. getDistanceAt(position: number): number;
  5804. /**
  5805. * Returns the array index of the previous point of an interpolated point along this path
  5806. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5807. * @returns the array index
  5808. */
  5809. getPreviousPointIndexAt(position: number): number;
  5810. /**
  5811. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5812. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5813. * @returns the sub position
  5814. */
  5815. getSubPositionAt(position: number): number;
  5816. /**
  5817. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5818. * @param target the vector of which to get the closest position to
  5819. * @returns the position of the closest virtual point on this path to the target vector
  5820. */
  5821. getClosestPositionTo(target: Vector3): number;
  5822. /**
  5823. * Returns a sub path (slice) of this path
  5824. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5825. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5826. * @returns a sub path (slice) of this path
  5827. */
  5828. slice(start?: number, end?: number): Path3D;
  5829. /**
  5830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5831. * @param path path which all values are copied into the curves points
  5832. * @param firstNormal which should be projected onto the curve
  5833. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5834. * @returns the same object updated.
  5835. */
  5836. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5837. private _compute;
  5838. private _getFirstNonNullVector;
  5839. private _getLastNonNullVector;
  5840. private _normalVector;
  5841. /**
  5842. * Updates the point at data for an interpolated point along this curve
  5843. * @param position the position of the point along this curve, from 0.0 to 1.0
  5844. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5845. * @returns the (updated) point at data
  5846. */
  5847. private _updatePointAtData;
  5848. /**
  5849. * Updates the point at data from the specified parameters
  5850. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5851. * @param point the interpolated point
  5852. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5853. */
  5854. private _setPointAtData;
  5855. /**
  5856. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5857. */
  5858. private _updateInterpolationMatrix;
  5859. }
  5860. /**
  5861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5862. * A Curve3 is designed from a series of successive Vector3.
  5863. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5864. */
  5865. export class Curve3 {
  5866. private _points;
  5867. private _length;
  5868. /**
  5869. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5871. * @param v1 (Vector3) the control point
  5872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5873. * @param nbPoints (integer) the wanted number of points in the curve
  5874. * @returns the created Curve3
  5875. */
  5876. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5877. /**
  5878. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5879. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5880. * @param v1 (Vector3) the first control point
  5881. * @param v2 (Vector3) the second control point
  5882. * @param v3 (Vector3) the end point of the Cubic Bezier
  5883. * @param nbPoints (integer) the wanted number of points in the curve
  5884. * @returns the created Curve3
  5885. */
  5886. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5887. /**
  5888. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5889. * @param p1 (Vector3) the origin point of the Hermite Spline
  5890. * @param t1 (Vector3) the tangent vector at the origin point
  5891. * @param p2 (Vector3) the end point of the Hermite Spline
  5892. * @param t2 (Vector3) the tangent vector at the end point
  5893. * @param nbPoints (integer) the wanted number of points in the curve
  5894. * @returns the created Curve3
  5895. */
  5896. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5897. /**
  5898. * Returns a Curve3 object along a CatmullRom Spline curve :
  5899. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5900. * @param nbPoints (integer) the wanted number of points between each curve control points
  5901. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5909. * @param points points which make up the curve
  5910. */
  5911. constructor(points: Vector3[]);
  5912. /**
  5913. * @returns the Curve3 stored array of successive Vector3
  5914. */
  5915. getPoints(): Vector3[];
  5916. /**
  5917. * @returns the computed length (float) of the curve.
  5918. */
  5919. length(): number;
  5920. /**
  5921. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5922. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5923. * curveA and curveB keep unchanged.
  5924. * @param curve the curve to continue from this curve
  5925. * @returns the newly constructed curve
  5926. */
  5927. continue(curve: DeepImmutable<Curve3>): Curve3;
  5928. private _computeLength;
  5929. }
  5930. }
  5931. declare module BABYLON {
  5932. /**
  5933. * This represents the main contract an easing function should follow.
  5934. * Easing functions are used throughout the animation system.
  5935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5936. */
  5937. export interface IEasingFunction {
  5938. /**
  5939. * Given an input gradient between 0 and 1, this returns the corresponding value
  5940. * of the easing function.
  5941. * The link below provides some of the most common examples of easing functions.
  5942. * @see https://easings.net/
  5943. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5944. * @returns the corresponding value on the curve defined by the easing function
  5945. */
  5946. ease(gradient: number): number;
  5947. }
  5948. /**
  5949. * Base class used for every default easing function.
  5950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5951. */
  5952. export class EasingFunction implements IEasingFunction {
  5953. /**
  5954. * Interpolation follows the mathematical formula associated with the easing function.
  5955. */
  5956. static readonly EASINGMODE_EASEIN: number;
  5957. /**
  5958. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5959. */
  5960. static readonly EASINGMODE_EASEOUT: number;
  5961. /**
  5962. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5963. */
  5964. static readonly EASINGMODE_EASEINOUT: number;
  5965. private _easingMode;
  5966. /**
  5967. * Sets the easing mode of the current function.
  5968. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5969. */
  5970. setEasingMode(easingMode: number): void;
  5971. /**
  5972. * Gets the current easing mode.
  5973. * @returns the easing mode
  5974. */
  5975. getEasingMode(): number;
  5976. /**
  5977. * @hidden
  5978. */
  5979. easeInCore(gradient: number): number;
  5980. /**
  5981. * Given an input gradient between 0 and 1, this returns the corresponding value
  5982. * of the easing function.
  5983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5984. * @returns the corresponding value on the curve defined by the easing function
  5985. */
  5986. ease(gradient: number): number;
  5987. }
  5988. /**
  5989. * Easing function with a circle shape (see link below).
  5990. * @see https://easings.net/#easeInCirc
  5991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5992. */
  5993. export class CircleEase extends EasingFunction implements IEasingFunction {
  5994. /** @hidden */
  5995. easeInCore(gradient: number): number;
  5996. }
  5997. /**
  5998. * Easing function with a ease back shape (see link below).
  5999. * @see https://easings.net/#easeInBack
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class BackEase extends EasingFunction implements IEasingFunction {
  6003. /** Defines the amplitude of the function */
  6004. amplitude: number;
  6005. /**
  6006. * Instantiates a back ease easing
  6007. * @see https://easings.net/#easeInBack
  6008. * @param amplitude Defines the amplitude of the function
  6009. */
  6010. constructor(
  6011. /** Defines the amplitude of the function */
  6012. amplitude?: number);
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a bouncing shape (see link below).
  6018. * @see https://easings.net/#easeInBounce
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class BounceEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of bounces */
  6023. bounces: number;
  6024. /** Defines the amplitude of the bounce */
  6025. bounciness: number;
  6026. /**
  6027. * Instantiates a bounce easing
  6028. * @see https://easings.net/#easeInBounce
  6029. * @param bounces Defines the number of bounces
  6030. * @param bounciness Defines the amplitude of the bounce
  6031. */
  6032. constructor(
  6033. /** Defines the number of bounces */
  6034. bounces?: number,
  6035. /** Defines the amplitude of the bounce */
  6036. bounciness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a power of 3 shape (see link below).
  6042. * @see https://easings.net/#easeInCubic
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class CubicEase extends EasingFunction implements IEasingFunction {
  6046. /** @hidden */
  6047. easeInCore(gradient: number): number;
  6048. }
  6049. /**
  6050. * Easing function with an elastic shape (see link below).
  6051. * @see https://easings.net/#easeInElastic
  6052. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6053. */
  6054. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6055. /** Defines the number of oscillations*/
  6056. oscillations: number;
  6057. /** Defines the amplitude of the oscillations*/
  6058. springiness: number;
  6059. /**
  6060. * Instantiates an elastic easing function
  6061. * @see https://easings.net/#easeInElastic
  6062. * @param oscillations Defines the number of oscillations
  6063. * @param springiness Defines the amplitude of the oscillations
  6064. */
  6065. constructor(
  6066. /** Defines the number of oscillations*/
  6067. oscillations?: number,
  6068. /** Defines the amplitude of the oscillations*/
  6069. springiness?: number);
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an exponential shape (see link below).
  6075. * @see https://easings.net/#easeInExpo
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the exponent of the function */
  6080. exponent: number;
  6081. /**
  6082. * Instantiates an exponential easing function
  6083. * @see https://easings.net/#easeInExpo
  6084. * @param exponent Defines the exponent of the function
  6085. */
  6086. constructor(
  6087. /** Defines the exponent of the function */
  6088. exponent?: number);
  6089. /** @hidden */
  6090. easeInCore(gradient: number): number;
  6091. }
  6092. /**
  6093. * Easing function with a power shape (see link below).
  6094. * @see https://easings.net/#easeInQuad
  6095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6096. */
  6097. export class PowerEase extends EasingFunction implements IEasingFunction {
  6098. /** Defines the power of the function */
  6099. power: number;
  6100. /**
  6101. * Instantiates an power base easing function
  6102. * @see https://easings.net/#easeInQuad
  6103. * @param power Defines the power of the function
  6104. */
  6105. constructor(
  6106. /** Defines the power of the function */
  6107. power?: number);
  6108. /** @hidden */
  6109. easeInCore(gradient: number): number;
  6110. }
  6111. /**
  6112. * Easing function with a power of 2 shape (see link below).
  6113. * @see https://easings.net/#easeInQuad
  6114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power of 4 shape (see link below).
  6122. * @see https://easings.net/#easeInQuart
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power of 5 shape (see link below).
  6131. * @see https://easings.net/#easeInQuint
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6135. /** @hidden */
  6136. easeInCore(gradient: number): number;
  6137. }
  6138. /**
  6139. * Easing function with a sin shape (see link below).
  6140. * @see https://easings.net/#easeInSine
  6141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6142. */
  6143. export class SineEase extends EasingFunction implements IEasingFunction {
  6144. /** @hidden */
  6145. easeInCore(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a bezier shape (see link below).
  6149. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6153. /** Defines the x component of the start tangent in the bezier curve */
  6154. x1: number;
  6155. /** Defines the y component of the start tangent in the bezier curve */
  6156. y1: number;
  6157. /** Defines the x component of the end tangent in the bezier curve */
  6158. x2: number;
  6159. /** Defines the y component of the end tangent in the bezier curve */
  6160. y2: number;
  6161. /**
  6162. * Instantiates a bezier function
  6163. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6164. * @param x1 Defines the x component of the start tangent in the bezier curve
  6165. * @param y1 Defines the y component of the start tangent in the bezier curve
  6166. * @param x2 Defines the x component of the end tangent in the bezier curve
  6167. * @param y2 Defines the y component of the end tangent in the bezier curve
  6168. */
  6169. constructor(
  6170. /** Defines the x component of the start tangent in the bezier curve */
  6171. x1?: number,
  6172. /** Defines the y component of the start tangent in the bezier curve */
  6173. y1?: number,
  6174. /** Defines the x component of the end tangent in the bezier curve */
  6175. x2?: number,
  6176. /** Defines the y component of the end tangent in the bezier curve */
  6177. y2?: number);
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * Class used to hold a RGB color
  6185. */
  6186. export class Color3 {
  6187. /**
  6188. * Defines the red component (between 0 and 1, default is 0)
  6189. */
  6190. r: number;
  6191. /**
  6192. * Defines the green component (between 0 and 1, default is 0)
  6193. */
  6194. g: number;
  6195. /**
  6196. * Defines the blue component (between 0 and 1, default is 0)
  6197. */
  6198. b: number;
  6199. /**
  6200. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6201. * @param r defines the red component (between 0 and 1, default is 0)
  6202. * @param g defines the green component (between 0 and 1, default is 0)
  6203. * @param b defines the blue component (between 0 and 1, default is 0)
  6204. */
  6205. constructor(
  6206. /**
  6207. * Defines the red component (between 0 and 1, default is 0)
  6208. */
  6209. r?: number,
  6210. /**
  6211. * Defines the green component (between 0 and 1, default is 0)
  6212. */
  6213. g?: number,
  6214. /**
  6215. * Defines the blue component (between 0 and 1, default is 0)
  6216. */
  6217. b?: number);
  6218. /**
  6219. * Creates a string with the Color3 current values
  6220. * @returns the string representation of the Color3 object
  6221. */
  6222. toString(): string;
  6223. /**
  6224. * Returns the string "Color3"
  6225. * @returns "Color3"
  6226. */
  6227. getClassName(): string;
  6228. /**
  6229. * Compute the Color3 hash code
  6230. * @returns an unique number that can be used to hash Color3 objects
  6231. */
  6232. getHashCode(): number;
  6233. /**
  6234. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6235. * @param array defines the array where to store the r,g,b components
  6236. * @param index defines an optional index in the target array to define where to start storing values
  6237. * @returns the current Color3 object
  6238. */
  6239. toArray(array: FloatArray, index?: number): Color3;
  6240. /**
  6241. * Update the current color with values stored in an array from the starting index of the given array
  6242. * @param array defines the source array
  6243. * @param offset defines an offset in the source array
  6244. * @returns the current Color3 object
  6245. */
  6246. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6247. /**
  6248. * Returns a new Color4 object from the current Color3 and the given alpha
  6249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6250. * @returns a new Color4 object
  6251. */
  6252. toColor4(alpha?: number): Color4;
  6253. /**
  6254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6255. * @returns the new array
  6256. */
  6257. asArray(): number[];
  6258. /**
  6259. * Returns the luminance value
  6260. * @returns a float value
  6261. */
  6262. toLuminance(): number;
  6263. /**
  6264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6265. * @param otherColor defines the second operand
  6266. * @returns the new Color3 object
  6267. */
  6268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6269. /**
  6270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6271. * @param otherColor defines the second operand
  6272. * @param result defines the Color3 object where to store the result
  6273. * @returns the current Color3
  6274. */
  6275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6276. /**
  6277. * Determines equality between Color3 objects
  6278. * @param otherColor defines the second operand
  6279. * @returns true if the rgb values are equal to the given ones
  6280. */
  6281. equals(otherColor: DeepImmutable<Color3>): boolean;
  6282. /**
  6283. * Determines equality between the current Color3 object and a set of r,b,g values
  6284. * @param r defines the red component to check
  6285. * @param g defines the green component to check
  6286. * @param b defines the blue component to check
  6287. * @returns true if the rgb values are equal to the given ones
  6288. */
  6289. equalsFloats(r: number, g: number, b: number): boolean;
  6290. /**
  6291. * Multiplies in place each rgb value by scale
  6292. * @param scale defines the scaling factor
  6293. * @returns the updated Color3
  6294. */
  6295. scale(scale: number): Color3;
  6296. /**
  6297. * Multiplies the rgb values by scale and stores the result into "result"
  6298. * @param scale defines the scaling factor
  6299. * @param result defines the Color3 object where to store the result
  6300. * @returns the unmodified current Color3
  6301. */
  6302. scaleToRef(scale: number, result: Color3): Color3;
  6303. /**
  6304. * Scale the current Color3 values by a factor and add the result to a given Color3
  6305. * @param scale defines the scale factor
  6306. * @param result defines color to store the result into
  6307. * @returns the unmodified current Color3
  6308. */
  6309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6310. /**
  6311. * Clamps the rgb values by the min and max values and stores the result into "result"
  6312. * @param min defines minimum clamping value (default is 0)
  6313. * @param max defines maximum clamping value (default is 1)
  6314. * @param result defines color to store the result into
  6315. * @returns the original Color3
  6316. */
  6317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6318. /**
  6319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. add(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6333. * @param otherColor defines the second operand
  6334. * @returns the new Color3
  6335. */
  6336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6337. /**
  6338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6339. * @param otherColor defines the second operand
  6340. * @param result defines Color3 object to store the result into
  6341. * @returns the unmodified current Color3
  6342. */
  6343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6344. /**
  6345. * Copy the current object
  6346. * @returns a new Color3 copied the current one
  6347. */
  6348. clone(): Color3;
  6349. /**
  6350. * Copies the rgb values from the source in the current Color3
  6351. * @param source defines the source Color3 object
  6352. * @returns the updated Color3 object
  6353. */
  6354. copyFrom(source: DeepImmutable<Color3>): Color3;
  6355. /**
  6356. * Updates the Color3 rgb values from the given floats
  6357. * @param r defines the red component to read from
  6358. * @param g defines the green component to read from
  6359. * @param b defines the blue component to read from
  6360. * @returns the current Color3 object
  6361. */
  6362. copyFromFloats(r: number, g: number, b: number): Color3;
  6363. /**
  6364. * Updates the Color3 rgb values from the given floats
  6365. * @param r defines the red component to read from
  6366. * @param g defines the green component to read from
  6367. * @param b defines the blue component to read from
  6368. * @returns the current Color3 object
  6369. */
  6370. set(r: number, g: number, b: number): Color3;
  6371. /**
  6372. * Compute the Color3 hexadecimal code as a string
  6373. * @returns a string containing the hexadecimal representation of the Color3 object
  6374. */
  6375. toHexString(): string;
  6376. /**
  6377. * Computes a new Color3 converted from the current one to linear space
  6378. * @returns a new Color3 object
  6379. */
  6380. toLinearSpace(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @returns a new color3 representing the HSV values
  6384. */
  6385. toHSV(): Color3;
  6386. /**
  6387. * Converts current color in rgb space to HSV values
  6388. * @param result defines the Color3 where to store the HSV values
  6389. */
  6390. toHSVToRef(result: Color3): void;
  6391. /**
  6392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6393. * @param convertedColor defines the Color3 object where to store the linear space version
  6394. * @returns the unmodified Color3
  6395. */
  6396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6397. /**
  6398. * Computes a new Color3 converted from the current one to gamma space
  6399. * @returns a new Color3 object
  6400. */
  6401. toGammaSpace(): Color3;
  6402. /**
  6403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6404. * @param convertedColor defines the Color3 object where to store the gamma space version
  6405. * @returns the unmodified Color3
  6406. */
  6407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6408. private static _BlackReadOnly;
  6409. /**
  6410. * Convert Hue, saturation and value to a Color3 (RGB)
  6411. * @param hue defines the hue
  6412. * @param saturation defines the saturation
  6413. * @param value defines the value
  6414. * @param result defines the Color3 where to store the RGB values
  6415. */
  6416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6417. /**
  6418. * Creates a new Color3 from the string containing valid hexadecimal values
  6419. * @param hex defines a string containing valid hexadecimal values
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromHexString(hex: string): Color3;
  6423. /**
  6424. * Creates a new Color3 from the starting index of the given array
  6425. * @param array defines the source array
  6426. * @param offset defines an offset in the source array
  6427. * @returns a new Color3 object
  6428. */
  6429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6430. /**
  6431. * Creates a new Color3 from the starting index element of the given array
  6432. * @param array defines the source array to read from
  6433. * @param offset defines the offset in the source array
  6434. * @param result defines the target Color3 object
  6435. */
  6436. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6437. /**
  6438. * Creates a new Color3 from integer values (< 256)
  6439. * @param r defines the red component to read from (value between 0 and 255)
  6440. * @param g defines the green component to read from (value between 0 and 255)
  6441. * @param b defines the blue component to read from (value between 0 and 255)
  6442. * @returns a new Color3 object
  6443. */
  6444. static FromInts(r: number, g: number, b: number): Color3;
  6445. /**
  6446. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6447. * @param start defines the start Color3 value
  6448. * @param end defines the end Color3 value
  6449. * @param amount defines the gradient value between start and end
  6450. * @returns a new Color3 object
  6451. */
  6452. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6453. /**
  6454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6455. * @param left defines the start value
  6456. * @param right defines the end value
  6457. * @param amount defines the gradient factor
  6458. * @param result defines the Color3 object where to store the result
  6459. */
  6460. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6461. /**
  6462. * Returns a Color3 value containing a red color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Red(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a green color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Green(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a blue color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Blue(): Color3;
  6476. /**
  6477. * Returns a Color3 value containing a black color
  6478. * @returns a new Color3 object
  6479. */
  6480. static Black(): Color3;
  6481. /**
  6482. * Gets a Color3 value containing a black color that must not be updated
  6483. */
  6484. static get BlackReadOnly(): DeepImmutable<Color3>;
  6485. /**
  6486. * Returns a Color3 value containing a white color
  6487. * @returns a new Color3 object
  6488. */
  6489. static White(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a purple color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Purple(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a magenta color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Magenta(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a yellow color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Yellow(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a gray color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Gray(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a teal color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Teal(): Color3;
  6515. /**
  6516. * Returns a Color3 value containing a random color
  6517. * @returns a new Color3 object
  6518. */
  6519. static Random(): Color3;
  6520. }
  6521. /**
  6522. * Class used to hold a RBGA color
  6523. */
  6524. export class Color4 {
  6525. /**
  6526. * Defines the red component (between 0 and 1, default is 0)
  6527. */
  6528. r: number;
  6529. /**
  6530. * Defines the green component (between 0 and 1, default is 0)
  6531. */
  6532. g: number;
  6533. /**
  6534. * Defines the blue component (between 0 and 1, default is 0)
  6535. */
  6536. b: number;
  6537. /**
  6538. * Defines the alpha component (between 0 and 1, default is 1)
  6539. */
  6540. a: number;
  6541. /**
  6542. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6543. * @param r defines the red component (between 0 and 1, default is 0)
  6544. * @param g defines the green component (between 0 and 1, default is 0)
  6545. * @param b defines the blue component (between 0 and 1, default is 0)
  6546. * @param a defines the alpha component (between 0 and 1, default is 1)
  6547. */
  6548. constructor(
  6549. /**
  6550. * Defines the red component (between 0 and 1, default is 0)
  6551. */
  6552. r?: number,
  6553. /**
  6554. * Defines the green component (between 0 and 1, default is 0)
  6555. */
  6556. g?: number,
  6557. /**
  6558. * Defines the blue component (between 0 and 1, default is 0)
  6559. */
  6560. b?: number,
  6561. /**
  6562. * Defines the alpha component (between 0 and 1, default is 1)
  6563. */
  6564. a?: number);
  6565. /**
  6566. * Adds in place the given Color4 values to the current Color4 object
  6567. * @param right defines the second operand
  6568. * @returns the current updated Color4 object
  6569. */
  6570. addInPlace(right: DeepImmutable<Color4>): Color4;
  6571. /**
  6572. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6573. * @returns the new array
  6574. */
  6575. asArray(): number[];
  6576. /**
  6577. * Stores from the starting index in the given array the Color4 successive values
  6578. * @param array defines the array where to store the r,g,b components
  6579. * @param index defines an optional index in the target array to define where to start storing values
  6580. * @returns the current Color4 object
  6581. */
  6582. toArray(array: number[], index?: number): Color4;
  6583. /**
  6584. * Update the current color with values stored in an array from the starting index of the given array
  6585. * @param array defines the source array
  6586. * @param offset defines an offset in the source array
  6587. * @returns the current Color4 object
  6588. */
  6589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6590. /**
  6591. * Determines equality between Color4 objects
  6592. * @param otherColor defines the second operand
  6593. * @returns true if the rgba values are equal to the given ones
  6594. */
  6595. equals(otherColor: DeepImmutable<Color4>): boolean;
  6596. /**
  6597. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6598. * @param right defines the second operand
  6599. * @returns a new Color4 object
  6600. */
  6601. add(right: DeepImmutable<Color4>): Color4;
  6602. /**
  6603. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6604. * @param right defines the second operand
  6605. * @returns a new Color4 object
  6606. */
  6607. subtract(right: DeepImmutable<Color4>): Color4;
  6608. /**
  6609. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6610. * @param right defines the second operand
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current Color4 object
  6613. */
  6614. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6615. /**
  6616. * Creates a new Color4 with the current Color4 values multiplied by scale
  6617. * @param scale defines the scaling factor to apply
  6618. * @returns a new Color4 object
  6619. */
  6620. scale(scale: number): Color4;
  6621. /**
  6622. * Multiplies the current Color4 values by scale and stores the result in "result"
  6623. * @param scale defines the scaling factor to apply
  6624. * @param result defines the Color4 object where to store the result
  6625. * @returns the current unmodified Color4
  6626. */
  6627. scaleToRef(scale: number, result: Color4): Color4;
  6628. /**
  6629. * Scale the current Color4 values by a factor and add the result to a given Color4
  6630. * @param scale defines the scale factor
  6631. * @param result defines the Color4 object where to store the result
  6632. * @returns the unmodified current Color4
  6633. */
  6634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6635. /**
  6636. * Clamps the rgb values by the min and max values and stores the result into "result"
  6637. * @param min defines minimum clamping value (default is 0)
  6638. * @param max defines maximum clamping value (default is 1)
  6639. * @param result defines color to store the result into.
  6640. * @returns the cuurent Color4
  6641. */
  6642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6643. /**
  6644. * Multipy an Color4 value by another and return a new Color4 object
  6645. * @param color defines the Color4 value to multiply by
  6646. * @returns a new Color4 object
  6647. */
  6648. multiply(color: Color4): Color4;
  6649. /**
  6650. * Multipy a Color4 value by another and push the result in a reference value
  6651. * @param color defines the Color4 value to multiply by
  6652. * @param result defines the Color4 to fill the result in
  6653. * @returns the result Color4
  6654. */
  6655. multiplyToRef(color: Color4, result: Color4): Color4;
  6656. /**
  6657. * Creates a string with the Color4 current values
  6658. * @returns the string representation of the Color4 object
  6659. */
  6660. toString(): string;
  6661. /**
  6662. * Returns the string "Color4"
  6663. * @returns "Color4"
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Compute the Color4 hash code
  6668. * @returns an unique number that can be used to hash Color4 objects
  6669. */
  6670. getHashCode(): number;
  6671. /**
  6672. * Creates a new Color4 copied from the current one
  6673. * @returns a new Color4 object
  6674. */
  6675. clone(): Color4;
  6676. /**
  6677. * Copies the given Color4 values into the current one
  6678. * @param source defines the source Color4 object
  6679. * @returns the current updated Color4 object
  6680. */
  6681. copyFrom(source: Color4): Color4;
  6682. /**
  6683. * Copies the given float values into the current one
  6684. * @param r defines the red component to read from
  6685. * @param g defines the green component to read from
  6686. * @param b defines the blue component to read from
  6687. * @param a defines the alpha component to read from
  6688. * @returns the current updated Color4 object
  6689. */
  6690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6691. /**
  6692. * Copies the given float values into the current one
  6693. * @param r defines the red component to read from
  6694. * @param g defines the green component to read from
  6695. * @param b defines the blue component to read from
  6696. * @param a defines the alpha component to read from
  6697. * @returns the current updated Color4 object
  6698. */
  6699. set(r: number, g: number, b: number, a: number): Color4;
  6700. /**
  6701. * Compute the Color4 hexadecimal code as a string
  6702. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6703. * @returns a string containing the hexadecimal representation of the Color4 object
  6704. */
  6705. toHexString(returnAsColor3?: boolean): string;
  6706. /**
  6707. * Computes a new Color4 converted from the current one to linear space
  6708. * @returns a new Color4 object
  6709. */
  6710. toLinearSpace(): Color4;
  6711. /**
  6712. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6713. * @param convertedColor defines the Color4 object where to store the linear space version
  6714. * @returns the unmodified Color4
  6715. */
  6716. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6717. /**
  6718. * Computes a new Color4 converted from the current one to gamma space
  6719. * @returns a new Color4 object
  6720. */
  6721. toGammaSpace(): Color4;
  6722. /**
  6723. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6724. * @param convertedColor defines the Color4 object where to store the gamma space version
  6725. * @returns the unmodified Color4
  6726. */
  6727. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6728. /**
  6729. * Creates a new Color4 from the string containing valid hexadecimal values
  6730. * @param hex defines a string containing valid hexadecimal values
  6731. * @returns a new Color4 object
  6732. */
  6733. static FromHexString(hex: string): Color4;
  6734. /**
  6735. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6736. * @param left defines the start value
  6737. * @param right defines the end value
  6738. * @param amount defines the gradient factor
  6739. * @returns a new Color4 object
  6740. */
  6741. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6742. /**
  6743. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6744. * @param left defines the start value
  6745. * @param right defines the end value
  6746. * @param amount defines the gradient factor
  6747. * @param result defines the Color4 object where to store data
  6748. */
  6749. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6750. /**
  6751. * Creates a new Color4 from a Color3 and an alpha value
  6752. * @param color3 defines the source Color3 to read from
  6753. * @param alpha defines the alpha component (1.0 by default)
  6754. * @returns a new Color4 object
  6755. */
  6756. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6757. /**
  6758. * Creates a new Color4 from the starting index element of the given array
  6759. * @param array defines the source array to read from
  6760. * @param offset defines the offset in the source array
  6761. * @returns a new Color4 object
  6762. */
  6763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6764. /**
  6765. * Creates a new Color4 from the starting index element of the given array
  6766. * @param array defines the source array to read from
  6767. * @param offset defines the offset in the source array
  6768. * @param result defines the target Color4 object
  6769. */
  6770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6771. /**
  6772. * Creates a new Color3 from integer values (< 256)
  6773. * @param r defines the red component to read from (value between 0 and 255)
  6774. * @param g defines the green component to read from (value between 0 and 255)
  6775. * @param b defines the blue component to read from (value between 0 and 255)
  6776. * @param a defines the alpha component to read from (value between 0 and 255)
  6777. * @returns a new Color3 object
  6778. */
  6779. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6780. /**
  6781. * Check the content of a given array and convert it to an array containing RGBA data
  6782. * If the original array was already containing count * 4 values then it is returned directly
  6783. * @param colors defines the array to check
  6784. * @param count defines the number of RGBA data to expect
  6785. * @returns an array containing count * 4 values (RGBA)
  6786. */
  6787. static CheckColors4(colors: number[], count: number): number[];
  6788. }
  6789. /**
  6790. * @hidden
  6791. */
  6792. export class TmpColors {
  6793. static Color3: Color3[];
  6794. static Color4: Color4[];
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. /**
  6799. * Defines an interface which represents an animation key frame
  6800. */
  6801. export interface IAnimationKey {
  6802. /**
  6803. * Frame of the key frame
  6804. */
  6805. frame: number;
  6806. /**
  6807. * Value at the specifies key frame
  6808. */
  6809. value: any;
  6810. /**
  6811. * The input tangent for the cubic hermite spline
  6812. */
  6813. inTangent?: any;
  6814. /**
  6815. * The output tangent for the cubic hermite spline
  6816. */
  6817. outTangent?: any;
  6818. /**
  6819. * The animation interpolation type
  6820. */
  6821. interpolation?: AnimationKeyInterpolation;
  6822. }
  6823. /**
  6824. * Enum for the animation key frame interpolation type
  6825. */
  6826. export enum AnimationKeyInterpolation {
  6827. /**
  6828. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6829. */
  6830. STEP = 1
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Represents the range of an animation
  6836. */
  6837. export class AnimationRange {
  6838. /**The name of the animation range**/
  6839. name: string;
  6840. /**The starting frame of the animation */
  6841. from: number;
  6842. /**The ending frame of the animation*/
  6843. to: number;
  6844. /**
  6845. * Initializes the range of an animation
  6846. * @param name The name of the animation range
  6847. * @param from The starting frame of the animation
  6848. * @param to The ending frame of the animation
  6849. */
  6850. constructor(
  6851. /**The name of the animation range**/
  6852. name: string,
  6853. /**The starting frame of the animation */
  6854. from: number,
  6855. /**The ending frame of the animation*/
  6856. to: number);
  6857. /**
  6858. * Makes a copy of the animation range
  6859. * @returns A copy of the animation range
  6860. */
  6861. clone(): AnimationRange;
  6862. }
  6863. }
  6864. declare module BABYLON {
  6865. /**
  6866. * Composed of a frame, and an action function
  6867. */
  6868. export class AnimationEvent {
  6869. /** The frame for which the event is triggered **/
  6870. frame: number;
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void;
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined;
  6875. /**
  6876. * Specifies if the animation event is done
  6877. */
  6878. isDone: boolean;
  6879. /**
  6880. * Initializes the animation event
  6881. * @param frame The frame for which the event is triggered
  6882. * @param action The event to perform when triggered
  6883. * @param onlyOnce Specifies if the event should be triggered only once
  6884. */
  6885. constructor(
  6886. /** The frame for which the event is triggered **/
  6887. frame: number,
  6888. /** The event to perform when triggered **/
  6889. action: (currentFrame: number) => void,
  6890. /** Specifies if the event should be triggered only once**/
  6891. onlyOnce?: boolean | undefined);
  6892. /** @hidden */
  6893. _clone(): AnimationEvent;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Interface used to define a behavior
  6899. */
  6900. export interface Behavior<T> {
  6901. /** gets or sets behavior's name */
  6902. name: string;
  6903. /**
  6904. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6905. */
  6906. init(): void;
  6907. /**
  6908. * Called when the behavior is attached to a target
  6909. * @param target defines the target where the behavior is attached to
  6910. */
  6911. attach(target: T): void;
  6912. /**
  6913. * Called when the behavior is detached from its target
  6914. */
  6915. detach(): void;
  6916. }
  6917. /**
  6918. * Interface implemented by classes supporting behaviors
  6919. */
  6920. export interface IBehaviorAware<T> {
  6921. /**
  6922. * Attach a behavior
  6923. * @param behavior defines the behavior to attach
  6924. * @returns the current host
  6925. */
  6926. addBehavior(behavior: Behavior<T>): T;
  6927. /**
  6928. * Remove a behavior from the current object
  6929. * @param behavior defines the behavior to detach
  6930. * @returns the current host
  6931. */
  6932. removeBehavior(behavior: Behavior<T>): T;
  6933. /**
  6934. * Gets a behavior using its name to search
  6935. * @param name defines the name to search
  6936. * @returns the behavior or null if not found
  6937. */
  6938. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to provide helpers for slicing
  6944. */
  6945. export class SliceTools {
  6946. /**
  6947. * Provides a slice function that will work even on IE
  6948. * @param data defines the array to slice
  6949. * @param start defines the start of the data (optional)
  6950. * @param end defines the end of the data (optional)
  6951. * @returns the new sliced array
  6952. */
  6953. static Slice<T>(data: T, start?: number, end?: number): T;
  6954. /**
  6955. * Provides a slice function that will work even on IE
  6956. * The difference between this and Slice is that this will force-convert to array
  6957. * @param data defines the array to slice
  6958. * @param start defines the start of the data (optional)
  6959. * @param end defines the end of the data (optional)
  6960. * @returns the new sliced array
  6961. */
  6962. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to store data that will be store in GPU memory
  6968. */
  6969. export class Buffer {
  6970. private _engine;
  6971. private _buffer;
  6972. /** @hidden */
  6973. _data: Nullable<DataArray>;
  6974. private _updatable;
  6975. private _instanced;
  6976. private _divisor;
  6977. private _isAlreadyOwned;
  6978. /**
  6979. * Gets the byte stride.
  6980. */
  6981. readonly byteStride: number;
  6982. /**
  6983. * Constructor
  6984. * @param engine the engine
  6985. * @param data the data to use for this buffer
  6986. * @param updatable whether the data is updatable
  6987. * @param stride the stride (optional)
  6988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6989. * @param instanced whether the buffer is instanced (optional)
  6990. * @param useBytes set to true if the stride in in bytes (optional)
  6991. * @param divisor sets an optional divisor for instances (1 by default)
  6992. */
  6993. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6994. /**
  6995. * Create a new VertexBuffer based on the current buffer
  6996. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6997. * @param offset defines offset in the buffer (0 by default)
  6998. * @param size defines the size in floats of attributes (position is 3 for instance)
  6999. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7000. * @param instanced defines if the vertex buffer contains indexed data
  7001. * @param useBytes defines if the offset and stride are in bytes *
  7002. * @param divisor sets an optional divisor for instances (1 by default)
  7003. * @returns the new vertex buffer
  7004. */
  7005. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7006. /**
  7007. * Gets a boolean indicating if the Buffer is updatable?
  7008. * @returns true if the buffer is updatable
  7009. */
  7010. isUpdatable(): boolean;
  7011. /**
  7012. * Gets current buffer's data
  7013. * @returns a DataArray or null
  7014. */
  7015. getData(): Nullable<DataArray>;
  7016. /**
  7017. * Gets underlying native buffer
  7018. * @returns underlying native buffer
  7019. */
  7020. getBuffer(): Nullable<DataBuffer>;
  7021. /**
  7022. * Gets the stride in float32 units (i.e. byte stride / 4).
  7023. * May not be an integer if the byte stride is not divisible by 4.
  7024. * @returns the stride in float32 units
  7025. * @deprecated Please use byteStride instead.
  7026. */
  7027. getStrideSize(): number;
  7028. /**
  7029. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7030. * @param data defines the data to store
  7031. */
  7032. create(data?: Nullable<DataArray>): void;
  7033. /** @hidden */
  7034. _rebuild(): void;
  7035. /**
  7036. * Update current buffer data
  7037. * @param data defines the data to store
  7038. */
  7039. update(data: DataArray): void;
  7040. /**
  7041. * Updates the data directly.
  7042. * @param data the new data
  7043. * @param offset the new offset
  7044. * @param vertexCount the vertex count (optional)
  7045. * @param useBytes set to true if the offset is in bytes
  7046. */
  7047. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7048. /** @hidden */
  7049. _increaseReferences(): void;
  7050. /**
  7051. * Release all resources
  7052. */
  7053. dispose(): void;
  7054. }
  7055. /**
  7056. * Specialized buffer used to store vertex data
  7057. */
  7058. export class VertexBuffer {
  7059. private static _Counter;
  7060. /** @hidden */
  7061. _buffer: Buffer;
  7062. private _kind;
  7063. private _size;
  7064. private _ownsBuffer;
  7065. private _instanced;
  7066. private _instanceDivisor;
  7067. /**
  7068. * The byte type.
  7069. */
  7070. static readonly BYTE: number;
  7071. /**
  7072. * The unsigned byte type.
  7073. */
  7074. static readonly UNSIGNED_BYTE: number;
  7075. /**
  7076. * The short type.
  7077. */
  7078. static readonly SHORT: number;
  7079. /**
  7080. * The unsigned short type.
  7081. */
  7082. static readonly UNSIGNED_SHORT: number;
  7083. /**
  7084. * The integer type.
  7085. */
  7086. static readonly INT: number;
  7087. /**
  7088. * The unsigned integer type.
  7089. */
  7090. static readonly UNSIGNED_INT: number;
  7091. /**
  7092. * The float type.
  7093. */
  7094. static readonly FLOAT: number;
  7095. /**
  7096. * Gets or sets the instance divisor when in instanced mode
  7097. */
  7098. get instanceDivisor(): number;
  7099. set instanceDivisor(value: number);
  7100. /**
  7101. * Gets the byte stride.
  7102. */
  7103. readonly byteStride: number;
  7104. /**
  7105. * Gets the byte offset.
  7106. */
  7107. readonly byteOffset: number;
  7108. /**
  7109. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7110. */
  7111. readonly normalized: boolean;
  7112. /**
  7113. * Gets the data type of each component in the array.
  7114. */
  7115. readonly type: number;
  7116. /**
  7117. * Gets the unique id of this vertex buffer
  7118. */
  7119. readonly uniqueId: number;
  7120. /**
  7121. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  7122. * All buffers with the same format will have the same hash code
  7123. */
  7124. readonly hashCode: number;
  7125. /**
  7126. * Constructor
  7127. * @param engine the engine
  7128. * @param data the data to use for this vertex buffer
  7129. * @param kind the vertex buffer kind
  7130. * @param updatable whether the data is updatable
  7131. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7132. * @param stride the stride (optional)
  7133. * @param instanced whether the buffer is instanced (optional)
  7134. * @param offset the offset of the data (optional)
  7135. * @param size the number of components (optional)
  7136. * @param type the type of the component (optional)
  7137. * @param normalized whether the data contains normalized data (optional)
  7138. * @param useBytes set to true if stride and offset are in bytes (optional)
  7139. * @param divisor defines the instance divisor to use (1 by default)
  7140. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7141. */
  7142. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7143. private _computeHashCode;
  7144. /** @hidden */
  7145. _rebuild(): void;
  7146. /**
  7147. * Returns the kind of the VertexBuffer (string)
  7148. * @returns a string
  7149. */
  7150. getKind(): string;
  7151. /**
  7152. * Gets a boolean indicating if the VertexBuffer is updatable?
  7153. * @returns true if the buffer is updatable
  7154. */
  7155. isUpdatable(): boolean;
  7156. /**
  7157. * Gets current buffer's data
  7158. * @returns a DataArray or null
  7159. */
  7160. getData(): Nullable<DataArray>;
  7161. /**
  7162. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7163. * @param totalVertices number of vertices in the buffer to take into account
  7164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7165. * @returns a float array containing vertex data
  7166. */
  7167. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7168. /**
  7169. * Gets underlying native buffer
  7170. * @returns underlying native buffer
  7171. */
  7172. getBuffer(): Nullable<DataBuffer>;
  7173. /**
  7174. * Gets the stride in float32 units (i.e. byte stride / 4).
  7175. * May not be an integer if the byte stride is not divisible by 4.
  7176. * @returns the stride in float32 units
  7177. * @deprecated Please use byteStride instead.
  7178. */
  7179. getStrideSize(): number;
  7180. /**
  7181. * Returns the offset as a multiple of the type byte length.
  7182. * @returns the offset in bytes
  7183. * @deprecated Please use byteOffset instead.
  7184. */
  7185. getOffset(): number;
  7186. /**
  7187. * Returns the number of components per vertex attribute (integer)
  7188. * @returns the size in float
  7189. */
  7190. getSize(): number;
  7191. /**
  7192. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7193. * @returns true if this buffer is instanced
  7194. */
  7195. getIsInstanced(): boolean;
  7196. /**
  7197. * Returns the instancing divisor, zero for non-instanced (integer).
  7198. * @returns a number
  7199. */
  7200. getInstanceDivisor(): number;
  7201. /**
  7202. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7203. * @param data defines the data to store
  7204. */
  7205. create(data?: DataArray): void;
  7206. /**
  7207. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7208. * This function will create a new buffer if the current one is not updatable
  7209. * @param data defines the data to store
  7210. */
  7211. update(data: DataArray): void;
  7212. /**
  7213. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7214. * Returns the directly updated WebGLBuffer.
  7215. * @param data the new data
  7216. * @param offset the new offset
  7217. * @param useBytes set to true if the offset is in bytes
  7218. */
  7219. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7220. /**
  7221. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7222. */
  7223. dispose(): void;
  7224. /**
  7225. * Enumerates each value of this vertex buffer as numbers.
  7226. * @param count the number of values to enumerate
  7227. * @param callback the callback function called for each value
  7228. */
  7229. forEach(count: number, callback: (value: number, index: number) => void): void;
  7230. /**
  7231. * Positions
  7232. */
  7233. static readonly PositionKind: string;
  7234. /**
  7235. * Normals
  7236. */
  7237. static readonly NormalKind: string;
  7238. /**
  7239. * Tangents
  7240. */
  7241. static readonly TangentKind: string;
  7242. /**
  7243. * Texture coordinates
  7244. */
  7245. static readonly UVKind: string;
  7246. /**
  7247. * Texture coordinates 2
  7248. */
  7249. static readonly UV2Kind: string;
  7250. /**
  7251. * Texture coordinates 3
  7252. */
  7253. static readonly UV3Kind: string;
  7254. /**
  7255. * Texture coordinates 4
  7256. */
  7257. static readonly UV4Kind: string;
  7258. /**
  7259. * Texture coordinates 5
  7260. */
  7261. static readonly UV5Kind: string;
  7262. /**
  7263. * Texture coordinates 6
  7264. */
  7265. static readonly UV6Kind: string;
  7266. /**
  7267. * Colors
  7268. */
  7269. static readonly ColorKind: string;
  7270. /**
  7271. * Matrix indices (for bones)
  7272. */
  7273. static readonly MatricesIndicesKind: string;
  7274. /**
  7275. * Matrix weights (for bones)
  7276. */
  7277. static readonly MatricesWeightsKind: string;
  7278. /**
  7279. * Additional matrix indices (for bones)
  7280. */
  7281. static readonly MatricesIndicesExtraKind: string;
  7282. /**
  7283. * Additional matrix weights (for bones)
  7284. */
  7285. static readonly MatricesWeightsExtraKind: string;
  7286. /**
  7287. * Deduces the stride given a kind.
  7288. * @param kind The kind string to deduce
  7289. * @returns The deduced stride
  7290. */
  7291. static DeduceStride(kind: string): number;
  7292. /**
  7293. * Gets the byte length of the given type.
  7294. * @param type the type
  7295. * @returns the number of bytes
  7296. */
  7297. static GetTypeByteLength(type: number): number;
  7298. /**
  7299. * Enumerates each value of the given parameters as numbers.
  7300. * @param data the data to enumerate
  7301. * @param byteOffset the byte offset of the data
  7302. * @param byteStride the byte stride of the data
  7303. * @param componentCount the number of components per element
  7304. * @param componentType the type of the component
  7305. * @param count the number of values to enumerate
  7306. * @param normalized whether the data is normalized
  7307. * @param callback the callback function called for each value
  7308. */
  7309. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7310. private static _GetFloatValue;
  7311. }
  7312. }
  7313. declare module BABYLON {
  7314. /**
  7315. * @hidden
  7316. */
  7317. export class IntersectionInfo {
  7318. bu: Nullable<number>;
  7319. bv: Nullable<number>;
  7320. distance: number;
  7321. faceId: number;
  7322. subMeshId: number;
  7323. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7324. }
  7325. }
  7326. declare module BABYLON {
  7327. /**
  7328. * Class used to store bounding sphere information
  7329. */
  7330. export class BoundingSphere {
  7331. /**
  7332. * Gets the center of the bounding sphere in local space
  7333. */
  7334. readonly center: Vector3;
  7335. /**
  7336. * Radius of the bounding sphere in local space
  7337. */
  7338. radius: number;
  7339. /**
  7340. * Gets the center of the bounding sphere in world space
  7341. */
  7342. readonly centerWorld: Vector3;
  7343. /**
  7344. * Radius of the bounding sphere in world space
  7345. */
  7346. radiusWorld: number;
  7347. /**
  7348. * Gets the minimum vector in local space
  7349. */
  7350. readonly minimum: Vector3;
  7351. /**
  7352. * Gets the maximum vector in local space
  7353. */
  7354. readonly maximum: Vector3;
  7355. private _worldMatrix;
  7356. private static readonly TmpVector3;
  7357. /**
  7358. * Creates a new bounding sphere
  7359. * @param min defines the minimum vector (in local space)
  7360. * @param max defines the maximum vector (in local space)
  7361. * @param worldMatrix defines the new world matrix
  7362. */
  7363. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7364. /**
  7365. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7366. * @param min defines the new minimum vector (in local space)
  7367. * @param max defines the new maximum vector (in local space)
  7368. * @param worldMatrix defines the new world matrix
  7369. */
  7370. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7371. /**
  7372. * Scale the current bounding sphere by applying a scale factor
  7373. * @param factor defines the scale factor to apply
  7374. * @returns the current bounding box
  7375. */
  7376. scale(factor: number): BoundingSphere;
  7377. /**
  7378. * Gets the world matrix of the bounding box
  7379. * @returns a matrix
  7380. */
  7381. getWorldMatrix(): DeepImmutable<Matrix>;
  7382. /** @hidden */
  7383. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7384. /**
  7385. * Tests if the bounding sphere is intersecting the frustum planes
  7386. * @param frustumPlanes defines the frustum planes to test
  7387. * @returns true if there is an intersection
  7388. */
  7389. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7390. /**
  7391. * Tests if the bounding sphere center is in between the frustum planes.
  7392. * Used for optimistic fast inclusion.
  7393. * @param frustumPlanes defines the frustum planes to test
  7394. * @returns true if the sphere center is in between the frustum planes
  7395. */
  7396. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7397. /**
  7398. * Tests if a point is inside the bounding sphere
  7399. * @param point defines the point to test
  7400. * @returns true if the point is inside the bounding sphere
  7401. */
  7402. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7403. /**
  7404. * Checks if two sphere intersect
  7405. * @param sphere0 sphere 0
  7406. * @param sphere1 sphere 1
  7407. * @returns true if the spheres intersect
  7408. */
  7409. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7410. }
  7411. }
  7412. declare module BABYLON {
  7413. /**
  7414. * Class used to store bounding box information
  7415. */
  7416. export class BoundingBox implements ICullable {
  7417. /**
  7418. * Gets the 8 vectors representing the bounding box in local space
  7419. */
  7420. readonly vectors: Vector3[];
  7421. /**
  7422. * Gets the center of the bounding box in local space
  7423. */
  7424. readonly center: Vector3;
  7425. /**
  7426. * Gets the center of the bounding box in world space
  7427. */
  7428. readonly centerWorld: Vector3;
  7429. /**
  7430. * Gets the extend size in local space
  7431. */
  7432. readonly extendSize: Vector3;
  7433. /**
  7434. * Gets the extend size in world space
  7435. */
  7436. readonly extendSizeWorld: Vector3;
  7437. /**
  7438. * Gets the OBB (object bounding box) directions
  7439. */
  7440. readonly directions: Vector3[];
  7441. /**
  7442. * Gets the 8 vectors representing the bounding box in world space
  7443. */
  7444. readonly vectorsWorld: Vector3[];
  7445. /**
  7446. * Gets the minimum vector in world space
  7447. */
  7448. readonly minimumWorld: Vector3;
  7449. /**
  7450. * Gets the maximum vector in world space
  7451. */
  7452. readonly maximumWorld: Vector3;
  7453. /**
  7454. * Gets the minimum vector in local space
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * Gets the maximum vector in local space
  7459. */
  7460. readonly maximum: Vector3;
  7461. private _worldMatrix;
  7462. private static readonly TmpVector3;
  7463. /**
  7464. * @hidden
  7465. */
  7466. _tag: number;
  7467. /**
  7468. * Creates a new bounding box
  7469. * @param min defines the minimum vector (in local space)
  7470. * @param max defines the maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7474. /**
  7475. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7476. * @param min defines the new minimum vector (in local space)
  7477. * @param max defines the new maximum vector (in local space)
  7478. * @param worldMatrix defines the new world matrix
  7479. */
  7480. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7481. /**
  7482. * Scale the current bounding box by applying a scale factor
  7483. * @param factor defines the scale factor to apply
  7484. * @returns the current bounding box
  7485. */
  7486. scale(factor: number): BoundingBox;
  7487. /**
  7488. * Gets the world matrix of the bounding box
  7489. * @returns a matrix
  7490. */
  7491. getWorldMatrix(): DeepImmutable<Matrix>;
  7492. /** @hidden */
  7493. _update(world: DeepImmutable<Matrix>): void;
  7494. /**
  7495. * Tests if the bounding box is intersecting the frustum planes
  7496. * @param frustumPlanes defines the frustum planes to test
  7497. * @returns true if there is an intersection
  7498. */
  7499. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7500. /**
  7501. * Tests if the bounding box is entirely inside the frustum planes
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @returns true if there is an inclusion
  7504. */
  7505. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a point is inside the bounding box
  7508. * @param point defines the point to test
  7509. * @returns true if the point is inside the bounding box
  7510. */
  7511. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7512. /**
  7513. * Tests if the bounding box intersects with a bounding sphere
  7514. * @param sphere defines the sphere to test
  7515. * @returns true if there is an intersection
  7516. */
  7517. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7518. /**
  7519. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7520. * @param min defines the min vector to use
  7521. * @param max defines the max vector to use
  7522. * @returns true if there is an intersection
  7523. */
  7524. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7525. /**
  7526. * Tests if two bounding boxes are intersections
  7527. * @param box0 defines the first box to test
  7528. * @param box1 defines the second box to test
  7529. * @returns true if there is an intersection
  7530. */
  7531. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7532. /**
  7533. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7534. * @param minPoint defines the minimum vector of the bounding box
  7535. * @param maxPoint defines the maximum vector of the bounding box
  7536. * @param sphereCenter defines the sphere center
  7537. * @param sphereRadius defines the sphere radius
  7538. * @returns true if there is an intersection
  7539. */
  7540. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7541. /**
  7542. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7543. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7544. * @param frustumPlanes defines the frustum planes to test
  7545. * @return true if there is an inclusion
  7546. */
  7547. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7548. /**
  7549. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7550. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7551. * @param frustumPlanes defines the frustum planes to test
  7552. * @return true if there is an intersection
  7553. */
  7554. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /** @hidden */
  7559. export class Collider {
  7560. /** Define if a collision was found */
  7561. collisionFound: boolean;
  7562. /**
  7563. * Define last intersection point in local space
  7564. */
  7565. intersectionPoint: Vector3;
  7566. /**
  7567. * Define last collided mesh
  7568. */
  7569. collidedMesh: Nullable<AbstractMesh>;
  7570. private _collisionPoint;
  7571. private _planeIntersectionPoint;
  7572. private _tempVector;
  7573. private _tempVector2;
  7574. private _tempVector3;
  7575. private _tempVector4;
  7576. private _edge;
  7577. private _baseToVertex;
  7578. private _destinationPoint;
  7579. private _slidePlaneNormal;
  7580. private _displacementVector;
  7581. /** @hidden */
  7582. _radius: Vector3;
  7583. /** @hidden */
  7584. _retry: number;
  7585. private _velocity;
  7586. private _basePoint;
  7587. private _epsilon;
  7588. /** @hidden */
  7589. _velocityWorldLength: number;
  7590. /** @hidden */
  7591. _basePointWorld: Vector3;
  7592. private _velocityWorld;
  7593. private _normalizedVelocity;
  7594. /** @hidden */
  7595. _initialVelocity: Vector3;
  7596. /** @hidden */
  7597. _initialPosition: Vector3;
  7598. private _nearestDistance;
  7599. private _collisionMask;
  7600. get collisionMask(): number;
  7601. set collisionMask(mask: number);
  7602. /**
  7603. * Gets the plane normal used to compute the sliding response (in local space)
  7604. */
  7605. get slidePlaneNormal(): Vector3;
  7606. /** @hidden */
  7607. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7608. /** @hidden */
  7609. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7610. /** @hidden */
  7611. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7612. /** @hidden */
  7613. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7614. /** @hidden */
  7615. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7616. /** @hidden */
  7617. _getResponse(pos: Vector3, vel: Vector3): void;
  7618. }
  7619. }
  7620. declare module BABYLON {
  7621. /**
  7622. * Interface for cullable objects
  7623. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7624. */
  7625. export interface ICullable {
  7626. /**
  7627. * Checks if the object or part of the object is in the frustum
  7628. * @param frustumPlanes Camera near/planes
  7629. * @returns true if the object is in frustum otherwise false
  7630. */
  7631. isInFrustum(frustumPlanes: Plane[]): boolean;
  7632. /**
  7633. * Checks if a cullable object (mesh...) is in the camera frustum
  7634. * Unlike isInFrustum this checks the full bounding box
  7635. * @param frustumPlanes Camera near/planes
  7636. * @returns true if the object is in frustum otherwise false
  7637. */
  7638. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7639. }
  7640. /**
  7641. * Info for a bounding data of a mesh
  7642. */
  7643. export class BoundingInfo implements ICullable {
  7644. /**
  7645. * Bounding box for the mesh
  7646. */
  7647. readonly boundingBox: BoundingBox;
  7648. /**
  7649. * Bounding sphere for the mesh
  7650. */
  7651. readonly boundingSphere: BoundingSphere;
  7652. private _isLocked;
  7653. private static readonly TmpVector3;
  7654. /**
  7655. * Constructs bounding info
  7656. * @param minimum min vector of the bounding box/sphere
  7657. * @param maximum max vector of the bounding box/sphere
  7658. * @param worldMatrix defines the new world matrix
  7659. */
  7660. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7661. /**
  7662. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7663. * @param min defines the new minimum vector (in local space)
  7664. * @param max defines the new maximum vector (in local space)
  7665. * @param worldMatrix defines the new world matrix
  7666. */
  7667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7668. /**
  7669. * min vector of the bounding box/sphere
  7670. */
  7671. get minimum(): Vector3;
  7672. /**
  7673. * max vector of the bounding box/sphere
  7674. */
  7675. get maximum(): Vector3;
  7676. /**
  7677. * If the info is locked and won't be updated to avoid perf overhead
  7678. */
  7679. get isLocked(): boolean;
  7680. set isLocked(value: boolean);
  7681. /**
  7682. * Updates the bounding sphere and box
  7683. * @param world world matrix to be used to update
  7684. */
  7685. update(world: DeepImmutable<Matrix>): void;
  7686. /**
  7687. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7688. * @param center New center of the bounding info
  7689. * @param extend New extend of the bounding info
  7690. * @returns the current bounding info
  7691. */
  7692. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7693. /**
  7694. * Grows the bounding info to include the given point.
  7695. * @param point The point that will be included in the current bounding info
  7696. * @returns the current bounding info
  7697. */
  7698. encapsulate(point: Vector3): BoundingInfo;
  7699. /**
  7700. * Grows the bounding info to encapsulate the given bounding info.
  7701. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7702. * @returns the current bounding info
  7703. */
  7704. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7705. /**
  7706. * Scale the current bounding info by applying a scale factor
  7707. * @param factor defines the scale factor to apply
  7708. * @returns the current bounding info
  7709. */
  7710. scale(factor: number): BoundingInfo;
  7711. /**
  7712. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7713. * @param frustumPlanes defines the frustum to test
  7714. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7715. * @returns true if the bounding info is in the frustum planes
  7716. */
  7717. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7718. /**
  7719. * Gets the world distance between the min and max points of the bounding box
  7720. */
  7721. get diagonalLength(): number;
  7722. /**
  7723. * Checks if a cullable object (mesh...) is in the camera frustum
  7724. * Unlike isInFrustum this checks the full bounding box
  7725. * @param frustumPlanes Camera near/planes
  7726. * @returns true if the object is in frustum otherwise false
  7727. */
  7728. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7729. /** @hidden */
  7730. _checkCollision(collider: Collider): boolean;
  7731. /**
  7732. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7733. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7734. * @param point the point to check intersection with
  7735. * @returns if the point intersects
  7736. */
  7737. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7738. /**
  7739. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7741. * @param boundingInfo the bounding info to check intersection with
  7742. * @param precise if the intersection should be done using OBB
  7743. * @returns if the bounding info intersects
  7744. */
  7745. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Extracts minimum and maximum values from a list of indexed positions
  7751. * @param positions defines the positions to use
  7752. * @param indices defines the indices to the positions
  7753. * @param indexStart defines the start index
  7754. * @param indexCount defines the end index
  7755. * @param bias defines bias value to add to the result
  7756. * @return minimum and maximum values
  7757. */
  7758. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7759. minimum: Vector3;
  7760. maximum: Vector3;
  7761. };
  7762. /**
  7763. * Extracts minimum and maximum values from a list of positions
  7764. * @param positions defines the positions to use
  7765. * @param start defines the start index in the positions array
  7766. * @param count defines the number of positions to handle
  7767. * @param bias defines bias value to add to the result
  7768. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7769. * @return minimum and maximum values
  7770. */
  7771. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7772. minimum: Vector3;
  7773. maximum: Vector3;
  7774. };
  7775. }
  7776. declare module BABYLON {
  7777. /**
  7778. * Class used to manipulate GUIDs
  7779. */
  7780. export class GUID {
  7781. /**
  7782. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7783. * Be aware Math.random() could cause collisions, but:
  7784. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7785. * @returns a pseudo random id
  7786. */
  7787. static RandomId(): string;
  7788. }
  7789. }
  7790. declare module BABYLON {
  7791. /**
  7792. * Base class of all the textures in babylon.
  7793. * It groups all the common properties the materials, post process, lights... might need
  7794. * in order to make a correct use of the texture.
  7795. */
  7796. export class BaseTexture extends ThinTexture implements IAnimatable {
  7797. /**
  7798. * Default anisotropic filtering level for the application.
  7799. * It is set to 4 as a good tradeoff between perf and quality.
  7800. */
  7801. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7802. /**
  7803. * Gets or sets the unique id of the texture
  7804. */
  7805. uniqueId: number;
  7806. /**
  7807. * Define the name of the texture.
  7808. */
  7809. name: string;
  7810. /**
  7811. * Gets or sets an object used to store user defined information.
  7812. */
  7813. metadata: any;
  7814. /**
  7815. * For internal use only. Please do not use.
  7816. */
  7817. reservedDataStore: any;
  7818. private _hasAlpha;
  7819. /**
  7820. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7821. */
  7822. set hasAlpha(value: boolean);
  7823. get hasAlpha(): boolean;
  7824. /**
  7825. * Defines if the alpha value should be determined via the rgb values.
  7826. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7827. */
  7828. getAlphaFromRGB: boolean;
  7829. /**
  7830. * Intensity or strength of the texture.
  7831. * It is commonly used by materials to fine tune the intensity of the texture
  7832. */
  7833. level: number;
  7834. /**
  7835. * Define the UV channel to use starting from 0 and defaulting to 0.
  7836. * This is part of the texture as textures usually maps to one uv set.
  7837. */
  7838. coordinatesIndex: number;
  7839. protected _coordinatesMode: number;
  7840. /**
  7841. * How a texture is mapped.
  7842. *
  7843. * | Value | Type | Description |
  7844. * | ----- | ----------------------------------- | ----------- |
  7845. * | 0 | EXPLICIT_MODE | |
  7846. * | 1 | SPHERICAL_MODE | |
  7847. * | 2 | PLANAR_MODE | |
  7848. * | 3 | CUBIC_MODE | |
  7849. * | 4 | PROJECTION_MODE | |
  7850. * | 5 | SKYBOX_MODE | |
  7851. * | 6 | INVCUBIC_MODE | |
  7852. * | 7 | EQUIRECTANGULAR_MODE | |
  7853. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7854. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7855. */
  7856. set coordinatesMode(value: number);
  7857. get coordinatesMode(): number;
  7858. /**
  7859. * | Value | Type | Description |
  7860. * | ----- | ------------------ | ----------- |
  7861. * | 0 | CLAMP_ADDRESSMODE | |
  7862. * | 1 | WRAP_ADDRESSMODE | |
  7863. * | 2 | MIRROR_ADDRESSMODE | |
  7864. */
  7865. get wrapU(): number;
  7866. set wrapU(value: number);
  7867. /**
  7868. * | Value | Type | Description |
  7869. * | ----- | ------------------ | ----------- |
  7870. * | 0 | CLAMP_ADDRESSMODE | |
  7871. * | 1 | WRAP_ADDRESSMODE | |
  7872. * | 2 | MIRROR_ADDRESSMODE | |
  7873. */
  7874. get wrapV(): number;
  7875. set wrapV(value: number);
  7876. /**
  7877. * | Value | Type | Description |
  7878. * | ----- | ------------------ | ----------- |
  7879. * | 0 | CLAMP_ADDRESSMODE | |
  7880. * | 1 | WRAP_ADDRESSMODE | |
  7881. * | 2 | MIRROR_ADDRESSMODE | |
  7882. */
  7883. wrapR: number;
  7884. /**
  7885. * With compliant hardware and browser (supporting anisotropic filtering)
  7886. * this defines the level of anisotropic filtering in the texture.
  7887. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7888. */
  7889. anisotropicFilteringLevel: number;
  7890. private _isCube;
  7891. /**
  7892. * Define if the texture is a cube texture or if false a 2d texture.
  7893. */
  7894. get isCube(): boolean;
  7895. set isCube(value: boolean);
  7896. /**
  7897. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7898. */
  7899. get is3D(): boolean;
  7900. set is3D(value: boolean);
  7901. /**
  7902. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7903. */
  7904. get is2DArray(): boolean;
  7905. set is2DArray(value: boolean);
  7906. private _gammaSpace;
  7907. /**
  7908. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7909. * HDR texture are usually stored in linear space.
  7910. * This only impacts the PBR and Background materials
  7911. */
  7912. get gammaSpace(): boolean;
  7913. set gammaSpace(gamma: boolean);
  7914. /**
  7915. * Gets or sets whether or not the texture contains RGBD data.
  7916. */
  7917. get isRGBD(): boolean;
  7918. set isRGBD(value: boolean);
  7919. /**
  7920. * Is Z inverted in the texture (useful in a cube texture).
  7921. */
  7922. invertZ: boolean;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. /**
  7928. * @hidden
  7929. */
  7930. lodLevelInAlpha: boolean;
  7931. /**
  7932. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7933. */
  7934. get lodGenerationOffset(): number;
  7935. set lodGenerationOffset(value: number);
  7936. /**
  7937. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7938. */
  7939. get lodGenerationScale(): number;
  7940. set lodGenerationScale(value: number);
  7941. /**
  7942. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7943. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7944. * average roughness values.
  7945. */
  7946. get linearSpecularLOD(): boolean;
  7947. set linearSpecularLOD(value: boolean);
  7948. /**
  7949. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7950. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7951. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7952. */
  7953. get irradianceTexture(): Nullable<BaseTexture>;
  7954. set irradianceTexture(value: Nullable<BaseTexture>);
  7955. /**
  7956. * Define if the texture is a render target.
  7957. */
  7958. isRenderTarget: boolean;
  7959. /**
  7960. * Define the unique id of the texture in the scene.
  7961. */
  7962. get uid(): string;
  7963. /** @hidden */
  7964. _prefiltered: boolean;
  7965. /**
  7966. * Return a string representation of the texture.
  7967. * @returns the texture as a string
  7968. */
  7969. toString(): string;
  7970. /**
  7971. * Get the class name of the texture.
  7972. * @returns "BaseTexture"
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Define the list of animation attached to the texture.
  7977. */
  7978. animations: Animation[];
  7979. /**
  7980. * An event triggered when the texture is disposed.
  7981. */
  7982. onDisposeObservable: Observable<BaseTexture>;
  7983. private _onDisposeObserver;
  7984. /**
  7985. * Callback triggered when the texture has been disposed.
  7986. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7987. */
  7988. set onDispose(callback: () => void);
  7989. protected _scene: Nullable<Scene>;
  7990. /** @hidden */
  7991. _texture: Nullable<InternalTexture>;
  7992. private _uid;
  7993. /**
  7994. * Define if the texture is preventing a material to render or not.
  7995. * If not and the texture is not ready, the engine will use a default black texture instead.
  7996. */
  7997. get isBlocking(): boolean;
  7998. /**
  7999. * Instantiates a new BaseTexture.
  8000. * Base class of all the textures in babylon.
  8001. * It groups all the common properties the materials, post process, lights... might need
  8002. * in order to make a correct use of the texture.
  8003. * @param sceneOrEngine Define the scene or engine the texture belongs to
  8004. */
  8005. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8006. /**
  8007. * Get the scene the texture belongs to.
  8008. * @returns the scene or null if undefined
  8009. */
  8010. getScene(): Nullable<Scene>;
  8011. /** @hidden */
  8012. protected _getEngine(): Nullable<ThinEngine>;
  8013. /**
  8014. * Checks if the texture has the same transform matrix than another texture
  8015. * @param texture texture to check against
  8016. * @returns true if the transforms are the same, else false
  8017. */
  8018. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8019. /**
  8020. * Get the texture transform matrix used to offset tile the texture for instance.
  8021. * @returns the transformation matrix
  8022. */
  8023. getTextureMatrix(): Matrix;
  8024. /**
  8025. * Get the texture reflection matrix used to rotate/transform the reflection.
  8026. * @returns the reflection matrix
  8027. */
  8028. getReflectionTextureMatrix(): Matrix;
  8029. /**
  8030. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8031. * @returns true if ready or not blocking
  8032. */
  8033. isReadyOrNotBlocking(): boolean;
  8034. /**
  8035. * Scales the texture if is `canRescale()`
  8036. * @param ratio the resize factor we want to use to rescale
  8037. */
  8038. scale(ratio: number): void;
  8039. /**
  8040. * Get if the texture can rescale.
  8041. */
  8042. get canRescale(): boolean;
  8043. /** @hidden */
  8044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8045. /** @hidden */
  8046. _rebuild(): void;
  8047. /**
  8048. * Clones the texture.
  8049. * @returns the cloned texture
  8050. */
  8051. clone(): Nullable<BaseTexture>;
  8052. /**
  8053. * Get the texture underlying type (INT, FLOAT...)
  8054. */
  8055. get textureType(): number;
  8056. /**
  8057. * Get the texture underlying format (RGB, RGBA...)
  8058. */
  8059. get textureFormat(): number;
  8060. /**
  8061. * Indicates that textures need to be re-calculated for all materials
  8062. */
  8063. protected _markAllSubMeshesAsTexturesDirty(): void;
  8064. /**
  8065. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8066. * This will returns an RGBA array buffer containing either in values (0-255) or
  8067. * float values (0-1) depending of the underlying buffer type.
  8068. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8069. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8070. * @param buffer defines a user defined buffer to fill with data (can be null)
  8071. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8072. * @returns The Array buffer promise containing the pixels data.
  8073. */
  8074. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8075. /** @hidden */
  8076. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8077. /** @hidden */
  8078. get _lodTextureHigh(): Nullable<BaseTexture>;
  8079. /** @hidden */
  8080. get _lodTextureMid(): Nullable<BaseTexture>;
  8081. /** @hidden */
  8082. get _lodTextureLow(): Nullable<BaseTexture>;
  8083. /**
  8084. * Dispose the texture and release its associated resources.
  8085. */
  8086. dispose(): void;
  8087. /**
  8088. * Serialize the texture into a JSON representation that can be parsed later on.
  8089. * @returns the JSON representation of the texture
  8090. */
  8091. serialize(): any;
  8092. /**
  8093. * Helper function to be called back once a list of texture contains only ready textures.
  8094. * @param textures Define the list of textures to wait for
  8095. * @param callback Define the callback triggered once the entire list will be ready
  8096. */
  8097. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8098. private static _isScene;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /** @hidden */
  8103. export class WebGLDataBuffer extends DataBuffer {
  8104. private _buffer;
  8105. constructor(resource: WebGLBuffer);
  8106. get underlyingResource(): any;
  8107. }
  8108. }
  8109. declare module BABYLON {
  8110. /** @hidden */
  8111. export class WebGLPipelineContext implements IPipelineContext {
  8112. private _valueCache;
  8113. private _uniforms;
  8114. engine: ThinEngine;
  8115. program: Nullable<WebGLProgram>;
  8116. context?: WebGLRenderingContext;
  8117. vertexShader?: WebGLShader;
  8118. fragmentShader?: WebGLShader;
  8119. isParallelCompiled: boolean;
  8120. onCompiled?: () => void;
  8121. transformFeedback?: WebGLTransformFeedback | null;
  8122. vertexCompilationError: Nullable<string>;
  8123. fragmentCompilationError: Nullable<string>;
  8124. programLinkError: Nullable<string>;
  8125. programValidationError: Nullable<string>;
  8126. get isAsync(): boolean;
  8127. get isReady(): boolean;
  8128. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8129. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8130. [key: string]: number;
  8131. }, uniformsNames: string[], uniforms: {
  8132. [key: string]: Nullable<WebGLUniformLocation>;
  8133. }, samplerList: string[], samplers: {
  8134. [key: string]: number;
  8135. }, attributesNames: string[], attributes: number[]): void;
  8136. /**
  8137. * Release all associated resources.
  8138. **/
  8139. dispose(): void;
  8140. /** @hidden */
  8141. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8142. /** @hidden */
  8143. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8144. /** @hidden */
  8145. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8146. /** @hidden */
  8147. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8148. /**
  8149. * Sets an integer value on a uniform variable.
  8150. * @param uniformName Name of the variable.
  8151. * @param value Value to be set.
  8152. */
  8153. setInt(uniformName: string, value: number): void;
  8154. /**
  8155. * Sets a int2 on a uniform variable.
  8156. * @param uniformName Name of the variable.
  8157. * @param x First int in int2.
  8158. * @param y Second int in int2.
  8159. */
  8160. setInt2(uniformName: string, x: number, y: number): void;
  8161. /**
  8162. * Sets a int3 on a uniform variable.
  8163. * @param uniformName Name of the variable.
  8164. * @param x First int in int3.
  8165. * @param y Second int in int3.
  8166. * @param y Third int in int3.
  8167. */
  8168. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8169. /**
  8170. * Sets a int4 on a uniform variable.
  8171. * @param uniformName Name of the variable.
  8172. * @param x First int in int4.
  8173. * @param y Second int in int4.
  8174. * @param y Third int in int4.
  8175. * @param w Fourth int in int4.
  8176. */
  8177. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8178. /**
  8179. * Sets an int array on a uniform variable.
  8180. * @param uniformName Name of the variable.
  8181. * @param array array to be set.
  8182. */
  8183. setIntArray(uniformName: string, array: Int32Array): void;
  8184. /**
  8185. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8186. * @param uniformName Name of the variable.
  8187. * @param array array to be set.
  8188. */
  8189. setIntArray2(uniformName: string, array: Int32Array): void;
  8190. /**
  8191. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray3(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setIntArray4(uniformName: string, array: Int32Array): void;
  8202. /**
  8203. * Sets an array on a uniform variable.
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setArray(uniformName: string, array: number[]): void;
  8208. /**
  8209. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. */
  8213. setArray2(uniformName: string, array: number[]): void;
  8214. /**
  8215. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8216. * @param uniformName Name of the variable.
  8217. * @param array array to be set.
  8218. * @returns this effect.
  8219. */
  8220. setArray3(uniformName: string, array: number[]): void;
  8221. /**
  8222. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8223. * @param uniformName Name of the variable.
  8224. * @param array array to be set.
  8225. */
  8226. setArray4(uniformName: string, array: number[]): void;
  8227. /**
  8228. * Sets matrices on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param matrices matrices to be set.
  8231. */
  8232. setMatrices(uniformName: string, matrices: Float32Array): void;
  8233. /**
  8234. * Sets matrix on a uniform variable.
  8235. * @param uniformName Name of the variable.
  8236. * @param matrix matrix to be set.
  8237. */
  8238. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8239. /**
  8240. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8241. * @param uniformName Name of the variable.
  8242. * @param matrix matrix to be set.
  8243. */
  8244. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8245. /**
  8246. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8247. * @param uniformName Name of the variable.
  8248. * @param matrix matrix to be set.
  8249. */
  8250. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8251. /**
  8252. * Sets a float on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param value value to be set.
  8255. * @returns this effect.
  8256. */
  8257. setFloat(uniformName: string, value: number): void;
  8258. /**
  8259. * Sets a Vector2 on a uniform variable.
  8260. * @param uniformName Name of the variable.
  8261. * @param vector2 vector2 to be set.
  8262. */
  8263. setVector2(uniformName: string, vector2: IVector2Like): void;
  8264. /**
  8265. * Sets a float2 on a uniform variable.
  8266. * @param uniformName Name of the variable.
  8267. * @param x First float in float2.
  8268. * @param y Second float in float2.
  8269. */
  8270. setFloat2(uniformName: string, x: number, y: number): void;
  8271. /**
  8272. * Sets a Vector3 on a uniform variable.
  8273. * @param uniformName Name of the variable.
  8274. * @param vector3 Value to be set.
  8275. */
  8276. setVector3(uniformName: string, vector3: IVector3Like): void;
  8277. /**
  8278. * Sets a float3 on a uniform variable.
  8279. * @param uniformName Name of the variable.
  8280. * @param x First float in float3.
  8281. * @param y Second float in float3.
  8282. * @param z Third float in float3.
  8283. */
  8284. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8285. /**
  8286. * Sets a Vector4 on a uniform variable.
  8287. * @param uniformName Name of the variable.
  8288. * @param vector4 Value to be set.
  8289. */
  8290. setVector4(uniformName: string, vector4: IVector4Like): void;
  8291. /**
  8292. * Sets a float4 on a uniform variable.
  8293. * @param uniformName Name of the variable.
  8294. * @param x First float in float4.
  8295. * @param y Second float in float4.
  8296. * @param z Third float in float4.
  8297. * @param w Fourth float in float4.
  8298. * @returns this effect.
  8299. */
  8300. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8301. /**
  8302. * Sets a Color3 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param color3 Value to be set.
  8305. */
  8306. setColor3(uniformName: string, color3: IColor3Like): void;
  8307. /**
  8308. * Sets a Color4 on a uniform variable.
  8309. * @param uniformName Name of the variable.
  8310. * @param color3 Value to be set.
  8311. * @param alpha Alpha value to be set.
  8312. */
  8313. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8314. /**
  8315. * Sets a Color4 on a uniform variable
  8316. * @param uniformName defines the name of the variable
  8317. * @param color4 defines the value to be set
  8318. */
  8319. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8320. _getVertexShaderCode(): string | null;
  8321. _getFragmentShaderCode(): string | null;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. interface ThinEngine {
  8326. /**
  8327. * Create an uniform buffer
  8328. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8329. * @param elements defines the content of the uniform buffer
  8330. * @returns the webGL uniform buffer
  8331. */
  8332. createUniformBuffer(elements: FloatArray): DataBuffer;
  8333. /**
  8334. * Create a dynamic uniform buffer
  8335. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8336. * @param elements defines the content of the uniform buffer
  8337. * @returns the webGL uniform buffer
  8338. */
  8339. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8340. /**
  8341. * Update an existing uniform buffer
  8342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8343. * @param uniformBuffer defines the target uniform buffer
  8344. * @param elements defines the content to update
  8345. * @param offset defines the offset in the uniform buffer where update should start
  8346. * @param count defines the size of the data to update
  8347. */
  8348. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8349. /**
  8350. * Bind an uniform buffer to the current webGL context
  8351. * @param buffer defines the buffer to bind
  8352. */
  8353. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8354. /**
  8355. * Bind a buffer to the current webGL context at a given location
  8356. * @param buffer defines the buffer to bind
  8357. * @param location defines the index where to bind the buffer
  8358. * @param name Name of the uniform variable to bind
  8359. */
  8360. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8361. /**
  8362. * Bind a specific block at a given index in a specific shader program
  8363. * @param pipelineContext defines the pipeline context to use
  8364. * @param blockName defines the block name
  8365. * @param index defines the index where to bind the block
  8366. */
  8367. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8368. }
  8369. }
  8370. declare module BABYLON {
  8371. /**
  8372. * Uniform buffer objects.
  8373. *
  8374. * Handles blocks of uniform on the GPU.
  8375. *
  8376. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8377. *
  8378. * For more information, please refer to :
  8379. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8380. */
  8381. export class UniformBuffer {
  8382. /** @hidden */
  8383. static _updatedUbosInFrame: {
  8384. [name: string]: number;
  8385. };
  8386. private _engine;
  8387. private _buffer;
  8388. private _buffers;
  8389. private _bufferIndex;
  8390. private _createBufferOnWrite;
  8391. private _data;
  8392. private _bufferData;
  8393. private _dynamic?;
  8394. private _uniformLocations;
  8395. private _uniformSizes;
  8396. private _uniformArraySizes;
  8397. private _uniformLocationPointer;
  8398. private _needSync;
  8399. private _noUBO;
  8400. private _currentEffect;
  8401. private _currentEffectName;
  8402. private _name;
  8403. private _currentFrameId;
  8404. /** @hidden */
  8405. _alreadyBound: boolean;
  8406. private static _MAX_UNIFORM_SIZE;
  8407. private static _tempBuffer;
  8408. private static _tempBufferInt32View;
  8409. /**
  8410. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8415. /**
  8416. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8421. /**
  8422. * Lambda to Update a single float in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateFloat: (name: string, x: number) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of float in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of float in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of float in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Lambda to Update an array of float in a uniform buffer.
  8447. * This is dynamic to allow compat with webgl 1 and 2.
  8448. * You will need to pass the name of the uniform as well as the value.
  8449. */
  8450. updateFloatArray: (name: string, array: Float32Array) => void;
  8451. /**
  8452. * Lambda to Update an array of number in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateArray: (name: string, array: number[]) => void;
  8457. /**
  8458. * Lambda to Update an array of number in a uniform buffer.
  8459. * This is dynamic to allow compat with webgl 1 and 2.
  8460. * You will need to pass the name of the uniform as well as the value.
  8461. */
  8462. updateIntArray: (name: string, array: Int32Array) => void;
  8463. /**
  8464. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8469. /**
  8470. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8471. * This is dynamic to allow compat with webgl 1 and 2.
  8472. * You will need to pass the name of the uniform as well as the value.
  8473. */
  8474. updateMatrices: (name: string, mat: Float32Array) => void;
  8475. /**
  8476. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateVector3: (name: string, vector: Vector3) => void;
  8481. /**
  8482. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8483. * This is dynamic to allow compat with webgl 1 and 2.
  8484. * You will need to pass the name of the uniform as well as the value.
  8485. */
  8486. updateVector4: (name: string, vector: Vector4) => void;
  8487. /**
  8488. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8489. * This is dynamic to allow compat with webgl 1 and 2.
  8490. * You will need to pass the name of the uniform as well as the value.
  8491. */
  8492. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8493. /**
  8494. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8495. * This is dynamic to allow compat with webgl 1 and 2.
  8496. * You will need to pass the name of the uniform as well as the value.
  8497. */
  8498. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8499. /**
  8500. * Lambda to Update a int a uniform buffer.
  8501. * This is dynamic to allow compat with webgl 1 and 2.
  8502. * You will need to pass the name of the uniform as well as the value.
  8503. */
  8504. updateInt: (name: string, x: number, suffix?: string) => void;
  8505. /**
  8506. * Lambda to Update a vec2 of int in a uniform buffer.
  8507. * This is dynamic to allow compat with webgl 1 and 2.
  8508. * You will need to pass the name of the uniform as well as the value.
  8509. */
  8510. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8511. /**
  8512. * Lambda to Update a vec3 of int in a uniform buffer.
  8513. * This is dynamic to allow compat with webgl 1 and 2.
  8514. * You will need to pass the name of the uniform as well as the value.
  8515. */
  8516. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8517. /**
  8518. * Lambda to Update a vec4 of int in a uniform buffer.
  8519. * This is dynamic to allow compat with webgl 1 and 2.
  8520. * You will need to pass the name of the uniform as well as the value.
  8521. */
  8522. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8523. /**
  8524. * Instantiates a new Uniform buffer objects.
  8525. *
  8526. * Handles blocks of uniform on the GPU.
  8527. *
  8528. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8529. *
  8530. * For more information, please refer to :
  8531. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8532. * @param engine Define the engine the buffer is associated with
  8533. * @param data Define the data contained in the buffer
  8534. * @param dynamic Define if the buffer is updatable
  8535. * @param name to assign to the buffer (debugging purpose)
  8536. */
  8537. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8538. /**
  8539. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8540. * or just falling back on setUniformXXX calls.
  8541. */
  8542. get useUbo(): boolean;
  8543. /**
  8544. * Indicates if the WebGL underlying uniform buffer is in sync
  8545. * with the javascript cache data.
  8546. */
  8547. get isSync(): boolean;
  8548. /**
  8549. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8550. * Also, a dynamic UniformBuffer will disable cache verification and always
  8551. * update the underlying WebGL uniform buffer to the GPU.
  8552. * @returns if Dynamic, otherwise false
  8553. */
  8554. isDynamic(): boolean;
  8555. /**
  8556. * The data cache on JS side.
  8557. * @returns the underlying data as a float array
  8558. */
  8559. getData(): Float32Array;
  8560. /**
  8561. * The underlying WebGL Uniform buffer.
  8562. * @returns the webgl buffer
  8563. */
  8564. getBuffer(): Nullable<DataBuffer>;
  8565. /**
  8566. * std140 layout specifies how to align data within an UBO structure.
  8567. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8568. * for specs.
  8569. */
  8570. private _fillAlignment;
  8571. /**
  8572. * Adds an uniform in the buffer.
  8573. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8574. * for the layout to be correct !
  8575. * @param name Name of the uniform, as used in the uniform block in the shader.
  8576. * @param size Data size, or data directly.
  8577. * @param arraySize The number of elements in the array, 0 if not an array.
  8578. */
  8579. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8580. /**
  8581. * Adds a Matrix 4x4 to the uniform buffer.
  8582. * @param name Name of the uniform, as used in the uniform block in the shader.
  8583. * @param mat A 4x4 matrix.
  8584. */
  8585. addMatrix(name: string, mat: Matrix): void;
  8586. /**
  8587. * Adds a vec2 to the uniform buffer.
  8588. * @param name Name of the uniform, as used in the uniform block in the shader.
  8589. * @param x Define the x component value of the vec2
  8590. * @param y Define the y component value of the vec2
  8591. */
  8592. addFloat2(name: string, x: number, y: number): void;
  8593. /**
  8594. * Adds a vec3 to the uniform buffer.
  8595. * @param name Name of the uniform, as used in the uniform block in the shader.
  8596. * @param x Define the x component value of the vec3
  8597. * @param y Define the y component value of the vec3
  8598. * @param z Define the z component value of the vec3
  8599. */
  8600. addFloat3(name: string, x: number, y: number, z: number): void;
  8601. /**
  8602. * Adds a vec3 to the uniform buffer.
  8603. * @param name Name of the uniform, as used in the uniform block in the shader.
  8604. * @param color Define the vec3 from a Color
  8605. */
  8606. addColor3(name: string, color: Color3): void;
  8607. /**
  8608. * Adds a vec4 to the uniform buffer.
  8609. * @param name Name of the uniform, as used in the uniform block in the shader.
  8610. * @param color Define the rgb components from a Color
  8611. * @param alpha Define the a component of the vec4
  8612. */
  8613. addColor4(name: string, color: Color3, alpha: number): void;
  8614. /**
  8615. * Adds a vec3 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. * @param vector Define the vec3 components from a Vector
  8618. */
  8619. addVector3(name: string, vector: Vector3): void;
  8620. /**
  8621. * Adds a Matrix 3x3 to the uniform buffer.
  8622. * @param name Name of the uniform, as used in the uniform block in the shader.
  8623. */
  8624. addMatrix3x3(name: string): void;
  8625. /**
  8626. * Adds a Matrix 2x2 to the uniform buffer.
  8627. * @param name Name of the uniform, as used in the uniform block in the shader.
  8628. */
  8629. addMatrix2x2(name: string): void;
  8630. /**
  8631. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8632. */
  8633. create(): void;
  8634. /** @hidden */
  8635. _rebuild(): void;
  8636. /** @hidden */
  8637. get _numBuffers(): number;
  8638. /** @hidden */
  8639. get _indexBuffer(): number;
  8640. /** Gets the name of this buffer */
  8641. get name(): string;
  8642. /**
  8643. * Updates the WebGL Uniform Buffer on the GPU.
  8644. * If the `dynamic` flag is set to true, no cache comparison is done.
  8645. * Otherwise, the buffer will be updated only if the cache differs.
  8646. */
  8647. update(): void;
  8648. private _createNewBuffer;
  8649. private _checkNewFrame;
  8650. /**
  8651. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8652. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8653. * @param data Define the flattened data
  8654. * @param size Define the size of the data.
  8655. */
  8656. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8657. /**
  8658. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8659. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8660. * @param data Define the flattened data
  8661. * @param size Define the size of the data.
  8662. */
  8663. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8664. private _valueCache;
  8665. private _cacheMatrix;
  8666. private _updateMatrix3x3ForUniform;
  8667. private _updateMatrix3x3ForEffect;
  8668. private _updateMatrix2x2ForEffect;
  8669. private _updateMatrix2x2ForUniform;
  8670. private _updateFloatForEffect;
  8671. private _updateFloatForUniform;
  8672. private _updateFloat2ForEffect;
  8673. private _updateFloat2ForUniform;
  8674. private _updateFloat3ForEffect;
  8675. private _updateFloat3ForUniform;
  8676. private _updateFloat4ForEffect;
  8677. private _updateFloat4ForUniform;
  8678. private _updateFloatArrayForEffect;
  8679. private _updateFloatArrayForUniform;
  8680. private _updateArrayForEffect;
  8681. private _updateArrayForUniform;
  8682. private _updateIntArrayForEffect;
  8683. private _updateIntArrayForUniform;
  8684. private _updateMatrixForEffect;
  8685. private _updateMatrixForUniform;
  8686. private _updateMatricesForEffect;
  8687. private _updateMatricesForUniform;
  8688. private _updateVector3ForEffect;
  8689. private _updateVector3ForUniform;
  8690. private _updateVector4ForEffect;
  8691. private _updateVector4ForUniform;
  8692. private _updateColor3ForEffect;
  8693. private _updateColor3ForUniform;
  8694. private _updateColor4ForEffect;
  8695. private _updateColor4ForUniform;
  8696. private _updateIntForEffect;
  8697. private _updateIntForUniform;
  8698. private _updateInt2ForEffect;
  8699. private _updateInt2ForUniform;
  8700. private _updateInt3ForEffect;
  8701. private _updateInt3ForUniform;
  8702. private _updateInt4ForEffect;
  8703. private _updateInt4ForUniform;
  8704. /**
  8705. * Sets a sampler uniform on the effect.
  8706. * @param name Define the name of the sampler.
  8707. * @param texture Define the texture to set in the sampler
  8708. */
  8709. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8710. /**
  8711. * Directly updates the value of the uniform in the cache AND on the GPU.
  8712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8713. * @param data Define the flattened data
  8714. */
  8715. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8716. /**
  8717. * Binds this uniform buffer to an effect.
  8718. * @param effect Define the effect to bind the buffer to
  8719. * @param name Name of the uniform block in the shader.
  8720. */
  8721. bindToEffect(effect: Effect, name: string): void;
  8722. /**
  8723. * Disposes the uniform buffer.
  8724. */
  8725. dispose(): void;
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Manages the defines for the Material
  8731. */
  8732. export class MaterialDefines {
  8733. /** @hidden */
  8734. protected _keys: string[];
  8735. private _isDirty;
  8736. /** @hidden */
  8737. _renderId: number;
  8738. /** @hidden */
  8739. _areLightsDirty: boolean;
  8740. /** @hidden */
  8741. _areLightsDisposed: boolean;
  8742. /** @hidden */
  8743. _areAttributesDirty: boolean;
  8744. /** @hidden */
  8745. _areTexturesDirty: boolean;
  8746. /** @hidden */
  8747. _areFresnelDirty: boolean;
  8748. /** @hidden */
  8749. _areMiscDirty: boolean;
  8750. /** @hidden */
  8751. _arePrePassDirty: boolean;
  8752. /** @hidden */
  8753. _areImageProcessingDirty: boolean;
  8754. /** @hidden */
  8755. _normals: boolean;
  8756. /** @hidden */
  8757. _uvs: boolean;
  8758. /** @hidden */
  8759. _needNormals: boolean;
  8760. /** @hidden */
  8761. _needUVs: boolean;
  8762. [id: string]: any;
  8763. /**
  8764. * Specifies if the material needs to be re-calculated
  8765. */
  8766. get isDirty(): boolean;
  8767. /**
  8768. * Marks the material to indicate that it has been re-calculated
  8769. */
  8770. markAsProcessed(): void;
  8771. /**
  8772. * Marks the material to indicate that it needs to be re-calculated
  8773. */
  8774. markAsUnprocessed(): void;
  8775. /**
  8776. * Marks the material to indicate all of its defines need to be re-calculated
  8777. */
  8778. markAllAsDirty(): void;
  8779. /**
  8780. * Marks the material to indicate that image processing needs to be re-calculated
  8781. */
  8782. markAsImageProcessingDirty(): void;
  8783. /**
  8784. * Marks the material to indicate the lights need to be re-calculated
  8785. * @param disposed Defines whether the light is dirty due to dispose or not
  8786. */
  8787. markAsLightDirty(disposed?: boolean): void;
  8788. /**
  8789. * Marks the attribute state as changed
  8790. */
  8791. markAsAttributesDirty(): void;
  8792. /**
  8793. * Marks the texture state as changed
  8794. */
  8795. markAsTexturesDirty(): void;
  8796. /**
  8797. * Marks the fresnel state as changed
  8798. */
  8799. markAsFresnelDirty(): void;
  8800. /**
  8801. * Marks the misc state as changed
  8802. */
  8803. markAsMiscDirty(): void;
  8804. /**
  8805. * Marks the prepass state as changed
  8806. */
  8807. markAsPrePassDirty(): void;
  8808. /**
  8809. * Rebuilds the material defines
  8810. */
  8811. rebuild(): void;
  8812. /**
  8813. * Specifies if two material defines are equal
  8814. * @param other - A material define instance to compare to
  8815. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8816. */
  8817. isEqual(other: MaterialDefines): boolean;
  8818. /**
  8819. * Clones this instance's defines to another instance
  8820. * @param other - material defines to clone values to
  8821. */
  8822. cloneTo(other: MaterialDefines): void;
  8823. /**
  8824. * Resets the material define values
  8825. */
  8826. reset(): void;
  8827. /**
  8828. * Converts the material define values to a string
  8829. * @returns - String of material define information
  8830. */
  8831. toString(): string;
  8832. }
  8833. }
  8834. declare module BABYLON {
  8835. /**
  8836. * Enum that determines the text-wrapping mode to use.
  8837. */
  8838. export enum InspectableType {
  8839. /**
  8840. * Checkbox for booleans
  8841. */
  8842. Checkbox = 0,
  8843. /**
  8844. * Sliders for numbers
  8845. */
  8846. Slider = 1,
  8847. /**
  8848. * Vector3
  8849. */
  8850. Vector3 = 2,
  8851. /**
  8852. * Quaternions
  8853. */
  8854. Quaternion = 3,
  8855. /**
  8856. * Color3
  8857. */
  8858. Color3 = 4,
  8859. /**
  8860. * String
  8861. */
  8862. String = 5
  8863. }
  8864. /**
  8865. * Interface used to define custom inspectable properties.
  8866. * This interface is used by the inspector to display custom property grids
  8867. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8868. */
  8869. export interface IInspectable {
  8870. /**
  8871. * Gets the label to display
  8872. */
  8873. label: string;
  8874. /**
  8875. * Gets the name of the property to edit
  8876. */
  8877. propertyName: string;
  8878. /**
  8879. * Gets the type of the editor to use
  8880. */
  8881. type: InspectableType;
  8882. /**
  8883. * Gets the minimum value of the property when using in "slider" mode
  8884. */
  8885. min?: number;
  8886. /**
  8887. * Gets the maximum value of the property when using in "slider" mode
  8888. */
  8889. max?: number;
  8890. /**
  8891. * Gets the setp to use when using in "slider" mode
  8892. */
  8893. step?: number;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8900. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  8901. */
  8902. export abstract class Light extends Node {
  8903. /**
  8904. * Falloff Default: light is falling off following the material specification:
  8905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8906. */
  8907. static readonly FALLOFF_DEFAULT: number;
  8908. /**
  8909. * Falloff Physical: light is falling off following the inverse squared distance law.
  8910. */
  8911. static readonly FALLOFF_PHYSICAL: number;
  8912. /**
  8913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8914. * to enhance interoperability with other engines.
  8915. */
  8916. static readonly FALLOFF_GLTF: number;
  8917. /**
  8918. * Falloff Standard: light is falling off like in the standard material
  8919. * to enhance interoperability with other materials.
  8920. */
  8921. static readonly FALLOFF_STANDARD: number;
  8922. /**
  8923. * If every light affecting the material is in this lightmapMode,
  8924. * material.lightmapTexture adds or multiplies
  8925. * (depends on material.useLightmapAsShadowmap)
  8926. * after every other light calculations.
  8927. */
  8928. static readonly LIGHTMAP_DEFAULT: number;
  8929. /**
  8930. * material.lightmapTexture as only diffuse lighting from this light
  8931. * adds only specular lighting from this light
  8932. * adds dynamic shadows
  8933. */
  8934. static readonly LIGHTMAP_SPECULAR: number;
  8935. /**
  8936. * material.lightmapTexture as only lighting
  8937. * no light calculation from this light
  8938. * only adds dynamic shadows from this light
  8939. */
  8940. static readonly LIGHTMAP_SHADOWSONLY: number;
  8941. /**
  8942. * Each light type uses the default quantity according to its type:
  8943. * point/spot lights use luminous intensity
  8944. * directional lights use illuminance
  8945. */
  8946. static readonly INTENSITYMODE_AUTOMATIC: number;
  8947. /**
  8948. * lumen (lm)
  8949. */
  8950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8951. /**
  8952. * candela (lm/sr)
  8953. */
  8954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8955. /**
  8956. * lux (lm/m^2)
  8957. */
  8958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8959. /**
  8960. * nit (cd/m^2)
  8961. */
  8962. static readonly INTENSITYMODE_LUMINANCE: number;
  8963. /**
  8964. * Light type const id of the point light.
  8965. */
  8966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8967. /**
  8968. * Light type const id of the directional light.
  8969. */
  8970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8971. /**
  8972. * Light type const id of the spot light.
  8973. */
  8974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8975. /**
  8976. * Light type const id of the hemispheric light.
  8977. */
  8978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8979. /**
  8980. * Diffuse gives the basic color to an object.
  8981. */
  8982. diffuse: Color3;
  8983. /**
  8984. * Specular produces a highlight color on an object.
  8985. * Note: This is note affecting PBR materials.
  8986. */
  8987. specular: Color3;
  8988. /**
  8989. * Defines the falloff type for this light. This lets overriding how punctual light are
  8990. * falling off base on range or angle.
  8991. * This can be set to any values in Light.FALLOFF_x.
  8992. *
  8993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8994. * other types of materials.
  8995. */
  8996. falloffType: number;
  8997. /**
  8998. * Strength of the light.
  8999. * Note: By default it is define in the framework own unit.
  9000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9001. */
  9002. intensity: number;
  9003. private _range;
  9004. protected _inverseSquaredRange: number;
  9005. /**
  9006. * Defines how far from the source the light is impacting in scene units.
  9007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9008. */
  9009. get range(): number;
  9010. /**
  9011. * Defines how far from the source the light is impacting in scene units.
  9012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9013. */
  9014. set range(value: number);
  9015. /**
  9016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9017. * of light.
  9018. */
  9019. private _photometricScale;
  9020. private _intensityMode;
  9021. /**
  9022. * Gets the photometric scale used to interpret the intensity.
  9023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9024. */
  9025. get intensityMode(): number;
  9026. /**
  9027. * Sets the photometric scale used to interpret the intensity.
  9028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9029. */
  9030. set intensityMode(value: number);
  9031. private _radius;
  9032. /**
  9033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9034. */
  9035. get radius(): number;
  9036. /**
  9037. * sets the light radius used by PBR Materials to simulate soft area lights.
  9038. */
  9039. set radius(value: number);
  9040. private _renderPriority;
  9041. /**
  9042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9043. * exceeding the number allowed of the materials.
  9044. */
  9045. renderPriority: number;
  9046. private _shadowEnabled;
  9047. /**
  9048. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9049. * the current shadow generator.
  9050. */
  9051. get shadowEnabled(): boolean;
  9052. /**
  9053. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9054. * the current shadow generator.
  9055. */
  9056. set shadowEnabled(value: boolean);
  9057. private _includedOnlyMeshes;
  9058. /**
  9059. * Gets the only meshes impacted by this light.
  9060. */
  9061. get includedOnlyMeshes(): AbstractMesh[];
  9062. /**
  9063. * Sets the only meshes impacted by this light.
  9064. */
  9065. set includedOnlyMeshes(value: AbstractMesh[]);
  9066. private _excludedMeshes;
  9067. /**
  9068. * Gets the meshes not impacted by this light.
  9069. */
  9070. get excludedMeshes(): AbstractMesh[];
  9071. /**
  9072. * Sets the meshes not impacted by this light.
  9073. */
  9074. set excludedMeshes(value: AbstractMesh[]);
  9075. private _excludeWithLayerMask;
  9076. /**
  9077. * Gets the layer id use to find what meshes are not impacted by the light.
  9078. * Inactive if 0
  9079. */
  9080. get excludeWithLayerMask(): number;
  9081. /**
  9082. * Sets the layer id use to find what meshes are not impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. set excludeWithLayerMask(value: number);
  9086. private _includeOnlyWithLayerMask;
  9087. /**
  9088. * Gets the layer id use to find what meshes are impacted by the light.
  9089. * Inactive if 0
  9090. */
  9091. get includeOnlyWithLayerMask(): number;
  9092. /**
  9093. * Sets the layer id use to find what meshes are impacted by the light.
  9094. * Inactive if 0
  9095. */
  9096. set includeOnlyWithLayerMask(value: number);
  9097. private _lightmapMode;
  9098. /**
  9099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9100. */
  9101. get lightmapMode(): number;
  9102. /**
  9103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9104. */
  9105. set lightmapMode(value: number);
  9106. /**
  9107. * Shadow generator associated to the light.
  9108. * @hidden Internal use only.
  9109. */
  9110. _shadowGenerator: Nullable<IShadowGenerator>;
  9111. /**
  9112. * @hidden Internal use only.
  9113. */
  9114. _excludedMeshesIds: string[];
  9115. /**
  9116. * @hidden Internal use only.
  9117. */
  9118. _includedOnlyMeshesIds: string[];
  9119. /**
  9120. * The current light uniform buffer.
  9121. * @hidden Internal use only.
  9122. */
  9123. _uniformBuffer: UniformBuffer;
  9124. /** @hidden */
  9125. _renderId: number;
  9126. /**
  9127. * Creates a Light object in the scene.
  9128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9129. * @param name The friendly name of the light
  9130. * @param scene The scene the light belongs too
  9131. */
  9132. constructor(name: string, scene: Scene);
  9133. protected abstract _buildUniformLayout(): void;
  9134. /**
  9135. * Sets the passed Effect "effect" with the Light information.
  9136. * @param effect The effect to update
  9137. * @param lightIndex The index of the light in the effect to update
  9138. * @returns The light
  9139. */
  9140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9141. /**
  9142. * Sets the passed Effect "effect" with the Light textures.
  9143. * @param effect The effect to update
  9144. * @param lightIndex The index of the light in the effect to update
  9145. * @returns The light
  9146. */
  9147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9148. /**
  9149. * Binds the lights information from the scene to the effect for the given mesh.
  9150. * @param lightIndex Light index
  9151. * @param scene The scene where the light belongs to
  9152. * @param effect The effect we are binding the data to
  9153. * @param useSpecular Defines if specular is supported
  9154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9155. */
  9156. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9157. /**
  9158. * Sets the passed Effect "effect" with the Light information.
  9159. * @param effect The effect to update
  9160. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9161. * @returns The light
  9162. */
  9163. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9164. /**
  9165. * Returns the string "Light".
  9166. * @returns the class name
  9167. */
  9168. getClassName(): string;
  9169. /** @hidden */
  9170. readonly _isLight: boolean;
  9171. /**
  9172. * Converts the light information to a readable string for debug purpose.
  9173. * @param fullDetails Supports for multiple levels of logging within scene loading
  9174. * @returns the human readable light info
  9175. */
  9176. toString(fullDetails?: boolean): string;
  9177. /** @hidden */
  9178. protected _syncParentEnabledState(): void;
  9179. /**
  9180. * Set the enabled state of this node.
  9181. * @param value - the new enabled state
  9182. */
  9183. setEnabled(value: boolean): void;
  9184. /**
  9185. * Returns the Light associated shadow generator if any.
  9186. * @return the associated shadow generator.
  9187. */
  9188. getShadowGenerator(): Nullable<IShadowGenerator>;
  9189. /**
  9190. * Returns a Vector3, the absolute light position in the World.
  9191. * @returns the world space position of the light
  9192. */
  9193. getAbsolutePosition(): Vector3;
  9194. /**
  9195. * Specifies if the light will affect the passed mesh.
  9196. * @param mesh The mesh to test against the light
  9197. * @return true the mesh is affected otherwise, false.
  9198. */
  9199. canAffectMesh(mesh: AbstractMesh): boolean;
  9200. /**
  9201. * Sort function to order lights for rendering.
  9202. * @param a First Light object to compare to second.
  9203. * @param b Second Light object to compare first.
  9204. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9205. */
  9206. static CompareLightsPriority(a: Light, b: Light): number;
  9207. /**
  9208. * Releases resources associated with this node.
  9209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9211. */
  9212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9213. /**
  9214. * Returns the light type ID (integer).
  9215. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9216. */
  9217. getTypeID(): number;
  9218. /**
  9219. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9220. * @returns the scaled intensity in intensity mode unit
  9221. */
  9222. getScaledIntensity(): number;
  9223. /**
  9224. * Returns a new Light object, named "name", from the current one.
  9225. * @param name The name of the cloned light
  9226. * @param newParent The parent of this light, if it has one
  9227. * @returns the new created light
  9228. */
  9229. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9230. /**
  9231. * Serializes the current light into a Serialization object.
  9232. * @returns the serialized object.
  9233. */
  9234. serialize(): any;
  9235. /**
  9236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9237. * This new light is named "name" and added to the passed scene.
  9238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9239. * @param name The friendly name of the light
  9240. * @param scene The scene the new light will belong to
  9241. * @returns the constructor function
  9242. */
  9243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9244. /**
  9245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9246. * @param parsedLight The JSON representation of the light
  9247. * @param scene The scene to create the parsed light in
  9248. * @returns the created light after parsing
  9249. */
  9250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9251. private _hookArrayForExcluded;
  9252. private _hookArrayForIncludedOnly;
  9253. private _resyncMeshes;
  9254. /**
  9255. * Forces the meshes to update their light related information in their rendering used effects
  9256. * @hidden Internal Use Only
  9257. */
  9258. _markMeshesAsLightDirty(): void;
  9259. /**
  9260. * Recomputes the cached photometric scale if needed.
  9261. */
  9262. private _computePhotometricScale;
  9263. /**
  9264. * Returns the Photometric Scale according to the light type and intensity mode.
  9265. */
  9266. private _getPhotometricScale;
  9267. /**
  9268. * Reorder the light in the scene according to their defined priority.
  9269. * @hidden Internal Use Only
  9270. */
  9271. _reorderLightsInScene(): void;
  9272. /**
  9273. * Prepares the list of defines specific to the light type.
  9274. * @param defines the list of defines
  9275. * @param lightIndex defines the index of the light for the effect
  9276. */
  9277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9278. }
  9279. }
  9280. declare module BABYLON {
  9281. /** Defines supported spaces */
  9282. export enum Space {
  9283. /** Local (object) space */
  9284. LOCAL = 0,
  9285. /** World space */
  9286. WORLD = 1,
  9287. /** Bone space */
  9288. BONE = 2
  9289. }
  9290. /** Defines the 3 main axes */
  9291. export class Axis {
  9292. /** X axis */
  9293. static X: Vector3;
  9294. /** Y axis */
  9295. static Y: Vector3;
  9296. /** Z axis */
  9297. static Z: Vector3;
  9298. }
  9299. /**
  9300. * Defines cartesian components.
  9301. */
  9302. export enum Coordinate {
  9303. /** X axis */
  9304. X = 0,
  9305. /** Y axis */
  9306. Y = 1,
  9307. /** Z axis */
  9308. Z = 2
  9309. }
  9310. }
  9311. declare module BABYLON {
  9312. /**
  9313. * Interface describing all the common properties and methods a shadow light needs to implement.
  9314. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9315. * as well as binding the different shadow properties to the effects.
  9316. */
  9317. export interface IShadowLight extends Light {
  9318. /**
  9319. * The light id in the scene (used in scene.findLightById for instance)
  9320. */
  9321. id: string;
  9322. /**
  9323. * The position the shadow will be casted from.
  9324. */
  9325. position: Vector3;
  9326. /**
  9327. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9328. */
  9329. direction: Vector3;
  9330. /**
  9331. * The transformed position. Position of the light in world space taking parenting in account.
  9332. */
  9333. transformedPosition: Vector3;
  9334. /**
  9335. * The transformed direction. Direction of the light in world space taking parenting in account.
  9336. */
  9337. transformedDirection: Vector3;
  9338. /**
  9339. * The friendly name of the light in the scene.
  9340. */
  9341. name: string;
  9342. /**
  9343. * Defines the shadow projection clipping minimum z value.
  9344. */
  9345. shadowMinZ: number;
  9346. /**
  9347. * Defines the shadow projection clipping maximum z value.
  9348. */
  9349. shadowMaxZ: number;
  9350. /**
  9351. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9352. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9353. */
  9354. computeTransformedInformation(): boolean;
  9355. /**
  9356. * Gets the scene the light belongs to.
  9357. * @returns The scene
  9358. */
  9359. getScene(): Scene;
  9360. /**
  9361. * Callback defining a custom Projection Matrix Builder.
  9362. * This can be used to override the default projection matrix computation.
  9363. */
  9364. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9365. /**
  9366. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9367. * @param matrix The matrix to updated with the projection information
  9368. * @param viewMatrix The transform matrix of the light
  9369. * @param renderList The list of mesh to render in the map
  9370. * @returns The current light
  9371. */
  9372. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9373. /**
  9374. * Gets the current depth scale used in ESM.
  9375. * @returns The scale
  9376. */
  9377. getDepthScale(): number;
  9378. /**
  9379. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9380. * @returns true if a cube texture needs to be use
  9381. */
  9382. needCube(): boolean;
  9383. /**
  9384. * Detects if the projection matrix requires to be recomputed this frame.
  9385. * @returns true if it requires to be recomputed otherwise, false.
  9386. */
  9387. needProjectionMatrixCompute(): boolean;
  9388. /**
  9389. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9390. */
  9391. forceProjectionMatrixCompute(): void;
  9392. /**
  9393. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9394. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9395. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9396. */
  9397. getShadowDirection(faceIndex?: number): Vector3;
  9398. /**
  9399. * Gets the minZ used for shadow according to both the scene and the light.
  9400. * @param activeCamera The camera we are returning the min for
  9401. * @returns the depth min z
  9402. */
  9403. getDepthMinZ(activeCamera: Camera): number;
  9404. /**
  9405. * Gets the maxZ used for shadow according to both the scene and the light.
  9406. * @param activeCamera The camera we are returning the max for
  9407. * @returns the depth max z
  9408. */
  9409. getDepthMaxZ(activeCamera: Camera): number;
  9410. }
  9411. /**
  9412. * Base implementation IShadowLight
  9413. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9414. */
  9415. export abstract class ShadowLight extends Light implements IShadowLight {
  9416. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9417. protected _position: Vector3;
  9418. protected _setPosition(value: Vector3): void;
  9419. /**
  9420. * Sets the position the shadow will be casted from. Also use as the light position for both
  9421. * point and spot lights.
  9422. */
  9423. get position(): Vector3;
  9424. /**
  9425. * Sets the position the shadow will be casted from. Also use as the light position for both
  9426. * point and spot lights.
  9427. */
  9428. set position(value: Vector3);
  9429. protected _direction: Vector3;
  9430. protected _setDirection(value: Vector3): void;
  9431. /**
  9432. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9433. * Also use as the light direction on spot and directional lights.
  9434. */
  9435. get direction(): Vector3;
  9436. /**
  9437. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9438. * Also use as the light direction on spot and directional lights.
  9439. */
  9440. set direction(value: Vector3);
  9441. protected _shadowMinZ: number;
  9442. /**
  9443. * Gets the shadow projection clipping minimum z value.
  9444. */
  9445. get shadowMinZ(): number;
  9446. /**
  9447. * Sets the shadow projection clipping minimum z value.
  9448. */
  9449. set shadowMinZ(value: number);
  9450. protected _shadowMaxZ: number;
  9451. /**
  9452. * Sets the shadow projection clipping maximum z value.
  9453. */
  9454. get shadowMaxZ(): number;
  9455. /**
  9456. * Gets the shadow projection clipping maximum z value.
  9457. */
  9458. set shadowMaxZ(value: number);
  9459. /**
  9460. * Callback defining a custom Projection Matrix Builder.
  9461. * This can be used to override the default projection matrix computation.
  9462. */
  9463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9464. /**
  9465. * The transformed position. Position of the light in world space taking parenting in account.
  9466. */
  9467. transformedPosition: Vector3;
  9468. /**
  9469. * The transformed direction. Direction of the light in world space taking parenting in account.
  9470. */
  9471. transformedDirection: Vector3;
  9472. private _needProjectionMatrixCompute;
  9473. /**
  9474. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9475. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9476. */
  9477. computeTransformedInformation(): boolean;
  9478. /**
  9479. * Return the depth scale used for the shadow map.
  9480. * @returns the depth scale.
  9481. */
  9482. getDepthScale(): number;
  9483. /**
  9484. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9485. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9486. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9487. */
  9488. getShadowDirection(faceIndex?: number): Vector3;
  9489. /**
  9490. * Returns the ShadowLight absolute position in the World.
  9491. * @returns the position vector in world space
  9492. */
  9493. getAbsolutePosition(): Vector3;
  9494. /**
  9495. * Sets the ShadowLight direction toward the passed target.
  9496. * @param target The point to target in local space
  9497. * @returns the updated ShadowLight direction
  9498. */
  9499. setDirectionToTarget(target: Vector3): Vector3;
  9500. /**
  9501. * Returns the light rotation in euler definition.
  9502. * @returns the x y z rotation in local space.
  9503. */
  9504. getRotation(): Vector3;
  9505. /**
  9506. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9507. * @returns true if a cube texture needs to be use
  9508. */
  9509. needCube(): boolean;
  9510. /**
  9511. * Detects if the projection matrix requires to be recomputed this frame.
  9512. * @returns true if it requires to be recomputed otherwise, false.
  9513. */
  9514. needProjectionMatrixCompute(): boolean;
  9515. /**
  9516. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9517. */
  9518. forceProjectionMatrixCompute(): void;
  9519. /** @hidden */
  9520. _initCache(): void;
  9521. /** @hidden */
  9522. _isSynchronized(): boolean;
  9523. /**
  9524. * Computes the world matrix of the node
  9525. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9526. * @returns the world matrix
  9527. */
  9528. computeWorldMatrix(force?: boolean): Matrix;
  9529. /**
  9530. * Gets the minZ used for shadow according to both the scene and the light.
  9531. * @param activeCamera The camera we are returning the min for
  9532. * @returns the depth min z
  9533. */
  9534. getDepthMinZ(activeCamera: Camera): number;
  9535. /**
  9536. * Gets the maxZ used for shadow according to both the scene and the light.
  9537. * @param activeCamera The camera we are returning the max for
  9538. * @returns the depth max z
  9539. */
  9540. getDepthMaxZ(activeCamera: Camera): number;
  9541. /**
  9542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9543. * @param matrix The matrix to updated with the projection information
  9544. * @param viewMatrix The transform matrix of the light
  9545. * @param renderList The list of mesh to render in the map
  9546. * @returns The current light
  9547. */
  9548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9549. }
  9550. }
  9551. declare module BABYLON {
  9552. /**
  9553. * Configuration needed for prepass-capable materials
  9554. */
  9555. export class PrePassConfiguration {
  9556. /**
  9557. * Previous world matrices of meshes carrying this material
  9558. * Used for computing velocity
  9559. */
  9560. previousWorldMatrices: {
  9561. [index: number]: Matrix;
  9562. };
  9563. /**
  9564. * Previous view project matrix
  9565. * Used for computing velocity
  9566. */
  9567. previousViewProjection: Matrix;
  9568. /**
  9569. * Previous bones of meshes carrying this material
  9570. * Used for computing velocity
  9571. */
  9572. previousBones: {
  9573. [index: number]: Float32Array;
  9574. };
  9575. /**
  9576. * Add the required uniforms to the current list.
  9577. * @param uniforms defines the current uniform list.
  9578. */
  9579. static AddUniforms(uniforms: string[]): void;
  9580. /**
  9581. * Add the required samplers to the current list.
  9582. * @param samplers defines the current sampler list.
  9583. */
  9584. static AddSamplers(samplers: string[]): void;
  9585. /**
  9586. * Binds the material data.
  9587. * @param effect defines the effect to update
  9588. * @param scene defines the scene the material belongs to.
  9589. * @param mesh The mesh
  9590. * @param world World matrix of this mesh
  9591. * @param isFrozen Is the material frozen
  9592. */
  9593. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9599. * This is the base of the follow, arc rotate cameras and Free camera
  9600. * @see https://doc.babylonjs.com/features/cameras
  9601. */
  9602. export class TargetCamera extends Camera {
  9603. private static _RigCamTransformMatrix;
  9604. private static _TargetTransformMatrix;
  9605. private static _TargetFocalPoint;
  9606. private _tmpUpVector;
  9607. private _tmpTargetVector;
  9608. /**
  9609. * Define the current direction the camera is moving to
  9610. */
  9611. cameraDirection: Vector3;
  9612. /**
  9613. * Define the current rotation the camera is rotating to
  9614. */
  9615. cameraRotation: Vector2;
  9616. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9617. ignoreParentScaling: boolean;
  9618. /**
  9619. * When set, the up vector of the camera will be updated by the rotation of the camera
  9620. */
  9621. updateUpVectorFromRotation: boolean;
  9622. private _tmpQuaternion;
  9623. /**
  9624. * Define the current rotation of the camera
  9625. */
  9626. rotation: Vector3;
  9627. /**
  9628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9629. */
  9630. rotationQuaternion: Quaternion;
  9631. /**
  9632. * Define the current speed of the camera
  9633. */
  9634. speed: number;
  9635. /**
  9636. * Add constraint to the camera to prevent it to move freely in all directions and
  9637. * around all axis.
  9638. */
  9639. noRotationConstraint: boolean;
  9640. /**
  9641. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9642. * panning
  9643. */
  9644. invertRotation: boolean;
  9645. /**
  9646. * Speed multiplier for inverse camera panning
  9647. */
  9648. inverseRotationSpeed: number;
  9649. /**
  9650. * Define the current target of the camera as an object or a position.
  9651. */
  9652. lockedTarget: any;
  9653. /** @hidden */
  9654. _currentTarget: Vector3;
  9655. /** @hidden */
  9656. _initialFocalDistance: number;
  9657. /** @hidden */
  9658. _viewMatrix: Matrix;
  9659. /** @hidden */
  9660. _camMatrix: Matrix;
  9661. /** @hidden */
  9662. _cameraTransformMatrix: Matrix;
  9663. /** @hidden */
  9664. _cameraRotationMatrix: Matrix;
  9665. /** @hidden */
  9666. _referencePoint: Vector3;
  9667. /** @hidden */
  9668. _transformedReferencePoint: Vector3;
  9669. /** @hidden */
  9670. _reset: () => void;
  9671. private _defaultUp;
  9672. /**
  9673. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9674. * This is the base of the follow, arc rotate cameras and Free camera
  9675. * @see https://doc.babylonjs.com/features/cameras
  9676. * @param name Defines the name of the camera in the scene
  9677. * @param position Defines the start position of the camera in the scene
  9678. * @param scene Defines the scene the camera belongs to
  9679. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9680. */
  9681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9682. /**
  9683. * Gets the position in front of the camera at a given distance.
  9684. * @param distance The distance from the camera we want the position to be
  9685. * @returns the position
  9686. */
  9687. getFrontPosition(distance: number): Vector3;
  9688. /** @hidden */
  9689. _getLockedTargetPosition(): Nullable<Vector3>;
  9690. private _storedPosition;
  9691. private _storedRotation;
  9692. private _storedRotationQuaternion;
  9693. /**
  9694. * Store current camera state of the camera (fov, position, rotation, etc..)
  9695. * @returns the camera
  9696. */
  9697. storeState(): Camera;
  9698. /**
  9699. * Restored camera state. You must call storeState() first
  9700. * @returns whether it was successful or not
  9701. * @hidden
  9702. */
  9703. _restoreStateValues(): boolean;
  9704. /** @hidden */
  9705. _initCache(): void;
  9706. /** @hidden */
  9707. _updateCache(ignoreParentClass?: boolean): void;
  9708. /** @hidden */
  9709. _isSynchronizedViewMatrix(): boolean;
  9710. /** @hidden */
  9711. _computeLocalCameraSpeed(): number;
  9712. /**
  9713. * Defines the target the camera should look at.
  9714. * @param target Defines the new target as a Vector or a mesh
  9715. */
  9716. setTarget(target: Vector3): void;
  9717. /**
  9718. * Defines the target point of the camera.
  9719. * The camera looks towards it form the radius distance.
  9720. */
  9721. get target(): Vector3;
  9722. set target(value: Vector3);
  9723. /**
  9724. * Return the current target position of the camera. This value is expressed in local space.
  9725. * @returns the target position
  9726. */
  9727. getTarget(): Vector3;
  9728. /** @hidden */
  9729. _decideIfNeedsToMove(): boolean;
  9730. /** @hidden */
  9731. _updatePosition(): void;
  9732. /** @hidden */
  9733. _checkInputs(): void;
  9734. protected _updateCameraRotationMatrix(): void;
  9735. /**
  9736. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9737. * @returns the current camera
  9738. */
  9739. private _rotateUpVectorWithCameraRotationMatrix;
  9740. private _cachedRotationZ;
  9741. private _cachedQuaternionRotationZ;
  9742. /** @hidden */
  9743. _getViewMatrix(): Matrix;
  9744. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9745. /**
  9746. * @hidden
  9747. */
  9748. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9749. /**
  9750. * @hidden
  9751. */
  9752. _updateRigCameras(): void;
  9753. private _getRigCamPositionAndTarget;
  9754. /**
  9755. * Gets the current object class name.
  9756. * @return the class name
  9757. */
  9758. getClassName(): string;
  9759. }
  9760. }
  9761. declare module BABYLON {
  9762. /**
  9763. * @ignore
  9764. * This is a list of all the different input types that are available in the application.
  9765. * Fo instance: ArcRotateCameraGamepadInput...
  9766. */
  9767. export var CameraInputTypes: {};
  9768. /**
  9769. * This is the contract to implement in order to create a new input class.
  9770. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9771. */
  9772. export interface ICameraInput<TCamera extends Camera> {
  9773. /**
  9774. * Defines the camera the input is attached to.
  9775. */
  9776. camera: Nullable<TCamera>;
  9777. /**
  9778. * Gets the class name of the current input.
  9779. * @returns the class name
  9780. */
  9781. getClassName(): string;
  9782. /**
  9783. * Get the friendly name associated with the input class.
  9784. * @returns the input friendly name
  9785. */
  9786. getSimpleName(): string;
  9787. /**
  9788. * Attach the input controls to a specific dom element to get the input from.
  9789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9790. */
  9791. attachControl(noPreventDefault?: boolean): void;
  9792. /**
  9793. * Detach the current controls from the specified dom element.
  9794. */
  9795. detachControl(): void;
  9796. /**
  9797. * Update the current camera state depending on the inputs that have been used this frame.
  9798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9799. */
  9800. checkInputs?: () => void;
  9801. }
  9802. /**
  9803. * Represents a map of input types to input instance or input index to input instance.
  9804. */
  9805. export interface CameraInputsMap<TCamera extends Camera> {
  9806. /**
  9807. * Accessor to the input by input type.
  9808. */
  9809. [name: string]: ICameraInput<TCamera>;
  9810. /**
  9811. * Accessor to the input by input index.
  9812. */
  9813. [idx: number]: ICameraInput<TCamera>;
  9814. }
  9815. /**
  9816. * This represents the input manager used within a camera.
  9817. * It helps dealing with all the different kind of input attached to a camera.
  9818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9819. */
  9820. export class CameraInputsManager<TCamera extends Camera> {
  9821. /**
  9822. * Defines the list of inputs attached to the camera.
  9823. */
  9824. attached: CameraInputsMap<TCamera>;
  9825. /**
  9826. * Defines the dom element the camera is collecting inputs from.
  9827. * This is null if the controls have not been attached.
  9828. */
  9829. attachedToElement: boolean;
  9830. /**
  9831. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9832. */
  9833. noPreventDefault: boolean;
  9834. /**
  9835. * Defined the camera the input manager belongs to.
  9836. */
  9837. camera: TCamera;
  9838. /**
  9839. * Update the current camera state depending on the inputs that have been used this frame.
  9840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9841. */
  9842. checkInputs: () => void;
  9843. /**
  9844. * Instantiate a new Camera Input Manager.
  9845. * @param camera Defines the camera the input manager belongs to
  9846. */
  9847. constructor(camera: TCamera);
  9848. /**
  9849. * Add an input method to a camera
  9850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9851. * @param input camera input method
  9852. */
  9853. add(input: ICameraInput<TCamera>): void;
  9854. /**
  9855. * Remove a specific input method from a camera
  9856. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9857. * @param inputToRemove camera input method
  9858. */
  9859. remove(inputToRemove: ICameraInput<TCamera>): void;
  9860. /**
  9861. * Remove a specific input type from a camera
  9862. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9863. * @param inputType the type of the input to remove
  9864. */
  9865. removeByType(inputType: string): void;
  9866. private _addCheckInputs;
  9867. /**
  9868. * Attach the input controls to the currently attached dom element to listen the events from.
  9869. * @param input Defines the input to attach
  9870. */
  9871. attachInput(input: ICameraInput<TCamera>): void;
  9872. /**
  9873. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9874. * @param element Defines the dom element to collect the events from
  9875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9876. */
  9877. attachElement(noPreventDefault?: boolean): void;
  9878. /**
  9879. * Detach the current manager inputs controls from a specific dom element.
  9880. * @param element Defines the dom element to collect the events from
  9881. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9882. */
  9883. detachElement(disconnect?: boolean): void;
  9884. /**
  9885. * Rebuild the dynamic inputCheck function from the current list of
  9886. * defined inputs in the manager.
  9887. */
  9888. rebuildInputCheck(): void;
  9889. /**
  9890. * Remove all attached input methods from a camera
  9891. */
  9892. clear(): void;
  9893. /**
  9894. * Serialize the current input manager attached to a camera.
  9895. * This ensures than once parsed,
  9896. * the input associated to the camera will be identical to the current ones
  9897. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9898. */
  9899. serialize(serializedCamera: any): void;
  9900. /**
  9901. * Parses an input manager serialized JSON to restore the previous list of inputs
  9902. * and states associated to a camera.
  9903. * @param parsedCamera Defines the JSON to parse
  9904. */
  9905. parse(parsedCamera: any): void;
  9906. }
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Gather the list of keyboard event types as constants.
  9911. */
  9912. export class KeyboardEventTypes {
  9913. /**
  9914. * The keydown event is fired when a key becomes active (pressed).
  9915. */
  9916. static readonly KEYDOWN: number;
  9917. /**
  9918. * The keyup event is fired when a key has been released.
  9919. */
  9920. static readonly KEYUP: number;
  9921. }
  9922. /**
  9923. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9924. */
  9925. export class KeyboardInfo {
  9926. /**
  9927. * Defines the type of event (KeyboardEventTypes)
  9928. */
  9929. type: number;
  9930. /**
  9931. * Defines the related dom event
  9932. */
  9933. event: KeyboardEvent;
  9934. /**
  9935. * Instantiates a new keyboard info.
  9936. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9937. * @param type Defines the type of event (KeyboardEventTypes)
  9938. * @param event Defines the related dom event
  9939. */
  9940. constructor(
  9941. /**
  9942. * Defines the type of event (KeyboardEventTypes)
  9943. */
  9944. type: number,
  9945. /**
  9946. * Defines the related dom event
  9947. */
  9948. event: KeyboardEvent);
  9949. }
  9950. /**
  9951. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9952. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9953. */
  9954. export class KeyboardInfoPre extends KeyboardInfo {
  9955. /**
  9956. * Defines the type of event (KeyboardEventTypes)
  9957. */
  9958. type: number;
  9959. /**
  9960. * Defines the related dom event
  9961. */
  9962. event: KeyboardEvent;
  9963. /**
  9964. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9965. */
  9966. skipOnPointerObservable: boolean;
  9967. /**
  9968. * Instantiates a new keyboard pre info.
  9969. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9970. * @param type Defines the type of event (KeyboardEventTypes)
  9971. * @param event Defines the related dom event
  9972. */
  9973. constructor(
  9974. /**
  9975. * Defines the type of event (KeyboardEventTypes)
  9976. */
  9977. type: number,
  9978. /**
  9979. * Defines the related dom event
  9980. */
  9981. event: KeyboardEvent);
  9982. }
  9983. }
  9984. declare module BABYLON {
  9985. /**
  9986. * Manage the keyboard inputs to control the movement of a free camera.
  9987. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9988. */
  9989. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9990. /**
  9991. * Defines the camera the input is attached to.
  9992. */
  9993. camera: FreeCamera;
  9994. /**
  9995. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9996. */
  9997. keysUp: number[];
  9998. /**
  9999. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10000. */
  10001. keysUpward: number[];
  10002. /**
  10003. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10004. */
  10005. keysDown: number[];
  10006. /**
  10007. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10008. */
  10009. keysDownward: number[];
  10010. /**
  10011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10012. */
  10013. keysLeft: number[];
  10014. /**
  10015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10016. */
  10017. keysRight: number[];
  10018. private _keys;
  10019. private _onCanvasBlurObserver;
  10020. private _onKeyboardObserver;
  10021. private _engine;
  10022. private _scene;
  10023. /**
  10024. * Attach the input controls to a specific dom element to get the input from.
  10025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10026. */
  10027. attachControl(noPreventDefault?: boolean): void;
  10028. /**
  10029. * Detach the current controls from the specified dom element.
  10030. */
  10031. detachControl(): void;
  10032. /**
  10033. * Update the current camera state depending on the inputs that have been used this frame.
  10034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10035. */
  10036. checkInputs(): void;
  10037. /**
  10038. * Gets the class name of the current input.
  10039. * @returns the class name
  10040. */
  10041. getClassName(): string;
  10042. /** @hidden */
  10043. _onLostFocus(): void;
  10044. /**
  10045. * Get the friendly name associated with the input class.
  10046. * @returns the input friendly name
  10047. */
  10048. getSimpleName(): string;
  10049. }
  10050. }
  10051. declare module BABYLON {
  10052. /**
  10053. * Interface used to define Action
  10054. */
  10055. export interface IAction {
  10056. /**
  10057. * Trigger for the action
  10058. */
  10059. trigger: number;
  10060. /** Options of the trigger */
  10061. triggerOptions: any;
  10062. /**
  10063. * Gets the trigger parameters
  10064. * @returns the trigger parameters
  10065. */
  10066. getTriggerParameter(): any;
  10067. /**
  10068. * Internal only - executes current action event
  10069. * @hidden
  10070. */
  10071. _executeCurrent(evt?: ActionEvent): void;
  10072. /**
  10073. * Serialize placeholder for child classes
  10074. * @param parent of child
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. /**
  10079. * Internal only
  10080. * @hidden
  10081. */
  10082. _prepare(): void;
  10083. /**
  10084. * Internal only - manager for action
  10085. * @hidden
  10086. */
  10087. _actionManager: Nullable<AbstractActionManager>;
  10088. /**
  10089. * Adds action to chain of actions, may be a DoNothingAction
  10090. * @param action defines the next action to execute
  10091. * @returns The action passed in
  10092. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10093. */
  10094. then(action: IAction): IAction;
  10095. }
  10096. /**
  10097. * The action to be carried out following a trigger
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10099. */
  10100. export class Action implements IAction {
  10101. /** the trigger, with or without parameters, for the action */
  10102. triggerOptions: any;
  10103. /**
  10104. * Trigger for the action
  10105. */
  10106. trigger: number;
  10107. /**
  10108. * Internal only - manager for action
  10109. * @hidden
  10110. */
  10111. _actionManager: ActionManager;
  10112. private _nextActiveAction;
  10113. private _child;
  10114. private _condition?;
  10115. private _triggerParameter;
  10116. /**
  10117. * An event triggered prior to action being executed.
  10118. */
  10119. onBeforeExecuteObservable: Observable<Action>;
  10120. /**
  10121. * Creates a new Action
  10122. * @param triggerOptions the trigger, with or without parameters, for the action
  10123. * @param condition an optional determinant of action
  10124. */
  10125. constructor(
  10126. /** the trigger, with or without parameters, for the action */
  10127. triggerOptions: any, condition?: Condition);
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _prepare(): void;
  10133. /**
  10134. * Gets the trigger parameter
  10135. * @returns the trigger parameter
  10136. */
  10137. getTriggerParameter(): any;
  10138. /**
  10139. * Sets the trigger parameter
  10140. * @param value defines the new trigger parameter
  10141. */
  10142. setTriggerParameter(value: any): void;
  10143. /**
  10144. * Internal only - executes current action event
  10145. * @hidden
  10146. */
  10147. _executeCurrent(evt?: ActionEvent): void;
  10148. /**
  10149. * Execute placeholder for child classes
  10150. * @param evt optional action event
  10151. */
  10152. execute(evt?: ActionEvent): void;
  10153. /**
  10154. * Skips to next active action
  10155. */
  10156. skipToNextActiveAction(): void;
  10157. /**
  10158. * Adds action to chain of actions, may be a DoNothingAction
  10159. * @param action defines the next action to execute
  10160. * @returns The action passed in
  10161. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10162. */
  10163. then(action: Action): Action;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _getProperty(propertyPath: string): string;
  10169. /**
  10170. * Internal only
  10171. * @hidden
  10172. */
  10173. _getEffectiveTarget(target: any, propertyPath: string): any;
  10174. /**
  10175. * Serialize placeholder for child classes
  10176. * @param parent of child
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. /**
  10181. * Internal only called by serialize
  10182. * @hidden
  10183. */
  10184. protected _serialize(serializedAction: any, parent?: any): any;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. static _SerializeValueAsString: (value: any) => string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. static _GetTargetProperty: (target: Scene | Node) => {
  10195. name: string;
  10196. targetType: string;
  10197. value: string;
  10198. };
  10199. }
  10200. }
  10201. declare module BABYLON {
  10202. /**
  10203. * A Condition applied to an Action
  10204. */
  10205. export class Condition {
  10206. /**
  10207. * Internal only - manager for action
  10208. * @hidden
  10209. */
  10210. _actionManager: ActionManager;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. _evaluationId: number;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. _currentResult: boolean;
  10221. /**
  10222. * Creates a new Condition
  10223. * @param actionManager the manager of the action the condition is applied to
  10224. */
  10225. constructor(actionManager: ActionManager);
  10226. /**
  10227. * Check if the current condition is valid
  10228. * @returns a boolean
  10229. */
  10230. isValid(): boolean;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _getProperty(propertyPath: string): string;
  10236. /**
  10237. * Internal only
  10238. * @hidden
  10239. */
  10240. _getEffectiveTarget(target: any, propertyPath: string): any;
  10241. /**
  10242. * Serialize placeholder for child classes
  10243. * @returns the serialized object
  10244. */
  10245. serialize(): any;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. protected _serialize(serializedCondition: any): any;
  10251. }
  10252. /**
  10253. * Defines specific conditional operators as extensions of Condition
  10254. */
  10255. export class ValueCondition extends Condition {
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string;
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any;
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator: number;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */
  10266. private static _IsEqual;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. private static _IsDifferent;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. private static _IsGreater;
  10277. /**
  10278. * Internal only
  10279. * @hidden
  10280. */
  10281. private static _IsLesser;
  10282. /**
  10283. * returns the number for IsEqual
  10284. */
  10285. static get IsEqual(): number;
  10286. /**
  10287. * Returns the number for IsDifferent
  10288. */
  10289. static get IsDifferent(): number;
  10290. /**
  10291. * Returns the number for IsGreater
  10292. */
  10293. static get IsGreater(): number;
  10294. /**
  10295. * Returns the number for IsLesser
  10296. */
  10297. static get IsLesser(): number;
  10298. /**
  10299. * Internal only The action manager for the condition
  10300. * @hidden
  10301. */
  10302. _actionManager: ActionManager;
  10303. /**
  10304. * Internal only
  10305. * @hidden
  10306. */
  10307. private _target;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. private _effectiveTarget;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. private _property;
  10318. /**
  10319. * Creates a new ValueCondition
  10320. * @param actionManager manager for the action the condition applies to
  10321. * @param target for the action
  10322. * @param propertyPath path to specify the property of the target the conditional operator uses
  10323. * @param value the value compared by the conditional operator against the current value of the property
  10324. * @param operator the conditional operator, default ValueCondition.IsEqual
  10325. */
  10326. constructor(actionManager: ActionManager, target: any,
  10327. /** path to specify the property of the target the conditional operator uses */
  10328. propertyPath: string,
  10329. /** the value compared by the conditional operator against the current value of the property */
  10330. value: any,
  10331. /** the conditional operator, default ValueCondition.IsEqual */
  10332. operator?: number);
  10333. /**
  10334. * Compares the given value with the property value for the specified conditional operator
  10335. * @returns the result of the comparison
  10336. */
  10337. isValid(): boolean;
  10338. /**
  10339. * Serialize the ValueCondition into a JSON compatible object
  10340. * @returns serialization object
  10341. */
  10342. serialize(): any;
  10343. /**
  10344. * Gets the name of the conditional operator for the ValueCondition
  10345. * @param operator the conditional operator
  10346. * @returns the name
  10347. */
  10348. static GetOperatorName(operator: number): string;
  10349. }
  10350. /**
  10351. * Defines a predicate condition as an extension of Condition
  10352. */
  10353. export class PredicateCondition extends Condition {
  10354. /** defines the predicate function used to validate the condition */
  10355. predicate: () => boolean;
  10356. /**
  10357. * Internal only - manager for action
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Creates a new PredicateCondition
  10363. * @param actionManager manager for the action the condition applies to
  10364. * @param predicate defines the predicate function used to validate the condition
  10365. */
  10366. constructor(actionManager: ActionManager,
  10367. /** defines the predicate function used to validate the condition */
  10368. predicate: () => boolean);
  10369. /**
  10370. * @returns the validity of the predicate condition
  10371. */
  10372. isValid(): boolean;
  10373. }
  10374. /**
  10375. * Defines a state condition as an extension of Condition
  10376. */
  10377. export class StateCondition extends Condition {
  10378. /** Value to compare with target state */
  10379. value: string;
  10380. /**
  10381. * Internal only - manager for action
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Creates a new StateCondition
  10392. * @param actionManager manager for the action the condition applies to
  10393. * @param target of the condition
  10394. * @param value to compare with target state
  10395. */
  10396. constructor(actionManager: ActionManager, target: any,
  10397. /** Value to compare with target state */
  10398. value: string);
  10399. /**
  10400. * Gets a boolean indicating if the current condition is met
  10401. * @returns the validity of the state
  10402. */
  10403. isValid(): boolean;
  10404. /**
  10405. * Serialize the StateCondition into a JSON compatible object
  10406. * @returns serialization object
  10407. */
  10408. serialize(): any;
  10409. }
  10410. }
  10411. declare module BABYLON {
  10412. /**
  10413. * This defines an action responsible to toggle a boolean once triggered.
  10414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10415. */
  10416. export class SwitchBooleanAction extends Action {
  10417. /**
  10418. * The path to the boolean property in the target object
  10419. */
  10420. propertyPath: string;
  10421. private _target;
  10422. private _effectiveTarget;
  10423. private _property;
  10424. /**
  10425. * Instantiate the action
  10426. * @param triggerOptions defines the trigger options
  10427. * @param target defines the object containing the boolean
  10428. * @param propertyPath defines the path to the boolean property in the target object
  10429. * @param condition defines the trigger related conditions
  10430. */
  10431. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10432. /** @hidden */
  10433. _prepare(): void;
  10434. /**
  10435. * Execute the action toggle the boolean value.
  10436. */
  10437. execute(): void;
  10438. /**
  10439. * Serializes the actions and its related information.
  10440. * @param parent defines the object to serialize in
  10441. * @returns the serialized object
  10442. */
  10443. serialize(parent: any): any;
  10444. }
  10445. /**
  10446. * This defines an action responsible to set a the state field of the target
  10447. * to a desired value once triggered.
  10448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10449. */
  10450. export class SetStateAction extends Action {
  10451. /**
  10452. * The value to store in the state field.
  10453. */
  10454. value: string;
  10455. private _target;
  10456. /**
  10457. * Instantiate the action
  10458. * @param triggerOptions defines the trigger options
  10459. * @param target defines the object containing the state property
  10460. * @param value defines the value to store in the state field
  10461. * @param condition defines the trigger related conditions
  10462. */
  10463. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10464. /**
  10465. * Execute the action and store the value on the target state property.
  10466. */
  10467. execute(): void;
  10468. /**
  10469. * Serializes the actions and its related information.
  10470. * @param parent defines the object to serialize in
  10471. * @returns the serialized object
  10472. */
  10473. serialize(parent: any): any;
  10474. }
  10475. /**
  10476. * This defines an action responsible to set a property of the target
  10477. * to a desired value once triggered.
  10478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10479. */
  10480. export class SetValueAction extends Action {
  10481. /**
  10482. * The path of the property to set in the target.
  10483. */
  10484. propertyPath: string;
  10485. /**
  10486. * The value to set in the property
  10487. */
  10488. value: any;
  10489. private _target;
  10490. private _effectiveTarget;
  10491. private _property;
  10492. /**
  10493. * Instantiate the action
  10494. * @param triggerOptions defines the trigger options
  10495. * @param target defines the object containing the property
  10496. * @param propertyPath defines the path of the property to set in the target
  10497. * @param value defines the value to set in the property
  10498. * @param condition defines the trigger related conditions
  10499. */
  10500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10501. /** @hidden */
  10502. _prepare(): void;
  10503. /**
  10504. * Execute the action and set the targeted property to the desired value.
  10505. */
  10506. execute(): void;
  10507. /**
  10508. * Serializes the actions and its related information.
  10509. * @param parent defines the object to serialize in
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. }
  10514. /**
  10515. * This defines an action responsible to increment the target value
  10516. * to a desired value once triggered.
  10517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10518. */
  10519. export class IncrementValueAction extends Action {
  10520. /**
  10521. * The path of the property to increment in the target.
  10522. */
  10523. propertyPath: string;
  10524. /**
  10525. * The value we should increment the property by.
  10526. */
  10527. value: any;
  10528. private _target;
  10529. private _effectiveTarget;
  10530. private _property;
  10531. /**
  10532. * Instantiate the action
  10533. * @param triggerOptions defines the trigger options
  10534. * @param target defines the object containing the property
  10535. * @param propertyPath defines the path of the property to increment in the target
  10536. * @param value defines the value value we should increment the property by
  10537. * @param condition defines the trigger related conditions
  10538. */
  10539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10540. /** @hidden */
  10541. _prepare(): void;
  10542. /**
  10543. * Execute the action and increment the target of the value amount.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to start an animation once triggered.
  10555. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class PlayAnimationAction extends Action {
  10558. /**
  10559. * Where the animation should start (animation frame)
  10560. */
  10561. from: number;
  10562. /**
  10563. * Where the animation should stop (animation frame)
  10564. */
  10565. to: number;
  10566. /**
  10567. * Define if the animation should loop or stop after the first play.
  10568. */
  10569. loop?: boolean;
  10570. private _target;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the target animation or animation name
  10575. * @param from defines from where the animation should start (animation frame)
  10576. * @param to defines where the animation should stop (animation frame)
  10577. * @param loop defines if the animation should loop or stop after the first play
  10578. * @param condition defines the trigger related conditions
  10579. */
  10580. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10581. /** @hidden */
  10582. _prepare(): void;
  10583. /**
  10584. * Execute the action and play the animation.
  10585. */
  10586. execute(): void;
  10587. /**
  10588. * Serializes the actions and its related information.
  10589. * @param parent defines the object to serialize in
  10590. * @returns the serialized object
  10591. */
  10592. serialize(parent: any): any;
  10593. }
  10594. /**
  10595. * This defines an action responsible to stop an animation once triggered.
  10596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class StopAnimationAction extends Action {
  10599. private _target;
  10600. /**
  10601. * Instantiate the action
  10602. * @param triggerOptions defines the trigger options
  10603. * @param target defines the target animation or animation name
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions: any, target: any, condition?: Condition);
  10607. /** @hidden */
  10608. _prepare(): void;
  10609. /**
  10610. * Execute the action and stop the animation.
  10611. */
  10612. execute(): void;
  10613. /**
  10614. * Serializes the actions and its related information.
  10615. * @param parent defines the object to serialize in
  10616. * @returns the serialized object
  10617. */
  10618. serialize(parent: any): any;
  10619. }
  10620. /**
  10621. * This defines an action responsible that does nothing once triggered.
  10622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10623. */
  10624. export class DoNothingAction extends Action {
  10625. /**
  10626. * Instantiate the action
  10627. * @param triggerOptions defines the trigger options
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions?: any, condition?: Condition);
  10631. /**
  10632. * Execute the action and do nothing.
  10633. */
  10634. execute(): void;
  10635. /**
  10636. * Serializes the actions and its related information.
  10637. * @param parent defines the object to serialize in
  10638. * @returns the serialized object
  10639. */
  10640. serialize(parent: any): any;
  10641. }
  10642. /**
  10643. * This defines an action responsible to trigger several actions once triggered.
  10644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10645. */
  10646. export class CombineAction extends Action {
  10647. /**
  10648. * The list of aggregated animations to run.
  10649. */
  10650. children: Action[];
  10651. /**
  10652. * Instantiate the action
  10653. * @param triggerOptions defines the trigger options
  10654. * @param children defines the list of aggregated animations to run
  10655. * @param condition defines the trigger related conditions
  10656. */
  10657. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10658. /** @hidden */
  10659. _prepare(): void;
  10660. /**
  10661. * Execute the action and executes all the aggregated actions.
  10662. */
  10663. execute(evt: ActionEvent): void;
  10664. /**
  10665. * Serializes the actions and its related information.
  10666. * @param parent defines the object to serialize in
  10667. * @returns the serialized object
  10668. */
  10669. serialize(parent: any): any;
  10670. }
  10671. /**
  10672. * This defines an action responsible to run code (external event) once triggered.
  10673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class ExecuteCodeAction extends Action {
  10676. /**
  10677. * The callback function to run.
  10678. */
  10679. func: (evt: ActionEvent) => void;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param func defines the callback function to run
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10687. /**
  10688. * Execute the action and run the attached code.
  10689. */
  10690. execute(evt: ActionEvent): void;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set the parent property of the target once triggered.
  10694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SetParentAction extends Action {
  10697. private _parent;
  10698. private _target;
  10699. /**
  10700. * Instantiate the action
  10701. * @param triggerOptions defines the trigger options
  10702. * @param target defines the target containing the parent property
  10703. * @param parent defines from where the animation should start (animation frame)
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10707. /** @hidden */
  10708. _prepare(): void;
  10709. /**
  10710. * Execute the action and set the parent property.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10724. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10725. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class ActionManager extends AbstractActionManager {
  10728. /**
  10729. * Nothing
  10730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly NothingTrigger: number;
  10733. /**
  10734. * On pick
  10735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnPickTrigger: number;
  10738. /**
  10739. * On left pick
  10740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnLeftPickTrigger: number;
  10743. /**
  10744. * On right pick
  10745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnRightPickTrigger: number;
  10748. /**
  10749. * On center pick
  10750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnCenterPickTrigger: number;
  10753. /**
  10754. * On pick down
  10755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnPickDownTrigger: number;
  10758. /**
  10759. * On double pick
  10760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnDoublePickTrigger: number;
  10763. /**
  10764. * On pick up
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnPickUpTrigger: number;
  10768. /**
  10769. * On pick out.
  10770. * This trigger will only be raised if you also declared a OnPickDown
  10771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnPickOutTrigger: number;
  10774. /**
  10775. * On long press
  10776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnLongPressTrigger: number;
  10779. /**
  10780. * On pointer over
  10781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnPointerOverTrigger: number;
  10784. /**
  10785. * On pointer out
  10786. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPointerOutTrigger: number;
  10789. /**
  10790. * On every frame
  10791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10792. */
  10793. static readonly OnEveryFrameTrigger: number;
  10794. /**
  10795. * On intersection enter
  10796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10797. */
  10798. static readonly OnIntersectionEnterTrigger: number;
  10799. /**
  10800. * On intersection exit
  10801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10802. */
  10803. static readonly OnIntersectionExitTrigger: number;
  10804. /**
  10805. * On key down
  10806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10807. */
  10808. static readonly OnKeyDownTrigger: number;
  10809. /**
  10810. * On key up
  10811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10812. */
  10813. static readonly OnKeyUpTrigger: number;
  10814. private _scene;
  10815. /**
  10816. * Creates a new action manager
  10817. * @param scene defines the hosting scene
  10818. */
  10819. constructor(scene: Scene);
  10820. /**
  10821. * Releases all associated resources
  10822. */
  10823. dispose(): void;
  10824. /**
  10825. * Gets hosting scene
  10826. * @returns the hosting scene
  10827. */
  10828. getScene(): Scene;
  10829. /**
  10830. * Does this action manager handles actions of any of the given triggers
  10831. * @param triggers defines the triggers to be tested
  10832. * @return a boolean indicating whether one (or more) of the triggers is handled
  10833. */
  10834. hasSpecificTriggers(triggers: number[]): boolean;
  10835. /**
  10836. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10837. * speed.
  10838. * @param triggerA defines the trigger to be tested
  10839. * @param triggerB defines the trigger to be tested
  10840. * @return a boolean indicating whether one (or more) of the triggers is handled
  10841. */
  10842. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10843. /**
  10844. * Does this action manager handles actions of a given trigger
  10845. * @param trigger defines the trigger to be tested
  10846. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10847. * @return whether the trigger is handled
  10848. */
  10849. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10850. /**
  10851. * Does this action manager has pointer triggers
  10852. */
  10853. get hasPointerTriggers(): boolean;
  10854. /**
  10855. * Does this action manager has pick triggers
  10856. */
  10857. get hasPickTriggers(): boolean;
  10858. /**
  10859. * Registers an action to this action manager
  10860. * @param action defines the action to be registered
  10861. * @return the action amended (prepared) after registration
  10862. */
  10863. registerAction(action: IAction): Nullable<IAction>;
  10864. /**
  10865. * Unregisters an action to this action manager
  10866. * @param action defines the action to be unregistered
  10867. * @return a boolean indicating whether the action has been unregistered
  10868. */
  10869. unregisterAction(action: IAction): Boolean;
  10870. /**
  10871. * Process a specific trigger
  10872. * @param trigger defines the trigger to process
  10873. * @param evt defines the event details to be processed
  10874. */
  10875. processTrigger(trigger: number, evt?: IActionEvent): void;
  10876. /** @hidden */
  10877. _getEffectiveTarget(target: any, propertyPath: string): any;
  10878. /** @hidden */
  10879. _getProperty(propertyPath: string): string;
  10880. /**
  10881. * Serialize this manager to a JSON object
  10882. * @param name defines the property name to store this manager
  10883. * @returns a JSON representation of this manager
  10884. */
  10885. serialize(name: string): any;
  10886. /**
  10887. * Creates a new ActionManager from a JSON data
  10888. * @param parsedActions defines the JSON data to read from
  10889. * @param object defines the hosting mesh
  10890. * @param scene defines the hosting scene
  10891. */
  10892. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10893. /**
  10894. * Get a trigger name by index
  10895. * @param trigger defines the trigger index
  10896. * @returns a trigger name
  10897. */
  10898. static GetTriggerName(trigger: number): string;
  10899. }
  10900. }
  10901. declare module BABYLON {
  10902. /**
  10903. * Class representing a ray with position and direction
  10904. */
  10905. export class Ray {
  10906. /** origin point */
  10907. origin: Vector3;
  10908. /** direction */
  10909. direction: Vector3;
  10910. /** length of the ray */
  10911. length: number;
  10912. private static readonly _TmpVector3;
  10913. private _tmpRay;
  10914. /**
  10915. * Creates a new ray
  10916. * @param origin origin point
  10917. * @param direction direction
  10918. * @param length length of the ray
  10919. */
  10920. constructor(
  10921. /** origin point */
  10922. origin: Vector3,
  10923. /** direction */
  10924. direction: Vector3,
  10925. /** length of the ray */
  10926. length?: number);
  10927. /**
  10928. * Checks if the ray intersects a box
  10929. * This does not account for the ray length by design to improve perfs.
  10930. * @param minimum bound of the box
  10931. * @param maximum bound of the box
  10932. * @param intersectionTreshold extra extend to be added to the box in all direction
  10933. * @returns if the box was hit
  10934. */
  10935. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10936. /**
  10937. * Checks if the ray intersects a box
  10938. * This does not account for the ray lenght by design to improve perfs.
  10939. * @param box the bounding box to check
  10940. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10941. * @returns if the box was hit
  10942. */
  10943. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10944. /**
  10945. * If the ray hits a sphere
  10946. * @param sphere the bounding sphere to check
  10947. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10948. * @returns true if it hits the sphere
  10949. */
  10950. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10951. /**
  10952. * If the ray hits a triange
  10953. * @param vertex0 triangle vertex
  10954. * @param vertex1 triangle vertex
  10955. * @param vertex2 triangle vertex
  10956. * @returns intersection information if hit
  10957. */
  10958. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10959. /**
  10960. * Checks if ray intersects a plane
  10961. * @param plane the plane to check
  10962. * @returns the distance away it was hit
  10963. */
  10964. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10965. /**
  10966. * Calculate the intercept of a ray on a given axis
  10967. * @param axis to check 'x' | 'y' | 'z'
  10968. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10969. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10970. */
  10971. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10972. /**
  10973. * Checks if ray intersects a mesh
  10974. * @param mesh the mesh to check
  10975. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10976. * @returns picking info of the intersection
  10977. */
  10978. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10979. /**
  10980. * Checks if ray intersects a mesh
  10981. * @param meshes the meshes to check
  10982. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10983. * @param results array to store result in
  10984. * @returns Array of picking infos
  10985. */
  10986. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10987. private _comparePickingInfo;
  10988. private static smallnum;
  10989. private static rayl;
  10990. /**
  10991. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  10992. * @param sega the first point of the segment to test the intersection against
  10993. * @param segb the second point of the segment to test the intersection against
  10994. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10995. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10996. */
  10997. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10998. /**
  10999. * Update the ray from viewport position
  11000. * @param x position
  11001. * @param y y position
  11002. * @param viewportWidth viewport width
  11003. * @param viewportHeight viewport height
  11004. * @param world world matrix
  11005. * @param view view matrix
  11006. * @param projection projection matrix
  11007. * @returns this ray updated
  11008. */
  11009. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11010. /**
  11011. * Creates a ray with origin and direction of 0,0,0
  11012. * @returns the new ray
  11013. */
  11014. static Zero(): Ray;
  11015. /**
  11016. * Creates a new ray from screen space and viewport
  11017. * @param x position
  11018. * @param y y position
  11019. * @param viewportWidth viewport width
  11020. * @param viewportHeight viewport height
  11021. * @param world world matrix
  11022. * @param view view matrix
  11023. * @param projection projection matrix
  11024. * @returns new ray
  11025. */
  11026. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11027. /**
  11028. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11029. * transformed to the given world matrix.
  11030. * @param origin The origin point
  11031. * @param end The end point
  11032. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11033. * @returns the new ray
  11034. */
  11035. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11036. /**
  11037. * Transforms a ray by a matrix
  11038. * @param ray ray to transform
  11039. * @param matrix matrix to apply
  11040. * @returns the resulting new ray
  11041. */
  11042. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11043. /**
  11044. * Transforms a ray by a matrix
  11045. * @param ray ray to transform
  11046. * @param matrix matrix to apply
  11047. * @param result ray to store result in
  11048. */
  11049. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11050. /**
  11051. * Unproject a ray from screen space to object space
  11052. * @param sourceX defines the screen space x coordinate to use
  11053. * @param sourceY defines the screen space y coordinate to use
  11054. * @param viewportWidth defines the current width of the viewport
  11055. * @param viewportHeight defines the current height of the viewport
  11056. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11057. * @param view defines the view matrix to use
  11058. * @param projection defines the projection matrix to use
  11059. */
  11060. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11061. }
  11062. /**
  11063. * Type used to define predicate used to select faces when a mesh intersection is detected
  11064. */
  11065. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11066. interface Scene {
  11067. /** @hidden */
  11068. _tempPickingRay: Nullable<Ray>;
  11069. /** @hidden */
  11070. _cachedRayForTransform: Ray;
  11071. /** @hidden */
  11072. _pickWithRayInverseMatrix: Matrix;
  11073. /** @hidden */
  11074. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11075. /** @hidden */
  11076. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11077. /** @hidden */
  11078. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11079. }
  11080. }
  11081. declare module BABYLON {
  11082. /**
  11083. * Groups all the scene component constants in one place to ease maintenance.
  11084. * @hidden
  11085. */
  11086. export class SceneComponentConstants {
  11087. static readonly NAME_EFFECTLAYER: string;
  11088. static readonly NAME_LAYER: string;
  11089. static readonly NAME_LENSFLARESYSTEM: string;
  11090. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11091. static readonly NAME_PARTICLESYSTEM: string;
  11092. static readonly NAME_GAMEPAD: string;
  11093. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11094. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11095. static readonly NAME_PREPASSRENDERER: string;
  11096. static readonly NAME_DEPTHRENDERER: string;
  11097. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11098. static readonly NAME_SPRITE: string;
  11099. static readonly NAME_SUBSURFACE: string;
  11100. static readonly NAME_OUTLINERENDERER: string;
  11101. static readonly NAME_PROCEDURALTEXTURE: string;
  11102. static readonly NAME_SHADOWGENERATOR: string;
  11103. static readonly NAME_OCTREE: string;
  11104. static readonly NAME_PHYSICSENGINE: string;
  11105. static readonly NAME_AUDIO: string;
  11106. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11107. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11108. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11109. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11110. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11111. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11112. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11113. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11114. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11115. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11116. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11117. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11118. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11119. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11120. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11121. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11122. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11123. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11124. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11125. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11126. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11127. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11128. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11129. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11130. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11131. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11132. static readonly STEP_AFTERRENDER_AUDIO: number;
  11133. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11134. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11135. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11136. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11137. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11138. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11139. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11140. static readonly STEP_POINTERMOVE_SPRITE: number;
  11141. static readonly STEP_POINTERDOWN_SPRITE: number;
  11142. static readonly STEP_POINTERUP_SPRITE: number;
  11143. }
  11144. /**
  11145. * This represents a scene component.
  11146. *
  11147. * This is used to decouple the dependency the scene is having on the different workloads like
  11148. * layers, post processes...
  11149. */
  11150. export interface ISceneComponent {
  11151. /**
  11152. * The name of the component. Each component must have a unique name.
  11153. */
  11154. name: string;
  11155. /**
  11156. * The scene the component belongs to.
  11157. */
  11158. scene: Scene;
  11159. /**
  11160. * Register the component to one instance of a scene.
  11161. */
  11162. register(): void;
  11163. /**
  11164. * Rebuilds the elements related to this component in case of
  11165. * context lost for instance.
  11166. */
  11167. rebuild(): void;
  11168. /**
  11169. * Disposes the component and the associated ressources.
  11170. */
  11171. dispose(): void;
  11172. }
  11173. /**
  11174. * This represents a SERIALIZABLE scene component.
  11175. *
  11176. * This extends Scene Component to add Serialization methods on top.
  11177. */
  11178. export interface ISceneSerializableComponent extends ISceneComponent {
  11179. /**
  11180. * Adds all the elements from the container to the scene
  11181. * @param container the container holding the elements
  11182. */
  11183. addFromContainer(container: AbstractScene): void;
  11184. /**
  11185. * Removes all the elements in the container from the scene
  11186. * @param container contains the elements to remove
  11187. * @param dispose if the removed element should be disposed (default: false)
  11188. */
  11189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11190. /**
  11191. * Serializes the component data to the specified json object
  11192. * @param serializationObject The object to serialize to
  11193. */
  11194. serialize(serializationObject: any): void;
  11195. }
  11196. /**
  11197. * Strong typing of a Mesh related stage step action
  11198. */
  11199. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11200. /**
  11201. * Strong typing of a Evaluate Sub Mesh related stage step action
  11202. */
  11203. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11204. /**
  11205. * Strong typing of a pre active Mesh related stage step action
  11206. */
  11207. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11208. /**
  11209. * Strong typing of a Camera related stage step action
  11210. */
  11211. export type CameraStageAction = (camera: Camera) => void;
  11212. /**
  11213. * Strong typing of a Camera Frame buffer related stage step action
  11214. */
  11215. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11216. /**
  11217. * Strong typing of a Render Target related stage step action
  11218. */
  11219. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11220. /**
  11221. * Strong typing of a RenderingGroup related stage step action
  11222. */
  11223. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11224. /**
  11225. * Strong typing of a Mesh Render related stage step action
  11226. */
  11227. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11228. /**
  11229. * Strong typing of a simple stage step action
  11230. */
  11231. export type SimpleStageAction = () => void;
  11232. /**
  11233. * Strong typing of a render target action.
  11234. */
  11235. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11236. /**
  11237. * Strong typing of a pointer move action.
  11238. */
  11239. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11240. /**
  11241. * Strong typing of a pointer up/down action.
  11242. */
  11243. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11244. /**
  11245. * Representation of a stage in the scene (Basically a list of ordered steps)
  11246. * @hidden
  11247. */
  11248. export class Stage<T extends Function> extends Array<{
  11249. index: number;
  11250. component: ISceneComponent;
  11251. action: T;
  11252. }> {
  11253. /**
  11254. * Hide ctor from the rest of the world.
  11255. * @param items The items to add.
  11256. */
  11257. private constructor();
  11258. /**
  11259. * Creates a new Stage.
  11260. * @returns A new instance of a Stage
  11261. */
  11262. static Create<T extends Function>(): Stage<T>;
  11263. /**
  11264. * Registers a step in an ordered way in the targeted stage.
  11265. * @param index Defines the position to register the step in
  11266. * @param component Defines the component attached to the step
  11267. * @param action Defines the action to launch during the step
  11268. */
  11269. registerStep(index: number, component: ISceneComponent, action: T): void;
  11270. /**
  11271. * Clears all the steps from the stage.
  11272. */
  11273. clear(): void;
  11274. }
  11275. }
  11276. declare module BABYLON {
  11277. interface Scene {
  11278. /** @hidden */
  11279. _pointerOverSprite: Nullable<Sprite>;
  11280. /** @hidden */
  11281. _pickedDownSprite: Nullable<Sprite>;
  11282. /** @hidden */
  11283. _tempSpritePickingRay: Nullable<Ray>;
  11284. /**
  11285. * All of the sprite managers added to this scene
  11286. * @see https://doc.babylonjs.com/babylon101/sprites
  11287. */
  11288. spriteManagers: Array<ISpriteManager>;
  11289. /**
  11290. * An event triggered when sprites rendering is about to start
  11291. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11292. */
  11293. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11294. /**
  11295. * An event triggered when sprites rendering is done
  11296. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11297. */
  11298. onAfterSpritesRenderingObservable: Observable<Scene>;
  11299. /** @hidden */
  11300. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11301. /** Launch a ray to try to pick a sprite in the scene
  11302. * @param x position on screen
  11303. * @param y position on screen
  11304. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11305. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11306. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11307. * @returns a PickingInfo
  11308. */
  11309. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11310. /** Use the given ray to pick a sprite in the scene
  11311. * @param ray The ray (in world space) to use to pick meshes
  11312. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11313. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11314. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11315. * @returns a PickingInfo
  11316. */
  11317. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11318. /** @hidden */
  11319. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11320. /** Launch a ray to try to pick sprites in the scene
  11321. * @param x position on screen
  11322. * @param y position on screen
  11323. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11324. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11325. * @returns a PickingInfo array
  11326. */
  11327. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11328. /** Use the given ray to pick sprites in the scene
  11329. * @param ray The ray (in world space) to use to pick meshes
  11330. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11331. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /**
  11336. * Force the sprite under the pointer
  11337. * @param sprite defines the sprite to use
  11338. */
  11339. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11340. /**
  11341. * Gets the sprite under the pointer
  11342. * @returns a Sprite or null if no sprite is under the pointer
  11343. */
  11344. getPointerOverSprite(): Nullable<Sprite>;
  11345. }
  11346. /**
  11347. * Defines the sprite scene component responsible to manage sprites
  11348. * in a given scene.
  11349. */
  11350. export class SpriteSceneComponent implements ISceneComponent {
  11351. /**
  11352. * The component name helpfull to identify the component in the list of scene components.
  11353. */
  11354. readonly name: string;
  11355. /**
  11356. * The scene the component belongs to.
  11357. */
  11358. scene: Scene;
  11359. /** @hidden */
  11360. private _spritePredicate;
  11361. /**
  11362. * Creates a new instance of the component for the given scene
  11363. * @param scene Defines the scene to register the component in
  11364. */
  11365. constructor(scene: Scene);
  11366. /**
  11367. * Registers the component in a given scene
  11368. */
  11369. register(): void;
  11370. /**
  11371. * Rebuilds the elements related to this component in case of
  11372. * context lost for instance.
  11373. */
  11374. rebuild(): void;
  11375. /**
  11376. * Disposes the component and the associated resources.
  11377. */
  11378. dispose(): void;
  11379. private _pickSpriteButKeepRay;
  11380. private _pointerMove;
  11381. private _pointerDown;
  11382. private _pointerUp;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Class used to provide helper for timing
  11388. */
  11389. export class TimingTools {
  11390. /**
  11391. * Polyfill for setImmediate
  11392. * @param action defines the action to execute after the current execution block
  11393. */
  11394. static SetImmediate(action: () => void): void;
  11395. }
  11396. }
  11397. declare module BABYLON {
  11398. /**
  11399. * Class used to enable instantiation of objects by class name
  11400. */
  11401. export class InstantiationTools {
  11402. /**
  11403. * Use this object to register external classes like custom textures or material
  11404. * to allow the loaders to instantiate them
  11405. */
  11406. static RegisteredExternalClasses: {
  11407. [key: string]: Object;
  11408. };
  11409. /**
  11410. * Tries to instantiate a new object from a given class name
  11411. * @param className defines the class name to instantiate
  11412. * @returns the new object or null if the system was not able to do the instantiation
  11413. */
  11414. static Instantiate(className: string): any;
  11415. }
  11416. }
  11417. declare module BABYLON {
  11418. /**
  11419. * Class used to host copy specific utilities
  11420. */
  11421. export class CopyTools {
  11422. /**
  11423. * Transform some pixel data to a base64 string
  11424. * @param pixels defines the pixel data to transform to base64
  11425. * @param size defines the width and height of the (texture) data
  11426. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11427. * @returns The base64 encoded string or null
  11428. */
  11429. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11430. /**
  11431. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11432. * @param texture defines the texture to read pixels from
  11433. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11434. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11435. * @returns The base64 encoded string or null
  11436. */
  11437. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11438. /**
  11439. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11440. * @param texture defines the texture to read pixels from
  11441. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11442. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11443. * @returns The base64 encoded string or null wrapped in a promise
  11444. */
  11445. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11446. }
  11447. }
  11448. declare module BABYLON {
  11449. /**
  11450. * Define options used to create a depth texture
  11451. */
  11452. export class DepthTextureCreationOptions {
  11453. /** Specifies whether or not a stencil should be allocated in the texture */
  11454. generateStencil?: boolean;
  11455. /** Specifies whether or not bilinear filtering is enable on the texture */
  11456. bilinearFiltering?: boolean;
  11457. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11458. comparisonFunction?: number;
  11459. /** Specifies if the created texture is a cube texture */
  11460. isCube?: boolean;
  11461. /** Specifies the sample count of the depth/stencil texture texture */
  11462. samples?: number;
  11463. }
  11464. }
  11465. declare module BABYLON {
  11466. interface ThinEngine {
  11467. /**
  11468. * Creates a depth stencil cube texture.
  11469. * This is only available in WebGL 2.
  11470. * @param size The size of face edge in the cube texture.
  11471. * @param options The options defining the cube texture.
  11472. * @returns The cube texture
  11473. */
  11474. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11475. /**
  11476. * Creates a cube texture
  11477. * @param rootUrl defines the url where the files to load is located
  11478. * @param scene defines the current scene
  11479. * @param files defines the list of files to load (1 per face)
  11480. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11481. * @param onLoad defines an optional callback raised when the texture is loaded
  11482. * @param onError defines an optional callback raised if there is an issue to load the texture
  11483. * @param format defines the format of the data
  11484. * @param forcedExtension defines the extension to use to pick the right loader
  11485. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11486. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11487. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11488. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11489. * @param loaderOptions options to be passed to the loader
  11490. * @returns the cube texture as an InternalTexture
  11491. */
  11492. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11493. /**
  11494. * Creates a cube texture
  11495. * @param rootUrl defines the url where the files to load is located
  11496. * @param scene defines the current scene
  11497. * @param files defines the list of files to load (1 per face)
  11498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11499. * @param onLoad defines an optional callback raised when the texture is loaded
  11500. * @param onError defines an optional callback raised if there is an issue to load the texture
  11501. * @param format defines the format of the data
  11502. * @param forcedExtension defines the extension to use to pick the right loader
  11503. * @returns the cube texture as an InternalTexture
  11504. */
  11505. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11506. /**
  11507. * Creates a cube texture
  11508. * @param rootUrl defines the url where the files to load is located
  11509. * @param scene defines the current scene
  11510. * @param files defines the list of files to load (1 per face)
  11511. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11512. * @param onLoad defines an optional callback raised when the texture is loaded
  11513. * @param onError defines an optional callback raised if there is an issue to load the texture
  11514. * @param format defines the format of the data
  11515. * @param forcedExtension defines the extension to use to pick the right loader
  11516. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11519. * @returns the cube texture as an InternalTexture
  11520. */
  11521. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11522. /** @hidden */
  11523. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11524. /** @hidden */
  11525. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11526. /** @hidden */
  11527. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11528. /** @hidden */
  11529. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11530. /** @hidden */
  11531. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11532. /**
  11533. * @hidden
  11534. */
  11535. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11536. }
  11537. }
  11538. declare module BABYLON {
  11539. /**
  11540. * Class for creating a cube texture
  11541. */
  11542. export class CubeTexture extends BaseTexture {
  11543. private _delayedOnLoad;
  11544. /**
  11545. * Observable triggered once the texture has been loaded.
  11546. */
  11547. onLoadObservable: Observable<CubeTexture>;
  11548. /**
  11549. * The url of the texture
  11550. */
  11551. url: string;
  11552. /**
  11553. * Gets or sets the center of the bounding box associated with the cube texture.
  11554. * It must define where the camera used to render the texture was set
  11555. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11556. */
  11557. boundingBoxPosition: Vector3;
  11558. private _boundingBoxSize;
  11559. /**
  11560. * Gets or sets the size of the bounding box associated with the cube texture
  11561. * When defined, the cubemap will switch to local mode
  11562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11563. * @example https://www.babylonjs-playground.com/#RNASML
  11564. */
  11565. set boundingBoxSize(value: Vector3);
  11566. /**
  11567. * Returns the bounding box size
  11568. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11569. */
  11570. get boundingBoxSize(): Vector3;
  11571. protected _rotationY: number;
  11572. /**
  11573. * Sets texture matrix rotation angle around Y axis in radians.
  11574. */
  11575. set rotationY(value: number);
  11576. /**
  11577. * Gets texture matrix rotation angle around Y axis radians.
  11578. */
  11579. get rotationY(): number;
  11580. /**
  11581. * Are mip maps generated for this texture or not.
  11582. */
  11583. get noMipmap(): boolean;
  11584. private _noMipmap;
  11585. private _files;
  11586. protected _forcedExtension: Nullable<string>;
  11587. private _extensions;
  11588. private _textureMatrix;
  11589. private _format;
  11590. private _createPolynomials;
  11591. private _loaderOptions;
  11592. /**
  11593. * Creates a cube texture from an array of image urls
  11594. * @param files defines an array of image urls
  11595. * @param scene defines the hosting scene
  11596. * @param noMipmap specifies if mip maps are not used
  11597. * @returns a cube texture
  11598. */
  11599. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11600. /**
  11601. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11602. * @param url defines the url of the prefiltered texture
  11603. * @param scene defines the scene the texture is attached to
  11604. * @param forcedExtension defines the extension of the file if different from the url
  11605. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11606. * @return the prefiltered texture
  11607. */
  11608. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11609. /**
  11610. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11611. * as prefiltered data.
  11612. * @param rootUrl defines the url of the texture or the root name of the six images
  11613. * @param null defines the scene or engine the texture is attached to
  11614. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11615. * @param noMipmap defines if mipmaps should be created or not
  11616. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11617. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11618. * @param onError defines a callback triggered in case of error during load
  11619. * @param format defines the internal format to use for the texture once loaded
  11620. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11621. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11622. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11623. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11624. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11625. * @param loaderOptions options to be passed to the loader
  11626. * @return the cube texture
  11627. */
  11628. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11629. /**
  11630. * Get the current class name of the texture useful for serialization or dynamic coding.
  11631. * @returns "CubeTexture"
  11632. */
  11633. getClassName(): string;
  11634. /**
  11635. * Update the url (and optional buffer) of this texture if url was null during construction.
  11636. * @param url the url of the texture
  11637. * @param forcedExtension defines the extension to use
  11638. * @param onLoad callback called when the texture is loaded (defaults to null)
  11639. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11640. */
  11641. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11642. /**
  11643. * Delays loading of the cube texture
  11644. * @param forcedExtension defines the extension to use
  11645. */
  11646. delayLoad(forcedExtension?: string): void;
  11647. /**
  11648. * Returns the reflection texture matrix
  11649. * @returns the reflection texture matrix
  11650. */
  11651. getReflectionTextureMatrix(): Matrix;
  11652. /**
  11653. * Sets the reflection texture matrix
  11654. * @param value Reflection texture matrix
  11655. */
  11656. setReflectionTextureMatrix(value: Matrix): void;
  11657. /**
  11658. * Parses text to create a cube texture
  11659. * @param parsedTexture define the serialized text to read from
  11660. * @param scene defines the hosting scene
  11661. * @param rootUrl defines the root url of the cube texture
  11662. * @returns a cube texture
  11663. */
  11664. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11665. /**
  11666. * Makes a clone, or deep copy, of the cube texture
  11667. * @returns a new cube texture
  11668. */
  11669. clone(): CubeTexture;
  11670. }
  11671. }
  11672. declare module BABYLON {
  11673. /**
  11674. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11676. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11678. */
  11679. export class ColorCurves {
  11680. private _dirty;
  11681. private _tempColor;
  11682. private _globalCurve;
  11683. private _highlightsCurve;
  11684. private _midtonesCurve;
  11685. private _shadowsCurve;
  11686. private _positiveCurve;
  11687. private _negativeCurve;
  11688. private _globalHue;
  11689. private _globalDensity;
  11690. private _globalSaturation;
  11691. private _globalExposure;
  11692. /**
  11693. * Gets the global Hue value.
  11694. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11695. */
  11696. get globalHue(): number;
  11697. /**
  11698. * Sets the global Hue value.
  11699. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11700. */
  11701. set globalHue(value: number);
  11702. /**
  11703. * Gets the global Density value.
  11704. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11705. * Values less than zero provide a filter of opposite hue.
  11706. */
  11707. get globalDensity(): number;
  11708. /**
  11709. * Sets the global Density value.
  11710. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11711. * Values less than zero provide a filter of opposite hue.
  11712. */
  11713. set globalDensity(value: number);
  11714. /**
  11715. * Gets the global Saturation value.
  11716. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11717. */
  11718. get globalSaturation(): number;
  11719. /**
  11720. * Sets the global Saturation value.
  11721. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11722. */
  11723. set globalSaturation(value: number);
  11724. /**
  11725. * Gets the global Exposure value.
  11726. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11727. */
  11728. get globalExposure(): number;
  11729. /**
  11730. * Sets the global Exposure value.
  11731. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11732. */
  11733. set globalExposure(value: number);
  11734. private _highlightsHue;
  11735. private _highlightsDensity;
  11736. private _highlightsSaturation;
  11737. private _highlightsExposure;
  11738. /**
  11739. * Gets the highlights Hue value.
  11740. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11741. */
  11742. get highlightsHue(): number;
  11743. /**
  11744. * Sets the highlights Hue value.
  11745. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11746. */
  11747. set highlightsHue(value: number);
  11748. /**
  11749. * Gets the highlights Density value.
  11750. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11751. * Values less than zero provide a filter of opposite hue.
  11752. */
  11753. get highlightsDensity(): number;
  11754. /**
  11755. * Sets the highlights Density value.
  11756. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11757. * Values less than zero provide a filter of opposite hue.
  11758. */
  11759. set highlightsDensity(value: number);
  11760. /**
  11761. * Gets the highlights Saturation value.
  11762. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11763. */
  11764. get highlightsSaturation(): number;
  11765. /**
  11766. * Sets the highlights Saturation value.
  11767. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11768. */
  11769. set highlightsSaturation(value: number);
  11770. /**
  11771. * Gets the highlights Exposure value.
  11772. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11773. */
  11774. get highlightsExposure(): number;
  11775. /**
  11776. * Sets the highlights Exposure value.
  11777. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11778. */
  11779. set highlightsExposure(value: number);
  11780. private _midtonesHue;
  11781. private _midtonesDensity;
  11782. private _midtonesSaturation;
  11783. private _midtonesExposure;
  11784. /**
  11785. * Gets the midtones Hue value.
  11786. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11787. */
  11788. get midtonesHue(): number;
  11789. /**
  11790. * Sets the midtones Hue value.
  11791. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11792. */
  11793. set midtonesHue(value: number);
  11794. /**
  11795. * Gets the midtones Density value.
  11796. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11797. * Values less than zero provide a filter of opposite hue.
  11798. */
  11799. get midtonesDensity(): number;
  11800. /**
  11801. * Sets the midtones Density value.
  11802. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11803. * Values less than zero provide a filter of opposite hue.
  11804. */
  11805. set midtonesDensity(value: number);
  11806. /**
  11807. * Gets the midtones Saturation value.
  11808. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11809. */
  11810. get midtonesSaturation(): number;
  11811. /**
  11812. * Sets the midtones Saturation value.
  11813. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11814. */
  11815. set midtonesSaturation(value: number);
  11816. /**
  11817. * Gets the midtones Exposure value.
  11818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11819. */
  11820. get midtonesExposure(): number;
  11821. /**
  11822. * Sets the midtones Exposure value.
  11823. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11824. */
  11825. set midtonesExposure(value: number);
  11826. private _shadowsHue;
  11827. private _shadowsDensity;
  11828. private _shadowsSaturation;
  11829. private _shadowsExposure;
  11830. /**
  11831. * Gets the shadows Hue value.
  11832. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11833. */
  11834. get shadowsHue(): number;
  11835. /**
  11836. * Sets the shadows Hue value.
  11837. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11838. */
  11839. set shadowsHue(value: number);
  11840. /**
  11841. * Gets the shadows Density value.
  11842. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11843. * Values less than zero provide a filter of opposite hue.
  11844. */
  11845. get shadowsDensity(): number;
  11846. /**
  11847. * Sets the shadows Density value.
  11848. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11849. * Values less than zero provide a filter of opposite hue.
  11850. */
  11851. set shadowsDensity(value: number);
  11852. /**
  11853. * Gets the shadows Saturation value.
  11854. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11855. */
  11856. get shadowsSaturation(): number;
  11857. /**
  11858. * Sets the shadows Saturation value.
  11859. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11860. */
  11861. set shadowsSaturation(value: number);
  11862. /**
  11863. * Gets the shadows Exposure value.
  11864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11865. */
  11866. get shadowsExposure(): number;
  11867. /**
  11868. * Sets the shadows Exposure value.
  11869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11870. */
  11871. set shadowsExposure(value: number);
  11872. /**
  11873. * Returns the class name
  11874. * @returns The class name
  11875. */
  11876. getClassName(): string;
  11877. /**
  11878. * Binds the color curves to the shader.
  11879. * @param colorCurves The color curve to bind
  11880. * @param effect The effect to bind to
  11881. * @param positiveUniform The positive uniform shader parameter
  11882. * @param neutralUniform The neutral uniform shader parameter
  11883. * @param negativeUniform The negative uniform shader parameter
  11884. */
  11885. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11886. /**
  11887. * Prepare the list of uniforms associated with the ColorCurves effects.
  11888. * @param uniformsList The list of uniforms used in the effect
  11889. */
  11890. static PrepareUniforms(uniformsList: string[]): void;
  11891. /**
  11892. * Returns color grading data based on a hue, density, saturation and exposure value.
  11893. * @param filterHue The hue of the color filter.
  11894. * @param filterDensity The density of the color filter.
  11895. * @param saturation The saturation.
  11896. * @param exposure The exposure.
  11897. * @param result The result data container.
  11898. */
  11899. private getColorGradingDataToRef;
  11900. /**
  11901. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11902. * @param value The input slider value in range [-100,100].
  11903. * @returns Adjusted value.
  11904. */
  11905. private static applyColorGradingSliderNonlinear;
  11906. /**
  11907. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11908. * @param hue The hue (H) input.
  11909. * @param saturation The saturation (S) input.
  11910. * @param brightness The brightness (B) input.
  11911. * @result An RGBA color represented as Vector4.
  11912. */
  11913. private static fromHSBToRef;
  11914. /**
  11915. * Returns a value clamped between min and max
  11916. * @param value The value to clamp
  11917. * @param min The minimum of value
  11918. * @param max The maximum of value
  11919. * @returns The clamped value.
  11920. */
  11921. private static clamp;
  11922. /**
  11923. * Clones the current color curve instance.
  11924. * @return The cloned curves
  11925. */
  11926. clone(): ColorCurves;
  11927. /**
  11928. * Serializes the current color curve instance to a json representation.
  11929. * @return a JSON representation
  11930. */
  11931. serialize(): any;
  11932. /**
  11933. * Parses the color curve from a json representation.
  11934. * @param source the JSON source to parse
  11935. * @return The parsed curves
  11936. */
  11937. static Parse(source: any): ColorCurves;
  11938. }
  11939. }
  11940. declare module BABYLON {
  11941. /**
  11942. * Interface to follow in your material defines to integrate easily the
  11943. * Image processing functions.
  11944. * @hidden
  11945. */
  11946. export interface IImageProcessingConfigurationDefines {
  11947. IMAGEPROCESSING: boolean;
  11948. VIGNETTE: boolean;
  11949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11950. VIGNETTEBLENDMODEOPAQUE: boolean;
  11951. TONEMAPPING: boolean;
  11952. TONEMAPPING_ACES: boolean;
  11953. CONTRAST: boolean;
  11954. EXPOSURE: boolean;
  11955. COLORCURVES: boolean;
  11956. COLORGRADING: boolean;
  11957. COLORGRADING3D: boolean;
  11958. SAMPLER3DGREENDEPTH: boolean;
  11959. SAMPLER3DBGRMAP: boolean;
  11960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11961. }
  11962. /**
  11963. * @hidden
  11964. */
  11965. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11966. IMAGEPROCESSING: boolean;
  11967. VIGNETTE: boolean;
  11968. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11969. VIGNETTEBLENDMODEOPAQUE: boolean;
  11970. TONEMAPPING: boolean;
  11971. TONEMAPPING_ACES: boolean;
  11972. CONTRAST: boolean;
  11973. COLORCURVES: boolean;
  11974. COLORGRADING: boolean;
  11975. COLORGRADING3D: boolean;
  11976. SAMPLER3DGREENDEPTH: boolean;
  11977. SAMPLER3DBGRMAP: boolean;
  11978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11979. EXPOSURE: boolean;
  11980. constructor();
  11981. }
  11982. /**
  11983. * This groups together the common properties used for image processing either in direct forward pass
  11984. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11985. * or not.
  11986. */
  11987. export class ImageProcessingConfiguration {
  11988. /**
  11989. * Default tone mapping applied in BabylonJS.
  11990. */
  11991. static readonly TONEMAPPING_STANDARD: number;
  11992. /**
  11993. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11994. * to other engines rendering to increase portability.
  11995. */
  11996. static readonly TONEMAPPING_ACES: number;
  11997. /**
  11998. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11999. */
  12000. colorCurves: Nullable<ColorCurves>;
  12001. private _colorCurvesEnabled;
  12002. /**
  12003. * Gets whether the color curves effect is enabled.
  12004. */
  12005. get colorCurvesEnabled(): boolean;
  12006. /**
  12007. * Sets whether the color curves effect is enabled.
  12008. */
  12009. set colorCurvesEnabled(value: boolean);
  12010. private _colorGradingTexture;
  12011. /**
  12012. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12013. */
  12014. get colorGradingTexture(): Nullable<BaseTexture>;
  12015. /**
  12016. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12017. */
  12018. set colorGradingTexture(value: Nullable<BaseTexture>);
  12019. private _colorGradingEnabled;
  12020. /**
  12021. * Gets whether the color grading effect is enabled.
  12022. */
  12023. get colorGradingEnabled(): boolean;
  12024. /**
  12025. * Sets whether the color grading effect is enabled.
  12026. */
  12027. set colorGradingEnabled(value: boolean);
  12028. private _colorGradingWithGreenDepth;
  12029. /**
  12030. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12031. */
  12032. get colorGradingWithGreenDepth(): boolean;
  12033. /**
  12034. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12035. */
  12036. set colorGradingWithGreenDepth(value: boolean);
  12037. private _colorGradingBGR;
  12038. /**
  12039. * Gets whether the color grading texture contains BGR values.
  12040. */
  12041. get colorGradingBGR(): boolean;
  12042. /**
  12043. * Sets whether the color grading texture contains BGR values.
  12044. */
  12045. set colorGradingBGR(value: boolean);
  12046. /** @hidden */
  12047. _exposure: number;
  12048. /**
  12049. * Gets the Exposure used in the effect.
  12050. */
  12051. get exposure(): number;
  12052. /**
  12053. * Sets the Exposure used in the effect.
  12054. */
  12055. set exposure(value: number);
  12056. private _toneMappingEnabled;
  12057. /**
  12058. * Gets whether the tone mapping effect is enabled.
  12059. */
  12060. get toneMappingEnabled(): boolean;
  12061. /**
  12062. * Sets whether the tone mapping effect is enabled.
  12063. */
  12064. set toneMappingEnabled(value: boolean);
  12065. private _toneMappingType;
  12066. /**
  12067. * Gets the type of tone mapping effect.
  12068. */
  12069. get toneMappingType(): number;
  12070. /**
  12071. * Sets the type of tone mapping effect used in BabylonJS.
  12072. */
  12073. set toneMappingType(value: number);
  12074. protected _contrast: number;
  12075. /**
  12076. * Gets the contrast used in the effect.
  12077. */
  12078. get contrast(): number;
  12079. /**
  12080. * Sets the contrast used in the effect.
  12081. */
  12082. set contrast(value: number);
  12083. /**
  12084. * Vignette stretch size.
  12085. */
  12086. vignetteStretch: number;
  12087. /**
  12088. * Vignette centre X Offset.
  12089. */
  12090. vignetteCentreX: number;
  12091. /**
  12092. * Vignette centre Y Offset.
  12093. */
  12094. vignetteCentreY: number;
  12095. /**
  12096. * Vignette weight or intensity of the vignette effect.
  12097. */
  12098. vignetteWeight: number;
  12099. /**
  12100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12101. * if vignetteEnabled is set to true.
  12102. */
  12103. vignetteColor: Color4;
  12104. /**
  12105. * Camera field of view used by the Vignette effect.
  12106. */
  12107. vignetteCameraFov: number;
  12108. private _vignetteBlendMode;
  12109. /**
  12110. * Gets the vignette blend mode allowing different kind of effect.
  12111. */
  12112. get vignetteBlendMode(): number;
  12113. /**
  12114. * Sets the vignette blend mode allowing different kind of effect.
  12115. */
  12116. set vignetteBlendMode(value: number);
  12117. private _vignetteEnabled;
  12118. /**
  12119. * Gets whether the vignette effect is enabled.
  12120. */
  12121. get vignetteEnabled(): boolean;
  12122. /**
  12123. * Sets whether the vignette effect is enabled.
  12124. */
  12125. set vignetteEnabled(value: boolean);
  12126. private _applyByPostProcess;
  12127. /**
  12128. * Gets whether the image processing is applied through a post process or not.
  12129. */
  12130. get applyByPostProcess(): boolean;
  12131. /**
  12132. * Sets whether the image processing is applied through a post process or not.
  12133. */
  12134. set applyByPostProcess(value: boolean);
  12135. private _isEnabled;
  12136. /**
  12137. * Gets whether the image processing is enabled or not.
  12138. */
  12139. get isEnabled(): boolean;
  12140. /**
  12141. * Sets whether the image processing is enabled or not.
  12142. */
  12143. set isEnabled(value: boolean);
  12144. /**
  12145. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12146. */
  12147. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12148. /**
  12149. * Method called each time the image processing information changes requires to recompile the effect.
  12150. */
  12151. protected _updateParameters(): void;
  12152. /**
  12153. * Gets the current class name.
  12154. * @return "ImageProcessingConfiguration"
  12155. */
  12156. getClassName(): string;
  12157. /**
  12158. * Prepare the list of uniforms associated with the Image Processing effects.
  12159. * @param uniforms The list of uniforms used in the effect
  12160. * @param defines the list of defines currently in use
  12161. */
  12162. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12163. /**
  12164. * Prepare the list of samplers associated with the Image Processing effects.
  12165. * @param samplersList The list of uniforms used in the effect
  12166. * @param defines the list of defines currently in use
  12167. */
  12168. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12169. /**
  12170. * Prepare the list of defines associated to the shader.
  12171. * @param defines the list of defines to complete
  12172. * @param forPostProcess Define if we are currently in post process mode or not
  12173. */
  12174. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12175. /**
  12176. * Returns true if all the image processing information are ready.
  12177. * @returns True if ready, otherwise, false
  12178. */
  12179. isReady(): boolean;
  12180. /**
  12181. * Binds the image processing to the shader.
  12182. * @param effect The effect to bind to
  12183. * @param overrideAspectRatio Override the aspect ratio of the effect
  12184. */
  12185. bind(effect: Effect, overrideAspectRatio?: number): void;
  12186. /**
  12187. * Clones the current image processing instance.
  12188. * @return The cloned image processing
  12189. */
  12190. clone(): ImageProcessingConfiguration;
  12191. /**
  12192. * Serializes the current image processing instance to a json representation.
  12193. * @return a JSON representation
  12194. */
  12195. serialize(): any;
  12196. /**
  12197. * Parses the image processing from a json representation.
  12198. * @param source the JSON source to parse
  12199. * @return The parsed image processing
  12200. */
  12201. static Parse(source: any): ImageProcessingConfiguration;
  12202. private static _VIGNETTEMODE_MULTIPLY;
  12203. private static _VIGNETTEMODE_OPAQUE;
  12204. /**
  12205. * Used to apply the vignette as a mix with the pixel color.
  12206. */
  12207. static get VIGNETTEMODE_MULTIPLY(): number;
  12208. /**
  12209. * Used to apply the vignette as a replacement of the pixel color.
  12210. */
  12211. static get VIGNETTEMODE_OPAQUE(): number;
  12212. }
  12213. }
  12214. declare module BABYLON {
  12215. /** @hidden */
  12216. export var postprocessVertexShader: {
  12217. name: string;
  12218. shader: string;
  12219. };
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12224. */
  12225. export type RenderTargetTextureSize = number | {
  12226. width: number;
  12227. height: number;
  12228. layers?: number;
  12229. };
  12230. interface ThinEngine {
  12231. /**
  12232. * Creates a new render target texture
  12233. * @param size defines the size of the texture
  12234. * @param options defines the options used to create the texture
  12235. * @returns a new render target texture stored in an InternalTexture
  12236. */
  12237. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12238. /**
  12239. * Creates a depth stencil texture.
  12240. * This is only available in WebGL 2 or with the depth texture extension available.
  12241. * @param size The size of face edge in the texture.
  12242. * @param options The options defining the texture.
  12243. * @returns The texture
  12244. */
  12245. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12246. /** @hidden */
  12247. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Defines the kind of connection point for node based material
  12253. */
  12254. export enum NodeMaterialBlockConnectionPointTypes {
  12255. /** Float */
  12256. Float = 1,
  12257. /** Int */
  12258. Int = 2,
  12259. /** Vector2 */
  12260. Vector2 = 4,
  12261. /** Vector3 */
  12262. Vector3 = 8,
  12263. /** Vector4 */
  12264. Vector4 = 16,
  12265. /** Color3 */
  12266. Color3 = 32,
  12267. /** Color4 */
  12268. Color4 = 64,
  12269. /** Matrix */
  12270. Matrix = 128,
  12271. /** Custom object */
  12272. Object = 256,
  12273. /** Detect type based on connection */
  12274. AutoDetect = 1024,
  12275. /** Output type that will be defined by input type */
  12276. BasedOnInput = 2048
  12277. }
  12278. }
  12279. declare module BABYLON {
  12280. /**
  12281. * Enum used to define the target of a block
  12282. */
  12283. export enum NodeMaterialBlockTargets {
  12284. /** Vertex shader */
  12285. Vertex = 1,
  12286. /** Fragment shader */
  12287. Fragment = 2,
  12288. /** Neutral */
  12289. Neutral = 4,
  12290. /** Vertex and Fragment */
  12291. VertexAndFragment = 3
  12292. }
  12293. }
  12294. declare module BABYLON {
  12295. /**
  12296. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12297. */
  12298. export enum NodeMaterialBlockConnectionPointMode {
  12299. /** Value is an uniform */
  12300. Uniform = 0,
  12301. /** Value is a mesh attribute */
  12302. Attribute = 1,
  12303. /** Value is a varying between vertex and fragment shaders */
  12304. Varying = 2,
  12305. /** Mode is undefined */
  12306. Undefined = 3
  12307. }
  12308. }
  12309. declare module BABYLON {
  12310. /**
  12311. * Enum used to define system values e.g. values automatically provided by the system
  12312. */
  12313. export enum NodeMaterialSystemValues {
  12314. /** World */
  12315. World = 1,
  12316. /** View */
  12317. View = 2,
  12318. /** Projection */
  12319. Projection = 3,
  12320. /** ViewProjection */
  12321. ViewProjection = 4,
  12322. /** WorldView */
  12323. WorldView = 5,
  12324. /** WorldViewProjection */
  12325. WorldViewProjection = 6,
  12326. /** CameraPosition */
  12327. CameraPosition = 7,
  12328. /** Fog Color */
  12329. FogColor = 8,
  12330. /** Delta time */
  12331. DeltaTime = 9
  12332. }
  12333. }
  12334. declare module BABYLON {
  12335. /**
  12336. * Represents a camera frustum
  12337. */
  12338. export class Frustum {
  12339. /**
  12340. * Gets the planes representing the frustum
  12341. * @param transform matrix to be applied to the returned planes
  12342. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12343. */
  12344. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12345. /**
  12346. * Gets the near frustum plane transformed by the transform matrix
  12347. * @param transform transformation matrix to be applied to the resulting frustum plane
  12348. * @param frustumPlane the resuling frustum plane
  12349. */
  12350. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12351. /**
  12352. * Gets the far frustum plane transformed by the transform matrix
  12353. * @param transform transformation matrix to be applied to the resulting frustum plane
  12354. * @param frustumPlane the resuling frustum plane
  12355. */
  12356. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12357. /**
  12358. * Gets the left frustum plane transformed by the transform matrix
  12359. * @param transform transformation matrix to be applied to the resulting frustum plane
  12360. * @param frustumPlane the resuling frustum plane
  12361. */
  12362. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12363. /**
  12364. * Gets the right frustum plane transformed by the transform matrix
  12365. * @param transform transformation matrix to be applied to the resulting frustum plane
  12366. * @param frustumPlane the resuling frustum plane
  12367. */
  12368. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12369. /**
  12370. * Gets the top frustum plane transformed by the transform matrix
  12371. * @param transform transformation matrix to be applied to the resulting frustum plane
  12372. * @param frustumPlane the resuling frustum plane
  12373. */
  12374. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12375. /**
  12376. * Gets the bottom frustum plane transformed by the transform matrix
  12377. * @param transform transformation matrix to be applied to the resulting frustum plane
  12378. * @param frustumPlane the resuling frustum plane
  12379. */
  12380. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12381. /**
  12382. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12383. * @param transform transformation matrix to be applied to the resulting frustum planes
  12384. * @param frustumPlanes the resuling frustum planes
  12385. */
  12386. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12387. }
  12388. }
  12389. declare module BABYLON {
  12390. /**
  12391. * Contains position and normal vectors for a vertex
  12392. */
  12393. export class PositionNormalVertex {
  12394. /** the position of the vertex (defaut: 0,0,0) */
  12395. position: Vector3;
  12396. /** the normal of the vertex (defaut: 0,1,0) */
  12397. normal: Vector3;
  12398. /**
  12399. * Creates a PositionNormalVertex
  12400. * @param position the position of the vertex (defaut: 0,0,0)
  12401. * @param normal the normal of the vertex (defaut: 0,1,0)
  12402. */
  12403. constructor(
  12404. /** the position of the vertex (defaut: 0,0,0) */
  12405. position?: Vector3,
  12406. /** the normal of the vertex (defaut: 0,1,0) */
  12407. normal?: Vector3);
  12408. /**
  12409. * Clones the PositionNormalVertex
  12410. * @returns the cloned PositionNormalVertex
  12411. */
  12412. clone(): PositionNormalVertex;
  12413. }
  12414. /**
  12415. * Contains position, normal and uv vectors for a vertex
  12416. */
  12417. export class PositionNormalTextureVertex {
  12418. /** the position of the vertex (defaut: 0,0,0) */
  12419. position: Vector3;
  12420. /** the normal of the vertex (defaut: 0,1,0) */
  12421. normal: Vector3;
  12422. /** the uv of the vertex (default: 0,0) */
  12423. uv: Vector2;
  12424. /**
  12425. * Creates a PositionNormalTextureVertex
  12426. * @param position the position of the vertex (defaut: 0,0,0)
  12427. * @param normal the normal of the vertex (defaut: 0,1,0)
  12428. * @param uv the uv of the vertex (default: 0,0)
  12429. */
  12430. constructor(
  12431. /** the position of the vertex (defaut: 0,0,0) */
  12432. position?: Vector3,
  12433. /** the normal of the vertex (defaut: 0,1,0) */
  12434. normal?: Vector3,
  12435. /** the uv of the vertex (default: 0,0) */
  12436. uv?: Vector2);
  12437. /**
  12438. * Clones the PositionNormalTextureVertex
  12439. * @returns the cloned PositionNormalTextureVertex
  12440. */
  12441. clone(): PositionNormalTextureVertex;
  12442. }
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Enum defining the type of animations supported by InputBlock
  12447. */
  12448. export enum AnimatedInputBlockTypes {
  12449. /** No animation */
  12450. None = 0,
  12451. /** Time based animation. Will only work for floats */
  12452. Time = 1
  12453. }
  12454. }
  12455. declare module BABYLON {
  12456. /**
  12457. * Block used to expose an input value
  12458. */
  12459. export class InputBlock extends NodeMaterialBlock {
  12460. private _mode;
  12461. private _associatedVariableName;
  12462. private _storedValue;
  12463. private _valueCallback;
  12464. private _type;
  12465. private _animationType;
  12466. /** Gets or set a value used to limit the range of float values */
  12467. min: number;
  12468. /** Gets or set a value used to limit the range of float values */
  12469. max: number;
  12470. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12471. isBoolean: boolean;
  12472. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12473. matrixMode: number;
  12474. /** @hidden */
  12475. _systemValue: Nullable<NodeMaterialSystemValues>;
  12476. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12477. isConstant: boolean;
  12478. /** Gets or sets the group to use to display this block in the Inspector */
  12479. groupInInspector: string;
  12480. /** Gets an observable raised when the value is changed */
  12481. onValueChangedObservable: Observable<InputBlock>;
  12482. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12483. convertToGammaSpace: boolean;
  12484. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12485. convertToLinearSpace: boolean;
  12486. /**
  12487. * Gets or sets the connection point type (default is float)
  12488. */
  12489. get type(): NodeMaterialBlockConnectionPointTypes;
  12490. /**
  12491. * Creates a new InputBlock
  12492. * @param name defines the block name
  12493. * @param target defines the target of that block (Vertex by default)
  12494. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12495. */
  12496. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12497. /**
  12498. * Validates if a name is a reserve word.
  12499. * @param newName the new name to be given to the node.
  12500. * @returns false if the name is a reserve word, else true.
  12501. */
  12502. validateBlockName(newName: string): boolean;
  12503. /**
  12504. * Gets the output component
  12505. */
  12506. get output(): NodeMaterialConnectionPoint;
  12507. /**
  12508. * Set the source of this connection point to a vertex attribute
  12509. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12510. * @returns the current connection point
  12511. */
  12512. setAsAttribute(attributeName?: string): InputBlock;
  12513. /**
  12514. * Set the source of this connection point to a system value
  12515. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12516. * @returns the current connection point
  12517. */
  12518. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12519. /**
  12520. * Gets or sets the value of that point.
  12521. * Please note that this value will be ignored if valueCallback is defined
  12522. */
  12523. get value(): any;
  12524. set value(value: any);
  12525. /**
  12526. * Gets or sets a callback used to get the value of that point.
  12527. * Please note that setting this value will force the connection point to ignore the value property
  12528. */
  12529. get valueCallback(): () => any;
  12530. set valueCallback(value: () => any);
  12531. /**
  12532. * Gets or sets the associated variable name in the shader
  12533. */
  12534. get associatedVariableName(): string;
  12535. set associatedVariableName(value: string);
  12536. /** Gets or sets the type of animation applied to the input */
  12537. get animationType(): AnimatedInputBlockTypes;
  12538. set animationType(value: AnimatedInputBlockTypes);
  12539. /**
  12540. * Gets a boolean indicating that this connection point not defined yet
  12541. */
  12542. get isUndefined(): boolean;
  12543. /**
  12544. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12545. * In this case the connection point name must be the name of the uniform to use.
  12546. * Can only be set on inputs
  12547. */
  12548. get isUniform(): boolean;
  12549. set isUniform(value: boolean);
  12550. /**
  12551. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12552. * In this case the connection point name must be the name of the attribute to use
  12553. * Can only be set on inputs
  12554. */
  12555. get isAttribute(): boolean;
  12556. set isAttribute(value: boolean);
  12557. /**
  12558. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12559. * Can only be set on exit points
  12560. */
  12561. get isVarying(): boolean;
  12562. set isVarying(value: boolean);
  12563. /**
  12564. * Gets a boolean indicating that the current connection point is a system value
  12565. */
  12566. get isSystemValue(): boolean;
  12567. /**
  12568. * Gets or sets the current well known value or null if not defined as a system value
  12569. */
  12570. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12571. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12572. /**
  12573. * Gets the current class name
  12574. * @returns the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Animate the input if animationType !== None
  12579. * @param scene defines the rendering scene
  12580. */
  12581. animate(scene: Scene): void;
  12582. private _emitDefine;
  12583. initialize(state: NodeMaterialBuildState): void;
  12584. /**
  12585. * Set the input block to its default value (based on its type)
  12586. */
  12587. setDefaultValue(): void;
  12588. private _emitConstant;
  12589. /** @hidden */
  12590. get _noContextSwitch(): boolean;
  12591. private _emit;
  12592. /** @hidden */
  12593. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12594. /** @hidden */
  12595. _transmit(effect: Effect, scene: Scene): void;
  12596. protected _buildBlock(state: NodeMaterialBuildState): void;
  12597. protected _dumpPropertiesCode(): string;
  12598. dispose(): void;
  12599. serialize(): any;
  12600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12601. }
  12602. }
  12603. declare module BABYLON {
  12604. /**
  12605. * Enum used to define the compatibility state between two connection points
  12606. */
  12607. export enum NodeMaterialConnectionPointCompatibilityStates {
  12608. /** Points are compatibles */
  12609. Compatible = 0,
  12610. /** Points are incompatible because of their types */
  12611. TypeIncompatible = 1,
  12612. /** Points are incompatible because of their targets (vertex vs fragment) */
  12613. TargetIncompatible = 2
  12614. }
  12615. /**
  12616. * Defines the direction of a connection point
  12617. */
  12618. export enum NodeMaterialConnectionPointDirection {
  12619. /** Input */
  12620. Input = 0,
  12621. /** Output */
  12622. Output = 1
  12623. }
  12624. /**
  12625. * Defines a connection point for a block
  12626. */
  12627. export class NodeMaterialConnectionPoint {
  12628. /**
  12629. * Checks if two types are equivalent
  12630. * @param type1 type 1 to check
  12631. * @param type2 type 2 to check
  12632. * @returns true if both types are equivalent, else false
  12633. */
  12634. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12635. /** @hidden */
  12636. _ownerBlock: NodeMaterialBlock;
  12637. /** @hidden */
  12638. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12639. private _endpoints;
  12640. private _associatedVariableName;
  12641. private _direction;
  12642. /** @hidden */
  12643. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12644. /** @hidden */
  12645. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12646. /** @hidden */
  12647. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12648. private _type;
  12649. /** @hidden */
  12650. _enforceAssociatedVariableName: boolean;
  12651. /** Gets the direction of the point */
  12652. get direction(): NodeMaterialConnectionPointDirection;
  12653. /** Indicates that this connection point needs dual validation before being connected to another point */
  12654. needDualDirectionValidation: boolean;
  12655. /**
  12656. * Gets or sets the additional types supported by this connection point
  12657. */
  12658. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12659. /**
  12660. * Gets or sets the additional types excluded by this connection point
  12661. */
  12662. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12663. /**
  12664. * Observable triggered when this point is connected
  12665. */
  12666. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12667. /**
  12668. * Gets or sets the associated variable name in the shader
  12669. */
  12670. get associatedVariableName(): string;
  12671. set associatedVariableName(value: string);
  12672. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12673. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12674. /**
  12675. * Gets or sets the connection point type (default is float)
  12676. */
  12677. get type(): NodeMaterialBlockConnectionPointTypes;
  12678. set type(value: NodeMaterialBlockConnectionPointTypes);
  12679. /**
  12680. * Gets or sets the connection point name
  12681. */
  12682. name: string;
  12683. /**
  12684. * Gets or sets the connection point name
  12685. */
  12686. displayName: string;
  12687. /**
  12688. * Gets or sets a boolean indicating that this connection point can be omitted
  12689. */
  12690. isOptional: boolean;
  12691. /**
  12692. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12693. */
  12694. isExposedOnFrame: boolean;
  12695. /**
  12696. * Gets or sets number indicating the position that the port is exposed to on a frame
  12697. */
  12698. exposedPortPosition: number;
  12699. /**
  12700. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12701. */
  12702. define: string;
  12703. /** @hidden */
  12704. _prioritizeVertex: boolean;
  12705. private _target;
  12706. /** Gets or sets the target of that connection point */
  12707. get target(): NodeMaterialBlockTargets;
  12708. set target(value: NodeMaterialBlockTargets);
  12709. /**
  12710. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12711. */
  12712. get isConnected(): boolean;
  12713. /**
  12714. * Gets a boolean indicating that the current point is connected to an input block
  12715. */
  12716. get isConnectedToInputBlock(): boolean;
  12717. /**
  12718. * Gets a the connected input block (if any)
  12719. */
  12720. get connectInputBlock(): Nullable<InputBlock>;
  12721. /** Get the other side of the connection (if any) */
  12722. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12723. /** Get the block that owns this connection point */
  12724. get ownerBlock(): NodeMaterialBlock;
  12725. /** Get the block connected on the other side of this connection (if any) */
  12726. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12727. /** Get the block connected on the endpoints of this connection (if any) */
  12728. get connectedBlocks(): Array<NodeMaterialBlock>;
  12729. /** Gets the list of connected endpoints */
  12730. get endpoints(): NodeMaterialConnectionPoint[];
  12731. /** Gets a boolean indicating if that output point is connected to at least one input */
  12732. get hasEndpoints(): boolean;
  12733. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12734. get isConnectedInVertexShader(): boolean;
  12735. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12736. get isConnectedInFragmentShader(): boolean;
  12737. /**
  12738. * Creates a block suitable to be used as an input for this input point.
  12739. * If null is returned, a block based on the point type will be created.
  12740. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12741. */
  12742. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12743. /**
  12744. * Creates a new connection point
  12745. * @param name defines the connection point name
  12746. * @param ownerBlock defines the block hosting this connection point
  12747. * @param direction defines the direction of the connection point
  12748. */
  12749. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12750. /**
  12751. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets a boolean indicating if the current point can be connected to another point
  12757. * @param connectionPoint defines the other connection point
  12758. * @returns a boolean
  12759. */
  12760. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12761. /**
  12762. * Gets a number indicating if the current point can be connected to another point
  12763. * @param connectionPoint defines the other connection point
  12764. * @returns a number defining the compatibility state
  12765. */
  12766. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12767. /**
  12768. * Connect this point to another connection point
  12769. * @param connectionPoint defines the other connection point
  12770. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12771. * @returns the current connection point
  12772. */
  12773. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Disconnect this point from one of his endpoint
  12776. * @param endpoint defines the other connection point
  12777. * @returns the current connection point
  12778. */
  12779. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12780. /**
  12781. * Serializes this point in a JSON representation
  12782. * @param isInput defines if the connection point is an input (default is true)
  12783. * @returns the serialized point object
  12784. */
  12785. serialize(isInput?: boolean): any;
  12786. /**
  12787. * Release resources
  12788. */
  12789. dispose(): void;
  12790. }
  12791. }
  12792. declare module BABYLON {
  12793. /**
  12794. * Enum used to define the material modes
  12795. */
  12796. export enum NodeMaterialModes {
  12797. /** Regular material */
  12798. Material = 0,
  12799. /** For post process */
  12800. PostProcess = 1,
  12801. /** For particle system */
  12802. Particle = 2,
  12803. /** For procedural texture */
  12804. ProceduralTexture = 3
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /** @hidden */
  12809. export var helperFunctions: {
  12810. name: string;
  12811. shader: string;
  12812. };
  12813. }
  12814. declare module BABYLON {
  12815. /**
  12816. * Block used to read a texture from a sampler
  12817. */
  12818. export class TextureBlock extends NodeMaterialBlock {
  12819. private _defineName;
  12820. private _linearDefineName;
  12821. private _gammaDefineName;
  12822. private _tempTextureRead;
  12823. private _samplerName;
  12824. private _transformedUVName;
  12825. private _textureTransformName;
  12826. private _textureInfoName;
  12827. private _mainUVName;
  12828. private _mainUVDefineName;
  12829. private _fragmentOnly;
  12830. /**
  12831. * Gets or sets the texture associated with the node
  12832. */
  12833. texture: Nullable<Texture>;
  12834. /**
  12835. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12836. */
  12837. convertToGammaSpace: boolean;
  12838. /**
  12839. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12840. */
  12841. convertToLinearSpace: boolean;
  12842. /**
  12843. * Create a new TextureBlock
  12844. * @param name defines the block name
  12845. */
  12846. constructor(name: string, fragmentOnly?: boolean);
  12847. /**
  12848. * Gets the current class name
  12849. * @returns the class name
  12850. */
  12851. getClassName(): string;
  12852. /**
  12853. * Gets the uv input component
  12854. */
  12855. get uv(): NodeMaterialConnectionPoint;
  12856. /**
  12857. * Gets the rgba output component
  12858. */
  12859. get rgba(): NodeMaterialConnectionPoint;
  12860. /**
  12861. * Gets the rgb output component
  12862. */
  12863. get rgb(): NodeMaterialConnectionPoint;
  12864. /**
  12865. * Gets the r output component
  12866. */
  12867. get r(): NodeMaterialConnectionPoint;
  12868. /**
  12869. * Gets the g output component
  12870. */
  12871. get g(): NodeMaterialConnectionPoint;
  12872. /**
  12873. * Gets the b output component
  12874. */
  12875. get b(): NodeMaterialConnectionPoint;
  12876. /**
  12877. * Gets the a output component
  12878. */
  12879. get a(): NodeMaterialConnectionPoint;
  12880. get target(): NodeMaterialBlockTargets;
  12881. autoConfigure(material: NodeMaterial): void;
  12882. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12884. isReady(): boolean;
  12885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12886. private get _isMixed();
  12887. private _injectVertexCode;
  12888. private _writeTextureRead;
  12889. private _writeOutput;
  12890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12891. protected _dumpPropertiesCode(): string;
  12892. serialize(): any;
  12893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12894. }
  12895. }
  12896. declare module BABYLON {
  12897. /** @hidden */
  12898. export var reflectionFunction: {
  12899. name: string;
  12900. shader: string;
  12901. };
  12902. }
  12903. declare module BABYLON {
  12904. /**
  12905. * Base block used to read a reflection texture from a sampler
  12906. */
  12907. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12908. /** @hidden */
  12909. _define3DName: string;
  12910. /** @hidden */
  12911. _defineCubicName: string;
  12912. /** @hidden */
  12913. _defineExplicitName: string;
  12914. /** @hidden */
  12915. _defineProjectionName: string;
  12916. /** @hidden */
  12917. _defineLocalCubicName: string;
  12918. /** @hidden */
  12919. _defineSphericalName: string;
  12920. /** @hidden */
  12921. _definePlanarName: string;
  12922. /** @hidden */
  12923. _defineEquirectangularName: string;
  12924. /** @hidden */
  12925. _defineMirroredEquirectangularFixedName: string;
  12926. /** @hidden */
  12927. _defineEquirectangularFixedName: string;
  12928. /** @hidden */
  12929. _defineSkyboxName: string;
  12930. /** @hidden */
  12931. _defineOppositeZ: string;
  12932. /** @hidden */
  12933. _cubeSamplerName: string;
  12934. /** @hidden */
  12935. _2DSamplerName: string;
  12936. protected _positionUVWName: string;
  12937. protected _directionWName: string;
  12938. protected _reflectionVectorName: string;
  12939. /** @hidden */
  12940. _reflectionCoordsName: string;
  12941. /** @hidden */
  12942. _reflectionMatrixName: string;
  12943. protected _reflectionColorName: string;
  12944. /**
  12945. * Gets or sets the texture associated with the node
  12946. */
  12947. texture: Nullable<BaseTexture>;
  12948. /**
  12949. * Create a new ReflectionTextureBaseBlock
  12950. * @param name defines the block name
  12951. */
  12952. constructor(name: string);
  12953. /**
  12954. * Gets the current class name
  12955. * @returns the class name
  12956. */
  12957. getClassName(): string;
  12958. /**
  12959. * Gets the world position input component
  12960. */
  12961. abstract get position(): NodeMaterialConnectionPoint;
  12962. /**
  12963. * Gets the world position input component
  12964. */
  12965. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12966. /**
  12967. * Gets the world normal input component
  12968. */
  12969. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12970. /**
  12971. * Gets the world input component
  12972. */
  12973. abstract get world(): NodeMaterialConnectionPoint;
  12974. /**
  12975. * Gets the camera (or eye) position component
  12976. */
  12977. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12978. /**
  12979. * Gets the view input component
  12980. */
  12981. abstract get view(): NodeMaterialConnectionPoint;
  12982. protected _getTexture(): Nullable<BaseTexture>;
  12983. autoConfigure(material: NodeMaterial): void;
  12984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12985. isReady(): boolean;
  12986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12987. /**
  12988. * Gets the code to inject in the vertex shader
  12989. * @param state current state of the node material building
  12990. * @returns the shader code
  12991. */
  12992. handleVertexSide(state: NodeMaterialBuildState): string;
  12993. /**
  12994. * Handles the inits for the fragment code path
  12995. * @param state node material build state
  12996. */
  12997. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12998. /**
  12999. * Generates the reflection coords code for the fragment code path
  13000. * @param worldNormalVarName name of the world normal variable
  13001. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13002. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13003. * @returns the shader code
  13004. */
  13005. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13006. /**
  13007. * Generates the reflection color code for the fragment code path
  13008. * @param lodVarName name of the lod variable
  13009. * @param swizzleLookupTexture swizzle to use for the final color variable
  13010. * @returns the shader code
  13011. */
  13012. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13013. /**
  13014. * Generates the code corresponding to the connected output points
  13015. * @param state node material build state
  13016. * @param varName name of the variable to output
  13017. * @returns the shader code
  13018. */
  13019. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13020. protected _buildBlock(state: NodeMaterialBuildState): this;
  13021. protected _dumpPropertiesCode(): string;
  13022. serialize(): any;
  13023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13024. }
  13025. }
  13026. declare module BABYLON {
  13027. /**
  13028. * Defines a connection point to be used for points with a custom object type
  13029. */
  13030. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13031. private _blockType;
  13032. private _blockName;
  13033. private _nameForCheking?;
  13034. /**
  13035. * Creates a new connection point
  13036. * @param name defines the connection point name
  13037. * @param ownerBlock defines the block hosting this connection point
  13038. * @param direction defines the direction of the connection point
  13039. */
  13040. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13041. /**
  13042. * Gets a number indicating if the current point can be connected to another point
  13043. * @param connectionPoint defines the other connection point
  13044. * @returns a number defining the compatibility state
  13045. */
  13046. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13047. /**
  13048. * Creates a block suitable to be used as an input for this input point.
  13049. * If null is returned, a block based on the point type will be created.
  13050. * @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
  13051. */
  13052. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Enum defining the type of properties that can be edited in the property pages in the NME
  13058. */
  13059. export enum PropertyTypeForEdition {
  13060. /** property is a boolean */
  13061. Boolean = 0,
  13062. /** property is a float */
  13063. Float = 1,
  13064. /** property is a Vector2 */
  13065. Vector2 = 2,
  13066. /** property is a list of values */
  13067. List = 3
  13068. }
  13069. /**
  13070. * Interface that defines an option in a variable of type list
  13071. */
  13072. export interface IEditablePropertyListOption {
  13073. /** label of the option */
  13074. "label": string;
  13075. /** value of the option */
  13076. "value": number;
  13077. }
  13078. /**
  13079. * Interface that defines the options available for an editable property
  13080. */
  13081. export interface IEditablePropertyOption {
  13082. /** min value */
  13083. "min"?: number;
  13084. /** max value */
  13085. "max"?: number;
  13086. /** notifiers: indicates which actions to take when the property is changed */
  13087. "notifiers"?: {
  13088. /** the material should be rebuilt */
  13089. "rebuild"?: boolean;
  13090. /** the preview should be updated */
  13091. "update"?: boolean;
  13092. };
  13093. /** list of the options for a variable of type list */
  13094. "options"?: IEditablePropertyListOption[];
  13095. }
  13096. /**
  13097. * Interface that describes an editable property
  13098. */
  13099. export interface IPropertyDescriptionForEdition {
  13100. /** name of the property */
  13101. "propertyName": string;
  13102. /** display name of the property */
  13103. "displayName": string;
  13104. /** type of the property */
  13105. "type": PropertyTypeForEdition;
  13106. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13107. "groupName": string;
  13108. /** options for the property */
  13109. "options": IEditablePropertyOption;
  13110. }
  13111. /**
  13112. * Decorator that flags a property in a node material block as being editable
  13113. */
  13114. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13115. }
  13116. declare module BABYLON {
  13117. /**
  13118. * Block used to implement the refraction part of the sub surface module of the PBR material
  13119. */
  13120. export class RefractionBlock extends NodeMaterialBlock {
  13121. /** @hidden */
  13122. _define3DName: string;
  13123. /** @hidden */
  13124. _refractionMatrixName: string;
  13125. /** @hidden */
  13126. _defineLODRefractionAlpha: string;
  13127. /** @hidden */
  13128. _defineLinearSpecularRefraction: string;
  13129. /** @hidden */
  13130. _defineOppositeZ: string;
  13131. /** @hidden */
  13132. _cubeSamplerName: string;
  13133. /** @hidden */
  13134. _2DSamplerName: string;
  13135. /** @hidden */
  13136. _vRefractionMicrosurfaceInfosName: string;
  13137. /** @hidden */
  13138. _vRefractionInfosName: string;
  13139. /** @hidden */
  13140. _vRefractionFilteringInfoName: string;
  13141. private _scene;
  13142. /**
  13143. * The properties below are set by the main PBR block prior to calling methods of this class.
  13144. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13145. * It's less burden on the user side in the editor part.
  13146. */
  13147. /** @hidden */
  13148. viewConnectionPoint: NodeMaterialConnectionPoint;
  13149. /** @hidden */
  13150. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13151. /**
  13152. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13153. * Materials half opaque for instance using refraction could benefit from this control.
  13154. */
  13155. linkRefractionWithTransparency: boolean;
  13156. /**
  13157. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13158. */
  13159. invertRefractionY: boolean;
  13160. /**
  13161. * Gets or sets the texture associated with the node
  13162. */
  13163. texture: Nullable<BaseTexture>;
  13164. /**
  13165. * Create a new RefractionBlock
  13166. * @param name defines the block name
  13167. */
  13168. constructor(name: string);
  13169. /**
  13170. * Gets the current class name
  13171. * @returns the class name
  13172. */
  13173. getClassName(): string;
  13174. /**
  13175. * Gets the intensity input component
  13176. */
  13177. get intensity(): NodeMaterialConnectionPoint;
  13178. /**
  13179. * Gets the tint at distance input component
  13180. */
  13181. get tintAtDistance(): NodeMaterialConnectionPoint;
  13182. /**
  13183. * Gets the view input component
  13184. */
  13185. get view(): NodeMaterialConnectionPoint;
  13186. /**
  13187. * Gets the refraction object output component
  13188. */
  13189. get refraction(): NodeMaterialConnectionPoint;
  13190. /**
  13191. * Returns true if the block has a texture
  13192. */
  13193. get hasTexture(): boolean;
  13194. protected _getTexture(): Nullable<BaseTexture>;
  13195. autoConfigure(material: NodeMaterial): void;
  13196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13197. isReady(): boolean;
  13198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13199. /**
  13200. * Gets the main code of the block (fragment side)
  13201. * @param state current state of the node material building
  13202. * @returns the shader code
  13203. */
  13204. getCode(state: NodeMaterialBuildState): string;
  13205. protected _buildBlock(state: NodeMaterialBuildState): this;
  13206. protected _dumpPropertiesCode(): string;
  13207. serialize(): any;
  13208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13209. }
  13210. }
  13211. declare module BABYLON {
  13212. /**
  13213. * Base block used as input for post process
  13214. */
  13215. export class CurrentScreenBlock extends NodeMaterialBlock {
  13216. private _samplerName;
  13217. private _linearDefineName;
  13218. private _gammaDefineName;
  13219. private _mainUVName;
  13220. private _tempTextureRead;
  13221. /**
  13222. * Gets or sets the texture associated with the node
  13223. */
  13224. texture: Nullable<BaseTexture>;
  13225. /**
  13226. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13227. */
  13228. convertToGammaSpace: boolean;
  13229. /**
  13230. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13231. */
  13232. convertToLinearSpace: boolean;
  13233. /**
  13234. * Create a new CurrentScreenBlock
  13235. * @param name defines the block name
  13236. */
  13237. constructor(name: string);
  13238. /**
  13239. * Gets the current class name
  13240. * @returns the class name
  13241. */
  13242. getClassName(): string;
  13243. /**
  13244. * Gets the uv input component
  13245. */
  13246. get uv(): NodeMaterialConnectionPoint;
  13247. /**
  13248. * Gets the rgba output component
  13249. */
  13250. get rgba(): NodeMaterialConnectionPoint;
  13251. /**
  13252. * Gets the rgb output component
  13253. */
  13254. get rgb(): NodeMaterialConnectionPoint;
  13255. /**
  13256. * Gets the r output component
  13257. */
  13258. get r(): NodeMaterialConnectionPoint;
  13259. /**
  13260. * Gets the g output component
  13261. */
  13262. get g(): NodeMaterialConnectionPoint;
  13263. /**
  13264. * Gets the b output component
  13265. */
  13266. get b(): NodeMaterialConnectionPoint;
  13267. /**
  13268. * Gets the a output component
  13269. */
  13270. get a(): NodeMaterialConnectionPoint;
  13271. /**
  13272. * Initialize the block and prepare the context for build
  13273. * @param state defines the state that will be used for the build
  13274. */
  13275. initialize(state: NodeMaterialBuildState): void;
  13276. get target(): NodeMaterialBlockTargets;
  13277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13278. isReady(): boolean;
  13279. private _injectVertexCode;
  13280. private _writeTextureRead;
  13281. private _writeOutput;
  13282. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13283. serialize(): any;
  13284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13285. }
  13286. }
  13287. declare module BABYLON {
  13288. /**
  13289. * Base block used for the particle texture
  13290. */
  13291. export class ParticleTextureBlock extends NodeMaterialBlock {
  13292. private _samplerName;
  13293. private _linearDefineName;
  13294. private _gammaDefineName;
  13295. private _tempTextureRead;
  13296. /**
  13297. * Gets or sets the texture associated with the node
  13298. */
  13299. texture: Nullable<BaseTexture>;
  13300. /**
  13301. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13302. */
  13303. convertToGammaSpace: boolean;
  13304. /**
  13305. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13306. */
  13307. convertToLinearSpace: boolean;
  13308. /**
  13309. * Create a new ParticleTextureBlock
  13310. * @param name defines the block name
  13311. */
  13312. constructor(name: string);
  13313. /**
  13314. * Gets the current class name
  13315. * @returns the class name
  13316. */
  13317. getClassName(): string;
  13318. /**
  13319. * Gets the uv input component
  13320. */
  13321. get uv(): NodeMaterialConnectionPoint;
  13322. /**
  13323. * Gets the rgba output component
  13324. */
  13325. get rgba(): NodeMaterialConnectionPoint;
  13326. /**
  13327. * Gets the rgb output component
  13328. */
  13329. get rgb(): NodeMaterialConnectionPoint;
  13330. /**
  13331. * Gets the r output component
  13332. */
  13333. get r(): NodeMaterialConnectionPoint;
  13334. /**
  13335. * Gets the g output component
  13336. */
  13337. get g(): NodeMaterialConnectionPoint;
  13338. /**
  13339. * Gets the b output component
  13340. */
  13341. get b(): NodeMaterialConnectionPoint;
  13342. /**
  13343. * Gets the a output component
  13344. */
  13345. get a(): NodeMaterialConnectionPoint;
  13346. /**
  13347. * Initialize the block and prepare the context for build
  13348. * @param state defines the state that will be used for the build
  13349. */
  13350. initialize(state: NodeMaterialBuildState): void;
  13351. autoConfigure(material: NodeMaterial): void;
  13352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13353. isReady(): boolean;
  13354. private _writeOutput;
  13355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13356. serialize(): any;
  13357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13358. }
  13359. }
  13360. declare module BABYLON {
  13361. /**
  13362. * Class used to store shared data between 2 NodeMaterialBuildState
  13363. */
  13364. export class NodeMaterialBuildStateSharedData {
  13365. /**
  13366. * Gets the list of emitted varyings
  13367. */
  13368. temps: string[];
  13369. /**
  13370. * Gets the list of emitted varyings
  13371. */
  13372. varyings: string[];
  13373. /**
  13374. * Gets the varying declaration string
  13375. */
  13376. varyingDeclaration: string;
  13377. /**
  13378. * Input blocks
  13379. */
  13380. inputBlocks: InputBlock[];
  13381. /**
  13382. * Input blocks
  13383. */
  13384. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13385. /**
  13386. * Bindable blocks (Blocks that need to set data to the effect)
  13387. */
  13388. bindableBlocks: NodeMaterialBlock[];
  13389. /**
  13390. * List of blocks that can provide a compilation fallback
  13391. */
  13392. blocksWithFallbacks: NodeMaterialBlock[];
  13393. /**
  13394. * List of blocks that can provide a define update
  13395. */
  13396. blocksWithDefines: NodeMaterialBlock[];
  13397. /**
  13398. * List of blocks that can provide a repeatable content
  13399. */
  13400. repeatableContentBlocks: NodeMaterialBlock[];
  13401. /**
  13402. * List of blocks that can provide a dynamic list of uniforms
  13403. */
  13404. dynamicUniformBlocks: NodeMaterialBlock[];
  13405. /**
  13406. * List of blocks that can block the isReady function for the material
  13407. */
  13408. blockingBlocks: NodeMaterialBlock[];
  13409. /**
  13410. * Gets the list of animated inputs
  13411. */
  13412. animatedInputs: InputBlock[];
  13413. /**
  13414. * Build Id used to avoid multiple recompilations
  13415. */
  13416. buildId: number;
  13417. /** List of emitted variables */
  13418. variableNames: {
  13419. [key: string]: number;
  13420. };
  13421. /** List of emitted defines */
  13422. defineNames: {
  13423. [key: string]: number;
  13424. };
  13425. /** Should emit comments? */
  13426. emitComments: boolean;
  13427. /** Emit build activity */
  13428. verbose: boolean;
  13429. /** Gets or sets the hosting scene */
  13430. scene: Scene;
  13431. /**
  13432. * Gets the compilation hints emitted at compilation time
  13433. */
  13434. hints: {
  13435. needWorldViewMatrix: boolean;
  13436. needWorldViewProjectionMatrix: boolean;
  13437. needAlphaBlending: boolean;
  13438. needAlphaTesting: boolean;
  13439. };
  13440. /**
  13441. * List of compilation checks
  13442. */
  13443. checks: {
  13444. emitVertex: boolean;
  13445. emitFragment: boolean;
  13446. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13447. };
  13448. /**
  13449. * Is vertex program allowed to be empty?
  13450. */
  13451. allowEmptyVertexProgram: boolean;
  13452. /** Creates a new shared data */
  13453. constructor();
  13454. /**
  13455. * Emits console errors and exceptions if there is a failing check
  13456. */
  13457. emitErrors(): void;
  13458. }
  13459. }
  13460. declare module BABYLON {
  13461. /**
  13462. * Class used to store node based material build state
  13463. */
  13464. export class NodeMaterialBuildState {
  13465. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13466. supportUniformBuffers: boolean;
  13467. /**
  13468. * Gets the list of emitted attributes
  13469. */
  13470. attributes: string[];
  13471. /**
  13472. * Gets the list of emitted uniforms
  13473. */
  13474. uniforms: string[];
  13475. /**
  13476. * Gets the list of emitted constants
  13477. */
  13478. constants: string[];
  13479. /**
  13480. * Gets the list of emitted samplers
  13481. */
  13482. samplers: string[];
  13483. /**
  13484. * Gets the list of emitted functions
  13485. */
  13486. functions: {
  13487. [key: string]: string;
  13488. };
  13489. /**
  13490. * Gets the list of emitted extensions
  13491. */
  13492. extensions: {
  13493. [key: string]: string;
  13494. };
  13495. /**
  13496. * Gets the target of the compilation state
  13497. */
  13498. target: NodeMaterialBlockTargets;
  13499. /**
  13500. * Gets the list of emitted counters
  13501. */
  13502. counters: {
  13503. [key: string]: number;
  13504. };
  13505. /**
  13506. * Shared data between multiple NodeMaterialBuildState instances
  13507. */
  13508. sharedData: NodeMaterialBuildStateSharedData;
  13509. /** @hidden */
  13510. _vertexState: NodeMaterialBuildState;
  13511. /** @hidden */
  13512. _attributeDeclaration: string;
  13513. /** @hidden */
  13514. _uniformDeclaration: string;
  13515. /** @hidden */
  13516. _constantDeclaration: string;
  13517. /** @hidden */
  13518. _samplerDeclaration: string;
  13519. /** @hidden */
  13520. _varyingTransfer: string;
  13521. /** @hidden */
  13522. _injectAtEnd: string;
  13523. private _repeatableContentAnchorIndex;
  13524. /** @hidden */
  13525. _builtCompilationString: string;
  13526. /**
  13527. * Gets the emitted compilation strings
  13528. */
  13529. compilationString: string;
  13530. /**
  13531. * Finalize the compilation strings
  13532. * @param state defines the current compilation state
  13533. */
  13534. finalize(state: NodeMaterialBuildState): void;
  13535. /** @hidden */
  13536. get _repeatableContentAnchor(): string;
  13537. /** @hidden */
  13538. _getFreeVariableName(prefix: string): string;
  13539. /** @hidden */
  13540. _getFreeDefineName(prefix: string): string;
  13541. /** @hidden */
  13542. _excludeVariableName(name: string): void;
  13543. /** @hidden */
  13544. _emit2DSampler(name: string): void;
  13545. /** @hidden */
  13546. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13547. /** @hidden */
  13548. _emitExtension(name: string, extension: string, define?: string): void;
  13549. /** @hidden */
  13550. _emitFunction(name: string, code: string, comments: string): void;
  13551. /** @hidden */
  13552. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13553. replaceStrings?: {
  13554. search: RegExp;
  13555. replace: string;
  13556. }[];
  13557. repeatKey?: string;
  13558. }): string;
  13559. /** @hidden */
  13560. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13561. repeatKey?: string;
  13562. removeAttributes?: boolean;
  13563. removeUniforms?: boolean;
  13564. removeVaryings?: boolean;
  13565. removeIfDef?: boolean;
  13566. replaceStrings?: {
  13567. search: RegExp;
  13568. replace: string;
  13569. }[];
  13570. }, storeKey?: string): void;
  13571. /** @hidden */
  13572. _registerTempVariable(name: string): boolean;
  13573. /** @hidden */
  13574. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13575. /** @hidden */
  13576. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13577. /** @hidden */
  13578. _emitFloat(value: number): string;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * Helper class used to generate session unique ID
  13584. */
  13585. export class UniqueIdGenerator {
  13586. private static _UniqueIdCounter;
  13587. /**
  13588. * Gets an unique (relatively to the current scene) Id
  13589. */
  13590. static get UniqueId(): number;
  13591. }
  13592. }
  13593. declare module BABYLON {
  13594. /**
  13595. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13596. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13597. */
  13598. export class EffectFallbacks implements IEffectFallbacks {
  13599. private _defines;
  13600. private _currentRank;
  13601. private _maxRank;
  13602. private _mesh;
  13603. /**
  13604. * Removes the fallback from the bound mesh.
  13605. */
  13606. unBindMesh(): void;
  13607. /**
  13608. * Adds a fallback on the specified property.
  13609. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13610. * @param define The name of the define in the shader
  13611. */
  13612. addFallback(rank: number, define: string): void;
  13613. /**
  13614. * Sets the mesh to use CPU skinning when needing to fallback.
  13615. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13616. * @param mesh The mesh to use the fallbacks.
  13617. */
  13618. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13619. /**
  13620. * Checks to see if more fallbacks are still available.
  13621. */
  13622. get hasMoreFallbacks(): boolean;
  13623. /**
  13624. * Removes the defines that should be removed when falling back.
  13625. * @param currentDefines defines the current define statements for the shader.
  13626. * @param effect defines the current effect we try to compile
  13627. * @returns The resulting defines with defines of the current rank removed.
  13628. */
  13629. reduce(currentDefines: string, effect: Effect): string;
  13630. }
  13631. }
  13632. declare module BABYLON {
  13633. /**
  13634. * Defines a block that can be used inside a node based material
  13635. */
  13636. export class NodeMaterialBlock {
  13637. private _buildId;
  13638. private _buildTarget;
  13639. private _target;
  13640. private _isFinalMerger;
  13641. private _isInput;
  13642. private _name;
  13643. protected _isUnique: boolean;
  13644. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13645. inputsAreExclusive: boolean;
  13646. /** @hidden */
  13647. _codeVariableName: string;
  13648. /** @hidden */
  13649. _inputs: NodeMaterialConnectionPoint[];
  13650. /** @hidden */
  13651. _outputs: NodeMaterialConnectionPoint[];
  13652. /** @hidden */
  13653. _preparationId: number;
  13654. /** @hidden */
  13655. readonly _originalTargetIsNeutral: boolean;
  13656. /**
  13657. * Gets the name of the block
  13658. */
  13659. get name(): string;
  13660. /**
  13661. * Sets the name of the block. Will check if the name is valid.
  13662. */
  13663. set name(newName: string);
  13664. /**
  13665. * Gets or sets the unique id of the node
  13666. */
  13667. uniqueId: number;
  13668. /**
  13669. * Gets or sets the comments associated with this block
  13670. */
  13671. comments: string;
  13672. /**
  13673. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13674. */
  13675. get isUnique(): boolean;
  13676. /**
  13677. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13678. */
  13679. get isFinalMerger(): boolean;
  13680. /**
  13681. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13682. */
  13683. get isInput(): boolean;
  13684. /**
  13685. * Gets or sets the build Id
  13686. */
  13687. get buildId(): number;
  13688. set buildId(value: number);
  13689. /**
  13690. * Gets or sets the target of the block
  13691. */
  13692. get target(): NodeMaterialBlockTargets;
  13693. set target(value: NodeMaterialBlockTargets);
  13694. /**
  13695. * Gets the list of input points
  13696. */
  13697. get inputs(): NodeMaterialConnectionPoint[];
  13698. /** Gets the list of output points */
  13699. get outputs(): NodeMaterialConnectionPoint[];
  13700. /**
  13701. * Find an input by its name
  13702. * @param name defines the name of the input to look for
  13703. * @returns the input or null if not found
  13704. */
  13705. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13706. /**
  13707. * Find an output by its name
  13708. * @param name defines the name of the output to look for
  13709. * @returns the output or null if not found
  13710. */
  13711. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13712. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13713. visibleInInspector: boolean;
  13714. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13715. visibleOnFrame: boolean;
  13716. /**
  13717. * Creates a new NodeMaterialBlock
  13718. * @param name defines the block name
  13719. * @param target defines the target of that block (Vertex by default)
  13720. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13721. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13722. */
  13723. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13724. /**
  13725. * Initialize the block and prepare the context for build
  13726. * @param state defines the state that will be used for the build
  13727. */
  13728. initialize(state: NodeMaterialBuildState): void;
  13729. /**
  13730. * Bind data to effect. Will only be called for blocks with isBindable === true
  13731. * @param effect defines the effect to bind data to
  13732. * @param nodeMaterial defines the hosting NodeMaterial
  13733. * @param mesh defines the mesh that will be rendered
  13734. * @param subMesh defines the submesh that will be rendered
  13735. */
  13736. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13737. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13738. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13739. protected _writeFloat(value: number): string;
  13740. /**
  13741. * Gets the current class name e.g. "NodeMaterialBlock"
  13742. * @returns the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Register a new input. Must be called inside a block constructor
  13747. * @param name defines the connection point name
  13748. * @param type defines the connection point type
  13749. * @param isOptional defines a boolean indicating that this input can be omitted
  13750. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13751. * @param point an already created connection point. If not provided, create a new one
  13752. * @returns the current block
  13753. */
  13754. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13755. /**
  13756. * Register a new output. Must be called inside a block constructor
  13757. * @param name defines the connection point name
  13758. * @param type defines the connection point type
  13759. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13760. * @param point an already created connection point. If not provided, create a new one
  13761. * @returns the current block
  13762. */
  13763. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13764. /**
  13765. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13766. * @param forOutput defines an optional connection point to check compatibility with
  13767. * @returns the first available input or null
  13768. */
  13769. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13770. /**
  13771. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13772. * @param forBlock defines an optional block to check compatibility with
  13773. * @returns the first available input or null
  13774. */
  13775. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13776. /**
  13777. * Gets the sibling of the given output
  13778. * @param current defines the current output
  13779. * @returns the next output in the list or null
  13780. */
  13781. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13782. /**
  13783. * Connect current block with another block
  13784. * @param other defines the block to connect with
  13785. * @param options define the various options to help pick the right connections
  13786. * @returns the current block
  13787. */
  13788. connectTo(other: NodeMaterialBlock, options?: {
  13789. input?: string;
  13790. output?: string;
  13791. outputSwizzle?: string;
  13792. }): this | undefined;
  13793. protected _buildBlock(state: NodeMaterialBuildState): void;
  13794. /**
  13795. * Add uniforms, samplers and uniform buffers at compilation time
  13796. * @param state defines the state to update
  13797. * @param nodeMaterial defines the node material requesting the update
  13798. * @param defines defines the material defines to update
  13799. * @param uniformBuffers defines the list of uniform buffer names
  13800. */
  13801. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13802. /**
  13803. * Add potential fallbacks if shader compilation fails
  13804. * @param mesh defines the mesh to be rendered
  13805. * @param fallbacks defines the current prioritized list of fallbacks
  13806. */
  13807. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13808. /**
  13809. * Initialize defines for shader compilation
  13810. * @param mesh defines the mesh to be rendered
  13811. * @param nodeMaterial defines the node material requesting the update
  13812. * @param defines defines the material defines to update
  13813. * @param useInstances specifies that instances should be used
  13814. */
  13815. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13816. /**
  13817. * Update defines for shader compilation
  13818. * @param mesh defines the mesh to be rendered
  13819. * @param nodeMaterial defines the node material requesting the update
  13820. * @param defines defines the material defines to update
  13821. * @param useInstances specifies that instances should be used
  13822. * @param subMesh defines which submesh to render
  13823. */
  13824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13825. /**
  13826. * Lets the block try to connect some inputs automatically
  13827. * @param material defines the hosting NodeMaterial
  13828. */
  13829. autoConfigure(material: NodeMaterial): void;
  13830. /**
  13831. * Function called when a block is declared as repeatable content generator
  13832. * @param vertexShaderState defines the current compilation state for the vertex shader
  13833. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13834. * @param mesh defines the mesh to be rendered
  13835. * @param defines defines the material defines to update
  13836. */
  13837. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13838. /**
  13839. * Checks if the block is ready
  13840. * @param mesh defines the mesh to be rendered
  13841. * @param nodeMaterial defines the node material requesting the update
  13842. * @param defines defines the material defines to update
  13843. * @param useInstances specifies that instances should be used
  13844. * @returns true if the block is ready
  13845. */
  13846. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13847. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13848. private _processBuild;
  13849. /**
  13850. * Validates the new name for the block node.
  13851. * @param newName the new name to be given to the node.
  13852. * @returns false if the name is a reserve word, else true.
  13853. */
  13854. validateBlockName(newName: string): boolean;
  13855. /**
  13856. * Compile the current node and generate the shader code
  13857. * @param state defines the current compilation state (uniforms, samplers, current string)
  13858. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13859. * @returns true if already built
  13860. */
  13861. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13862. protected _inputRename(name: string): string;
  13863. protected _outputRename(name: string): string;
  13864. protected _dumpPropertiesCode(): string;
  13865. /** @hidden */
  13866. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13867. /** @hidden */
  13868. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13869. /**
  13870. * Clone the current block to a new identical block
  13871. * @param scene defines the hosting scene
  13872. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13873. * @returns a copy of the current block
  13874. */
  13875. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13876. /**
  13877. * Serializes this block in a JSON representation
  13878. * @returns the serialized block object
  13879. */
  13880. serialize(): any;
  13881. /** @hidden */
  13882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13883. private _deserializePortDisplayNamesAndExposedOnFrame;
  13884. /**
  13885. * Release resources
  13886. */
  13887. dispose(): void;
  13888. }
  13889. }
  13890. declare module BABYLON {
  13891. /**
  13892. * Base class of materials working in push mode in babylon JS
  13893. * @hidden
  13894. */
  13895. export class PushMaterial extends Material {
  13896. protected _activeEffect: Effect;
  13897. protected _normalMatrix: Matrix;
  13898. constructor(name: string, scene: Scene);
  13899. getEffect(): Effect;
  13900. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13901. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13902. /**
  13903. * Binds the given world matrix to the active effect
  13904. *
  13905. * @param world the matrix to bind
  13906. */
  13907. bindOnlyWorldMatrix(world: Matrix): void;
  13908. /**
  13909. * Binds the given normal matrix to the active effect
  13910. *
  13911. * @param normalMatrix the matrix to bind
  13912. */
  13913. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13914. bind(world: Matrix, mesh?: Mesh): void;
  13915. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13916. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13917. }
  13918. }
  13919. declare module BABYLON {
  13920. /**
  13921. * Root class for all node material optimizers
  13922. */
  13923. export class NodeMaterialOptimizer {
  13924. /**
  13925. * Function used to optimize a NodeMaterial graph
  13926. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13927. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13928. */
  13929. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13930. }
  13931. }
  13932. declare module BABYLON {
  13933. /**
  13934. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13935. */
  13936. export class TransformBlock extends NodeMaterialBlock {
  13937. /**
  13938. * Defines the value to use to complement W value to transform it to a Vector4
  13939. */
  13940. complementW: number;
  13941. /**
  13942. * Defines the value to use to complement z value to transform it to a Vector4
  13943. */
  13944. complementZ: number;
  13945. /**
  13946. * Creates a new TransformBlock
  13947. * @param name defines the block name
  13948. */
  13949. constructor(name: string);
  13950. /**
  13951. * Gets the current class name
  13952. * @returns the class name
  13953. */
  13954. getClassName(): string;
  13955. /**
  13956. * Gets the vector input
  13957. */
  13958. get vector(): NodeMaterialConnectionPoint;
  13959. /**
  13960. * Gets the output component
  13961. */
  13962. get output(): NodeMaterialConnectionPoint;
  13963. /**
  13964. * Gets the xyz output component
  13965. */
  13966. get xyz(): NodeMaterialConnectionPoint;
  13967. /**
  13968. * Gets the matrix transform input
  13969. */
  13970. get transform(): NodeMaterialConnectionPoint;
  13971. protected _buildBlock(state: NodeMaterialBuildState): this;
  13972. /**
  13973. * Update defines for shader compilation
  13974. * @param mesh defines the mesh to be rendered
  13975. * @param nodeMaterial defines the node material requesting the update
  13976. * @param defines defines the material defines to update
  13977. * @param useInstances specifies that instances should be used
  13978. * @param subMesh defines which submesh to render
  13979. */
  13980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13981. serialize(): any;
  13982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13983. protected _dumpPropertiesCode(): string;
  13984. }
  13985. }
  13986. declare module BABYLON {
  13987. /**
  13988. * Block used to output the vertex position
  13989. */
  13990. export class VertexOutputBlock extends NodeMaterialBlock {
  13991. /**
  13992. * Creates a new VertexOutputBlock
  13993. * @param name defines the block name
  13994. */
  13995. constructor(name: string);
  13996. /**
  13997. * Gets the current class name
  13998. * @returns the class name
  13999. */
  14000. getClassName(): string;
  14001. /**
  14002. * Gets the vector input component
  14003. */
  14004. get vector(): NodeMaterialConnectionPoint;
  14005. protected _buildBlock(state: NodeMaterialBuildState): this;
  14006. }
  14007. }
  14008. declare module BABYLON {
  14009. /**
  14010. * Block used to output the final color
  14011. */
  14012. export class FragmentOutputBlock extends NodeMaterialBlock {
  14013. /**
  14014. * Create a new FragmentOutputBlock
  14015. * @param name defines the block name
  14016. */
  14017. constructor(name: string);
  14018. /**
  14019. * Gets the current class name
  14020. * @returns the class name
  14021. */
  14022. getClassName(): string;
  14023. /**
  14024. * Gets the rgba input component
  14025. */
  14026. get rgba(): NodeMaterialConnectionPoint;
  14027. /**
  14028. * Gets the rgb input component
  14029. */
  14030. get rgb(): NodeMaterialConnectionPoint;
  14031. /**
  14032. * Gets the a input component
  14033. */
  14034. get a(): NodeMaterialConnectionPoint;
  14035. protected _buildBlock(state: NodeMaterialBuildState): this;
  14036. }
  14037. }
  14038. declare module BABYLON {
  14039. /**
  14040. * Block used for the particle ramp gradient section
  14041. */
  14042. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14043. /**
  14044. * Create a new ParticleRampGradientBlock
  14045. * @param name defines the block name
  14046. */
  14047. constructor(name: string);
  14048. /**
  14049. * Gets the current class name
  14050. * @returns the class name
  14051. */
  14052. getClassName(): string;
  14053. /**
  14054. * Gets the color input component
  14055. */
  14056. get color(): NodeMaterialConnectionPoint;
  14057. /**
  14058. * Gets the rampColor output component
  14059. */
  14060. get rampColor(): NodeMaterialConnectionPoint;
  14061. /**
  14062. * Initialize the block and prepare the context for build
  14063. * @param state defines the state that will be used for the build
  14064. */
  14065. initialize(state: NodeMaterialBuildState): void;
  14066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14067. }
  14068. }
  14069. declare module BABYLON {
  14070. /**
  14071. * Block used for the particle blend multiply section
  14072. */
  14073. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14074. /**
  14075. * Create a new ParticleBlendMultiplyBlock
  14076. * @param name defines the block name
  14077. */
  14078. constructor(name: string);
  14079. /**
  14080. * Gets the current class name
  14081. * @returns the class name
  14082. */
  14083. getClassName(): string;
  14084. /**
  14085. * Gets the color input component
  14086. */
  14087. get color(): NodeMaterialConnectionPoint;
  14088. /**
  14089. * Gets the alphaTexture input component
  14090. */
  14091. get alphaTexture(): NodeMaterialConnectionPoint;
  14092. /**
  14093. * Gets the alphaColor input component
  14094. */
  14095. get alphaColor(): NodeMaterialConnectionPoint;
  14096. /**
  14097. * Gets the blendColor output component
  14098. */
  14099. get blendColor(): NodeMaterialConnectionPoint;
  14100. /**
  14101. * Initialize the block and prepare the context for build
  14102. * @param state defines the state that will be used for the build
  14103. */
  14104. initialize(state: NodeMaterialBuildState): void;
  14105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14106. }
  14107. }
  14108. declare module BABYLON {
  14109. /**
  14110. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14111. */
  14112. export class VectorMergerBlock extends NodeMaterialBlock {
  14113. /**
  14114. * Create a new VectorMergerBlock
  14115. * @param name defines the block name
  14116. */
  14117. constructor(name: string);
  14118. /**
  14119. * Gets the current class name
  14120. * @returns the class name
  14121. */
  14122. getClassName(): string;
  14123. /**
  14124. * Gets the xyz component (input)
  14125. */
  14126. get xyzIn(): NodeMaterialConnectionPoint;
  14127. /**
  14128. * Gets the xy component (input)
  14129. */
  14130. get xyIn(): NodeMaterialConnectionPoint;
  14131. /**
  14132. * Gets the x component (input)
  14133. */
  14134. get x(): NodeMaterialConnectionPoint;
  14135. /**
  14136. * Gets the y component (input)
  14137. */
  14138. get y(): NodeMaterialConnectionPoint;
  14139. /**
  14140. * Gets the z component (input)
  14141. */
  14142. get z(): NodeMaterialConnectionPoint;
  14143. /**
  14144. * Gets the w component (input)
  14145. */
  14146. get w(): NodeMaterialConnectionPoint;
  14147. /**
  14148. * Gets the xyzw component (output)
  14149. */
  14150. get xyzw(): NodeMaterialConnectionPoint;
  14151. /**
  14152. * Gets the xyz component (output)
  14153. */
  14154. get xyzOut(): NodeMaterialConnectionPoint;
  14155. /**
  14156. * Gets the xy component (output)
  14157. */
  14158. get xyOut(): NodeMaterialConnectionPoint;
  14159. /**
  14160. * Gets the xy component (output)
  14161. * @deprecated Please use xyOut instead.
  14162. */
  14163. get xy(): NodeMaterialConnectionPoint;
  14164. /**
  14165. * Gets the xyz component (output)
  14166. * @deprecated Please use xyzOut instead.
  14167. */
  14168. get xyz(): NodeMaterialConnectionPoint;
  14169. protected _buildBlock(state: NodeMaterialBuildState): this;
  14170. }
  14171. }
  14172. declare module BABYLON {
  14173. /**
  14174. * Block used to remap a float from a range to a new one
  14175. */
  14176. export class RemapBlock extends NodeMaterialBlock {
  14177. /**
  14178. * Gets or sets the source range
  14179. */
  14180. sourceRange: Vector2;
  14181. /**
  14182. * Gets or sets the target range
  14183. */
  14184. targetRange: Vector2;
  14185. /**
  14186. * Creates a new RemapBlock
  14187. * @param name defines the block name
  14188. */
  14189. constructor(name: string);
  14190. /**
  14191. * Gets the current class name
  14192. * @returns the class name
  14193. */
  14194. getClassName(): string;
  14195. /**
  14196. * Gets the input component
  14197. */
  14198. get input(): NodeMaterialConnectionPoint;
  14199. /**
  14200. * Gets the source min input component
  14201. */
  14202. get sourceMin(): NodeMaterialConnectionPoint;
  14203. /**
  14204. * Gets the source max input component
  14205. */
  14206. get sourceMax(): NodeMaterialConnectionPoint;
  14207. /**
  14208. * Gets the target min input component
  14209. */
  14210. get targetMin(): NodeMaterialConnectionPoint;
  14211. /**
  14212. * Gets the target max input component
  14213. */
  14214. get targetMax(): NodeMaterialConnectionPoint;
  14215. /**
  14216. * Gets the output component
  14217. */
  14218. get output(): NodeMaterialConnectionPoint;
  14219. protected _buildBlock(state: NodeMaterialBuildState): this;
  14220. protected _dumpPropertiesCode(): string;
  14221. serialize(): any;
  14222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14223. }
  14224. }
  14225. declare module BABYLON {
  14226. /**
  14227. * Block used to multiply 2 values
  14228. */
  14229. export class MultiplyBlock extends NodeMaterialBlock {
  14230. /**
  14231. * Creates a new MultiplyBlock
  14232. * @param name defines the block name
  14233. */
  14234. constructor(name: string);
  14235. /**
  14236. * Gets the current class name
  14237. * @returns the class name
  14238. */
  14239. getClassName(): string;
  14240. /**
  14241. * Gets the left operand input component
  14242. */
  14243. get left(): NodeMaterialConnectionPoint;
  14244. /**
  14245. * Gets the right operand input component
  14246. */
  14247. get right(): NodeMaterialConnectionPoint;
  14248. /**
  14249. * Gets the output component
  14250. */
  14251. get output(): NodeMaterialConnectionPoint;
  14252. protected _buildBlock(state: NodeMaterialBuildState): this;
  14253. }
  14254. }
  14255. declare module BABYLON {
  14256. /** Interface used by value gradients (color, factor, ...) */
  14257. export interface IValueGradient {
  14258. /**
  14259. * Gets or sets the gradient value (between 0 and 1)
  14260. */
  14261. gradient: number;
  14262. }
  14263. /** Class used to store color4 gradient */
  14264. export class ColorGradient implements IValueGradient {
  14265. /**
  14266. * Gets or sets the gradient value (between 0 and 1)
  14267. */
  14268. gradient: number;
  14269. /**
  14270. * Gets or sets first associated color
  14271. */
  14272. color1: Color4;
  14273. /**
  14274. * Gets or sets second associated color
  14275. */
  14276. color2?: Color4 | undefined;
  14277. /**
  14278. * Creates a new color4 gradient
  14279. * @param gradient gets or sets the gradient value (between 0 and 1)
  14280. * @param color1 gets or sets first associated color
  14281. * @param color2 gets or sets first second color
  14282. */
  14283. constructor(
  14284. /**
  14285. * Gets or sets the gradient value (between 0 and 1)
  14286. */
  14287. gradient: number,
  14288. /**
  14289. * Gets or sets first associated color
  14290. */
  14291. color1: Color4,
  14292. /**
  14293. * Gets or sets second associated color
  14294. */
  14295. color2?: Color4 | undefined);
  14296. /**
  14297. * Will get a color picked randomly between color1 and color2.
  14298. * If color2 is undefined then color1 will be used
  14299. * @param result defines the target Color4 to store the result in
  14300. */
  14301. getColorToRef(result: Color4): void;
  14302. }
  14303. /** Class used to store color 3 gradient */
  14304. export class Color3Gradient implements IValueGradient {
  14305. /**
  14306. * Gets or sets the gradient value (between 0 and 1)
  14307. */
  14308. gradient: number;
  14309. /**
  14310. * Gets or sets the associated color
  14311. */
  14312. color: Color3;
  14313. /**
  14314. * Creates a new color3 gradient
  14315. * @param gradient gets or sets the gradient value (between 0 and 1)
  14316. * @param color gets or sets associated color
  14317. */
  14318. constructor(
  14319. /**
  14320. * Gets or sets the gradient value (between 0 and 1)
  14321. */
  14322. gradient: number,
  14323. /**
  14324. * Gets or sets the associated color
  14325. */
  14326. color: Color3);
  14327. }
  14328. /** Class used to store factor gradient */
  14329. export class FactorGradient implements IValueGradient {
  14330. /**
  14331. * Gets or sets the gradient value (between 0 and 1)
  14332. */
  14333. gradient: number;
  14334. /**
  14335. * Gets or sets first associated factor
  14336. */
  14337. factor1: number;
  14338. /**
  14339. * Gets or sets second associated factor
  14340. */
  14341. factor2?: number | undefined;
  14342. /**
  14343. * Creates a new factor gradient
  14344. * @param gradient gets or sets the gradient value (between 0 and 1)
  14345. * @param factor1 gets or sets first associated factor
  14346. * @param factor2 gets or sets second associated factor
  14347. */
  14348. constructor(
  14349. /**
  14350. * Gets or sets the gradient value (between 0 and 1)
  14351. */
  14352. gradient: number,
  14353. /**
  14354. * Gets or sets first associated factor
  14355. */
  14356. factor1: number,
  14357. /**
  14358. * Gets or sets second associated factor
  14359. */
  14360. factor2?: number | undefined);
  14361. /**
  14362. * Will get a number picked randomly between factor1 and factor2.
  14363. * If factor2 is undefined then factor1 will be used
  14364. * @returns the picked number
  14365. */
  14366. getFactor(): number;
  14367. }
  14368. /**
  14369. * Helper used to simplify some generic gradient tasks
  14370. */
  14371. export class GradientHelper {
  14372. /**
  14373. * Gets the current gradient from an array of IValueGradient
  14374. * @param ratio defines the current ratio to get
  14375. * @param gradients defines the array of IValueGradient
  14376. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14377. */
  14378. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14379. }
  14380. }
  14381. declare module BABYLON {
  14382. interface ThinEngine {
  14383. /**
  14384. * Creates a raw texture
  14385. * @param data defines the data to store in the texture
  14386. * @param width defines the width of the texture
  14387. * @param height defines the height of the texture
  14388. * @param format defines the format of the data
  14389. * @param generateMipMaps defines if the engine should generate the mip levels
  14390. * @param invertY defines if data must be stored with Y axis inverted
  14391. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14392. * @param compression defines the compression used (null by default)
  14393. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14394. * @returns the raw texture inside an InternalTexture
  14395. */
  14396. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14397. /**
  14398. * Update a raw texture
  14399. * @param texture defines the texture to update
  14400. * @param data defines the data to store in the texture
  14401. * @param format defines the format of the data
  14402. * @param invertY defines if data must be stored with Y axis inverted
  14403. */
  14404. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14405. /**
  14406. * Update a raw texture
  14407. * @param texture defines the texture to update
  14408. * @param data defines the data to store in the texture
  14409. * @param format defines the format of the data
  14410. * @param invertY defines if data must be stored with Y axis inverted
  14411. * @param compression defines the compression used (null by default)
  14412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14413. */
  14414. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14415. /**
  14416. * Creates a new raw cube texture
  14417. * @param data defines the array of data to use to create each face
  14418. * @param size defines the size of the textures
  14419. * @param format defines the format of the data
  14420. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14421. * @param generateMipMaps defines if the engine should generate the mip levels
  14422. * @param invertY defines if data must be stored with Y axis inverted
  14423. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14424. * @param compression defines the compression used (null by default)
  14425. * @returns the cube texture as an InternalTexture
  14426. */
  14427. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14428. /**
  14429. * Update a raw cube texture
  14430. * @param texture defines the texture to update
  14431. * @param data defines the data to store
  14432. * @param format defines the data format
  14433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14434. * @param invertY defines if data must be stored with Y axis inverted
  14435. */
  14436. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14437. /**
  14438. * Update a raw cube texture
  14439. * @param texture defines the texture to update
  14440. * @param data defines the data to store
  14441. * @param format defines the data format
  14442. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14443. * @param invertY defines if data must be stored with Y axis inverted
  14444. * @param compression defines the compression used (null by default)
  14445. */
  14446. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14447. /**
  14448. * Update a raw cube texture
  14449. * @param texture defines the texture to update
  14450. * @param data defines the data to store
  14451. * @param format defines the data format
  14452. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14453. * @param invertY defines if data must be stored with Y axis inverted
  14454. * @param compression defines the compression used (null by default)
  14455. * @param level defines which level of the texture to update
  14456. */
  14457. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14458. /**
  14459. * Creates a new raw cube texture from a specified url
  14460. * @param url defines the url where the data is located
  14461. * @param scene defines the current scene
  14462. * @param size defines the size of the textures
  14463. * @param format defines the format of the data
  14464. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14465. * @param noMipmap defines if the engine should avoid generating the mip levels
  14466. * @param callback defines a callback used to extract texture data from loaded data
  14467. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14468. * @param onLoad defines a callback called when texture is loaded
  14469. * @param onError defines a callback called if there is an error
  14470. * @returns the cube texture as an InternalTexture
  14471. */
  14472. 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;
  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. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14486. * @param invertY defines if data must be stored with Y axis inverted
  14487. * @returns the cube texture as an InternalTexture
  14488. */
  14489. 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;
  14490. /**
  14491. * Creates a new raw 3D texture
  14492. * @param data defines the data used to create the texture
  14493. * @param width defines the width of the texture
  14494. * @param height defines the height of the texture
  14495. * @param depth defines the depth of the texture
  14496. * @param format defines the format of the texture
  14497. * @param generateMipMaps defines if the engine must generate mip levels
  14498. * @param invertY defines if data must be stored with Y axis inverted
  14499. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14500. * @param compression defines the compressed used (can be null)
  14501. * @param textureType defines the compressed used (can be null)
  14502. * @returns a new raw 3D texture (stored in an InternalTexture)
  14503. */
  14504. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14505. /**
  14506. * Update a raw 3D texture
  14507. * @param texture defines the texture to update
  14508. * @param data defines the data to store
  14509. * @param format defines the data format
  14510. * @param invertY defines if data must be stored with Y axis inverted
  14511. */
  14512. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14513. /**
  14514. * Update a raw 3D texture
  14515. * @param texture defines the texture to update
  14516. * @param data defines the data to store
  14517. * @param format defines the data format
  14518. * @param invertY defines if data must be stored with Y axis inverted
  14519. * @param compression defines the used compression (can be null)
  14520. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14521. */
  14522. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14523. /**
  14524. * Creates a new raw 2D array texture
  14525. * @param data defines the data used to create the texture
  14526. * @param width defines the width of the texture
  14527. * @param height defines the height of the texture
  14528. * @param depth defines the number of layers of the texture
  14529. * @param format defines the format of the texture
  14530. * @param generateMipMaps defines if the engine must generate mip levels
  14531. * @param invertY defines if data must be stored with Y axis inverted
  14532. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14533. * @param compression defines the compressed used (can be null)
  14534. * @param textureType defines the compressed used (can be null)
  14535. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14536. */
  14537. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14538. /**
  14539. * Update a raw 2D array texture
  14540. * @param texture defines the texture to update
  14541. * @param data defines the data to store
  14542. * @param format defines the data format
  14543. * @param invertY defines if data must be stored with Y axis inverted
  14544. */
  14545. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14546. /**
  14547. * Update a raw 2D array texture
  14548. * @param texture defines the texture to update
  14549. * @param data defines the data to store
  14550. * @param format defines the data format
  14551. * @param invertY defines if data must be stored with Y axis inverted
  14552. * @param compression defines the used compression (can be null)
  14553. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14554. */
  14555. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14556. }
  14557. }
  14558. declare module BABYLON {
  14559. /**
  14560. * Raw texture can help creating a texture directly from an array of data.
  14561. * This can be super useful if you either get the data from an uncompressed source or
  14562. * if you wish to create your texture pixel by pixel.
  14563. */
  14564. export class RawTexture extends Texture {
  14565. /**
  14566. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14567. */
  14568. format: number;
  14569. /**
  14570. * Instantiates a new RawTexture.
  14571. * Raw texture can help creating a texture directly from an array of data.
  14572. * This can be super useful if you either get the data from an uncompressed source or
  14573. * if you wish to create your texture pixel by pixel.
  14574. * @param data define the array of data to use to create the texture
  14575. * @param width define the width of the texture
  14576. * @param height define the height of the texture
  14577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14578. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14579. * @param generateMipMaps define whether mip maps should be generated or not
  14580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14583. */
  14584. constructor(data: ArrayBufferView, width: number, height: number,
  14585. /**
  14586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14587. */
  14588. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14589. /**
  14590. * Updates the texture underlying data.
  14591. * @param data Define the new data of the texture
  14592. */
  14593. update(data: ArrayBufferView): void;
  14594. /**
  14595. * Creates a luminance texture from some data.
  14596. * @param data Define the texture data
  14597. * @param width Define the width of the texture
  14598. * @param height Define the height of the texture
  14599. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14603. * @returns the luminance texture
  14604. */
  14605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14606. /**
  14607. * Creates a luminance alpha texture from some data.
  14608. * @param data Define the texture data
  14609. * @param width Define the width of the texture
  14610. * @param height Define the height of the texture
  14611. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14615. * @returns the luminance alpha texture
  14616. */
  14617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14618. /**
  14619. * Creates an alpha texture from some data.
  14620. * @param data Define the texture data
  14621. * @param width Define the width of the texture
  14622. * @param height Define the height of the texture
  14623. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14627. * @returns the alpha texture
  14628. */
  14629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14630. /**
  14631. * Creates a RGB texture from some data.
  14632. * @param data Define the texture data
  14633. * @param width Define the width of the texture
  14634. * @param height Define the height of the texture
  14635. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14640. * @returns the RGB alpha texture
  14641. */
  14642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14643. /**
  14644. * Creates a RGBA texture from some data.
  14645. * @param data Define the texture data
  14646. * @param width Define the width of the texture
  14647. * @param height Define the height of the texture
  14648. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14653. * @returns the RGBA texture
  14654. */
  14655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14656. /**
  14657. * Creates a R texture from some data.
  14658. * @param data Define the texture data
  14659. * @param width Define the width of the texture
  14660. * @param height Define the height of the texture
  14661. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14666. * @returns the R texture
  14667. */
  14668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. interface ThinEngine {
  14673. /**
  14674. * Update a dynamic index buffer
  14675. * @param indexBuffer defines the target index buffer
  14676. * @param indices defines the data to update
  14677. * @param offset defines the offset in the target index buffer where update should start
  14678. */
  14679. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14680. /**
  14681. * Updates a dynamic vertex buffer.
  14682. * @param vertexBuffer the vertex buffer to update
  14683. * @param data the data used to update the vertex buffer
  14684. * @param byteOffset the byte offset of the data
  14685. * @param byteLength the byte length of the data
  14686. */
  14687. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14688. }
  14689. }
  14690. declare module BABYLON {
  14691. interface AbstractScene {
  14692. /**
  14693. * The list of procedural textures added to the scene
  14694. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14695. */
  14696. proceduralTextures: Array<ProceduralTexture>;
  14697. }
  14698. /**
  14699. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14700. * in a given scene.
  14701. */
  14702. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14703. /**
  14704. * The component name helpful to identify the component in the list of scene components.
  14705. */
  14706. readonly name: string;
  14707. /**
  14708. * The scene the component belongs to.
  14709. */
  14710. scene: Scene;
  14711. /**
  14712. * Creates a new instance of the component for the given scene
  14713. * @param scene Defines the scene to register the component in
  14714. */
  14715. constructor(scene: Scene);
  14716. /**
  14717. * Registers the component in a given scene
  14718. */
  14719. register(): void;
  14720. /**
  14721. * Rebuilds the elements related to this component in case of
  14722. * context lost for instance.
  14723. */
  14724. rebuild(): void;
  14725. /**
  14726. * Disposes the component and the associated resources.
  14727. */
  14728. dispose(): void;
  14729. private _beforeClear;
  14730. }
  14731. }
  14732. declare module BABYLON {
  14733. interface ThinEngine {
  14734. /**
  14735. * Creates a new render target cube texture
  14736. * @param size defines the size of the texture
  14737. * @param options defines the options used to create the texture
  14738. * @returns a new render target cube texture stored in an InternalTexture
  14739. */
  14740. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14741. }
  14742. }
  14743. declare module BABYLON {
  14744. /** @hidden */
  14745. export var proceduralVertexShader: {
  14746. name: string;
  14747. shader: string;
  14748. };
  14749. }
  14750. declare module BABYLON {
  14751. /**
  14752. * 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.
  14753. * This is the base class of any Procedural texture and contains most of the shareable code.
  14754. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14755. */
  14756. export class ProceduralTexture extends Texture {
  14757. /**
  14758. * Define if the texture is enabled or not (disabled texture will not render)
  14759. */
  14760. isEnabled: boolean;
  14761. /**
  14762. * Define if the texture must be cleared before rendering (default is true)
  14763. */
  14764. autoClear: boolean;
  14765. /**
  14766. * Callback called when the texture is generated
  14767. */
  14768. onGenerated: () => void;
  14769. /**
  14770. * Event raised when the texture is generated
  14771. */
  14772. onGeneratedObservable: Observable<ProceduralTexture>;
  14773. /**
  14774. * Event raised before the texture is generated
  14775. */
  14776. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14777. /**
  14778. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14779. */
  14780. nodeMaterialSource: Nullable<NodeMaterial>;
  14781. /** @hidden */
  14782. _generateMipMaps: boolean;
  14783. /** @hidden **/
  14784. _effect: Effect;
  14785. /** @hidden */
  14786. _textures: {
  14787. [key: string]: Texture;
  14788. };
  14789. /** @hidden */
  14790. protected _fallbackTexture: Nullable<Texture>;
  14791. private _size;
  14792. private _textureType;
  14793. private _currentRefreshId;
  14794. private _frameId;
  14795. private _refreshRate;
  14796. private _vertexBuffers;
  14797. private _indexBuffer;
  14798. private _uniforms;
  14799. private _samplers;
  14800. private _fragment;
  14801. private _floats;
  14802. private _ints;
  14803. private _floatsArrays;
  14804. private _colors3;
  14805. private _colors4;
  14806. private _vectors2;
  14807. private _vectors3;
  14808. private _matrices;
  14809. private _fallbackTextureUsed;
  14810. private _fullEngine;
  14811. private _cachedDefines;
  14812. private _contentUpdateId;
  14813. private _contentData;
  14814. /**
  14815. * Instantiates a new procedural texture.
  14816. * 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.
  14817. * This is the base class of any Procedural texture and contains most of the shareable code.
  14818. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14819. * @param name Define the name of the texture
  14820. * @param size Define the size of the texture to create
  14821. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14822. * @param scene Define the scene the texture belongs to
  14823. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14824. * @param generateMipMaps Define if the texture should creates mip maps or not
  14825. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14826. * @param textureType The FBO internal texture type
  14827. */
  14828. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14829. /**
  14830. * The effect that is created when initializing the post process.
  14831. * @returns The created effect corresponding the the postprocess.
  14832. */
  14833. getEffect(): Effect;
  14834. /**
  14835. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14836. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14837. */
  14838. getContent(): Nullable<Promise<ArrayBufferView>>;
  14839. private _createIndexBuffer;
  14840. /** @hidden */
  14841. _rebuild(): void;
  14842. /**
  14843. * Resets the texture in order to recreate its associated resources.
  14844. * This can be called in case of context loss
  14845. */
  14846. reset(): void;
  14847. protected _getDefines(): string;
  14848. /**
  14849. * Is the texture ready to be used ? (rendered at least once)
  14850. * @returns true if ready, otherwise, false.
  14851. */
  14852. isReady(): boolean;
  14853. /**
  14854. * Resets the refresh counter of the texture and start bak from scratch.
  14855. * Could be useful to regenerate the texture if it is setup to render only once.
  14856. */
  14857. resetRefreshCounter(): void;
  14858. /**
  14859. * Set the fragment shader to use in order to render the texture.
  14860. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14861. */
  14862. setFragment(fragment: any): void;
  14863. /**
  14864. * Define the refresh rate of the texture or the rendering frequency.
  14865. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14866. */
  14867. get refreshRate(): number;
  14868. set refreshRate(value: number);
  14869. /** @hidden */
  14870. _shouldRender(): boolean;
  14871. /**
  14872. * Get the size the texture is rendering at.
  14873. * @returns the size (on cube texture it is always squared)
  14874. */
  14875. getRenderSize(): RenderTargetTextureSize;
  14876. /**
  14877. * Resize the texture to new value.
  14878. * @param size Define the new size the texture should have
  14879. * @param generateMipMaps Define whether the new texture should create mip maps
  14880. */
  14881. resize(size: number, generateMipMaps: boolean): void;
  14882. private _checkUniform;
  14883. /**
  14884. * Set a texture in the shader program used to render.
  14885. * @param name Define the name of the uniform samplers as defined in the shader
  14886. * @param texture Define the texture to bind to this sampler
  14887. * @return the texture itself allowing "fluent" like uniform updates
  14888. */
  14889. setTexture(name: string, texture: Texture): ProceduralTexture;
  14890. /**
  14891. * Set a float in the shader.
  14892. * @param name Define the name of the uniform as defined in the shader
  14893. * @param value Define the value to give to the uniform
  14894. * @return the texture itself allowing "fluent" like uniform updates
  14895. */
  14896. setFloat(name: string, value: number): ProceduralTexture;
  14897. /**
  14898. * Set a int in the shader.
  14899. * @param name Define the name of the uniform as defined in the shader
  14900. * @param value Define the value to give to the uniform
  14901. * @return the texture itself allowing "fluent" like uniform updates
  14902. */
  14903. setInt(name: string, value: number): ProceduralTexture;
  14904. /**
  14905. * Set an array of floats in the shader.
  14906. * @param name Define the name of the uniform as defined in the shader
  14907. * @param value Define the value to give to the uniform
  14908. * @return the texture itself allowing "fluent" like uniform updates
  14909. */
  14910. setFloats(name: string, value: number[]): ProceduralTexture;
  14911. /**
  14912. * Set a vec3 in the shader from a Color3.
  14913. * @param name Define the name of the uniform as defined in the shader
  14914. * @param value Define the value to give to the uniform
  14915. * @return the texture itself allowing "fluent" like uniform updates
  14916. */
  14917. setColor3(name: string, value: Color3): ProceduralTexture;
  14918. /**
  14919. * Set a vec4 in the shader from a Color4.
  14920. * @param name Define the name of the uniform as defined in the shader
  14921. * @param value Define the value to give to the uniform
  14922. * @return the texture itself allowing "fluent" like uniform updates
  14923. */
  14924. setColor4(name: string, value: Color4): ProceduralTexture;
  14925. /**
  14926. * Set a vec2 in the shader from a Vector2.
  14927. * @param name Define the name of the uniform as defined in the shader
  14928. * @param value Define the value to give to the uniform
  14929. * @return the texture itself allowing "fluent" like uniform updates
  14930. */
  14931. setVector2(name: string, value: Vector2): ProceduralTexture;
  14932. /**
  14933. * Set a vec3 in the shader from a Vector3.
  14934. * @param name Define the name of the uniform as defined in the shader
  14935. * @param value Define the value to give to the uniform
  14936. * @return the texture itself allowing "fluent" like uniform updates
  14937. */
  14938. setVector3(name: string, value: Vector3): ProceduralTexture;
  14939. /**
  14940. * Set a mat4 in the shader from a MAtrix.
  14941. * @param name Define the name of the uniform as defined in the shader
  14942. * @param value Define the value to give to the uniform
  14943. * @return the texture itself allowing "fluent" like uniform updates
  14944. */
  14945. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14946. /**
  14947. * Render the texture to its associated render target.
  14948. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14949. */
  14950. render(useCameraPostProcess?: boolean): void;
  14951. /**
  14952. * Clone the texture.
  14953. * @returns the cloned texture
  14954. */
  14955. clone(): ProceduralTexture;
  14956. /**
  14957. * Dispose the texture and release its associated resources.
  14958. */
  14959. dispose(): void;
  14960. }
  14961. }
  14962. declare module BABYLON {
  14963. /**
  14964. * This represents the base class for particle system in Babylon.
  14965. * 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.
  14966. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14967. * @example https://doc.babylonjs.com/babylon101/particles
  14968. */
  14969. export class BaseParticleSystem {
  14970. /**
  14971. * Source color is added to the destination color without alpha affecting the result
  14972. */
  14973. static BLENDMODE_ONEONE: number;
  14974. /**
  14975. * Blend current color and particle color using particle’s alpha
  14976. */
  14977. static BLENDMODE_STANDARD: number;
  14978. /**
  14979. * Add current color and particle color multiplied by particle’s alpha
  14980. */
  14981. static BLENDMODE_ADD: number;
  14982. /**
  14983. * Multiply current color with particle color
  14984. */
  14985. static BLENDMODE_MULTIPLY: number;
  14986. /**
  14987. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14988. */
  14989. static BLENDMODE_MULTIPLYADD: number;
  14990. /**
  14991. * List of animations used by the particle system.
  14992. */
  14993. animations: Animation[];
  14994. /**
  14995. * Gets or sets the unique id of the particle system
  14996. */
  14997. uniqueId: number;
  14998. /**
  14999. * The id of the Particle system.
  15000. */
  15001. id: string;
  15002. /**
  15003. * The friendly name of the Particle system.
  15004. */
  15005. name: string;
  15006. /**
  15007. * Snippet ID if the particle system was created from the snippet server
  15008. */
  15009. snippetId: string;
  15010. /**
  15011. * The rendering group used by the Particle system to chose when to render.
  15012. */
  15013. renderingGroupId: number;
  15014. /**
  15015. * The emitter represents the Mesh or position we are attaching the particle system to.
  15016. */
  15017. emitter: Nullable<AbstractMesh | Vector3>;
  15018. /**
  15019. * The maximum number of particles to emit per frame
  15020. */
  15021. emitRate: number;
  15022. /**
  15023. * If you want to launch only a few particles at once, that can be done, as well.
  15024. */
  15025. manualEmitCount: number;
  15026. /**
  15027. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15028. */
  15029. updateSpeed: number;
  15030. /**
  15031. * The amount of time the particle system is running (depends of the overall update speed).
  15032. */
  15033. targetStopDuration: number;
  15034. /**
  15035. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15036. */
  15037. disposeOnStop: boolean;
  15038. /**
  15039. * Minimum power of emitting particles.
  15040. */
  15041. minEmitPower: number;
  15042. /**
  15043. * Maximum power of emitting particles.
  15044. */
  15045. maxEmitPower: number;
  15046. /**
  15047. * Minimum life time of emitting particles.
  15048. */
  15049. minLifeTime: number;
  15050. /**
  15051. * Maximum life time of emitting particles.
  15052. */
  15053. maxLifeTime: number;
  15054. /**
  15055. * Minimum Size of emitting particles.
  15056. */
  15057. minSize: number;
  15058. /**
  15059. * Maximum Size of emitting particles.
  15060. */
  15061. maxSize: number;
  15062. /**
  15063. * Minimum scale of emitting particles on X axis.
  15064. */
  15065. minScaleX: number;
  15066. /**
  15067. * Maximum scale of emitting particles on X axis.
  15068. */
  15069. maxScaleX: number;
  15070. /**
  15071. * Minimum scale of emitting particles on Y axis.
  15072. */
  15073. minScaleY: number;
  15074. /**
  15075. * Maximum scale of emitting particles on Y axis.
  15076. */
  15077. maxScaleY: number;
  15078. /**
  15079. * Gets or sets the minimal initial rotation in radians.
  15080. */
  15081. minInitialRotation: number;
  15082. /**
  15083. * Gets or sets the maximal initial rotation in radians.
  15084. */
  15085. maxInitialRotation: number;
  15086. /**
  15087. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15088. */
  15089. minAngularSpeed: number;
  15090. /**
  15091. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15092. */
  15093. maxAngularSpeed: number;
  15094. /**
  15095. * The texture used to render each particle. (this can be a spritesheet)
  15096. */
  15097. particleTexture: Nullable<BaseTexture>;
  15098. /**
  15099. * The layer mask we are rendering the particles through.
  15100. */
  15101. layerMask: number;
  15102. /**
  15103. * This can help using your own shader to render the particle system.
  15104. * The according effect will be created
  15105. */
  15106. customShader: any;
  15107. /**
  15108. * By default particle system starts as soon as they are created. This prevents the
  15109. * automatic start to happen and let you decide when to start emitting particles.
  15110. */
  15111. preventAutoStart: boolean;
  15112. protected _rootUrl: string;
  15113. private _noiseTexture;
  15114. /**
  15115. * Gets or sets a texture used to add random noise to particle positions
  15116. */
  15117. get noiseTexture(): Nullable<ProceduralTexture>;
  15118. set noiseTexture(value: Nullable<ProceduralTexture>);
  15119. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15120. noiseStrength: Vector3;
  15121. /**
  15122. * Callback triggered when the particle animation is ending.
  15123. */
  15124. onAnimationEnd: Nullable<() => void>;
  15125. /**
  15126. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15127. */
  15128. blendMode: number;
  15129. /**
  15130. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15131. * to override the particles.
  15132. */
  15133. forceDepthWrite: boolean;
  15134. /** 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 */
  15135. preWarmCycles: number;
  15136. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15137. preWarmStepOffset: number;
  15138. /**
  15139. * 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)
  15140. */
  15141. spriteCellChangeSpeed: number;
  15142. /**
  15143. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15144. */
  15145. startSpriteCellID: number;
  15146. /**
  15147. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15148. */
  15149. endSpriteCellID: number;
  15150. /**
  15151. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15152. */
  15153. spriteCellWidth: number;
  15154. /**
  15155. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15156. */
  15157. spriteCellHeight: number;
  15158. /**
  15159. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15160. */
  15161. spriteRandomStartCell: boolean;
  15162. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15163. translationPivot: Vector2;
  15164. /** @hidden */
  15165. protected _isAnimationSheetEnabled: boolean;
  15166. /**
  15167. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15168. */
  15169. beginAnimationOnStart: boolean;
  15170. /**
  15171. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15172. */
  15173. beginAnimationFrom: number;
  15174. /**
  15175. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15176. */
  15177. beginAnimationTo: number;
  15178. /**
  15179. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15180. */
  15181. beginAnimationLoop: boolean;
  15182. /**
  15183. * Gets or sets a world offset applied to all particles
  15184. */
  15185. worldOffset: Vector3;
  15186. /**
  15187. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15188. */
  15189. get isAnimationSheetEnabled(): boolean;
  15190. set isAnimationSheetEnabled(value: boolean);
  15191. /**
  15192. * Get hosting scene
  15193. * @returns the scene
  15194. */
  15195. getScene(): Nullable<Scene>;
  15196. /**
  15197. * You can use gravity if you want to give an orientation to your particles.
  15198. */
  15199. gravity: Vector3;
  15200. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15201. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15202. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15203. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15204. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15205. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15206. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15207. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15208. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15209. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15210. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15211. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15212. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15213. /**
  15214. * Defines the delay in milliseconds before starting the system (0 by default)
  15215. */
  15216. startDelay: number;
  15217. /**
  15218. * Gets the current list of drag gradients.
  15219. * You must use addDragGradient and removeDragGradient to update this list
  15220. * @returns the list of drag gradients
  15221. */
  15222. getDragGradients(): Nullable<Array<FactorGradient>>;
  15223. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15224. limitVelocityDamping: number;
  15225. /**
  15226. * Gets the current list of limit velocity gradients.
  15227. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15228. * @returns the list of limit velocity gradients
  15229. */
  15230. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15231. /**
  15232. * Gets the current list of color gradients.
  15233. * You must use addColorGradient and removeColorGradient to update this list
  15234. * @returns the list of color gradients
  15235. */
  15236. getColorGradients(): Nullable<Array<ColorGradient>>;
  15237. /**
  15238. * Gets the current list of size gradients.
  15239. * You must use addSizeGradient and removeSizeGradient to update this list
  15240. * @returns the list of size gradients
  15241. */
  15242. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15243. /**
  15244. * Gets the current list of color remap gradients.
  15245. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15246. * @returns the list of color remap gradients
  15247. */
  15248. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15249. /**
  15250. * Gets the current list of alpha remap gradients.
  15251. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15252. * @returns the list of alpha remap gradients
  15253. */
  15254. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15255. /**
  15256. * Gets the current list of life time gradients.
  15257. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15258. * @returns the list of life time gradients
  15259. */
  15260. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15261. /**
  15262. * Gets the current list of angular speed gradients.
  15263. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15264. * @returns the list of angular speed gradients
  15265. */
  15266. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15267. /**
  15268. * Gets the current list of velocity gradients.
  15269. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15270. * @returns the list of velocity gradients
  15271. */
  15272. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15273. /**
  15274. * Gets the current list of start size gradients.
  15275. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15276. * @returns the list of start size gradients
  15277. */
  15278. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15279. /**
  15280. * Gets the current list of emit rate gradients.
  15281. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15282. * @returns the list of emit rate gradients
  15283. */
  15284. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15285. /**
  15286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15288. */
  15289. get direction1(): Vector3;
  15290. set direction1(value: Vector3);
  15291. /**
  15292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15293. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15294. */
  15295. get direction2(): Vector3;
  15296. set direction2(value: Vector3);
  15297. /**
  15298. * 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.
  15299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15300. */
  15301. get minEmitBox(): Vector3;
  15302. set minEmitBox(value: Vector3);
  15303. /**
  15304. * 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.
  15305. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15306. */
  15307. get maxEmitBox(): Vector3;
  15308. set maxEmitBox(value: Vector3);
  15309. /**
  15310. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15311. */
  15312. color1: Color4;
  15313. /**
  15314. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15315. */
  15316. color2: Color4;
  15317. /**
  15318. * Color the particle will have at the end of its lifetime
  15319. */
  15320. colorDead: Color4;
  15321. /**
  15322. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15323. */
  15324. textureMask: Color4;
  15325. /**
  15326. * The particle emitter type defines the emitter used by the particle system.
  15327. * It can be for example box, sphere, or cone...
  15328. */
  15329. particleEmitterType: IParticleEmitterType;
  15330. /** @hidden */
  15331. _isSubEmitter: boolean;
  15332. /**
  15333. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15334. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15335. */
  15336. billboardMode: number;
  15337. protected _isBillboardBased: boolean;
  15338. /**
  15339. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15340. */
  15341. get isBillboardBased(): boolean;
  15342. set isBillboardBased(value: boolean);
  15343. /**
  15344. * The scene the particle system belongs to.
  15345. */
  15346. protected _scene: Nullable<Scene>;
  15347. /**
  15348. * The engine the particle system belongs to.
  15349. */
  15350. protected _engine: ThinEngine;
  15351. /**
  15352. * Local cache of defines for image processing.
  15353. */
  15354. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15355. /**
  15356. * Default configuration related to image processing available in the standard Material.
  15357. */
  15358. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15359. /**
  15360. * Gets the image processing configuration used either in this material.
  15361. */
  15362. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15363. /**
  15364. * Sets the Default image processing configuration used either in the this material.
  15365. *
  15366. * If sets to null, the scene one is in use.
  15367. */
  15368. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15369. /**
  15370. * Attaches a new image processing configuration to the Standard Material.
  15371. * @param configuration
  15372. */
  15373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15374. /** @hidden */
  15375. protected _reset(): void;
  15376. /** @hidden */
  15377. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15378. /**
  15379. * Instantiates a particle system.
  15380. * 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.
  15381. * @param name The name of the particle system
  15382. */
  15383. constructor(name: string);
  15384. /**
  15385. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15386. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15387. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15388. * @returns the emitter
  15389. */
  15390. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15391. /**
  15392. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15393. * @param radius The radius of the hemisphere to emit from
  15394. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15395. * @returns the emitter
  15396. */
  15397. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15398. /**
  15399. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15400. * @param radius The radius of the sphere to emit from
  15401. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15402. * @returns the emitter
  15403. */
  15404. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15405. /**
  15406. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15407. * @param radius The radius of the sphere to emit from
  15408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15410. * @returns the emitter
  15411. */
  15412. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15413. /**
  15414. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15415. * @param radius The radius of the emission cylinder
  15416. * @param height The height of the emission cylinder
  15417. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15418. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15419. * @returns the emitter
  15420. */
  15421. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15422. /**
  15423. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15424. * @param radius The radius of the cylinder to emit from
  15425. * @param height The height of the emission cylinder
  15426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15429. * @returns the emitter
  15430. */
  15431. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15432. /**
  15433. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15434. * @param radius The radius of the cone to emit from
  15435. * @param angle The base angle of the cone
  15436. * @returns the emitter
  15437. */
  15438. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15439. /**
  15440. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15443. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15444. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15445. * @returns the emitter
  15446. */
  15447. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15448. }
  15449. }
  15450. declare module BABYLON {
  15451. /**
  15452. * Type of sub emitter
  15453. */
  15454. export enum SubEmitterType {
  15455. /**
  15456. * Attached to the particle over it's lifetime
  15457. */
  15458. ATTACHED = 0,
  15459. /**
  15460. * Created when the particle dies
  15461. */
  15462. END = 1
  15463. }
  15464. /**
  15465. * Sub emitter class used to emit particles from an existing particle
  15466. */
  15467. export class SubEmitter {
  15468. /**
  15469. * the particle system to be used by the sub emitter
  15470. */
  15471. particleSystem: ParticleSystem;
  15472. /**
  15473. * Type of the submitter (Default: END)
  15474. */
  15475. type: SubEmitterType;
  15476. /**
  15477. * 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)
  15478. * Note: This only is supported when using an emitter of type Mesh
  15479. */
  15480. inheritDirection: boolean;
  15481. /**
  15482. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15483. */
  15484. inheritedVelocityAmount: number;
  15485. /**
  15486. * Creates a sub emitter
  15487. * @param particleSystem the particle system to be used by the sub emitter
  15488. */
  15489. constructor(
  15490. /**
  15491. * the particle system to be used by the sub emitter
  15492. */
  15493. particleSystem: ParticleSystem);
  15494. /**
  15495. * Clones the sub emitter
  15496. * @returns the cloned sub emitter
  15497. */
  15498. clone(): SubEmitter;
  15499. /**
  15500. * Serialize current object to a JSON object
  15501. * @returns the serialized object
  15502. */
  15503. serialize(): any;
  15504. /** @hidden */
  15505. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15506. /**
  15507. * Creates a new SubEmitter from a serialized JSON version
  15508. * @param serializationObject defines the JSON object to read from
  15509. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15510. * @param rootUrl defines the rootUrl for data loading
  15511. * @returns a new SubEmitter
  15512. */
  15513. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15514. /** Release associated resources */
  15515. dispose(): void;
  15516. }
  15517. }
  15518. declare module BABYLON {
  15519. /** @hidden */
  15520. export var clipPlaneFragmentDeclaration: {
  15521. name: string;
  15522. shader: string;
  15523. };
  15524. }
  15525. declare module BABYLON {
  15526. /** @hidden */
  15527. export var imageProcessingDeclaration: {
  15528. name: string;
  15529. shader: string;
  15530. };
  15531. }
  15532. declare module BABYLON {
  15533. /** @hidden */
  15534. export var imageProcessingFunctions: {
  15535. name: string;
  15536. shader: string;
  15537. };
  15538. }
  15539. declare module BABYLON {
  15540. /** @hidden */
  15541. export var clipPlaneFragment: {
  15542. name: string;
  15543. shader: string;
  15544. };
  15545. }
  15546. declare module BABYLON {
  15547. /** @hidden */
  15548. export var particlesPixelShader: {
  15549. name: string;
  15550. shader: string;
  15551. };
  15552. }
  15553. declare module BABYLON {
  15554. /** @hidden */
  15555. export var clipPlaneVertexDeclaration: {
  15556. name: string;
  15557. shader: string;
  15558. };
  15559. }
  15560. declare module BABYLON {
  15561. /** @hidden */
  15562. export var clipPlaneVertex: {
  15563. name: string;
  15564. shader: string;
  15565. };
  15566. }
  15567. declare module BABYLON {
  15568. /** @hidden */
  15569. export var particlesVertexShader: {
  15570. name: string;
  15571. shader: string;
  15572. };
  15573. }
  15574. declare module BABYLON {
  15575. /**
  15576. * Interface used to define entities containing multiple clip planes
  15577. */
  15578. export interface IClipPlanesHolder {
  15579. /**
  15580. * Gets or sets the active clipplane 1
  15581. */
  15582. clipPlane: Nullable<Plane>;
  15583. /**
  15584. * Gets or sets the active clipplane 2
  15585. */
  15586. clipPlane2: Nullable<Plane>;
  15587. /**
  15588. * Gets or sets the active clipplane 3
  15589. */
  15590. clipPlane3: Nullable<Plane>;
  15591. /**
  15592. * Gets or sets the active clipplane 4
  15593. */
  15594. clipPlane4: Nullable<Plane>;
  15595. /**
  15596. * Gets or sets the active clipplane 5
  15597. */
  15598. clipPlane5: Nullable<Plane>;
  15599. /**
  15600. * Gets or sets the active clipplane 6
  15601. */
  15602. clipPlane6: Nullable<Plane>;
  15603. }
  15604. }
  15605. declare module BABYLON {
  15606. /**
  15607. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15608. *
  15609. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15610. *
  15611. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15612. */
  15613. export class ThinMaterialHelper {
  15614. /**
  15615. * Binds the clip plane information from the holder to the effect.
  15616. * @param effect The effect we are binding the data to
  15617. * @param holder The entity containing the clip plane information
  15618. */
  15619. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15620. }
  15621. }
  15622. declare module BABYLON {
  15623. interface ThinEngine {
  15624. /**
  15625. * Sets alpha constants used by some alpha blending modes
  15626. * @param r defines the red component
  15627. * @param g defines the green component
  15628. * @param b defines the blue component
  15629. * @param a defines the alpha component
  15630. */
  15631. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15632. /**
  15633. * Sets the current alpha mode
  15634. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15635. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15636. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15637. */
  15638. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15639. /**
  15640. * Gets the current alpha mode
  15641. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15642. * @returns the current alpha mode
  15643. */
  15644. getAlphaMode(): number;
  15645. /**
  15646. * Sets the current alpha equation
  15647. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15648. */
  15649. setAlphaEquation(equation: number): void;
  15650. /**
  15651. * Gets the current alpha equation.
  15652. * @returns the current alpha equation
  15653. */
  15654. getAlphaEquation(): number;
  15655. }
  15656. }
  15657. declare module BABYLON {
  15658. /**
  15659. * This represents a particle system in Babylon.
  15660. * 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.
  15661. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15662. * @example https://doc.babylonjs.com/babylon101/particles
  15663. */
  15664. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15665. /**
  15666. * Billboard mode will only apply to Y axis
  15667. */
  15668. static readonly BILLBOARDMODE_Y: number;
  15669. /**
  15670. * Billboard mode will apply to all axes
  15671. */
  15672. static readonly BILLBOARDMODE_ALL: number;
  15673. /**
  15674. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15675. */
  15676. static readonly BILLBOARDMODE_STRETCHED: number;
  15677. /**
  15678. * This function can be defined to provide custom update for active particles.
  15679. * This function will be called instead of regular update (age, position, color, etc.).
  15680. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15681. */
  15682. updateFunction: (particles: Particle[]) => void;
  15683. private _emitterWorldMatrix;
  15684. /**
  15685. * This function can be defined to specify initial direction for every new particle.
  15686. * It by default use the emitterType defined function
  15687. */
  15688. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15689. /**
  15690. * This function can be defined to specify initial position for every new particle.
  15691. * It by default use the emitterType defined function
  15692. */
  15693. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15694. /**
  15695. * @hidden
  15696. */
  15697. _inheritedVelocityOffset: Vector3;
  15698. /**
  15699. * An event triggered when the system is disposed
  15700. */
  15701. onDisposeObservable: Observable<IParticleSystem>;
  15702. /**
  15703. * An event triggered when the system is stopped
  15704. */
  15705. onStoppedObservable: Observable<IParticleSystem>;
  15706. private _onDisposeObserver;
  15707. /**
  15708. * Sets a callback that will be triggered when the system is disposed
  15709. */
  15710. set onDispose(callback: () => void);
  15711. private _particles;
  15712. private _epsilon;
  15713. private _capacity;
  15714. private _stockParticles;
  15715. private _newPartsExcess;
  15716. private _vertexData;
  15717. private _vertexBuffer;
  15718. private _vertexBuffers;
  15719. private _spriteBuffer;
  15720. private _indexBuffer;
  15721. private _effect;
  15722. private _customEffect;
  15723. private _cachedDefines;
  15724. private _scaledColorStep;
  15725. private _colorDiff;
  15726. private _scaledDirection;
  15727. private _scaledGravity;
  15728. private _currentRenderId;
  15729. private _alive;
  15730. private _useInstancing;
  15731. private _vertexArrayObject;
  15732. private _started;
  15733. private _stopped;
  15734. private _actualFrame;
  15735. private _scaledUpdateSpeed;
  15736. private _vertexBufferSize;
  15737. /** @hidden */
  15738. _currentEmitRateGradient: Nullable<FactorGradient>;
  15739. /** @hidden */
  15740. _currentEmitRate1: number;
  15741. /** @hidden */
  15742. _currentEmitRate2: number;
  15743. /** @hidden */
  15744. _currentStartSizeGradient: Nullable<FactorGradient>;
  15745. /** @hidden */
  15746. _currentStartSize1: number;
  15747. /** @hidden */
  15748. _currentStartSize2: number;
  15749. private readonly _rawTextureWidth;
  15750. private _rampGradientsTexture;
  15751. private _useRampGradients;
  15752. /** Gets or sets a matrix to use to compute projection */
  15753. defaultProjectionMatrix: Matrix;
  15754. /** Gets or sets a matrix to use to compute view */
  15755. defaultViewMatrix: Matrix;
  15756. /** Gets or sets a boolean indicating that ramp gradients must be used
  15757. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15758. */
  15759. get useRampGradients(): boolean;
  15760. set useRampGradients(value: boolean);
  15761. /**
  15762. * 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.
  15763. * 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: [])
  15764. */
  15765. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15766. private _subEmitters;
  15767. /**
  15768. * @hidden
  15769. * If the particle systems emitter should be disposed when the particle system is disposed
  15770. */
  15771. _disposeEmitterOnDispose: boolean;
  15772. /**
  15773. * The current active Sub-systems, this property is used by the root particle system only.
  15774. */
  15775. activeSubSystems: Array<ParticleSystem>;
  15776. /**
  15777. * Specifies if the particles are updated in emitter local space or world space
  15778. */
  15779. isLocal: boolean;
  15780. private _rootParticleSystem;
  15781. /**
  15782. * Gets the current list of active particles
  15783. */
  15784. get particles(): Particle[];
  15785. /**
  15786. * Gets the number of particles active at the same time.
  15787. * @returns The number of active particles.
  15788. */
  15789. getActiveCount(): number;
  15790. /**
  15791. * Returns the string "ParticleSystem"
  15792. * @returns a string containing the class name
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Gets a boolean indicating that the system is stopping
  15797. * @returns true if the system is currently stopping
  15798. */
  15799. isStopping(): boolean;
  15800. /**
  15801. * Gets the custom effect used to render the particles
  15802. * @param blendMode Blend mode for which the effect should be retrieved
  15803. * @returns The effect
  15804. */
  15805. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15806. /**
  15807. * Sets the custom effect used to render the particles
  15808. * @param effect The effect to set
  15809. * @param blendMode Blend mode for which the effect should be set
  15810. */
  15811. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15812. /** @hidden */
  15813. private _onBeforeDrawParticlesObservable;
  15814. /**
  15815. * Observable that will be called just before the particles are drawn
  15816. */
  15817. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15818. /**
  15819. * Gets the name of the particle vertex shader
  15820. */
  15821. get vertexShaderName(): string;
  15822. /**
  15823. * Instantiates a particle system.
  15824. * 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.
  15825. * @param name The name of the particle system
  15826. * @param capacity The max number of particles alive at the same time
  15827. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15828. * @param customEffect a custom effect used to change the way particles are rendered by default
  15829. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15830. * @param epsilon Offset used to render the particles
  15831. */
  15832. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15833. private _addFactorGradient;
  15834. private _removeFactorGradient;
  15835. /**
  15836. * Adds a new life time gradient
  15837. * @param gradient defines the gradient to use (between 0 and 1)
  15838. * @param factor defines the life time factor to affect to the specified gradient
  15839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15840. * @returns the current particle system
  15841. */
  15842. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15843. /**
  15844. * Remove a specific life time gradient
  15845. * @param gradient defines the gradient to remove
  15846. * @returns the current particle system
  15847. */
  15848. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15849. /**
  15850. * Adds a new size gradient
  15851. * @param gradient defines the gradient to use (between 0 and 1)
  15852. * @param factor defines the size factor to affect to the specified gradient
  15853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15854. * @returns the current particle system
  15855. */
  15856. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15857. /**
  15858. * Remove a specific size gradient
  15859. * @param gradient defines the gradient to remove
  15860. * @returns the current particle system
  15861. */
  15862. removeSizeGradient(gradient: number): IParticleSystem;
  15863. /**
  15864. * Adds a new color remap gradient
  15865. * @param gradient defines the gradient to use (between 0 and 1)
  15866. * @param min defines the color remap minimal range
  15867. * @param max defines the color remap maximal range
  15868. * @returns the current particle system
  15869. */
  15870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15871. /**
  15872. * Remove a specific color remap gradient
  15873. * @param gradient defines the gradient to remove
  15874. * @returns the current particle system
  15875. */
  15876. removeColorRemapGradient(gradient: number): IParticleSystem;
  15877. /**
  15878. * Adds a new alpha remap gradient
  15879. * @param gradient defines the gradient to use (between 0 and 1)
  15880. * @param min defines the alpha remap minimal range
  15881. * @param max defines the alpha remap maximal range
  15882. * @returns the current particle system
  15883. */
  15884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15885. /**
  15886. * Remove a specific alpha remap gradient
  15887. * @param gradient defines the gradient to remove
  15888. * @returns the current particle system
  15889. */
  15890. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15891. /**
  15892. * Adds a new angular speed gradient
  15893. * @param gradient defines the gradient to use (between 0 and 1)
  15894. * @param factor defines the angular speed to affect to the specified gradient
  15895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15896. * @returns the current particle system
  15897. */
  15898. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15899. /**
  15900. * Remove a specific angular speed gradient
  15901. * @param gradient defines the gradient to remove
  15902. * @returns the current particle system
  15903. */
  15904. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15905. /**
  15906. * Adds a new velocity gradient
  15907. * @param gradient defines the gradient to use (between 0 and 1)
  15908. * @param factor defines the velocity to affect to the specified gradient
  15909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15910. * @returns the current particle system
  15911. */
  15912. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15913. /**
  15914. * Remove a specific velocity gradient
  15915. * @param gradient defines the gradient to remove
  15916. * @returns the current particle system
  15917. */
  15918. removeVelocityGradient(gradient: number): IParticleSystem;
  15919. /**
  15920. * Adds a new limit velocity gradient
  15921. * @param gradient defines the gradient to use (between 0 and 1)
  15922. * @param factor defines the limit velocity value to affect to the specified gradient
  15923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15924. * @returns the current particle system
  15925. */
  15926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15927. /**
  15928. * Remove a specific limit velocity gradient
  15929. * @param gradient defines the gradient to remove
  15930. * @returns the current particle system
  15931. */
  15932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15933. /**
  15934. * Adds a new drag gradient
  15935. * @param gradient defines the gradient to use (between 0 and 1)
  15936. * @param factor defines the drag value to affect to the specified gradient
  15937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15938. * @returns the current particle system
  15939. */
  15940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15941. /**
  15942. * Remove a specific drag gradient
  15943. * @param gradient defines the gradient to remove
  15944. * @returns the current particle system
  15945. */
  15946. removeDragGradient(gradient: number): IParticleSystem;
  15947. /**
  15948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15949. * @param gradient defines the gradient to use (between 0 and 1)
  15950. * @param factor defines the emit rate value to affect to the specified gradient
  15951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15952. * @returns the current particle system
  15953. */
  15954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15955. /**
  15956. * Remove a specific emit rate gradient
  15957. * @param gradient defines the gradient to remove
  15958. * @returns the current particle system
  15959. */
  15960. removeEmitRateGradient(gradient: number): IParticleSystem;
  15961. /**
  15962. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15963. * @param gradient defines the gradient to use (between 0 and 1)
  15964. * @param factor defines the start size value to affect to the specified gradient
  15965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15966. * @returns the current particle system
  15967. */
  15968. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15969. /**
  15970. * Remove a specific start size gradient
  15971. * @param gradient defines the gradient to remove
  15972. * @returns the current particle system
  15973. */
  15974. removeStartSizeGradient(gradient: number): IParticleSystem;
  15975. private _createRampGradientTexture;
  15976. /**
  15977. * Gets the current list of ramp gradients.
  15978. * You must use addRampGradient and removeRampGradient to update this list
  15979. * @returns the list of ramp gradients
  15980. */
  15981. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15982. /** Force the system to rebuild all gradients that need to be resync */
  15983. forceRefreshGradients(): void;
  15984. private _syncRampGradientTexture;
  15985. /**
  15986. * Adds a new ramp gradient used to remap particle colors
  15987. * @param gradient defines the gradient to use (between 0 and 1)
  15988. * @param color defines the color to affect to the specified gradient
  15989. * @returns the current particle system
  15990. */
  15991. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15992. /**
  15993. * Remove a specific ramp gradient
  15994. * @param gradient defines the gradient to remove
  15995. * @returns the current particle system
  15996. */
  15997. removeRampGradient(gradient: number): ParticleSystem;
  15998. /**
  15999. * Adds a new color gradient
  16000. * @param gradient defines the gradient to use (between 0 and 1)
  16001. * @param color1 defines the color to affect to the specified gradient
  16002. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16003. * @returns this particle system
  16004. */
  16005. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16006. /**
  16007. * Remove a specific color gradient
  16008. * @param gradient defines the gradient to remove
  16009. * @returns this particle system
  16010. */
  16011. removeColorGradient(gradient: number): IParticleSystem;
  16012. private _fetchR;
  16013. protected _reset(): void;
  16014. private _resetEffect;
  16015. private _createVertexBuffers;
  16016. private _createIndexBuffer;
  16017. /**
  16018. * Gets the maximum number of particles active at the same time.
  16019. * @returns The max number of active particles.
  16020. */
  16021. getCapacity(): number;
  16022. /**
  16023. * Gets whether there are still active particles in the system.
  16024. * @returns True if it is alive, otherwise false.
  16025. */
  16026. isAlive(): boolean;
  16027. /**
  16028. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16029. * @returns True if it has been started, otherwise false.
  16030. */
  16031. isStarted(): boolean;
  16032. private _prepareSubEmitterInternalArray;
  16033. /**
  16034. * Starts the particle system and begins to emit
  16035. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16036. */
  16037. start(delay?: number): void;
  16038. /**
  16039. * Stops the particle system.
  16040. * @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.
  16041. */
  16042. stop(stopSubEmitters?: boolean): void;
  16043. /**
  16044. * Remove all active particles
  16045. */
  16046. reset(): void;
  16047. /**
  16048. * @hidden (for internal use only)
  16049. */
  16050. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16051. /**
  16052. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16053. * Its lifetime will start back at 0.
  16054. */
  16055. recycleParticle: (particle: Particle) => void;
  16056. private _stopSubEmitters;
  16057. private _createParticle;
  16058. private _removeFromRoot;
  16059. private _emitFromParticle;
  16060. private _update;
  16061. /** @hidden */
  16062. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16063. /** @hidden */
  16064. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16065. /**
  16066. * Fill the defines array according to the current settings of the particle system
  16067. * @param defines Array to be updated
  16068. * @param blendMode blend mode to take into account when updating the array
  16069. */
  16070. fillDefines(defines: Array<string>, blendMode: number): void;
  16071. /**
  16072. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16073. * @param uniforms Uniforms array to fill
  16074. * @param attributes Attributes array to fill
  16075. * @param samplers Samplers array to fill
  16076. */
  16077. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16078. /** @hidden */
  16079. private _getEffect;
  16080. /**
  16081. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16082. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16083. */
  16084. animate(preWarmOnly?: boolean): void;
  16085. private _appendParticleVertices;
  16086. /**
  16087. * Rebuilds the particle system.
  16088. */
  16089. rebuild(): void;
  16090. /**
  16091. * Is this system ready to be used/rendered
  16092. * @return true if the system is ready
  16093. */
  16094. isReady(): boolean;
  16095. private _render;
  16096. /**
  16097. * Renders the particle system in its current state.
  16098. * @returns the current number of particles
  16099. */
  16100. render(): number;
  16101. /**
  16102. * Disposes the particle system and free the associated resources
  16103. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16104. */
  16105. dispose(disposeTexture?: boolean): void;
  16106. /**
  16107. * Clones the particle system.
  16108. * @param name The name of the cloned object
  16109. * @param newEmitter The new emitter to use
  16110. * @returns the cloned particle system
  16111. */
  16112. clone(name: string, newEmitter: any): ParticleSystem;
  16113. /**
  16114. * Serializes the particle system to a JSON object
  16115. * @param serializeTexture defines if the texture must be serialized as well
  16116. * @returns the JSON object
  16117. */
  16118. serialize(serializeTexture?: boolean): any;
  16119. /** @hidden */
  16120. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16121. /** @hidden */
  16122. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16123. /**
  16124. * Parses a JSON object to create a particle system.
  16125. * @param parsedParticleSystem The JSON object to parse
  16126. * @param sceneOrEngine The scene or the engine to create the particle system in
  16127. * @param rootUrl The root url to use to load external dependencies like texture
  16128. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16129. * @returns the Parsed particle system
  16130. */
  16131. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16132. }
  16133. }
  16134. declare module BABYLON {
  16135. /**
  16136. * A particle represents one of the element emitted by a particle system.
  16137. * This is mainly define by its coordinates, direction, velocity and age.
  16138. */
  16139. export class Particle {
  16140. /**
  16141. * The particle system the particle belongs to.
  16142. */
  16143. particleSystem: ParticleSystem;
  16144. private static _Count;
  16145. /**
  16146. * Unique ID of the particle
  16147. */
  16148. id: number;
  16149. /**
  16150. * The world position of the particle in the scene.
  16151. */
  16152. position: Vector3;
  16153. /**
  16154. * The world direction of the particle in the scene.
  16155. */
  16156. direction: Vector3;
  16157. /**
  16158. * The color of the particle.
  16159. */
  16160. color: Color4;
  16161. /**
  16162. * The color change of the particle per step.
  16163. */
  16164. colorStep: Color4;
  16165. /**
  16166. * Defines how long will the life of the particle be.
  16167. */
  16168. lifeTime: number;
  16169. /**
  16170. * The current age of the particle.
  16171. */
  16172. age: number;
  16173. /**
  16174. * The current size of the particle.
  16175. */
  16176. size: number;
  16177. /**
  16178. * The current scale of the particle.
  16179. */
  16180. scale: Vector2;
  16181. /**
  16182. * The current angle of the particle.
  16183. */
  16184. angle: number;
  16185. /**
  16186. * Defines how fast is the angle changing.
  16187. */
  16188. angularSpeed: number;
  16189. /**
  16190. * Defines the cell index used by the particle to be rendered from a sprite.
  16191. */
  16192. cellIndex: number;
  16193. /**
  16194. * The information required to support color remapping
  16195. */
  16196. remapData: Vector4;
  16197. /** @hidden */
  16198. _randomCellOffset?: number;
  16199. /** @hidden */
  16200. _initialDirection: Nullable<Vector3>;
  16201. /** @hidden */
  16202. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16203. /** @hidden */
  16204. _initialStartSpriteCellID: number;
  16205. /** @hidden */
  16206. _initialEndSpriteCellID: number;
  16207. /** @hidden */
  16208. _currentColorGradient: Nullable<ColorGradient>;
  16209. /** @hidden */
  16210. _currentColor1: Color4;
  16211. /** @hidden */
  16212. _currentColor2: Color4;
  16213. /** @hidden */
  16214. _currentSizeGradient: Nullable<FactorGradient>;
  16215. /** @hidden */
  16216. _currentSize1: number;
  16217. /** @hidden */
  16218. _currentSize2: number;
  16219. /** @hidden */
  16220. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16221. /** @hidden */
  16222. _currentAngularSpeed1: number;
  16223. /** @hidden */
  16224. _currentAngularSpeed2: number;
  16225. /** @hidden */
  16226. _currentVelocityGradient: Nullable<FactorGradient>;
  16227. /** @hidden */
  16228. _currentVelocity1: number;
  16229. /** @hidden */
  16230. _currentVelocity2: number;
  16231. /** @hidden */
  16232. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16233. /** @hidden */
  16234. _currentLimitVelocity1: number;
  16235. /** @hidden */
  16236. _currentLimitVelocity2: number;
  16237. /** @hidden */
  16238. _currentDragGradient: Nullable<FactorGradient>;
  16239. /** @hidden */
  16240. _currentDrag1: number;
  16241. /** @hidden */
  16242. _currentDrag2: number;
  16243. /** @hidden */
  16244. _randomNoiseCoordinates1: Vector3;
  16245. /** @hidden */
  16246. _randomNoiseCoordinates2: Vector3;
  16247. /** @hidden */
  16248. _localPosition?: Vector3;
  16249. /**
  16250. * Creates a new instance Particle
  16251. * @param particleSystem the particle system the particle belongs to
  16252. */
  16253. constructor(
  16254. /**
  16255. * The particle system the particle belongs to.
  16256. */
  16257. particleSystem: ParticleSystem);
  16258. private updateCellInfoFromSystem;
  16259. /**
  16260. * Defines how the sprite cell index is updated for the particle
  16261. */
  16262. updateCellIndex(): void;
  16263. /** @hidden */
  16264. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16265. /** @hidden */
  16266. _inheritParticleInfoToSubEmitters(): void;
  16267. /** @hidden */
  16268. _reset(): void;
  16269. /**
  16270. * Copy the properties of particle to another one.
  16271. * @param other the particle to copy the information to.
  16272. */
  16273. copyTo(other: Particle): void;
  16274. }
  16275. }
  16276. declare module BABYLON {
  16277. /**
  16278. * Particle emitter represents a volume emitting particles.
  16279. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16280. */
  16281. export interface IParticleEmitterType {
  16282. /**
  16283. * Called by the particle System when the direction is computed for the created particle.
  16284. * @param worldMatrix is the world matrix of the particle system
  16285. * @param directionToUpdate is the direction vector to update with the result
  16286. * @param particle is the particle we are computed the direction for
  16287. * @param isLocal defines if the direction should be set in local space
  16288. */
  16289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16290. /**
  16291. * Called by the particle System when the position is computed for the created particle.
  16292. * @param worldMatrix is the world matrix of the particle system
  16293. * @param positionToUpdate is the position vector to update with the result
  16294. * @param particle is the particle we are computed the position for
  16295. * @param isLocal defines if the position should be set in local space
  16296. */
  16297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16298. /**
  16299. * Clones the current emitter and returns a copy of it
  16300. * @returns the new emitter
  16301. */
  16302. clone(): IParticleEmitterType;
  16303. /**
  16304. * Called by the GPUParticleSystem to setup the update shader
  16305. * @param effect defines the update shader
  16306. */
  16307. applyToShader(effect: Effect): void;
  16308. /**
  16309. * Returns a string to use to update the GPU particles update shader
  16310. * @returns the effect defines string
  16311. */
  16312. getEffectDefines(): string;
  16313. /**
  16314. * Returns a string representing the class name
  16315. * @returns a string containing the class name
  16316. */
  16317. getClassName(): string;
  16318. /**
  16319. * Serializes the particle system to a JSON object.
  16320. * @returns the JSON object
  16321. */
  16322. serialize(): any;
  16323. /**
  16324. * Parse properties from a JSON object
  16325. * @param serializationObject defines the JSON object
  16326. * @param scene defines the hosting scene
  16327. */
  16328. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16329. }
  16330. }
  16331. declare module BABYLON {
  16332. /**
  16333. * Particle emitter emitting particles from the inside of a box.
  16334. * It emits the particles randomly between 2 given directions.
  16335. */
  16336. export class BoxParticleEmitter implements IParticleEmitterType {
  16337. /**
  16338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16339. */
  16340. direction1: Vector3;
  16341. /**
  16342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16343. */
  16344. direction2: Vector3;
  16345. /**
  16346. * 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.
  16347. */
  16348. minEmitBox: Vector3;
  16349. /**
  16350. * 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.
  16351. */
  16352. maxEmitBox: Vector3;
  16353. /**
  16354. * Creates a new instance BoxParticleEmitter
  16355. */
  16356. constructor();
  16357. /**
  16358. * Called by the particle System when the direction is computed for the created particle.
  16359. * @param worldMatrix is the world matrix of the particle system
  16360. * @param directionToUpdate is the direction vector to update with the result
  16361. * @param particle is the particle we are computed the direction for
  16362. * @param isLocal defines if the direction should be set in local space
  16363. */
  16364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16365. /**
  16366. * Called by the particle System when the position is computed for the created particle.
  16367. * @param worldMatrix is the world matrix of the particle system
  16368. * @param positionToUpdate is the position vector to update with the result
  16369. * @param particle is the particle we are computed the position for
  16370. * @param isLocal defines if the position should be set in local space
  16371. */
  16372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16373. /**
  16374. * Clones the current emitter and returns a copy of it
  16375. * @returns the new emitter
  16376. */
  16377. clone(): BoxParticleEmitter;
  16378. /**
  16379. * Called by the GPUParticleSystem to setup the update shader
  16380. * @param effect defines the update shader
  16381. */
  16382. applyToShader(effect: Effect): void;
  16383. /**
  16384. * Returns a string to use to update the GPU particles update shader
  16385. * @returns a string containing the defines string
  16386. */
  16387. getEffectDefines(): string;
  16388. /**
  16389. * Returns the string "BoxParticleEmitter"
  16390. * @returns a string containing the class name
  16391. */
  16392. getClassName(): string;
  16393. /**
  16394. * Serializes the particle system to a JSON object.
  16395. * @returns the JSON object
  16396. */
  16397. serialize(): any;
  16398. /**
  16399. * Parse properties from a JSON object
  16400. * @param serializationObject defines the JSON object
  16401. */
  16402. parse(serializationObject: any): void;
  16403. }
  16404. }
  16405. declare module BABYLON {
  16406. /**
  16407. * Particle emitter emitting particles from the inside of a cone.
  16408. * It emits the particles alongside the cone volume from the base to the particle.
  16409. * The emission direction might be randomized.
  16410. */
  16411. export class ConeParticleEmitter implements IParticleEmitterType {
  16412. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16413. directionRandomizer: number;
  16414. private _radius;
  16415. private _angle;
  16416. private _height;
  16417. /**
  16418. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16419. */
  16420. radiusRange: number;
  16421. /**
  16422. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16423. */
  16424. heightRange: number;
  16425. /**
  16426. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16427. */
  16428. emitFromSpawnPointOnly: boolean;
  16429. /**
  16430. * Gets or sets the radius of the emission cone
  16431. */
  16432. get radius(): number;
  16433. set radius(value: number);
  16434. /**
  16435. * Gets or sets the angle of the emission cone
  16436. */
  16437. get angle(): number;
  16438. set angle(value: number);
  16439. private _buildHeight;
  16440. /**
  16441. * Creates a new instance ConeParticleEmitter
  16442. * @param radius the radius of the emission cone (1 by default)
  16443. * @param angle the cone base angle (PI by default)
  16444. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16445. */
  16446. constructor(radius?: number, angle?: number,
  16447. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16448. directionRandomizer?: number);
  16449. /**
  16450. * Called by the particle System when the direction is computed for the created particle.
  16451. * @param worldMatrix is the world matrix of the particle system
  16452. * @param directionToUpdate is the direction vector to update with the result
  16453. * @param particle is the particle we are computed the direction for
  16454. * @param isLocal defines if the direction should be set in local space
  16455. */
  16456. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16457. /**
  16458. * Called by the particle System when the position is computed for the created particle.
  16459. * @param worldMatrix is the world matrix of the particle system
  16460. * @param positionToUpdate is the position vector to update with the result
  16461. * @param particle is the particle we are computed the position for
  16462. * @param isLocal defines if the position should be set in local space
  16463. */
  16464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16465. /**
  16466. * Clones the current emitter and returns a copy of it
  16467. * @returns the new emitter
  16468. */
  16469. clone(): ConeParticleEmitter;
  16470. /**
  16471. * Called by the GPUParticleSystem to setup the update shader
  16472. * @param effect defines the update shader
  16473. */
  16474. applyToShader(effect: Effect): void;
  16475. /**
  16476. * Returns a string to use to update the GPU particles update shader
  16477. * @returns a string containing the defines string
  16478. */
  16479. getEffectDefines(): string;
  16480. /**
  16481. * Returns the string "ConeParticleEmitter"
  16482. * @returns a string containing the class name
  16483. */
  16484. getClassName(): string;
  16485. /**
  16486. * Serializes the particle system to a JSON object.
  16487. * @returns the JSON object
  16488. */
  16489. serialize(): any;
  16490. /**
  16491. * Parse properties from a JSON object
  16492. * @param serializationObject defines the JSON object
  16493. */
  16494. parse(serializationObject: any): void;
  16495. }
  16496. }
  16497. declare module BABYLON {
  16498. /**
  16499. * Particle emitter emitting particles from the inside of a cylinder.
  16500. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16501. */
  16502. export class CylinderParticleEmitter implements IParticleEmitterType {
  16503. /**
  16504. * The radius of the emission cylinder.
  16505. */
  16506. radius: number;
  16507. /**
  16508. * The height of the emission cylinder.
  16509. */
  16510. height: number;
  16511. /**
  16512. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16513. */
  16514. radiusRange: number;
  16515. /**
  16516. * How much to randomize the particle direction [0-1].
  16517. */
  16518. directionRandomizer: number;
  16519. /**
  16520. * Creates a new instance CylinderParticleEmitter
  16521. * @param radius the radius of the emission cylinder (1 by default)
  16522. * @param height the height of the emission cylinder (1 by default)
  16523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16525. */
  16526. constructor(
  16527. /**
  16528. * The radius of the emission cylinder.
  16529. */
  16530. radius?: number,
  16531. /**
  16532. * The height of the emission cylinder.
  16533. */
  16534. height?: number,
  16535. /**
  16536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16537. */
  16538. radiusRange?: number,
  16539. /**
  16540. * How much to randomize the particle direction [0-1].
  16541. */
  16542. directionRandomizer?: number);
  16543. /**
  16544. * Called by the particle System when the direction is computed for the created particle.
  16545. * @param worldMatrix is the world matrix of the particle system
  16546. * @param directionToUpdate is the direction vector to update with the result
  16547. * @param particle is the particle we are computed the direction for
  16548. * @param isLocal defines if the direction should be set in local space
  16549. */
  16550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16551. /**
  16552. * Called by the particle System when the position is computed for the created particle.
  16553. * @param worldMatrix is the world matrix of the particle system
  16554. * @param positionToUpdate is the position vector to update with the result
  16555. * @param particle is the particle we are computed the position for
  16556. * @param isLocal defines if the position should be set in local space
  16557. */
  16558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16559. /**
  16560. * Clones the current emitter and returns a copy of it
  16561. * @returns the new emitter
  16562. */
  16563. clone(): CylinderParticleEmitter;
  16564. /**
  16565. * Called by the GPUParticleSystem to setup the update shader
  16566. * @param effect defines the update shader
  16567. */
  16568. applyToShader(effect: Effect): void;
  16569. /**
  16570. * Returns a string to use to update the GPU particles update shader
  16571. * @returns a string containing the defines string
  16572. */
  16573. getEffectDefines(): string;
  16574. /**
  16575. * Returns the string "CylinderParticleEmitter"
  16576. * @returns a string containing the class name
  16577. */
  16578. getClassName(): string;
  16579. /**
  16580. * Serializes the particle system to a JSON object.
  16581. * @returns the JSON object
  16582. */
  16583. serialize(): any;
  16584. /**
  16585. * Parse properties from a JSON object
  16586. * @param serializationObject defines the JSON object
  16587. */
  16588. parse(serializationObject: any): void;
  16589. }
  16590. /**
  16591. * Particle emitter emitting particles from the inside of a cylinder.
  16592. * It emits the particles randomly between two vectors.
  16593. */
  16594. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16595. /**
  16596. * The min limit of the emission direction.
  16597. */
  16598. direction1: Vector3;
  16599. /**
  16600. * The max limit of the emission direction.
  16601. */
  16602. direction2: Vector3;
  16603. /**
  16604. * Creates a new instance CylinderDirectedParticleEmitter
  16605. * @param radius the radius of the emission cylinder (1 by default)
  16606. * @param height the height of the emission cylinder (1 by default)
  16607. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16608. * @param direction1 the min limit of the emission direction (up vector by default)
  16609. * @param direction2 the max limit of the emission direction (up vector by default)
  16610. */
  16611. constructor(radius?: number, height?: number, radiusRange?: number,
  16612. /**
  16613. * The min limit of the emission direction.
  16614. */
  16615. direction1?: Vector3,
  16616. /**
  16617. * The max limit of the emission direction.
  16618. */
  16619. direction2?: Vector3);
  16620. /**
  16621. * Called by the particle System when the direction is computed for the created particle.
  16622. * @param worldMatrix is the world matrix of the particle system
  16623. * @param directionToUpdate is the direction vector to update with the result
  16624. * @param particle is the particle we are computed the direction for
  16625. */
  16626. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16627. /**
  16628. * Clones the current emitter and returns a copy of it
  16629. * @returns the new emitter
  16630. */
  16631. clone(): CylinderDirectedParticleEmitter;
  16632. /**
  16633. * Called by the GPUParticleSystem to setup the update shader
  16634. * @param effect defines the update shader
  16635. */
  16636. applyToShader(effect: Effect): void;
  16637. /**
  16638. * Returns a string to use to update the GPU particles update shader
  16639. * @returns a string containing the defines string
  16640. */
  16641. getEffectDefines(): string;
  16642. /**
  16643. * Returns the string "CylinderDirectedParticleEmitter"
  16644. * @returns a string containing the class name
  16645. */
  16646. getClassName(): string;
  16647. /**
  16648. * Serializes the particle system to a JSON object.
  16649. * @returns the JSON object
  16650. */
  16651. serialize(): any;
  16652. /**
  16653. * Parse properties from a JSON object
  16654. * @param serializationObject defines the JSON object
  16655. */
  16656. parse(serializationObject: any): void;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Particle emitter emitting particles from the inside of a hemisphere.
  16662. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16663. */
  16664. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16665. /**
  16666. * The radius of the emission hemisphere.
  16667. */
  16668. radius: number;
  16669. /**
  16670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16671. */
  16672. radiusRange: number;
  16673. /**
  16674. * How much to randomize the particle direction [0-1].
  16675. */
  16676. directionRandomizer: number;
  16677. /**
  16678. * Creates a new instance HemisphericParticleEmitter
  16679. * @param radius the radius of the emission hemisphere (1 by default)
  16680. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16681. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16682. */
  16683. constructor(
  16684. /**
  16685. * The radius of the emission hemisphere.
  16686. */
  16687. radius?: number,
  16688. /**
  16689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16690. */
  16691. radiusRange?: number,
  16692. /**
  16693. * How much to randomize the particle direction [0-1].
  16694. */
  16695. directionRandomizer?: number);
  16696. /**
  16697. * Called by the particle System when the direction is computed for the created particle.
  16698. * @param worldMatrix is the world matrix of the particle system
  16699. * @param directionToUpdate is the direction vector to update with the result
  16700. * @param particle is the particle we are computed the direction for
  16701. * @param isLocal defines if the direction should be set in local space
  16702. */
  16703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16704. /**
  16705. * Called by the particle System when the position is computed for the created particle.
  16706. * @param worldMatrix is the world matrix of the particle system
  16707. * @param positionToUpdate is the position vector to update with the result
  16708. * @param particle is the particle we are computed the position for
  16709. * @param isLocal defines if the position should be set in local space
  16710. */
  16711. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16712. /**
  16713. * Clones the current emitter and returns a copy of it
  16714. * @returns the new emitter
  16715. */
  16716. clone(): HemisphericParticleEmitter;
  16717. /**
  16718. * Called by the GPUParticleSystem to setup the update shader
  16719. * @param effect defines the update shader
  16720. */
  16721. applyToShader(effect: Effect): void;
  16722. /**
  16723. * Returns a string to use to update the GPU particles update shader
  16724. * @returns a string containing the defines string
  16725. */
  16726. getEffectDefines(): string;
  16727. /**
  16728. * Returns the string "HemisphericParticleEmitter"
  16729. * @returns a string containing the class name
  16730. */
  16731. getClassName(): string;
  16732. /**
  16733. * Serializes the particle system to a JSON object.
  16734. * @returns the JSON object
  16735. */
  16736. serialize(): any;
  16737. /**
  16738. * Parse properties from a JSON object
  16739. * @param serializationObject defines the JSON object
  16740. */
  16741. parse(serializationObject: any): void;
  16742. }
  16743. }
  16744. declare module BABYLON {
  16745. /**
  16746. * Particle emitter emitting particles from a point.
  16747. * It emits the particles randomly between 2 given directions.
  16748. */
  16749. export class PointParticleEmitter implements IParticleEmitterType {
  16750. /**
  16751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16752. */
  16753. direction1: Vector3;
  16754. /**
  16755. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16756. */
  16757. direction2: Vector3;
  16758. /**
  16759. * Creates a new instance PointParticleEmitter
  16760. */
  16761. constructor();
  16762. /**
  16763. * Called by the particle System when the direction is computed for the created particle.
  16764. * @param worldMatrix is the world matrix of the particle system
  16765. * @param directionToUpdate is the direction vector to update with the result
  16766. * @param particle is the particle we are computed the direction for
  16767. * @param isLocal defines if the direction should be set in local space
  16768. */
  16769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16770. /**
  16771. * Called by the particle System when the position is computed for the created particle.
  16772. * @param worldMatrix is the world matrix of the particle system
  16773. * @param positionToUpdate is the position vector to update with the result
  16774. * @param particle is the particle we are computed the position for
  16775. * @param isLocal defines if the position should be set in local space
  16776. */
  16777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16778. /**
  16779. * Clones the current emitter and returns a copy of it
  16780. * @returns the new emitter
  16781. */
  16782. clone(): PointParticleEmitter;
  16783. /**
  16784. * Called by the GPUParticleSystem to setup the update shader
  16785. * @param effect defines the update shader
  16786. */
  16787. applyToShader(effect: Effect): void;
  16788. /**
  16789. * Returns a string to use to update the GPU particles update shader
  16790. * @returns a string containing the defines string
  16791. */
  16792. getEffectDefines(): string;
  16793. /**
  16794. * Returns the string "PointParticleEmitter"
  16795. * @returns a string containing the class name
  16796. */
  16797. getClassName(): string;
  16798. /**
  16799. * Serializes the particle system to a JSON object.
  16800. * @returns the JSON object
  16801. */
  16802. serialize(): any;
  16803. /**
  16804. * Parse properties from a JSON object
  16805. * @param serializationObject defines the JSON object
  16806. */
  16807. parse(serializationObject: any): void;
  16808. }
  16809. }
  16810. declare module BABYLON {
  16811. /**
  16812. * Particle emitter emitting particles from the inside of a sphere.
  16813. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16814. */
  16815. export class SphereParticleEmitter implements IParticleEmitterType {
  16816. /**
  16817. * The radius of the emission sphere.
  16818. */
  16819. radius: number;
  16820. /**
  16821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16822. */
  16823. radiusRange: number;
  16824. /**
  16825. * How much to randomize the particle direction [0-1].
  16826. */
  16827. directionRandomizer: number;
  16828. /**
  16829. * Creates a new instance SphereParticleEmitter
  16830. * @param radius the radius of the emission sphere (1 by default)
  16831. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16832. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16833. */
  16834. constructor(
  16835. /**
  16836. * The radius of the emission sphere.
  16837. */
  16838. radius?: number,
  16839. /**
  16840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16841. */
  16842. radiusRange?: number,
  16843. /**
  16844. * How much to randomize the particle direction [0-1].
  16845. */
  16846. directionRandomizer?: number);
  16847. /**
  16848. * Called by the particle System when the direction is computed for the created particle.
  16849. * @param worldMatrix is the world matrix of the particle system
  16850. * @param directionToUpdate is the direction vector to update with the result
  16851. * @param particle is the particle we are computed the direction for
  16852. * @param isLocal defines if the direction should be set in local space
  16853. */
  16854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16855. /**
  16856. * Called by the particle System when the position is computed for the created particle.
  16857. * @param worldMatrix is the world matrix of the particle system
  16858. * @param positionToUpdate is the position vector to update with the result
  16859. * @param particle is the particle we are computed the position for
  16860. * @param isLocal defines if the position should be set in local space
  16861. */
  16862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16863. /**
  16864. * Clones the current emitter and returns a copy of it
  16865. * @returns the new emitter
  16866. */
  16867. clone(): SphereParticleEmitter;
  16868. /**
  16869. * Called by the GPUParticleSystem to setup the update shader
  16870. * @param effect defines the update shader
  16871. */
  16872. applyToShader(effect: Effect): void;
  16873. /**
  16874. * Returns a string to use to update the GPU particles update shader
  16875. * @returns a string containing the defines string
  16876. */
  16877. getEffectDefines(): string;
  16878. /**
  16879. * Returns the string "SphereParticleEmitter"
  16880. * @returns a string containing the class name
  16881. */
  16882. getClassName(): string;
  16883. /**
  16884. * Serializes the particle system to a JSON object.
  16885. * @returns the JSON object
  16886. */
  16887. serialize(): any;
  16888. /**
  16889. * Parse properties from a JSON object
  16890. * @param serializationObject defines the JSON object
  16891. */
  16892. parse(serializationObject: any): void;
  16893. }
  16894. /**
  16895. * Particle emitter emitting particles from the inside of a sphere.
  16896. * It emits the particles randomly between two vectors.
  16897. */
  16898. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16899. /**
  16900. * The min limit of the emission direction.
  16901. */
  16902. direction1: Vector3;
  16903. /**
  16904. * The max limit of the emission direction.
  16905. */
  16906. direction2: Vector3;
  16907. /**
  16908. * Creates a new instance SphereDirectedParticleEmitter
  16909. * @param radius the radius of the emission sphere (1 by default)
  16910. * @param direction1 the min limit of the emission direction (up vector by default)
  16911. * @param direction2 the max limit of the emission direction (up vector by default)
  16912. */
  16913. constructor(radius?: number,
  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. * Called by the particle System when the direction is computed for the created particle.
  16924. * @param worldMatrix is the world matrix of the particle system
  16925. * @param directionToUpdate is the direction vector to update with the result
  16926. * @param particle is the particle we are computed the direction for
  16927. */
  16928. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16929. /**
  16930. * Clones the current emitter and returns a copy of it
  16931. * @returns the new emitter
  16932. */
  16933. clone(): SphereDirectedParticleEmitter;
  16934. /**
  16935. * Called by the GPUParticleSystem to setup the update shader
  16936. * @param effect defines the update shader
  16937. */
  16938. applyToShader(effect: Effect): void;
  16939. /**
  16940. * Returns a string to use to update the GPU particles update shader
  16941. * @returns a string containing the defines string
  16942. */
  16943. getEffectDefines(): string;
  16944. /**
  16945. * Returns the string "SphereDirectedParticleEmitter"
  16946. * @returns a string containing the class name
  16947. */
  16948. getClassName(): string;
  16949. /**
  16950. * Serializes the particle system to a JSON object.
  16951. * @returns the JSON object
  16952. */
  16953. serialize(): any;
  16954. /**
  16955. * Parse properties from a JSON object
  16956. * @param serializationObject defines the JSON object
  16957. */
  16958. parse(serializationObject: any): void;
  16959. }
  16960. }
  16961. declare module BABYLON {
  16962. /**
  16963. * Particle emitter emitting particles from a custom list of positions.
  16964. */
  16965. export class CustomParticleEmitter implements IParticleEmitterType {
  16966. /**
  16967. * Gets or sets the position generator that will create the initial position of each particle.
  16968. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16969. */
  16970. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16971. /**
  16972. * Gets or sets the destination generator that will create the final destination of each particle.
  16973. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16974. */
  16975. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16976. /**
  16977. * Creates a new instance CustomParticleEmitter
  16978. */
  16979. constructor();
  16980. /**
  16981. * Called by the particle System when the direction is computed for the created particle.
  16982. * @param worldMatrix is the world matrix of the particle system
  16983. * @param directionToUpdate is the direction vector to update with the result
  16984. * @param particle is the particle we are computed the direction for
  16985. * @param isLocal defines if the direction should be set in local space
  16986. */
  16987. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16988. /**
  16989. * Called by the particle System when the position is computed for the created particle.
  16990. * @param worldMatrix is the world matrix of the particle system
  16991. * @param positionToUpdate is the position vector to update with the result
  16992. * @param particle is the particle we are computed the position for
  16993. * @param isLocal defines if the position should be set in local space
  16994. */
  16995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16996. /**
  16997. * Clones the current emitter and returns a copy of it
  16998. * @returns the new emitter
  16999. */
  17000. clone(): CustomParticleEmitter;
  17001. /**
  17002. * Called by the GPUParticleSystem to setup the update shader
  17003. * @param effect defines the update shader
  17004. */
  17005. applyToShader(effect: Effect): void;
  17006. /**
  17007. * Returns a string to use to update the GPU particles update shader
  17008. * @returns a string containing the defines string
  17009. */
  17010. getEffectDefines(): string;
  17011. /**
  17012. * Returns the string "PointParticleEmitter"
  17013. * @returns a string containing the class name
  17014. */
  17015. getClassName(): string;
  17016. /**
  17017. * Serializes the particle system to a JSON object.
  17018. * @returns the JSON object
  17019. */
  17020. serialize(): any;
  17021. /**
  17022. * Parse properties from a JSON object
  17023. * @param serializationObject defines the JSON object
  17024. */
  17025. parse(serializationObject: any): void;
  17026. }
  17027. }
  17028. declare module BABYLON {
  17029. /**
  17030. * Particle emitter emitting particles from the inside of a box.
  17031. * It emits the particles randomly between 2 given directions.
  17032. */
  17033. export class MeshParticleEmitter implements IParticleEmitterType {
  17034. private _indices;
  17035. private _positions;
  17036. private _normals;
  17037. private _storedNormal;
  17038. private _mesh;
  17039. /**
  17040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17041. */
  17042. direction1: Vector3;
  17043. /**
  17044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17045. */
  17046. direction2: Vector3;
  17047. /**
  17048. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17049. */
  17050. useMeshNormalsForDirection: boolean;
  17051. /** Defines the mesh to use as source */
  17052. get mesh(): Nullable<AbstractMesh>;
  17053. set mesh(value: Nullable<AbstractMesh>);
  17054. /**
  17055. * Creates a new instance MeshParticleEmitter
  17056. * @param mesh defines the mesh to use as source
  17057. */
  17058. constructor(mesh?: Nullable<AbstractMesh>);
  17059. /**
  17060. * Called by the particle System when the direction is computed for the created particle.
  17061. * @param worldMatrix is the world matrix of the particle system
  17062. * @param directionToUpdate is the direction vector to update with the result
  17063. * @param particle is the particle we are computed the direction for
  17064. * @param isLocal defines if the direction should be set in local space
  17065. */
  17066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17067. /**
  17068. * Called by the particle System when the position is computed for the created particle.
  17069. * @param worldMatrix is the world matrix of the particle system
  17070. * @param positionToUpdate is the position vector to update with the result
  17071. * @param particle is the particle we are computed the position for
  17072. * @param isLocal defines if the position should be set in local space
  17073. */
  17074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17075. /**
  17076. * Clones the current emitter and returns a copy of it
  17077. * @returns the new emitter
  17078. */
  17079. clone(): MeshParticleEmitter;
  17080. /**
  17081. * Called by the GPUParticleSystem to setup the update shader
  17082. * @param effect defines the update shader
  17083. */
  17084. applyToShader(effect: Effect): void;
  17085. /**
  17086. * Returns a string to use to update the GPU particles update shader
  17087. * @returns a string containing the defines string
  17088. */
  17089. getEffectDefines(): string;
  17090. /**
  17091. * Returns the string "BoxParticleEmitter"
  17092. * @returns a string containing the class name
  17093. */
  17094. getClassName(): string;
  17095. /**
  17096. * Serializes the particle system to a JSON object.
  17097. * @returns the JSON object
  17098. */
  17099. serialize(): any;
  17100. /**
  17101. * Parse properties from a JSON object
  17102. * @param serializationObject defines the JSON object
  17103. * @param scene defines the hosting scene
  17104. */
  17105. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17106. }
  17107. }
  17108. declare module BABYLON {
  17109. /**
  17110. * Interface representing a particle system in Babylon.js.
  17111. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17112. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17113. */
  17114. export interface IParticleSystem {
  17115. /**
  17116. * List of animations used by the particle system.
  17117. */
  17118. animations: Animation[];
  17119. /**
  17120. * The id of the Particle system.
  17121. */
  17122. id: string;
  17123. /**
  17124. * The name of the Particle system.
  17125. */
  17126. name: string;
  17127. /**
  17128. * The emitter represents the Mesh or position we are attaching the particle system to.
  17129. */
  17130. emitter: Nullable<AbstractMesh | Vector3>;
  17131. /**
  17132. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17133. */
  17134. isBillboardBased: boolean;
  17135. /**
  17136. * The rendering group used by the Particle system to chose when to render.
  17137. */
  17138. renderingGroupId: number;
  17139. /**
  17140. * The layer mask we are rendering the particles through.
  17141. */
  17142. layerMask: number;
  17143. /**
  17144. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17145. */
  17146. updateSpeed: number;
  17147. /**
  17148. * The amount of time the particle system is running (depends of the overall update speed).
  17149. */
  17150. targetStopDuration: number;
  17151. /**
  17152. * The texture used to render each particle. (this can be a spritesheet)
  17153. */
  17154. particleTexture: Nullable<BaseTexture>;
  17155. /**
  17156. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17157. */
  17158. blendMode: number;
  17159. /**
  17160. * Minimum life time of emitting particles.
  17161. */
  17162. minLifeTime: number;
  17163. /**
  17164. * Maximum life time of emitting particles.
  17165. */
  17166. maxLifeTime: number;
  17167. /**
  17168. * Minimum Size of emitting particles.
  17169. */
  17170. minSize: number;
  17171. /**
  17172. * Maximum Size of emitting particles.
  17173. */
  17174. maxSize: number;
  17175. /**
  17176. * Minimum scale of emitting particles on X axis.
  17177. */
  17178. minScaleX: number;
  17179. /**
  17180. * Maximum scale of emitting particles on X axis.
  17181. */
  17182. maxScaleX: number;
  17183. /**
  17184. * Minimum scale of emitting particles on Y axis.
  17185. */
  17186. minScaleY: number;
  17187. /**
  17188. * Maximum scale of emitting particles on Y axis.
  17189. */
  17190. maxScaleY: number;
  17191. /**
  17192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17193. */
  17194. color1: Color4;
  17195. /**
  17196. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17197. */
  17198. color2: Color4;
  17199. /**
  17200. * Color the particle will have at the end of its lifetime.
  17201. */
  17202. colorDead: Color4;
  17203. /**
  17204. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17205. */
  17206. emitRate: number;
  17207. /**
  17208. * You can use gravity if you want to give an orientation to your particles.
  17209. */
  17210. gravity: Vector3;
  17211. /**
  17212. * Minimum power of emitting particles.
  17213. */
  17214. minEmitPower: number;
  17215. /**
  17216. * Maximum power of emitting particles.
  17217. */
  17218. maxEmitPower: number;
  17219. /**
  17220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17221. */
  17222. minAngularSpeed: number;
  17223. /**
  17224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17225. */
  17226. maxAngularSpeed: number;
  17227. /**
  17228. * Gets or sets the minimal initial rotation in radians.
  17229. */
  17230. minInitialRotation: number;
  17231. /**
  17232. * Gets or sets the maximal initial rotation in radians.
  17233. */
  17234. maxInitialRotation: number;
  17235. /**
  17236. * The particle emitter type defines the emitter used by the particle system.
  17237. * It can be for example box, sphere, or cone...
  17238. */
  17239. particleEmitterType: Nullable<IParticleEmitterType>;
  17240. /**
  17241. * Defines the delay in milliseconds before starting the system (0 by default)
  17242. */
  17243. startDelay: number;
  17244. /**
  17245. * 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
  17246. */
  17247. preWarmCycles: number;
  17248. /**
  17249. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17250. */
  17251. preWarmStepOffset: number;
  17252. /**
  17253. * 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)
  17254. */
  17255. spriteCellChangeSpeed: number;
  17256. /**
  17257. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17258. */
  17259. startSpriteCellID: number;
  17260. /**
  17261. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17262. */
  17263. endSpriteCellID: number;
  17264. /**
  17265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17266. */
  17267. spriteCellWidth: number;
  17268. /**
  17269. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17270. */
  17271. spriteCellHeight: number;
  17272. /**
  17273. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17274. */
  17275. spriteRandomStartCell: boolean;
  17276. /**
  17277. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17278. */
  17279. isAnimationSheetEnabled: boolean;
  17280. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17281. translationPivot: Vector2;
  17282. /**
  17283. * Gets or sets a texture used to add random noise to particle positions
  17284. */
  17285. noiseTexture: Nullable<BaseTexture>;
  17286. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17287. noiseStrength: Vector3;
  17288. /**
  17289. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17290. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17291. */
  17292. billboardMode: number;
  17293. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17294. limitVelocityDamping: number;
  17295. /**
  17296. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17297. */
  17298. beginAnimationOnStart: boolean;
  17299. /**
  17300. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17301. */
  17302. beginAnimationFrom: number;
  17303. /**
  17304. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17305. */
  17306. beginAnimationTo: number;
  17307. /**
  17308. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17309. */
  17310. beginAnimationLoop: boolean;
  17311. /**
  17312. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17313. */
  17314. disposeOnStop: boolean;
  17315. /**
  17316. * If you want to launch only a few particles at once, that can be done, as well.
  17317. */
  17318. manualEmitCount: number;
  17319. /**
  17320. * Specifies if the particles are updated in emitter local space or world space
  17321. */
  17322. isLocal: boolean;
  17323. /** Snippet ID if the particle system was created from the snippet server */
  17324. snippetId: string;
  17325. /** Gets or sets a matrix to use to compute projection */
  17326. defaultProjectionMatrix: Matrix;
  17327. /**
  17328. * Gets the maximum number of particles active at the same time.
  17329. * @returns The max number of active particles.
  17330. */
  17331. getCapacity(): number;
  17332. /**
  17333. * Gets the number of particles active at the same time.
  17334. * @returns The number of active particles.
  17335. */
  17336. getActiveCount(): number;
  17337. /**
  17338. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17339. * @returns True if it has been started, otherwise false.
  17340. */
  17341. isStarted(): boolean;
  17342. /**
  17343. * Animates the particle system for this frame.
  17344. */
  17345. animate(): void;
  17346. /**
  17347. * Renders the particle system in its current state.
  17348. * @returns the current number of particles
  17349. */
  17350. render(): number;
  17351. /**
  17352. * Dispose the particle system and frees its associated resources.
  17353. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17354. */
  17355. dispose(disposeTexture?: boolean): void;
  17356. /**
  17357. * An event triggered when the system is disposed
  17358. */
  17359. onDisposeObservable: Observable<IParticleSystem>;
  17360. /**
  17361. * An event triggered when the system is stopped
  17362. */
  17363. onStoppedObservable: Observable<IParticleSystem>;
  17364. /**
  17365. * Clones the particle system.
  17366. * @param name The name of the cloned object
  17367. * @param newEmitter The new emitter to use
  17368. * @returns the cloned particle system
  17369. */
  17370. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17371. /**
  17372. * Serializes the particle system to a JSON object
  17373. * @param serializeTexture defines if the texture must be serialized as well
  17374. * @returns the JSON object
  17375. */
  17376. serialize(serializeTexture: boolean): any;
  17377. /**
  17378. * Rebuild the particle system
  17379. */
  17380. rebuild(): void;
  17381. /** Force the system to rebuild all gradients that need to be resync */
  17382. forceRefreshGradients(): void;
  17383. /**
  17384. * Starts the particle system and begins to emit
  17385. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17386. */
  17387. start(delay?: number): void;
  17388. /**
  17389. * Stops the particle system.
  17390. */
  17391. stop(): void;
  17392. /**
  17393. * Remove all active particles
  17394. */
  17395. reset(): void;
  17396. /**
  17397. * Gets a boolean indicating that the system is stopping
  17398. * @returns true if the system is currently stopping
  17399. */
  17400. isStopping(): boolean;
  17401. /**
  17402. * Is this system ready to be used/rendered
  17403. * @return true if the system is ready
  17404. */
  17405. isReady(): boolean;
  17406. /**
  17407. * Returns the string "ParticleSystem"
  17408. * @returns a string containing the class name
  17409. */
  17410. getClassName(): string;
  17411. /**
  17412. * Gets the custom effect used to render the particles
  17413. * @param blendMode Blend mode for which the effect should be retrieved
  17414. * @returns The effect
  17415. */
  17416. getCustomEffect(blendMode: number): Nullable<Effect>;
  17417. /**
  17418. * Sets the custom effect used to render the particles
  17419. * @param effect The effect to set
  17420. * @param blendMode Blend mode for which the effect should be set
  17421. */
  17422. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17423. /**
  17424. * Fill the defines array according to the current settings of the particle system
  17425. * @param defines Array to be updated
  17426. * @param blendMode blend mode to take into account when updating the array
  17427. */
  17428. fillDefines(defines: Array<string>, blendMode: number): void;
  17429. /**
  17430. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17431. * @param uniforms Uniforms array to fill
  17432. * @param attributes Attributes array to fill
  17433. * @param samplers Samplers array to fill
  17434. */
  17435. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17436. /**
  17437. * Observable that will be called just before the particles are drawn
  17438. */
  17439. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17440. /**
  17441. * Gets the name of the particle vertex shader
  17442. */
  17443. vertexShaderName: string;
  17444. /**
  17445. * Adds a new color gradient
  17446. * @param gradient defines the gradient to use (between 0 and 1)
  17447. * @param color1 defines the color to affect to the specified gradient
  17448. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17449. * @returns the current particle system
  17450. */
  17451. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17452. /**
  17453. * Remove a specific color gradient
  17454. * @param gradient defines the gradient to remove
  17455. * @returns the current particle system
  17456. */
  17457. removeColorGradient(gradient: number): IParticleSystem;
  17458. /**
  17459. * Adds a new size gradient
  17460. * @param gradient defines the gradient to use (between 0 and 1)
  17461. * @param factor defines the size factor to affect to the specified gradient
  17462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17463. * @returns the current particle system
  17464. */
  17465. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17466. /**
  17467. * Remove a specific size gradient
  17468. * @param gradient defines the gradient to remove
  17469. * @returns the current particle system
  17470. */
  17471. removeSizeGradient(gradient: number): IParticleSystem;
  17472. /**
  17473. * Gets the current list of color gradients.
  17474. * You must use addColorGradient and removeColorGradient to update this list
  17475. * @returns the list of color gradients
  17476. */
  17477. getColorGradients(): Nullable<Array<ColorGradient>>;
  17478. /**
  17479. * Gets the current list of size gradients.
  17480. * You must use addSizeGradient and removeSizeGradient to update this list
  17481. * @returns the list of size gradients
  17482. */
  17483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Gets the current list of angular speed gradients.
  17486. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17487. * @returns the list of angular speed gradients
  17488. */
  17489. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17490. /**
  17491. * Adds a new angular speed gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param factor defines the angular speed to affect to the specified gradient
  17494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17495. * @returns the current particle system
  17496. */
  17497. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific angular speed gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Gets the current list of velocity gradients.
  17506. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17507. * @returns the list of velocity gradients
  17508. */
  17509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17510. /**
  17511. * Adds a new velocity gradient
  17512. * @param gradient defines the gradient to use (between 0 and 1)
  17513. * @param factor defines the velocity to affect to the specified gradient
  17514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17515. * @returns the current particle system
  17516. */
  17517. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17518. /**
  17519. * Remove a specific velocity gradient
  17520. * @param gradient defines the gradient to remove
  17521. * @returns the current particle system
  17522. */
  17523. removeVelocityGradient(gradient: number): IParticleSystem;
  17524. /**
  17525. * Gets the current list of limit velocity gradients.
  17526. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17527. * @returns the list of limit velocity gradients
  17528. */
  17529. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17530. /**
  17531. * Adds a new limit velocity gradient
  17532. * @param gradient defines the gradient to use (between 0 and 1)
  17533. * @param factor defines the limit velocity to affect to the specified gradient
  17534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17535. * @returns the current particle system
  17536. */
  17537. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17538. /**
  17539. * Remove a specific limit velocity gradient
  17540. * @param gradient defines the gradient to remove
  17541. * @returns the current particle system
  17542. */
  17543. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17544. /**
  17545. * Adds a new drag gradient
  17546. * @param gradient defines the gradient to use (between 0 and 1)
  17547. * @param factor defines the drag to affect to the specified gradient
  17548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17549. * @returns the current particle system
  17550. */
  17551. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17552. /**
  17553. * Remove a specific drag gradient
  17554. * @param gradient defines the gradient to remove
  17555. * @returns the current particle system
  17556. */
  17557. removeDragGradient(gradient: number): IParticleSystem;
  17558. /**
  17559. * Gets the current list of drag gradients.
  17560. * You must use addDragGradient and removeDragGradient to update this list
  17561. * @returns the list of drag gradients
  17562. */
  17563. getDragGradients(): Nullable<Array<FactorGradient>>;
  17564. /**
  17565. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17566. * @param gradient defines the gradient to use (between 0 and 1)
  17567. * @param factor defines the emit rate to affect to the specified gradient
  17568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17569. * @returns the current particle system
  17570. */
  17571. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17572. /**
  17573. * Remove a specific emit rate gradient
  17574. * @param gradient defines the gradient to remove
  17575. * @returns the current particle system
  17576. */
  17577. removeEmitRateGradient(gradient: number): IParticleSystem;
  17578. /**
  17579. * Gets the current list of emit rate gradients.
  17580. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17581. * @returns the list of emit rate gradients
  17582. */
  17583. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17584. /**
  17585. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the start size to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific start size gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeStartSizeGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Gets the current list of start size gradients.
  17600. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17601. * @returns the list of start size gradients
  17602. */
  17603. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17604. /**
  17605. * Adds a new life time gradient
  17606. * @param gradient defines the gradient to use (between 0 and 1)
  17607. * @param factor defines the life time factor to affect to the specified gradient
  17608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17609. * @returns the current particle system
  17610. */
  17611. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17612. /**
  17613. * Remove a specific life time gradient
  17614. * @param gradient defines the gradient to remove
  17615. * @returns the current particle system
  17616. */
  17617. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17618. /**
  17619. * Gets the current list of life time gradients.
  17620. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17621. * @returns the list of life time gradients
  17622. */
  17623. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17624. /**
  17625. * Gets the current list of color gradients.
  17626. * You must use addColorGradient and removeColorGradient to update this list
  17627. * @returns the list of color gradients
  17628. */
  17629. getColorGradients(): Nullable<Array<ColorGradient>>;
  17630. /**
  17631. * Adds a new ramp gradient used to remap particle colors
  17632. * @param gradient defines the gradient to use (between 0 and 1)
  17633. * @param color defines the color to affect to the specified gradient
  17634. * @returns the current particle system
  17635. */
  17636. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17637. /**
  17638. * Gets the current list of ramp gradients.
  17639. * You must use addRampGradient and removeRampGradient to update this list
  17640. * @returns the list of ramp gradients
  17641. */
  17642. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17643. /** Gets or sets a boolean indicating that ramp gradients must be used
  17644. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17645. */
  17646. useRampGradients: boolean;
  17647. /**
  17648. * Adds a new color remap gradient
  17649. * @param gradient defines the gradient to use (between 0 and 1)
  17650. * @param min defines the color remap minimal range
  17651. * @param max defines the color remap maximal range
  17652. * @returns the current particle system
  17653. */
  17654. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17655. /**
  17656. * Gets the current list of color remap gradients.
  17657. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17658. * @returns the list of color remap gradients
  17659. */
  17660. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17661. /**
  17662. * Adds a new alpha remap gradient
  17663. * @param gradient defines the gradient to use (between 0 and 1)
  17664. * @param min defines the alpha remap minimal range
  17665. * @param max defines the alpha remap maximal range
  17666. * @returns the current particle system
  17667. */
  17668. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17669. /**
  17670. * Gets the current list of alpha remap gradients.
  17671. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17672. * @returns the list of alpha remap gradients
  17673. */
  17674. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17675. /**
  17676. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17677. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17678. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17679. * @returns the emitter
  17680. */
  17681. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17682. /**
  17683. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17684. * @param radius The radius of the hemisphere to emit from
  17685. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17686. * @returns the emitter
  17687. */
  17688. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17689. /**
  17690. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17691. * @param radius The radius of the sphere to emit from
  17692. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17693. * @returns the emitter
  17694. */
  17695. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17696. /**
  17697. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17698. * @param radius The radius of the sphere to emit from
  17699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17701. * @returns the emitter
  17702. */
  17703. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17704. /**
  17705. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17706. * @param radius The radius of the emission cylinder
  17707. * @param height The height of the emission cylinder
  17708. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17709. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17710. * @returns the emitter
  17711. */
  17712. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17713. /**
  17714. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17715. * @param radius The radius of the cylinder to emit from
  17716. * @param height The height of the emission cylinder
  17717. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17720. * @returns the emitter
  17721. */
  17722. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17723. /**
  17724. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17725. * @param radius The radius of the cone to emit from
  17726. * @param angle The base angle of the cone
  17727. * @returns the emitter
  17728. */
  17729. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17730. /**
  17731. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17734. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17735. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17736. * @returns the emitter
  17737. */
  17738. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17739. /**
  17740. * Get hosting scene
  17741. * @returns the scene
  17742. */
  17743. getScene(): Nullable<Scene>;
  17744. }
  17745. }
  17746. declare module BABYLON {
  17747. /**
  17748. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17749. */
  17750. export class ColorSplitterBlock extends NodeMaterialBlock {
  17751. /**
  17752. * Create a new ColorSplitterBlock
  17753. * @param name defines the block name
  17754. */
  17755. constructor(name: string);
  17756. /**
  17757. * Gets the current class name
  17758. * @returns the class name
  17759. */
  17760. getClassName(): string;
  17761. /**
  17762. * Gets the rgba component (input)
  17763. */
  17764. get rgba(): NodeMaterialConnectionPoint;
  17765. /**
  17766. * Gets the rgb component (input)
  17767. */
  17768. get rgbIn(): NodeMaterialConnectionPoint;
  17769. /**
  17770. * Gets the rgb component (output)
  17771. */
  17772. get rgbOut(): NodeMaterialConnectionPoint;
  17773. /**
  17774. * Gets the r component (output)
  17775. */
  17776. get r(): NodeMaterialConnectionPoint;
  17777. /**
  17778. * Gets the g component (output)
  17779. */
  17780. get g(): NodeMaterialConnectionPoint;
  17781. /**
  17782. * Gets the b component (output)
  17783. */
  17784. get b(): NodeMaterialConnectionPoint;
  17785. /**
  17786. * Gets the a component (output)
  17787. */
  17788. get a(): NodeMaterialConnectionPoint;
  17789. protected _inputRename(name: string): string;
  17790. protected _outputRename(name: string): string;
  17791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17792. }
  17793. }
  17794. declare module BABYLON {
  17795. /**
  17796. * Operations supported by the Trigonometry block
  17797. */
  17798. export enum TrigonometryBlockOperations {
  17799. /** Cos */
  17800. Cos = 0,
  17801. /** Sin */
  17802. Sin = 1,
  17803. /** Abs */
  17804. Abs = 2,
  17805. /** Exp */
  17806. Exp = 3,
  17807. /** Exp2 */
  17808. Exp2 = 4,
  17809. /** Round */
  17810. Round = 5,
  17811. /** Floor */
  17812. Floor = 6,
  17813. /** Ceiling */
  17814. Ceiling = 7,
  17815. /** Square root */
  17816. Sqrt = 8,
  17817. /** Log */
  17818. Log = 9,
  17819. /** Tangent */
  17820. Tan = 10,
  17821. /** Arc tangent */
  17822. ArcTan = 11,
  17823. /** Arc cosinus */
  17824. ArcCos = 12,
  17825. /** Arc sinus */
  17826. ArcSin = 13,
  17827. /** Fraction */
  17828. Fract = 14,
  17829. /** Sign */
  17830. Sign = 15,
  17831. /** To radians (from degrees) */
  17832. Radians = 16,
  17833. /** To degrees (from radians) */
  17834. Degrees = 17
  17835. }
  17836. /**
  17837. * Block used to apply trigonometry operation to floats
  17838. */
  17839. export class TrigonometryBlock extends NodeMaterialBlock {
  17840. /**
  17841. * Gets or sets the operation applied by the block
  17842. */
  17843. operation: TrigonometryBlockOperations;
  17844. /**
  17845. * Creates a new TrigonometryBlock
  17846. * @param name defines the block name
  17847. */
  17848. constructor(name: string);
  17849. /**
  17850. * Gets the current class name
  17851. * @returns the class name
  17852. */
  17853. getClassName(): string;
  17854. /**
  17855. * Gets the input component
  17856. */
  17857. get input(): NodeMaterialConnectionPoint;
  17858. /**
  17859. * Gets the output component
  17860. */
  17861. get output(): NodeMaterialConnectionPoint;
  17862. protected _buildBlock(state: NodeMaterialBuildState): this;
  17863. serialize(): any;
  17864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17865. protected _dumpPropertiesCode(): string;
  17866. }
  17867. }
  17868. declare module BABYLON {
  17869. /**
  17870. * Interface used to configure the node material editor
  17871. */
  17872. export interface INodeMaterialEditorOptions {
  17873. /** Define the URl to load node editor script */
  17874. editorURL?: string;
  17875. }
  17876. /** @hidden */
  17877. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17878. NORMAL: boolean;
  17879. TANGENT: boolean;
  17880. UV1: boolean;
  17881. /** BONES */
  17882. NUM_BONE_INFLUENCERS: number;
  17883. BonesPerMesh: number;
  17884. BONETEXTURE: boolean;
  17885. /** MORPH TARGETS */
  17886. MORPHTARGETS: boolean;
  17887. MORPHTARGETS_NORMAL: boolean;
  17888. MORPHTARGETS_TANGENT: boolean;
  17889. MORPHTARGETS_UV: boolean;
  17890. NUM_MORPH_INFLUENCERS: number;
  17891. /** IMAGE PROCESSING */
  17892. IMAGEPROCESSING: boolean;
  17893. VIGNETTE: boolean;
  17894. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17895. VIGNETTEBLENDMODEOPAQUE: boolean;
  17896. TONEMAPPING: boolean;
  17897. TONEMAPPING_ACES: boolean;
  17898. CONTRAST: boolean;
  17899. EXPOSURE: boolean;
  17900. COLORCURVES: boolean;
  17901. COLORGRADING: boolean;
  17902. COLORGRADING3D: boolean;
  17903. SAMPLER3DGREENDEPTH: boolean;
  17904. SAMPLER3DBGRMAP: boolean;
  17905. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17906. /** MISC. */
  17907. BUMPDIRECTUV: number;
  17908. constructor();
  17909. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17910. }
  17911. /**
  17912. * Class used to configure NodeMaterial
  17913. */
  17914. export interface INodeMaterialOptions {
  17915. /**
  17916. * Defines if blocks should emit comments
  17917. */
  17918. emitComments: boolean;
  17919. }
  17920. /**
  17921. * Class used to create a node based material built by assembling shader blocks
  17922. */
  17923. export class NodeMaterial extends PushMaterial {
  17924. private static _BuildIdGenerator;
  17925. private _options;
  17926. private _vertexCompilationState;
  17927. private _fragmentCompilationState;
  17928. private _sharedData;
  17929. private _buildId;
  17930. private _buildWasSuccessful;
  17931. private _cachedWorldViewMatrix;
  17932. private _cachedWorldViewProjectionMatrix;
  17933. private _optimizers;
  17934. private _animationFrame;
  17935. /** Define the Url to load node editor script */
  17936. static EditorURL: string;
  17937. /** Define the Url to load snippets */
  17938. static SnippetUrl: string;
  17939. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17940. static IgnoreTexturesAtLoadTime: boolean;
  17941. private BJSNODEMATERIALEDITOR;
  17942. /** Get the inspector from bundle or global */
  17943. private _getGlobalNodeMaterialEditor;
  17944. /**
  17945. * Snippet ID if the material was created from the snippet server
  17946. */
  17947. snippetId: string;
  17948. /**
  17949. * Gets or sets data used by visual editor
  17950. * @see https://nme.babylonjs.com
  17951. */
  17952. editorData: any;
  17953. /**
  17954. * 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)
  17955. */
  17956. ignoreAlpha: boolean;
  17957. /**
  17958. * Defines the maximum number of lights that can be used in the material
  17959. */
  17960. maxSimultaneousLights: number;
  17961. /**
  17962. * Observable raised when the material is built
  17963. */
  17964. onBuildObservable: Observable<NodeMaterial>;
  17965. /**
  17966. * Gets or sets the root nodes of the material vertex shader
  17967. */
  17968. _vertexOutputNodes: NodeMaterialBlock[];
  17969. /**
  17970. * Gets or sets the root nodes of the material fragment (pixel) shader
  17971. */
  17972. _fragmentOutputNodes: NodeMaterialBlock[];
  17973. /** Gets or sets options to control the node material overall behavior */
  17974. get options(): INodeMaterialOptions;
  17975. set options(options: INodeMaterialOptions);
  17976. /**
  17977. * Default configuration related to image processing available in the standard Material.
  17978. */
  17979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17980. /**
  17981. * Gets the image processing configuration used either in this material.
  17982. */
  17983. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17984. /**
  17985. * Sets the Default image processing configuration used either in the this material.
  17986. *
  17987. * If sets to null, the scene one is in use.
  17988. */
  17989. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17990. /**
  17991. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17992. */
  17993. attachedBlocks: NodeMaterialBlock[];
  17994. /**
  17995. * Specifies the mode of the node material
  17996. * @hidden
  17997. */
  17998. _mode: NodeMaterialModes;
  17999. /**
  18000. * Gets the mode property
  18001. */
  18002. get mode(): NodeMaterialModes;
  18003. /**
  18004. * A free comment about the material
  18005. */
  18006. comment: string;
  18007. /**
  18008. * Create a new node based material
  18009. * @param name defines the material name
  18010. * @param scene defines the hosting scene
  18011. * @param options defines creation option
  18012. */
  18013. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18014. /**
  18015. * Gets the current class name of the material e.g. "NodeMaterial"
  18016. * @returns the class name
  18017. */
  18018. getClassName(): string;
  18019. /**
  18020. * Keep track of the image processing observer to allow dispose and replace.
  18021. */
  18022. private _imageProcessingObserver;
  18023. /**
  18024. * Attaches a new image processing configuration to the Standard Material.
  18025. * @param configuration
  18026. */
  18027. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18028. /**
  18029. * Get a block by its name
  18030. * @param name defines the name of the block to retrieve
  18031. * @returns the required block or null if not found
  18032. */
  18033. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18034. /**
  18035. * Get a block by its name
  18036. * @param predicate defines the predicate used to find the good candidate
  18037. * @returns the required block or null if not found
  18038. */
  18039. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18040. /**
  18041. * Get an input block by its name
  18042. * @param predicate defines the predicate used to find the good candidate
  18043. * @returns the required input block or null if not found
  18044. */
  18045. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18046. /**
  18047. * Gets the list of input blocks attached to this material
  18048. * @returns an array of InputBlocks
  18049. */
  18050. getInputBlocks(): InputBlock[];
  18051. /**
  18052. * Adds a new optimizer to the list of optimizers
  18053. * @param optimizer defines the optimizers to add
  18054. * @returns the current material
  18055. */
  18056. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18057. /**
  18058. * Remove an optimizer from the list of optimizers
  18059. * @param optimizer defines the optimizers to remove
  18060. * @returns the current material
  18061. */
  18062. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18063. /**
  18064. * Add a new block to the list of output nodes
  18065. * @param node defines the node to add
  18066. * @returns the current material
  18067. */
  18068. addOutputNode(node: NodeMaterialBlock): this;
  18069. /**
  18070. * Remove a block from the list of root nodes
  18071. * @param node defines the node to remove
  18072. * @returns the current material
  18073. */
  18074. removeOutputNode(node: NodeMaterialBlock): this;
  18075. private _addVertexOutputNode;
  18076. private _removeVertexOutputNode;
  18077. private _addFragmentOutputNode;
  18078. private _removeFragmentOutputNode;
  18079. /**
  18080. * Specifies if the material will require alpha blending
  18081. * @returns a boolean specifying if alpha blending is needed
  18082. */
  18083. needAlphaBlending(): boolean;
  18084. /**
  18085. * Specifies if this material should be rendered in alpha test mode
  18086. * @returns a boolean specifying if an alpha test is needed.
  18087. */
  18088. needAlphaTesting(): boolean;
  18089. private _initializeBlock;
  18090. private _resetDualBlocks;
  18091. /**
  18092. * Remove a block from the current node material
  18093. * @param block defines the block to remove
  18094. */
  18095. removeBlock(block: NodeMaterialBlock): void;
  18096. /**
  18097. * Build the material and generates the inner effect
  18098. * @param verbose defines if the build should log activity
  18099. */
  18100. build(verbose?: boolean): void;
  18101. /**
  18102. * Runs an otpimization phase to try to improve the shader code
  18103. */
  18104. optimize(): void;
  18105. private _prepareDefinesForAttributes;
  18106. /**
  18107. * Create a post process from the material
  18108. * @param camera The camera to apply the render pass to.
  18109. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18111. * @param engine The engine which the post process will be applied. (default: current engine)
  18112. * @param reusable If the post process can be reused on the same frame. (default: false)
  18113. * @param textureType Type of textures used when performing the post process. (default: 0)
  18114. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18115. * @returns the post process created
  18116. */
  18117. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18118. /**
  18119. * Create the post process effect from the material
  18120. * @param postProcess The post process to create the effect for
  18121. */
  18122. createEffectForPostProcess(postProcess: PostProcess): void;
  18123. private _createEffectForPostProcess;
  18124. /**
  18125. * Create a new procedural texture based on this node material
  18126. * @param size defines the size of the texture
  18127. * @param scene defines the hosting scene
  18128. * @returns the new procedural texture attached to this node material
  18129. */
  18130. createProceduralTexture(size: number | {
  18131. width: number;
  18132. height: number;
  18133. layers?: number;
  18134. }, scene: Scene): Nullable<ProceduralTexture>;
  18135. private _createEffectForParticles;
  18136. private _checkInternals;
  18137. /**
  18138. * Create the effect to be used as the custom effect for a particle system
  18139. * @param particleSystem Particle system to create the effect for
  18140. * @param onCompiled defines a function to call when the effect creation is successful
  18141. * @param onError defines a function to call when the effect creation has failed
  18142. */
  18143. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18144. private _processDefines;
  18145. /**
  18146. * Get if the submesh is ready to be used and all its information available.
  18147. * Child classes can use it to update shaders
  18148. * @param mesh defines the mesh to check
  18149. * @param subMesh defines which submesh to check
  18150. * @param useInstances specifies that instances should be used
  18151. * @returns a boolean indicating that the submesh is ready or not
  18152. */
  18153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18154. /**
  18155. * Get a string representing the shaders built by the current node graph
  18156. */
  18157. get compiledShaders(): string;
  18158. /**
  18159. * Binds the world matrix to the material
  18160. * @param world defines the world transformation matrix
  18161. */
  18162. bindOnlyWorldMatrix(world: Matrix): void;
  18163. /**
  18164. * Binds the submesh to this material by preparing the effect and shader to draw
  18165. * @param world defines the world transformation matrix
  18166. * @param mesh defines the mesh containing the submesh
  18167. * @param subMesh defines the submesh to bind the material to
  18168. */
  18169. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18170. /**
  18171. * Gets the active textures from the material
  18172. * @returns an array of textures
  18173. */
  18174. getActiveTextures(): BaseTexture[];
  18175. /**
  18176. * Gets the list of texture blocks
  18177. * @returns an array of texture blocks
  18178. */
  18179. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18180. /**
  18181. * Specifies if the material uses a texture
  18182. * @param texture defines the texture to check against the material
  18183. * @returns a boolean specifying if the material uses the texture
  18184. */
  18185. hasTexture(texture: BaseTexture): boolean;
  18186. /**
  18187. * Disposes the material
  18188. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18189. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18190. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18191. */
  18192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18193. /** Creates the node editor window. */
  18194. private _createNodeEditor;
  18195. /**
  18196. * Launch the node material editor
  18197. * @param config Define the configuration of the editor
  18198. * @return a promise fulfilled when the node editor is visible
  18199. */
  18200. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18201. /**
  18202. * Clear the current material
  18203. */
  18204. clear(): void;
  18205. /**
  18206. * Clear the current material and set it to a default state
  18207. */
  18208. setToDefault(): void;
  18209. /**
  18210. * Clear the current material and set it to a default state for post process
  18211. */
  18212. setToDefaultPostProcess(): void;
  18213. /**
  18214. * Clear the current material and set it to a default state for procedural texture
  18215. */
  18216. setToDefaultProceduralTexture(): void;
  18217. /**
  18218. * Clear the current material and set it to a default state for particle
  18219. */
  18220. setToDefaultParticle(): void;
  18221. /**
  18222. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18223. * @param url defines the url to load from
  18224. * @returns a promise that will fulfil when the material is fully loaded
  18225. */
  18226. loadAsync(url: string): Promise<void>;
  18227. private _gatherBlocks;
  18228. /**
  18229. * Generate a string containing the code declaration required to create an equivalent of this material
  18230. * @returns a string
  18231. */
  18232. generateCode(): string;
  18233. /**
  18234. * Serializes this material in a JSON representation
  18235. * @returns the serialized material object
  18236. */
  18237. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18238. private _restoreConnections;
  18239. /**
  18240. * Clear the current graph and load a new one from a serialization object
  18241. * @param source defines the JSON representation of the material
  18242. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18243. * @param merge defines whether or not the source must be merged or replace the current content
  18244. */
  18245. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18246. /**
  18247. * Makes a duplicate of the current material.
  18248. * @param name - name to use for the new material.
  18249. */
  18250. clone(name: string): NodeMaterial;
  18251. /**
  18252. * Creates a node material from parsed material data
  18253. * @param source defines the JSON representation of the material
  18254. * @param scene defines the hosting scene
  18255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18256. * @returns a new node material
  18257. */
  18258. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18259. /**
  18260. * Creates a node material from a snippet saved in a remote file
  18261. * @param name defines the name of the material to create
  18262. * @param url defines the url to load from
  18263. * @param scene defines the hosting scene
  18264. * @returns a promise that will resolve to the new node material
  18265. */
  18266. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18267. /**
  18268. * Creates a node material from a snippet saved by the node material editor
  18269. * @param snippetId defines the snippet to load
  18270. * @param scene defines the hosting scene
  18271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18272. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18273. * @returns a promise that will resolve to the new node material
  18274. */
  18275. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18276. /**
  18277. * Creates a new node material set to default basic configuration
  18278. * @param name defines the name of the material
  18279. * @param scene defines the hosting scene
  18280. * @returns a new NodeMaterial
  18281. */
  18282. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18283. }
  18284. }
  18285. declare module BABYLON {
  18286. interface ThinEngine {
  18287. /**
  18288. * Unbind a list of render target textures from the webGL context
  18289. * This is used only when drawBuffer extension or webGL2 are active
  18290. * @param textures defines the render target textures to unbind
  18291. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18292. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18293. */
  18294. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18295. /**
  18296. * Create a multi render target texture
  18297. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18298. * @param size defines the size of the texture
  18299. * @param options defines the creation options
  18300. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18301. * @returns the cube texture as an InternalTexture
  18302. */
  18303. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18304. /**
  18305. * Update the sample count for a given multiple render target texture
  18306. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18307. * @param textures defines the textures to update
  18308. * @param samples defines the sample count to set
  18309. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18310. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18311. */
  18312. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18313. /**
  18314. * Select a subsets of attachments to draw to.
  18315. * @param attachments gl attachments
  18316. */
  18317. bindAttachments(attachments: number[]): void;
  18318. /**
  18319. * Creates a layout object to draw/clear on specific textures in a MRT
  18320. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18321. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18322. */
  18323. buildTextureLayout(textureStatus: boolean[]): number[];
  18324. /**
  18325. * Restores the webgl state to only draw on the main color attachment
  18326. * when the frame buffer associated is the canvas frame buffer
  18327. */
  18328. restoreSingleAttachment(): void;
  18329. /**
  18330. * Restores the webgl state to only draw on the main color attachment
  18331. * when the frame buffer associated is not the canvas frame buffer
  18332. */
  18333. restoreSingleAttachmentForRenderTarget(): void;
  18334. /**
  18335. * Clears a list of attachments
  18336. * @param attachments list of the attachments
  18337. * @param colorMain clear color for the main attachment (the first one)
  18338. * @param colorOthers clear color for the other attachments
  18339. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18340. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18341. */
  18342. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18343. }
  18344. }
  18345. declare module BABYLON {
  18346. /**
  18347. * Creation options of the multi render target texture.
  18348. */
  18349. export interface IMultiRenderTargetOptions {
  18350. /**
  18351. * Define if the texture needs to create mip maps after render.
  18352. */
  18353. generateMipMaps?: boolean;
  18354. /**
  18355. * Define the types of all the draw buffers we want to create
  18356. */
  18357. types?: number[];
  18358. /**
  18359. * Define the sampling modes of all the draw buffers we want to create
  18360. */
  18361. samplingModes?: number[];
  18362. /**
  18363. * Define if a depth buffer is required
  18364. */
  18365. generateDepthBuffer?: boolean;
  18366. /**
  18367. * Define if a stencil buffer is required
  18368. */
  18369. generateStencilBuffer?: boolean;
  18370. /**
  18371. * Define if a depth texture is required instead of a depth buffer
  18372. */
  18373. generateDepthTexture?: boolean;
  18374. /**
  18375. * Define the number of desired draw buffers
  18376. */
  18377. textureCount?: number;
  18378. /**
  18379. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18380. */
  18381. doNotChangeAspectRatio?: boolean;
  18382. /**
  18383. * Define the default type of the buffers we are creating
  18384. */
  18385. defaultType?: number;
  18386. /**
  18387. * Define the default type of the buffers we are creating
  18388. */
  18389. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18390. }
  18391. /**
  18392. * A multi render target, like a render target provides the ability to render to a texture.
  18393. * Unlike the render target, it can render to several draw buffers in one draw.
  18394. * This is specially interesting in deferred rendering or for any effects requiring more than
  18395. * just one color from a single pass.
  18396. */
  18397. export class MultiRenderTarget extends RenderTargetTexture {
  18398. private _internalTextures;
  18399. private _textures;
  18400. private _multiRenderTargetOptions;
  18401. private _count;
  18402. private _drawOnlyOnFirstAttachmentByDefault;
  18403. /**
  18404. * Get if draw buffers are currently supported by the used hardware and browser.
  18405. */
  18406. get isSupported(): boolean;
  18407. /**
  18408. * Get the list of textures generated by the multi render target.
  18409. */
  18410. get textures(): Texture[];
  18411. /**
  18412. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18413. */
  18414. get count(): number;
  18415. /**
  18416. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18417. */
  18418. get depthTexture(): Texture;
  18419. /**
  18420. * Set the wrapping mode on U of all the textures we are rendering to.
  18421. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18422. */
  18423. set wrapU(wrap: number);
  18424. /**
  18425. * Set the wrapping mode on V of all the textures we are rendering to.
  18426. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18427. */
  18428. set wrapV(wrap: number);
  18429. /**
  18430. * Instantiate a new multi render target texture.
  18431. * A multi render target, like a render target provides the ability to render to a texture.
  18432. * Unlike the render target, it can render to several draw buffers in one draw.
  18433. * This is specially interesting in deferred rendering or for any effects requiring more than
  18434. * just one color from a single pass.
  18435. * @param name Define the name of the texture
  18436. * @param size Define the size of the buffers to render to
  18437. * @param count Define the number of target we are rendering into
  18438. * @param scene Define the scene the texture belongs to
  18439. * @param options Define the options used to create the multi render target
  18440. */
  18441. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18442. private _initTypes;
  18443. /** @hidden */
  18444. _rebuild(forceFullRebuild?: boolean): void;
  18445. private _createInternalTextures;
  18446. private _createTextures;
  18447. /**
  18448. * Replaces a texture within the MRT.
  18449. * @param texture The new texture to insert in the MRT
  18450. * @param index The index of the texture to replace
  18451. */
  18452. replaceTexture(texture: Texture, index: number): void;
  18453. /**
  18454. * Define the number of samples used if MSAA is enabled.
  18455. */
  18456. get samples(): number;
  18457. set samples(value: number);
  18458. /**
  18459. * Resize all the textures in the multi render target.
  18460. * Be careful as it will recreate all the data in the new texture.
  18461. * @param size Define the new size
  18462. */
  18463. resize(size: any): void;
  18464. /**
  18465. * Changes the number of render targets in this MRT
  18466. * Be careful as it will recreate all the data in the new texture.
  18467. * @param count new texture count
  18468. * @param options Specifies texture types and sampling modes for new textures
  18469. */
  18470. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18471. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18472. /**
  18473. * Dispose the render targets and their associated resources
  18474. */
  18475. dispose(): void;
  18476. /**
  18477. * Release all the underlying texture used as draw buffers.
  18478. */
  18479. releaseInternalTextures(): void;
  18480. }
  18481. }
  18482. declare module BABYLON {
  18483. /** @hidden */
  18484. export var imageProcessingPixelShader: {
  18485. name: string;
  18486. shader: string;
  18487. };
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * ImageProcessingPostProcess
  18492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18493. */
  18494. export class ImageProcessingPostProcess extends PostProcess {
  18495. /**
  18496. * Default configuration related to image processing available in the PBR Material.
  18497. */
  18498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18499. /**
  18500. * Gets the image processing configuration used either in this material.
  18501. */
  18502. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18503. /**
  18504. * Sets the Default image processing configuration used either in the this material.
  18505. *
  18506. * If sets to null, the scene one is in use.
  18507. */
  18508. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18509. /**
  18510. * Keep track of the image processing observer to allow dispose and replace.
  18511. */
  18512. private _imageProcessingObserver;
  18513. /**
  18514. * Attaches a new image processing configuration to the PBR Material.
  18515. * @param configuration
  18516. */
  18517. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18518. /**
  18519. * If the post process is supported.
  18520. */
  18521. get isSupported(): boolean;
  18522. /**
  18523. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18524. */
  18525. get colorCurves(): Nullable<ColorCurves>;
  18526. /**
  18527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18528. */
  18529. set colorCurves(value: Nullable<ColorCurves>);
  18530. /**
  18531. * Gets whether the color curves effect is enabled.
  18532. */
  18533. get colorCurvesEnabled(): boolean;
  18534. /**
  18535. * Sets whether the color curves effect is enabled.
  18536. */
  18537. set colorCurvesEnabled(value: boolean);
  18538. /**
  18539. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18540. */
  18541. get colorGradingTexture(): Nullable<BaseTexture>;
  18542. /**
  18543. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18544. */
  18545. set colorGradingTexture(value: Nullable<BaseTexture>);
  18546. /**
  18547. * Gets whether the color grading effect is enabled.
  18548. */
  18549. get colorGradingEnabled(): boolean;
  18550. /**
  18551. * Gets whether the color grading effect is enabled.
  18552. */
  18553. set colorGradingEnabled(value: boolean);
  18554. /**
  18555. * Gets exposure used in the effect.
  18556. */
  18557. get exposure(): number;
  18558. /**
  18559. * Sets exposure used in the effect.
  18560. */
  18561. set exposure(value: number);
  18562. /**
  18563. * Gets whether tonemapping is enabled or not.
  18564. */
  18565. get toneMappingEnabled(): boolean;
  18566. /**
  18567. * Sets whether tonemapping is enabled or not
  18568. */
  18569. set toneMappingEnabled(value: boolean);
  18570. /**
  18571. * Gets the type of tone mapping effect.
  18572. */
  18573. get toneMappingType(): number;
  18574. /**
  18575. * Sets the type of tone mapping effect.
  18576. */
  18577. set toneMappingType(value: number);
  18578. /**
  18579. * Gets contrast used in the effect.
  18580. */
  18581. get contrast(): number;
  18582. /**
  18583. * Sets contrast used in the effect.
  18584. */
  18585. set contrast(value: number);
  18586. /**
  18587. * Gets Vignette stretch size.
  18588. */
  18589. get vignetteStretch(): number;
  18590. /**
  18591. * Sets Vignette stretch size.
  18592. */
  18593. set vignetteStretch(value: number);
  18594. /**
  18595. * Gets Vignette centre X Offset.
  18596. */
  18597. get vignetteCentreX(): number;
  18598. /**
  18599. * Sets Vignette centre X Offset.
  18600. */
  18601. set vignetteCentreX(value: number);
  18602. /**
  18603. * Gets Vignette centre Y Offset.
  18604. */
  18605. get vignetteCentreY(): number;
  18606. /**
  18607. * Sets Vignette centre Y Offset.
  18608. */
  18609. set vignetteCentreY(value: number);
  18610. /**
  18611. * Gets Vignette weight or intensity of the vignette effect.
  18612. */
  18613. get vignetteWeight(): number;
  18614. /**
  18615. * Sets Vignette weight or intensity of the vignette effect.
  18616. */
  18617. set vignetteWeight(value: number);
  18618. /**
  18619. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18620. * if vignetteEnabled is set to true.
  18621. */
  18622. get vignetteColor(): Color4;
  18623. /**
  18624. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18625. * if vignetteEnabled is set to true.
  18626. */
  18627. set vignetteColor(value: Color4);
  18628. /**
  18629. * Gets Camera field of view used by the Vignette effect.
  18630. */
  18631. get vignetteCameraFov(): number;
  18632. /**
  18633. * Sets Camera field of view used by the Vignette effect.
  18634. */
  18635. set vignetteCameraFov(value: number);
  18636. /**
  18637. * Gets the vignette blend mode allowing different kind of effect.
  18638. */
  18639. get vignetteBlendMode(): number;
  18640. /**
  18641. * Sets the vignette blend mode allowing different kind of effect.
  18642. */
  18643. set vignetteBlendMode(value: number);
  18644. /**
  18645. * Gets whether the vignette effect is enabled.
  18646. */
  18647. get vignetteEnabled(): boolean;
  18648. /**
  18649. * Sets whether the vignette effect is enabled.
  18650. */
  18651. set vignetteEnabled(value: boolean);
  18652. private _fromLinearSpace;
  18653. /**
  18654. * Gets whether the input of the processing is in Gamma or Linear Space.
  18655. */
  18656. get fromLinearSpace(): boolean;
  18657. /**
  18658. * Sets whether the input of the processing is in Gamma or Linear Space.
  18659. */
  18660. set fromLinearSpace(value: boolean);
  18661. /**
  18662. * Defines cache preventing GC.
  18663. */
  18664. private _defines;
  18665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18666. /**
  18667. * "ImageProcessingPostProcess"
  18668. * @returns "ImageProcessingPostProcess"
  18669. */
  18670. getClassName(): string;
  18671. /**
  18672. * @hidden
  18673. */
  18674. _updateParameters(): void;
  18675. dispose(camera?: Camera): void;
  18676. }
  18677. }
  18678. declare module BABYLON {
  18679. /**
  18680. * A multi render target designed to render the prepass.
  18681. * Prepass is a scene component used to render information in multiple textures
  18682. * alongside with the scene materials rendering.
  18683. * Note : This is an internal class, and you should NOT need to instanciate this.
  18684. * Only the `PrePassRenderer` should instanciate this class.
  18685. * It is more likely that you need a regular `MultiRenderTarget`
  18686. * @hidden
  18687. */
  18688. export class PrePassRenderTarget extends MultiRenderTarget {
  18689. /**
  18690. * @hidden
  18691. */
  18692. _beforeCompositionPostProcesses: PostProcess[];
  18693. /**
  18694. * Image processing post process for composition
  18695. */
  18696. imageProcessingPostProcess: ImageProcessingPostProcess;
  18697. /**
  18698. * @hidden
  18699. */
  18700. _engine: Engine;
  18701. /**
  18702. * @hidden
  18703. */
  18704. _scene: Scene;
  18705. /**
  18706. * @hidden
  18707. */
  18708. _outputPostProcess: Nullable<PostProcess>;
  18709. /**
  18710. * @hidden
  18711. */
  18712. _internalTextureDirty: boolean;
  18713. /**
  18714. * Is this render target enabled for prepass rendering
  18715. */
  18716. enabled: boolean;
  18717. /**
  18718. * Render target associated with this prePassRenderTarget
  18719. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18720. */
  18721. renderTargetTexture: Nullable<RenderTargetTexture>;
  18722. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18723. /**
  18724. * Creates a composition effect for this RT
  18725. * @hidden
  18726. */
  18727. _createCompositionEffect(): void;
  18728. /**
  18729. * Checks that the size of this RT is still adapted to the desired render size.
  18730. * @hidden
  18731. */
  18732. _checkSize(): void;
  18733. /**
  18734. * Changes the number of render targets in this MRT
  18735. * Be careful as it will recreate all the data in the new texture.
  18736. * @param count new texture count
  18737. * @param options Specifies texture types and sampling modes for new textures
  18738. */
  18739. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18740. /**
  18741. * Resets the post processes chains applied to this RT.
  18742. * @hidden
  18743. */
  18744. _resetPostProcessChain(): void;
  18745. /**
  18746. * Diposes this render target
  18747. */
  18748. dispose(): void;
  18749. }
  18750. }
  18751. declare module BABYLON {
  18752. /**
  18753. * Interface for defining prepass effects in the prepass post-process pipeline
  18754. */
  18755. export interface PrePassEffectConfiguration {
  18756. /**
  18757. * Name of the effect
  18758. */
  18759. name: string;
  18760. /**
  18761. * Post process to attach for this effect
  18762. */
  18763. postProcess?: PostProcess;
  18764. /**
  18765. * Textures required in the MRT
  18766. */
  18767. texturesRequired: number[];
  18768. /**
  18769. * Is the effect enabled
  18770. */
  18771. enabled: boolean;
  18772. /**
  18773. * Does the output of this prepass need to go through imageprocessing
  18774. */
  18775. needsImageProcessing?: boolean;
  18776. /**
  18777. * Disposes the effect configuration
  18778. */
  18779. dispose?: () => void;
  18780. /**
  18781. * Creates the associated post process
  18782. */
  18783. createPostProcess?: () => PostProcess;
  18784. }
  18785. }
  18786. declare module BABYLON {
  18787. /**
  18788. * Options to be used when creating a FresnelParameters.
  18789. */
  18790. export type IFresnelParametersCreationOptions = {
  18791. /**
  18792. * Define the color used on edges (grazing angle)
  18793. */
  18794. leftColor?: Color3;
  18795. /**
  18796. * Define the color used on center
  18797. */
  18798. rightColor?: Color3;
  18799. /**
  18800. * Define bias applied to computed fresnel term
  18801. */
  18802. bias?: number;
  18803. /**
  18804. * Defined the power exponent applied to fresnel term
  18805. */
  18806. power?: number;
  18807. /**
  18808. * Define if the fresnel effect is enable or not.
  18809. */
  18810. isEnabled?: boolean;
  18811. };
  18812. /**
  18813. * Serialized format for FresnelParameters.
  18814. */
  18815. export type IFresnelParametersSerialized = {
  18816. /**
  18817. * Define the color used on edges (grazing angle) [as an array]
  18818. */
  18819. leftColor: number[];
  18820. /**
  18821. * Define the color used on center [as an array]
  18822. */
  18823. rightColor: number[];
  18824. /**
  18825. * Define bias applied to computed fresnel term
  18826. */
  18827. bias: number;
  18828. /**
  18829. * Defined the power exponent applied to fresnel term
  18830. */
  18831. power?: number;
  18832. /**
  18833. * Define if the fresnel effect is enable or not.
  18834. */
  18835. isEnabled: boolean;
  18836. };
  18837. /**
  18838. * This represents all the required information to add a fresnel effect on a material:
  18839. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18840. */
  18841. export class FresnelParameters {
  18842. private _isEnabled;
  18843. /**
  18844. * Define if the fresnel effect is enable or not.
  18845. */
  18846. get isEnabled(): boolean;
  18847. set isEnabled(value: boolean);
  18848. /**
  18849. * Define the color used on edges (grazing angle)
  18850. */
  18851. leftColor: Color3;
  18852. /**
  18853. * Define the color used on center
  18854. */
  18855. rightColor: Color3;
  18856. /**
  18857. * Define bias applied to computed fresnel term
  18858. */
  18859. bias: number;
  18860. /**
  18861. * Defined the power exponent applied to fresnel term
  18862. */
  18863. power: number;
  18864. /**
  18865. * Creates a new FresnelParameters object.
  18866. *
  18867. * @param options provide your own settings to optionally to override defaults
  18868. */
  18869. constructor(options?: IFresnelParametersCreationOptions);
  18870. /**
  18871. * Clones the current fresnel and its values
  18872. * @returns a clone fresnel configuration
  18873. */
  18874. clone(): FresnelParameters;
  18875. /**
  18876. * Determines equality between FresnelParameters objects
  18877. * @param otherFresnelParameters defines the second operand
  18878. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18879. */
  18880. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18881. /**
  18882. * Serializes the current fresnel parameters to a JSON representation.
  18883. * @return the JSON serialization
  18884. */
  18885. serialize(): IFresnelParametersSerialized;
  18886. /**
  18887. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18888. * @param parsedFresnelParameters Define the JSON representation
  18889. * @returns the parsed parameters
  18890. */
  18891. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18892. }
  18893. }
  18894. declare module BABYLON {
  18895. /**
  18896. * This groups all the flags used to control the materials channel.
  18897. */
  18898. export class MaterialFlags {
  18899. private static _DiffuseTextureEnabled;
  18900. /**
  18901. * Are diffuse textures enabled in the application.
  18902. */
  18903. static get DiffuseTextureEnabled(): boolean;
  18904. static set DiffuseTextureEnabled(value: boolean);
  18905. private static _DetailTextureEnabled;
  18906. /**
  18907. * Are detail textures enabled in the application.
  18908. */
  18909. static get DetailTextureEnabled(): boolean;
  18910. static set DetailTextureEnabled(value: boolean);
  18911. private static _AmbientTextureEnabled;
  18912. /**
  18913. * Are ambient textures enabled in the application.
  18914. */
  18915. static get AmbientTextureEnabled(): boolean;
  18916. static set AmbientTextureEnabled(value: boolean);
  18917. private static _OpacityTextureEnabled;
  18918. /**
  18919. * Are opacity textures enabled in the application.
  18920. */
  18921. static get OpacityTextureEnabled(): boolean;
  18922. static set OpacityTextureEnabled(value: boolean);
  18923. private static _ReflectionTextureEnabled;
  18924. /**
  18925. * Are reflection textures enabled in the application.
  18926. */
  18927. static get ReflectionTextureEnabled(): boolean;
  18928. static set ReflectionTextureEnabled(value: boolean);
  18929. private static _EmissiveTextureEnabled;
  18930. /**
  18931. * Are emissive textures enabled in the application.
  18932. */
  18933. static get EmissiveTextureEnabled(): boolean;
  18934. static set EmissiveTextureEnabled(value: boolean);
  18935. private static _SpecularTextureEnabled;
  18936. /**
  18937. * Are specular textures enabled in the application.
  18938. */
  18939. static get SpecularTextureEnabled(): boolean;
  18940. static set SpecularTextureEnabled(value: boolean);
  18941. private static _BumpTextureEnabled;
  18942. /**
  18943. * Are bump textures enabled in the application.
  18944. */
  18945. static get BumpTextureEnabled(): boolean;
  18946. static set BumpTextureEnabled(value: boolean);
  18947. private static _LightmapTextureEnabled;
  18948. /**
  18949. * Are lightmap textures enabled in the application.
  18950. */
  18951. static get LightmapTextureEnabled(): boolean;
  18952. static set LightmapTextureEnabled(value: boolean);
  18953. private static _RefractionTextureEnabled;
  18954. /**
  18955. * Are refraction textures enabled in the application.
  18956. */
  18957. static get RefractionTextureEnabled(): boolean;
  18958. static set RefractionTextureEnabled(value: boolean);
  18959. private static _ColorGradingTextureEnabled;
  18960. /**
  18961. * Are color grading textures enabled in the application.
  18962. */
  18963. static get ColorGradingTextureEnabled(): boolean;
  18964. static set ColorGradingTextureEnabled(value: boolean);
  18965. private static _FresnelEnabled;
  18966. /**
  18967. * Are fresnels enabled in the application.
  18968. */
  18969. static get FresnelEnabled(): boolean;
  18970. static set FresnelEnabled(value: boolean);
  18971. private static _ClearCoatTextureEnabled;
  18972. /**
  18973. * Are clear coat textures enabled in the application.
  18974. */
  18975. static get ClearCoatTextureEnabled(): boolean;
  18976. static set ClearCoatTextureEnabled(value: boolean);
  18977. private static _ClearCoatBumpTextureEnabled;
  18978. /**
  18979. * Are clear coat bump textures enabled in the application.
  18980. */
  18981. static get ClearCoatBumpTextureEnabled(): boolean;
  18982. static set ClearCoatBumpTextureEnabled(value: boolean);
  18983. private static _ClearCoatTintTextureEnabled;
  18984. /**
  18985. * Are clear coat tint textures enabled in the application.
  18986. */
  18987. static get ClearCoatTintTextureEnabled(): boolean;
  18988. static set ClearCoatTintTextureEnabled(value: boolean);
  18989. private static _SheenTextureEnabled;
  18990. /**
  18991. * Are sheen textures enabled in the application.
  18992. */
  18993. static get SheenTextureEnabled(): boolean;
  18994. static set SheenTextureEnabled(value: boolean);
  18995. private static _AnisotropicTextureEnabled;
  18996. /**
  18997. * Are anisotropic textures enabled in the application.
  18998. */
  18999. static get AnisotropicTextureEnabled(): boolean;
  19000. static set AnisotropicTextureEnabled(value: boolean);
  19001. private static _ThicknessTextureEnabled;
  19002. /**
  19003. * Are thickness textures enabled in the application.
  19004. */
  19005. static get ThicknessTextureEnabled(): boolean;
  19006. static set ThicknessTextureEnabled(value: boolean);
  19007. }
  19008. }
  19009. declare module BABYLON {
  19010. /** @hidden */
  19011. export var defaultFragmentDeclaration: {
  19012. name: string;
  19013. shader: string;
  19014. };
  19015. }
  19016. declare module BABYLON {
  19017. /** @hidden */
  19018. export var sceneUboDeclaration: {
  19019. name: string;
  19020. shader: string;
  19021. };
  19022. }
  19023. declare module BABYLON {
  19024. /** @hidden */
  19025. export var meshUboDeclaration: {
  19026. name: string;
  19027. shader: string;
  19028. };
  19029. }
  19030. declare module BABYLON {
  19031. /** @hidden */
  19032. export var defaultUboDeclaration: {
  19033. name: string;
  19034. shader: string;
  19035. };
  19036. }
  19037. declare module BABYLON {
  19038. /** @hidden */
  19039. export var prePassDeclaration: {
  19040. name: string;
  19041. shader: string;
  19042. };
  19043. }
  19044. declare module BABYLON {
  19045. /** @hidden */
  19046. export var lightFragmentDeclaration: {
  19047. name: string;
  19048. shader: string;
  19049. };
  19050. }
  19051. declare module BABYLON {
  19052. /** @hidden */
  19053. export var lightUboDeclaration: {
  19054. name: string;
  19055. shader: string;
  19056. };
  19057. }
  19058. declare module BABYLON {
  19059. /** @hidden */
  19060. export var lightsFragmentFunctions: {
  19061. name: string;
  19062. shader: string;
  19063. };
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var shadowsFragmentFunctions: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /** @hidden */
  19074. export var fresnelFunction: {
  19075. name: string;
  19076. shader: string;
  19077. };
  19078. }
  19079. declare module BABYLON {
  19080. /** @hidden */
  19081. export var bumpFragmentMainFunctions: {
  19082. name: string;
  19083. shader: string;
  19084. };
  19085. }
  19086. declare module BABYLON {
  19087. /** @hidden */
  19088. export var bumpFragmentFunctions: {
  19089. name: string;
  19090. shader: string;
  19091. };
  19092. }
  19093. declare module BABYLON {
  19094. /** @hidden */
  19095. export var logDepthDeclaration: {
  19096. name: string;
  19097. shader: string;
  19098. };
  19099. }
  19100. declare module BABYLON {
  19101. /** @hidden */
  19102. export var fogFragmentDeclaration: {
  19103. name: string;
  19104. shader: string;
  19105. };
  19106. }
  19107. declare module BABYLON {
  19108. /** @hidden */
  19109. export var bumpFragment: {
  19110. name: string;
  19111. shader: string;
  19112. };
  19113. }
  19114. declare module BABYLON {
  19115. /** @hidden */
  19116. export var depthPrePass: {
  19117. name: string;
  19118. shader: string;
  19119. };
  19120. }
  19121. declare module BABYLON {
  19122. /** @hidden */
  19123. export var lightFragment: {
  19124. name: string;
  19125. shader: string;
  19126. };
  19127. }
  19128. declare module BABYLON {
  19129. /** @hidden */
  19130. export var logDepthFragment: {
  19131. name: string;
  19132. shader: string;
  19133. };
  19134. }
  19135. declare module BABYLON {
  19136. /** @hidden */
  19137. export var fogFragment: {
  19138. name: string;
  19139. shader: string;
  19140. };
  19141. }
  19142. declare module BABYLON {
  19143. /** @hidden */
  19144. export var defaultPixelShader: {
  19145. name: string;
  19146. shader: string;
  19147. };
  19148. }
  19149. declare module BABYLON {
  19150. /** @hidden */
  19151. export var defaultVertexDeclaration: {
  19152. name: string;
  19153. shader: string;
  19154. };
  19155. }
  19156. declare module BABYLON {
  19157. /** @hidden */
  19158. export var bonesDeclaration: {
  19159. name: string;
  19160. shader: string;
  19161. };
  19162. }
  19163. declare module BABYLON {
  19164. /** @hidden */
  19165. export var prePassVertexDeclaration: {
  19166. name: string;
  19167. shader: string;
  19168. };
  19169. }
  19170. declare module BABYLON {
  19171. /** @hidden */
  19172. export var bumpVertexDeclaration: {
  19173. name: string;
  19174. shader: string;
  19175. };
  19176. }
  19177. declare module BABYLON {
  19178. /** @hidden */
  19179. export var fogVertexDeclaration: {
  19180. name: string;
  19181. shader: string;
  19182. };
  19183. }
  19184. declare module BABYLON {
  19185. /** @hidden */
  19186. export var lightVxFragmentDeclaration: {
  19187. name: string;
  19188. shader: string;
  19189. };
  19190. }
  19191. declare module BABYLON {
  19192. /** @hidden */
  19193. export var lightVxUboDeclaration: {
  19194. name: string;
  19195. shader: string;
  19196. };
  19197. }
  19198. declare module BABYLON {
  19199. /** @hidden */
  19200. export var morphTargetsVertexGlobalDeclaration: {
  19201. name: string;
  19202. shader: string;
  19203. };
  19204. }
  19205. declare module BABYLON {
  19206. /** @hidden */
  19207. export var morphTargetsVertexDeclaration: {
  19208. name: string;
  19209. shader: string;
  19210. };
  19211. }
  19212. declare module BABYLON {
  19213. /** @hidden */
  19214. export var morphTargetsVertex: {
  19215. name: string;
  19216. shader: string;
  19217. };
  19218. }
  19219. declare module BABYLON {
  19220. /** @hidden */
  19221. export var instancesVertex: {
  19222. name: string;
  19223. shader: string;
  19224. };
  19225. }
  19226. declare module BABYLON {
  19227. /** @hidden */
  19228. export var bonesVertex: {
  19229. name: string;
  19230. shader: string;
  19231. };
  19232. }
  19233. declare module BABYLON {
  19234. /** @hidden */
  19235. export var prePassVertex: {
  19236. name: string;
  19237. shader: string;
  19238. };
  19239. }
  19240. declare module BABYLON {
  19241. /** @hidden */
  19242. export var bumpVertex: {
  19243. name: string;
  19244. shader: string;
  19245. };
  19246. }
  19247. declare module BABYLON {
  19248. /** @hidden */
  19249. export var fogVertex: {
  19250. name: string;
  19251. shader: string;
  19252. };
  19253. }
  19254. declare module BABYLON {
  19255. /** @hidden */
  19256. export var shadowsVertex: {
  19257. name: string;
  19258. shader: string;
  19259. };
  19260. }
  19261. declare module BABYLON {
  19262. /** @hidden */
  19263. export var pointCloudVertex: {
  19264. name: string;
  19265. shader: string;
  19266. };
  19267. }
  19268. declare module BABYLON {
  19269. /** @hidden */
  19270. export var logDepthVertex: {
  19271. name: string;
  19272. shader: string;
  19273. };
  19274. }
  19275. declare module BABYLON {
  19276. /** @hidden */
  19277. export var defaultVertexShader: {
  19278. name: string;
  19279. shader: string;
  19280. };
  19281. }
  19282. declare module BABYLON {
  19283. /**
  19284. * @hidden
  19285. */
  19286. export interface IMaterialDetailMapDefines {
  19287. DETAIL: boolean;
  19288. DETAILDIRECTUV: number;
  19289. DETAIL_NORMALBLENDMETHOD: number;
  19290. /** @hidden */
  19291. _areTexturesDirty: boolean;
  19292. }
  19293. /**
  19294. * Define the code related to the detail map parameters of a material
  19295. *
  19296. * Inspired from:
  19297. * 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
  19298. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19299. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19300. */
  19301. export class DetailMapConfiguration {
  19302. private _texture;
  19303. /**
  19304. * The detail texture of the material.
  19305. */
  19306. texture: Nullable<BaseTexture>;
  19307. /**
  19308. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19309. * Bigger values mean stronger blending
  19310. */
  19311. diffuseBlendLevel: number;
  19312. /**
  19313. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19314. * Bigger values mean stronger blending. Only used with PBR materials
  19315. */
  19316. roughnessBlendLevel: number;
  19317. /**
  19318. * Defines how strong the bump effect from the detail map is
  19319. * Bigger values mean stronger effect
  19320. */
  19321. bumpLevel: number;
  19322. private _normalBlendMethod;
  19323. /**
  19324. * The method used to blend the bump and detail normals together
  19325. */
  19326. normalBlendMethod: number;
  19327. private _isEnabled;
  19328. /**
  19329. * Enable or disable the detail map on this material
  19330. */
  19331. isEnabled: boolean;
  19332. /** @hidden */
  19333. private _internalMarkAllSubMeshesAsTexturesDirty;
  19334. /** @hidden */
  19335. _markAllSubMeshesAsTexturesDirty(): void;
  19336. /**
  19337. * Instantiate a new detail map
  19338. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19339. */
  19340. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19341. /**
  19342. * Gets whether the submesh is ready to be used or not.
  19343. * @param defines the list of "defines" to update.
  19344. * @param scene defines the scene the material belongs to.
  19345. * @returns - boolean indicating that the submesh is ready or not.
  19346. */
  19347. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19348. /**
  19349. * Update the defines for detail map usage
  19350. * @param defines the list of "defines" to update.
  19351. * @param scene defines the scene the material belongs to.
  19352. */
  19353. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19354. /**
  19355. * Binds the material data.
  19356. * @param uniformBuffer defines the Uniform buffer to fill in.
  19357. * @param scene defines the scene the material belongs to.
  19358. * @param isFrozen defines whether the material is frozen or not.
  19359. */
  19360. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19361. /**
  19362. * Checks to see if a texture is used in the material.
  19363. * @param texture - Base texture to use.
  19364. * @returns - Boolean specifying if a texture is used in the material.
  19365. */
  19366. hasTexture(texture: BaseTexture): boolean;
  19367. /**
  19368. * Returns an array of the actively used textures.
  19369. * @param activeTextures Array of BaseTextures
  19370. */
  19371. getActiveTextures(activeTextures: BaseTexture[]): void;
  19372. /**
  19373. * Returns the animatable textures.
  19374. * @param animatables Array of animatable textures.
  19375. */
  19376. getAnimatables(animatables: IAnimatable[]): void;
  19377. /**
  19378. * Disposes the resources of the material.
  19379. * @param forceDisposeTextures - Forces the disposal of all textures.
  19380. */
  19381. dispose(forceDisposeTextures?: boolean): void;
  19382. /**
  19383. * Get the current class name useful for serialization or dynamic coding.
  19384. * @returns "DetailMap"
  19385. */
  19386. getClassName(): string;
  19387. /**
  19388. * Add the required uniforms to the current list.
  19389. * @param uniforms defines the current uniform list.
  19390. */
  19391. static AddUniforms(uniforms: string[]): void;
  19392. /**
  19393. * Add the required samplers to the current list.
  19394. * @param samplers defines the current sampler list.
  19395. */
  19396. static AddSamplers(samplers: string[]): void;
  19397. /**
  19398. * Add the required uniforms to the current buffer.
  19399. * @param uniformBuffer defines the current uniform buffer.
  19400. */
  19401. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19402. /**
  19403. * Makes a duplicate of the current instance into another one.
  19404. * @param detailMap define the instance where to copy the info
  19405. */
  19406. copyTo(detailMap: DetailMapConfiguration): void;
  19407. /**
  19408. * Serializes this detail map instance
  19409. * @returns - An object with the serialized instance.
  19410. */
  19411. serialize(): any;
  19412. /**
  19413. * Parses a detail map setting from a serialized object.
  19414. * @param source - Serialized object.
  19415. * @param scene Defines the scene we are parsing for
  19416. * @param rootUrl Defines the rootUrl to load from
  19417. */
  19418. parse(source: any, scene: Scene, rootUrl: string): void;
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. /** @hidden */
  19423. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19424. MAINUV1: boolean;
  19425. MAINUV2: boolean;
  19426. DIFFUSE: boolean;
  19427. DIFFUSEDIRECTUV: number;
  19428. DETAIL: boolean;
  19429. DETAILDIRECTUV: number;
  19430. DETAIL_NORMALBLENDMETHOD: number;
  19431. AMBIENT: boolean;
  19432. AMBIENTDIRECTUV: number;
  19433. OPACITY: boolean;
  19434. OPACITYDIRECTUV: number;
  19435. OPACITYRGB: boolean;
  19436. REFLECTION: boolean;
  19437. EMISSIVE: boolean;
  19438. EMISSIVEDIRECTUV: number;
  19439. SPECULAR: boolean;
  19440. SPECULARDIRECTUV: number;
  19441. BUMP: boolean;
  19442. BUMPDIRECTUV: number;
  19443. PARALLAX: boolean;
  19444. PARALLAXOCCLUSION: boolean;
  19445. SPECULAROVERALPHA: boolean;
  19446. CLIPPLANE: boolean;
  19447. CLIPPLANE2: boolean;
  19448. CLIPPLANE3: boolean;
  19449. CLIPPLANE4: boolean;
  19450. CLIPPLANE5: boolean;
  19451. CLIPPLANE6: boolean;
  19452. ALPHATEST: boolean;
  19453. DEPTHPREPASS: boolean;
  19454. ALPHAFROMDIFFUSE: boolean;
  19455. POINTSIZE: boolean;
  19456. FOG: boolean;
  19457. SPECULARTERM: boolean;
  19458. DIFFUSEFRESNEL: boolean;
  19459. OPACITYFRESNEL: boolean;
  19460. REFLECTIONFRESNEL: boolean;
  19461. REFRACTIONFRESNEL: boolean;
  19462. EMISSIVEFRESNEL: boolean;
  19463. FRESNEL: boolean;
  19464. NORMAL: boolean;
  19465. UV1: boolean;
  19466. UV2: boolean;
  19467. VERTEXCOLOR: boolean;
  19468. VERTEXALPHA: boolean;
  19469. NUM_BONE_INFLUENCERS: number;
  19470. BonesPerMesh: number;
  19471. BONETEXTURE: boolean;
  19472. BONES_VELOCITY_ENABLED: boolean;
  19473. INSTANCES: boolean;
  19474. THIN_INSTANCES: boolean;
  19475. GLOSSINESS: boolean;
  19476. ROUGHNESS: boolean;
  19477. EMISSIVEASILLUMINATION: boolean;
  19478. LINKEMISSIVEWITHDIFFUSE: boolean;
  19479. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19480. LIGHTMAP: boolean;
  19481. LIGHTMAPDIRECTUV: number;
  19482. OBJECTSPACE_NORMALMAP: boolean;
  19483. USELIGHTMAPASSHADOWMAP: boolean;
  19484. REFLECTIONMAP_3D: boolean;
  19485. REFLECTIONMAP_SPHERICAL: boolean;
  19486. REFLECTIONMAP_PLANAR: boolean;
  19487. REFLECTIONMAP_CUBIC: boolean;
  19488. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19489. REFLECTIONMAP_PROJECTION: boolean;
  19490. REFLECTIONMAP_SKYBOX: boolean;
  19491. REFLECTIONMAP_EXPLICIT: boolean;
  19492. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19493. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19494. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19495. REFLECTIONMAP_OPPOSITEZ: boolean;
  19496. INVERTCUBICMAP: boolean;
  19497. LOGARITHMICDEPTH: boolean;
  19498. REFRACTION: boolean;
  19499. REFRACTIONMAP_3D: boolean;
  19500. REFLECTIONOVERALPHA: boolean;
  19501. TWOSIDEDLIGHTING: boolean;
  19502. SHADOWFLOAT: boolean;
  19503. MORPHTARGETS: boolean;
  19504. MORPHTARGETS_NORMAL: boolean;
  19505. MORPHTARGETS_TANGENT: boolean;
  19506. MORPHTARGETS_UV: boolean;
  19507. NUM_MORPH_INFLUENCERS: number;
  19508. NONUNIFORMSCALING: boolean;
  19509. PREMULTIPLYALPHA: boolean;
  19510. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19511. ALPHABLEND: boolean;
  19512. PREPASS: boolean;
  19513. PREPASS_IRRADIANCE: boolean;
  19514. PREPASS_IRRADIANCE_INDEX: number;
  19515. PREPASS_ALBEDO: boolean;
  19516. PREPASS_ALBEDO_INDEX: number;
  19517. PREPASS_DEPTH: boolean;
  19518. PREPASS_DEPTH_INDEX: number;
  19519. PREPASS_NORMAL: boolean;
  19520. PREPASS_NORMAL_INDEX: number;
  19521. PREPASS_POSITION: boolean;
  19522. PREPASS_POSITION_INDEX: number;
  19523. PREPASS_VELOCITY: boolean;
  19524. PREPASS_VELOCITY_INDEX: number;
  19525. PREPASS_REFLECTIVITY: boolean;
  19526. PREPASS_REFLECTIVITY_INDEX: number;
  19527. SCENE_MRT_COUNT: number;
  19528. RGBDLIGHTMAP: boolean;
  19529. RGBDREFLECTION: boolean;
  19530. RGBDREFRACTION: boolean;
  19531. IMAGEPROCESSING: boolean;
  19532. VIGNETTE: boolean;
  19533. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19534. VIGNETTEBLENDMODEOPAQUE: boolean;
  19535. TONEMAPPING: boolean;
  19536. TONEMAPPING_ACES: boolean;
  19537. CONTRAST: boolean;
  19538. COLORCURVES: boolean;
  19539. COLORGRADING: boolean;
  19540. COLORGRADING3D: boolean;
  19541. SAMPLER3DGREENDEPTH: boolean;
  19542. SAMPLER3DBGRMAP: boolean;
  19543. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19544. MULTIVIEW: boolean;
  19545. /**
  19546. * If the reflection texture on this material is in linear color space
  19547. * @hidden
  19548. */
  19549. IS_REFLECTION_LINEAR: boolean;
  19550. /**
  19551. * If the refraction texture on this material is in linear color space
  19552. * @hidden
  19553. */
  19554. IS_REFRACTION_LINEAR: boolean;
  19555. EXPOSURE: boolean;
  19556. constructor();
  19557. setReflectionMode(modeToEnable: string): void;
  19558. }
  19559. /**
  19560. * This is the default material used in Babylon. It is the best trade off between quality
  19561. * and performances.
  19562. * @see https://doc.babylonjs.com/babylon101/materials
  19563. */
  19564. export class StandardMaterial extends PushMaterial {
  19565. private _diffuseTexture;
  19566. /**
  19567. * The basic texture of the material as viewed under a light.
  19568. */
  19569. diffuseTexture: Nullable<BaseTexture>;
  19570. private _ambientTexture;
  19571. /**
  19572. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19573. */
  19574. ambientTexture: Nullable<BaseTexture>;
  19575. private _opacityTexture;
  19576. /**
  19577. * Define the transparency of the material from a texture.
  19578. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19579. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19580. */
  19581. opacityTexture: Nullable<BaseTexture>;
  19582. private _reflectionTexture;
  19583. /**
  19584. * Define the texture used to display the reflection.
  19585. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19586. */
  19587. reflectionTexture: Nullable<BaseTexture>;
  19588. private _emissiveTexture;
  19589. /**
  19590. * Define texture of the material as if self lit.
  19591. * This will be mixed in the final result even in the absence of light.
  19592. */
  19593. emissiveTexture: Nullable<BaseTexture>;
  19594. private _specularTexture;
  19595. /**
  19596. * Define how the color and intensity of the highlight given by the light in the material.
  19597. */
  19598. specularTexture: Nullable<BaseTexture>;
  19599. private _bumpTexture;
  19600. /**
  19601. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19602. * 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.
  19603. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19604. */
  19605. bumpTexture: Nullable<BaseTexture>;
  19606. private _lightmapTexture;
  19607. /**
  19608. * Complex lighting can be computationally expensive to compute at runtime.
  19609. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19610. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19611. */
  19612. lightmapTexture: Nullable<BaseTexture>;
  19613. private _refractionTexture;
  19614. /**
  19615. * Define the texture used to display the refraction.
  19616. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19617. */
  19618. refractionTexture: Nullable<BaseTexture>;
  19619. /**
  19620. * The color of the material lit by the environmental background lighting.
  19621. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19622. */
  19623. ambientColor: Color3;
  19624. /**
  19625. * The basic color of the material as viewed under a light.
  19626. */
  19627. diffuseColor: Color3;
  19628. /**
  19629. * Define how the color and intensity of the highlight given by the light in the material.
  19630. */
  19631. specularColor: Color3;
  19632. /**
  19633. * Define the color of the material as if self lit.
  19634. * This will be mixed in the final result even in the absence of light.
  19635. */
  19636. emissiveColor: Color3;
  19637. /**
  19638. * Defines how sharp are the highlights in the material.
  19639. * The bigger the value the sharper giving a more glossy feeling to the result.
  19640. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19641. */
  19642. specularPower: number;
  19643. private _useAlphaFromDiffuseTexture;
  19644. /**
  19645. * Does the transparency come from the diffuse texture alpha channel.
  19646. */
  19647. useAlphaFromDiffuseTexture: boolean;
  19648. private _useEmissiveAsIllumination;
  19649. /**
  19650. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19651. */
  19652. useEmissiveAsIllumination: boolean;
  19653. private _linkEmissiveWithDiffuse;
  19654. /**
  19655. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19656. * the emissive level when the final color is close to one.
  19657. */
  19658. linkEmissiveWithDiffuse: boolean;
  19659. private _useSpecularOverAlpha;
  19660. /**
  19661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19662. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19663. */
  19664. useSpecularOverAlpha: boolean;
  19665. private _useReflectionOverAlpha;
  19666. /**
  19667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19669. */
  19670. useReflectionOverAlpha: boolean;
  19671. private _disableLighting;
  19672. /**
  19673. * Does lights from the scene impacts this material.
  19674. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19675. */
  19676. disableLighting: boolean;
  19677. private _useObjectSpaceNormalMap;
  19678. /**
  19679. * Allows using an object space normal map (instead of tangent space).
  19680. */
  19681. useObjectSpaceNormalMap: boolean;
  19682. private _useParallax;
  19683. /**
  19684. * Is parallax enabled or not.
  19685. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19686. */
  19687. useParallax: boolean;
  19688. private _useParallaxOcclusion;
  19689. /**
  19690. * Is parallax occlusion enabled or not.
  19691. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19692. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19693. */
  19694. useParallaxOcclusion: boolean;
  19695. /**
  19696. * 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.
  19697. */
  19698. parallaxScaleBias: number;
  19699. private _roughness;
  19700. /**
  19701. * Helps to define how blurry the reflections should appears in the material.
  19702. */
  19703. roughness: number;
  19704. /**
  19705. * In case of refraction, define the value of the index of refraction.
  19706. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19707. */
  19708. indexOfRefraction: number;
  19709. /**
  19710. * Invert the refraction texture alongside the y axis.
  19711. * It can be useful with procedural textures or probe for instance.
  19712. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19713. */
  19714. invertRefractionY: boolean;
  19715. /**
  19716. * Defines the alpha limits in alpha test mode.
  19717. */
  19718. alphaCutOff: number;
  19719. private _useLightmapAsShadowmap;
  19720. /**
  19721. * In case of light mapping, define whether the map contains light or shadow informations.
  19722. */
  19723. useLightmapAsShadowmap: boolean;
  19724. private _diffuseFresnelParameters;
  19725. /**
  19726. * Define the diffuse fresnel parameters of the material.
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19728. */
  19729. diffuseFresnelParameters: FresnelParameters;
  19730. private _opacityFresnelParameters;
  19731. /**
  19732. * Define the opacity fresnel parameters of the material.
  19733. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19734. */
  19735. opacityFresnelParameters: FresnelParameters;
  19736. private _reflectionFresnelParameters;
  19737. /**
  19738. * Define the reflection fresnel parameters of the material.
  19739. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19740. */
  19741. reflectionFresnelParameters: FresnelParameters;
  19742. private _refractionFresnelParameters;
  19743. /**
  19744. * Define the refraction fresnel parameters of the material.
  19745. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19746. */
  19747. refractionFresnelParameters: FresnelParameters;
  19748. private _emissiveFresnelParameters;
  19749. /**
  19750. * Define the emissive fresnel parameters of the material.
  19751. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19752. */
  19753. emissiveFresnelParameters: FresnelParameters;
  19754. private _useReflectionFresnelFromSpecular;
  19755. /**
  19756. * If true automatically deducts the fresnels values from the material specularity.
  19757. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19758. */
  19759. useReflectionFresnelFromSpecular: boolean;
  19760. private _useGlossinessFromSpecularMapAlpha;
  19761. /**
  19762. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19763. */
  19764. useGlossinessFromSpecularMapAlpha: boolean;
  19765. private _maxSimultaneousLights;
  19766. /**
  19767. * Defines the maximum number of lights that can be used in the material
  19768. */
  19769. maxSimultaneousLights: number;
  19770. private _invertNormalMapX;
  19771. /**
  19772. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19773. */
  19774. invertNormalMapX: boolean;
  19775. private _invertNormalMapY;
  19776. /**
  19777. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19778. */
  19779. invertNormalMapY: boolean;
  19780. private _twoSidedLighting;
  19781. /**
  19782. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19783. */
  19784. twoSidedLighting: boolean;
  19785. /**
  19786. * Default configuration related to image processing available in the standard Material.
  19787. */
  19788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19789. /**
  19790. * Gets the image processing configuration used either in this material.
  19791. */
  19792. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19793. /**
  19794. * Sets the Default image processing configuration used either in the this material.
  19795. *
  19796. * If sets to null, the scene one is in use.
  19797. */
  19798. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19799. /**
  19800. * Keep track of the image processing observer to allow dispose and replace.
  19801. */
  19802. private _imageProcessingObserver;
  19803. /**
  19804. * Attaches a new image processing configuration to the Standard Material.
  19805. * @param configuration
  19806. */
  19807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19808. /**
  19809. * Defines additional PrePass parameters for the material.
  19810. */
  19811. readonly prePassConfiguration: PrePassConfiguration;
  19812. /**
  19813. * Can this material render to prepass
  19814. */
  19815. get isPrePassCapable(): boolean;
  19816. /**
  19817. * Gets whether the color curves effect is enabled.
  19818. */
  19819. get cameraColorCurvesEnabled(): boolean;
  19820. /**
  19821. * Sets whether the color curves effect is enabled.
  19822. */
  19823. set cameraColorCurvesEnabled(value: boolean);
  19824. /**
  19825. * Gets whether the color grading effect is enabled.
  19826. */
  19827. get cameraColorGradingEnabled(): boolean;
  19828. /**
  19829. * Gets whether the color grading effect is enabled.
  19830. */
  19831. set cameraColorGradingEnabled(value: boolean);
  19832. /**
  19833. * Gets whether tonemapping is enabled or not.
  19834. */
  19835. get cameraToneMappingEnabled(): boolean;
  19836. /**
  19837. * Sets whether tonemapping is enabled or not
  19838. */
  19839. set cameraToneMappingEnabled(value: boolean);
  19840. /**
  19841. * The camera exposure used on this material.
  19842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19843. * This corresponds to a photographic exposure.
  19844. */
  19845. get cameraExposure(): number;
  19846. /**
  19847. * The camera exposure used on this material.
  19848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19849. * This corresponds to a photographic exposure.
  19850. */
  19851. set cameraExposure(value: number);
  19852. /**
  19853. * Gets The camera contrast used on this material.
  19854. */
  19855. get cameraContrast(): number;
  19856. /**
  19857. * Sets The camera contrast used on this material.
  19858. */
  19859. set cameraContrast(value: number);
  19860. /**
  19861. * Gets the Color Grading 2D Lookup Texture.
  19862. */
  19863. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19864. /**
  19865. * Sets the Color Grading 2D Lookup Texture.
  19866. */
  19867. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19868. /**
  19869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19871. * 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;
  19872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19873. */
  19874. get cameraColorCurves(): Nullable<ColorCurves>;
  19875. /**
  19876. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19878. * 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;
  19879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19880. */
  19881. set cameraColorCurves(value: Nullable<ColorCurves>);
  19882. /**
  19883. * Can this material render to several textures at once
  19884. */
  19885. get canRenderToMRT(): boolean;
  19886. /**
  19887. * Defines the detail map parameters for the material.
  19888. */
  19889. readonly detailMap: DetailMapConfiguration;
  19890. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19891. protected _worldViewProjectionMatrix: Matrix;
  19892. protected _globalAmbientColor: Color3;
  19893. protected _useLogarithmicDepth: boolean;
  19894. protected _rebuildInParallel: boolean;
  19895. /**
  19896. * Instantiates a new standard material.
  19897. * This is the default material used in Babylon. It is the best trade off between quality
  19898. * and performances.
  19899. * @see https://doc.babylonjs.com/babylon101/materials
  19900. * @param name Define the name of the material in the scene
  19901. * @param scene Define the scene the material belong to
  19902. */
  19903. constructor(name: string, scene: Scene);
  19904. /**
  19905. * Gets a boolean indicating that current material needs to register RTT
  19906. */
  19907. get hasRenderTargetTextures(): boolean;
  19908. /**
  19909. * Gets the current class name of the material e.g. "StandardMaterial"
  19910. * Mainly use in serialization.
  19911. * @returns the class name
  19912. */
  19913. getClassName(): string;
  19914. /**
  19915. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19916. * You can try switching to logarithmic depth.
  19917. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19918. */
  19919. get useLogarithmicDepth(): boolean;
  19920. set useLogarithmicDepth(value: boolean);
  19921. /**
  19922. * Specifies if the material will require alpha blending
  19923. * @returns a boolean specifying if alpha blending is needed
  19924. */
  19925. needAlphaBlending(): boolean;
  19926. /**
  19927. * Specifies if this material should be rendered in alpha test mode
  19928. * @returns a boolean specifying if an alpha test is needed.
  19929. */
  19930. needAlphaTesting(): boolean;
  19931. /**
  19932. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19933. */
  19934. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19935. /**
  19936. * Specifies whether or not there is a usable alpha channel for transparency.
  19937. */
  19938. protected _hasAlphaChannel(): boolean;
  19939. /**
  19940. * Get the texture used for alpha test purpose.
  19941. * @returns the diffuse texture in case of the standard material.
  19942. */
  19943. getAlphaTestTexture(): Nullable<BaseTexture>;
  19944. /**
  19945. * Get if the submesh is ready to be used and all its information available.
  19946. * Child classes can use it to update shaders
  19947. * @param mesh defines the mesh to check
  19948. * @param subMesh defines which submesh to check
  19949. * @param useInstances specifies that instances should be used
  19950. * @returns a boolean indicating that the submesh is ready or not
  19951. */
  19952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19953. /**
  19954. * Builds the material UBO layouts.
  19955. * Used internally during the effect preparation.
  19956. */
  19957. buildUniformLayout(): void;
  19958. /**
  19959. * Unbinds the material from the mesh
  19960. */
  19961. unbind(): void;
  19962. /**
  19963. * Binds the submesh to this material by preparing the effect and shader to draw
  19964. * @param world defines the world transformation matrix
  19965. * @param mesh defines the mesh containing the submesh
  19966. * @param subMesh defines the submesh to bind the material to
  19967. */
  19968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19969. /**
  19970. * Get the list of animatables in the material.
  19971. * @returns the list of animatables object used in the material
  19972. */
  19973. getAnimatables(): IAnimatable[];
  19974. /**
  19975. * Gets the active textures from the material
  19976. * @returns an array of textures
  19977. */
  19978. getActiveTextures(): BaseTexture[];
  19979. /**
  19980. * Specifies if the material uses a texture
  19981. * @param texture defines the texture to check against the material
  19982. * @returns a boolean specifying if the material uses the texture
  19983. */
  19984. hasTexture(texture: BaseTexture): boolean;
  19985. /**
  19986. * Disposes the material
  19987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19989. */
  19990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19991. /**
  19992. * Makes a duplicate of the material, and gives it a new name
  19993. * @param name defines the new name for the duplicated material
  19994. * @returns the cloned material
  19995. */
  19996. clone(name: string): StandardMaterial;
  19997. /**
  19998. * Serializes this material in a JSON representation
  19999. * @returns the serialized material object
  20000. */
  20001. serialize(): any;
  20002. /**
  20003. * Creates a standard material from parsed material data
  20004. * @param source defines the JSON representation of the material
  20005. * @param scene defines the hosting scene
  20006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20007. * @returns a new standard material
  20008. */
  20009. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20010. /**
  20011. * Are diffuse textures enabled in the application.
  20012. */
  20013. static get DiffuseTextureEnabled(): boolean;
  20014. static set DiffuseTextureEnabled(value: boolean);
  20015. /**
  20016. * Are detail textures enabled in the application.
  20017. */
  20018. static get DetailTextureEnabled(): boolean;
  20019. static set DetailTextureEnabled(value: boolean);
  20020. /**
  20021. * Are ambient textures enabled in the application.
  20022. */
  20023. static get AmbientTextureEnabled(): boolean;
  20024. static set AmbientTextureEnabled(value: boolean);
  20025. /**
  20026. * Are opacity textures enabled in the application.
  20027. */
  20028. static get OpacityTextureEnabled(): boolean;
  20029. static set OpacityTextureEnabled(value: boolean);
  20030. /**
  20031. * Are reflection textures enabled in the application.
  20032. */
  20033. static get ReflectionTextureEnabled(): boolean;
  20034. static set ReflectionTextureEnabled(value: boolean);
  20035. /**
  20036. * Are emissive textures enabled in the application.
  20037. */
  20038. static get EmissiveTextureEnabled(): boolean;
  20039. static set EmissiveTextureEnabled(value: boolean);
  20040. /**
  20041. * Are specular textures enabled in the application.
  20042. */
  20043. static get SpecularTextureEnabled(): boolean;
  20044. static set SpecularTextureEnabled(value: boolean);
  20045. /**
  20046. * Are bump textures enabled in the application.
  20047. */
  20048. static get BumpTextureEnabled(): boolean;
  20049. static set BumpTextureEnabled(value: boolean);
  20050. /**
  20051. * Are lightmap textures enabled in the application.
  20052. */
  20053. static get LightmapTextureEnabled(): boolean;
  20054. static set LightmapTextureEnabled(value: boolean);
  20055. /**
  20056. * Are refraction textures enabled in the application.
  20057. */
  20058. static get RefractionTextureEnabled(): boolean;
  20059. static set RefractionTextureEnabled(value: boolean);
  20060. /**
  20061. * Are color grading textures enabled in the application.
  20062. */
  20063. static get ColorGradingTextureEnabled(): boolean;
  20064. static set ColorGradingTextureEnabled(value: boolean);
  20065. /**
  20066. * Are fresnels enabled in the application.
  20067. */
  20068. static get FresnelEnabled(): boolean;
  20069. static set FresnelEnabled(value: boolean);
  20070. }
  20071. }
  20072. declare module BABYLON {
  20073. /** @hidden */
  20074. export var rgbdDecodePixelShader: {
  20075. name: string;
  20076. shader: string;
  20077. };
  20078. }
  20079. declare module BABYLON {
  20080. /** @hidden */
  20081. export var passPixelShader: {
  20082. name: string;
  20083. shader: string;
  20084. };
  20085. }
  20086. declare module BABYLON {
  20087. /** @hidden */
  20088. export var passCubePixelShader: {
  20089. name: string;
  20090. shader: string;
  20091. };
  20092. }
  20093. declare module BABYLON {
  20094. /**
  20095. * PassPostProcess which produces an output the same as it's input
  20096. */
  20097. export class PassPostProcess extends PostProcess {
  20098. /**
  20099. * Gets a string identifying the name of the class
  20100. * @returns "PassPostProcess" string
  20101. */
  20102. getClassName(): string;
  20103. /**
  20104. * Creates the PassPostProcess
  20105. * @param name The name of the effect.
  20106. * @param options The required width/height ratio to downsize to before computing the render pass.
  20107. * @param camera The camera to apply the render pass to.
  20108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20109. * @param engine The engine which the post process will be applied. (default: current engine)
  20110. * @param reusable If the post process can be reused on the same frame. (default: false)
  20111. * @param textureType The type of texture to be used when performing the post processing.
  20112. * @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)
  20113. */
  20114. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20115. /** @hidden */
  20116. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20117. }
  20118. /**
  20119. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20120. */
  20121. export class PassCubePostProcess extends PostProcess {
  20122. private _face;
  20123. /**
  20124. * Gets or sets the cube face to display.
  20125. * * 0 is +X
  20126. * * 1 is -X
  20127. * * 2 is +Y
  20128. * * 3 is -Y
  20129. * * 4 is +Z
  20130. * * 5 is -Z
  20131. */
  20132. get face(): number;
  20133. set face(value: number);
  20134. /**
  20135. * Gets a string identifying the name of the class
  20136. * @returns "PassCubePostProcess" string
  20137. */
  20138. getClassName(): string;
  20139. /**
  20140. * Creates the PassCubePostProcess
  20141. * @param name The name of the effect.
  20142. * @param options The required width/height ratio to downsize to before computing the render pass.
  20143. * @param camera The camera to apply the render pass to.
  20144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20145. * @param engine The engine which the post process will be applied. (default: current engine)
  20146. * @param reusable If the post process can be reused on the same frame. (default: false)
  20147. * @param textureType The type of texture to be used when performing the post processing.
  20148. * @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)
  20149. */
  20150. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20151. /** @hidden */
  20152. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20153. }
  20154. }
  20155. declare module BABYLON {
  20156. /**
  20157. * Class used to host texture specific utilities
  20158. */
  20159. export class TextureTools {
  20160. /**
  20161. * Uses the GPU to create a copy texture rescaled at a given size
  20162. * @param texture Texture to copy from
  20163. * @param width defines the desired width
  20164. * @param height defines the desired height
  20165. * @param useBilinearMode defines if bilinear mode has to be used
  20166. * @return the generated texture
  20167. */
  20168. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20169. /**
  20170. * Apply a post process to a texture
  20171. * @param postProcessName name of the fragment post process
  20172. * @param internalTexture the texture to encode
  20173. * @param scene the scene hosting the texture
  20174. * @param type type of the output texture. If not provided, use the one from internalTexture
  20175. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20176. * @param format format of the output texture. If not provided, use the one from internalTexture
  20177. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20178. */
  20179. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20180. }
  20181. }
  20182. declare module BABYLON {
  20183. /**
  20184. * Class used to host RGBD texture specific utilities
  20185. */
  20186. export class RGBDTextureTools {
  20187. /**
  20188. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20189. * @param texture the texture to expand.
  20190. */
  20191. static ExpandRGBDTexture(texture: Texture): void;
  20192. /**
  20193. * Encode the texture to RGBD if possible.
  20194. * @param internalTexture the texture to encode
  20195. * @param scene the scene hosting the texture
  20196. * @param outputTextureType type of the texture in which the encoding is performed
  20197. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20198. */
  20199. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20200. }
  20201. }
  20202. declare module BABYLON {
  20203. /**
  20204. * Class used to host texture specific utilities
  20205. */
  20206. export class BRDFTextureTools {
  20207. /**
  20208. * Prevents texture cache collision
  20209. */
  20210. private static _instanceNumber;
  20211. /**
  20212. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20213. * @param scene defines the hosting scene
  20214. * @returns the environment BRDF texture
  20215. */
  20216. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20217. private static _environmentBRDFBase64Texture;
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * @hidden
  20223. */
  20224. export interface IMaterialClearCoatDefines {
  20225. CLEARCOAT: boolean;
  20226. CLEARCOAT_DEFAULTIOR: boolean;
  20227. CLEARCOAT_TEXTURE: boolean;
  20228. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20229. CLEARCOAT_TEXTUREDIRECTUV: number;
  20230. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20231. CLEARCOAT_BUMP: boolean;
  20232. CLEARCOAT_BUMPDIRECTUV: number;
  20233. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20234. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20235. CLEARCOAT_REMAP_F0: boolean;
  20236. CLEARCOAT_TINT: boolean;
  20237. CLEARCOAT_TINT_TEXTURE: boolean;
  20238. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20239. /** @hidden */
  20240. _areTexturesDirty: boolean;
  20241. }
  20242. /**
  20243. * Define the code related to the clear coat parameters of the pbr material.
  20244. */
  20245. export class PBRClearCoatConfiguration {
  20246. /**
  20247. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20248. * The default fits with a polyurethane material.
  20249. * @hidden
  20250. */
  20251. static readonly _DefaultIndexOfRefraction: number;
  20252. private _isEnabled;
  20253. /**
  20254. * Defines if the clear coat is enabled in the material.
  20255. */
  20256. isEnabled: boolean;
  20257. /**
  20258. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20259. */
  20260. intensity: number;
  20261. /**
  20262. * Defines the clear coat layer roughness.
  20263. */
  20264. roughness: number;
  20265. private _indexOfRefraction;
  20266. /**
  20267. * Defines the index of refraction of the clear coat.
  20268. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20269. * The default fits with a polyurethane material.
  20270. * Changing the default value is more performance intensive.
  20271. */
  20272. indexOfRefraction: number;
  20273. private _texture;
  20274. /**
  20275. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20276. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20277. * if textureRoughness is not empty, else no texture roughness is used
  20278. */
  20279. texture: Nullable<BaseTexture>;
  20280. private _useRoughnessFromMainTexture;
  20281. /**
  20282. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20283. * If false, the green channel from textureRoughness is used for roughness
  20284. */
  20285. useRoughnessFromMainTexture: boolean;
  20286. private _textureRoughness;
  20287. /**
  20288. * Stores the clear coat roughness in a texture (green channel)
  20289. * Not used if useRoughnessFromMainTexture is true
  20290. */
  20291. textureRoughness: Nullable<BaseTexture>;
  20292. private _remapF0OnInterfaceChange;
  20293. /**
  20294. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20295. */
  20296. remapF0OnInterfaceChange: boolean;
  20297. private _bumpTexture;
  20298. /**
  20299. * Define the clear coat specific bump texture.
  20300. */
  20301. bumpTexture: Nullable<BaseTexture>;
  20302. private _isTintEnabled;
  20303. /**
  20304. * Defines if the clear coat tint is enabled in the material.
  20305. */
  20306. isTintEnabled: boolean;
  20307. /**
  20308. * Defines the clear coat tint of the material.
  20309. * This is only use if tint is enabled
  20310. */
  20311. tintColor: Color3;
  20312. /**
  20313. * Defines the distance at which the tint color should be found in the
  20314. * clear coat media.
  20315. * This is only use if tint is enabled
  20316. */
  20317. tintColorAtDistance: number;
  20318. /**
  20319. * Defines the clear coat layer thickness.
  20320. * This is only use if tint is enabled
  20321. */
  20322. tintThickness: number;
  20323. private _tintTexture;
  20324. /**
  20325. * Stores the clear tint values in a texture.
  20326. * rgb is tint
  20327. * a is a thickness factor
  20328. */
  20329. tintTexture: Nullable<BaseTexture>;
  20330. /** @hidden */
  20331. private _internalMarkAllSubMeshesAsTexturesDirty;
  20332. /** @hidden */
  20333. _markAllSubMeshesAsTexturesDirty(): void;
  20334. /**
  20335. * Instantiate a new instance of clear coat configuration.
  20336. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20337. */
  20338. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20339. /**
  20340. * Gets whether the submesh is ready to be used or not.
  20341. * @param defines the list of "defines" to update.
  20342. * @param scene defines the scene the material belongs to.
  20343. * @param engine defines the engine the material belongs to.
  20344. * @param disableBumpMap defines whether the material disables bump or not.
  20345. * @returns - boolean indicating that the submesh is ready or not.
  20346. */
  20347. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20348. /**
  20349. * Checks to see if a texture is used in the material.
  20350. * @param defines the list of "defines" to update.
  20351. * @param scene defines the scene to the material belongs to.
  20352. */
  20353. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20354. /**
  20355. * Binds the material data.
  20356. * @param uniformBuffer defines the Uniform buffer to fill in.
  20357. * @param scene defines the scene the material belongs to.
  20358. * @param engine defines the engine the material belongs to.
  20359. * @param disableBumpMap defines whether the material disables bump or not.
  20360. * @param isFrozen defines whether the material is frozen or not.
  20361. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20362. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20363. * @param subMesh the submesh to bind data for
  20364. */
  20365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20366. /**
  20367. * Checks to see if a texture is used in the material.
  20368. * @param texture - Base texture to use.
  20369. * @returns - Boolean specifying if a texture is used in the material.
  20370. */
  20371. hasTexture(texture: BaseTexture): boolean;
  20372. /**
  20373. * Returns an array of the actively used textures.
  20374. * @param activeTextures Array of BaseTextures
  20375. */
  20376. getActiveTextures(activeTextures: BaseTexture[]): void;
  20377. /**
  20378. * Returns the animatable textures.
  20379. * @param animatables Array of animatable textures.
  20380. */
  20381. getAnimatables(animatables: IAnimatable[]): void;
  20382. /**
  20383. * Disposes the resources of the material.
  20384. * @param forceDisposeTextures - Forces the disposal of all textures.
  20385. */
  20386. dispose(forceDisposeTextures?: boolean): void;
  20387. /**
  20388. * Get the current class name of the texture useful for serialization or dynamic coding.
  20389. * @returns "PBRClearCoatConfiguration"
  20390. */
  20391. getClassName(): string;
  20392. /**
  20393. * Add fallbacks to the effect fallbacks list.
  20394. * @param defines defines the Base texture to use.
  20395. * @param fallbacks defines the current fallback list.
  20396. * @param currentRank defines the current fallback rank.
  20397. * @returns the new fallback rank.
  20398. */
  20399. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20400. /**
  20401. * Add the required uniforms to the current list.
  20402. * @param uniforms defines the current uniform list.
  20403. */
  20404. static AddUniforms(uniforms: string[]): void;
  20405. /**
  20406. * Add the required samplers to the current list.
  20407. * @param samplers defines the current sampler list.
  20408. */
  20409. static AddSamplers(samplers: string[]): void;
  20410. /**
  20411. * Add the required uniforms to the current buffer.
  20412. * @param uniformBuffer defines the current uniform buffer.
  20413. */
  20414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20415. /**
  20416. * Makes a duplicate of the current configuration into another one.
  20417. * @param clearCoatConfiguration define the config where to copy the info
  20418. */
  20419. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20420. /**
  20421. * Serializes this clear coat configuration.
  20422. * @returns - An object with the serialized config.
  20423. */
  20424. serialize(): any;
  20425. /**
  20426. * Parses a anisotropy Configuration from a serialized object.
  20427. * @param source - Serialized object.
  20428. * @param scene Defines the scene we are parsing for
  20429. * @param rootUrl Defines the rootUrl to load from
  20430. */
  20431. parse(source: any, scene: Scene, rootUrl: string): void;
  20432. }
  20433. }
  20434. declare module BABYLON {
  20435. /**
  20436. * @hidden
  20437. */
  20438. export interface IMaterialAnisotropicDefines {
  20439. ANISOTROPIC: boolean;
  20440. ANISOTROPIC_TEXTURE: boolean;
  20441. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20442. MAINUV1: boolean;
  20443. _areTexturesDirty: boolean;
  20444. _needUVs: boolean;
  20445. }
  20446. /**
  20447. * Define the code related to the anisotropic parameters of the pbr material.
  20448. */
  20449. export class PBRAnisotropicConfiguration {
  20450. private _isEnabled;
  20451. /**
  20452. * Defines if the anisotropy is enabled in the material.
  20453. */
  20454. isEnabled: boolean;
  20455. /**
  20456. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20457. */
  20458. intensity: number;
  20459. /**
  20460. * Defines if the effect is along the tangents, bitangents or in between.
  20461. * By default, the effect is "stretching" the highlights along the tangents.
  20462. */
  20463. direction: Vector2;
  20464. private _texture;
  20465. /**
  20466. * Stores the anisotropy values in a texture.
  20467. * rg is direction (like normal from -1 to 1)
  20468. * b is a intensity
  20469. */
  20470. texture: Nullable<BaseTexture>;
  20471. /** @hidden */
  20472. private _internalMarkAllSubMeshesAsTexturesDirty;
  20473. /** @hidden */
  20474. _markAllSubMeshesAsTexturesDirty(): void;
  20475. /**
  20476. * Instantiate a new instance of anisotropy configuration.
  20477. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20478. */
  20479. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20480. /**
  20481. * Specifies that the submesh is ready to be used.
  20482. * @param defines the list of "defines" to update.
  20483. * @param scene defines the scene the material belongs to.
  20484. * @returns - boolean indicating that the submesh is ready or not.
  20485. */
  20486. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20487. /**
  20488. * Checks to see if a texture is used in the material.
  20489. * @param defines the list of "defines" to update.
  20490. * @param mesh the mesh we are preparing the defines for.
  20491. * @param scene defines the scene the material belongs to.
  20492. */
  20493. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20494. /**
  20495. * Binds the material data.
  20496. * @param uniformBuffer defines the Uniform buffer to fill in.
  20497. * @param scene defines the scene the material belongs to.
  20498. * @param isFrozen defines whether the material is frozen or not.
  20499. */
  20500. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20501. /**
  20502. * Checks to see if a texture is used in the material.
  20503. * @param texture - Base texture to use.
  20504. * @returns - Boolean specifying if a texture is used in the material.
  20505. */
  20506. hasTexture(texture: BaseTexture): boolean;
  20507. /**
  20508. * Returns an array of the actively used textures.
  20509. * @param activeTextures Array of BaseTextures
  20510. */
  20511. getActiveTextures(activeTextures: BaseTexture[]): void;
  20512. /**
  20513. * Returns the animatable textures.
  20514. * @param animatables Array of animatable textures.
  20515. */
  20516. getAnimatables(animatables: IAnimatable[]): void;
  20517. /**
  20518. * Disposes the resources of the material.
  20519. * @param forceDisposeTextures - Forces the disposal of all textures.
  20520. */
  20521. dispose(forceDisposeTextures?: boolean): void;
  20522. /**
  20523. * Get the current class name of the texture useful for serialization or dynamic coding.
  20524. * @returns "PBRAnisotropicConfiguration"
  20525. */
  20526. getClassName(): string;
  20527. /**
  20528. * Add fallbacks to the effect fallbacks list.
  20529. * @param defines defines the Base texture to use.
  20530. * @param fallbacks defines the current fallback list.
  20531. * @param currentRank defines the current fallback rank.
  20532. * @returns the new fallback rank.
  20533. */
  20534. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20535. /**
  20536. * Add the required uniforms to the current list.
  20537. * @param uniforms defines the current uniform list.
  20538. */
  20539. static AddUniforms(uniforms: string[]): void;
  20540. /**
  20541. * Add the required uniforms to the current buffer.
  20542. * @param uniformBuffer defines the current uniform buffer.
  20543. */
  20544. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20545. /**
  20546. * Add the required samplers to the current list.
  20547. * @param samplers defines the current sampler list.
  20548. */
  20549. static AddSamplers(samplers: string[]): void;
  20550. /**
  20551. * Makes a duplicate of the current configuration into another one.
  20552. * @param anisotropicConfiguration define the config where to copy the info
  20553. */
  20554. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20555. /**
  20556. * Serializes this anisotropy configuration.
  20557. * @returns - An object with the serialized config.
  20558. */
  20559. serialize(): any;
  20560. /**
  20561. * Parses a anisotropy Configuration from a serialized object.
  20562. * @param source - Serialized object.
  20563. * @param scene Defines the scene we are parsing for
  20564. * @param rootUrl Defines the rootUrl to load from
  20565. */
  20566. parse(source: any, scene: Scene, rootUrl: string): void;
  20567. }
  20568. }
  20569. declare module BABYLON {
  20570. /**
  20571. * @hidden
  20572. */
  20573. export interface IMaterialBRDFDefines {
  20574. BRDF_V_HEIGHT_CORRELATED: boolean;
  20575. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20576. SPHERICAL_HARMONICS: boolean;
  20577. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20578. /** @hidden */
  20579. _areMiscDirty: boolean;
  20580. }
  20581. /**
  20582. * Define the code related to the BRDF parameters of the pbr material.
  20583. */
  20584. export class PBRBRDFConfiguration {
  20585. /**
  20586. * Default value used for the energy conservation.
  20587. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20588. */
  20589. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20590. /**
  20591. * Default value used for the Smith Visibility Height Correlated mode.
  20592. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20593. */
  20594. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20595. /**
  20596. * Default value used for the IBL diffuse part.
  20597. * This can help switching back to the polynomials mode globally which is a tiny bit
  20598. * less GPU intensive at the drawback of a lower quality.
  20599. */
  20600. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20601. /**
  20602. * Default value used for activating energy conservation for the specular workflow.
  20603. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20604. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20605. */
  20606. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20607. private _useEnergyConservation;
  20608. /**
  20609. * Defines if the material uses energy conservation.
  20610. */
  20611. useEnergyConservation: boolean;
  20612. private _useSmithVisibilityHeightCorrelated;
  20613. /**
  20614. * LEGACY Mode set to false
  20615. * Defines if the material uses height smith correlated visibility term.
  20616. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20617. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20618. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20619. * Not relying on height correlated will also disable energy conservation.
  20620. */
  20621. useSmithVisibilityHeightCorrelated: boolean;
  20622. private _useSphericalHarmonics;
  20623. /**
  20624. * LEGACY Mode set to false
  20625. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20626. * diffuse part of the IBL.
  20627. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20628. * to the ground truth.
  20629. */
  20630. useSphericalHarmonics: boolean;
  20631. private _useSpecularGlossinessInputEnergyConservation;
  20632. /**
  20633. * Defines if the material uses energy conservation, when the specular workflow is active.
  20634. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20635. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20636. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20637. */
  20638. useSpecularGlossinessInputEnergyConservation: boolean;
  20639. /** @hidden */
  20640. private _internalMarkAllSubMeshesAsMiscDirty;
  20641. /** @hidden */
  20642. _markAllSubMeshesAsMiscDirty(): void;
  20643. /**
  20644. * Instantiate a new instance of clear coat configuration.
  20645. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20646. */
  20647. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20648. /**
  20649. * Checks to see if a texture is used in the material.
  20650. * @param defines the list of "defines" to update.
  20651. */
  20652. prepareDefines(defines: IMaterialBRDFDefines): void;
  20653. /**
  20654. * Get the current class name of the texture useful for serialization or dynamic coding.
  20655. * @returns "PBRClearCoatConfiguration"
  20656. */
  20657. getClassName(): string;
  20658. /**
  20659. * Makes a duplicate of the current configuration into another one.
  20660. * @param brdfConfiguration define the config where to copy the info
  20661. */
  20662. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20663. /**
  20664. * Serializes this BRDF configuration.
  20665. * @returns - An object with the serialized config.
  20666. */
  20667. serialize(): any;
  20668. /**
  20669. * Parses a anisotropy Configuration from a serialized object.
  20670. * @param source - Serialized object.
  20671. * @param scene Defines the scene we are parsing for
  20672. * @param rootUrl Defines the rootUrl to load from
  20673. */
  20674. parse(source: any, scene: Scene, rootUrl: string): void;
  20675. }
  20676. }
  20677. declare module BABYLON {
  20678. /**
  20679. * @hidden
  20680. */
  20681. export interface IMaterialSheenDefines {
  20682. SHEEN: boolean;
  20683. SHEEN_TEXTURE: boolean;
  20684. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20685. SHEEN_TEXTUREDIRECTUV: number;
  20686. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20687. SHEEN_LINKWITHALBEDO: boolean;
  20688. SHEEN_ROUGHNESS: boolean;
  20689. SHEEN_ALBEDOSCALING: boolean;
  20690. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20691. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20692. /** @hidden */
  20693. _areTexturesDirty: boolean;
  20694. }
  20695. /**
  20696. * Define the code related to the Sheen parameters of the pbr material.
  20697. */
  20698. export class PBRSheenConfiguration {
  20699. private _isEnabled;
  20700. /**
  20701. * Defines if the material uses sheen.
  20702. */
  20703. isEnabled: boolean;
  20704. private _linkSheenWithAlbedo;
  20705. /**
  20706. * Defines if the sheen is linked to the sheen color.
  20707. */
  20708. linkSheenWithAlbedo: boolean;
  20709. /**
  20710. * Defines the sheen intensity.
  20711. */
  20712. intensity: number;
  20713. /**
  20714. * Defines the sheen color.
  20715. */
  20716. color: Color3;
  20717. private _texture;
  20718. /**
  20719. * Stores the sheen tint values in a texture.
  20720. * rgb is tint
  20721. * 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)
  20722. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20723. */
  20724. texture: Nullable<BaseTexture>;
  20725. private _useRoughnessFromMainTexture;
  20726. /**
  20727. * Indicates that the alpha channel of the texture property will be used for roughness.
  20728. * Has no effect if the roughness (and texture!) property is not defined
  20729. */
  20730. useRoughnessFromMainTexture: boolean;
  20731. private _roughness;
  20732. /**
  20733. * Defines the sheen roughness.
  20734. * It is not taken into account if linkSheenWithAlbedo is true.
  20735. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20736. */
  20737. roughness: Nullable<number>;
  20738. private _textureRoughness;
  20739. /**
  20740. * Stores the sheen roughness in a texture.
  20741. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20742. */
  20743. textureRoughness: Nullable<BaseTexture>;
  20744. private _albedoScaling;
  20745. /**
  20746. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20747. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20748. * making it easier to setup and tweak the effect
  20749. */
  20750. albedoScaling: boolean;
  20751. /** @hidden */
  20752. private _internalMarkAllSubMeshesAsTexturesDirty;
  20753. /** @hidden */
  20754. _markAllSubMeshesAsTexturesDirty(): void;
  20755. /**
  20756. * Instantiate a new instance of clear coat configuration.
  20757. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20758. */
  20759. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20760. /**
  20761. * Specifies that the submesh is ready to be used.
  20762. * @param defines the list of "defines" to update.
  20763. * @param scene defines the scene the material belongs to.
  20764. * @returns - boolean indicating that the submesh is ready or not.
  20765. */
  20766. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20767. /**
  20768. * Checks to see if a texture is used in the material.
  20769. * @param defines the list of "defines" to update.
  20770. * @param scene defines the scene the material belongs to.
  20771. */
  20772. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20773. /**
  20774. * Binds the material data.
  20775. * @param uniformBuffer defines the Uniform buffer to fill in.
  20776. * @param scene defines the scene the material belongs to.
  20777. * @param isFrozen defines whether the material is frozen or not.
  20778. * @param subMesh the submesh to bind data for
  20779. */
  20780. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20781. /**
  20782. * Checks to see if a texture is used in the material.
  20783. * @param texture - Base texture to use.
  20784. * @returns - Boolean specifying if a texture is used in the material.
  20785. */
  20786. hasTexture(texture: BaseTexture): boolean;
  20787. /**
  20788. * Returns an array of the actively used textures.
  20789. * @param activeTextures Array of BaseTextures
  20790. */
  20791. getActiveTextures(activeTextures: BaseTexture[]): void;
  20792. /**
  20793. * Returns the animatable textures.
  20794. * @param animatables Array of animatable textures.
  20795. */
  20796. getAnimatables(animatables: IAnimatable[]): void;
  20797. /**
  20798. * Disposes the resources of the material.
  20799. * @param forceDisposeTextures - Forces the disposal of all textures.
  20800. */
  20801. dispose(forceDisposeTextures?: boolean): void;
  20802. /**
  20803. * Get the current class name of the texture useful for serialization or dynamic coding.
  20804. * @returns "PBRSheenConfiguration"
  20805. */
  20806. getClassName(): string;
  20807. /**
  20808. * Add fallbacks to the effect fallbacks list.
  20809. * @param defines defines the Base texture to use.
  20810. * @param fallbacks defines the current fallback list.
  20811. * @param currentRank defines the current fallback rank.
  20812. * @returns the new fallback rank.
  20813. */
  20814. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20815. /**
  20816. * Add the required uniforms to the current list.
  20817. * @param uniforms defines the current uniform list.
  20818. */
  20819. static AddUniforms(uniforms: string[]): void;
  20820. /**
  20821. * Add the required uniforms to the current buffer.
  20822. * @param uniformBuffer defines the current uniform buffer.
  20823. */
  20824. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20825. /**
  20826. * Add the required samplers to the current list.
  20827. * @param samplers defines the current sampler list.
  20828. */
  20829. static AddSamplers(samplers: string[]): void;
  20830. /**
  20831. * Makes a duplicate of the current configuration into another one.
  20832. * @param sheenConfiguration define the config where to copy the info
  20833. */
  20834. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20835. /**
  20836. * Serializes this BRDF configuration.
  20837. * @returns - An object with the serialized config.
  20838. */
  20839. serialize(): any;
  20840. /**
  20841. * Parses a anisotropy Configuration from a serialized object.
  20842. * @param source - Serialized object.
  20843. * @param scene Defines the scene we are parsing for
  20844. * @param rootUrl Defines the rootUrl to load from
  20845. */
  20846. parse(source: any, scene: Scene, rootUrl: string): void;
  20847. }
  20848. }
  20849. declare module BABYLON {
  20850. /**
  20851. * @hidden
  20852. */
  20853. export interface IMaterialSubSurfaceDefines {
  20854. SUBSURFACE: boolean;
  20855. SS_REFRACTION: boolean;
  20856. SS_TRANSLUCENCY: boolean;
  20857. SS_SCATTERING: boolean;
  20858. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20859. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20860. SS_REFRACTIONMAP_3D: boolean;
  20861. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20862. SS_LODINREFRACTIONALPHA: boolean;
  20863. SS_GAMMAREFRACTION: boolean;
  20864. SS_RGBDREFRACTION: boolean;
  20865. SS_LINEARSPECULARREFRACTION: boolean;
  20866. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20867. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20868. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20869. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20870. /** @hidden */
  20871. _areTexturesDirty: boolean;
  20872. }
  20873. /**
  20874. * Define the code related to the sub surface parameters of the pbr material.
  20875. */
  20876. export class PBRSubSurfaceConfiguration {
  20877. private _isRefractionEnabled;
  20878. /**
  20879. * Defines if the refraction is enabled in the material.
  20880. */
  20881. isRefractionEnabled: boolean;
  20882. private _isTranslucencyEnabled;
  20883. /**
  20884. * Defines if the translucency is enabled in the material.
  20885. */
  20886. isTranslucencyEnabled: boolean;
  20887. private _isScatteringEnabled;
  20888. /**
  20889. * Defines if the sub surface scattering is enabled in the material.
  20890. */
  20891. isScatteringEnabled: boolean;
  20892. private _scatteringDiffusionProfileIndex;
  20893. /**
  20894. * Diffusion profile for subsurface scattering.
  20895. * Useful for better scattering in the skins or foliages.
  20896. */
  20897. get scatteringDiffusionProfile(): Nullable<Color3>;
  20898. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20899. /**
  20900. * Defines the refraction intensity of the material.
  20901. * The refraction when enabled replaces the Diffuse part of the material.
  20902. * The intensity helps transitioning between diffuse and refraction.
  20903. */
  20904. refractionIntensity: number;
  20905. /**
  20906. * Defines the translucency intensity of the material.
  20907. * When translucency has been enabled, this defines how much of the "translucency"
  20908. * is added to the diffuse part of the material.
  20909. */
  20910. translucencyIntensity: number;
  20911. /**
  20912. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20913. */
  20914. useAlbedoToTintRefraction: boolean;
  20915. private _thicknessTexture;
  20916. /**
  20917. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20918. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20919. * 0 would mean minimumThickness
  20920. * 1 would mean maximumThickness
  20921. * The other channels might be use as a mask to vary the different effects intensity.
  20922. */
  20923. thicknessTexture: Nullable<BaseTexture>;
  20924. private _refractionTexture;
  20925. /**
  20926. * Defines the texture to use for refraction.
  20927. */
  20928. refractionTexture: Nullable<BaseTexture>;
  20929. private _indexOfRefraction;
  20930. /**
  20931. * Index of refraction of the material base layer.
  20932. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20933. *
  20934. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20935. *
  20936. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20937. */
  20938. indexOfRefraction: number;
  20939. private _volumeIndexOfRefraction;
  20940. /**
  20941. * Index of refraction of the material's volume.
  20942. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20943. *
  20944. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20945. * the volume will use the same IOR as the surface.
  20946. */
  20947. get volumeIndexOfRefraction(): number;
  20948. set volumeIndexOfRefraction(value: number);
  20949. private _invertRefractionY;
  20950. /**
  20951. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20952. */
  20953. invertRefractionY: boolean;
  20954. private _linkRefractionWithTransparency;
  20955. /**
  20956. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20957. * Materials half opaque for instance using refraction could benefit from this control.
  20958. */
  20959. linkRefractionWithTransparency: boolean;
  20960. /**
  20961. * Defines the minimum thickness stored in the thickness map.
  20962. * If no thickness map is defined, this value will be used to simulate thickness.
  20963. */
  20964. minimumThickness: number;
  20965. /**
  20966. * Defines the maximum thickness stored in the thickness map.
  20967. */
  20968. maximumThickness: number;
  20969. /**
  20970. * Defines the volume tint of the material.
  20971. * This is used for both translucency and scattering.
  20972. */
  20973. tintColor: Color3;
  20974. /**
  20975. * Defines the distance at which the tint color should be found in the media.
  20976. * This is used for refraction only.
  20977. */
  20978. tintColorAtDistance: number;
  20979. /**
  20980. * Defines how far each channel transmit through the media.
  20981. * It is defined as a color to simplify it selection.
  20982. */
  20983. diffusionDistance: Color3;
  20984. private _useMaskFromThicknessTexture;
  20985. /**
  20986. * Stores the intensity of the different subsurface effects in the thickness texture.
  20987. * * the green channel is the translucency intensity.
  20988. * * the blue channel is the scattering intensity.
  20989. * * the alpha channel is the refraction intensity.
  20990. */
  20991. useMaskFromThicknessTexture: boolean;
  20992. private _scene;
  20993. private _useMaskFromThicknessTextureGltf;
  20994. /**
  20995. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20996. * matches the channel-packing that is used by glTF.
  20997. * * the red channel is the transmission/translucency intensity.
  20998. * * the green channel is the thickness.
  20999. */
  21000. useMaskFromThicknessTextureGltf: boolean;
  21001. /** @hidden */
  21002. private _internalMarkAllSubMeshesAsTexturesDirty;
  21003. private _internalMarkScenePrePassDirty;
  21004. /** @hidden */
  21005. _markAllSubMeshesAsTexturesDirty(): void;
  21006. /** @hidden */
  21007. _markScenePrePassDirty(): void;
  21008. /**
  21009. * Instantiate a new instance of sub surface configuration.
  21010. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21011. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21012. * @param scene The scene
  21013. */
  21014. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21015. /**
  21016. * Gets whether the submesh is ready to be used or not.
  21017. * @param defines the list of "defines" to update.
  21018. * @param scene defines the scene the material belongs to.
  21019. * @returns - boolean indicating that the submesh is ready or not.
  21020. */
  21021. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21022. /**
  21023. * Checks to see if a texture is used in the material.
  21024. * @param defines the list of "defines" to update.
  21025. * @param scene defines the scene to the material belongs to.
  21026. */
  21027. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21028. /**
  21029. * Binds the material data.
  21030. * @param uniformBuffer defines the Uniform buffer to fill in.
  21031. * @param scene defines the scene the material belongs to.
  21032. * @param engine defines the engine the material belongs to.
  21033. * @param isFrozen defines whether the material is frozen or not.
  21034. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21035. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21036. */
  21037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21038. /**
  21039. * Unbinds the material from the mesh.
  21040. * @param activeEffect defines the effect that should be unbound from.
  21041. * @returns true if unbound, otherwise false
  21042. */
  21043. unbind(activeEffect: Effect): boolean;
  21044. /**
  21045. * Returns the texture used for refraction or null if none is used.
  21046. * @param scene defines the scene the material belongs to.
  21047. * @returns - Refraction texture if present. If no refraction texture and refraction
  21048. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21049. */
  21050. private _getRefractionTexture;
  21051. /**
  21052. * Returns true if alpha blending should be disabled.
  21053. */
  21054. get disableAlphaBlending(): boolean;
  21055. /**
  21056. * Fills the list of render target textures.
  21057. * @param renderTargets the list of render targets to update
  21058. */
  21059. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21060. /**
  21061. * Checks to see if a texture is used in the material.
  21062. * @param texture - Base texture to use.
  21063. * @returns - Boolean specifying if a texture is used in the material.
  21064. */
  21065. hasTexture(texture: BaseTexture): boolean;
  21066. /**
  21067. * Gets a boolean indicating that current material needs to register RTT
  21068. * @returns true if this uses a render target otherwise false.
  21069. */
  21070. hasRenderTargetTextures(): boolean;
  21071. /**
  21072. * Returns an array of the actively used textures.
  21073. * @param activeTextures Array of BaseTextures
  21074. */
  21075. getActiveTextures(activeTextures: BaseTexture[]): void;
  21076. /**
  21077. * Returns the animatable textures.
  21078. * @param animatables Array of animatable textures.
  21079. */
  21080. getAnimatables(animatables: IAnimatable[]): void;
  21081. /**
  21082. * Disposes the resources of the material.
  21083. * @param forceDisposeTextures - Forces the disposal of all textures.
  21084. */
  21085. dispose(forceDisposeTextures?: boolean): void;
  21086. /**
  21087. * Get the current class name of the texture useful for serialization or dynamic coding.
  21088. * @returns "PBRSubSurfaceConfiguration"
  21089. */
  21090. getClassName(): string;
  21091. /**
  21092. * Add fallbacks to the effect fallbacks list.
  21093. * @param defines defines the Base texture to use.
  21094. * @param fallbacks defines the current fallback list.
  21095. * @param currentRank defines the current fallback rank.
  21096. * @returns the new fallback rank.
  21097. */
  21098. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21099. /**
  21100. * Add the required uniforms to the current list.
  21101. * @param uniforms defines the current uniform list.
  21102. */
  21103. static AddUniforms(uniforms: string[]): void;
  21104. /**
  21105. * Add the required samplers to the current list.
  21106. * @param samplers defines the current sampler list.
  21107. */
  21108. static AddSamplers(samplers: string[]): void;
  21109. /**
  21110. * Add the required uniforms to the current buffer.
  21111. * @param uniformBuffer defines the current uniform buffer.
  21112. */
  21113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21114. /**
  21115. * Makes a duplicate of the current configuration into another one.
  21116. * @param configuration define the config where to copy the info
  21117. */
  21118. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21119. /**
  21120. * Serializes this Sub Surface configuration.
  21121. * @returns - An object with the serialized config.
  21122. */
  21123. serialize(): any;
  21124. /**
  21125. * Parses a anisotropy Configuration from a serialized object.
  21126. * @param source - Serialized object.
  21127. * @param scene Defines the scene we are parsing for
  21128. * @param rootUrl Defines the rootUrl to load from
  21129. */
  21130. parse(source: any, scene: Scene, rootUrl: string): void;
  21131. }
  21132. }
  21133. declare module BABYLON {
  21134. /**
  21135. * Class representing spherical harmonics coefficients to the 3rd degree
  21136. */
  21137. export class SphericalHarmonics {
  21138. /**
  21139. * Defines whether or not the harmonics have been prescaled for rendering.
  21140. */
  21141. preScaled: boolean;
  21142. /**
  21143. * The l0,0 coefficients of the spherical harmonics
  21144. */
  21145. l00: Vector3;
  21146. /**
  21147. * The l1,-1 coefficients of the spherical harmonics
  21148. */
  21149. l1_1: Vector3;
  21150. /**
  21151. * The l1,0 coefficients of the spherical harmonics
  21152. */
  21153. l10: Vector3;
  21154. /**
  21155. * The l1,1 coefficients of the spherical harmonics
  21156. */
  21157. l11: Vector3;
  21158. /**
  21159. * The l2,-2 coefficients of the spherical harmonics
  21160. */
  21161. l2_2: Vector3;
  21162. /**
  21163. * The l2,-1 coefficients of the spherical harmonics
  21164. */
  21165. l2_1: Vector3;
  21166. /**
  21167. * The l2,0 coefficients of the spherical harmonics
  21168. */
  21169. l20: Vector3;
  21170. /**
  21171. * The l2,1 coefficients of the spherical harmonics
  21172. */
  21173. l21: Vector3;
  21174. /**
  21175. * The l2,2 coefficients of the spherical harmonics
  21176. */
  21177. l22: Vector3;
  21178. /**
  21179. * Adds a light to the spherical harmonics
  21180. * @param direction the direction of the light
  21181. * @param color the color of the light
  21182. * @param deltaSolidAngle the delta solid angle of the light
  21183. */
  21184. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21185. /**
  21186. * Scales the spherical harmonics by the given amount
  21187. * @param scale the amount to scale
  21188. */
  21189. scaleInPlace(scale: number): void;
  21190. /**
  21191. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21192. *
  21193. * ```
  21194. * E_lm = A_l * L_lm
  21195. * ```
  21196. *
  21197. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21198. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21199. * the scaling factors are given in equation 9.
  21200. */
  21201. convertIncidentRadianceToIrradiance(): void;
  21202. /**
  21203. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21204. *
  21205. * ```
  21206. * L = (1/pi) * E * rho
  21207. * ```
  21208. *
  21209. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21210. */
  21211. convertIrradianceToLambertianRadiance(): void;
  21212. /**
  21213. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21214. * required operations at run time.
  21215. *
  21216. * This is simply done by scaling back the SH with Ylm constants parameter.
  21217. * The trigonometric part being applied by the shader at run time.
  21218. */
  21219. preScaleForRendering(): void;
  21220. /**
  21221. * Constructs a spherical harmonics from an array.
  21222. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21223. * @returns the spherical harmonics
  21224. */
  21225. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21226. /**
  21227. * Gets the spherical harmonics from polynomial
  21228. * @param polynomial the spherical polynomial
  21229. * @returns the spherical harmonics
  21230. */
  21231. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21232. }
  21233. /**
  21234. * Class representing spherical polynomial coefficients to the 3rd degree
  21235. */
  21236. export class SphericalPolynomial {
  21237. private _harmonics;
  21238. /**
  21239. * The spherical harmonics used to create the polynomials.
  21240. */
  21241. get preScaledHarmonics(): SphericalHarmonics;
  21242. /**
  21243. * The x coefficients of the spherical polynomial
  21244. */
  21245. x: Vector3;
  21246. /**
  21247. * The y coefficients of the spherical polynomial
  21248. */
  21249. y: Vector3;
  21250. /**
  21251. * The z coefficients of the spherical polynomial
  21252. */
  21253. z: Vector3;
  21254. /**
  21255. * The xx coefficients of the spherical polynomial
  21256. */
  21257. xx: Vector3;
  21258. /**
  21259. * The yy coefficients of the spherical polynomial
  21260. */
  21261. yy: Vector3;
  21262. /**
  21263. * The zz coefficients of the spherical polynomial
  21264. */
  21265. zz: Vector3;
  21266. /**
  21267. * The xy coefficients of the spherical polynomial
  21268. */
  21269. xy: Vector3;
  21270. /**
  21271. * The yz coefficients of the spherical polynomial
  21272. */
  21273. yz: Vector3;
  21274. /**
  21275. * The zx coefficients of the spherical polynomial
  21276. */
  21277. zx: Vector3;
  21278. /**
  21279. * Adds an ambient color to the spherical polynomial
  21280. * @param color the color to add
  21281. */
  21282. addAmbient(color: Color3): void;
  21283. /**
  21284. * Scales the spherical polynomial by the given amount
  21285. * @param scale the amount to scale
  21286. */
  21287. scaleInPlace(scale: number): void;
  21288. /**
  21289. * Gets the spherical polynomial from harmonics
  21290. * @param harmonics the spherical harmonics
  21291. * @returns the spherical polynomial
  21292. */
  21293. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21294. /**
  21295. * Constructs a spherical polynomial from an array.
  21296. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21297. * @returns the spherical polynomial
  21298. */
  21299. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21300. }
  21301. }
  21302. declare module BABYLON {
  21303. /**
  21304. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21305. */
  21306. export interface CubeMapInfo {
  21307. /**
  21308. * The pixel array for the front face.
  21309. * This is stored in format, left to right, up to down format.
  21310. */
  21311. front: Nullable<ArrayBufferView>;
  21312. /**
  21313. * The pixel array for the back face.
  21314. * This is stored in format, left to right, up to down format.
  21315. */
  21316. back: Nullable<ArrayBufferView>;
  21317. /**
  21318. * The pixel array for the left face.
  21319. * This is stored in format, left to right, up to down format.
  21320. */
  21321. left: Nullable<ArrayBufferView>;
  21322. /**
  21323. * The pixel array for the right face.
  21324. * This is stored in format, left to right, up to down format.
  21325. */
  21326. right: Nullable<ArrayBufferView>;
  21327. /**
  21328. * The pixel array for the up face.
  21329. * This is stored in format, left to right, up to down format.
  21330. */
  21331. up: Nullable<ArrayBufferView>;
  21332. /**
  21333. * The pixel array for the down face.
  21334. * This is stored in format, left to right, up to down format.
  21335. */
  21336. down: Nullable<ArrayBufferView>;
  21337. /**
  21338. * The size of the cubemap stored.
  21339. *
  21340. * Each faces will be size * size pixels.
  21341. */
  21342. size: number;
  21343. /**
  21344. * The format of the texture.
  21345. *
  21346. * RGBA, RGB.
  21347. */
  21348. format: number;
  21349. /**
  21350. * The type of the texture data.
  21351. *
  21352. * UNSIGNED_INT, FLOAT.
  21353. */
  21354. type: number;
  21355. /**
  21356. * Specifies whether the texture is in gamma space.
  21357. */
  21358. gammaSpace: boolean;
  21359. }
  21360. /**
  21361. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21362. */
  21363. export class PanoramaToCubeMapTools {
  21364. private static FACE_LEFT;
  21365. private static FACE_RIGHT;
  21366. private static FACE_FRONT;
  21367. private static FACE_BACK;
  21368. private static FACE_DOWN;
  21369. private static FACE_UP;
  21370. /**
  21371. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21372. *
  21373. * @param float32Array The source data.
  21374. * @param inputWidth The width of the input panorama.
  21375. * @param inputHeight The height of the input panorama.
  21376. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21377. * @return The cubemap data
  21378. */
  21379. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21380. private static CreateCubemapTexture;
  21381. private static CalcProjectionSpherical;
  21382. }
  21383. }
  21384. declare module BABYLON {
  21385. /**
  21386. * Helper class dealing with the extraction of spherical polynomial dataArray
  21387. * from a cube map.
  21388. */
  21389. export class CubeMapToSphericalPolynomialTools {
  21390. private static FileFaces;
  21391. /**
  21392. * Converts a texture to the according Spherical Polynomial data.
  21393. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21394. *
  21395. * @param texture The texture to extract the information from.
  21396. * @return The Spherical Polynomial data.
  21397. */
  21398. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21399. /**
  21400. * Converts a cubemap to the according Spherical Polynomial data.
  21401. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21402. *
  21403. * @param cubeInfo The Cube map to extract the information from.
  21404. * @return The Spherical Polynomial data.
  21405. */
  21406. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21407. }
  21408. }
  21409. declare module BABYLON {
  21410. interface BaseTexture {
  21411. /**
  21412. * Get the polynomial representation of the texture data.
  21413. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21414. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21415. */
  21416. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21417. }
  21418. }
  21419. declare module BABYLON {
  21420. /** @hidden */
  21421. export var pbrFragmentDeclaration: {
  21422. name: string;
  21423. shader: string;
  21424. };
  21425. }
  21426. declare module BABYLON {
  21427. /** @hidden */
  21428. export var pbrUboDeclaration: {
  21429. name: string;
  21430. shader: string;
  21431. };
  21432. }
  21433. declare module BABYLON {
  21434. /** @hidden */
  21435. export var pbrFragmentExtraDeclaration: {
  21436. name: string;
  21437. shader: string;
  21438. };
  21439. }
  21440. declare module BABYLON {
  21441. /** @hidden */
  21442. export var pbrFragmentSamplersDeclaration: {
  21443. name: string;
  21444. shader: string;
  21445. };
  21446. }
  21447. declare module BABYLON {
  21448. /** @hidden */
  21449. export var subSurfaceScatteringFunctions: {
  21450. name: string;
  21451. shader: string;
  21452. };
  21453. }
  21454. declare module BABYLON {
  21455. /** @hidden */
  21456. export var importanceSampling: {
  21457. name: string;
  21458. shader: string;
  21459. };
  21460. }
  21461. declare module BABYLON {
  21462. /** @hidden */
  21463. export var pbrHelperFunctions: {
  21464. name: string;
  21465. shader: string;
  21466. };
  21467. }
  21468. declare module BABYLON {
  21469. /** @hidden */
  21470. export var harmonicsFunctions: {
  21471. name: string;
  21472. shader: string;
  21473. };
  21474. }
  21475. declare module BABYLON {
  21476. /** @hidden */
  21477. export var pbrDirectLightingSetupFunctions: {
  21478. name: string;
  21479. shader: string;
  21480. };
  21481. }
  21482. declare module BABYLON {
  21483. /** @hidden */
  21484. export var pbrDirectLightingFalloffFunctions: {
  21485. name: string;
  21486. shader: string;
  21487. };
  21488. }
  21489. declare module BABYLON {
  21490. /** @hidden */
  21491. export var pbrBRDFFunctions: {
  21492. name: string;
  21493. shader: string;
  21494. };
  21495. }
  21496. declare module BABYLON {
  21497. /** @hidden */
  21498. export var hdrFilteringFunctions: {
  21499. name: string;
  21500. shader: string;
  21501. };
  21502. }
  21503. declare module BABYLON {
  21504. /** @hidden */
  21505. export var pbrDirectLightingFunctions: {
  21506. name: string;
  21507. shader: string;
  21508. };
  21509. }
  21510. declare module BABYLON {
  21511. /** @hidden */
  21512. export var pbrIBLFunctions: {
  21513. name: string;
  21514. shader: string;
  21515. };
  21516. }
  21517. declare module BABYLON {
  21518. /** @hidden */
  21519. export var pbrBlockAlbedoOpacity: {
  21520. name: string;
  21521. shader: string;
  21522. };
  21523. }
  21524. declare module BABYLON {
  21525. /** @hidden */
  21526. export var pbrBlockReflectivity: {
  21527. name: string;
  21528. shader: string;
  21529. };
  21530. }
  21531. declare module BABYLON {
  21532. /** @hidden */
  21533. export var pbrBlockAmbientOcclusion: {
  21534. name: string;
  21535. shader: string;
  21536. };
  21537. }
  21538. declare module BABYLON {
  21539. /** @hidden */
  21540. export var pbrBlockAlphaFresnel: {
  21541. name: string;
  21542. shader: string;
  21543. };
  21544. }
  21545. declare module BABYLON {
  21546. /** @hidden */
  21547. export var pbrBlockAnisotropic: {
  21548. name: string;
  21549. shader: string;
  21550. };
  21551. }
  21552. declare module BABYLON {
  21553. /** @hidden */
  21554. export var pbrBlockReflection: {
  21555. name: string;
  21556. shader: string;
  21557. };
  21558. }
  21559. declare module BABYLON {
  21560. /** @hidden */
  21561. export var pbrBlockSheen: {
  21562. name: string;
  21563. shader: string;
  21564. };
  21565. }
  21566. declare module BABYLON {
  21567. /** @hidden */
  21568. export var pbrBlockClearcoat: {
  21569. name: string;
  21570. shader: string;
  21571. };
  21572. }
  21573. declare module BABYLON {
  21574. /** @hidden */
  21575. export var pbrBlockSubSurface: {
  21576. name: string;
  21577. shader: string;
  21578. };
  21579. }
  21580. declare module BABYLON {
  21581. /** @hidden */
  21582. export var pbrBlockNormalGeometric: {
  21583. name: string;
  21584. shader: string;
  21585. };
  21586. }
  21587. declare module BABYLON {
  21588. /** @hidden */
  21589. export var pbrBlockNormalFinal: {
  21590. name: string;
  21591. shader: string;
  21592. };
  21593. }
  21594. declare module BABYLON {
  21595. /** @hidden */
  21596. export var pbrBlockLightmapInit: {
  21597. name: string;
  21598. shader: string;
  21599. };
  21600. }
  21601. declare module BABYLON {
  21602. /** @hidden */
  21603. export var pbrBlockGeometryInfo: {
  21604. name: string;
  21605. shader: string;
  21606. };
  21607. }
  21608. declare module BABYLON {
  21609. /** @hidden */
  21610. export var pbrBlockReflectance0: {
  21611. name: string;
  21612. shader: string;
  21613. };
  21614. }
  21615. declare module BABYLON {
  21616. /** @hidden */
  21617. export var pbrBlockReflectance: {
  21618. name: string;
  21619. shader: string;
  21620. };
  21621. }
  21622. declare module BABYLON {
  21623. /** @hidden */
  21624. export var pbrBlockDirectLighting: {
  21625. name: string;
  21626. shader: string;
  21627. };
  21628. }
  21629. declare module BABYLON {
  21630. /** @hidden */
  21631. export var pbrBlockFinalLitComponents: {
  21632. name: string;
  21633. shader: string;
  21634. };
  21635. }
  21636. declare module BABYLON {
  21637. /** @hidden */
  21638. export var pbrBlockFinalUnlitComponents: {
  21639. name: string;
  21640. shader: string;
  21641. };
  21642. }
  21643. declare module BABYLON {
  21644. /** @hidden */
  21645. export var pbrBlockFinalColorComposition: {
  21646. name: string;
  21647. shader: string;
  21648. };
  21649. }
  21650. declare module BABYLON {
  21651. /** @hidden */
  21652. export var pbrBlockImageProcessing: {
  21653. name: string;
  21654. shader: string;
  21655. };
  21656. }
  21657. declare module BABYLON {
  21658. /** @hidden */
  21659. export var pbrDebug: {
  21660. name: string;
  21661. shader: string;
  21662. };
  21663. }
  21664. declare module BABYLON {
  21665. /** @hidden */
  21666. export var pbrPixelShader: {
  21667. name: string;
  21668. shader: string;
  21669. };
  21670. }
  21671. declare module BABYLON {
  21672. /** @hidden */
  21673. export var pbrVertexDeclaration: {
  21674. name: string;
  21675. shader: string;
  21676. };
  21677. }
  21678. declare module BABYLON {
  21679. /** @hidden */
  21680. export var pbrVertexShader: {
  21681. name: string;
  21682. shader: string;
  21683. };
  21684. }
  21685. declare module BABYLON {
  21686. /**
  21687. * Manages the defines for the PBR Material.
  21688. * @hidden
  21689. */
  21690. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21691. PBR: boolean;
  21692. NUM_SAMPLES: string;
  21693. REALTIME_FILTERING: boolean;
  21694. MAINUV1: boolean;
  21695. MAINUV2: boolean;
  21696. UV1: boolean;
  21697. UV2: boolean;
  21698. ALBEDO: boolean;
  21699. GAMMAALBEDO: boolean;
  21700. ALBEDODIRECTUV: number;
  21701. VERTEXCOLOR: boolean;
  21702. DETAIL: boolean;
  21703. DETAILDIRECTUV: number;
  21704. DETAIL_NORMALBLENDMETHOD: number;
  21705. AMBIENT: boolean;
  21706. AMBIENTDIRECTUV: number;
  21707. AMBIENTINGRAYSCALE: boolean;
  21708. OPACITY: boolean;
  21709. VERTEXALPHA: boolean;
  21710. OPACITYDIRECTUV: number;
  21711. OPACITYRGB: boolean;
  21712. ALPHATEST: boolean;
  21713. DEPTHPREPASS: boolean;
  21714. ALPHABLEND: boolean;
  21715. ALPHAFROMALBEDO: boolean;
  21716. ALPHATESTVALUE: string;
  21717. SPECULAROVERALPHA: boolean;
  21718. RADIANCEOVERALPHA: boolean;
  21719. ALPHAFRESNEL: boolean;
  21720. LINEARALPHAFRESNEL: boolean;
  21721. PREMULTIPLYALPHA: boolean;
  21722. EMISSIVE: boolean;
  21723. EMISSIVEDIRECTUV: number;
  21724. REFLECTIVITY: boolean;
  21725. REFLECTIVITYDIRECTUV: number;
  21726. SPECULARTERM: boolean;
  21727. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21728. MICROSURFACEAUTOMATIC: boolean;
  21729. LODBASEDMICROSFURACE: boolean;
  21730. MICROSURFACEMAP: boolean;
  21731. MICROSURFACEMAPDIRECTUV: number;
  21732. METALLICWORKFLOW: boolean;
  21733. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21734. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21735. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21736. AOSTOREINMETALMAPRED: boolean;
  21737. METALLIC_REFLECTANCE: boolean;
  21738. METALLIC_REFLECTANCEDIRECTUV: number;
  21739. ENVIRONMENTBRDF: boolean;
  21740. ENVIRONMENTBRDF_RGBD: boolean;
  21741. NORMAL: boolean;
  21742. TANGENT: boolean;
  21743. BUMP: boolean;
  21744. BUMPDIRECTUV: number;
  21745. OBJECTSPACE_NORMALMAP: boolean;
  21746. PARALLAX: boolean;
  21747. PARALLAXOCCLUSION: boolean;
  21748. NORMALXYSCALE: boolean;
  21749. LIGHTMAP: boolean;
  21750. LIGHTMAPDIRECTUV: number;
  21751. USELIGHTMAPASSHADOWMAP: boolean;
  21752. GAMMALIGHTMAP: boolean;
  21753. RGBDLIGHTMAP: boolean;
  21754. REFLECTION: boolean;
  21755. REFLECTIONMAP_3D: boolean;
  21756. REFLECTIONMAP_SPHERICAL: boolean;
  21757. REFLECTIONMAP_PLANAR: boolean;
  21758. REFLECTIONMAP_CUBIC: boolean;
  21759. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21760. REFLECTIONMAP_PROJECTION: boolean;
  21761. REFLECTIONMAP_SKYBOX: boolean;
  21762. REFLECTIONMAP_EXPLICIT: boolean;
  21763. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21764. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21765. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21766. INVERTCUBICMAP: boolean;
  21767. USESPHERICALFROMREFLECTIONMAP: boolean;
  21768. USEIRRADIANCEMAP: boolean;
  21769. SPHERICAL_HARMONICS: boolean;
  21770. USESPHERICALINVERTEX: boolean;
  21771. REFLECTIONMAP_OPPOSITEZ: boolean;
  21772. LODINREFLECTIONALPHA: boolean;
  21773. GAMMAREFLECTION: boolean;
  21774. RGBDREFLECTION: boolean;
  21775. LINEARSPECULARREFLECTION: boolean;
  21776. RADIANCEOCCLUSION: boolean;
  21777. HORIZONOCCLUSION: boolean;
  21778. INSTANCES: boolean;
  21779. THIN_INSTANCES: boolean;
  21780. PREPASS: boolean;
  21781. PREPASS_IRRADIANCE: boolean;
  21782. PREPASS_IRRADIANCE_INDEX: number;
  21783. PREPASS_ALBEDO: boolean;
  21784. PREPASS_ALBEDO_INDEX: number;
  21785. PREPASS_DEPTH: boolean;
  21786. PREPASS_DEPTH_INDEX: number;
  21787. PREPASS_NORMAL: boolean;
  21788. PREPASS_NORMAL_INDEX: number;
  21789. PREPASS_POSITION: boolean;
  21790. PREPASS_POSITION_INDEX: number;
  21791. PREPASS_VELOCITY: boolean;
  21792. PREPASS_VELOCITY_INDEX: number;
  21793. PREPASS_REFLECTIVITY: boolean;
  21794. PREPASS_REFLECTIVITY_INDEX: number;
  21795. SCENE_MRT_COUNT: number;
  21796. NUM_BONE_INFLUENCERS: number;
  21797. BonesPerMesh: number;
  21798. BONETEXTURE: boolean;
  21799. BONES_VELOCITY_ENABLED: boolean;
  21800. NONUNIFORMSCALING: boolean;
  21801. MORPHTARGETS: boolean;
  21802. MORPHTARGETS_NORMAL: boolean;
  21803. MORPHTARGETS_TANGENT: boolean;
  21804. MORPHTARGETS_UV: boolean;
  21805. NUM_MORPH_INFLUENCERS: number;
  21806. IMAGEPROCESSING: boolean;
  21807. VIGNETTE: boolean;
  21808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21809. VIGNETTEBLENDMODEOPAQUE: boolean;
  21810. TONEMAPPING: boolean;
  21811. TONEMAPPING_ACES: boolean;
  21812. CONTRAST: boolean;
  21813. COLORCURVES: boolean;
  21814. COLORGRADING: boolean;
  21815. COLORGRADING3D: boolean;
  21816. SAMPLER3DGREENDEPTH: boolean;
  21817. SAMPLER3DBGRMAP: boolean;
  21818. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21819. EXPOSURE: boolean;
  21820. MULTIVIEW: boolean;
  21821. USEPHYSICALLIGHTFALLOFF: boolean;
  21822. USEGLTFLIGHTFALLOFF: boolean;
  21823. TWOSIDEDLIGHTING: boolean;
  21824. SHADOWFLOAT: boolean;
  21825. CLIPPLANE: boolean;
  21826. CLIPPLANE2: boolean;
  21827. CLIPPLANE3: boolean;
  21828. CLIPPLANE4: boolean;
  21829. CLIPPLANE5: boolean;
  21830. CLIPPLANE6: boolean;
  21831. POINTSIZE: boolean;
  21832. FOG: boolean;
  21833. LOGARITHMICDEPTH: boolean;
  21834. FORCENORMALFORWARD: boolean;
  21835. SPECULARAA: boolean;
  21836. CLEARCOAT: boolean;
  21837. CLEARCOAT_DEFAULTIOR: boolean;
  21838. CLEARCOAT_TEXTURE: boolean;
  21839. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21840. CLEARCOAT_TEXTUREDIRECTUV: number;
  21841. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21842. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21843. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21844. CLEARCOAT_BUMP: boolean;
  21845. CLEARCOAT_BUMPDIRECTUV: number;
  21846. CLEARCOAT_REMAP_F0: boolean;
  21847. CLEARCOAT_TINT: boolean;
  21848. CLEARCOAT_TINT_TEXTURE: boolean;
  21849. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21850. ANISOTROPIC: boolean;
  21851. ANISOTROPIC_TEXTURE: boolean;
  21852. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21853. BRDF_V_HEIGHT_CORRELATED: boolean;
  21854. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21855. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21856. SHEEN: boolean;
  21857. SHEEN_TEXTURE: boolean;
  21858. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21859. SHEEN_TEXTUREDIRECTUV: number;
  21860. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21861. SHEEN_LINKWITHALBEDO: boolean;
  21862. SHEEN_ROUGHNESS: boolean;
  21863. SHEEN_ALBEDOSCALING: boolean;
  21864. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21865. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21866. SUBSURFACE: boolean;
  21867. SS_REFRACTION: boolean;
  21868. SS_TRANSLUCENCY: boolean;
  21869. SS_SCATTERING: boolean;
  21870. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21871. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21872. SS_REFRACTIONMAP_3D: boolean;
  21873. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21874. SS_LODINREFRACTIONALPHA: boolean;
  21875. SS_GAMMAREFRACTION: boolean;
  21876. SS_RGBDREFRACTION: boolean;
  21877. SS_LINEARSPECULARREFRACTION: boolean;
  21878. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21879. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21880. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21881. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21882. UNLIT: boolean;
  21883. DEBUGMODE: number;
  21884. /**
  21885. * Initializes the PBR Material defines.
  21886. */
  21887. constructor();
  21888. /**
  21889. * Resets the PBR Material defines.
  21890. */
  21891. reset(): void;
  21892. }
  21893. /**
  21894. * The Physically based material base class of BJS.
  21895. *
  21896. * This offers the main features of a standard PBR material.
  21897. * For more information, please refer to the documentation :
  21898. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21899. */
  21900. export abstract class PBRBaseMaterial extends PushMaterial {
  21901. /**
  21902. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21903. */
  21904. static readonly PBRMATERIAL_OPAQUE: number;
  21905. /**
  21906. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21907. */
  21908. static readonly PBRMATERIAL_ALPHATEST: number;
  21909. /**
  21910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21911. */
  21912. static readonly PBRMATERIAL_ALPHABLEND: number;
  21913. /**
  21914. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21915. * They are also discarded below the alpha cutoff threshold to improve performances.
  21916. */
  21917. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21918. /**
  21919. * Defines the default value of how much AO map is occluding the analytical lights
  21920. * (point spot...).
  21921. */
  21922. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21923. /**
  21924. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21925. */
  21926. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21927. /**
  21928. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21929. * to enhance interoperability with other engines.
  21930. */
  21931. static readonly LIGHTFALLOFF_GLTF: number;
  21932. /**
  21933. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21934. * to enhance interoperability with other materials.
  21935. */
  21936. static readonly LIGHTFALLOFF_STANDARD: number;
  21937. /**
  21938. * Intensity of the direct lights e.g. the four lights available in your scene.
  21939. * This impacts both the direct diffuse and specular highlights.
  21940. */
  21941. protected _directIntensity: number;
  21942. /**
  21943. * Intensity of the emissive part of the material.
  21944. * This helps controlling the emissive effect without modifying the emissive color.
  21945. */
  21946. protected _emissiveIntensity: number;
  21947. /**
  21948. * Intensity of the environment e.g. how much the environment will light the object
  21949. * either through harmonics for rough material or through the reflection for shiny ones.
  21950. */
  21951. protected _environmentIntensity: number;
  21952. /**
  21953. * This is a special control allowing the reduction of the specular highlights coming from the
  21954. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21955. */
  21956. protected _specularIntensity: number;
  21957. /**
  21958. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21959. */
  21960. private _lightingInfos;
  21961. /**
  21962. * Debug Control allowing disabling the bump map on this material.
  21963. */
  21964. protected _disableBumpMap: boolean;
  21965. /**
  21966. * AKA Diffuse Texture in standard nomenclature.
  21967. */
  21968. protected _albedoTexture: Nullable<BaseTexture>;
  21969. /**
  21970. * AKA Occlusion Texture in other nomenclature.
  21971. */
  21972. protected _ambientTexture: Nullable<BaseTexture>;
  21973. /**
  21974. * AKA Occlusion Texture Intensity in other nomenclature.
  21975. */
  21976. protected _ambientTextureStrength: number;
  21977. /**
  21978. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21979. * 1 means it completely occludes it
  21980. * 0 mean it has no impact
  21981. */
  21982. protected _ambientTextureImpactOnAnalyticalLights: number;
  21983. /**
  21984. * Stores the alpha values in a texture.
  21985. */
  21986. protected _opacityTexture: Nullable<BaseTexture>;
  21987. /**
  21988. * Stores the reflection values in a texture.
  21989. */
  21990. protected _reflectionTexture: Nullable<BaseTexture>;
  21991. /**
  21992. * Stores the emissive values in a texture.
  21993. */
  21994. protected _emissiveTexture: Nullable<BaseTexture>;
  21995. /**
  21996. * AKA Specular texture in other nomenclature.
  21997. */
  21998. protected _reflectivityTexture: Nullable<BaseTexture>;
  21999. /**
  22000. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22001. */
  22002. protected _metallicTexture: Nullable<BaseTexture>;
  22003. /**
  22004. * Specifies the metallic scalar of the metallic/roughness workflow.
  22005. * Can also be used to scale the metalness values of the metallic texture.
  22006. */
  22007. protected _metallic: Nullable<number>;
  22008. /**
  22009. * Specifies the roughness scalar of the metallic/roughness workflow.
  22010. * Can also be used to scale the roughness values of the metallic texture.
  22011. */
  22012. protected _roughness: Nullable<number>;
  22013. /**
  22014. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22015. * By default the indexOfrefraction is used to compute F0;
  22016. *
  22017. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22018. *
  22019. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22020. * F90 = metallicReflectanceColor;
  22021. */
  22022. protected _metallicF0Factor: number;
  22023. /**
  22024. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22025. * By default the F90 is always 1;
  22026. *
  22027. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22028. *
  22029. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22030. * F90 = metallicReflectanceColor;
  22031. */
  22032. protected _metallicReflectanceColor: Color3;
  22033. /**
  22034. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22035. * This is multiply against the scalar values defined in the material.
  22036. */
  22037. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22038. /**
  22039. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22040. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22041. */
  22042. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22043. /**
  22044. * Stores surface normal data used to displace a mesh in a texture.
  22045. */
  22046. protected _bumpTexture: Nullable<BaseTexture>;
  22047. /**
  22048. * Stores the pre-calculated light information of a mesh in a texture.
  22049. */
  22050. protected _lightmapTexture: Nullable<BaseTexture>;
  22051. /**
  22052. * The color of a material in ambient lighting.
  22053. */
  22054. protected _ambientColor: Color3;
  22055. /**
  22056. * AKA Diffuse Color in other nomenclature.
  22057. */
  22058. protected _albedoColor: Color3;
  22059. /**
  22060. * AKA Specular Color in other nomenclature.
  22061. */
  22062. protected _reflectivityColor: Color3;
  22063. /**
  22064. * The color applied when light is reflected from a material.
  22065. */
  22066. protected _reflectionColor: Color3;
  22067. /**
  22068. * The color applied when light is emitted from a material.
  22069. */
  22070. protected _emissiveColor: Color3;
  22071. /**
  22072. * AKA Glossiness in other nomenclature.
  22073. */
  22074. protected _microSurface: number;
  22075. /**
  22076. * Specifies that the material will use the light map as a show map.
  22077. */
  22078. protected _useLightmapAsShadowmap: boolean;
  22079. /**
  22080. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22081. * makes the reflect vector face the model (under horizon).
  22082. */
  22083. protected _useHorizonOcclusion: boolean;
  22084. /**
  22085. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22086. * too much the area relying on ambient texture to define their ambient occlusion.
  22087. */
  22088. protected _useRadianceOcclusion: boolean;
  22089. /**
  22090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22091. */
  22092. protected _useAlphaFromAlbedoTexture: boolean;
  22093. /**
  22094. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22095. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22096. */
  22097. protected _useSpecularOverAlpha: boolean;
  22098. /**
  22099. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22100. */
  22101. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22102. /**
  22103. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22104. */
  22105. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22106. /**
  22107. * Specifies if the metallic texture contains the roughness information in its green channel.
  22108. */
  22109. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22110. /**
  22111. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22112. */
  22113. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22114. /**
  22115. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22116. */
  22117. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22118. /**
  22119. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22120. */
  22121. protected _useAmbientInGrayScale: boolean;
  22122. /**
  22123. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22124. * The material will try to infer what glossiness each pixel should be.
  22125. */
  22126. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22127. /**
  22128. * Defines the falloff type used in this material.
  22129. * It by default is Physical.
  22130. */
  22131. protected _lightFalloff: number;
  22132. /**
  22133. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22134. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22135. */
  22136. protected _useRadianceOverAlpha: boolean;
  22137. /**
  22138. * Allows using an object space normal map (instead of tangent space).
  22139. */
  22140. protected _useObjectSpaceNormalMap: boolean;
  22141. /**
  22142. * Allows using the bump map in parallax mode.
  22143. */
  22144. protected _useParallax: boolean;
  22145. /**
  22146. * Allows using the bump map in parallax occlusion mode.
  22147. */
  22148. protected _useParallaxOcclusion: boolean;
  22149. /**
  22150. * Controls the scale bias of the parallax mode.
  22151. */
  22152. protected _parallaxScaleBias: number;
  22153. /**
  22154. * If sets to true, disables all the lights affecting the material.
  22155. */
  22156. protected _disableLighting: boolean;
  22157. /**
  22158. * Number of Simultaneous lights allowed on the material.
  22159. */
  22160. protected _maxSimultaneousLights: number;
  22161. /**
  22162. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22163. */
  22164. protected _invertNormalMapX: boolean;
  22165. /**
  22166. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22167. */
  22168. protected _invertNormalMapY: boolean;
  22169. /**
  22170. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22171. */
  22172. protected _twoSidedLighting: boolean;
  22173. /**
  22174. * Defines the alpha limits in alpha test mode.
  22175. */
  22176. protected _alphaCutOff: number;
  22177. /**
  22178. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22179. */
  22180. protected _forceAlphaTest: boolean;
  22181. /**
  22182. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22183. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22184. */
  22185. protected _useAlphaFresnel: boolean;
  22186. /**
  22187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22188. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22189. */
  22190. protected _useLinearAlphaFresnel: boolean;
  22191. /**
  22192. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22193. * from cos theta and roughness:
  22194. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22195. */
  22196. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22197. /**
  22198. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22199. */
  22200. protected _forceIrradianceInFragment: boolean;
  22201. private _realTimeFiltering;
  22202. /**
  22203. * Enables realtime filtering on the texture.
  22204. */
  22205. get realTimeFiltering(): boolean;
  22206. set realTimeFiltering(b: boolean);
  22207. private _realTimeFilteringQuality;
  22208. /**
  22209. * Quality switch for realtime filtering
  22210. */
  22211. get realTimeFilteringQuality(): number;
  22212. set realTimeFilteringQuality(n: number);
  22213. /**
  22214. * Can this material render to several textures at once
  22215. */
  22216. get canRenderToMRT(): boolean;
  22217. /**
  22218. * Force normal to face away from face.
  22219. */
  22220. protected _forceNormalForward: boolean;
  22221. /**
  22222. * Enables specular anti aliasing in the PBR shader.
  22223. * It will both interacts on the Geometry for analytical and IBL lighting.
  22224. * It also prefilter the roughness map based on the bump values.
  22225. */
  22226. protected _enableSpecularAntiAliasing: boolean;
  22227. /**
  22228. * Default configuration related to image processing available in the PBR Material.
  22229. */
  22230. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22231. /**
  22232. * Keep track of the image processing observer to allow dispose and replace.
  22233. */
  22234. private _imageProcessingObserver;
  22235. /**
  22236. * Attaches a new image processing configuration to the PBR Material.
  22237. * @param configuration
  22238. */
  22239. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22240. /**
  22241. * Stores the available render targets.
  22242. */
  22243. private _renderTargets;
  22244. /**
  22245. * Sets the global ambient color for the material used in lighting calculations.
  22246. */
  22247. private _globalAmbientColor;
  22248. /**
  22249. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22250. */
  22251. private _useLogarithmicDepth;
  22252. /**
  22253. * If set to true, no lighting calculations will be applied.
  22254. */
  22255. private _unlit;
  22256. private _debugMode;
  22257. /**
  22258. * @hidden
  22259. * This is reserved for the inspector.
  22260. * Defines the material debug mode.
  22261. * It helps seeing only some components of the material while troubleshooting.
  22262. */
  22263. debugMode: number;
  22264. /**
  22265. * @hidden
  22266. * This is reserved for the inspector.
  22267. * Specify from where on screen the debug mode should start.
  22268. * The value goes from -1 (full screen) to 1 (not visible)
  22269. * It helps with side by side comparison against the final render
  22270. * This defaults to -1
  22271. */
  22272. private debugLimit;
  22273. /**
  22274. * @hidden
  22275. * This is reserved for the inspector.
  22276. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22277. * You can use the factor to better multiply the final value.
  22278. */
  22279. private debugFactor;
  22280. /**
  22281. * Defines the clear coat layer parameters for the material.
  22282. */
  22283. readonly clearCoat: PBRClearCoatConfiguration;
  22284. /**
  22285. * Defines the anisotropic parameters for the material.
  22286. */
  22287. readonly anisotropy: PBRAnisotropicConfiguration;
  22288. /**
  22289. * Defines the BRDF parameters for the material.
  22290. */
  22291. readonly brdf: PBRBRDFConfiguration;
  22292. /**
  22293. * Defines the Sheen parameters for the material.
  22294. */
  22295. readonly sheen: PBRSheenConfiguration;
  22296. /**
  22297. * Defines the SubSurface parameters for the material.
  22298. */
  22299. readonly subSurface: PBRSubSurfaceConfiguration;
  22300. /**
  22301. * Defines additional PrePass parameters for the material.
  22302. */
  22303. readonly prePassConfiguration: PrePassConfiguration;
  22304. /**
  22305. * Defines the detail map parameters for the material.
  22306. */
  22307. readonly detailMap: DetailMapConfiguration;
  22308. protected _rebuildInParallel: boolean;
  22309. /**
  22310. * Instantiates a new PBRMaterial instance.
  22311. *
  22312. * @param name The material name
  22313. * @param scene The scene the material will be use in.
  22314. */
  22315. constructor(name: string, scene: Scene);
  22316. /**
  22317. * Gets a boolean indicating that current material needs to register RTT
  22318. */
  22319. get hasRenderTargetTextures(): boolean;
  22320. /**
  22321. * Can this material render to prepass
  22322. */
  22323. get isPrePassCapable(): boolean;
  22324. /**
  22325. * Gets the name of the material class.
  22326. */
  22327. getClassName(): string;
  22328. /**
  22329. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22330. */
  22331. get useLogarithmicDepth(): boolean;
  22332. /**
  22333. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22334. */
  22335. set useLogarithmicDepth(value: boolean);
  22336. /**
  22337. * Returns true if alpha blending should be disabled.
  22338. */
  22339. protected get _disableAlphaBlending(): boolean;
  22340. /**
  22341. * Specifies whether or not this material should be rendered in alpha blend mode.
  22342. */
  22343. needAlphaBlending(): boolean;
  22344. /**
  22345. * Specifies whether or not this material should be rendered in alpha test mode.
  22346. */
  22347. needAlphaTesting(): boolean;
  22348. /**
  22349. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22350. */
  22351. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22352. /**
  22353. * Specifies whether or not there is a usable alpha channel for transparency.
  22354. */
  22355. protected _hasAlphaChannel(): boolean;
  22356. /**
  22357. * Gets the texture used for the alpha test.
  22358. */
  22359. getAlphaTestTexture(): Nullable<BaseTexture>;
  22360. /**
  22361. * Specifies that the submesh is ready to be used.
  22362. * @param mesh - BJS mesh.
  22363. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22364. * @param useInstances - Specifies that instances should be used.
  22365. * @returns - boolean indicating that the submesh is ready or not.
  22366. */
  22367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22368. /**
  22369. * Specifies if the material uses metallic roughness workflow.
  22370. * @returns boolean specifying if the material uses metallic roughness workflow.
  22371. */
  22372. isMetallicWorkflow(): boolean;
  22373. private _prepareEffect;
  22374. private _prepareDefines;
  22375. /**
  22376. * Force shader compilation
  22377. */
  22378. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22379. /**
  22380. * Initializes the uniform buffer layout for the shader.
  22381. */
  22382. buildUniformLayout(): void;
  22383. /**
  22384. * Unbinds the material from the mesh
  22385. */
  22386. unbind(): void;
  22387. /**
  22388. * Binds the submesh data.
  22389. * @param world - The world matrix.
  22390. * @param mesh - The BJS mesh.
  22391. * @param subMesh - A submesh of the BJS mesh.
  22392. */
  22393. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22394. /**
  22395. * Returns the animatable textures.
  22396. * @returns - Array of animatable textures.
  22397. */
  22398. getAnimatables(): IAnimatable[];
  22399. /**
  22400. * Returns the texture used for reflections.
  22401. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22402. */
  22403. private _getReflectionTexture;
  22404. /**
  22405. * Returns an array of the actively used textures.
  22406. * @returns - Array of BaseTextures
  22407. */
  22408. getActiveTextures(): BaseTexture[];
  22409. /**
  22410. * Checks to see if a texture is used in the material.
  22411. * @param texture - Base texture to use.
  22412. * @returns - Boolean specifying if a texture is used in the material.
  22413. */
  22414. hasTexture(texture: BaseTexture): boolean;
  22415. /**
  22416. * Sets the required values to the prepass renderer.
  22417. * @param prePassRenderer defines the prepass renderer to setup
  22418. */
  22419. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22420. /**
  22421. * Disposes the resources of the material.
  22422. * @param forceDisposeEffect - Forces the disposal of effects.
  22423. * @param forceDisposeTextures - Forces the disposal of all textures.
  22424. */
  22425. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22426. }
  22427. }
  22428. declare module BABYLON {
  22429. /**
  22430. * The Physically based material of BJS.
  22431. *
  22432. * This offers the main features of a standard PBR material.
  22433. * For more information, please refer to the documentation :
  22434. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22435. */
  22436. export class PBRMaterial extends PBRBaseMaterial {
  22437. /**
  22438. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22439. */
  22440. static readonly PBRMATERIAL_OPAQUE: number;
  22441. /**
  22442. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22443. */
  22444. static readonly PBRMATERIAL_ALPHATEST: number;
  22445. /**
  22446. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22447. */
  22448. static readonly PBRMATERIAL_ALPHABLEND: number;
  22449. /**
  22450. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22451. * They are also discarded below the alpha cutoff threshold to improve performances.
  22452. */
  22453. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22454. /**
  22455. * Defines the default value of how much AO map is occluding the analytical lights
  22456. * (point spot...).
  22457. */
  22458. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22459. /**
  22460. * Intensity of the direct lights e.g. the four lights available in your scene.
  22461. * This impacts both the direct diffuse and specular highlights.
  22462. */
  22463. directIntensity: number;
  22464. /**
  22465. * Intensity of the emissive part of the material.
  22466. * This helps controlling the emissive effect without modifying the emissive color.
  22467. */
  22468. emissiveIntensity: number;
  22469. /**
  22470. * Intensity of the environment e.g. how much the environment will light the object
  22471. * either through harmonics for rough material or through the reflection for shiny ones.
  22472. */
  22473. environmentIntensity: number;
  22474. /**
  22475. * This is a special control allowing the reduction of the specular highlights coming from the
  22476. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22477. */
  22478. specularIntensity: number;
  22479. /**
  22480. * Debug Control allowing disabling the bump map on this material.
  22481. */
  22482. disableBumpMap: boolean;
  22483. /**
  22484. * AKA Diffuse Texture in standard nomenclature.
  22485. */
  22486. albedoTexture: BaseTexture;
  22487. /**
  22488. * AKA Occlusion Texture in other nomenclature.
  22489. */
  22490. ambientTexture: BaseTexture;
  22491. /**
  22492. * AKA Occlusion Texture Intensity in other nomenclature.
  22493. */
  22494. ambientTextureStrength: number;
  22495. /**
  22496. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22497. * 1 means it completely occludes it
  22498. * 0 mean it has no impact
  22499. */
  22500. ambientTextureImpactOnAnalyticalLights: number;
  22501. /**
  22502. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22503. */
  22504. opacityTexture: BaseTexture;
  22505. /**
  22506. * Stores the reflection values in a texture.
  22507. */
  22508. reflectionTexture: Nullable<BaseTexture>;
  22509. /**
  22510. * Stores the emissive values in a texture.
  22511. */
  22512. emissiveTexture: BaseTexture;
  22513. /**
  22514. * AKA Specular texture in other nomenclature.
  22515. */
  22516. reflectivityTexture: BaseTexture;
  22517. /**
  22518. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22519. */
  22520. metallicTexture: BaseTexture;
  22521. /**
  22522. * Specifies the metallic scalar of the metallic/roughness workflow.
  22523. * Can also be used to scale the metalness values of the metallic texture.
  22524. */
  22525. metallic: Nullable<number>;
  22526. /**
  22527. * Specifies the roughness scalar of the metallic/roughness workflow.
  22528. * Can also be used to scale the roughness values of the metallic texture.
  22529. */
  22530. roughness: Nullable<number>;
  22531. /**
  22532. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22533. * By default the indexOfrefraction is used to compute F0;
  22534. *
  22535. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22536. *
  22537. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22538. * F90 = metallicReflectanceColor;
  22539. */
  22540. metallicF0Factor: number;
  22541. /**
  22542. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22543. * By default the F90 is always 1;
  22544. *
  22545. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22546. *
  22547. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22548. * F90 = metallicReflectanceColor;
  22549. */
  22550. metallicReflectanceColor: Color3;
  22551. /**
  22552. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22553. * This is multiply against the scalar values defined in the material.
  22554. */
  22555. metallicReflectanceTexture: Nullable<BaseTexture>;
  22556. /**
  22557. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22558. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22559. */
  22560. microSurfaceTexture: BaseTexture;
  22561. /**
  22562. * Stores surface normal data used to displace a mesh in a texture.
  22563. */
  22564. bumpTexture: BaseTexture;
  22565. /**
  22566. * Stores the pre-calculated light information of a mesh in a texture.
  22567. */
  22568. lightmapTexture: BaseTexture;
  22569. /**
  22570. * Stores the refracted light information in a texture.
  22571. */
  22572. get refractionTexture(): Nullable<BaseTexture>;
  22573. set refractionTexture(value: Nullable<BaseTexture>);
  22574. /**
  22575. * The color of a material in ambient lighting.
  22576. */
  22577. ambientColor: Color3;
  22578. /**
  22579. * AKA Diffuse Color in other nomenclature.
  22580. */
  22581. albedoColor: Color3;
  22582. /**
  22583. * AKA Specular Color in other nomenclature.
  22584. */
  22585. reflectivityColor: Color3;
  22586. /**
  22587. * The color reflected from the material.
  22588. */
  22589. reflectionColor: Color3;
  22590. /**
  22591. * The color emitted from the material.
  22592. */
  22593. emissiveColor: Color3;
  22594. /**
  22595. * AKA Glossiness in other nomenclature.
  22596. */
  22597. microSurface: number;
  22598. /**
  22599. * Index of refraction of the material base layer.
  22600. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22601. *
  22602. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22603. *
  22604. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22605. */
  22606. get indexOfRefraction(): number;
  22607. set indexOfRefraction(value: number);
  22608. /**
  22609. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22610. */
  22611. get invertRefractionY(): boolean;
  22612. set invertRefractionY(value: boolean);
  22613. /**
  22614. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22615. * Materials half opaque for instance using refraction could benefit from this control.
  22616. */
  22617. get linkRefractionWithTransparency(): boolean;
  22618. set linkRefractionWithTransparency(value: boolean);
  22619. /**
  22620. * If true, the light map contains occlusion information instead of lighting info.
  22621. */
  22622. useLightmapAsShadowmap: boolean;
  22623. /**
  22624. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22625. */
  22626. useAlphaFromAlbedoTexture: boolean;
  22627. /**
  22628. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22629. */
  22630. forceAlphaTest: boolean;
  22631. /**
  22632. * Defines the alpha limits in alpha test mode.
  22633. */
  22634. alphaCutOff: number;
  22635. /**
  22636. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22637. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22638. */
  22639. useSpecularOverAlpha: boolean;
  22640. /**
  22641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22642. */
  22643. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22644. /**
  22645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22646. */
  22647. useRoughnessFromMetallicTextureAlpha: boolean;
  22648. /**
  22649. * Specifies if the metallic texture contains the roughness information in its green channel.
  22650. */
  22651. useRoughnessFromMetallicTextureGreen: boolean;
  22652. /**
  22653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22654. */
  22655. useMetallnessFromMetallicTextureBlue: boolean;
  22656. /**
  22657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22658. */
  22659. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22660. /**
  22661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22662. */
  22663. useAmbientInGrayScale: boolean;
  22664. /**
  22665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22666. * The material will try to infer what glossiness each pixel should be.
  22667. */
  22668. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22669. /**
  22670. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22671. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22672. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22673. */
  22674. get usePhysicalLightFalloff(): boolean;
  22675. /**
  22676. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22677. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22678. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22679. */
  22680. set usePhysicalLightFalloff(value: boolean);
  22681. /**
  22682. * In order to support the falloff compatibility with gltf, a special mode has been added
  22683. * to reproduce the gltf light falloff.
  22684. */
  22685. get useGLTFLightFalloff(): boolean;
  22686. /**
  22687. * In order to support the falloff compatibility with gltf, a special mode has been added
  22688. * to reproduce the gltf light falloff.
  22689. */
  22690. set useGLTFLightFalloff(value: boolean);
  22691. /**
  22692. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22693. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22694. */
  22695. useRadianceOverAlpha: boolean;
  22696. /**
  22697. * Allows using an object space normal map (instead of tangent space).
  22698. */
  22699. useObjectSpaceNormalMap: boolean;
  22700. /**
  22701. * Allows using the bump map in parallax mode.
  22702. */
  22703. useParallax: boolean;
  22704. /**
  22705. * Allows using the bump map in parallax occlusion mode.
  22706. */
  22707. useParallaxOcclusion: boolean;
  22708. /**
  22709. * Controls the scale bias of the parallax mode.
  22710. */
  22711. parallaxScaleBias: number;
  22712. /**
  22713. * If sets to true, disables all the lights affecting the material.
  22714. */
  22715. disableLighting: boolean;
  22716. /**
  22717. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22718. */
  22719. forceIrradianceInFragment: boolean;
  22720. /**
  22721. * Number of Simultaneous lights allowed on the material.
  22722. */
  22723. maxSimultaneousLights: number;
  22724. /**
  22725. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22726. */
  22727. invertNormalMapX: boolean;
  22728. /**
  22729. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22730. */
  22731. invertNormalMapY: boolean;
  22732. /**
  22733. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22734. */
  22735. twoSidedLighting: boolean;
  22736. /**
  22737. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22738. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22739. */
  22740. useAlphaFresnel: boolean;
  22741. /**
  22742. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22743. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22744. */
  22745. useLinearAlphaFresnel: boolean;
  22746. /**
  22747. * Let user defines the brdf lookup texture used for IBL.
  22748. * A default 8bit version is embedded but you could point at :
  22749. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22750. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22751. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22752. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22753. */
  22754. environmentBRDFTexture: Nullable<BaseTexture>;
  22755. /**
  22756. * Force normal to face away from face.
  22757. */
  22758. forceNormalForward: boolean;
  22759. /**
  22760. * Enables specular anti aliasing in the PBR shader.
  22761. * It will both interacts on the Geometry for analytical and IBL lighting.
  22762. * It also prefilter the roughness map based on the bump values.
  22763. */
  22764. enableSpecularAntiAliasing: boolean;
  22765. /**
  22766. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22767. * makes the reflect vector face the model (under horizon).
  22768. */
  22769. useHorizonOcclusion: boolean;
  22770. /**
  22771. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22772. * too much the area relying on ambient texture to define their ambient occlusion.
  22773. */
  22774. useRadianceOcclusion: boolean;
  22775. /**
  22776. * If set to true, no lighting calculations will be applied.
  22777. */
  22778. unlit: boolean;
  22779. /**
  22780. * Gets the image processing configuration used either in this material.
  22781. */
  22782. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22783. /**
  22784. * Sets the Default image processing configuration used either in the this material.
  22785. *
  22786. * If sets to null, the scene one is in use.
  22787. */
  22788. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22789. /**
  22790. * Gets whether the color curves effect is enabled.
  22791. */
  22792. get cameraColorCurvesEnabled(): boolean;
  22793. /**
  22794. * Sets whether the color curves effect is enabled.
  22795. */
  22796. set cameraColorCurvesEnabled(value: boolean);
  22797. /**
  22798. * Gets whether the color grading effect is enabled.
  22799. */
  22800. get cameraColorGradingEnabled(): boolean;
  22801. /**
  22802. * Gets whether the color grading effect is enabled.
  22803. */
  22804. set cameraColorGradingEnabled(value: boolean);
  22805. /**
  22806. * Gets whether tonemapping is enabled or not.
  22807. */
  22808. get cameraToneMappingEnabled(): boolean;
  22809. /**
  22810. * Sets whether tonemapping is enabled or not
  22811. */
  22812. set cameraToneMappingEnabled(value: boolean);
  22813. /**
  22814. * The camera exposure used on this material.
  22815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22816. * This corresponds to a photographic exposure.
  22817. */
  22818. get cameraExposure(): number;
  22819. /**
  22820. * The camera exposure used on this material.
  22821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22822. * This corresponds to a photographic exposure.
  22823. */
  22824. set cameraExposure(value: number);
  22825. /**
  22826. * Gets The camera contrast used on this material.
  22827. */
  22828. get cameraContrast(): number;
  22829. /**
  22830. * Sets The camera contrast used on this material.
  22831. */
  22832. set cameraContrast(value: number);
  22833. /**
  22834. * Gets the Color Grading 2D Lookup Texture.
  22835. */
  22836. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22837. /**
  22838. * Sets the Color Grading 2D Lookup Texture.
  22839. */
  22840. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22841. /**
  22842. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22843. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22844. * 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;
  22845. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22846. */
  22847. get cameraColorCurves(): Nullable<ColorCurves>;
  22848. /**
  22849. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22850. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22851. * 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;
  22852. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22853. */
  22854. set cameraColorCurves(value: Nullable<ColorCurves>);
  22855. /**
  22856. * Instantiates a new PBRMaterial instance.
  22857. *
  22858. * @param name The material name
  22859. * @param scene The scene the material will be use in.
  22860. */
  22861. constructor(name: string, scene: Scene);
  22862. /**
  22863. * Returns the name of this material class.
  22864. */
  22865. getClassName(): string;
  22866. /**
  22867. * Makes a duplicate of the current material.
  22868. * @param name - name to use for the new material.
  22869. */
  22870. clone(name: string): PBRMaterial;
  22871. /**
  22872. * Serializes this PBR Material.
  22873. * @returns - An object with the serialized material.
  22874. */
  22875. serialize(): any;
  22876. /**
  22877. * Parses a PBR Material from a serialized object.
  22878. * @param source - Serialized object.
  22879. * @param scene - BJS scene instance.
  22880. * @param rootUrl - url for the scene object
  22881. * @returns - PBRMaterial
  22882. */
  22883. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22884. }
  22885. }
  22886. declare module BABYLON {
  22887. /** @hidden */
  22888. export var mrtFragmentDeclaration: {
  22889. name: string;
  22890. shader: string;
  22891. };
  22892. }
  22893. declare module BABYLON {
  22894. /** @hidden */
  22895. export var geometryPixelShader: {
  22896. name: string;
  22897. shader: string;
  22898. };
  22899. }
  22900. declare module BABYLON {
  22901. /** @hidden */
  22902. export var instancesDeclaration: {
  22903. name: string;
  22904. shader: string;
  22905. };
  22906. }
  22907. declare module BABYLON {
  22908. /** @hidden */
  22909. export var geometryVertexDeclaration: {
  22910. name: string;
  22911. shader: string;
  22912. };
  22913. }
  22914. declare module BABYLON {
  22915. /** @hidden */
  22916. export var geometryUboDeclaration: {
  22917. name: string;
  22918. shader: string;
  22919. };
  22920. }
  22921. declare module BABYLON {
  22922. /** @hidden */
  22923. export var geometryVertexShader: {
  22924. name: string;
  22925. shader: string;
  22926. };
  22927. }
  22928. declare module BABYLON {
  22929. /** @hidden */
  22930. interface ISavedTransformationMatrix {
  22931. world: Matrix;
  22932. viewProjection: Matrix;
  22933. }
  22934. /**
  22935. * This renderer is helpful to fill one of the render target with a geometry buffer.
  22936. */
  22937. export class GeometryBufferRenderer {
  22938. /**
  22939. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22940. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22941. */
  22942. static readonly DEPTH_TEXTURE_TYPE: number;
  22943. /**
  22944. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22945. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22946. */
  22947. static readonly NORMAL_TEXTURE_TYPE: number;
  22948. /**
  22949. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22950. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22951. */
  22952. static readonly POSITION_TEXTURE_TYPE: number;
  22953. /**
  22954. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22955. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22956. */
  22957. static readonly VELOCITY_TEXTURE_TYPE: number;
  22958. /**
  22959. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22960. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22961. */
  22962. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22963. /**
  22964. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22965. * in order to compute objects velocities when enableVelocity is set to "true"
  22966. * @hidden
  22967. */
  22968. _previousTransformationMatrices: {
  22969. [index: number]: ISavedTransformationMatrix;
  22970. };
  22971. /**
  22972. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22973. * in order to compute objects velocities when enableVelocity is set to "true"
  22974. * @hidden
  22975. */
  22976. _previousBonesTransformationMatrices: {
  22977. [index: number]: Float32Array;
  22978. };
  22979. /**
  22980. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22981. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22982. */
  22983. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22984. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22985. renderTransparentMeshes: boolean;
  22986. private _scene;
  22987. private _resizeObserver;
  22988. private _multiRenderTarget;
  22989. private _ratio;
  22990. private _enablePosition;
  22991. private _enableVelocity;
  22992. private _enableReflectivity;
  22993. private _positionIndex;
  22994. private _velocityIndex;
  22995. private _reflectivityIndex;
  22996. private _depthIndex;
  22997. private _normalIndex;
  22998. private _linkedWithPrePass;
  22999. private _prePassRenderer;
  23000. private _attachments;
  23001. private _useUbo;
  23002. protected _effect: Effect;
  23003. protected _cachedDefines: string;
  23004. /**
  23005. * @hidden
  23006. * Sets up internal structures to share outputs with PrePassRenderer
  23007. * This method should only be called by the PrePassRenderer itself
  23008. */
  23009. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23010. /**
  23011. * @hidden
  23012. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23013. * This method should only be called by the PrePassRenderer itself
  23014. */
  23015. _unlinkPrePassRenderer(): void;
  23016. /**
  23017. * @hidden
  23018. * Resets the geometry buffer layout
  23019. */
  23020. _resetLayout(): void;
  23021. /**
  23022. * @hidden
  23023. * Replaces a texture in the geometry buffer renderer
  23024. * Useful when linking textures of the prepass renderer
  23025. */
  23026. _forceTextureType(geometryBufferType: number, index: number): void;
  23027. /**
  23028. * @hidden
  23029. * Sets texture attachments
  23030. * Useful when linking textures of the prepass renderer
  23031. */
  23032. _setAttachments(attachments: number[]): void;
  23033. /**
  23034. * @hidden
  23035. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23036. * Useful when linking textures of the prepass renderer
  23037. */
  23038. _linkInternalTexture(internalTexture: InternalTexture): void;
  23039. /**
  23040. * Gets the render list (meshes to be rendered) used in the G buffer.
  23041. */
  23042. get renderList(): Nullable<AbstractMesh[]>;
  23043. /**
  23044. * Set the render list (meshes to be rendered) used in the G buffer.
  23045. */
  23046. set renderList(meshes: Nullable<AbstractMesh[]>);
  23047. /**
  23048. * Gets whether or not G buffer are supported by the running hardware.
  23049. * This requires draw buffer supports
  23050. */
  23051. get isSupported(): boolean;
  23052. /**
  23053. * Returns the index of the given texture type in the G-Buffer textures array
  23054. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23055. * @returns the index of the given texture type in the G-Buffer textures array
  23056. */
  23057. getTextureIndex(textureType: number): number;
  23058. /**
  23059. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23060. */
  23061. get enablePosition(): boolean;
  23062. /**
  23063. * Sets whether or not objects positions are enabled for the G buffer.
  23064. */
  23065. set enablePosition(enable: boolean);
  23066. /**
  23067. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23068. */
  23069. get enableVelocity(): boolean;
  23070. /**
  23071. * Sets whether or not objects velocities are enabled for the G buffer.
  23072. */
  23073. set enableVelocity(enable: boolean);
  23074. /**
  23075. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23076. */
  23077. get enableReflectivity(): boolean;
  23078. /**
  23079. * Sets whether or not objects roughness are enabled for the G buffer.
  23080. */
  23081. set enableReflectivity(enable: boolean);
  23082. /**
  23083. * Gets the scene associated with the buffer.
  23084. */
  23085. get scene(): Scene;
  23086. /**
  23087. * Gets the ratio used by the buffer during its creation.
  23088. * How big is the buffer related to the main canvas.
  23089. */
  23090. get ratio(): number;
  23091. /** @hidden */
  23092. static _SceneComponentInitialization: (scene: Scene) => void;
  23093. /**
  23094. * Creates a new G Buffer for the scene
  23095. * @param scene The scene the buffer belongs to
  23096. * @param ratio How big is the buffer related to the main canvas.
  23097. */
  23098. constructor(scene: Scene, ratio?: number);
  23099. /**
  23100. * Checks whether everything is ready to render a submesh to the G buffer.
  23101. * @param subMesh the submesh to check readiness for
  23102. * @param useInstances is the mesh drawn using instance or not
  23103. * @returns true if ready otherwise false
  23104. */
  23105. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23106. /**
  23107. * Gets the current underlying G Buffer.
  23108. * @returns the buffer
  23109. */
  23110. getGBuffer(): MultiRenderTarget;
  23111. /**
  23112. * Gets the number of samples used to render the buffer (anti aliasing).
  23113. */
  23114. get samples(): number;
  23115. /**
  23116. * Sets the number of samples used to render the buffer (anti aliasing).
  23117. */
  23118. set samples(value: number);
  23119. /**
  23120. * Disposes the renderer and frees up associated resources.
  23121. */
  23122. dispose(): void;
  23123. private _assignRenderTargetIndices;
  23124. protected _createRenderTargets(): void;
  23125. private _copyBonesTransformationMatrices;
  23126. }
  23127. }
  23128. declare module BABYLON {
  23129. /**
  23130. * Renders a pre pass of the scene
  23131. * This means every mesh in the scene will be rendered to a render target texture
  23132. * And then this texture will be composited to the rendering canvas with post processes
  23133. * It is necessary for effects like subsurface scattering or deferred shading
  23134. */
  23135. export class PrePassRenderer {
  23136. /** @hidden */
  23137. static _SceneComponentInitialization: (scene: Scene) => void;
  23138. /**
  23139. * To save performance, we can excluded skinned meshes from the prepass
  23140. */
  23141. excludedSkinnedMesh: AbstractMesh[];
  23142. /**
  23143. * Force material to be excluded from the prepass
  23144. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23145. * and you don't want a material to show in the effect.
  23146. */
  23147. excludedMaterials: Material[];
  23148. private _scene;
  23149. private _engine;
  23150. /**
  23151. * Number of textures in the multi render target texture where the scene is directly rendered
  23152. */
  23153. mrtCount: number;
  23154. private _mrtFormats;
  23155. private _mrtLayout;
  23156. private _textureIndices;
  23157. private _multiRenderAttachments;
  23158. private _defaultAttachments;
  23159. private _clearAttachments;
  23160. /**
  23161. * Returns the index of a texture in the multi render target texture array.
  23162. * @param type Texture type
  23163. * @return The index
  23164. */
  23165. getIndex(type: number): number;
  23166. /**
  23167. * How many samples are used for MSAA of the scene render target
  23168. */
  23169. get samples(): number;
  23170. set samples(n: number);
  23171. private static _textureFormats;
  23172. private _isDirty;
  23173. /**
  23174. * The render target where the scene is directly rendered
  23175. */
  23176. defaultRT: PrePassRenderTarget;
  23177. /**
  23178. * Configuration for prepass effects
  23179. */
  23180. private _effectConfigurations;
  23181. /**
  23182. * @return the prepass render target for the rendering pass.
  23183. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23184. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23185. */
  23186. getRenderTarget(): PrePassRenderTarget;
  23187. /**
  23188. * @hidden
  23189. * Managed by the scene component
  23190. * @param prePassRenderTarget
  23191. */
  23192. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23193. /**
  23194. * Returns true if the currently rendered prePassRenderTarget is the one
  23195. * associated with the scene.
  23196. */
  23197. get currentRTisSceneRT(): boolean;
  23198. private _geometryBuffer;
  23199. /**
  23200. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23201. */
  23202. doNotUseGeometryRendererFallback: boolean;
  23203. private _refreshGeometryBufferRendererLink;
  23204. private _currentTarget;
  23205. /**
  23206. * All the render targets generated by prepass
  23207. */
  23208. renderTargets: PrePassRenderTarget[];
  23209. private readonly _clearColor;
  23210. private _enabled;
  23211. private _needsCompositionForThisPass;
  23212. private _postProcessesSourceForThisPass;
  23213. /**
  23214. * Indicates if the prepass is enabled
  23215. */
  23216. get enabled(): boolean;
  23217. /**
  23218. * Set to true to disable gamma transform in PrePass.
  23219. * Can be useful in case you already proceed to gamma transform on a material level
  23220. * and your post processes don't need to be in linear color space.
  23221. */
  23222. disableGammaTransform: boolean;
  23223. /**
  23224. * Instanciates a prepass renderer
  23225. * @param scene The scene
  23226. */
  23227. constructor(scene: Scene);
  23228. /**
  23229. * Creates a new PrePassRenderTarget
  23230. * This should be the only way to instanciate a `PrePassRenderTarget`
  23231. * @param name Name of the `PrePassRenderTarget`
  23232. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23233. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23234. * @hidden
  23235. */
  23236. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23237. /**
  23238. * Indicates if rendering a prepass is supported
  23239. */
  23240. get isSupported(): boolean;
  23241. /**
  23242. * Sets the proper output textures to draw in the engine.
  23243. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23244. * @param subMesh Submesh on which the effect is applied
  23245. */
  23246. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23247. private _reinitializeAttachments;
  23248. private _resetLayout;
  23249. private _updateGeometryBufferLayout;
  23250. /**
  23251. * Restores attachments for single texture draw.
  23252. */
  23253. restoreAttachments(): void;
  23254. /**
  23255. * @hidden
  23256. */
  23257. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23258. private _prepareFrame;
  23259. private _renderPostProcesses;
  23260. /**
  23261. * @hidden
  23262. */
  23263. _afterDraw(faceIndex?: number, layer?: number): void;
  23264. /**
  23265. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23266. * @hidden
  23267. */
  23268. _clear(): void;
  23269. private _bindFrameBuffer;
  23270. private _setEnabled;
  23271. private _setRenderTargetEnabled;
  23272. /**
  23273. * Adds an effect configuration to the prepass render target.
  23274. * If an effect has already been added, it won't add it twice and will return the configuration
  23275. * already present.
  23276. * @param cfg the effect configuration
  23277. * @return the effect configuration now used by the prepass
  23278. */
  23279. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23280. private _enable;
  23281. private _disable;
  23282. private _getPostProcessesSource;
  23283. private _setupOutputForThisPass;
  23284. private _linkInternalTexture;
  23285. private _needsImageProcessing;
  23286. private _hasImageProcessing;
  23287. /**
  23288. * Internal, gets the first post proces.
  23289. * @returns the first post process to be run on this camera.
  23290. */
  23291. private _getFirstPostProcess;
  23292. /**
  23293. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23294. */
  23295. markAsDirty(): void;
  23296. /**
  23297. * Enables a texture on the MultiRenderTarget for prepass
  23298. */
  23299. private _enableTextures;
  23300. private _update;
  23301. private _markAllMaterialsAsPrePassDirty;
  23302. /**
  23303. * Disposes the prepass renderer.
  23304. */
  23305. dispose(): void;
  23306. }
  23307. }
  23308. declare module BABYLON {
  23309. /**
  23310. * Size options for a post process
  23311. */
  23312. export type PostProcessOptions = {
  23313. width: number;
  23314. height: number;
  23315. };
  23316. /**
  23317. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23318. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23319. */
  23320. export class PostProcess {
  23321. /**
  23322. * Gets or sets the unique id of the post process
  23323. */
  23324. uniqueId: number;
  23325. /** Name of the PostProcess. */
  23326. name: string;
  23327. /**
  23328. * Width of the texture to apply the post process on
  23329. */
  23330. width: number;
  23331. /**
  23332. * Height of the texture to apply the post process on
  23333. */
  23334. height: number;
  23335. /**
  23336. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23337. */
  23338. nodeMaterialSource: Nullable<NodeMaterial>;
  23339. /**
  23340. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23341. * @hidden
  23342. */
  23343. _outputTexture: Nullable<InternalTexture>;
  23344. /**
  23345. * Sampling mode used by the shader
  23346. * See https://doc.babylonjs.com/classes/3.1/texture
  23347. */
  23348. renderTargetSamplingMode: number;
  23349. /**
  23350. * Clear color to use when screen clearing
  23351. */
  23352. clearColor: Color4;
  23353. /**
  23354. * If the buffer needs to be cleared before applying the post process. (default: true)
  23355. * Should be set to false if shader will overwrite all previous pixels.
  23356. */
  23357. autoClear: boolean;
  23358. /**
  23359. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23360. */
  23361. alphaMode: number;
  23362. /**
  23363. * Sets the setAlphaBlendConstants of the babylon engine
  23364. */
  23365. alphaConstants: Color4;
  23366. /**
  23367. * Animations to be used for the post processing
  23368. */
  23369. animations: Animation[];
  23370. /**
  23371. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23372. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23373. */
  23374. enablePixelPerfectMode: boolean;
  23375. /**
  23376. * Force the postprocess to be applied without taking in account viewport
  23377. */
  23378. forceFullscreenViewport: boolean;
  23379. /**
  23380. * List of inspectable custom properties (used by the Inspector)
  23381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23382. */
  23383. inspectableCustomProperties: IInspectable[];
  23384. /**
  23385. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23386. *
  23387. * | Value | Type | Description |
  23388. * | ----- | ----------------------------------- | ----------- |
  23389. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23390. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23391. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23392. *
  23393. */
  23394. scaleMode: number;
  23395. /**
  23396. * Force textures to be a power of two (default: false)
  23397. */
  23398. alwaysForcePOT: boolean;
  23399. private _samples;
  23400. /**
  23401. * Number of sample textures (default: 1)
  23402. */
  23403. get samples(): number;
  23404. set samples(n: number);
  23405. /**
  23406. * Modify the scale of the post process to be the same as the viewport (default: false)
  23407. */
  23408. adaptScaleToCurrentViewport: boolean;
  23409. private _camera;
  23410. protected _scene: Scene;
  23411. private _engine;
  23412. private _options;
  23413. private _reusable;
  23414. private _renderId;
  23415. private _textureType;
  23416. private _textureFormat;
  23417. /**
  23418. * Smart array of input and output textures for the post process.
  23419. * @hidden
  23420. */
  23421. _textures: SmartArray<InternalTexture>;
  23422. /**
  23423. * Smart array of input and output textures for the post process.
  23424. * @hidden
  23425. */
  23426. private _textureCache;
  23427. /**
  23428. * The index in _textures that corresponds to the output texture.
  23429. * @hidden
  23430. */
  23431. _currentRenderTextureInd: number;
  23432. private _effect;
  23433. private _samplers;
  23434. private _fragmentUrl;
  23435. private _vertexUrl;
  23436. private _parameters;
  23437. protected _postProcessDefines: Nullable<string>;
  23438. private _scaleRatio;
  23439. protected _indexParameters: any;
  23440. private _shareOutputWithPostProcess;
  23441. private _texelSize;
  23442. /** @hidden */
  23443. _forcedOutputTexture: Nullable<InternalTexture>;
  23444. /**
  23445. * Prepass configuration in case this post process needs a texture from prepass
  23446. * @hidden
  23447. */
  23448. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23449. /**
  23450. * Returns the fragment url or shader name used in the post process.
  23451. * @returns the fragment url or name in the shader store.
  23452. */
  23453. getEffectName(): string;
  23454. /**
  23455. * An event triggered when the postprocess is activated.
  23456. */
  23457. onActivateObservable: Observable<Camera>;
  23458. private _onActivateObserver;
  23459. /**
  23460. * A function that is added to the onActivateObservable
  23461. */
  23462. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23463. /**
  23464. * An event triggered when the postprocess changes its size.
  23465. */
  23466. onSizeChangedObservable: Observable<PostProcess>;
  23467. private _onSizeChangedObserver;
  23468. /**
  23469. * A function that is added to the onSizeChangedObservable
  23470. */
  23471. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23472. /**
  23473. * An event triggered when the postprocess applies its effect.
  23474. */
  23475. onApplyObservable: Observable<Effect>;
  23476. private _onApplyObserver;
  23477. /**
  23478. * A function that is added to the onApplyObservable
  23479. */
  23480. set onApply(callback: (effect: Effect) => void);
  23481. /**
  23482. * An event triggered before rendering the postprocess
  23483. */
  23484. onBeforeRenderObservable: Observable<Effect>;
  23485. private _onBeforeRenderObserver;
  23486. /**
  23487. * A function that is added to the onBeforeRenderObservable
  23488. */
  23489. set onBeforeRender(callback: (effect: Effect) => void);
  23490. /**
  23491. * An event triggered after rendering the postprocess
  23492. */
  23493. onAfterRenderObservable: Observable<Effect>;
  23494. private _onAfterRenderObserver;
  23495. /**
  23496. * A function that is added to the onAfterRenderObservable
  23497. */
  23498. set onAfterRender(callback: (efect: Effect) => void);
  23499. /**
  23500. * 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
  23501. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23502. */
  23503. get inputTexture(): InternalTexture;
  23504. set inputTexture(value: InternalTexture);
  23505. /**
  23506. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23507. * the only way to unset it is to use this function to restore its internal state
  23508. */
  23509. restoreDefaultInputTexture(): void;
  23510. /**
  23511. * Gets the camera which post process is applied to.
  23512. * @returns The camera the post process is applied to.
  23513. */
  23514. getCamera(): Camera;
  23515. /**
  23516. * Gets the texel size of the postprocess.
  23517. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23518. */
  23519. get texelSize(): Vector2;
  23520. /**
  23521. * Creates a new instance PostProcess
  23522. * @param name The name of the PostProcess.
  23523. * @param fragmentUrl The url of the fragment shader to be used.
  23524. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23525. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23526. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23527. * @param camera The camera to apply the render pass to.
  23528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23529. * @param engine The engine which the post process will be applied. (default: current engine)
  23530. * @param reusable If the post process can be reused on the same frame. (default: false)
  23531. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23532. * @param textureType Type of textures used when performing the post process. (default: 0)
  23533. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23534. * @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
  23535. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23536. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23537. */
  23538. 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);
  23539. /**
  23540. * Gets a string identifying the name of the class
  23541. * @returns "PostProcess" string
  23542. */
  23543. getClassName(): string;
  23544. /**
  23545. * Gets the engine which this post process belongs to.
  23546. * @returns The engine the post process was enabled with.
  23547. */
  23548. getEngine(): Engine;
  23549. /**
  23550. * The effect that is created when initializing the post process.
  23551. * @returns The created effect corresponding the the postprocess.
  23552. */
  23553. getEffect(): Effect;
  23554. /**
  23555. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23556. * @param postProcess The post process to share the output with.
  23557. * @returns This post process.
  23558. */
  23559. shareOutputWith(postProcess: PostProcess): PostProcess;
  23560. /**
  23561. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23562. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23563. */
  23564. useOwnOutput(): void;
  23565. /**
  23566. * Updates the effect with the current post process compile time values and recompiles the shader.
  23567. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23568. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23569. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23570. * @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
  23571. * @param onCompiled Called when the shader has been compiled.
  23572. * @param onError Called if there is an error when compiling a shader.
  23573. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23574. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23575. */
  23576. 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;
  23577. /**
  23578. * The post process is reusable if it can be used multiple times within one frame.
  23579. * @returns If the post process is reusable
  23580. */
  23581. isReusable(): boolean;
  23582. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23583. markTextureDirty(): void;
  23584. private _createRenderTargetTexture;
  23585. private _flushTextureCache;
  23586. private _resize;
  23587. /**
  23588. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23589. * 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.
  23590. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23591. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23592. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23593. * @returns The target texture that was bound to be written to.
  23594. */
  23595. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23596. /**
  23597. * If the post process is supported.
  23598. */
  23599. get isSupported(): boolean;
  23600. /**
  23601. * The aspect ratio of the output texture.
  23602. */
  23603. get aspectRatio(): number;
  23604. /**
  23605. * Get a value indicating if the post-process is ready to be used
  23606. * @returns true if the post-process is ready (shader is compiled)
  23607. */
  23608. isReady(): boolean;
  23609. /**
  23610. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23611. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23612. */
  23613. apply(): Nullable<Effect>;
  23614. private _disposeTextures;
  23615. private _disposeTextureCache;
  23616. /**
  23617. * Sets the required values to the prepass renderer.
  23618. * @param prePassRenderer defines the prepass renderer to setup.
  23619. * @returns true if the pre pass is needed.
  23620. */
  23621. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23622. /**
  23623. * Disposes the post process.
  23624. * @param camera The camera to dispose the post process on.
  23625. */
  23626. dispose(camera?: Camera): void;
  23627. /**
  23628. * Serializes the particle system to a JSON object
  23629. * @returns the JSON object
  23630. */
  23631. serialize(): any;
  23632. /**
  23633. * Clones this post process
  23634. * @returns a new post process similar to this one
  23635. */
  23636. clone(): Nullable<PostProcess>;
  23637. /**
  23638. * Creates a material from parsed material data
  23639. * @param parsedPostProcess defines parsed post process data
  23640. * @param scene defines the hosting scene
  23641. * @param rootUrl defines the root URL to use to load textures
  23642. * @returns a new post process
  23643. */
  23644. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23645. /** @hidden */
  23646. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23647. }
  23648. }
  23649. declare module BABYLON {
  23650. /** @hidden */
  23651. export var kernelBlurVaryingDeclaration: {
  23652. name: string;
  23653. shader: string;
  23654. };
  23655. }
  23656. declare module BABYLON {
  23657. /** @hidden */
  23658. export var packingFunctions: {
  23659. name: string;
  23660. shader: string;
  23661. };
  23662. }
  23663. declare module BABYLON {
  23664. /** @hidden */
  23665. export var kernelBlurFragment: {
  23666. name: string;
  23667. shader: string;
  23668. };
  23669. }
  23670. declare module BABYLON {
  23671. /** @hidden */
  23672. export var kernelBlurFragment2: {
  23673. name: string;
  23674. shader: string;
  23675. };
  23676. }
  23677. declare module BABYLON {
  23678. /** @hidden */
  23679. export var kernelBlurPixelShader: {
  23680. name: string;
  23681. shader: string;
  23682. };
  23683. }
  23684. declare module BABYLON {
  23685. /** @hidden */
  23686. export var kernelBlurVertex: {
  23687. name: string;
  23688. shader: string;
  23689. };
  23690. }
  23691. declare module BABYLON {
  23692. /** @hidden */
  23693. export var kernelBlurVertexShader: {
  23694. name: string;
  23695. shader: string;
  23696. };
  23697. }
  23698. declare module BABYLON {
  23699. /**
  23700. * The Blur Post Process which blurs an image based on a kernel and direction.
  23701. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23702. */
  23703. export class BlurPostProcess extends PostProcess {
  23704. private blockCompilation;
  23705. protected _kernel: number;
  23706. protected _idealKernel: number;
  23707. protected _packedFloat: boolean;
  23708. private _staticDefines;
  23709. /** The direction in which to blur the image. */
  23710. direction: Vector2;
  23711. /**
  23712. * Sets the length in pixels of the blur sample region
  23713. */
  23714. set kernel(v: number);
  23715. /**
  23716. * Gets the length in pixels of the blur sample region
  23717. */
  23718. get kernel(): number;
  23719. /**
  23720. * Sets whether or not the blur needs to unpack/repack floats
  23721. */
  23722. set packedFloat(v: boolean);
  23723. /**
  23724. * Gets whether or not the blur is unpacking/repacking floats
  23725. */
  23726. get packedFloat(): boolean;
  23727. /**
  23728. * Gets a string identifying the name of the class
  23729. * @returns "BlurPostProcess" string
  23730. */
  23731. getClassName(): string;
  23732. /**
  23733. * Creates a new instance BlurPostProcess
  23734. * @param name The name of the effect.
  23735. * @param direction The direction in which to blur the image.
  23736. * @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.
  23737. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23738. * @param camera The camera to apply the render pass to.
  23739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23740. * @param engine The engine which the post process will be applied. (default: current engine)
  23741. * @param reusable If the post process can be reused on the same frame. (default: false)
  23742. * @param textureType Type of textures used when performing the post process. (default: 0)
  23743. * @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)
  23744. */
  23745. 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);
  23746. /**
  23747. * Updates the effect with the current post process compile time values and recompiles the shader.
  23748. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23749. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23750. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23751. * @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
  23752. * @param onCompiled Called when the shader has been compiled.
  23753. * @param onError Called if there is an error when compiling a shader.
  23754. */
  23755. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23756. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23757. /**
  23758. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23759. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23760. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23761. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23762. * The gaps between physical kernels are compensated for in the weighting of the samples
  23763. * @param idealKernel Ideal blur kernel.
  23764. * @return Nearest best kernel.
  23765. */
  23766. protected _nearestBestKernel(idealKernel: number): number;
  23767. /**
  23768. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23769. * @param x The point on the Gaussian distribution to sample.
  23770. * @return the value of the Gaussian function at x.
  23771. */
  23772. protected _gaussianWeight(x: number): number;
  23773. /**
  23774. * Generates a string that can be used as a floating point number in GLSL.
  23775. * @param x Value to print.
  23776. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23777. * @return GLSL float string.
  23778. */
  23779. protected _glslFloat(x: number, decimalFigures?: number): string;
  23780. /** @hidden */
  23781. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23782. }
  23783. }
  23784. declare module BABYLON {
  23785. /**
  23786. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23787. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23788. * You can then easily use it as a reflectionTexture on a flat surface.
  23789. * In case the surface is not a plane, please consider relying on reflection probes.
  23790. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23791. */
  23792. export class MirrorTexture extends RenderTargetTexture {
  23793. private scene;
  23794. /**
  23795. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23796. * 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.
  23797. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23798. */
  23799. mirrorPlane: Plane;
  23800. /**
  23801. * Define the blur ratio used to blur the reflection if needed.
  23802. */
  23803. set blurRatio(value: number);
  23804. get blurRatio(): number;
  23805. /**
  23806. * Define the adaptive blur kernel used to blur the reflection if needed.
  23807. * This will autocompute the closest best match for the `blurKernel`
  23808. */
  23809. set adaptiveBlurKernel(value: number);
  23810. /**
  23811. * Define the blur kernel used to blur the reflection if needed.
  23812. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23813. */
  23814. set blurKernel(value: number);
  23815. /**
  23816. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23817. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23818. */
  23819. set blurKernelX(value: number);
  23820. get blurKernelX(): number;
  23821. /**
  23822. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23823. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23824. */
  23825. set blurKernelY(value: number);
  23826. get blurKernelY(): number;
  23827. private _autoComputeBlurKernel;
  23828. protected _onRatioRescale(): void;
  23829. private _updateGammaSpace;
  23830. private _imageProcessingConfigChangeObserver;
  23831. private _transformMatrix;
  23832. private _mirrorMatrix;
  23833. private _blurX;
  23834. private _blurY;
  23835. private _adaptiveBlurKernel;
  23836. private _blurKernelX;
  23837. private _blurKernelY;
  23838. private _blurRatio;
  23839. /**
  23840. * Instantiates a Mirror Texture.
  23841. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23842. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23843. * You can then easily use it as a reflectionTexture on a flat surface.
  23844. * In case the surface is not a plane, please consider relying on reflection probes.
  23845. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23846. * @param name
  23847. * @param size
  23848. * @param scene
  23849. * @param generateMipMaps
  23850. * @param type
  23851. * @param samplingMode
  23852. * @param generateDepthBuffer
  23853. */
  23854. constructor(name: string, size: number | {
  23855. width: number;
  23856. height: number;
  23857. } | {
  23858. ratio: number;
  23859. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23860. private _preparePostProcesses;
  23861. /**
  23862. * Clone the mirror texture.
  23863. * @returns the cloned texture
  23864. */
  23865. clone(): MirrorTexture;
  23866. /**
  23867. * Serialize the texture to a JSON representation you could use in Parse later on
  23868. * @returns the serialized JSON representation
  23869. */
  23870. serialize(): any;
  23871. /**
  23872. * Dispose the texture and release its associated resources.
  23873. */
  23874. dispose(): void;
  23875. }
  23876. }
  23877. declare module BABYLON {
  23878. /**
  23879. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23880. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23881. */
  23882. export class Texture extends BaseTexture {
  23883. /**
  23884. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23885. */
  23886. static SerializeBuffers: boolean;
  23887. /**
  23888. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23889. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23890. */
  23891. static ForceSerializeBuffers: boolean;
  23892. /** @hidden */
  23893. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23894. /** @hidden */
  23895. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23896. /** @hidden */
  23897. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23898. /** nearest is mag = nearest and min = nearest and mip = linear */
  23899. static readonly NEAREST_SAMPLINGMODE: number;
  23900. /** nearest is mag = nearest and min = nearest and mip = linear */
  23901. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23903. static readonly BILINEAR_SAMPLINGMODE: number;
  23904. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23905. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23906. /** Trilinear is mag = linear and min = linear and mip = linear */
  23907. static readonly TRILINEAR_SAMPLINGMODE: number;
  23908. /** Trilinear is mag = linear and min = linear and mip = linear */
  23909. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23910. /** mag = nearest and min = nearest and mip = nearest */
  23911. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23912. /** mag = nearest and min = linear and mip = nearest */
  23913. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23914. /** mag = nearest and min = linear and mip = linear */
  23915. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23916. /** mag = nearest and min = linear and mip = none */
  23917. static readonly NEAREST_LINEAR: number;
  23918. /** mag = nearest and min = nearest and mip = none */
  23919. static readonly NEAREST_NEAREST: number;
  23920. /** mag = linear and min = nearest and mip = nearest */
  23921. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23922. /** mag = linear and min = nearest and mip = linear */
  23923. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23924. /** mag = linear and min = linear and mip = none */
  23925. static readonly LINEAR_LINEAR: number;
  23926. /** mag = linear and min = nearest and mip = none */
  23927. static readonly LINEAR_NEAREST: number;
  23928. /** Explicit coordinates mode */
  23929. static readonly EXPLICIT_MODE: number;
  23930. /** Spherical coordinates mode */
  23931. static readonly SPHERICAL_MODE: number;
  23932. /** Planar coordinates mode */
  23933. static readonly PLANAR_MODE: number;
  23934. /** Cubic coordinates mode */
  23935. static readonly CUBIC_MODE: number;
  23936. /** Projection coordinates mode */
  23937. static readonly PROJECTION_MODE: number;
  23938. /** Inverse Cubic coordinates mode */
  23939. static readonly SKYBOX_MODE: number;
  23940. /** Inverse Cubic coordinates mode */
  23941. static readonly INVCUBIC_MODE: number;
  23942. /** Equirectangular coordinates mode */
  23943. static readonly EQUIRECTANGULAR_MODE: number;
  23944. /** Equirectangular Fixed coordinates mode */
  23945. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23946. /** Equirectangular Fixed Mirrored coordinates mode */
  23947. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23948. /** Texture is not repeating outside of 0..1 UVs */
  23949. static readonly CLAMP_ADDRESSMODE: number;
  23950. /** Texture is repeating outside of 0..1 UVs */
  23951. static readonly WRAP_ADDRESSMODE: number;
  23952. /** Texture is repeating and mirrored */
  23953. static readonly MIRROR_ADDRESSMODE: number;
  23954. /**
  23955. * 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
  23956. */
  23957. static UseSerializedUrlIfAny: boolean;
  23958. /**
  23959. * Define the url of the texture.
  23960. */
  23961. url: Nullable<string>;
  23962. /**
  23963. * Define an offset on the texture to offset the u coordinates of the UVs
  23964. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23965. */
  23966. uOffset: number;
  23967. /**
  23968. * Define an offset on the texture to offset the v coordinates of the UVs
  23969. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23970. */
  23971. vOffset: number;
  23972. /**
  23973. * Define an offset on the texture to scale the u coordinates of the UVs
  23974. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23975. */
  23976. uScale: number;
  23977. /**
  23978. * Define an offset on the texture to scale the v coordinates of the UVs
  23979. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23980. */
  23981. vScale: number;
  23982. /**
  23983. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23984. * @see https://doc.babylonjs.com/how_to/more_materials
  23985. */
  23986. uAng: number;
  23987. /**
  23988. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23989. * @see https://doc.babylonjs.com/how_to/more_materials
  23990. */
  23991. vAng: number;
  23992. /**
  23993. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23994. * @see https://doc.babylonjs.com/how_to/more_materials
  23995. */
  23996. wAng: number;
  23997. /**
  23998. * Defines the center of rotation (U)
  23999. */
  24000. uRotationCenter: number;
  24001. /**
  24002. * Defines the center of rotation (V)
  24003. */
  24004. vRotationCenter: number;
  24005. /**
  24006. * Defines the center of rotation (W)
  24007. */
  24008. wRotationCenter: number;
  24009. /**
  24010. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24011. */
  24012. homogeneousRotationInUVTransform: boolean;
  24013. /**
  24014. * Are mip maps generated for this texture or not.
  24015. */
  24016. get noMipmap(): boolean;
  24017. /**
  24018. * List of inspectable custom properties (used by the Inspector)
  24019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24020. */
  24021. inspectableCustomProperties: Nullable<IInspectable[]>;
  24022. private _noMipmap;
  24023. /** @hidden */
  24024. _invertY: boolean;
  24025. private _rowGenerationMatrix;
  24026. private _cachedTextureMatrix;
  24027. private _projectionModeMatrix;
  24028. private _t0;
  24029. private _t1;
  24030. private _t2;
  24031. private _cachedUOffset;
  24032. private _cachedVOffset;
  24033. private _cachedUScale;
  24034. private _cachedVScale;
  24035. private _cachedUAng;
  24036. private _cachedVAng;
  24037. private _cachedWAng;
  24038. private _cachedProjectionMatrixId;
  24039. private _cachedURotationCenter;
  24040. private _cachedVRotationCenter;
  24041. private _cachedWRotationCenter;
  24042. private _cachedHomogeneousRotationInUVTransform;
  24043. private _cachedCoordinatesMode;
  24044. /** @hidden */
  24045. protected _initialSamplingMode: number;
  24046. /** @hidden */
  24047. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24048. private _deleteBuffer;
  24049. protected _format: Nullable<number>;
  24050. private _delayedOnLoad;
  24051. private _delayedOnError;
  24052. private _mimeType?;
  24053. private _loaderOptions?;
  24054. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24055. get mimeType(): string | undefined;
  24056. /**
  24057. * Observable triggered once the texture has been loaded.
  24058. */
  24059. onLoadObservable: Observable<Texture>;
  24060. protected _isBlocking: boolean;
  24061. /**
  24062. * Is the texture preventing material to render while loading.
  24063. * If false, a default texture will be used instead of the loading one during the preparation step.
  24064. */
  24065. set isBlocking(value: boolean);
  24066. get isBlocking(): boolean;
  24067. /**
  24068. * Get the current sampling mode associated with the texture.
  24069. */
  24070. get samplingMode(): number;
  24071. /**
  24072. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24073. */
  24074. get invertY(): boolean;
  24075. /**
  24076. * Instantiates a new texture.
  24077. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24078. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24079. * @param url defines the url of the picture to load as a texture
  24080. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24081. * @param noMipmap defines if the texture will require mip maps or not
  24082. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24083. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24084. * @param onLoad defines a callback triggered when the texture has been loaded
  24085. * @param onError defines a callback triggered when an error occurred during the loading session
  24086. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24087. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24088. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24089. * @param mimeType defines an optional mime type information
  24090. * @param loaderOptions options to be passed to the loader
  24091. */
  24092. 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);
  24093. /**
  24094. * Update the url (and optional buffer) of this texture if url was null during construction.
  24095. * @param url the url of the texture
  24096. * @param buffer the buffer of the texture (defaults to null)
  24097. * @param onLoad callback called when the texture is loaded (defaults to null)
  24098. */
  24099. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24100. /**
  24101. * Finish the loading sequence of a texture flagged as delayed load.
  24102. * @hidden
  24103. */
  24104. delayLoad(): void;
  24105. private _prepareRowForTextureGeneration;
  24106. /**
  24107. * Checks if the texture has the same transform matrix than another texture
  24108. * @param texture texture to check against
  24109. * @returns true if the transforms are the same, else false
  24110. */
  24111. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24112. /**
  24113. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24114. * @returns the transform matrix of the texture.
  24115. */
  24116. getTextureMatrix(uBase?: number): Matrix;
  24117. /**
  24118. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24119. * @returns The reflection texture transform
  24120. */
  24121. getReflectionTextureMatrix(): Matrix;
  24122. /**
  24123. * Clones the texture.
  24124. * @returns the cloned texture
  24125. */
  24126. clone(): Texture;
  24127. /**
  24128. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24129. * @returns The JSON representation of the texture
  24130. */
  24131. serialize(): any;
  24132. /**
  24133. * Get the current class name of the texture useful for serialization or dynamic coding.
  24134. * @returns "Texture"
  24135. */
  24136. getClassName(): string;
  24137. /**
  24138. * Dispose the texture and release its associated resources.
  24139. */
  24140. dispose(): void;
  24141. /**
  24142. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24143. * @param parsedTexture Define the JSON representation of the texture
  24144. * @param scene Define the scene the parsed texture should be instantiated in
  24145. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24146. * @returns The parsed texture if successful
  24147. */
  24148. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24149. /**
  24150. * Creates a texture from its base 64 representation.
  24151. * @param data Define the base64 payload without the data: prefix
  24152. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24153. * @param scene Define the scene the texture should belong to
  24154. * @param noMipmap Forces the texture to not create mip map information if true
  24155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24156. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24157. * @param onLoad define a callback triggered when the texture has been loaded
  24158. * @param onError define a callback triggered when an error occurred during the loading session
  24159. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24160. * @returns the created texture
  24161. */
  24162. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24163. /**
  24164. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24165. * @param data Define the base64 payload without the data: prefix
  24166. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24167. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24168. * @param scene Define the scene the texture should belong to
  24169. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24170. * @param noMipmap Forces the texture to not create mip map information if true
  24171. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24172. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24173. * @param onLoad define a callback triggered when the texture has been loaded
  24174. * @param onError define a callback triggered when an error occurred during the loading session
  24175. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24176. * @returns the created texture
  24177. */
  24178. 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;
  24179. }
  24180. }
  24181. declare module BABYLON {
  24182. /**
  24183. * ThinSprite Class used to represent a thin sprite
  24184. * This is the base class for sprites but can also directly be used with ThinEngine
  24185. * @see https://doc.babylonjs.com/babylon101/sprites
  24186. */
  24187. export class ThinSprite {
  24188. /** Gets or sets the cell index in the sprite sheet */
  24189. cellIndex: number;
  24190. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24191. cellRef: string;
  24192. /** Gets or sets the current world position */
  24193. position: IVector3Like;
  24194. /** Gets or sets the main color */
  24195. color: IColor4Like;
  24196. /** Gets or sets the width */
  24197. width: number;
  24198. /** Gets or sets the height */
  24199. height: number;
  24200. /** Gets or sets rotation angle */
  24201. angle: number;
  24202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24203. invertU: boolean;
  24204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24205. invertV: boolean;
  24206. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24207. isVisible: boolean;
  24208. /**
  24209. * Returns a boolean indicating if the animation is started
  24210. */
  24211. get animationStarted(): boolean;
  24212. /** Gets the initial key for the animation (setting it will restart the animation) */
  24213. get fromIndex(): number;
  24214. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24215. get toIndex(): number;
  24216. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24217. get loopAnimation(): boolean;
  24218. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24219. get delay(): number;
  24220. /** @hidden */
  24221. _xOffset: number;
  24222. /** @hidden */
  24223. _yOffset: number;
  24224. /** @hidden */
  24225. _xSize: number;
  24226. /** @hidden */
  24227. _ySize: number;
  24228. private _animationStarted;
  24229. protected _loopAnimation: boolean;
  24230. protected _fromIndex: number;
  24231. protected _toIndex: number;
  24232. protected _delay: number;
  24233. private _direction;
  24234. private _time;
  24235. private _onBaseAnimationEnd;
  24236. /**
  24237. * Creates a new Thin Sprite
  24238. */
  24239. constructor();
  24240. /**
  24241. * Starts an animation
  24242. * @param from defines the initial key
  24243. * @param to defines the end key
  24244. * @param loop defines if the animation must loop
  24245. * @param delay defines the start delay (in ms)
  24246. * @param onAnimationEnd defines a callback for when the animation ends
  24247. */
  24248. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24249. /** Stops current animation (if any) */
  24250. stopAnimation(): void;
  24251. /** @hidden */
  24252. _animate(deltaTime: number): void;
  24253. }
  24254. }
  24255. declare module BABYLON {
  24256. /** @hidden */
  24257. export var imageProcessingCompatibility: {
  24258. name: string;
  24259. shader: string;
  24260. };
  24261. }
  24262. declare module BABYLON {
  24263. /** @hidden */
  24264. export var spritesPixelShader: {
  24265. name: string;
  24266. shader: string;
  24267. };
  24268. }
  24269. declare module BABYLON {
  24270. /** @hidden */
  24271. export var spritesVertexShader: {
  24272. name: string;
  24273. shader: string;
  24274. };
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * Class used to render sprites.
  24279. *
  24280. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24281. */
  24282. export class SpriteRenderer {
  24283. /**
  24284. * Defines the texture of the spritesheet
  24285. */
  24286. texture: Nullable<ThinTexture>;
  24287. /**
  24288. * Defines the default width of a cell in the spritesheet
  24289. */
  24290. cellWidth: number;
  24291. /**
  24292. * Defines the default height of a cell in the spritesheet
  24293. */
  24294. cellHeight: number;
  24295. /**
  24296. * Blend mode use to render the particle, it can be any of
  24297. * the static Constants.ALPHA_x properties provided in this class.
  24298. * Default value is Constants.ALPHA_COMBINE
  24299. */
  24300. blendMode: number;
  24301. /**
  24302. * Gets or sets a boolean indicating if alpha mode is automatically
  24303. * reset.
  24304. */
  24305. autoResetAlpha: boolean;
  24306. /**
  24307. * Disables writing to the depth buffer when rendering the sprites.
  24308. * It can be handy to disable depth writing when using textures without alpha channel
  24309. * and setting some specific blend modes.
  24310. */
  24311. disableDepthWrite: boolean;
  24312. /**
  24313. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24314. */
  24315. fogEnabled: boolean;
  24316. /**
  24317. * Gets the capacity of the manager
  24318. */
  24319. get capacity(): number;
  24320. private readonly _engine;
  24321. private readonly _useVAO;
  24322. private readonly _useInstancing;
  24323. private readonly _scene;
  24324. private readonly _capacity;
  24325. private readonly _epsilon;
  24326. private _vertexBufferSize;
  24327. private _vertexData;
  24328. private _buffer;
  24329. private _vertexBuffers;
  24330. private _spriteBuffer;
  24331. private _indexBuffer;
  24332. private _effectBase;
  24333. private _effectFog;
  24334. private _vertexArrayObject;
  24335. /**
  24336. * Creates a new sprite Renderer
  24337. * @param engine defines the engine the renderer works with
  24338. * @param capacity defines the maximum allowed number of sprites
  24339. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24340. * @param scene defines the hosting scene
  24341. */
  24342. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24343. /**
  24344. * Render all child sprites
  24345. * @param sprites defines the list of sprites to render
  24346. * @param deltaTime defines the time since last frame
  24347. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24348. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24349. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24350. */
  24351. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24352. private _appendSpriteVertex;
  24353. /**
  24354. * Release associated resources
  24355. */
  24356. dispose(): void;
  24357. }
  24358. }
  24359. declare module BABYLON {
  24360. /**
  24361. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24362. */
  24363. export interface ISpriteManager extends IDisposable {
  24364. /**
  24365. * Gets manager's name
  24366. */
  24367. name: string;
  24368. /**
  24369. * Restricts the camera to viewing objects with the same layerMask.
  24370. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24371. */
  24372. layerMask: number;
  24373. /**
  24374. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24375. */
  24376. isPickable: boolean;
  24377. /**
  24378. * Gets the hosting scene
  24379. */
  24380. scene: Scene;
  24381. /**
  24382. * Specifies the rendering group id for this mesh (0 by default)
  24383. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24384. */
  24385. renderingGroupId: number;
  24386. /**
  24387. * Defines the list of sprites managed by the manager.
  24388. */
  24389. sprites: Array<Sprite>;
  24390. /**
  24391. * Gets or sets the spritesheet texture
  24392. */
  24393. texture: Texture;
  24394. /** Defines the default width of a cell in the spritesheet */
  24395. cellWidth: number;
  24396. /** Defines the default height of a cell in the spritesheet */
  24397. cellHeight: number;
  24398. /**
  24399. * Tests the intersection of a sprite with a specific ray.
  24400. * @param ray The ray we are sending to test the collision
  24401. * @param camera The camera space we are sending rays in
  24402. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24403. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24404. * @returns picking info or null.
  24405. */
  24406. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24407. /**
  24408. * Intersects the sprites with a ray
  24409. * @param ray defines the ray to intersect with
  24410. * @param camera defines the current active camera
  24411. * @param predicate defines a predicate used to select candidate sprites
  24412. * @returns null if no hit or a PickingInfo array
  24413. */
  24414. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24415. /**
  24416. * Renders the list of sprites on screen.
  24417. */
  24418. render(): void;
  24419. }
  24420. /**
  24421. * Class used to manage multiple sprites on the same spritesheet
  24422. * @see https://doc.babylonjs.com/babylon101/sprites
  24423. */
  24424. export class SpriteManager implements ISpriteManager {
  24425. /** defines the manager's name */
  24426. name: string;
  24427. /** Define the Url to load snippets */
  24428. static SnippetUrl: string;
  24429. /** Snippet ID if the manager was created from the snippet server */
  24430. snippetId: string;
  24431. /** Gets the list of sprites */
  24432. sprites: Sprite[];
  24433. /** Gets or sets the rendering group id (0 by default) */
  24434. renderingGroupId: number;
  24435. /** Gets or sets camera layer mask */
  24436. layerMask: number;
  24437. /** Gets or sets a boolean indicating if the sprites are pickable */
  24438. isPickable: boolean;
  24439. /**
  24440. * An event triggered when the manager is disposed.
  24441. */
  24442. onDisposeObservable: Observable<SpriteManager>;
  24443. /**
  24444. * Callback called when the manager is disposed
  24445. */
  24446. set onDispose(callback: () => void);
  24447. /**
  24448. * Gets or sets the unique id of the sprite
  24449. */
  24450. uniqueId: number;
  24451. /**
  24452. * Gets the array of sprites
  24453. */
  24454. get children(): Sprite[];
  24455. /**
  24456. * Gets the hosting scene
  24457. */
  24458. get scene(): Scene;
  24459. /**
  24460. * Gets the capacity of the manager
  24461. */
  24462. get capacity(): number;
  24463. /**
  24464. * Gets or sets the spritesheet texture
  24465. */
  24466. get texture(): Texture;
  24467. set texture(value: Texture);
  24468. /** Defines the default width of a cell in the spritesheet */
  24469. get cellWidth(): number;
  24470. set cellWidth(value: number);
  24471. /** Defines the default height of a cell in the spritesheet */
  24472. get cellHeight(): number;
  24473. set cellHeight(value: number);
  24474. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24475. get fogEnabled(): boolean;
  24476. set fogEnabled(value: boolean);
  24477. /**
  24478. * Blend mode use to render the particle, it can be any of
  24479. * the static Constants.ALPHA_x properties provided in this class.
  24480. * Default value is Constants.ALPHA_COMBINE
  24481. */
  24482. get blendMode(): number;
  24483. set blendMode(blendMode: number);
  24484. /** Disables writing to the depth buffer when rendering the sprites.
  24485. * It can be handy to disable depth writing when using textures without alpha channel
  24486. * and setting some specific blend modes.
  24487. */
  24488. disableDepthWrite: boolean;
  24489. private _spriteRenderer;
  24490. /** Associative array from JSON sprite data file */
  24491. private _cellData;
  24492. /** Array of sprite names from JSON sprite data file */
  24493. private _spriteMap;
  24494. /** True when packed cell data from JSON file is ready*/
  24495. private _packedAndReady;
  24496. private _textureContent;
  24497. private _onDisposeObserver;
  24498. private _fromPacked;
  24499. private _scene;
  24500. /**
  24501. * Creates a new sprite manager
  24502. * @param name defines the manager's name
  24503. * @param imgUrl defines the sprite sheet url
  24504. * @param capacity defines the maximum allowed number of sprites
  24505. * @param cellSize defines the size of a sprite cell
  24506. * @param scene defines the hosting scene
  24507. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24508. * @param samplingMode defines the sampling mode to use with spritesheet
  24509. * @param fromPacked set to false; do not alter
  24510. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24511. */
  24512. constructor(
  24513. /** defines the manager's name */
  24514. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24515. /**
  24516. * Returns the string "SpriteManager"
  24517. * @returns "SpriteManager"
  24518. */
  24519. getClassName(): string;
  24520. private _makePacked;
  24521. private _checkTextureAlpha;
  24522. /**
  24523. * Intersects the sprites with a ray
  24524. * @param ray defines the ray to intersect with
  24525. * @param camera defines the current active camera
  24526. * @param predicate defines a predicate used to select candidate sprites
  24527. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24528. * @returns null if no hit or a PickingInfo
  24529. */
  24530. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24531. /**
  24532. * Intersects the sprites with a ray
  24533. * @param ray defines the ray to intersect with
  24534. * @param camera defines the current active camera
  24535. * @param predicate defines a predicate used to select candidate sprites
  24536. * @returns null if no hit or a PickingInfo array
  24537. */
  24538. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24539. /**
  24540. * Render all child sprites
  24541. */
  24542. render(): void;
  24543. private _customUpdate;
  24544. /**
  24545. * Release associated resources
  24546. */
  24547. dispose(): void;
  24548. /**
  24549. * Serializes the sprite manager to a JSON object
  24550. * @param serializeTexture defines if the texture must be serialized as well
  24551. * @returns the JSON object
  24552. */
  24553. serialize(serializeTexture?: boolean): any;
  24554. /**
  24555. * Parses a JSON object to create a new sprite manager.
  24556. * @param parsedManager The JSON object to parse
  24557. * @param scene The scene to create the sprite manager
  24558. * @param rootUrl The root url to use to load external dependencies like texture
  24559. * @returns the new sprite manager
  24560. */
  24561. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24562. /**
  24563. * Creates a sprite manager from a snippet saved in a remote file
  24564. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24565. * @param url defines the url to load from
  24566. * @param scene defines the hosting scene
  24567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24568. * @returns a promise that will resolve to the new sprite manager
  24569. */
  24570. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24571. /**
  24572. * Creates a sprite manager from a snippet saved by the sprite editor
  24573. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24574. * @param scene defines the hosting scene
  24575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24576. * @returns a promise that will resolve to the new sprite manager
  24577. */
  24578. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24579. }
  24580. }
  24581. declare module BABYLON {
  24582. /**
  24583. * Class used to represent a sprite
  24584. * @see https://doc.babylonjs.com/babylon101/sprites
  24585. */
  24586. export class Sprite extends ThinSprite implements IAnimatable {
  24587. /** defines the name */
  24588. name: string;
  24589. /** Gets or sets the current world position */
  24590. position: Vector3;
  24591. /** Gets or sets the main color */
  24592. color: Color4;
  24593. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24594. disposeWhenFinishedAnimating: boolean;
  24595. /** Gets the list of attached animations */
  24596. animations: Nullable<Array<Animation>>;
  24597. /** Gets or sets a boolean indicating if the sprite can be picked */
  24598. isPickable: boolean;
  24599. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24600. useAlphaForPicking: boolean;
  24601. /**
  24602. * Gets or sets the associated action manager
  24603. */
  24604. actionManager: Nullable<ActionManager>;
  24605. /**
  24606. * An event triggered when the control has been disposed
  24607. */
  24608. onDisposeObservable: Observable<Sprite>;
  24609. private _manager;
  24610. private _onAnimationEnd;
  24611. /**
  24612. * Gets or sets the sprite size
  24613. */
  24614. get size(): number;
  24615. set size(value: number);
  24616. /**
  24617. * Gets or sets the unique id of the sprite
  24618. */
  24619. uniqueId: number;
  24620. /**
  24621. * Gets the manager of this sprite
  24622. */
  24623. get manager(): ISpriteManager;
  24624. /**
  24625. * Creates a new Sprite
  24626. * @param name defines the name
  24627. * @param manager defines the manager
  24628. */
  24629. constructor(
  24630. /** defines the name */
  24631. name: string, manager: ISpriteManager);
  24632. /**
  24633. * Returns the string "Sprite"
  24634. * @returns "Sprite"
  24635. */
  24636. getClassName(): string;
  24637. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24638. get fromIndex(): number;
  24639. set fromIndex(value: number);
  24640. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24641. get toIndex(): number;
  24642. set toIndex(value: number);
  24643. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24644. get loopAnimation(): boolean;
  24645. set loopAnimation(value: boolean);
  24646. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24647. get delay(): number;
  24648. set delay(value: number);
  24649. /**
  24650. * Starts an animation
  24651. * @param from defines the initial key
  24652. * @param to defines the end key
  24653. * @param loop defines if the animation must loop
  24654. * @param delay defines the start delay (in ms)
  24655. * @param onAnimationEnd defines a callback to call when animation ends
  24656. */
  24657. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24658. private _endAnimation;
  24659. /** Release associated resources */
  24660. dispose(): void;
  24661. /**
  24662. * Serializes the sprite to a JSON object
  24663. * @returns the JSON object
  24664. */
  24665. serialize(): any;
  24666. /**
  24667. * Parses a JSON object to create a new sprite
  24668. * @param parsedSprite The JSON object to parse
  24669. * @param manager defines the hosting manager
  24670. * @returns the new sprite
  24671. */
  24672. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24673. }
  24674. }
  24675. declare module BABYLON {
  24676. /**
  24677. * Information about the result of picking within a scene
  24678. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24679. */
  24680. export class PickingInfo {
  24681. /** @hidden */
  24682. _pickingUnavailable: boolean;
  24683. /**
  24684. * If the pick collided with an object
  24685. */
  24686. hit: boolean;
  24687. /**
  24688. * Distance away where the pick collided
  24689. */
  24690. distance: number;
  24691. /**
  24692. * The location of pick collision
  24693. */
  24694. pickedPoint: Nullable<Vector3>;
  24695. /**
  24696. * The mesh corresponding the the pick collision
  24697. */
  24698. pickedMesh: Nullable<AbstractMesh>;
  24699. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24700. bu: number;
  24701. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24702. bv: number;
  24703. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24704. faceId: number;
  24705. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24706. subMeshFaceId: number;
  24707. /** Id of the the submesh that was picked */
  24708. subMeshId: number;
  24709. /** If a sprite was picked, this will be the sprite the pick collided with */
  24710. pickedSprite: Nullable<Sprite>;
  24711. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24712. thinInstanceIndex: number;
  24713. /**
  24714. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24715. */
  24716. originMesh: Nullable<AbstractMesh>;
  24717. /**
  24718. * The ray that was used to perform the picking.
  24719. */
  24720. ray: Nullable<Ray>;
  24721. /**
  24722. * Gets the normal corresponding to the face the pick collided with
  24723. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24724. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24725. * @returns The normal corresponding to the face the pick collided with
  24726. */
  24727. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24728. /**
  24729. * Gets the texture coordinates of where the pick occurred
  24730. * @returns the vector containing the coordinates of the texture
  24731. */
  24732. getTextureCoordinates(): Nullable<Vector2>;
  24733. }
  24734. }
  24735. declare module BABYLON {
  24736. /**
  24737. * Gather the list of pointer event types as constants.
  24738. */
  24739. export class PointerEventTypes {
  24740. /**
  24741. * 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.
  24742. */
  24743. static readonly POINTERDOWN: number;
  24744. /**
  24745. * The pointerup event is fired when a pointer is no longer active.
  24746. */
  24747. static readonly POINTERUP: number;
  24748. /**
  24749. * The pointermove event is fired when a pointer changes coordinates.
  24750. */
  24751. static readonly POINTERMOVE: number;
  24752. /**
  24753. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24754. */
  24755. static readonly POINTERWHEEL: number;
  24756. /**
  24757. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24758. */
  24759. static readonly POINTERPICK: number;
  24760. /**
  24761. * The pointertap event is fired when a the object has been touched and released without drag.
  24762. */
  24763. static readonly POINTERTAP: number;
  24764. /**
  24765. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24766. */
  24767. static readonly POINTERDOUBLETAP: number;
  24768. }
  24769. /**
  24770. * Base class of pointer info types.
  24771. */
  24772. export class PointerInfoBase {
  24773. /**
  24774. * Defines the type of event (PointerEventTypes)
  24775. */
  24776. type: number;
  24777. /**
  24778. * Defines the related dom event
  24779. */
  24780. event: PointerEvent | MouseWheelEvent;
  24781. /**
  24782. * Instantiates the base class of pointers info.
  24783. * @param type Defines the type of event (PointerEventTypes)
  24784. * @param event Defines the related dom event
  24785. */
  24786. constructor(
  24787. /**
  24788. * Defines the type of event (PointerEventTypes)
  24789. */
  24790. type: number,
  24791. /**
  24792. * Defines the related dom event
  24793. */
  24794. event: PointerEvent | MouseWheelEvent);
  24795. }
  24796. /**
  24797. * This class is used to store pointer related info for the onPrePointerObservable event.
  24798. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24799. */
  24800. export class PointerInfoPre extends PointerInfoBase {
  24801. /**
  24802. * Ray from a pointer if availible (eg. 6dof controller)
  24803. */
  24804. ray: Nullable<Ray>;
  24805. /**
  24806. * Defines the local position of the pointer on the canvas.
  24807. */
  24808. localPosition: Vector2;
  24809. /**
  24810. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24811. */
  24812. skipOnPointerObservable: boolean;
  24813. /**
  24814. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24815. * @param type Defines the type of event (PointerEventTypes)
  24816. * @param event Defines the related dom event
  24817. * @param localX Defines the local x coordinates of the pointer when the event occured
  24818. * @param localY Defines the local y coordinates of the pointer when the event occured
  24819. */
  24820. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24821. }
  24822. /**
  24823. * This type contains all the data related to a pointer event in Babylon.js.
  24824. * 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.
  24825. */
  24826. export class PointerInfo extends PointerInfoBase {
  24827. /**
  24828. * Defines the picking info associated to the info (if any)\
  24829. */
  24830. pickInfo: Nullable<PickingInfo>;
  24831. /**
  24832. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24833. * @param type Defines the type of event (PointerEventTypes)
  24834. * @param event Defines the related dom event
  24835. * @param pickInfo Defines the picking info associated to the info (if any)\
  24836. */
  24837. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24838. /**
  24839. * Defines the picking info associated to the info (if any)\
  24840. */
  24841. pickInfo: Nullable<PickingInfo>);
  24842. }
  24843. /**
  24844. * Data relating to a touch event on the screen.
  24845. */
  24846. export interface PointerTouch {
  24847. /**
  24848. * X coordinate of touch.
  24849. */
  24850. x: number;
  24851. /**
  24852. * Y coordinate of touch.
  24853. */
  24854. y: number;
  24855. /**
  24856. * Id of touch. Unique for each finger.
  24857. */
  24858. pointerId: number;
  24859. /**
  24860. * Event type passed from DOM.
  24861. */
  24862. type: any;
  24863. }
  24864. }
  24865. declare module BABYLON {
  24866. /**
  24867. * Manage the mouse inputs to control the movement of a free camera.
  24868. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24869. */
  24870. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24871. /**
  24872. * Define if touch is enabled in the mouse input
  24873. */
  24874. touchEnabled: boolean;
  24875. /**
  24876. * Defines the camera the input is attached to.
  24877. */
  24878. camera: FreeCamera;
  24879. /**
  24880. * Defines the buttons associated with the input to handle camera move.
  24881. */
  24882. buttons: number[];
  24883. /**
  24884. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24885. */
  24886. angularSensibility: number;
  24887. private _pointerInput;
  24888. private _onMouseMove;
  24889. private _observer;
  24890. private previousPosition;
  24891. /**
  24892. * Observable for when a pointer move event occurs containing the move offset
  24893. */
  24894. onPointerMovedObservable: Observable<{
  24895. offsetX: number;
  24896. offsetY: number;
  24897. }>;
  24898. /**
  24899. * @hidden
  24900. * If the camera should be rotated automatically based on pointer movement
  24901. */
  24902. _allowCameraRotation: boolean;
  24903. /**
  24904. * Manage the mouse inputs to control the movement of a free camera.
  24905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24906. * @param touchEnabled Defines if touch is enabled or not
  24907. */
  24908. constructor(
  24909. /**
  24910. * Define if touch is enabled in the mouse input
  24911. */
  24912. touchEnabled?: boolean);
  24913. /**
  24914. * Attach the input controls to a specific dom element to get the input from.
  24915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24916. */
  24917. attachControl(noPreventDefault?: boolean): void;
  24918. /**
  24919. * Called on JS contextmenu event.
  24920. * Override this method to provide functionality.
  24921. */
  24922. protected onContextMenu(evt: PointerEvent): void;
  24923. /**
  24924. * Detach the current controls from the specified dom element.
  24925. */
  24926. detachControl(): void;
  24927. /**
  24928. * Gets the class name of the current input.
  24929. * @returns the class name
  24930. */
  24931. getClassName(): string;
  24932. /**
  24933. * Get the friendly name associated with the input class.
  24934. * @returns the input friendly name
  24935. */
  24936. getSimpleName(): string;
  24937. }
  24938. }
  24939. declare module BABYLON {
  24940. /**
  24941. * Base class for mouse wheel input..
  24942. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24943. * for example usage.
  24944. */
  24945. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24946. /**
  24947. * Defines the camera the input is attached to.
  24948. */
  24949. abstract camera: Camera;
  24950. /**
  24951. * How fast is the camera moves in relation to X axis mouseWheel events.
  24952. * Use negative value to reverse direction.
  24953. */
  24954. wheelPrecisionX: number;
  24955. /**
  24956. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24957. * Use negative value to reverse direction.
  24958. */
  24959. wheelPrecisionY: number;
  24960. /**
  24961. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24962. * Use negative value to reverse direction.
  24963. */
  24964. wheelPrecisionZ: number;
  24965. /**
  24966. * Observable for when a mouse wheel move event occurs.
  24967. */
  24968. onChangedObservable: Observable<{
  24969. wheelDeltaX: number;
  24970. wheelDeltaY: number;
  24971. wheelDeltaZ: number;
  24972. }>;
  24973. private _wheel;
  24974. private _observer;
  24975. /**
  24976. * Attach the input controls to a specific dom element to get the input from.
  24977. * @param noPreventDefault Defines whether event caught by the controls
  24978. * should call preventdefault().
  24979. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24980. */
  24981. attachControl(noPreventDefault?: boolean): void;
  24982. /**
  24983. * Detach the current controls from the specified dom element.
  24984. */
  24985. detachControl(): void;
  24986. /**
  24987. * Called for each rendered frame.
  24988. */
  24989. checkInputs(): void;
  24990. /**
  24991. * Gets the class name of the current input.
  24992. * @returns the class name
  24993. */
  24994. getClassName(): string;
  24995. /**
  24996. * Get the friendly name associated with the input class.
  24997. * @returns the input friendly name
  24998. */
  24999. getSimpleName(): string;
  25000. /**
  25001. * Incremental value of multiple mouse wheel movements of the X axis.
  25002. * Should be zero-ed when read.
  25003. */
  25004. protected _wheelDeltaX: number;
  25005. /**
  25006. * Incremental value of multiple mouse wheel movements of the Y axis.
  25007. * Should be zero-ed when read.
  25008. */
  25009. protected _wheelDeltaY: number;
  25010. /**
  25011. * Incremental value of multiple mouse wheel movements of the Z axis.
  25012. * Should be zero-ed when read.
  25013. */
  25014. protected _wheelDeltaZ: number;
  25015. /**
  25016. * Firefox uses a different scheme to report scroll distances to other
  25017. * browsers. Rather than use complicated methods to calculate the exact
  25018. * multiple we need to apply, let's just cheat and use a constant.
  25019. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25020. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25021. */
  25022. private readonly _ffMultiplier;
  25023. /**
  25024. * Different event attributes for wheel data fall into a few set ranges.
  25025. * Some relevant but dated date here:
  25026. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25027. */
  25028. private readonly _normalize;
  25029. }
  25030. }
  25031. declare module BABYLON {
  25032. /**
  25033. * Manage the mouse wheel inputs to control a free camera.
  25034. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25035. */
  25036. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25037. /**
  25038. * Defines the camera the input is attached to.
  25039. */
  25040. camera: FreeCamera;
  25041. /**
  25042. * Gets the class name of the current input.
  25043. * @returns the class name
  25044. */
  25045. getClassName(): string;
  25046. /**
  25047. * Set which movement axis (relative to camera's orientation) the mouse
  25048. * wheel's X axis controls.
  25049. * @param axis The axis to be moved. Set null to clear.
  25050. */
  25051. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25052. /**
  25053. * Get the configured movement axis (relative to camera's orientation) the
  25054. * mouse wheel's X axis controls.
  25055. * @returns The configured axis or null if none.
  25056. */
  25057. get wheelXMoveRelative(): Nullable<Coordinate>;
  25058. /**
  25059. * Set which movement axis (relative to camera's orientation) the mouse
  25060. * wheel's Y axis controls.
  25061. * @param axis The axis to be moved. Set null to clear.
  25062. */
  25063. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25064. /**
  25065. * Get the configured movement axis (relative to camera's orientation) the
  25066. * mouse wheel's Y axis controls.
  25067. * @returns The configured axis or null if none.
  25068. */
  25069. get wheelYMoveRelative(): Nullable<Coordinate>;
  25070. /**
  25071. * Set which movement axis (relative to camera's orientation) the mouse
  25072. * wheel's Z axis controls.
  25073. * @param axis The axis to be moved. Set null to clear.
  25074. */
  25075. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25076. /**
  25077. * Get the configured movement axis (relative to camera's orientation) the
  25078. * mouse wheel's Z axis controls.
  25079. * @returns The configured axis or null if none.
  25080. */
  25081. get wheelZMoveRelative(): Nullable<Coordinate>;
  25082. /**
  25083. * Set which rotation axis (relative to camera's orientation) the mouse
  25084. * wheel's X axis controls.
  25085. * @param axis The axis to be moved. Set null to clear.
  25086. */
  25087. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25088. /**
  25089. * Get the configured rotation axis (relative to camera's orientation) the
  25090. * mouse wheel's X axis controls.
  25091. * @returns The configured axis or null if none.
  25092. */
  25093. get wheelXRotateRelative(): Nullable<Coordinate>;
  25094. /**
  25095. * Set which rotation axis (relative to camera's orientation) the mouse
  25096. * wheel's Y axis controls.
  25097. * @param axis The axis to be moved. Set null to clear.
  25098. */
  25099. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25100. /**
  25101. * Get the configured rotation axis (relative to camera's orientation) the
  25102. * mouse wheel's Y axis controls.
  25103. * @returns The configured axis or null if none.
  25104. */
  25105. get wheelYRotateRelative(): Nullable<Coordinate>;
  25106. /**
  25107. * Set which rotation axis (relative to camera's orientation) the mouse
  25108. * wheel's Z axis controls.
  25109. * @param axis The axis to be moved. Set null to clear.
  25110. */
  25111. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25112. /**
  25113. * Get the configured rotation axis (relative to camera's orientation) the
  25114. * mouse wheel's Z axis controls.
  25115. * @returns The configured axis or null if none.
  25116. */
  25117. get wheelZRotateRelative(): Nullable<Coordinate>;
  25118. /**
  25119. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25120. * controls.
  25121. * @param axis The axis to be moved. Set null to clear.
  25122. */
  25123. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25124. /**
  25125. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25126. * X axis controls.
  25127. * @returns The configured axis or null if none.
  25128. */
  25129. get wheelXMoveScene(): Nullable<Coordinate>;
  25130. /**
  25131. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25132. * controls.
  25133. * @param axis The axis to be moved. Set null to clear.
  25134. */
  25135. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25136. /**
  25137. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25138. * Y axis controls.
  25139. * @returns The configured axis or null if none.
  25140. */
  25141. get wheelYMoveScene(): Nullable<Coordinate>;
  25142. /**
  25143. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25144. * controls.
  25145. * @param axis The axis to be moved. Set null to clear.
  25146. */
  25147. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25148. /**
  25149. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25150. * Z axis controls.
  25151. * @returns The configured axis or null if none.
  25152. */
  25153. get wheelZMoveScene(): Nullable<Coordinate>;
  25154. /**
  25155. * Called for each rendered frame.
  25156. */
  25157. checkInputs(): void;
  25158. private _moveRelative;
  25159. private _rotateRelative;
  25160. private _moveScene;
  25161. /**
  25162. * These are set to the desired default behaviour.
  25163. */
  25164. private _wheelXAction;
  25165. private _wheelXActionCoordinate;
  25166. private _wheelYAction;
  25167. private _wheelYActionCoordinate;
  25168. private _wheelZAction;
  25169. private _wheelZActionCoordinate;
  25170. /**
  25171. * Update the camera according to any configured properties for the 3
  25172. * mouse-wheel axis.
  25173. */
  25174. private _updateCamera;
  25175. /**
  25176. * Update one property of the camera.
  25177. */
  25178. private _updateCameraProperty;
  25179. }
  25180. }
  25181. declare module BABYLON {
  25182. /**
  25183. * Manage the touch inputs to control the movement of a free camera.
  25184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25185. */
  25186. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25187. /**
  25188. * Define if mouse events can be treated as touch events
  25189. */
  25190. allowMouse: boolean;
  25191. /**
  25192. * Defines the camera the input is attached to.
  25193. */
  25194. camera: FreeCamera;
  25195. /**
  25196. * Defines the touch sensibility for rotation.
  25197. * The higher the faster.
  25198. */
  25199. touchAngularSensibility: number;
  25200. /**
  25201. * Defines the touch sensibility for move.
  25202. * The higher the faster.
  25203. */
  25204. touchMoveSensibility: number;
  25205. private _offsetX;
  25206. private _offsetY;
  25207. private _pointerPressed;
  25208. private _pointerInput?;
  25209. private _observer;
  25210. private _onLostFocus;
  25211. /**
  25212. * Manage the touch inputs to control the movement of a free camera.
  25213. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25214. * @param allowMouse Defines if mouse events can be treated as touch events
  25215. */
  25216. constructor(
  25217. /**
  25218. * Define if mouse events can be treated as touch events
  25219. */
  25220. allowMouse?: boolean);
  25221. /**
  25222. * Attach the input controls to a specific dom element to get the input from.
  25223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25224. */
  25225. attachControl(noPreventDefault?: boolean): void;
  25226. /**
  25227. * Detach the current controls from the specified dom element.
  25228. */
  25229. detachControl(): void;
  25230. /**
  25231. * Update the current camera state depending on the inputs that have been used this frame.
  25232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25233. */
  25234. checkInputs(): void;
  25235. /**
  25236. * Gets the class name of the current input.
  25237. * @returns the class name
  25238. */
  25239. getClassName(): string;
  25240. /**
  25241. * Get the friendly name associated with the input class.
  25242. * @returns the input friendly name
  25243. */
  25244. getSimpleName(): string;
  25245. }
  25246. }
  25247. declare module BABYLON {
  25248. /**
  25249. * Default Inputs manager for the FreeCamera.
  25250. * It groups all the default supported inputs for ease of use.
  25251. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25252. */
  25253. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25254. /**
  25255. * @hidden
  25256. */
  25257. _mouseInput: Nullable<FreeCameraMouseInput>;
  25258. /**
  25259. * @hidden
  25260. */
  25261. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25262. /**
  25263. * Instantiates a new FreeCameraInputsManager.
  25264. * @param camera Defines the camera the inputs belong to
  25265. */
  25266. constructor(camera: FreeCamera);
  25267. /**
  25268. * Add keyboard input support to the input manager.
  25269. * @returns the current input manager
  25270. */
  25271. addKeyboard(): FreeCameraInputsManager;
  25272. /**
  25273. * Add mouse input support to the input manager.
  25274. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25275. * @returns the current input manager
  25276. */
  25277. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25278. /**
  25279. * Removes the mouse input support from the manager
  25280. * @returns the current input manager
  25281. */
  25282. removeMouse(): FreeCameraInputsManager;
  25283. /**
  25284. * Add mouse wheel input support to the input manager.
  25285. * @returns the current input manager
  25286. */
  25287. addMouseWheel(): FreeCameraInputsManager;
  25288. /**
  25289. * Removes the mouse wheel input support from the manager
  25290. * @returns the current input manager
  25291. */
  25292. removeMouseWheel(): FreeCameraInputsManager;
  25293. /**
  25294. * Add touch input support to the input manager.
  25295. * @returns the current input manager
  25296. */
  25297. addTouch(): FreeCameraInputsManager;
  25298. /**
  25299. * Remove all attached input methods from a camera
  25300. */
  25301. clear(): void;
  25302. }
  25303. }
  25304. declare module BABYLON {
  25305. /**
  25306. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25307. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25308. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25309. */
  25310. export class FreeCamera extends TargetCamera {
  25311. /**
  25312. * Define the collision ellipsoid of the camera.
  25313. * This is helpful to simulate a camera body like the player body around the camera
  25314. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25315. */
  25316. ellipsoid: Vector3;
  25317. /**
  25318. * Define an offset for the position of the ellipsoid around the camera.
  25319. * This can be helpful to determine the center of the body near the gravity center of the body
  25320. * instead of its head.
  25321. */
  25322. ellipsoidOffset: Vector3;
  25323. /**
  25324. * Enable or disable collisions of the camera with the rest of the scene objects.
  25325. */
  25326. checkCollisions: boolean;
  25327. /**
  25328. * Enable or disable gravity on the camera.
  25329. */
  25330. applyGravity: boolean;
  25331. /**
  25332. * Define the input manager associated to the camera.
  25333. */
  25334. inputs: FreeCameraInputsManager;
  25335. /**
  25336. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25337. * Higher values reduce sensitivity.
  25338. */
  25339. get angularSensibility(): number;
  25340. /**
  25341. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25342. * Higher values reduce sensitivity.
  25343. */
  25344. set angularSensibility(value: number);
  25345. /**
  25346. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25347. */
  25348. get keysUp(): number[];
  25349. set keysUp(value: number[]);
  25350. /**
  25351. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25352. */
  25353. get keysUpward(): number[];
  25354. set keysUpward(value: number[]);
  25355. /**
  25356. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25357. */
  25358. get keysDown(): number[];
  25359. set keysDown(value: number[]);
  25360. /**
  25361. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25362. */
  25363. get keysDownward(): number[];
  25364. set keysDownward(value: number[]);
  25365. /**
  25366. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25367. */
  25368. get keysLeft(): number[];
  25369. set keysLeft(value: number[]);
  25370. /**
  25371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25372. */
  25373. get keysRight(): number[];
  25374. set keysRight(value: number[]);
  25375. /**
  25376. * Event raised when the camera collide with a mesh in the scene.
  25377. */
  25378. onCollide: (collidedMesh: AbstractMesh) => void;
  25379. private _collider;
  25380. private _needMoveForGravity;
  25381. private _oldPosition;
  25382. private _diffPosition;
  25383. private _newPosition;
  25384. /** @hidden */
  25385. _localDirection: Vector3;
  25386. /** @hidden */
  25387. _transformedDirection: Vector3;
  25388. /**
  25389. * Instantiates a Free Camera.
  25390. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25391. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25392. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25393. * @param name Define the name of the camera in the scene
  25394. * @param position Define the start position of the camera in the scene
  25395. * @param scene Define the scene the camera belongs to
  25396. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25397. */
  25398. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25399. /**
  25400. * Attach the input controls to a specific dom element to get the input from.
  25401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25402. */
  25403. attachControl(noPreventDefault?: boolean): void;
  25404. /**
  25405. * Attach the input controls to a specific dom element to get the input from.
  25406. * @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
  25407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25408. * BACK COMPAT SIGNATURE ONLY.
  25409. */
  25410. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25411. /**
  25412. * Detach the current controls from the specified dom element.
  25413. */
  25414. detachControl(): void;
  25415. /**
  25416. * Detach the current controls from the specified dom element.
  25417. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25418. */
  25419. detachControl(ignored: any): void;
  25420. private _collisionMask;
  25421. /**
  25422. * Define a collision mask to limit the list of object the camera can collide with
  25423. */
  25424. get collisionMask(): number;
  25425. set collisionMask(mask: number);
  25426. /** @hidden */
  25427. _collideWithWorld(displacement: Vector3): void;
  25428. private _onCollisionPositionChange;
  25429. /** @hidden */
  25430. _checkInputs(): void;
  25431. /** @hidden */
  25432. _decideIfNeedsToMove(): boolean;
  25433. /** @hidden */
  25434. _updatePosition(): void;
  25435. /**
  25436. * Destroy the camera and release the current resources hold by it.
  25437. */
  25438. dispose(): void;
  25439. /**
  25440. * Gets the current object class name.
  25441. * @return the class name
  25442. */
  25443. getClassName(): string;
  25444. }
  25445. }
  25446. declare module BABYLON {
  25447. /**
  25448. * Represents a gamepad control stick position
  25449. */
  25450. export class StickValues {
  25451. /**
  25452. * The x component of the control stick
  25453. */
  25454. x: number;
  25455. /**
  25456. * The y component of the control stick
  25457. */
  25458. y: number;
  25459. /**
  25460. * Initializes the gamepad x and y control stick values
  25461. * @param x The x component of the gamepad control stick value
  25462. * @param y The y component of the gamepad control stick value
  25463. */
  25464. constructor(
  25465. /**
  25466. * The x component of the control stick
  25467. */
  25468. x: number,
  25469. /**
  25470. * The y component of the control stick
  25471. */
  25472. y: number);
  25473. }
  25474. /**
  25475. * An interface which manages callbacks for gamepad button changes
  25476. */
  25477. export interface GamepadButtonChanges {
  25478. /**
  25479. * Called when a gamepad has been changed
  25480. */
  25481. changed: boolean;
  25482. /**
  25483. * Called when a gamepad press event has been triggered
  25484. */
  25485. pressChanged: boolean;
  25486. /**
  25487. * Called when a touch event has been triggered
  25488. */
  25489. touchChanged: boolean;
  25490. /**
  25491. * Called when a value has changed
  25492. */
  25493. valueChanged: boolean;
  25494. }
  25495. /**
  25496. * Represents a gamepad
  25497. */
  25498. export class Gamepad {
  25499. /**
  25500. * The id of the gamepad
  25501. */
  25502. id: string;
  25503. /**
  25504. * The index of the gamepad
  25505. */
  25506. index: number;
  25507. /**
  25508. * The browser gamepad
  25509. */
  25510. browserGamepad: any;
  25511. /**
  25512. * Specifies what type of gamepad this represents
  25513. */
  25514. type: number;
  25515. private _leftStick;
  25516. private _rightStick;
  25517. /** @hidden */
  25518. _isConnected: boolean;
  25519. private _leftStickAxisX;
  25520. private _leftStickAxisY;
  25521. private _rightStickAxisX;
  25522. private _rightStickAxisY;
  25523. /**
  25524. * Triggered when the left control stick has been changed
  25525. */
  25526. private _onleftstickchanged;
  25527. /**
  25528. * Triggered when the right control stick has been changed
  25529. */
  25530. private _onrightstickchanged;
  25531. /**
  25532. * Represents a gamepad controller
  25533. */
  25534. static GAMEPAD: number;
  25535. /**
  25536. * Represents a generic controller
  25537. */
  25538. static GENERIC: number;
  25539. /**
  25540. * Represents an XBox controller
  25541. */
  25542. static XBOX: number;
  25543. /**
  25544. * Represents a pose-enabled controller
  25545. */
  25546. static POSE_ENABLED: number;
  25547. /**
  25548. * Represents an Dual Shock controller
  25549. */
  25550. static DUALSHOCK: number;
  25551. /**
  25552. * Specifies whether the left control stick should be Y-inverted
  25553. */
  25554. protected _invertLeftStickY: boolean;
  25555. /**
  25556. * Specifies if the gamepad has been connected
  25557. */
  25558. get isConnected(): boolean;
  25559. /**
  25560. * Initializes the gamepad
  25561. * @param id The id of the gamepad
  25562. * @param index The index of the gamepad
  25563. * @param browserGamepad The browser gamepad
  25564. * @param leftStickX The x component of the left joystick
  25565. * @param leftStickY The y component of the left joystick
  25566. * @param rightStickX The x component of the right joystick
  25567. * @param rightStickY The y component of the right joystick
  25568. */
  25569. constructor(
  25570. /**
  25571. * The id of the gamepad
  25572. */
  25573. id: string,
  25574. /**
  25575. * The index of the gamepad
  25576. */
  25577. index: number,
  25578. /**
  25579. * The browser gamepad
  25580. */
  25581. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25582. /**
  25583. * Callback triggered when the left joystick has changed
  25584. * @param callback
  25585. */
  25586. onleftstickchanged(callback: (values: StickValues) => void): void;
  25587. /**
  25588. * Callback triggered when the right joystick has changed
  25589. * @param callback
  25590. */
  25591. onrightstickchanged(callback: (values: StickValues) => void): void;
  25592. /**
  25593. * Gets the left joystick
  25594. */
  25595. get leftStick(): StickValues;
  25596. /**
  25597. * Sets the left joystick values
  25598. */
  25599. set leftStick(newValues: StickValues);
  25600. /**
  25601. * Gets the right joystick
  25602. */
  25603. get rightStick(): StickValues;
  25604. /**
  25605. * Sets the right joystick value
  25606. */
  25607. set rightStick(newValues: StickValues);
  25608. /**
  25609. * Updates the gamepad joystick positions
  25610. */
  25611. update(): void;
  25612. /**
  25613. * Disposes the gamepad
  25614. */
  25615. dispose(): void;
  25616. }
  25617. /**
  25618. * Represents a generic gamepad
  25619. */
  25620. export class GenericPad extends Gamepad {
  25621. private _buttons;
  25622. private _onbuttondown;
  25623. private _onbuttonup;
  25624. /**
  25625. * Observable triggered when a button has been pressed
  25626. */
  25627. onButtonDownObservable: Observable<number>;
  25628. /**
  25629. * Observable triggered when a button has been released
  25630. */
  25631. onButtonUpObservable: Observable<number>;
  25632. /**
  25633. * Callback triggered when a button has been pressed
  25634. * @param callback Called when a button has been pressed
  25635. */
  25636. onbuttondown(callback: (buttonPressed: number) => void): void;
  25637. /**
  25638. * Callback triggered when a button has been released
  25639. * @param callback Called when a button has been released
  25640. */
  25641. onbuttonup(callback: (buttonReleased: number) => void): void;
  25642. /**
  25643. * Initializes the generic gamepad
  25644. * @param id The id of the generic gamepad
  25645. * @param index The index of the generic gamepad
  25646. * @param browserGamepad The browser gamepad
  25647. */
  25648. constructor(id: string, index: number, browserGamepad: any);
  25649. private _setButtonValue;
  25650. /**
  25651. * Updates the generic gamepad
  25652. */
  25653. update(): void;
  25654. /**
  25655. * Disposes the generic gamepad
  25656. */
  25657. dispose(): void;
  25658. }
  25659. }
  25660. declare module BABYLON {
  25661. /**
  25662. * Defines a runtime animation
  25663. */
  25664. export class RuntimeAnimation {
  25665. private _events;
  25666. /**
  25667. * The current frame of the runtime animation
  25668. */
  25669. private _currentFrame;
  25670. /**
  25671. * The animation used by the runtime animation
  25672. */
  25673. private _animation;
  25674. /**
  25675. * The target of the runtime animation
  25676. */
  25677. private _target;
  25678. /**
  25679. * The initiating animatable
  25680. */
  25681. private _host;
  25682. /**
  25683. * The original value of the runtime animation
  25684. */
  25685. private _originalValue;
  25686. /**
  25687. * The original blend value of the runtime animation
  25688. */
  25689. private _originalBlendValue;
  25690. /**
  25691. * The offsets cache of the runtime animation
  25692. */
  25693. private _offsetsCache;
  25694. /**
  25695. * The high limits cache of the runtime animation
  25696. */
  25697. private _highLimitsCache;
  25698. /**
  25699. * Specifies if the runtime animation has been stopped
  25700. */
  25701. private _stopped;
  25702. /**
  25703. * The blending factor of the runtime animation
  25704. */
  25705. private _blendingFactor;
  25706. /**
  25707. * The BabylonJS scene
  25708. */
  25709. private _scene;
  25710. /**
  25711. * The current value of the runtime animation
  25712. */
  25713. private _currentValue;
  25714. /** @hidden */
  25715. _animationState: _IAnimationState;
  25716. /**
  25717. * The active target of the runtime animation
  25718. */
  25719. private _activeTargets;
  25720. private _currentActiveTarget;
  25721. private _directTarget;
  25722. /**
  25723. * The target path of the runtime animation
  25724. */
  25725. private _targetPath;
  25726. /**
  25727. * The weight of the runtime animation
  25728. */
  25729. private _weight;
  25730. /**
  25731. * The ratio offset of the runtime animation
  25732. */
  25733. private _ratioOffset;
  25734. /**
  25735. * The previous delay of the runtime animation
  25736. */
  25737. private _previousDelay;
  25738. /**
  25739. * The previous ratio of the runtime animation
  25740. */
  25741. private _previousRatio;
  25742. private _enableBlending;
  25743. private _keys;
  25744. private _minFrame;
  25745. private _maxFrame;
  25746. private _minValue;
  25747. private _maxValue;
  25748. private _targetIsArray;
  25749. /**
  25750. * Gets the current frame of the runtime animation
  25751. */
  25752. get currentFrame(): number;
  25753. /**
  25754. * Gets the weight of the runtime animation
  25755. */
  25756. get weight(): number;
  25757. /**
  25758. * Gets the current value of the runtime animation
  25759. */
  25760. get currentValue(): any;
  25761. /**
  25762. * Gets the target path of the runtime animation
  25763. */
  25764. get targetPath(): string;
  25765. /**
  25766. * Gets the actual target of the runtime animation
  25767. */
  25768. get target(): any;
  25769. /**
  25770. * Gets the additive state of the runtime animation
  25771. */
  25772. get isAdditive(): boolean;
  25773. /** @hidden */
  25774. _onLoop: () => void;
  25775. /**
  25776. * Create a new RuntimeAnimation object
  25777. * @param target defines the target of the animation
  25778. * @param animation defines the source animation object
  25779. * @param scene defines the hosting scene
  25780. * @param host defines the initiating Animatable
  25781. */
  25782. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25783. private _preparePath;
  25784. /**
  25785. * Gets the animation from the runtime animation
  25786. */
  25787. get animation(): Animation;
  25788. /**
  25789. * Resets the runtime animation to the beginning
  25790. * @param restoreOriginal defines whether to restore the target property to the original value
  25791. */
  25792. reset(restoreOriginal?: boolean): void;
  25793. /**
  25794. * Specifies if the runtime animation is stopped
  25795. * @returns Boolean specifying if the runtime animation is stopped
  25796. */
  25797. isStopped(): boolean;
  25798. /**
  25799. * Disposes of the runtime animation
  25800. */
  25801. dispose(): void;
  25802. /**
  25803. * Apply the interpolated value to the target
  25804. * @param currentValue defines the value computed by the animation
  25805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25806. */
  25807. setValue(currentValue: any, weight: number): void;
  25808. private _getOriginalValues;
  25809. private _setValue;
  25810. /**
  25811. * Gets the loop pmode of the runtime animation
  25812. * @returns Loop Mode
  25813. */
  25814. private _getCorrectLoopMode;
  25815. /**
  25816. * Move the current animation to a given frame
  25817. * @param frame defines the frame to move to
  25818. */
  25819. goToFrame(frame: number): void;
  25820. /**
  25821. * @hidden Internal use only
  25822. */
  25823. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25824. /**
  25825. * Execute the current animation
  25826. * @param delay defines the delay to add to the current frame
  25827. * @param from defines the lower bound of the animation range
  25828. * @param to defines the upper bound of the animation range
  25829. * @param loop defines if the current animation must loop
  25830. * @param speedRatio defines the current speed ratio
  25831. * @param weight defines the weight of the animation (default is -1 so no weight)
  25832. * @param onLoop optional callback called when animation loops
  25833. * @returns a boolean indicating if the animation is running
  25834. */
  25835. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25836. }
  25837. }
  25838. declare module BABYLON {
  25839. /**
  25840. * Class used to store an actual running animation
  25841. */
  25842. export class Animatable {
  25843. /** defines the target object */
  25844. target: any;
  25845. /** defines the starting frame number (default is 0) */
  25846. fromFrame: number;
  25847. /** defines the ending frame number (default is 100) */
  25848. toFrame: number;
  25849. /** defines if the animation must loop (default is false) */
  25850. loopAnimation: boolean;
  25851. /** defines a callback to call when animation ends if it is not looping */
  25852. onAnimationEnd?: (() => void) | null | undefined;
  25853. /** defines a callback to call when animation loops */
  25854. onAnimationLoop?: (() => void) | null | undefined;
  25855. /** defines whether the animation should be evaluated additively */
  25856. isAdditive: boolean;
  25857. private _localDelayOffset;
  25858. private _pausedDelay;
  25859. private _runtimeAnimations;
  25860. private _paused;
  25861. private _scene;
  25862. private _speedRatio;
  25863. private _weight;
  25864. private _syncRoot;
  25865. /**
  25866. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25867. * This will only apply for non looping animation (default is true)
  25868. */
  25869. disposeOnEnd: boolean;
  25870. /**
  25871. * Gets a boolean indicating if the animation has started
  25872. */
  25873. animationStarted: boolean;
  25874. /**
  25875. * Observer raised when the animation ends
  25876. */
  25877. onAnimationEndObservable: Observable<Animatable>;
  25878. /**
  25879. * Observer raised when the animation loops
  25880. */
  25881. onAnimationLoopObservable: Observable<Animatable>;
  25882. /**
  25883. * Gets the root Animatable used to synchronize and normalize animations
  25884. */
  25885. get syncRoot(): Nullable<Animatable>;
  25886. /**
  25887. * Gets the current frame of the first RuntimeAnimation
  25888. * Used to synchronize Animatables
  25889. */
  25890. get masterFrame(): number;
  25891. /**
  25892. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25893. */
  25894. get weight(): number;
  25895. set weight(value: number);
  25896. /**
  25897. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25898. */
  25899. get speedRatio(): number;
  25900. set speedRatio(value: number);
  25901. /**
  25902. * Creates a new Animatable
  25903. * @param scene defines the hosting scene
  25904. * @param target defines the target object
  25905. * @param fromFrame defines the starting frame number (default is 0)
  25906. * @param toFrame defines the ending frame number (default is 100)
  25907. * @param loopAnimation defines if the animation must loop (default is false)
  25908. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25909. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25910. * @param animations defines a group of animation to add to the new Animatable
  25911. * @param onAnimationLoop defines a callback to call when animation loops
  25912. * @param isAdditive defines whether the animation should be evaluated additively
  25913. */
  25914. constructor(scene: Scene,
  25915. /** defines the target object */
  25916. target: any,
  25917. /** defines the starting frame number (default is 0) */
  25918. fromFrame?: number,
  25919. /** defines the ending frame number (default is 100) */
  25920. toFrame?: number,
  25921. /** defines if the animation must loop (default is false) */
  25922. loopAnimation?: boolean, speedRatio?: number,
  25923. /** defines a callback to call when animation ends if it is not looping */
  25924. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25925. /** defines a callback to call when animation loops */
  25926. onAnimationLoop?: (() => void) | null | undefined,
  25927. /** defines whether the animation should be evaluated additively */
  25928. isAdditive?: boolean);
  25929. /**
  25930. * Synchronize and normalize current Animatable with a source Animatable
  25931. * This is useful when using animation weights and when animations are not of the same length
  25932. * @param root defines the root Animatable to synchronize with
  25933. * @returns the current Animatable
  25934. */
  25935. syncWith(root: Animatable): Animatable;
  25936. /**
  25937. * Gets the list of runtime animations
  25938. * @returns an array of RuntimeAnimation
  25939. */
  25940. getAnimations(): RuntimeAnimation[];
  25941. /**
  25942. * Adds more animations to the current animatable
  25943. * @param target defines the target of the animations
  25944. * @param animations defines the new animations to add
  25945. */
  25946. appendAnimations(target: any, animations: Animation[]): void;
  25947. /**
  25948. * Gets the source animation for a specific property
  25949. * @param property defines the property to look for
  25950. * @returns null or the source animation for the given property
  25951. */
  25952. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25953. /**
  25954. * Gets the runtime animation for a specific property
  25955. * @param property defines the property to look for
  25956. * @returns null or the runtime animation for the given property
  25957. */
  25958. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25959. /**
  25960. * Resets the animatable to its original state
  25961. */
  25962. reset(): void;
  25963. /**
  25964. * Allows the animatable to blend with current running animations
  25965. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25966. * @param blendingSpeed defines the blending speed to use
  25967. */
  25968. enableBlending(blendingSpeed: number): void;
  25969. /**
  25970. * Disable animation blending
  25971. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25972. */
  25973. disableBlending(): void;
  25974. /**
  25975. * Jump directly to a given frame
  25976. * @param frame defines the frame to jump to
  25977. */
  25978. goToFrame(frame: number): void;
  25979. /**
  25980. * Pause the animation
  25981. */
  25982. pause(): void;
  25983. /**
  25984. * Restart the animation
  25985. */
  25986. restart(): void;
  25987. private _raiseOnAnimationEnd;
  25988. /**
  25989. * Stop and delete the current animation
  25990. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25991. * @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)
  25992. */
  25993. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25994. /**
  25995. * Wait asynchronously for the animation to end
  25996. * @returns a promise which will be fulfilled when the animation ends
  25997. */
  25998. waitAsync(): Promise<Animatable>;
  25999. /** @hidden */
  26000. _animate(delay: number): boolean;
  26001. }
  26002. interface Scene {
  26003. /** @hidden */
  26004. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26005. /** @hidden */
  26006. _processLateAnimationBindingsForMatrices(holder: {
  26007. totalWeight: number;
  26008. totalAdditiveWeight: number;
  26009. animations: RuntimeAnimation[];
  26010. additiveAnimations: RuntimeAnimation[];
  26011. originalValue: Matrix;
  26012. }): any;
  26013. /** @hidden */
  26014. _processLateAnimationBindingsForQuaternions(holder: {
  26015. totalWeight: number;
  26016. totalAdditiveWeight: number;
  26017. animations: RuntimeAnimation[];
  26018. additiveAnimations: RuntimeAnimation[];
  26019. originalValue: Quaternion;
  26020. }, refQuaternion: Quaternion): Quaternion;
  26021. /** @hidden */
  26022. _processLateAnimationBindings(): void;
  26023. /**
  26024. * Will start the animation sequence of a given target
  26025. * @param target defines the target
  26026. * @param from defines from which frame should animation start
  26027. * @param to defines until which frame should animation run.
  26028. * @param weight defines the weight to apply to the animation (1.0 by default)
  26029. * @param loop defines if the animation loops
  26030. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26031. * @param onAnimationEnd defines the function to be executed when the animation ends
  26032. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26033. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26034. * @param onAnimationLoop defines the callback to call when an animation loops
  26035. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26036. * @returns the animatable object created for this animation
  26037. */
  26038. 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;
  26039. /**
  26040. * Will start the animation sequence of a given target
  26041. * @param target defines the target
  26042. * @param from defines from which frame should animation start
  26043. * @param to defines until which frame should animation run.
  26044. * @param loop defines if the animation loops
  26045. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26046. * @param onAnimationEnd defines the function to be executed when the animation ends
  26047. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26048. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26049. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26050. * @param onAnimationLoop defines the callback to call when an animation loops
  26051. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26052. * @returns the animatable object created for this animation
  26053. */
  26054. 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;
  26055. /**
  26056. * Will start the animation sequence of a given target and its hierarchy
  26057. * @param target defines the target
  26058. * @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.
  26059. * @param from defines from which frame should animation start
  26060. * @param to defines until which frame should animation run.
  26061. * @param loop defines if the animation loops
  26062. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26063. * @param onAnimationEnd defines the function to be executed when the animation ends
  26064. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26065. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26066. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26067. * @param onAnimationLoop defines the callback to call when an animation loops
  26068. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26069. * @returns the list of created animatables
  26070. */
  26071. 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[];
  26072. /**
  26073. * Begin a new animation on a given node
  26074. * @param target defines the target where the animation will take place
  26075. * @param animations defines the list of animations to start
  26076. * @param from defines the initial value
  26077. * @param to defines the final value
  26078. * @param loop defines if you want animation to loop (off by default)
  26079. * @param speedRatio defines the speed ratio to apply to all animations
  26080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26081. * @param onAnimationLoop defines the callback to call when an animation loops
  26082. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26083. * @returns the list of created animatables
  26084. */
  26085. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26086. /**
  26087. * Begin a new animation on a given node and its hierarchy
  26088. * @param target defines the root node where the animation will take place
  26089. * @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.
  26090. * @param animations defines the list of animations to start
  26091. * @param from defines the initial value
  26092. * @param to defines the final value
  26093. * @param loop defines if you want animation to loop (off by default)
  26094. * @param speedRatio defines the speed ratio to apply to all animations
  26095. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26096. * @param onAnimationLoop defines the callback to call when an animation loops
  26097. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26098. * @returns the list of animatables created for all nodes
  26099. */
  26100. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26101. /**
  26102. * Gets the animatable associated with a specific target
  26103. * @param target defines the target of the animatable
  26104. * @returns the required animatable if found
  26105. */
  26106. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26107. /**
  26108. * Gets all animatables associated with a given target
  26109. * @param target defines the target to look animatables for
  26110. * @returns an array of Animatables
  26111. */
  26112. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26113. /**
  26114. * Stops and removes all animations that have been applied to the scene
  26115. */
  26116. stopAllAnimations(): void;
  26117. /**
  26118. * Gets the current delta time used by animation engine
  26119. */
  26120. deltaTime: number;
  26121. }
  26122. interface Bone {
  26123. /**
  26124. * Copy an animation range from another bone
  26125. * @param source defines the source bone
  26126. * @param rangeName defines the range name to copy
  26127. * @param frameOffset defines the frame offset
  26128. * @param rescaleAsRequired defines if rescaling must be applied if required
  26129. * @param skelDimensionsRatio defines the scaling ratio
  26130. * @returns true if operation was successful
  26131. */
  26132. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26133. }
  26134. }
  26135. declare module BABYLON {
  26136. /**
  26137. * Class used to override all child animations of a given target
  26138. */
  26139. export class AnimationPropertiesOverride {
  26140. /**
  26141. * Gets or sets a value indicating if animation blending must be used
  26142. */
  26143. enableBlending: boolean;
  26144. /**
  26145. * Gets or sets the blending speed to use when enableBlending is true
  26146. */
  26147. blendingSpeed: number;
  26148. /**
  26149. * Gets or sets the default loop mode to use
  26150. */
  26151. loopMode: number;
  26152. }
  26153. }
  26154. declare module BABYLON {
  26155. /**
  26156. * Class used to handle skinning animations
  26157. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26158. */
  26159. export class Skeleton implements IAnimatable {
  26160. /** defines the skeleton name */
  26161. name: string;
  26162. /** defines the skeleton Id */
  26163. id: string;
  26164. /**
  26165. * Defines the list of child bones
  26166. */
  26167. bones: Bone[];
  26168. /**
  26169. * Defines an estimate of the dimension of the skeleton at rest
  26170. */
  26171. dimensionsAtRest: Vector3;
  26172. /**
  26173. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26174. */
  26175. needInitialSkinMatrix: boolean;
  26176. /**
  26177. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26178. */
  26179. overrideMesh: Nullable<AbstractMesh>;
  26180. /**
  26181. * Gets the list of animations attached to this skeleton
  26182. */
  26183. animations: Array<Animation>;
  26184. private _scene;
  26185. private _isDirty;
  26186. private _transformMatrices;
  26187. private _transformMatrixTexture;
  26188. private _meshesWithPoseMatrix;
  26189. private _animatables;
  26190. private _identity;
  26191. private _synchronizedWithMesh;
  26192. private _ranges;
  26193. private _lastAbsoluteTransformsUpdateId;
  26194. private _canUseTextureForBones;
  26195. private _uniqueId;
  26196. /** @hidden */
  26197. _numBonesWithLinkedTransformNode: number;
  26198. /** @hidden */
  26199. _hasWaitingData: Nullable<boolean>;
  26200. /** @hidden */
  26201. _waitingOverrideMeshId: Nullable<string>;
  26202. /**
  26203. * Specifies if the skeleton should be serialized
  26204. */
  26205. doNotSerialize: boolean;
  26206. private _useTextureToStoreBoneMatrices;
  26207. /**
  26208. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26209. * Please note that this option is not available if the hardware does not support it
  26210. */
  26211. get useTextureToStoreBoneMatrices(): boolean;
  26212. set useTextureToStoreBoneMatrices(value: boolean);
  26213. private _animationPropertiesOverride;
  26214. /**
  26215. * Gets or sets the animation properties override
  26216. */
  26217. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26218. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26219. /**
  26220. * List of inspectable custom properties (used by the Inspector)
  26221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26222. */
  26223. inspectableCustomProperties: IInspectable[];
  26224. /**
  26225. * An observable triggered before computing the skeleton's matrices
  26226. */
  26227. onBeforeComputeObservable: Observable<Skeleton>;
  26228. /**
  26229. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26230. */
  26231. get isUsingTextureForMatrices(): boolean;
  26232. /**
  26233. * Gets the unique ID of this skeleton
  26234. */
  26235. get uniqueId(): number;
  26236. /**
  26237. * Creates a new skeleton
  26238. * @param name defines the skeleton name
  26239. * @param id defines the skeleton Id
  26240. * @param scene defines the hosting scene
  26241. */
  26242. constructor(
  26243. /** defines the skeleton name */
  26244. name: string,
  26245. /** defines the skeleton Id */
  26246. id: string, scene: Scene);
  26247. /**
  26248. * Gets the current object class name.
  26249. * @return the class name
  26250. */
  26251. getClassName(): string;
  26252. /**
  26253. * Returns an array containing the root bones
  26254. * @returns an array containing the root bones
  26255. */
  26256. getChildren(): Array<Bone>;
  26257. /**
  26258. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26259. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26260. * @returns a Float32Array containing matrices data
  26261. */
  26262. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26263. /**
  26264. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26265. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26266. * @returns a raw texture containing the data
  26267. */
  26268. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26269. /**
  26270. * Gets the current hosting scene
  26271. * @returns a scene object
  26272. */
  26273. getScene(): Scene;
  26274. /**
  26275. * Gets a string representing the current skeleton data
  26276. * @param fullDetails defines a boolean indicating if we want a verbose version
  26277. * @returns a string representing the current skeleton data
  26278. */
  26279. toString(fullDetails?: boolean): string;
  26280. /**
  26281. * Get bone's index searching by name
  26282. * @param name defines bone's name to search for
  26283. * @return the indice of the bone. Returns -1 if not found
  26284. */
  26285. getBoneIndexByName(name: string): number;
  26286. /**
  26287. * Create a new animation range
  26288. * @param name defines the name of the range
  26289. * @param from defines the start key
  26290. * @param to defines the end key
  26291. */
  26292. createAnimationRange(name: string, from: number, to: number): void;
  26293. /**
  26294. * Delete a specific animation range
  26295. * @param name defines the name of the range
  26296. * @param deleteFrames defines if frames must be removed as well
  26297. */
  26298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26299. /**
  26300. * Gets a specific animation range
  26301. * @param name defines the name of the range to look for
  26302. * @returns the requested animation range or null if not found
  26303. */
  26304. getAnimationRange(name: string): Nullable<AnimationRange>;
  26305. /**
  26306. * Gets the list of all animation ranges defined on this skeleton
  26307. * @returns an array
  26308. */
  26309. getAnimationRanges(): Nullable<AnimationRange>[];
  26310. /**
  26311. * Copy animation range from a source skeleton.
  26312. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26313. * @param source defines the source skeleton
  26314. * @param name defines the name of the range to copy
  26315. * @param rescaleAsRequired defines if rescaling must be applied if required
  26316. * @returns true if operation was successful
  26317. */
  26318. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26319. /**
  26320. * Forces the skeleton to go to rest pose
  26321. */
  26322. returnToRest(): void;
  26323. private _getHighestAnimationFrame;
  26324. /**
  26325. * Begin a specific animation range
  26326. * @param name defines the name of the range to start
  26327. * @param loop defines if looping must be turned on (false by default)
  26328. * @param speedRatio defines the speed ratio to apply (1 by default)
  26329. * @param onAnimationEnd defines a callback which will be called when animation will end
  26330. * @returns a new animatable
  26331. */
  26332. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26333. /**
  26334. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26335. * @param skeleton defines the Skeleton containing the animation range to convert
  26336. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26337. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26338. * @returns the original skeleton
  26339. */
  26340. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26341. /** @hidden */
  26342. _markAsDirty(): void;
  26343. /** @hidden */
  26344. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26345. /** @hidden */
  26346. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26347. private _computeTransformMatrices;
  26348. /**
  26349. * Build all resources required to render a skeleton
  26350. */
  26351. prepare(): void;
  26352. /**
  26353. * Gets the list of animatables currently running for this skeleton
  26354. * @returns an array of animatables
  26355. */
  26356. getAnimatables(): IAnimatable[];
  26357. /**
  26358. * Clone the current skeleton
  26359. * @param name defines the name of the new skeleton
  26360. * @param id defines the id of the new skeleton
  26361. * @returns the new skeleton
  26362. */
  26363. clone(name: string, id?: string): Skeleton;
  26364. /**
  26365. * Enable animation blending for this skeleton
  26366. * @param blendingSpeed defines the blending speed to apply
  26367. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26368. */
  26369. enableBlending(blendingSpeed?: number): void;
  26370. /**
  26371. * Releases all resources associated with the current skeleton
  26372. */
  26373. dispose(): void;
  26374. /**
  26375. * Serialize the skeleton in a JSON object
  26376. * @returns a JSON object
  26377. */
  26378. serialize(): any;
  26379. /**
  26380. * Creates a new skeleton from serialized data
  26381. * @param parsedSkeleton defines the serialized data
  26382. * @param scene defines the hosting scene
  26383. * @returns a new skeleton
  26384. */
  26385. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26386. /**
  26387. * Compute all node absolute transforms
  26388. * @param forceUpdate defines if computation must be done even if cache is up to date
  26389. */
  26390. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26391. /**
  26392. * Gets the root pose matrix
  26393. * @returns a matrix
  26394. */
  26395. getPoseMatrix(): Nullable<Matrix>;
  26396. /**
  26397. * Sorts bones per internal index
  26398. */
  26399. sortBones(): void;
  26400. private _sortBones;
  26401. /**
  26402. * Set the current local matrix as the restPose for all bones in the skeleton.
  26403. */
  26404. setCurrentPoseAsRest(): void;
  26405. }
  26406. }
  26407. declare module BABYLON {
  26408. /**
  26409. * Class used to store bone information
  26410. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26411. */
  26412. export class Bone extends Node {
  26413. /**
  26414. * defines the bone name
  26415. */
  26416. name: string;
  26417. private static _tmpVecs;
  26418. private static _tmpQuat;
  26419. private static _tmpMats;
  26420. /**
  26421. * Gets the list of child bones
  26422. */
  26423. children: Bone[];
  26424. /** Gets the animations associated with this bone */
  26425. animations: Animation[];
  26426. /**
  26427. * Gets or sets bone length
  26428. */
  26429. length: number;
  26430. /**
  26431. * @hidden Internal only
  26432. * Set this value to map this bone to a different index in the transform matrices
  26433. * Set this value to -1 to exclude the bone from the transform matrices
  26434. */
  26435. _index: Nullable<number>;
  26436. private _skeleton;
  26437. private _localMatrix;
  26438. private _restPose;
  26439. private _bindPose;
  26440. private _baseMatrix;
  26441. private _absoluteTransform;
  26442. private _invertedAbsoluteTransform;
  26443. private _parent;
  26444. private _scalingDeterminant;
  26445. private _worldTransform;
  26446. private _localScaling;
  26447. private _localRotation;
  26448. private _localPosition;
  26449. private _needToDecompose;
  26450. private _needToCompose;
  26451. /** @hidden */
  26452. _linkedTransformNode: Nullable<TransformNode>;
  26453. /** @hidden */
  26454. _waitingTransformNodeId: Nullable<string>;
  26455. /** @hidden */
  26456. get _matrix(): Matrix;
  26457. /** @hidden */
  26458. set _matrix(value: Matrix);
  26459. /**
  26460. * Create a new bone
  26461. * @param name defines the bone name
  26462. * @param skeleton defines the parent skeleton
  26463. * @param parentBone defines the parent (can be null if the bone is the root)
  26464. * @param localMatrix defines the local matrix
  26465. * @param restPose defines the rest pose matrix
  26466. * @param baseMatrix defines the base matrix
  26467. * @param index defines index of the bone in the hierarchy
  26468. */
  26469. constructor(
  26470. /**
  26471. * defines the bone name
  26472. */
  26473. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26474. /**
  26475. * Gets the current object class name.
  26476. * @return the class name
  26477. */
  26478. getClassName(): string;
  26479. /**
  26480. * Gets the parent skeleton
  26481. * @returns a skeleton
  26482. */
  26483. getSkeleton(): Skeleton;
  26484. /**
  26485. * Gets parent bone
  26486. * @returns a bone or null if the bone is the root of the bone hierarchy
  26487. */
  26488. getParent(): Nullable<Bone>;
  26489. /**
  26490. * Returns an array containing the root bones
  26491. * @returns an array containing the root bones
  26492. */
  26493. getChildren(): Array<Bone>;
  26494. /**
  26495. * Gets the node index in matrix array generated for rendering
  26496. * @returns the node index
  26497. */
  26498. getIndex(): number;
  26499. /**
  26500. * Sets the parent bone
  26501. * @param parent defines the parent (can be null if the bone is the root)
  26502. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26503. */
  26504. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26505. /**
  26506. * Gets the local matrix
  26507. * @returns a matrix
  26508. */
  26509. getLocalMatrix(): Matrix;
  26510. /**
  26511. * Gets the base matrix (initial matrix which remains unchanged)
  26512. * @returns a matrix
  26513. */
  26514. getBaseMatrix(): Matrix;
  26515. /**
  26516. * Gets the rest pose matrix
  26517. * @returns a matrix
  26518. */
  26519. getRestPose(): Matrix;
  26520. /**
  26521. * Sets the rest pose matrix
  26522. * @param matrix the local-space rest pose to set for this bone
  26523. */
  26524. setRestPose(matrix: Matrix): void;
  26525. /**
  26526. * Gets the bind pose matrix
  26527. * @returns the bind pose matrix
  26528. */
  26529. getBindPose(): Matrix;
  26530. /**
  26531. * Sets the bind pose matrix
  26532. * @param matrix the local-space bind pose to set for this bone
  26533. */
  26534. setBindPose(matrix: Matrix): void;
  26535. /**
  26536. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26537. */
  26538. getWorldMatrix(): Matrix;
  26539. /**
  26540. * Sets the local matrix to rest pose matrix
  26541. */
  26542. returnToRest(): void;
  26543. /**
  26544. * Gets the inverse of the absolute transform matrix.
  26545. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26546. * @returns a matrix
  26547. */
  26548. getInvertedAbsoluteTransform(): Matrix;
  26549. /**
  26550. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26551. * @returns a matrix
  26552. */
  26553. getAbsoluteTransform(): Matrix;
  26554. /**
  26555. * Links with the given transform node.
  26556. * The local matrix of this bone is copied from the transform node every frame.
  26557. * @param transformNode defines the transform node to link to
  26558. */
  26559. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26560. /**
  26561. * Gets the node used to drive the bone's transformation
  26562. * @returns a transform node or null
  26563. */
  26564. getTransformNode(): Nullable<TransformNode>;
  26565. /** Gets or sets current position (in local space) */
  26566. get position(): Vector3;
  26567. set position(newPosition: Vector3);
  26568. /** Gets or sets current rotation (in local space) */
  26569. get rotation(): Vector3;
  26570. set rotation(newRotation: Vector3);
  26571. /** Gets or sets current rotation quaternion (in local space) */
  26572. get rotationQuaternion(): Quaternion;
  26573. set rotationQuaternion(newRotation: Quaternion);
  26574. /** Gets or sets current scaling (in local space) */
  26575. get scaling(): Vector3;
  26576. set scaling(newScaling: Vector3);
  26577. /**
  26578. * Gets the animation properties override
  26579. */
  26580. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26581. private _decompose;
  26582. private _compose;
  26583. /**
  26584. * Update the base and local matrices
  26585. * @param matrix defines the new base or local matrix
  26586. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26587. * @param updateLocalMatrix defines if the local matrix should be updated
  26588. */
  26589. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26590. /** @hidden */
  26591. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26592. /**
  26593. * Flag the bone as dirty (Forcing it to update everything)
  26594. */
  26595. markAsDirty(): void;
  26596. /** @hidden */
  26597. _markAsDirtyAndCompose(): void;
  26598. private _markAsDirtyAndDecompose;
  26599. /**
  26600. * Translate the bone in local or world space
  26601. * @param vec The amount to translate the bone
  26602. * @param space The space that the translation is in
  26603. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26604. */
  26605. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26606. /**
  26607. * Set the position of the bone in local or world space
  26608. * @param position The position to set the bone
  26609. * @param space The space that the position is in
  26610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26611. */
  26612. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26613. /**
  26614. * Set the absolute position of the bone (world space)
  26615. * @param position The position to set the bone
  26616. * @param mesh The mesh that this bone is attached to
  26617. */
  26618. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26619. /**
  26620. * Scale the bone on the x, y and z axes (in local space)
  26621. * @param x The amount to scale the bone on the x axis
  26622. * @param y The amount to scale the bone on the y axis
  26623. * @param z The amount to scale the bone on the z axis
  26624. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26625. */
  26626. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26627. /**
  26628. * Set the bone scaling in local space
  26629. * @param scale defines the scaling vector
  26630. */
  26631. setScale(scale: Vector3): void;
  26632. /**
  26633. * Gets the current scaling in local space
  26634. * @returns the current scaling vector
  26635. */
  26636. getScale(): Vector3;
  26637. /**
  26638. * Gets the current scaling in local space and stores it in a target vector
  26639. * @param result defines the target vector
  26640. */
  26641. getScaleToRef(result: Vector3): void;
  26642. /**
  26643. * Set the yaw, pitch, and roll of the bone in local or world space
  26644. * @param yaw The rotation of the bone on the y axis
  26645. * @param pitch The rotation of the bone on the x axis
  26646. * @param roll The rotation of the bone on the z axis
  26647. * @param space The space that the axes of rotation are in
  26648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26649. */
  26650. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26651. /**
  26652. * Add a rotation to the bone on an axis in local or world space
  26653. * @param axis The axis to rotate the bone on
  26654. * @param amount The amount to rotate the bone
  26655. * @param space The space that the axis is in
  26656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26657. */
  26658. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26659. /**
  26660. * Set the rotation of the bone to a particular axis angle in local or world space
  26661. * @param axis The axis to rotate the bone on
  26662. * @param angle The angle that the bone should be rotated to
  26663. * @param space The space that the axis is in
  26664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26665. */
  26666. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26667. /**
  26668. * Set the euler rotation of the bone in local or world space
  26669. * @param rotation The euler rotation that the bone should be set to
  26670. * @param space The space that the rotation is in
  26671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26672. */
  26673. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26674. /**
  26675. * Set the quaternion rotation of the bone in local or world space
  26676. * @param quat The quaternion rotation that the bone should be set to
  26677. * @param space The space that the rotation is in
  26678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26679. */
  26680. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26681. /**
  26682. * Set the rotation matrix of the bone in local or world space
  26683. * @param rotMat The rotation matrix that the bone should be set to
  26684. * @param space The space that the rotation is in
  26685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26686. */
  26687. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26688. private _rotateWithMatrix;
  26689. private _getNegativeRotationToRef;
  26690. /**
  26691. * Get the position of the bone in local or world space
  26692. * @param space The space that the returned position is in
  26693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26694. * @returns The position of the bone
  26695. */
  26696. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26697. /**
  26698. * Copy the position of the bone to a vector3 in local or world space
  26699. * @param space The space that the returned position is in
  26700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26701. * @param result The vector3 to copy the position to
  26702. */
  26703. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26704. /**
  26705. * Get the absolute position of the bone (world space)
  26706. * @param mesh The mesh that this bone is attached to
  26707. * @returns The absolute position of the bone
  26708. */
  26709. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26710. /**
  26711. * Copy the absolute position of the bone (world space) to the result param
  26712. * @param mesh The mesh that this bone is attached to
  26713. * @param result The vector3 to copy the absolute position to
  26714. */
  26715. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26716. /**
  26717. * Compute the absolute transforms of this bone and its children
  26718. */
  26719. computeAbsoluteTransforms(): void;
  26720. /**
  26721. * Get the world direction from an axis that is in the local space of the bone
  26722. * @param localAxis The local direction that is used to compute the world direction
  26723. * @param mesh The mesh that this bone is attached to
  26724. * @returns The world direction
  26725. */
  26726. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26727. /**
  26728. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26729. * @param localAxis The local direction that is used to compute the world direction
  26730. * @param mesh The mesh that this bone is attached to
  26731. * @param result The vector3 that the world direction will be copied to
  26732. */
  26733. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26734. /**
  26735. * Get the euler rotation of the bone in local or world space
  26736. * @param space The space that the rotation should be in
  26737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26738. * @returns The euler rotation
  26739. */
  26740. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26741. /**
  26742. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26743. * @param space The space that the rotation should be in
  26744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26745. * @param result The vector3 that the rotation should be copied to
  26746. */
  26747. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26748. /**
  26749. * Get the quaternion rotation of the bone in either local or world space
  26750. * @param space The space that the rotation should be in
  26751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26752. * @returns The quaternion rotation
  26753. */
  26754. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26755. /**
  26756. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26757. * @param space The space that the rotation should be in
  26758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26759. * @param result The quaternion that the rotation should be copied to
  26760. */
  26761. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26762. /**
  26763. * Get the rotation matrix of the bone in local or world space
  26764. * @param space The space that the rotation should be in
  26765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26766. * @returns The rotation matrix
  26767. */
  26768. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26769. /**
  26770. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26771. * @param space The space that the rotation should be in
  26772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26773. * @param result The quaternion that the rotation should be copied to
  26774. */
  26775. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26776. /**
  26777. * Get the world position of a point that is in the local space of the bone
  26778. * @param position The local position
  26779. * @param mesh The mesh that this bone is attached to
  26780. * @returns The world position
  26781. */
  26782. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26783. /**
  26784. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26785. * @param position The local position
  26786. * @param mesh The mesh that this bone is attached to
  26787. * @param result The vector3 that the world position should be copied to
  26788. */
  26789. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26790. /**
  26791. * Get the local position of a point that is in world space
  26792. * @param position The world position
  26793. * @param mesh The mesh that this bone is attached to
  26794. * @returns The local position
  26795. */
  26796. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26797. /**
  26798. * Get the local position of a point that is in world space and copy it to the result param
  26799. * @param position The world position
  26800. * @param mesh The mesh that this bone is attached to
  26801. * @param result The vector3 that the local position should be copied to
  26802. */
  26803. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26804. /**
  26805. * Set the current local matrix as the restPose for this bone.
  26806. */
  26807. setCurrentPoseAsRest(): void;
  26808. }
  26809. }
  26810. declare module BABYLON {
  26811. /**
  26812. * 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.
  26813. * @see https://doc.babylonjs.com/how_to/transformnode
  26814. */
  26815. export class TransformNode extends Node {
  26816. /**
  26817. * Object will not rotate to face the camera
  26818. */
  26819. static BILLBOARDMODE_NONE: number;
  26820. /**
  26821. * Object will rotate to face the camera but only on the x axis
  26822. */
  26823. static BILLBOARDMODE_X: number;
  26824. /**
  26825. * Object will rotate to face the camera but only on the y axis
  26826. */
  26827. static BILLBOARDMODE_Y: number;
  26828. /**
  26829. * Object will rotate to face the camera but only on the z axis
  26830. */
  26831. static BILLBOARDMODE_Z: number;
  26832. /**
  26833. * Object will rotate to face the camera
  26834. */
  26835. static BILLBOARDMODE_ALL: number;
  26836. /**
  26837. * Object will rotate to face the camera's position instead of orientation
  26838. */
  26839. static BILLBOARDMODE_USE_POSITION: number;
  26840. private static _TmpRotation;
  26841. private static _TmpScaling;
  26842. private static _TmpTranslation;
  26843. private _forward;
  26844. private _forwardInverted;
  26845. private _up;
  26846. private _right;
  26847. private _rightInverted;
  26848. private _position;
  26849. private _rotation;
  26850. private _rotationQuaternion;
  26851. protected _scaling: Vector3;
  26852. protected _isDirty: boolean;
  26853. private _transformToBoneReferal;
  26854. private _isAbsoluteSynced;
  26855. private _billboardMode;
  26856. /**
  26857. * Gets or sets the billboard mode. Default is 0.
  26858. *
  26859. * | Value | Type | Description |
  26860. * | --- | --- | --- |
  26861. * | 0 | BILLBOARDMODE_NONE | |
  26862. * | 1 | BILLBOARDMODE_X | |
  26863. * | 2 | BILLBOARDMODE_Y | |
  26864. * | 4 | BILLBOARDMODE_Z | |
  26865. * | 7 | BILLBOARDMODE_ALL | |
  26866. *
  26867. */
  26868. get billboardMode(): number;
  26869. set billboardMode(value: number);
  26870. private _preserveParentRotationForBillboard;
  26871. /**
  26872. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26873. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26874. */
  26875. get preserveParentRotationForBillboard(): boolean;
  26876. set preserveParentRotationForBillboard(value: boolean);
  26877. /**
  26878. * 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
  26879. */
  26880. scalingDeterminant: number;
  26881. private _infiniteDistance;
  26882. /**
  26883. * Gets or sets the distance of the object to max, often used by skybox
  26884. */
  26885. get infiniteDistance(): boolean;
  26886. set infiniteDistance(value: boolean);
  26887. /**
  26888. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26889. * By default the system will update normals to compensate
  26890. */
  26891. ignoreNonUniformScaling: boolean;
  26892. /**
  26893. * 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
  26894. */
  26895. reIntegrateRotationIntoRotationQuaternion: boolean;
  26896. /** @hidden */
  26897. _poseMatrix: Nullable<Matrix>;
  26898. /** @hidden */
  26899. _localMatrix: Matrix;
  26900. private _usePivotMatrix;
  26901. private _absolutePosition;
  26902. private _absoluteScaling;
  26903. private _absoluteRotationQuaternion;
  26904. private _pivotMatrix;
  26905. private _pivotMatrixInverse;
  26906. /** @hidden */
  26907. _postMultiplyPivotMatrix: boolean;
  26908. protected _isWorldMatrixFrozen: boolean;
  26909. /** @hidden */
  26910. _indexInSceneTransformNodesArray: number;
  26911. /**
  26912. * An event triggered after the world matrix is updated
  26913. */
  26914. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26915. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26916. /**
  26917. * Gets a string identifying the name of the class
  26918. * @returns "TransformNode" string
  26919. */
  26920. getClassName(): string;
  26921. /**
  26922. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26923. */
  26924. get position(): Vector3;
  26925. set position(newPosition: Vector3);
  26926. /**
  26927. * 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)).
  26928. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26929. */
  26930. get rotation(): Vector3;
  26931. set rotation(newRotation: Vector3);
  26932. /**
  26933. * 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)).
  26934. */
  26935. get scaling(): Vector3;
  26936. set scaling(newScaling: Vector3);
  26937. /**
  26938. * 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).
  26939. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26940. */
  26941. get rotationQuaternion(): Nullable<Quaternion>;
  26942. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26943. /**
  26944. * The forward direction of that transform in world space.
  26945. */
  26946. get forward(): Vector3;
  26947. /**
  26948. * The up direction of that transform in world space.
  26949. */
  26950. get up(): Vector3;
  26951. /**
  26952. * The right direction of that transform in world space.
  26953. */
  26954. get right(): Vector3;
  26955. /**
  26956. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26957. * @param matrix the matrix to copy the pose from
  26958. * @returns this TransformNode.
  26959. */
  26960. updatePoseMatrix(matrix: Matrix): TransformNode;
  26961. /**
  26962. * Returns the mesh Pose matrix.
  26963. * @returns the pose matrix
  26964. */
  26965. getPoseMatrix(): Matrix;
  26966. /** @hidden */
  26967. _isSynchronized(): boolean;
  26968. /** @hidden */
  26969. _initCache(): void;
  26970. /**
  26971. * Flag the transform node as dirty (Forcing it to update everything)
  26972. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26973. * @returns this transform node
  26974. */
  26975. markAsDirty(property: string): TransformNode;
  26976. /**
  26977. * Returns the current mesh absolute position.
  26978. * Returns a Vector3.
  26979. */
  26980. get absolutePosition(): Vector3;
  26981. /**
  26982. * Returns the current mesh absolute scaling.
  26983. * Returns a Vector3.
  26984. */
  26985. get absoluteScaling(): Vector3;
  26986. /**
  26987. * Returns the current mesh absolute rotation.
  26988. * Returns a Quaternion.
  26989. */
  26990. get absoluteRotationQuaternion(): Quaternion;
  26991. /**
  26992. * Sets a new matrix to apply before all other transformation
  26993. * @param matrix defines the transform matrix
  26994. * @returns the current TransformNode
  26995. */
  26996. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26997. /**
  26998. * Sets a new pivot matrix to the current node
  26999. * @param matrix defines the new pivot matrix to use
  27000. * @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
  27001. * @returns the current TransformNode
  27002. */
  27003. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27004. /**
  27005. * Returns the mesh pivot matrix.
  27006. * Default : Identity.
  27007. * @returns the matrix
  27008. */
  27009. getPivotMatrix(): Matrix;
  27010. /**
  27011. * Instantiate (when possible) or clone that node with its hierarchy
  27012. * @param newParent defines the new parent to use for the instance (or clone)
  27013. * @param options defines options to configure how copy is done
  27014. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27015. * @returns an instance (or a clone) of the current node with its hiearchy
  27016. */
  27017. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27018. doNotInstantiate: boolean;
  27019. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27020. /**
  27021. * Prevents the World matrix to be computed any longer
  27022. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27023. * @returns the TransformNode.
  27024. */
  27025. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27026. /**
  27027. * Allows back the World matrix computation.
  27028. * @returns the TransformNode.
  27029. */
  27030. unfreezeWorldMatrix(): this;
  27031. /**
  27032. * True if the World matrix has been frozen.
  27033. */
  27034. get isWorldMatrixFrozen(): boolean;
  27035. /**
  27036. * Returns the mesh absolute position in the World.
  27037. * @returns a Vector3.
  27038. */
  27039. getAbsolutePosition(): Vector3;
  27040. /**
  27041. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27042. * @param absolutePosition the absolute position to set
  27043. * @returns the TransformNode.
  27044. */
  27045. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27046. /**
  27047. * Sets the mesh position in its local space.
  27048. * @param vector3 the position to set in localspace
  27049. * @returns the TransformNode.
  27050. */
  27051. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27052. /**
  27053. * Returns the mesh position in the local space from the current World matrix values.
  27054. * @returns a new Vector3.
  27055. */
  27056. getPositionExpressedInLocalSpace(): Vector3;
  27057. /**
  27058. * Translates the mesh along the passed Vector3 in its local space.
  27059. * @param vector3 the distance to translate in localspace
  27060. * @returns the TransformNode.
  27061. */
  27062. locallyTranslate(vector3: Vector3): TransformNode;
  27063. private static _lookAtVectorCache;
  27064. /**
  27065. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27066. * @param targetPoint the position (must be in same space as current mesh) to look at
  27067. * @param yawCor optional yaw (y-axis) correction in radians
  27068. * @param pitchCor optional pitch (x-axis) correction in radians
  27069. * @param rollCor optional roll (z-axis) correction in radians
  27070. * @param space the chosen space of the target
  27071. * @returns the TransformNode.
  27072. */
  27073. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27074. /**
  27075. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27076. * This Vector3 is expressed in the World space.
  27077. * @param localAxis axis to rotate
  27078. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27079. */
  27080. getDirection(localAxis: Vector3): Vector3;
  27081. /**
  27082. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27083. * localAxis is expressed in the mesh local space.
  27084. * result is computed in the Wordl space from the mesh World matrix.
  27085. * @param localAxis axis to rotate
  27086. * @param result the resulting transformnode
  27087. * @returns this TransformNode.
  27088. */
  27089. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27090. /**
  27091. * Sets this transform node rotation to the given local axis.
  27092. * @param localAxis the axis in local space
  27093. * @param yawCor optional yaw (y-axis) correction in radians
  27094. * @param pitchCor optional pitch (x-axis) correction in radians
  27095. * @param rollCor optional roll (z-axis) correction in radians
  27096. * @returns this TransformNode
  27097. */
  27098. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27099. /**
  27100. * Sets a new pivot point to the current node
  27101. * @param point defines the new pivot point to use
  27102. * @param space defines if the point is in world or local space (local by default)
  27103. * @returns the current TransformNode
  27104. */
  27105. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27106. /**
  27107. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27108. * @returns the pivot point
  27109. */
  27110. getPivotPoint(): Vector3;
  27111. /**
  27112. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27113. * @param result the vector3 to store the result
  27114. * @returns this TransformNode.
  27115. */
  27116. getPivotPointToRef(result: Vector3): TransformNode;
  27117. /**
  27118. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27119. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27120. */
  27121. getAbsolutePivotPoint(): Vector3;
  27122. /**
  27123. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27124. * @param result vector3 to store the result
  27125. * @returns this TransformNode.
  27126. */
  27127. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27128. /**
  27129. * Defines the passed node as the parent of the current node.
  27130. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27131. * @see https://doc.babylonjs.com/how_to/parenting
  27132. * @param node the node ot set as the parent
  27133. * @returns this TransformNode.
  27134. */
  27135. setParent(node: Nullable<Node>): TransformNode;
  27136. private _nonUniformScaling;
  27137. /**
  27138. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27139. */
  27140. get nonUniformScaling(): boolean;
  27141. /** @hidden */
  27142. _updateNonUniformScalingState(value: boolean): boolean;
  27143. /**
  27144. * Attach the current TransformNode to another TransformNode associated with a bone
  27145. * @param bone Bone affecting the TransformNode
  27146. * @param affectedTransformNode TransformNode associated with the bone
  27147. * @returns this object
  27148. */
  27149. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27150. /**
  27151. * Detach the transform node if its associated with a bone
  27152. * @returns this object
  27153. */
  27154. detachFromBone(): TransformNode;
  27155. private static _rotationAxisCache;
  27156. /**
  27157. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27158. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27159. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27160. * The passed axis is also normalized.
  27161. * @param axis the axis to rotate around
  27162. * @param amount the amount to rotate in radians
  27163. * @param space Space to rotate in (Default: local)
  27164. * @returns the TransformNode.
  27165. */
  27166. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27167. /**
  27168. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27169. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27170. * The passed axis is also normalized. .
  27171. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27172. * @param point the point to rotate around
  27173. * @param axis the axis to rotate around
  27174. * @param amount the amount to rotate in radians
  27175. * @returns the TransformNode
  27176. */
  27177. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27178. /**
  27179. * Translates the mesh along the axis vector for the passed distance in the given space.
  27180. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27181. * @param axis the axis to translate in
  27182. * @param distance the distance to translate
  27183. * @param space Space to rotate in (Default: local)
  27184. * @returns the TransformNode.
  27185. */
  27186. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27187. /**
  27188. * Adds a rotation step to the mesh current rotation.
  27189. * x, y, z are Euler angles expressed in radians.
  27190. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27191. * This means this rotation is made in the mesh local space only.
  27192. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27193. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27194. * ```javascript
  27195. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27196. * ```
  27197. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27198. * 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.
  27199. * @param x Rotation to add
  27200. * @param y Rotation to add
  27201. * @param z Rotation to add
  27202. * @returns the TransformNode.
  27203. */
  27204. addRotation(x: number, y: number, z: number): TransformNode;
  27205. /**
  27206. * @hidden
  27207. */
  27208. protected _getEffectiveParent(): Nullable<Node>;
  27209. /**
  27210. * Computes the world matrix of the node
  27211. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27212. * @returns the world matrix
  27213. */
  27214. computeWorldMatrix(force?: boolean): Matrix;
  27215. /**
  27216. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27217. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27218. */
  27219. resetLocalMatrix(independentOfChildren?: boolean): void;
  27220. protected _afterComputeWorldMatrix(): void;
  27221. /**
  27222. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27223. * @param func callback function to add
  27224. *
  27225. * @returns the TransformNode.
  27226. */
  27227. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27228. /**
  27229. * Removes a registered callback function.
  27230. * @param func callback function to remove
  27231. * @returns the TransformNode.
  27232. */
  27233. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27234. /**
  27235. * Gets the position of the current mesh in camera space
  27236. * @param camera defines the camera to use
  27237. * @returns a position
  27238. */
  27239. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27240. /**
  27241. * Returns the distance from the mesh to the active camera
  27242. * @param camera defines the camera to use
  27243. * @returns the distance
  27244. */
  27245. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27246. /**
  27247. * Clone the current transform node
  27248. * @param name Name of the new clone
  27249. * @param newParent New parent for the clone
  27250. * @param doNotCloneChildren Do not clone children hierarchy
  27251. * @returns the new transform node
  27252. */
  27253. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27254. /**
  27255. * Serializes the objects information.
  27256. * @param currentSerializationObject defines the object to serialize in
  27257. * @returns the serialized object
  27258. */
  27259. serialize(currentSerializationObject?: any): any;
  27260. /**
  27261. * Returns a new TransformNode object parsed from the source provided.
  27262. * @param parsedTransformNode is the source.
  27263. * @param scene the scene the object belongs to
  27264. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27265. * @returns a new TransformNode object parsed from the source provided.
  27266. */
  27267. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27268. /**
  27269. * Get all child-transformNodes of this node
  27270. * @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
  27271. * @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
  27272. * @returns an array of TransformNode
  27273. */
  27274. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27275. /**
  27276. * Releases resources associated with this transform node.
  27277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27279. */
  27280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27281. /**
  27282. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27283. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27284. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27285. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27286. * @returns the current mesh
  27287. */
  27288. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27289. private _syncAbsoluteScalingAndRotation;
  27290. }
  27291. }
  27292. declare module BABYLON {
  27293. /**
  27294. * Defines the types of pose enabled controllers that are supported
  27295. */
  27296. export enum PoseEnabledControllerType {
  27297. /**
  27298. * HTC Vive
  27299. */
  27300. VIVE = 0,
  27301. /**
  27302. * Oculus Rift
  27303. */
  27304. OCULUS = 1,
  27305. /**
  27306. * Windows mixed reality
  27307. */
  27308. WINDOWS = 2,
  27309. /**
  27310. * Samsung gear VR
  27311. */
  27312. GEAR_VR = 3,
  27313. /**
  27314. * Google Daydream
  27315. */
  27316. DAYDREAM = 4,
  27317. /**
  27318. * Generic
  27319. */
  27320. GENERIC = 5
  27321. }
  27322. /**
  27323. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27324. */
  27325. export interface MutableGamepadButton {
  27326. /**
  27327. * Value of the button/trigger
  27328. */
  27329. value: number;
  27330. /**
  27331. * If the button/trigger is currently touched
  27332. */
  27333. touched: boolean;
  27334. /**
  27335. * If the button/trigger is currently pressed
  27336. */
  27337. pressed: boolean;
  27338. }
  27339. /**
  27340. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27341. * @hidden
  27342. */
  27343. export interface ExtendedGamepadButton extends GamepadButton {
  27344. /**
  27345. * If the button/trigger is currently pressed
  27346. */
  27347. readonly pressed: boolean;
  27348. /**
  27349. * If the button/trigger is currently touched
  27350. */
  27351. readonly touched: boolean;
  27352. /**
  27353. * Value of the button/trigger
  27354. */
  27355. readonly value: number;
  27356. }
  27357. /** @hidden */
  27358. export interface _GamePadFactory {
  27359. /**
  27360. * Returns whether or not the current gamepad can be created for this type of controller.
  27361. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27362. * @returns true if it can be created, otherwise false
  27363. */
  27364. canCreate(gamepadInfo: any): boolean;
  27365. /**
  27366. * Creates a new instance of the Gamepad.
  27367. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27368. * @returns the new gamepad instance
  27369. */
  27370. create(gamepadInfo: any): Gamepad;
  27371. }
  27372. /**
  27373. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27374. */
  27375. export class PoseEnabledControllerHelper {
  27376. /** @hidden */
  27377. static _ControllerFactories: _GamePadFactory[];
  27378. /** @hidden */
  27379. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27380. /**
  27381. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27382. * @param vrGamepad the gamepad to initialized
  27383. * @returns a vr controller of the type the gamepad identified as
  27384. */
  27385. static InitiateController(vrGamepad: any): Gamepad;
  27386. }
  27387. /**
  27388. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27389. */
  27390. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27391. /**
  27392. * If the controller is used in a webXR session
  27393. */
  27394. isXR: boolean;
  27395. private _deviceRoomPosition;
  27396. private _deviceRoomRotationQuaternion;
  27397. /**
  27398. * The device position in babylon space
  27399. */
  27400. devicePosition: Vector3;
  27401. /**
  27402. * The device rotation in babylon space
  27403. */
  27404. deviceRotationQuaternion: Quaternion;
  27405. /**
  27406. * The scale factor of the device in babylon space
  27407. */
  27408. deviceScaleFactor: number;
  27409. /**
  27410. * (Likely devicePosition should be used instead) The device position in its room space
  27411. */
  27412. position: Vector3;
  27413. /**
  27414. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27415. */
  27416. rotationQuaternion: Quaternion;
  27417. /**
  27418. * The type of controller (Eg. Windows mixed reality)
  27419. */
  27420. controllerType: PoseEnabledControllerType;
  27421. protected _calculatedPosition: Vector3;
  27422. private _calculatedRotation;
  27423. /**
  27424. * The raw pose from the device
  27425. */
  27426. rawPose: DevicePose;
  27427. private _trackPosition;
  27428. private _maxRotationDistFromHeadset;
  27429. private _draggedRoomRotation;
  27430. /**
  27431. * @hidden
  27432. */
  27433. _disableTrackPosition(fixedPosition: Vector3): void;
  27434. /**
  27435. * Internal, the mesh attached to the controller
  27436. * @hidden
  27437. */
  27438. _mesh: Nullable<AbstractMesh>;
  27439. private _poseControlledCamera;
  27440. private _leftHandSystemQuaternion;
  27441. /**
  27442. * Internal, matrix used to convert room space to babylon space
  27443. * @hidden
  27444. */
  27445. _deviceToWorld: Matrix;
  27446. /**
  27447. * Node to be used when casting a ray from the controller
  27448. * @hidden
  27449. */
  27450. _pointingPoseNode: Nullable<TransformNode>;
  27451. /**
  27452. * Name of the child mesh that can be used to cast a ray from the controller
  27453. */
  27454. static readonly POINTING_POSE: string;
  27455. /**
  27456. * Creates a new PoseEnabledController from a gamepad
  27457. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27458. */
  27459. constructor(browserGamepad: any);
  27460. private _workingMatrix;
  27461. /**
  27462. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27463. */
  27464. update(): void;
  27465. /**
  27466. * Updates only the pose device and mesh without doing any button event checking
  27467. */
  27468. protected _updatePoseAndMesh(): void;
  27469. /**
  27470. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27471. * @param poseData raw pose fromthe device
  27472. */
  27473. updateFromDevice(poseData: DevicePose): void;
  27474. /**
  27475. * @hidden
  27476. */
  27477. _meshAttachedObservable: Observable<AbstractMesh>;
  27478. /**
  27479. * Attaches a mesh to the controller
  27480. * @param mesh the mesh to be attached
  27481. */
  27482. attachToMesh(mesh: AbstractMesh): void;
  27483. /**
  27484. * Attaches the controllers mesh to a camera
  27485. * @param camera the camera the mesh should be attached to
  27486. */
  27487. attachToPoseControlledCamera(camera: TargetCamera): void;
  27488. /**
  27489. * Disposes of the controller
  27490. */
  27491. dispose(): void;
  27492. /**
  27493. * The mesh that is attached to the controller
  27494. */
  27495. get mesh(): Nullable<AbstractMesh>;
  27496. /**
  27497. * Gets the ray of the controller in the direction the controller is pointing
  27498. * @param length the length the resulting ray should be
  27499. * @returns a ray in the direction the controller is pointing
  27500. */
  27501. getForwardRay(length?: number): Ray;
  27502. }
  27503. }
  27504. declare module BABYLON {
  27505. /**
  27506. * Defines the WebVRController object that represents controllers tracked in 3D space
  27507. */
  27508. export abstract class WebVRController extends PoseEnabledController {
  27509. /**
  27510. * Internal, the default controller model for the controller
  27511. */
  27512. protected _defaultModel: Nullable<AbstractMesh>;
  27513. /**
  27514. * Fired when the trigger state has changed
  27515. */
  27516. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27517. /**
  27518. * Fired when the main button state has changed
  27519. */
  27520. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27521. /**
  27522. * Fired when the secondary button state has changed
  27523. */
  27524. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27525. /**
  27526. * Fired when the pad state has changed
  27527. */
  27528. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27529. /**
  27530. * Fired when controllers stick values have changed
  27531. */
  27532. onPadValuesChangedObservable: Observable<StickValues>;
  27533. /**
  27534. * Array of button availible on the controller
  27535. */
  27536. protected _buttons: Array<MutableGamepadButton>;
  27537. private _onButtonStateChange;
  27538. /**
  27539. * Fired when a controller button's state has changed
  27540. * @param callback the callback containing the button that was modified
  27541. */
  27542. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27543. /**
  27544. * X and Y axis corresponding to the controllers joystick
  27545. */
  27546. pad: StickValues;
  27547. /**
  27548. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27549. */
  27550. hand: string;
  27551. /**
  27552. * The default controller model for the controller
  27553. */
  27554. get defaultModel(): Nullable<AbstractMesh>;
  27555. /**
  27556. * Creates a new WebVRController from a gamepad
  27557. * @param vrGamepad the gamepad that the WebVRController should be created from
  27558. */
  27559. constructor(vrGamepad: any);
  27560. /**
  27561. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27562. */
  27563. update(): void;
  27564. /**
  27565. * Function to be called when a button is modified
  27566. */
  27567. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27568. /**
  27569. * Loads a mesh and attaches it to the controller
  27570. * @param scene the scene the mesh should be added to
  27571. * @param meshLoaded callback for when the mesh has been loaded
  27572. */
  27573. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27574. private _setButtonValue;
  27575. private _changes;
  27576. private _checkChanges;
  27577. /**
  27578. * Disposes of th webVRCOntroller
  27579. */
  27580. dispose(): void;
  27581. }
  27582. }
  27583. declare module BABYLON {
  27584. /**
  27585. * The HemisphericLight simulates the ambient environment light,
  27586. * so the passed direction is the light reflection direction, not the incoming direction.
  27587. */
  27588. export class HemisphericLight extends Light {
  27589. /**
  27590. * The groundColor is the light in the opposite direction to the one specified during creation.
  27591. * 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.
  27592. */
  27593. groundColor: Color3;
  27594. /**
  27595. * The light reflection direction, not the incoming direction.
  27596. */
  27597. direction: Vector3;
  27598. /**
  27599. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27600. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27601. * The HemisphericLight can't cast shadows.
  27602. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27603. * @param name The friendly name of the light
  27604. * @param direction The direction of the light reflection
  27605. * @param scene The scene the light belongs to
  27606. */
  27607. constructor(name: string, direction: Vector3, scene: Scene);
  27608. protected _buildUniformLayout(): void;
  27609. /**
  27610. * Returns the string "HemisphericLight".
  27611. * @return The class name
  27612. */
  27613. getClassName(): string;
  27614. /**
  27615. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27616. * Returns the updated direction.
  27617. * @param target The target the direction should point to
  27618. * @return The computed direction
  27619. */
  27620. setDirectionToTarget(target: Vector3): Vector3;
  27621. /**
  27622. * Returns the shadow generator associated to the light.
  27623. * @returns Always null for hemispheric lights because it does not support shadows.
  27624. */
  27625. getShadowGenerator(): Nullable<IShadowGenerator>;
  27626. /**
  27627. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27628. * @param effect The effect to update
  27629. * @param lightIndex The index of the light in the effect to update
  27630. * @returns The hemispheric light
  27631. */
  27632. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27633. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27634. /**
  27635. * Computes the world matrix of the node
  27636. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27637. * @param useWasUpdatedFlag defines a reserved property
  27638. * @returns the world matrix
  27639. */
  27640. computeWorldMatrix(): Matrix;
  27641. /**
  27642. * Returns the integer 3.
  27643. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27644. */
  27645. getTypeID(): number;
  27646. /**
  27647. * Prepares the list of defines specific to the light type.
  27648. * @param defines the list of defines
  27649. * @param lightIndex defines the index of the light for the effect
  27650. */
  27651. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27652. }
  27653. }
  27654. declare module BABYLON {
  27655. /** @hidden */
  27656. export var vrMultiviewToSingleviewPixelShader: {
  27657. name: string;
  27658. shader: string;
  27659. };
  27660. }
  27661. declare module BABYLON {
  27662. /**
  27663. * Renders to multiple views with a single draw call
  27664. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27665. */
  27666. export class MultiviewRenderTarget extends RenderTargetTexture {
  27667. /**
  27668. * Creates a multiview render target
  27669. * @param scene scene used with the render target
  27670. * @param size the size of the render target (used for each view)
  27671. */
  27672. constructor(scene: Scene, size?: number | {
  27673. width: number;
  27674. height: number;
  27675. } | {
  27676. ratio: number;
  27677. });
  27678. /**
  27679. * @hidden
  27680. * @param faceIndex the face index, if its a cube texture
  27681. */
  27682. _bindFrameBuffer(faceIndex?: number): void;
  27683. /**
  27684. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27685. * @returns the view count
  27686. */
  27687. getViewCount(): number;
  27688. }
  27689. }
  27690. declare module BABYLON {
  27691. interface Engine {
  27692. /**
  27693. * Creates a new multiview render target
  27694. * @param width defines the width of the texture
  27695. * @param height defines the height of the texture
  27696. * @returns the created multiview texture
  27697. */
  27698. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27699. /**
  27700. * Binds a multiview framebuffer to be drawn to
  27701. * @param multiviewTexture texture to bind
  27702. */
  27703. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27704. }
  27705. interface Camera {
  27706. /**
  27707. * @hidden
  27708. * 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)
  27709. */
  27710. _useMultiviewToSingleView: boolean;
  27711. /**
  27712. * @hidden
  27713. * 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)
  27714. */
  27715. _multiviewTexture: Nullable<RenderTargetTexture>;
  27716. /**
  27717. * @hidden
  27718. * ensures the multiview texture of the camera exists and has the specified width/height
  27719. * @param width height to set on the multiview texture
  27720. * @param height width to set on the multiview texture
  27721. */
  27722. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27723. }
  27724. interface Scene {
  27725. /** @hidden */
  27726. _transformMatrixR: Matrix;
  27727. /** @hidden */
  27728. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27729. /** @hidden */
  27730. _createMultiviewUbo(): void;
  27731. /** @hidden */
  27732. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27733. /** @hidden */
  27734. _renderMultiviewToSingleView(camera: Camera): void;
  27735. }
  27736. }
  27737. declare module BABYLON {
  27738. /**
  27739. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27740. * This will not be used for webXR as it supports displaying texture arrays directly
  27741. */
  27742. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27743. /**
  27744. * Gets a string identifying the name of the class
  27745. * @returns "VRMultiviewToSingleviewPostProcess" string
  27746. */
  27747. getClassName(): string;
  27748. /**
  27749. * Initializes a VRMultiviewToSingleview
  27750. * @param name name of the post process
  27751. * @param camera camera to be applied to
  27752. * @param scaleFactor scaling factor to the size of the output texture
  27753. */
  27754. constructor(name: string, camera: Camera, scaleFactor: number);
  27755. }
  27756. }
  27757. declare module BABYLON {
  27758. /**
  27759. * Interface used to define additional presentation attributes
  27760. */
  27761. export interface IVRPresentationAttributes {
  27762. /**
  27763. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27764. */
  27765. highRefreshRate: boolean;
  27766. /**
  27767. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27768. */
  27769. foveationLevel: number;
  27770. }
  27771. interface Engine {
  27772. /** @hidden */
  27773. _vrDisplay: any;
  27774. /** @hidden */
  27775. _vrSupported: boolean;
  27776. /** @hidden */
  27777. _oldSize: Size;
  27778. /** @hidden */
  27779. _oldHardwareScaleFactor: number;
  27780. /** @hidden */
  27781. _vrExclusivePointerMode: boolean;
  27782. /** @hidden */
  27783. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27784. /** @hidden */
  27785. _onVRDisplayPointerRestricted: () => void;
  27786. /** @hidden */
  27787. _onVRDisplayPointerUnrestricted: () => void;
  27788. /** @hidden */
  27789. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27790. /** @hidden */
  27791. _onVrDisplayDisconnect: Nullable<() => void>;
  27792. /** @hidden */
  27793. _onVrDisplayPresentChange: Nullable<() => void>;
  27794. /**
  27795. * Observable signaled when VR display mode changes
  27796. */
  27797. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27798. /**
  27799. * Observable signaled when VR request present is complete
  27800. */
  27801. onVRRequestPresentComplete: Observable<boolean>;
  27802. /**
  27803. * Observable signaled when VR request present starts
  27804. */
  27805. onVRRequestPresentStart: Observable<Engine>;
  27806. /**
  27807. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27808. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27809. */
  27810. isInVRExclusivePointerMode: boolean;
  27811. /**
  27812. * Gets a boolean indicating if a webVR device was detected
  27813. * @returns true if a webVR device was detected
  27814. */
  27815. isVRDevicePresent(): boolean;
  27816. /**
  27817. * Gets the current webVR device
  27818. * @returns the current webVR device (or null)
  27819. */
  27820. getVRDevice(): any;
  27821. /**
  27822. * Initializes a webVR display and starts listening to display change events
  27823. * The onVRDisplayChangedObservable will be notified upon these changes
  27824. * @returns A promise containing a VRDisplay and if vr is supported
  27825. */
  27826. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27827. /** @hidden */
  27828. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27829. /**
  27830. * Gets or sets the presentation attributes used to configure VR rendering
  27831. */
  27832. vrPresentationAttributes?: IVRPresentationAttributes;
  27833. /**
  27834. * Call this function to switch to webVR mode
  27835. * Will do nothing if webVR is not supported or if there is no webVR device
  27836. * @param options the webvr options provided to the camera. mainly used for multiview
  27837. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27838. */
  27839. enableVR(options: WebVROptions): void;
  27840. /** @hidden */
  27841. _onVRFullScreenTriggered(): void;
  27842. }
  27843. }
  27844. declare module BABYLON {
  27845. /**
  27846. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27847. * IMPORTANT!! The data is right-hand data.
  27848. * @export
  27849. * @interface DevicePose
  27850. */
  27851. export interface DevicePose {
  27852. /**
  27853. * The position of the device, values in array are [x,y,z].
  27854. */
  27855. readonly position: Nullable<Float32Array>;
  27856. /**
  27857. * The linearVelocity of the device, values in array are [x,y,z].
  27858. */
  27859. readonly linearVelocity: Nullable<Float32Array>;
  27860. /**
  27861. * The linearAcceleration of the device, values in array are [x,y,z].
  27862. */
  27863. readonly linearAcceleration: Nullable<Float32Array>;
  27864. /**
  27865. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27866. */
  27867. readonly orientation: Nullable<Float32Array>;
  27868. /**
  27869. * The angularVelocity of the device, values in array are [x,y,z].
  27870. */
  27871. readonly angularVelocity: Nullable<Float32Array>;
  27872. /**
  27873. * The angularAcceleration of the device, values in array are [x,y,z].
  27874. */
  27875. readonly angularAcceleration: Nullable<Float32Array>;
  27876. }
  27877. /**
  27878. * Interface representing a pose controlled object in Babylon.
  27879. * A pose controlled object has both regular pose values as well as pose values
  27880. * from an external device such as a VR head mounted display
  27881. */
  27882. export interface PoseControlled {
  27883. /**
  27884. * The position of the object in babylon space.
  27885. */
  27886. position: Vector3;
  27887. /**
  27888. * The rotation quaternion of the object in babylon space.
  27889. */
  27890. rotationQuaternion: Quaternion;
  27891. /**
  27892. * The position of the device in babylon space.
  27893. */
  27894. devicePosition?: Vector3;
  27895. /**
  27896. * The rotation quaternion of the device in babylon space.
  27897. */
  27898. deviceRotationQuaternion: Quaternion;
  27899. /**
  27900. * The raw pose coming from the device.
  27901. */
  27902. rawPose: Nullable<DevicePose>;
  27903. /**
  27904. * The scale of the device to be used when translating from device space to babylon space.
  27905. */
  27906. deviceScaleFactor: number;
  27907. /**
  27908. * Updates the poseControlled values based on the input device pose.
  27909. * @param poseData the pose data to update the object with
  27910. */
  27911. updateFromDevice(poseData: DevicePose): void;
  27912. }
  27913. /**
  27914. * Set of options to customize the webVRCamera
  27915. */
  27916. export interface WebVROptions {
  27917. /**
  27918. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27919. */
  27920. trackPosition?: boolean;
  27921. /**
  27922. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27923. */
  27924. positionScale?: number;
  27925. /**
  27926. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27927. */
  27928. displayName?: string;
  27929. /**
  27930. * Should the native controller meshes be initialized. (default: true)
  27931. */
  27932. controllerMeshes?: boolean;
  27933. /**
  27934. * Creating a default HemiLight only on controllers. (default: true)
  27935. */
  27936. defaultLightingOnControllers?: boolean;
  27937. /**
  27938. * If you don't want to use the default VR button of the helper. (default: false)
  27939. */
  27940. useCustomVRButton?: boolean;
  27941. /**
  27942. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27943. */
  27944. customVRButton?: HTMLButtonElement;
  27945. /**
  27946. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27947. */
  27948. rayLength?: number;
  27949. /**
  27950. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27951. */
  27952. defaultHeight?: number;
  27953. /**
  27954. * If multiview should be used if available (default: false)
  27955. */
  27956. useMultiview?: boolean;
  27957. }
  27958. /**
  27959. * This represents a WebVR camera.
  27960. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27961. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27962. */
  27963. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27964. private webVROptions;
  27965. /**
  27966. * @hidden
  27967. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27968. */
  27969. _vrDevice: any;
  27970. /**
  27971. * The rawPose of the vrDevice.
  27972. */
  27973. rawPose: Nullable<DevicePose>;
  27974. private _onVREnabled;
  27975. private _specsVersion;
  27976. private _attached;
  27977. private _frameData;
  27978. protected _descendants: Array<Node>;
  27979. private _deviceRoomPosition;
  27980. /** @hidden */
  27981. _deviceRoomRotationQuaternion: Quaternion;
  27982. private _standingMatrix;
  27983. /**
  27984. * Represents device position in babylon space.
  27985. */
  27986. devicePosition: Vector3;
  27987. /**
  27988. * Represents device rotation in babylon space.
  27989. */
  27990. deviceRotationQuaternion: Quaternion;
  27991. /**
  27992. * The scale of the device to be used when translating from device space to babylon space.
  27993. */
  27994. deviceScaleFactor: number;
  27995. private _deviceToWorld;
  27996. private _worldToDevice;
  27997. /**
  27998. * References to the webVR controllers for the vrDevice.
  27999. */
  28000. controllers: Array<WebVRController>;
  28001. /**
  28002. * Emits an event when a controller is attached.
  28003. */
  28004. onControllersAttachedObservable: Observable<WebVRController[]>;
  28005. /**
  28006. * Emits an event when a controller's mesh has been loaded;
  28007. */
  28008. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28009. /**
  28010. * Emits an event when the HMD's pose has been updated.
  28011. */
  28012. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28013. private _poseSet;
  28014. /**
  28015. * If the rig cameras be used as parent instead of this camera.
  28016. */
  28017. rigParenting: boolean;
  28018. private _lightOnControllers;
  28019. private _defaultHeight?;
  28020. /**
  28021. * Instantiates a WebVRFreeCamera.
  28022. * @param name The name of the WebVRFreeCamera
  28023. * @param position The starting anchor position for the camera
  28024. * @param scene The scene the camera belongs to
  28025. * @param webVROptions a set of customizable options for the webVRCamera
  28026. */
  28027. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28028. /**
  28029. * Gets the device distance from the ground in meters.
  28030. * @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.
  28031. */
  28032. deviceDistanceToRoomGround(): number;
  28033. /**
  28034. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28035. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28036. */
  28037. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28038. /**
  28039. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28040. * @returns A promise with a boolean set to if the standing matrix is supported.
  28041. */
  28042. useStandingMatrixAsync(): Promise<boolean>;
  28043. /**
  28044. * Disposes the camera
  28045. */
  28046. dispose(): void;
  28047. /**
  28048. * Gets a vrController by name.
  28049. * @param name The name of the controller to retreive
  28050. * @returns the controller matching the name specified or null if not found
  28051. */
  28052. getControllerByName(name: string): Nullable<WebVRController>;
  28053. private _leftController;
  28054. /**
  28055. * The controller corresponding to the users left hand.
  28056. */
  28057. get leftController(): Nullable<WebVRController>;
  28058. private _rightController;
  28059. /**
  28060. * The controller corresponding to the users right hand.
  28061. */
  28062. get rightController(): Nullable<WebVRController>;
  28063. /**
  28064. * Casts a ray forward from the vrCamera's gaze.
  28065. * @param length Length of the ray (default: 100)
  28066. * @returns the ray corresponding to the gaze
  28067. */
  28068. getForwardRay(length?: number): Ray;
  28069. /**
  28070. * @hidden
  28071. * Updates the camera based on device's frame data
  28072. */
  28073. _checkInputs(): void;
  28074. /**
  28075. * Updates the poseControlled values based on the input device pose.
  28076. * @param poseData Pose coming from the device
  28077. */
  28078. updateFromDevice(poseData: DevicePose): void;
  28079. private _detachIfAttached;
  28080. /**
  28081. * WebVR's attach control will start broadcasting frames to the device.
  28082. * Note that in certain browsers (chrome for example) this function must be called
  28083. * within a user-interaction callback. Example:
  28084. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28085. *
  28086. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28087. */
  28088. attachControl(noPreventDefault?: boolean): void;
  28089. /**
  28090. * Detach the current controls from the specified dom element.
  28091. */
  28092. detachControl(): void;
  28093. /**
  28094. * @returns the name of this class
  28095. */
  28096. getClassName(): string;
  28097. /**
  28098. * Calls resetPose on the vrDisplay
  28099. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28100. */
  28101. resetToCurrentRotation(): void;
  28102. /**
  28103. * @hidden
  28104. * Updates the rig cameras (left and right eye)
  28105. */
  28106. _updateRigCameras(): void;
  28107. private _workingVector;
  28108. private _oneVector;
  28109. private _workingMatrix;
  28110. private updateCacheCalled;
  28111. private _correctPositionIfNotTrackPosition;
  28112. /**
  28113. * @hidden
  28114. * Updates the cached values of the camera
  28115. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28116. */
  28117. _updateCache(ignoreParentClass?: boolean): void;
  28118. /**
  28119. * @hidden
  28120. * Get current device position in babylon world
  28121. */
  28122. _computeDevicePosition(): void;
  28123. /**
  28124. * Updates the current device position and rotation in the babylon world
  28125. */
  28126. update(): void;
  28127. /**
  28128. * @hidden
  28129. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28130. * @returns an identity matrix
  28131. */
  28132. _getViewMatrix(): Matrix;
  28133. private _tmpMatrix;
  28134. /**
  28135. * This function is called by the two RIG cameras.
  28136. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28137. * @hidden
  28138. */
  28139. _getWebVRViewMatrix(): Matrix;
  28140. /** @hidden */
  28141. _getWebVRProjectionMatrix(): Matrix;
  28142. private _onGamepadConnectedObserver;
  28143. private _onGamepadDisconnectedObserver;
  28144. private _updateCacheWhenTrackingDisabledObserver;
  28145. /**
  28146. * Initializes the controllers and their meshes
  28147. */
  28148. initControllers(): void;
  28149. }
  28150. }
  28151. declare module BABYLON {
  28152. /**
  28153. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28154. *
  28155. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28156. *
  28157. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28158. */
  28159. export class MaterialHelper {
  28160. /**
  28161. * Bind the current view position to an effect.
  28162. * @param effect The effect to be bound
  28163. * @param scene The scene the eyes position is used from
  28164. * @param variableName name of the shader variable that will hold the eye position
  28165. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28166. * @return the computed eye position
  28167. */
  28168. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28169. /**
  28170. * Update the scene ubo before it can be used in rendering processing
  28171. * @param scene the scene to retrieve the ubo from
  28172. * @returns the scene UniformBuffer
  28173. */
  28174. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28175. /**
  28176. * Binds the scene's uniform buffer to the effect.
  28177. * @param effect defines the effect to bind to the scene uniform buffer
  28178. * @param sceneUbo defines the uniform buffer storing scene data
  28179. */
  28180. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28181. /**
  28182. * Helps preparing the defines values about the UVs in used in the effect.
  28183. * UVs are shared as much as we can across channels in the shaders.
  28184. * @param texture The texture we are preparing the UVs for
  28185. * @param defines The defines to update
  28186. * @param key The channel key "diffuse", "specular"... used in the shader
  28187. */
  28188. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28189. /**
  28190. * Binds a texture matrix value to its corresponding uniform
  28191. * @param texture The texture to bind the matrix for
  28192. * @param uniformBuffer The uniform buffer receiving the data
  28193. * @param key The channel key "diffuse", "specular"... used in the shader
  28194. */
  28195. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28196. /**
  28197. * Gets the current status of the fog (should it be enabled?)
  28198. * @param mesh defines the mesh to evaluate for fog support
  28199. * @param scene defines the hosting scene
  28200. * @returns true if fog must be enabled
  28201. */
  28202. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28203. /**
  28204. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28205. * @param mesh defines the current mesh
  28206. * @param scene defines the current scene
  28207. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28208. * @param pointsCloud defines if point cloud rendering has to be turned on
  28209. * @param fogEnabled defines if fog has to be turned on
  28210. * @param alphaTest defines if alpha testing has to be turned on
  28211. * @param defines defines the current list of defines
  28212. */
  28213. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28214. /**
  28215. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28216. * @param scene defines the current scene
  28217. * @param engine defines the current engine
  28218. * @param defines specifies the list of active defines
  28219. * @param useInstances defines if instances have to be turned on
  28220. * @param useClipPlane defines if clip plane have to be turned on
  28221. * @param useInstances defines if instances have to be turned on
  28222. * @param useThinInstances defines if thin instances have to be turned on
  28223. */
  28224. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28225. /**
  28226. * Prepares the defines for bones
  28227. * @param mesh The mesh containing the geometry data we will draw
  28228. * @param defines The defines to update
  28229. */
  28230. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28231. /**
  28232. * Prepares the defines for morph targets
  28233. * @param mesh The mesh containing the geometry data we will draw
  28234. * @param defines The defines to update
  28235. */
  28236. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28237. /**
  28238. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28239. * @param mesh The mesh containing the geometry data we will draw
  28240. * @param defines The defines to update
  28241. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28242. * @param useBones Precise whether bones should be used or not (override mesh info)
  28243. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28244. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28245. * @returns false if defines are considered not dirty and have not been checked
  28246. */
  28247. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28248. /**
  28249. * Prepares the defines related to multiview
  28250. * @param scene The scene we are intending to draw
  28251. * @param defines The defines to update
  28252. */
  28253. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28254. /**
  28255. * Prepares the defines related to the prepass
  28256. * @param scene The scene we are intending to draw
  28257. * @param defines The defines to update
  28258. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28259. */
  28260. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28261. /**
  28262. * Prepares the defines related to the light information passed in parameter
  28263. * @param scene The scene we are intending to draw
  28264. * @param mesh The mesh the effect is compiling for
  28265. * @param light The light the effect is compiling for
  28266. * @param lightIndex The index of the light
  28267. * @param defines The defines to update
  28268. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28269. * @param state Defines the current state regarding what is needed (normals, etc...)
  28270. */
  28271. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28272. needNormals: boolean;
  28273. needRebuild: boolean;
  28274. shadowEnabled: boolean;
  28275. specularEnabled: boolean;
  28276. lightmapMode: boolean;
  28277. }): void;
  28278. /**
  28279. * Prepares the defines related to the light information passed in parameter
  28280. * @param scene The scene we are intending to draw
  28281. * @param mesh The mesh the effect is compiling for
  28282. * @param defines The defines to update
  28283. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28284. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28285. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28286. * @returns true if normals will be required for the rest of the effect
  28287. */
  28288. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28289. /**
  28290. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28291. * @param lightIndex defines the light index
  28292. * @param uniformsList The uniform list
  28293. * @param samplersList The sampler list
  28294. * @param projectedLightTexture defines if projected texture must be used
  28295. * @param uniformBuffersList defines an optional list of uniform buffers
  28296. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28297. */
  28298. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28299. /**
  28300. * Prepares the uniforms and samplers list to be used in the effect
  28301. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28302. * @param samplersList The sampler list
  28303. * @param defines The defines helping in the list generation
  28304. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28305. */
  28306. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28307. /**
  28308. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28309. * @param defines The defines to update while falling back
  28310. * @param fallbacks The authorized effect fallbacks
  28311. * @param maxSimultaneousLights The maximum number of lights allowed
  28312. * @param rank the current rank of the Effect
  28313. * @returns The newly affected rank
  28314. */
  28315. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28316. private static _TmpMorphInfluencers;
  28317. /**
  28318. * Prepares the list of attributes required for morph targets according to the effect defines.
  28319. * @param attribs The current list of supported attribs
  28320. * @param mesh The mesh to prepare the morph targets attributes for
  28321. * @param influencers The number of influencers
  28322. */
  28323. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28324. /**
  28325. * Prepares the list of attributes required for morph targets according to the effect defines.
  28326. * @param attribs The current list of supported attribs
  28327. * @param mesh The mesh to prepare the morph targets attributes for
  28328. * @param defines The current Defines of the effect
  28329. */
  28330. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28331. /**
  28332. * Prepares the list of attributes required for bones according to the effect defines.
  28333. * @param attribs The current list of supported attribs
  28334. * @param mesh The mesh to prepare the bones attributes for
  28335. * @param defines The current Defines of the effect
  28336. * @param fallbacks The current effect fallback strategy
  28337. */
  28338. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28339. /**
  28340. * Check and prepare the list of attributes required for instances according to the effect defines.
  28341. * @param attribs The current list of supported attribs
  28342. * @param defines The current MaterialDefines of the effect
  28343. */
  28344. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28345. /**
  28346. * Add the list of attributes required for instances to the attribs array.
  28347. * @param attribs The current list of supported attribs
  28348. */
  28349. static PushAttributesForInstances(attribs: string[]): void;
  28350. /**
  28351. * Binds the light information to the effect.
  28352. * @param light The light containing the generator
  28353. * @param effect The effect we are binding the data to
  28354. * @param lightIndex The light index in the effect used to render
  28355. */
  28356. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28357. /**
  28358. * Binds the lights information from the scene to the effect for the given mesh.
  28359. * @param light Light to bind
  28360. * @param lightIndex Light index
  28361. * @param scene The scene where the light belongs to
  28362. * @param effect The effect we are binding the data to
  28363. * @param useSpecular Defines if specular is supported
  28364. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28365. */
  28366. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28367. /**
  28368. * Binds the lights information from the scene to the effect for the given mesh.
  28369. * @param scene The scene the lights belongs to
  28370. * @param mesh The mesh we are binding the information to render
  28371. * @param effect The effect we are binding the data to
  28372. * @param defines The generated defines for the effect
  28373. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28375. */
  28376. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28377. private static _tempFogColor;
  28378. /**
  28379. * Binds the fog information from the scene to the effect for the given mesh.
  28380. * @param scene The scene the lights belongs to
  28381. * @param mesh The mesh we are binding the information to render
  28382. * @param effect The effect we are binding the data to
  28383. * @param linearSpace Defines if the fog effect is applied in linear space
  28384. */
  28385. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28386. /**
  28387. * Binds the bones information from the mesh to the effect.
  28388. * @param mesh The mesh we are binding the information to render
  28389. * @param effect The effect we are binding the data to
  28390. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28391. */
  28392. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28393. private static _CopyBonesTransformationMatrices;
  28394. /**
  28395. * Binds the morph targets information from the mesh to the effect.
  28396. * @param abstractMesh The mesh we are binding the information to render
  28397. * @param effect The effect we are binding the data to
  28398. */
  28399. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28400. /**
  28401. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28402. * @param defines The generated defines used in the effect
  28403. * @param effect The effect we are binding the data to
  28404. * @param scene The scene we are willing to render with logarithmic scale for
  28405. */
  28406. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28407. /**
  28408. * Binds the clip plane information from the scene to the effect.
  28409. * @param scene The scene the clip plane information are extracted from
  28410. * @param effect The effect we are binding the data to
  28411. */
  28412. static BindClipPlane(effect: Effect, scene: Scene): void;
  28413. }
  28414. }
  28415. declare module BABYLON {
  28416. /** @hidden */
  28417. export var bayerDitherFunctions: {
  28418. name: string;
  28419. shader: string;
  28420. };
  28421. }
  28422. declare module BABYLON {
  28423. /** @hidden */
  28424. export var shadowMapFragmentDeclaration: {
  28425. name: string;
  28426. shader: string;
  28427. };
  28428. }
  28429. declare module BABYLON {
  28430. /** @hidden */
  28431. export var shadowMapFragment: {
  28432. name: string;
  28433. shader: string;
  28434. };
  28435. }
  28436. declare module BABYLON {
  28437. /** @hidden */
  28438. export var shadowMapPixelShader: {
  28439. name: string;
  28440. shader: string;
  28441. };
  28442. }
  28443. declare module BABYLON {
  28444. /** @hidden */
  28445. export var shadowMapVertexDeclaration: {
  28446. name: string;
  28447. shader: string;
  28448. };
  28449. }
  28450. declare module BABYLON {
  28451. /** @hidden */
  28452. export var shadowMapVertexNormalBias: {
  28453. name: string;
  28454. shader: string;
  28455. };
  28456. }
  28457. declare module BABYLON {
  28458. /** @hidden */
  28459. export var shadowMapVertexMetric: {
  28460. name: string;
  28461. shader: string;
  28462. };
  28463. }
  28464. declare module BABYLON {
  28465. /** @hidden */
  28466. export var shadowMapVertexShader: {
  28467. name: string;
  28468. shader: string;
  28469. };
  28470. }
  28471. declare module BABYLON {
  28472. /** @hidden */
  28473. export var depthBoxBlurPixelShader: {
  28474. name: string;
  28475. shader: string;
  28476. };
  28477. }
  28478. declare module BABYLON {
  28479. /** @hidden */
  28480. export var shadowMapFragmentSoftTransparentShadow: {
  28481. name: string;
  28482. shader: string;
  28483. };
  28484. }
  28485. declare module BABYLON {
  28486. /**
  28487. * Creates an instance based on a source mesh.
  28488. */
  28489. export class InstancedMesh extends AbstractMesh {
  28490. private _sourceMesh;
  28491. private _currentLOD;
  28492. /** @hidden */
  28493. _indexInSourceMeshInstanceArray: number;
  28494. constructor(name: string, source: Mesh);
  28495. /**
  28496. * Returns the string "InstancedMesh".
  28497. */
  28498. getClassName(): string;
  28499. /** Gets the list of lights affecting that mesh */
  28500. get lightSources(): Light[];
  28501. _resyncLightSources(): void;
  28502. _resyncLightSource(light: Light): void;
  28503. _removeLightSource(light: Light, dispose: boolean): void;
  28504. /**
  28505. * If the source mesh receives shadows
  28506. */
  28507. get receiveShadows(): boolean;
  28508. /**
  28509. * The material of the source mesh
  28510. */
  28511. get material(): Nullable<Material>;
  28512. /**
  28513. * Visibility of the source mesh
  28514. */
  28515. get visibility(): number;
  28516. /**
  28517. * Skeleton of the source mesh
  28518. */
  28519. get skeleton(): Nullable<Skeleton>;
  28520. /**
  28521. * Rendering ground id of the source mesh
  28522. */
  28523. get renderingGroupId(): number;
  28524. set renderingGroupId(value: number);
  28525. /**
  28526. * Returns the total number of vertices (integer).
  28527. */
  28528. getTotalVertices(): number;
  28529. /**
  28530. * Returns a positive integer : the total number of indices in this mesh geometry.
  28531. * @returns the numner of indices or zero if the mesh has no geometry.
  28532. */
  28533. getTotalIndices(): number;
  28534. /**
  28535. * The source mesh of the instance
  28536. */
  28537. get sourceMesh(): Mesh;
  28538. /**
  28539. * Creates a new InstancedMesh object from the mesh model.
  28540. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28541. * @param name defines the name of the new instance
  28542. * @returns a new InstancedMesh
  28543. */
  28544. createInstance(name: string): InstancedMesh;
  28545. /**
  28546. * Is this node ready to be used/rendered
  28547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28548. * @return {boolean} is it ready
  28549. */
  28550. isReady(completeCheck?: boolean): boolean;
  28551. /**
  28552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28553. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28554. * @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.
  28555. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28556. */
  28557. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28558. /**
  28559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28561. * The `data` are either a numeric array either a Float32Array.
  28562. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28563. * 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).
  28564. * Note that a new underlying VertexBuffer object is created each call.
  28565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28566. *
  28567. * Possible `kind` values :
  28568. * - VertexBuffer.PositionKind
  28569. * - VertexBuffer.UVKind
  28570. * - VertexBuffer.UV2Kind
  28571. * - VertexBuffer.UV3Kind
  28572. * - VertexBuffer.UV4Kind
  28573. * - VertexBuffer.UV5Kind
  28574. * - VertexBuffer.UV6Kind
  28575. * - VertexBuffer.ColorKind
  28576. * - VertexBuffer.MatricesIndicesKind
  28577. * - VertexBuffer.MatricesIndicesExtraKind
  28578. * - VertexBuffer.MatricesWeightsKind
  28579. * - VertexBuffer.MatricesWeightsExtraKind
  28580. *
  28581. * Returns the Mesh.
  28582. */
  28583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28584. /**
  28585. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28586. * If the mesh has no geometry, it is simply returned as it is.
  28587. * The `data` are either a numeric array either a Float32Array.
  28588. * No new underlying VertexBuffer object is created.
  28589. * 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.
  28590. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  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. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28609. /**
  28610. * Sets the mesh indices.
  28611. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28612. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28613. * This method creates a new index buffer each call.
  28614. * Returns the Mesh.
  28615. */
  28616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28617. /**
  28618. * Boolean : True if the mesh owns the requested kind of data.
  28619. */
  28620. isVerticesDataPresent(kind: string): boolean;
  28621. /**
  28622. * Returns an array of indices (IndicesArray).
  28623. */
  28624. getIndices(): Nullable<IndicesArray>;
  28625. get _positions(): Nullable<Vector3[]>;
  28626. /**
  28627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28628. * This means the mesh underlying bounding box and sphere are recomputed.
  28629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28630. * @returns the current mesh
  28631. */
  28632. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28633. /** @hidden */
  28634. _preActivate(): InstancedMesh;
  28635. /** @hidden */
  28636. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28637. /** @hidden */
  28638. _postActivate(): void;
  28639. getWorldMatrix(): Matrix;
  28640. get isAnInstance(): boolean;
  28641. /**
  28642. * Returns the current associated LOD AbstractMesh.
  28643. */
  28644. getLOD(camera: Camera): AbstractMesh;
  28645. /** @hidden */
  28646. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28647. /** @hidden */
  28648. _syncSubMeshes(): InstancedMesh;
  28649. /** @hidden */
  28650. _generatePointsArray(): boolean;
  28651. /** @hidden */
  28652. _updateBoundingInfo(): AbstractMesh;
  28653. /**
  28654. * Creates a new InstancedMesh from the current mesh.
  28655. * - name (string) : the cloned mesh name
  28656. * - newParent (optional Node) : the optional Node to parent the clone to.
  28657. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28658. *
  28659. * Returns the clone.
  28660. */
  28661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28662. /**
  28663. * Disposes the InstancedMesh.
  28664. * Returns nothing.
  28665. */
  28666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28667. }
  28668. interface Mesh {
  28669. /**
  28670. * Register a custom buffer that will be instanced
  28671. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28672. * @param kind defines the buffer kind
  28673. * @param stride defines the stride in floats
  28674. */
  28675. registerInstancedBuffer(kind: string, stride: number): void;
  28676. /**
  28677. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28678. */
  28679. _invalidateInstanceVertexArrayObject(): void;
  28680. /**
  28681. * true to use the edge renderer for all instances of this mesh
  28682. */
  28683. edgesShareWithInstances: boolean;
  28684. /** @hidden */
  28685. _userInstancedBuffersStorage: {
  28686. data: {
  28687. [key: string]: Float32Array;
  28688. };
  28689. sizes: {
  28690. [key: string]: number;
  28691. };
  28692. vertexBuffers: {
  28693. [key: string]: Nullable<VertexBuffer>;
  28694. };
  28695. strides: {
  28696. [key: string]: number;
  28697. };
  28698. vertexArrayObjects?: {
  28699. [key: string]: WebGLVertexArrayObject;
  28700. };
  28701. };
  28702. }
  28703. interface AbstractMesh {
  28704. /**
  28705. * Object used to store instanced buffers defined by user
  28706. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28707. */
  28708. instancedBuffers: {
  28709. [key: string]: any;
  28710. };
  28711. }
  28712. }
  28713. declare module BABYLON {
  28714. /**
  28715. * Defines the options associated with the creation of a shader material.
  28716. */
  28717. export interface IShaderMaterialOptions {
  28718. /**
  28719. * Does the material work in alpha blend mode
  28720. */
  28721. needAlphaBlending: boolean;
  28722. /**
  28723. * Does the material work in alpha test mode
  28724. */
  28725. needAlphaTesting: boolean;
  28726. /**
  28727. * The list of attribute names used in the shader
  28728. */
  28729. attributes: string[];
  28730. /**
  28731. * The list of uniform names used in the shader
  28732. */
  28733. uniforms: string[];
  28734. /**
  28735. * The list of UBO names used in the shader
  28736. */
  28737. uniformBuffers: string[];
  28738. /**
  28739. * The list of sampler names used in the shader
  28740. */
  28741. samplers: string[];
  28742. /**
  28743. * The list of defines used in the shader
  28744. */
  28745. defines: string[];
  28746. }
  28747. /**
  28748. * 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.
  28749. *
  28750. * This returned material effects how the mesh will look based on the code in the shaders.
  28751. *
  28752. * @see https://doc.babylonjs.com/how_to/shader_material
  28753. */
  28754. export class ShaderMaterial extends Material {
  28755. private _shaderPath;
  28756. private _options;
  28757. private _textures;
  28758. private _textureArrays;
  28759. private _floats;
  28760. private _ints;
  28761. private _floatsArrays;
  28762. private _colors3;
  28763. private _colors3Arrays;
  28764. private _colors4;
  28765. private _colors4Arrays;
  28766. private _vectors2;
  28767. private _vectors3;
  28768. private _vectors4;
  28769. private _matrices;
  28770. private _matrixArrays;
  28771. private _matrices3x3;
  28772. private _matrices2x2;
  28773. private _vectors2Arrays;
  28774. private _vectors3Arrays;
  28775. private _vectors4Arrays;
  28776. private _cachedWorldViewMatrix;
  28777. private _cachedWorldViewProjectionMatrix;
  28778. private _renderId;
  28779. private _multiview;
  28780. private _cachedDefines;
  28781. /** Define the Url to load snippets */
  28782. static SnippetUrl: string;
  28783. /** Snippet ID if the material was created from the snippet server */
  28784. snippetId: string;
  28785. /**
  28786. * Instantiate a new shader material.
  28787. * 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.
  28788. * This returned material effects how the mesh will look based on the code in the shaders.
  28789. * @see https://doc.babylonjs.com/how_to/shader_material
  28790. * @param name Define the name of the material in the scene
  28791. * @param scene Define the scene the material belongs to
  28792. * @param shaderPath Defines the route to the shader code in one of three ways:
  28793. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28794. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28795. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28796. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28797. * @param options Define the options used to create the shader
  28798. */
  28799. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28800. /**
  28801. * Gets the shader path used to define the shader code
  28802. * It can be modified to trigger a new compilation
  28803. */
  28804. get shaderPath(): any;
  28805. /**
  28806. * Sets the shader path used to define the shader code
  28807. * It can be modified to trigger a new compilation
  28808. */
  28809. set shaderPath(shaderPath: any);
  28810. /**
  28811. * Gets the options used to compile the shader.
  28812. * They can be modified to trigger a new compilation
  28813. */
  28814. get options(): IShaderMaterialOptions;
  28815. /**
  28816. * Gets the current class name of the material e.g. "ShaderMaterial"
  28817. * Mainly use in serialization.
  28818. * @returns the class name
  28819. */
  28820. getClassName(): string;
  28821. /**
  28822. * Specifies if the material will require alpha blending
  28823. * @returns a boolean specifying if alpha blending is needed
  28824. */
  28825. needAlphaBlending(): boolean;
  28826. /**
  28827. * Specifies if this material should be rendered in alpha test mode
  28828. * @returns a boolean specifying if an alpha test is needed.
  28829. */
  28830. needAlphaTesting(): boolean;
  28831. private _checkUniform;
  28832. /**
  28833. * Set a texture in the shader.
  28834. * @param name Define the name of the uniform samplers as defined in the shader
  28835. * @param texture Define the texture to bind to this sampler
  28836. * @return the material itself allowing "fluent" like uniform updates
  28837. */
  28838. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28839. /**
  28840. * Set a texture array in the shader.
  28841. * @param name Define the name of the uniform sampler array as defined in the shader
  28842. * @param textures Define the list of textures to bind to this sampler
  28843. * @return the material itself allowing "fluent" like uniform updates
  28844. */
  28845. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28846. /**
  28847. * Set a float in the shader.
  28848. * @param name Define the name of the uniform as defined in the shader
  28849. * @param value Define the value to give to the uniform
  28850. * @return the material itself allowing "fluent" like uniform updates
  28851. */
  28852. setFloat(name: string, value: number): ShaderMaterial;
  28853. /**
  28854. * Set a int in the shader.
  28855. * @param name Define the name of the uniform as defined in the shader
  28856. * @param value Define the value to give to the uniform
  28857. * @return the material itself allowing "fluent" like uniform updates
  28858. */
  28859. setInt(name: string, value: number): ShaderMaterial;
  28860. /**
  28861. * Set an array of floats in the shader.
  28862. * @param name Define the name of the uniform as defined in the shader
  28863. * @param value Define the value to give to the uniform
  28864. * @return the material itself allowing "fluent" like uniform updates
  28865. */
  28866. setFloats(name: string, value: number[]): ShaderMaterial;
  28867. /**
  28868. * Set a vec3 in the shader from a Color3.
  28869. * @param name Define the name of the uniform as defined in the shader
  28870. * @param value Define the value to give to the uniform
  28871. * @return the material itself allowing "fluent" like uniform updates
  28872. */
  28873. setColor3(name: string, value: Color3): ShaderMaterial;
  28874. /**
  28875. * Set a vec3 array in the shader from a Color3 array.
  28876. * @param name Define the name of the uniform as defined in the shader
  28877. * @param value Define the value to give to the uniform
  28878. * @return the material itself allowing "fluent" like uniform updates
  28879. */
  28880. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28881. /**
  28882. * Set a vec4 in the shader from a Color4.
  28883. * @param name Define the name of the uniform as defined in the shader
  28884. * @param value Define the value to give to the uniform
  28885. * @return the material itself allowing "fluent" like uniform updates
  28886. */
  28887. setColor4(name: string, value: Color4): ShaderMaterial;
  28888. /**
  28889. * Set a vec4 array in the shader from a Color4 array.
  28890. * @param name Define the name of the uniform as defined in the shader
  28891. * @param value Define the value to give to the uniform
  28892. * @return the material itself allowing "fluent" like uniform updates
  28893. */
  28894. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28895. /**
  28896. * Set a vec2 in the shader from a Vector2.
  28897. * @param name Define the name of the uniform as defined in the shader
  28898. * @param value Define the value to give to the uniform
  28899. * @return the material itself allowing "fluent" like uniform updates
  28900. */
  28901. setVector2(name: string, value: Vector2): ShaderMaterial;
  28902. /**
  28903. * Set a vec3 in the shader from a Vector3.
  28904. * @param name Define the name of the uniform as defined in the shader
  28905. * @param value Define the value to give to the uniform
  28906. * @return the material itself allowing "fluent" like uniform updates
  28907. */
  28908. setVector3(name: string, value: Vector3): ShaderMaterial;
  28909. /**
  28910. * Set a vec4 in the shader from a Vector4.
  28911. * @param name Define the name of the uniform as defined in the shader
  28912. * @param value Define the value to give to the uniform
  28913. * @return the material itself allowing "fluent" like uniform updates
  28914. */
  28915. setVector4(name: string, value: Vector4): ShaderMaterial;
  28916. /**
  28917. * Set a mat4 in the shader from a Matrix.
  28918. * @param name Define the name of the uniform as defined in the shader
  28919. * @param value Define the value to give to the uniform
  28920. * @return the material itself allowing "fluent" like uniform updates
  28921. */
  28922. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28923. /**
  28924. * Set a float32Array in the shader from a matrix array.
  28925. * @param name Define the name of the uniform as defined in the shader
  28926. * @param value Define the value to give to the uniform
  28927. * @return the material itself allowing "fluent" like uniform updates
  28928. */
  28929. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28930. /**
  28931. * Set a mat3 in the shader from a Float32Array.
  28932. * @param name Define the name of the uniform as defined in the shader
  28933. * @param value Define the value to give to the uniform
  28934. * @return the material itself allowing "fluent" like uniform updates
  28935. */
  28936. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28937. /**
  28938. * Set a mat2 in the shader from a Float32Array.
  28939. * @param name Define the name of the uniform as defined in the shader
  28940. * @param value Define the value to give to the uniform
  28941. * @return the material itself allowing "fluent" like uniform updates
  28942. */
  28943. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28944. /**
  28945. * Set a vec2 array in the shader from a number array.
  28946. * @param name Define the name of the uniform as defined in the shader
  28947. * @param value Define the value to give to the uniform
  28948. * @return the material itself allowing "fluent" like uniform updates
  28949. */
  28950. setArray2(name: string, value: number[]): ShaderMaterial;
  28951. /**
  28952. * Set a vec3 array in the shader from a number array.
  28953. * @param name Define the name of the uniform as defined in the shader
  28954. * @param value Define the value to give to the uniform
  28955. * @return the material itself allowing "fluent" like uniform updates
  28956. */
  28957. setArray3(name: string, value: number[]): ShaderMaterial;
  28958. /**
  28959. * Set a vec4 array in the shader from a number array.
  28960. * @param name Define the name of the uniform as defined in the shader
  28961. * @param value Define the value to give to the uniform
  28962. * @return the material itself allowing "fluent" like uniform updates
  28963. */
  28964. setArray4(name: string, value: number[]): ShaderMaterial;
  28965. private _checkCache;
  28966. /**
  28967. * Specifies that the submesh is ready to be used
  28968. * @param mesh defines the mesh to check
  28969. * @param subMesh defines which submesh to check
  28970. * @param useInstances specifies that instances should be used
  28971. * @returns a boolean indicating that the submesh is ready or not
  28972. */
  28973. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28974. /**
  28975. * Checks if the material is ready to render the requested mesh
  28976. * @param mesh Define the mesh to render
  28977. * @param useInstances Define whether or not the material is used with instances
  28978. * @returns true if ready, otherwise false
  28979. */
  28980. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28981. /**
  28982. * Binds the world matrix to the material
  28983. * @param world defines the world transformation matrix
  28984. * @param effectOverride - If provided, use this effect instead of internal effect
  28985. */
  28986. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28987. /**
  28988. * Binds the submesh to this material by preparing the effect and shader to draw
  28989. * @param world defines the world transformation matrix
  28990. * @param mesh defines the mesh containing the submesh
  28991. * @param subMesh defines the submesh to bind the material to
  28992. */
  28993. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28994. /**
  28995. * Binds the material to the mesh
  28996. * @param world defines the world transformation matrix
  28997. * @param mesh defines the mesh to bind the material to
  28998. * @param effectOverride - If provided, use this effect instead of internal effect
  28999. */
  29000. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29001. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29002. /**
  29003. * Gets the active textures from the material
  29004. * @returns an array of textures
  29005. */
  29006. getActiveTextures(): BaseTexture[];
  29007. /**
  29008. * Specifies if the material uses a texture
  29009. * @param texture defines the texture to check against the material
  29010. * @returns a boolean specifying if the material uses the texture
  29011. */
  29012. hasTexture(texture: BaseTexture): boolean;
  29013. /**
  29014. * Makes a duplicate of the material, and gives it a new name
  29015. * @param name defines the new name for the duplicated material
  29016. * @returns the cloned material
  29017. */
  29018. clone(name: string): ShaderMaterial;
  29019. /**
  29020. * Disposes the material
  29021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29024. */
  29025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29026. /**
  29027. * Serializes this material in a JSON representation
  29028. * @returns the serialized material object
  29029. */
  29030. serialize(): any;
  29031. /**
  29032. * Creates a shader material from parsed shader material data
  29033. * @param source defines the JSON representation of the material
  29034. * @param scene defines the hosting scene
  29035. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29036. * @returns a new material
  29037. */
  29038. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29039. /**
  29040. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29041. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29042. * @param url defines the url to load from
  29043. * @param scene defines the hosting scene
  29044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29045. * @returns a promise that will resolve to the new ShaderMaterial
  29046. */
  29047. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29048. /**
  29049. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29050. * @param snippetId defines the snippet to load
  29051. * @param scene defines the hosting scene
  29052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29053. * @returns a promise that will resolve to the new ShaderMaterial
  29054. */
  29055. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29056. }
  29057. }
  29058. declare module BABYLON {
  29059. /** @hidden */
  29060. export var colorPixelShader: {
  29061. name: string;
  29062. shader: string;
  29063. };
  29064. }
  29065. declare module BABYLON {
  29066. /** @hidden */
  29067. export var colorVertexShader: {
  29068. name: string;
  29069. shader: string;
  29070. };
  29071. }
  29072. declare module BABYLON {
  29073. /**
  29074. * Line mesh
  29075. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29076. */
  29077. export class LinesMesh extends Mesh {
  29078. /**
  29079. * If vertex color should be applied to the mesh
  29080. */
  29081. readonly useVertexColor?: boolean | undefined;
  29082. /**
  29083. * If vertex alpha should be applied to the mesh
  29084. */
  29085. readonly useVertexAlpha?: boolean | undefined;
  29086. /**
  29087. * Color of the line (Default: White)
  29088. */
  29089. color: Color3;
  29090. /**
  29091. * Alpha of the line (Default: 1)
  29092. */
  29093. alpha: number;
  29094. /**
  29095. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29096. * This margin is expressed in world space coordinates, so its value may vary.
  29097. * Default value is 0.1
  29098. */
  29099. intersectionThreshold: number;
  29100. private _colorShader;
  29101. private color4;
  29102. /**
  29103. * Creates a new LinesMesh
  29104. * @param name defines the name
  29105. * @param scene defines the hosting scene
  29106. * @param parent defines the parent mesh if any
  29107. * @param source defines the optional source LinesMesh used to clone data from
  29108. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29109. * When false, achieved by calling a clone(), also passing False.
  29110. * This will make creation of children, recursive.
  29111. * @param useVertexColor defines if this LinesMesh supports vertex color
  29112. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29113. */
  29114. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29115. /**
  29116. * If vertex color should be applied to the mesh
  29117. */
  29118. useVertexColor?: boolean | undefined,
  29119. /**
  29120. * If vertex alpha should be applied to the mesh
  29121. */
  29122. useVertexAlpha?: boolean | undefined);
  29123. private _addClipPlaneDefine;
  29124. private _removeClipPlaneDefine;
  29125. isReady(): boolean;
  29126. /**
  29127. * Returns the string "LineMesh"
  29128. */
  29129. getClassName(): string;
  29130. /**
  29131. * @hidden
  29132. */
  29133. get material(): Material;
  29134. /**
  29135. * @hidden
  29136. */
  29137. set material(value: Material);
  29138. /**
  29139. * @hidden
  29140. */
  29141. get checkCollisions(): boolean;
  29142. set checkCollisions(value: boolean);
  29143. /** @hidden */
  29144. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29145. /** @hidden */
  29146. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29147. /**
  29148. * Disposes of the line mesh
  29149. * @param doNotRecurse If children should be disposed
  29150. */
  29151. dispose(doNotRecurse?: boolean): void;
  29152. /**
  29153. * Returns a new LineMesh object cloned from the current one.
  29154. */
  29155. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29156. /**
  29157. * Creates a new InstancedLinesMesh object from the mesh model.
  29158. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29159. * @param name defines the name of the new instance
  29160. * @returns a new InstancedLinesMesh
  29161. */
  29162. createInstance(name: string): InstancedLinesMesh;
  29163. }
  29164. /**
  29165. * Creates an instance based on a source LinesMesh
  29166. */
  29167. export class InstancedLinesMesh extends InstancedMesh {
  29168. /**
  29169. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29170. * This margin is expressed in world space coordinates, so its value may vary.
  29171. * Initialized with the intersectionThreshold value of the source LinesMesh
  29172. */
  29173. intersectionThreshold: number;
  29174. constructor(name: string, source: LinesMesh);
  29175. /**
  29176. * Returns the string "InstancedLinesMesh".
  29177. */
  29178. getClassName(): string;
  29179. }
  29180. }
  29181. declare module BABYLON {
  29182. /** @hidden */
  29183. export var linePixelShader: {
  29184. name: string;
  29185. shader: string;
  29186. };
  29187. }
  29188. declare module BABYLON {
  29189. /** @hidden */
  29190. export var lineVertexShader: {
  29191. name: string;
  29192. shader: string;
  29193. };
  29194. }
  29195. declare module BABYLON {
  29196. interface Scene {
  29197. /** @hidden */
  29198. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29199. }
  29200. interface AbstractMesh {
  29201. /**
  29202. * Gets the edgesRenderer associated with the mesh
  29203. */
  29204. edgesRenderer: Nullable<EdgesRenderer>;
  29205. }
  29206. interface LinesMesh {
  29207. /**
  29208. * Enables the edge rendering mode on the mesh.
  29209. * This mode makes the mesh edges visible
  29210. * @param epsilon defines the maximal distance between two angles to detect a face
  29211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29212. * @returns the currentAbstractMesh
  29213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29214. */
  29215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29216. }
  29217. interface InstancedLinesMesh {
  29218. /**
  29219. * Enables the edge rendering mode on the mesh.
  29220. * This mode makes the mesh edges visible
  29221. * @param epsilon defines the maximal distance between two angles to detect a face
  29222. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29223. * @returns the current InstancedLinesMesh
  29224. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29225. */
  29226. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29227. }
  29228. /**
  29229. * Defines the minimum contract an Edges renderer should follow.
  29230. */
  29231. export interface IEdgesRenderer extends IDisposable {
  29232. /**
  29233. * Gets or sets a boolean indicating if the edgesRenderer is active
  29234. */
  29235. isEnabled: boolean;
  29236. /**
  29237. * Renders the edges of the attached mesh,
  29238. */
  29239. render(): void;
  29240. /**
  29241. * Checks whether or not the edges renderer is ready to render.
  29242. * @return true if ready, otherwise false.
  29243. */
  29244. isReady(): boolean;
  29245. /**
  29246. * List of instances to render in case the source mesh has instances
  29247. */
  29248. customInstances: SmartArray<Matrix>;
  29249. }
  29250. /**
  29251. * Defines the additional options of the edges renderer
  29252. */
  29253. export interface IEdgesRendererOptions {
  29254. /**
  29255. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29256. * If not defined, the default value is true
  29257. */
  29258. useAlternateEdgeFinder?: boolean;
  29259. /**
  29260. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29261. * If not defined, the default value is true.
  29262. * 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)
  29263. * This option is used only if useAlternateEdgeFinder = true
  29264. */
  29265. useFastVertexMerger?: boolean;
  29266. /**
  29267. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29268. * The default value is 1e-6
  29269. * This option is used only if useAlternateEdgeFinder = true
  29270. */
  29271. epsilonVertexMerge?: number;
  29272. /**
  29273. * 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
  29274. * 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.
  29275. * This option is used only if useAlternateEdgeFinder = true
  29276. */
  29277. applyTessellation?: boolean;
  29278. /**
  29279. * 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
  29280. * The default value is 1e-6
  29281. * This option is used only if useAlternateEdgeFinder = true
  29282. */
  29283. epsilonVertexAligned?: number;
  29284. }
  29285. /**
  29286. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29287. */
  29288. export class EdgesRenderer implements IEdgesRenderer {
  29289. /**
  29290. * Define the size of the edges with an orthographic camera
  29291. */
  29292. edgesWidthScalerForOrthographic: number;
  29293. /**
  29294. * Define the size of the edges with a perspective camera
  29295. */
  29296. edgesWidthScalerForPerspective: number;
  29297. protected _source: AbstractMesh;
  29298. protected _linesPositions: number[];
  29299. protected _linesNormals: number[];
  29300. protected _linesIndices: number[];
  29301. protected _epsilon: number;
  29302. protected _indicesCount: number;
  29303. protected _lineShader: ShaderMaterial;
  29304. protected _ib: DataBuffer;
  29305. protected _buffers: {
  29306. [key: string]: Nullable<VertexBuffer>;
  29307. };
  29308. protected _buffersForInstances: {
  29309. [key: string]: Nullable<VertexBuffer>;
  29310. };
  29311. protected _checkVerticesInsteadOfIndices: boolean;
  29312. protected _options: Nullable<IEdgesRendererOptions>;
  29313. private _meshRebuildObserver;
  29314. private _meshDisposeObserver;
  29315. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29316. isEnabled: boolean;
  29317. /** Gets the vertices generated by the edge renderer */
  29318. get linesPositions(): Immutable<Array<number>>;
  29319. /** Gets the normals generated by the edge renderer */
  29320. get linesNormals(): Immutable<Array<number>>;
  29321. /** Gets the indices generated by the edge renderer */
  29322. get linesIndices(): Immutable<Array<number>>;
  29323. /**
  29324. * List of instances to render in case the source mesh has instances
  29325. */
  29326. customInstances: SmartArray<Matrix>;
  29327. private static GetShader;
  29328. /**
  29329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29331. * @param source Mesh used to create edges
  29332. * @param epsilon sum of angles in adjacency to check for edge
  29333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29335. * @param options The options to apply when generating the edges
  29336. */
  29337. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29338. protected _prepareRessources(): void;
  29339. /** @hidden */
  29340. _rebuild(): void;
  29341. /**
  29342. * Releases the required resources for the edges renderer
  29343. */
  29344. dispose(): void;
  29345. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29346. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29347. /**
  29348. * Checks if the pair of p0 and p1 is en edge
  29349. * @param faceIndex
  29350. * @param edge
  29351. * @param faceNormals
  29352. * @param p0
  29353. * @param p1
  29354. * @private
  29355. */
  29356. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29357. /**
  29358. * push line into the position, normal and index buffer
  29359. * @protected
  29360. */
  29361. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29362. /**
  29363. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29364. */
  29365. private _tessellateTriangle;
  29366. private _generateEdgesLinesAlternate;
  29367. /**
  29368. * Generates lines edges from adjacencjes
  29369. * @private
  29370. */
  29371. _generateEdgesLines(): void;
  29372. /**
  29373. * Checks whether or not the edges renderer is ready to render.
  29374. * @return true if ready, otherwise false.
  29375. */
  29376. isReady(): boolean;
  29377. /**
  29378. * Renders the edges of the attached mesh,
  29379. */
  29380. render(): void;
  29381. }
  29382. /**
  29383. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29384. */
  29385. export class LineEdgesRenderer extends EdgesRenderer {
  29386. /**
  29387. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29388. * @param source LineMesh used to generate edges
  29389. * @param epsilon not important (specified angle for edge detection)
  29390. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29391. */
  29392. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29393. /**
  29394. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29395. */
  29396. _generateEdgesLines(): void;
  29397. }
  29398. }
  29399. declare module BABYLON {
  29400. /**
  29401. * This represents the object necessary to create a rendering group.
  29402. * This is exclusively used and created by the rendering manager.
  29403. * To modify the behavior, you use the available helpers in your scene or meshes.
  29404. * @hidden
  29405. */
  29406. export class RenderingGroup {
  29407. index: number;
  29408. private static _zeroVector;
  29409. private _scene;
  29410. private _opaqueSubMeshes;
  29411. private _transparentSubMeshes;
  29412. private _alphaTestSubMeshes;
  29413. private _depthOnlySubMeshes;
  29414. private _particleSystems;
  29415. private _spriteManagers;
  29416. private _opaqueSortCompareFn;
  29417. private _alphaTestSortCompareFn;
  29418. private _transparentSortCompareFn;
  29419. private _renderOpaque;
  29420. private _renderAlphaTest;
  29421. private _renderTransparent;
  29422. /** @hidden */
  29423. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29424. onBeforeTransparentRendering: () => void;
  29425. /**
  29426. * Set the opaque sort comparison function.
  29427. * If null the sub meshes will be render in the order they were created
  29428. */
  29429. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29430. /**
  29431. * Set the alpha test sort comparison function.
  29432. * If null the sub meshes will be render in the order they were created
  29433. */
  29434. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29435. /**
  29436. * Set the transparent sort comparison function.
  29437. * If null the sub meshes will be render in the order they were created
  29438. */
  29439. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29440. /**
  29441. * Creates a new rendering group.
  29442. * @param index The rendering group index
  29443. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29444. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29445. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29446. */
  29447. 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>);
  29448. /**
  29449. * Render all the sub meshes contained in the group.
  29450. * @param customRenderFunction Used to override the default render behaviour of the group.
  29451. * @returns true if rendered some submeshes.
  29452. */
  29453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29454. /**
  29455. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29456. * @param subMeshes The submeshes to render
  29457. */
  29458. private renderOpaqueSorted;
  29459. /**
  29460. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29461. * @param subMeshes The submeshes to render
  29462. */
  29463. private renderAlphaTestSorted;
  29464. /**
  29465. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29466. * @param subMeshes The submeshes to render
  29467. */
  29468. private renderTransparentSorted;
  29469. /**
  29470. * Renders the submeshes in a specified order.
  29471. * @param subMeshes The submeshes to sort before render
  29472. * @param sortCompareFn The comparison function use to sort
  29473. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29474. * @param transparent Specifies to activate blending if true
  29475. */
  29476. private static renderSorted;
  29477. /**
  29478. * Renders the submeshes in the order they were dispatched (no sort applied).
  29479. * @param subMeshes The submeshes to render
  29480. */
  29481. private static renderUnsorted;
  29482. /**
  29483. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29484. * are rendered back to front if in the same alpha index.
  29485. *
  29486. * @param a The first submesh
  29487. * @param b The second submesh
  29488. * @returns The result of the comparison
  29489. */
  29490. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29491. /**
  29492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29493. * are rendered back to front.
  29494. *
  29495. * @param a The first submesh
  29496. * @param b The second submesh
  29497. * @returns The result of the comparison
  29498. */
  29499. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29500. /**
  29501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29502. * are rendered front to back (prevent overdraw).
  29503. *
  29504. * @param a The first submesh
  29505. * @param b The second submesh
  29506. * @returns The result of the comparison
  29507. */
  29508. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29509. /**
  29510. * Resets the different lists of submeshes to prepare a new frame.
  29511. */
  29512. prepare(): void;
  29513. dispose(): void;
  29514. /**
  29515. * Inserts the submesh in its correct queue depending on its material.
  29516. * @param subMesh The submesh to dispatch
  29517. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29518. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29519. */
  29520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29521. dispatchSprites(spriteManager: ISpriteManager): void;
  29522. dispatchParticles(particleSystem: IParticleSystem): void;
  29523. private _renderParticles;
  29524. private _renderSprites;
  29525. }
  29526. }
  29527. declare module BABYLON {
  29528. /**
  29529. * Interface describing the different options available in the rendering manager
  29530. * regarding Auto Clear between groups.
  29531. */
  29532. export interface IRenderingManagerAutoClearSetup {
  29533. /**
  29534. * Defines whether or not autoclear is enable.
  29535. */
  29536. autoClear: boolean;
  29537. /**
  29538. * Defines whether or not to autoclear the depth buffer.
  29539. */
  29540. depth: boolean;
  29541. /**
  29542. * Defines whether or not to autoclear the stencil buffer.
  29543. */
  29544. stencil: boolean;
  29545. }
  29546. /**
  29547. * This class is used by the onRenderingGroupObservable
  29548. */
  29549. export class RenderingGroupInfo {
  29550. /**
  29551. * The Scene that being rendered
  29552. */
  29553. scene: Scene;
  29554. /**
  29555. * The camera currently used for the rendering pass
  29556. */
  29557. camera: Nullable<Camera>;
  29558. /**
  29559. * The ID of the renderingGroup being processed
  29560. */
  29561. renderingGroupId: number;
  29562. }
  29563. /**
  29564. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29565. * It is enable to manage the different groups as well as the different necessary sort functions.
  29566. * This should not be used directly aside of the few static configurations
  29567. */
  29568. export class RenderingManager {
  29569. /**
  29570. * The max id used for rendering groups (not included)
  29571. */
  29572. static MAX_RENDERINGGROUPS: number;
  29573. /**
  29574. * The min id used for rendering groups (included)
  29575. */
  29576. static MIN_RENDERINGGROUPS: number;
  29577. /**
  29578. * Used to globally prevent autoclearing scenes.
  29579. */
  29580. static AUTOCLEAR: boolean;
  29581. /**
  29582. * @hidden
  29583. */
  29584. _useSceneAutoClearSetup: boolean;
  29585. private _scene;
  29586. private _renderingGroups;
  29587. private _depthStencilBufferAlreadyCleaned;
  29588. private _autoClearDepthStencil;
  29589. private _customOpaqueSortCompareFn;
  29590. private _customAlphaTestSortCompareFn;
  29591. private _customTransparentSortCompareFn;
  29592. private _renderingGroupInfo;
  29593. /**
  29594. * Instantiates a new rendering group for a particular scene
  29595. * @param scene Defines the scene the groups belongs to
  29596. */
  29597. constructor(scene: Scene);
  29598. private _clearDepthStencilBuffer;
  29599. /**
  29600. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29601. * @hidden
  29602. */
  29603. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29604. /**
  29605. * Resets the different information of the group to prepare a new frame
  29606. * @hidden
  29607. */
  29608. reset(): void;
  29609. /**
  29610. * Dispose and release the group and its associated resources.
  29611. * @hidden
  29612. */
  29613. dispose(): void;
  29614. /**
  29615. * Clear the info related to rendering groups preventing retention points during dispose.
  29616. */
  29617. freeRenderingGroups(): void;
  29618. private _prepareRenderingGroup;
  29619. /**
  29620. * Add a sprite manager to the rendering manager in order to render it this frame.
  29621. * @param spriteManager Define the sprite manager to render
  29622. */
  29623. dispatchSprites(spriteManager: ISpriteManager): void;
  29624. /**
  29625. * Add a particle system to the rendering manager in order to render it this frame.
  29626. * @param particleSystem Define the particle system to render
  29627. */
  29628. dispatchParticles(particleSystem: IParticleSystem): void;
  29629. /**
  29630. * Add a submesh to the manager in order to render it this frame
  29631. * @param subMesh The submesh to dispatch
  29632. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29633. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29634. */
  29635. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29636. /**
  29637. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29638. * This allowed control for front to back rendering or reversely depending of the special needs.
  29639. *
  29640. * @param renderingGroupId The rendering group id corresponding to its index
  29641. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29642. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29643. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29644. */
  29645. 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;
  29646. /**
  29647. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29648. *
  29649. * @param renderingGroupId The rendering group id corresponding to its index
  29650. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29651. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29652. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29653. */
  29654. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29655. /**
  29656. * Gets the current auto clear configuration for one rendering group of the rendering
  29657. * manager.
  29658. * @param index the rendering group index to get the information for
  29659. * @returns The auto clear setup for the requested rendering group
  29660. */
  29661. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29662. }
  29663. }
  29664. declare module BABYLON {
  29665. /**
  29666. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29667. */
  29668. export interface ICustomShaderOptions {
  29669. /**
  29670. * Gets or sets the custom shader name to use
  29671. */
  29672. shaderName: string;
  29673. /**
  29674. * The list of attribute names used in the shader
  29675. */
  29676. attributes?: string[];
  29677. /**
  29678. * The list of uniform names used in the shader
  29679. */
  29680. uniforms?: string[];
  29681. /**
  29682. * The list of sampler names used in the shader
  29683. */
  29684. samplers?: string[];
  29685. /**
  29686. * The list of defines used in the shader
  29687. */
  29688. defines?: string[];
  29689. }
  29690. /**
  29691. * Interface to implement to create a shadow generator compatible with BJS.
  29692. */
  29693. export interface IShadowGenerator {
  29694. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29695. id: string;
  29696. /**
  29697. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29698. * @returns The render target texture if present otherwise, null
  29699. */
  29700. getShadowMap(): Nullable<RenderTargetTexture>;
  29701. /**
  29702. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29703. * @param subMesh The submesh we want to render in the shadow map
  29704. * @param useInstances Defines whether will draw in the map using instances
  29705. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29706. * @returns true if ready otherwise, false
  29707. */
  29708. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29709. /**
  29710. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29711. * @param defines Defines of the material we want to update
  29712. * @param lightIndex Index of the light in the enabled light list of the material
  29713. */
  29714. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29715. /**
  29716. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29717. * defined in the generator but impacting the effect).
  29718. * It implies the uniforms available on the materials are the standard BJS ones.
  29719. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29720. * @param effect The effect we are binding the information for
  29721. */
  29722. bindShadowLight(lightIndex: string, effect: Effect): void;
  29723. /**
  29724. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29725. * (eq to shadow projection matrix * light transform matrix)
  29726. * @returns The transform matrix used to create the shadow map
  29727. */
  29728. getTransformMatrix(): Matrix;
  29729. /**
  29730. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29731. * Cube and 2D textures for instance.
  29732. */
  29733. recreateShadowMap(): void;
  29734. /**
  29735. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29736. * @param onCompiled Callback triggered at the and of the effects compilation
  29737. * @param options Sets of optional options forcing the compilation with different modes
  29738. */
  29739. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29740. useInstances: boolean;
  29741. }>): void;
  29742. /**
  29743. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29744. * @param options Sets of optional options forcing the compilation with different modes
  29745. * @returns A promise that resolves when the compilation completes
  29746. */
  29747. forceCompilationAsync(options?: Partial<{
  29748. useInstances: boolean;
  29749. }>): Promise<void>;
  29750. /**
  29751. * Serializes the shadow generator setup to a json object.
  29752. * @returns The serialized JSON object
  29753. */
  29754. serialize(): any;
  29755. /**
  29756. * Disposes the Shadow map and related Textures and effects.
  29757. */
  29758. dispose(): void;
  29759. }
  29760. /**
  29761. * Default implementation IShadowGenerator.
  29762. * This is the main object responsible of generating shadows in the framework.
  29763. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29764. */
  29765. export class ShadowGenerator implements IShadowGenerator {
  29766. private static _Counter;
  29767. /**
  29768. * Name of the shadow generator class
  29769. */
  29770. static CLASSNAME: string;
  29771. /**
  29772. * Shadow generator mode None: no filtering applied.
  29773. */
  29774. static readonly FILTER_NONE: number;
  29775. /**
  29776. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29778. */
  29779. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29780. /**
  29781. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29782. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29783. */
  29784. static readonly FILTER_POISSONSAMPLING: number;
  29785. /**
  29786. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29788. */
  29789. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29790. /**
  29791. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29792. * edge artifacts on steep falloff.
  29793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29794. */
  29795. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29796. /**
  29797. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29798. * edge artifacts on steep falloff.
  29799. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29800. */
  29801. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29802. /**
  29803. * Shadow generator mode PCF: Percentage Closer Filtering
  29804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29805. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29806. */
  29807. static readonly FILTER_PCF: number;
  29808. /**
  29809. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29810. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29811. * Contact Hardening
  29812. */
  29813. static readonly FILTER_PCSS: number;
  29814. /**
  29815. * Reserved for PCF and PCSS
  29816. * Highest Quality.
  29817. *
  29818. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29819. *
  29820. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29821. */
  29822. static readonly QUALITY_HIGH: number;
  29823. /**
  29824. * Reserved for PCF and PCSS
  29825. * Good tradeoff for quality/perf cross devices
  29826. *
  29827. * Execute PCF on a 3*3 kernel.
  29828. *
  29829. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29830. */
  29831. static readonly QUALITY_MEDIUM: number;
  29832. /**
  29833. * Reserved for PCF and PCSS
  29834. * The lowest quality but the fastest.
  29835. *
  29836. * Execute PCF on a 1*1 kernel.
  29837. *
  29838. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29839. */
  29840. static readonly QUALITY_LOW: number;
  29841. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29842. id: string;
  29843. /** Gets or sets the custom shader name to use */
  29844. customShaderOptions: ICustomShaderOptions;
  29845. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29846. customAllowRendering: (subMesh: SubMesh) => boolean;
  29847. /**
  29848. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29849. */
  29850. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29851. /**
  29852. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29853. */
  29854. onAfterShadowMapRenderObservable: Observable<Effect>;
  29855. /**
  29856. * Observable triggered before a mesh is rendered in the shadow map.
  29857. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29858. */
  29859. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29860. /**
  29861. * Observable triggered after a mesh is rendered in the shadow map.
  29862. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29863. */
  29864. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29865. protected _bias: number;
  29866. /**
  29867. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29868. */
  29869. get bias(): number;
  29870. /**
  29871. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29872. */
  29873. set bias(bias: number);
  29874. protected _normalBias: number;
  29875. /**
  29876. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29877. */
  29878. get normalBias(): number;
  29879. /**
  29880. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29881. */
  29882. set normalBias(normalBias: number);
  29883. protected _blurBoxOffset: number;
  29884. /**
  29885. * Gets the blur box offset: offset applied during the blur pass.
  29886. * Only useful if useKernelBlur = false
  29887. */
  29888. get blurBoxOffset(): number;
  29889. /**
  29890. * Sets the blur box offset: offset applied during the blur pass.
  29891. * Only useful if useKernelBlur = false
  29892. */
  29893. set blurBoxOffset(value: number);
  29894. protected _blurScale: number;
  29895. /**
  29896. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29897. * 2 means half of the size.
  29898. */
  29899. get blurScale(): number;
  29900. /**
  29901. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29902. * 2 means half of the size.
  29903. */
  29904. set blurScale(value: number);
  29905. protected _blurKernel: number;
  29906. /**
  29907. * Gets the blur kernel: kernel size of the blur pass.
  29908. * Only useful if useKernelBlur = true
  29909. */
  29910. get blurKernel(): number;
  29911. /**
  29912. * Sets the blur kernel: kernel size of the blur pass.
  29913. * Only useful if useKernelBlur = true
  29914. */
  29915. set blurKernel(value: number);
  29916. protected _useKernelBlur: boolean;
  29917. /**
  29918. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29919. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29920. */
  29921. get useKernelBlur(): boolean;
  29922. /**
  29923. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29924. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29925. */
  29926. set useKernelBlur(value: boolean);
  29927. protected _depthScale: number;
  29928. /**
  29929. * Gets the depth scale used in ESM mode.
  29930. */
  29931. get depthScale(): number;
  29932. /**
  29933. * Sets the depth scale used in ESM mode.
  29934. * This can override the scale stored on the light.
  29935. */
  29936. set depthScale(value: number);
  29937. protected _validateFilter(filter: number): number;
  29938. protected _filter: number;
  29939. /**
  29940. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29941. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29942. */
  29943. get filter(): number;
  29944. /**
  29945. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29946. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29947. */
  29948. set filter(value: number);
  29949. /**
  29950. * Gets if the current filter is set to Poisson Sampling.
  29951. */
  29952. get usePoissonSampling(): boolean;
  29953. /**
  29954. * Sets the current filter to Poisson Sampling.
  29955. */
  29956. set usePoissonSampling(value: boolean);
  29957. /**
  29958. * Gets if the current filter is set to ESM.
  29959. */
  29960. get useExponentialShadowMap(): boolean;
  29961. /**
  29962. * Sets the current filter is to ESM.
  29963. */
  29964. set useExponentialShadowMap(value: boolean);
  29965. /**
  29966. * Gets if the current filter is set to filtered ESM.
  29967. */
  29968. get useBlurExponentialShadowMap(): boolean;
  29969. /**
  29970. * Gets if the current filter is set to filtered ESM.
  29971. */
  29972. set useBlurExponentialShadowMap(value: boolean);
  29973. /**
  29974. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29975. * exponential to prevent steep falloff artifacts).
  29976. */
  29977. get useCloseExponentialShadowMap(): boolean;
  29978. /**
  29979. * Sets the current filter to "close ESM" (using the inverse of the
  29980. * exponential to prevent steep falloff artifacts).
  29981. */
  29982. set useCloseExponentialShadowMap(value: boolean);
  29983. /**
  29984. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29985. * exponential to prevent steep falloff artifacts).
  29986. */
  29987. get useBlurCloseExponentialShadowMap(): boolean;
  29988. /**
  29989. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29990. * exponential to prevent steep falloff artifacts).
  29991. */
  29992. set useBlurCloseExponentialShadowMap(value: boolean);
  29993. /**
  29994. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29995. */
  29996. get usePercentageCloserFiltering(): boolean;
  29997. /**
  29998. * Sets the current filter to "PCF" (percentage closer filtering).
  29999. */
  30000. set usePercentageCloserFiltering(value: boolean);
  30001. protected _filteringQuality: number;
  30002. /**
  30003. * Gets the PCF or PCSS Quality.
  30004. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30005. */
  30006. get filteringQuality(): number;
  30007. /**
  30008. * Sets the PCF or PCSS Quality.
  30009. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30010. */
  30011. set filteringQuality(filteringQuality: number);
  30012. /**
  30013. * Gets if the current filter is set to "PCSS" (contact hardening).
  30014. */
  30015. get useContactHardeningShadow(): boolean;
  30016. /**
  30017. * Sets the current filter to "PCSS" (contact hardening).
  30018. */
  30019. set useContactHardeningShadow(value: boolean);
  30020. protected _contactHardeningLightSizeUVRatio: number;
  30021. /**
  30022. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30023. * Using a ratio helps keeping shape stability independently of the map size.
  30024. *
  30025. * It does not account for the light projection as it was having too much
  30026. * instability during the light setup or during light position changes.
  30027. *
  30028. * Only valid if useContactHardeningShadow is true.
  30029. */
  30030. get contactHardeningLightSizeUVRatio(): number;
  30031. /**
  30032. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30033. * Using a ratio helps keeping shape stability independently of the map size.
  30034. *
  30035. * It does not account for the light projection as it was having too much
  30036. * instability during the light setup or during light position changes.
  30037. *
  30038. * Only valid if useContactHardeningShadow is true.
  30039. */
  30040. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30041. protected _darkness: number;
  30042. /** Gets or sets the actual darkness of a shadow */
  30043. get darkness(): number;
  30044. set darkness(value: number);
  30045. /**
  30046. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30047. * 0 means strongest and 1 would means no shadow.
  30048. * @returns the darkness.
  30049. */
  30050. getDarkness(): number;
  30051. /**
  30052. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30053. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30054. * @returns the shadow generator allowing fluent coding.
  30055. */
  30056. setDarkness(darkness: number): ShadowGenerator;
  30057. protected _transparencyShadow: boolean;
  30058. /** Gets or sets the ability to have transparent shadow */
  30059. get transparencyShadow(): boolean;
  30060. set transparencyShadow(value: boolean);
  30061. /**
  30062. * Sets the ability to have transparent shadow (boolean).
  30063. * @param transparent True if transparent else False
  30064. * @returns the shadow generator allowing fluent coding
  30065. */
  30066. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30067. /**
  30068. * Enables or disables shadows with varying strength based on the transparency
  30069. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30070. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30071. * mesh.visibility * alphaTexture.a
  30072. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30073. */
  30074. enableSoftTransparentShadow: boolean;
  30075. protected _shadowMap: Nullable<RenderTargetTexture>;
  30076. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30077. /**
  30078. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30079. * @returns The render target texture if present otherwise, null
  30080. */
  30081. getShadowMap(): Nullable<RenderTargetTexture>;
  30082. /**
  30083. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30084. * @returns The render target texture if the shadow map is present otherwise, null
  30085. */
  30086. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30087. /**
  30088. * Gets the class name of that object
  30089. * @returns "ShadowGenerator"
  30090. */
  30091. getClassName(): string;
  30092. /**
  30093. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30094. * @param mesh Mesh to add
  30095. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30096. * @returns the Shadow Generator itself
  30097. */
  30098. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30099. /**
  30100. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30101. * @param mesh Mesh to remove
  30102. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30103. * @returns the Shadow Generator itself
  30104. */
  30105. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30106. /**
  30107. * Controls the extent to which the shadows fade out at the edge of the frustum
  30108. */
  30109. frustumEdgeFalloff: number;
  30110. protected _light: IShadowLight;
  30111. /**
  30112. * Returns the associated light object.
  30113. * @returns the light generating the shadow
  30114. */
  30115. getLight(): IShadowLight;
  30116. /**
  30117. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30118. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30119. * It might on the other hand introduce peter panning.
  30120. */
  30121. forceBackFacesOnly: boolean;
  30122. protected _scene: Scene;
  30123. protected _lightDirection: Vector3;
  30124. protected _viewMatrix: Matrix;
  30125. protected _projectionMatrix: Matrix;
  30126. protected _transformMatrix: Matrix;
  30127. protected _cachedPosition: Vector3;
  30128. protected _cachedDirection: Vector3;
  30129. protected _cachedDefines: string;
  30130. protected _currentRenderID: number;
  30131. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30132. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30133. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30134. protected _blurPostProcesses: PostProcess[];
  30135. protected _mapSize: number;
  30136. protected _currentFaceIndex: number;
  30137. protected _currentFaceIndexCache: number;
  30138. protected _textureType: number;
  30139. protected _defaultTextureMatrix: Matrix;
  30140. protected _storedUniqueId: Nullable<number>;
  30141. protected _nameForCustomEffect: string;
  30142. /** @hidden */
  30143. static _SceneComponentInitialization: (scene: Scene) => void;
  30144. /**
  30145. * Gets or sets the size of the texture what stores the shadows
  30146. */
  30147. get mapSize(): number;
  30148. set mapSize(size: number);
  30149. /**
  30150. * Creates a ShadowGenerator object.
  30151. * A ShadowGenerator is the required tool to use the shadows.
  30152. * Each light casting shadows needs to use its own ShadowGenerator.
  30153. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30154. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30155. * @param light The light object generating the shadows.
  30156. * @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.
  30157. */
  30158. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30159. protected _initializeGenerator(): void;
  30160. protected _createTargetRenderTexture(): void;
  30161. protected _initializeShadowMap(): void;
  30162. protected _initializeBlurRTTAndPostProcesses(): void;
  30163. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30164. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30165. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30166. protected _applyFilterValues(): void;
  30167. /**
  30168. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30169. * @param onCompiled Callback triggered at the and of the effects compilation
  30170. * @param options Sets of optional options forcing the compilation with different modes
  30171. */
  30172. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30173. useInstances: boolean;
  30174. }>): void;
  30175. /**
  30176. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30177. * @param options Sets of optional options forcing the compilation with different modes
  30178. * @returns A promise that resolves when the compilation completes
  30179. */
  30180. forceCompilationAsync(options?: Partial<{
  30181. useInstances: boolean;
  30182. }>): Promise<void>;
  30183. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30184. private _prepareShadowDefines;
  30185. /**
  30186. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30187. * @param subMesh The submesh we want to render in the shadow map
  30188. * @param useInstances Defines whether will draw in the map using instances
  30189. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30190. * @returns true if ready otherwise, false
  30191. */
  30192. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30193. /**
  30194. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30195. * @param defines Defines of the material we want to update
  30196. * @param lightIndex Index of the light in the enabled light list of the material
  30197. */
  30198. prepareDefines(defines: any, lightIndex: number): void;
  30199. /**
  30200. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30201. * defined in the generator but impacting the effect).
  30202. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30203. * @param effect The effect we are binding the information for
  30204. */
  30205. bindShadowLight(lightIndex: string, effect: Effect): void;
  30206. /**
  30207. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30208. * (eq to shadow projection matrix * light transform matrix)
  30209. * @returns The transform matrix used to create the shadow map
  30210. */
  30211. getTransformMatrix(): Matrix;
  30212. /**
  30213. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30214. * Cube and 2D textures for instance.
  30215. */
  30216. recreateShadowMap(): void;
  30217. protected _disposeBlurPostProcesses(): void;
  30218. protected _disposeRTTandPostProcesses(): void;
  30219. /**
  30220. * Disposes the ShadowGenerator.
  30221. * Returns nothing.
  30222. */
  30223. dispose(): void;
  30224. /**
  30225. * Serializes the shadow generator setup to a json object.
  30226. * @returns The serialized JSON object
  30227. */
  30228. serialize(): any;
  30229. /**
  30230. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30231. * @param parsedShadowGenerator The JSON object to parse
  30232. * @param scene The scene to create the shadow map for
  30233. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30234. * @returns The parsed shadow generator
  30235. */
  30236. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30237. }
  30238. }
  30239. declare module BABYLON {
  30240. /**
  30241. * Options to be used when creating a shadow depth material
  30242. */
  30243. export interface IIOptionShadowDepthMaterial {
  30244. /** Variables in the vertex shader code that need to have their names remapped.
  30245. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30246. * "var_name" should be either: worldPos or vNormalW
  30247. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30248. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30249. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30250. */
  30251. remappedVariables?: string[];
  30252. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30253. standalone?: boolean;
  30254. }
  30255. /**
  30256. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30257. */
  30258. export class ShadowDepthWrapper {
  30259. private _scene;
  30260. private _options?;
  30261. private _baseMaterial;
  30262. private _onEffectCreatedObserver;
  30263. private _subMeshToEffect;
  30264. private _subMeshToDepthEffect;
  30265. private _meshes;
  30266. /** @hidden */
  30267. _matriceNames: any;
  30268. /** Gets the standalone status of the wrapper */
  30269. get standalone(): boolean;
  30270. /** Gets the base material the wrapper is built upon */
  30271. get baseMaterial(): Material;
  30272. /**
  30273. * Instantiate a new shadow depth wrapper.
  30274. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30275. * generate the shadow depth map. For more information, please refer to the documentation:
  30276. * https://doc.babylonjs.com/babylon101/shadows
  30277. * @param baseMaterial Material to wrap
  30278. * @param scene Define the scene the material belongs to
  30279. * @param options Options used to create the wrapper
  30280. */
  30281. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30282. /**
  30283. * Gets the effect to use to generate the depth map
  30284. * @param subMesh subMesh to get the effect for
  30285. * @param shadowGenerator shadow generator to get the effect for
  30286. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30287. */
  30288. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30289. /**
  30290. * Specifies that the submesh is ready to be used for depth rendering
  30291. * @param subMesh submesh to check
  30292. * @param defines the list of defines to take into account when checking the effect
  30293. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30294. * @param useInstances specifies that instances should be used
  30295. * @returns a boolean indicating that the submesh is ready or not
  30296. */
  30297. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30298. /**
  30299. * Disposes the resources
  30300. */
  30301. dispose(): void;
  30302. private _makeEffect;
  30303. }
  30304. }
  30305. declare module BABYLON {
  30306. /**
  30307. * Options for compiling materials.
  30308. */
  30309. export interface IMaterialCompilationOptions {
  30310. /**
  30311. * Defines whether clip planes are enabled.
  30312. */
  30313. clipPlane: boolean;
  30314. /**
  30315. * Defines whether instances are enabled.
  30316. */
  30317. useInstances: boolean;
  30318. }
  30319. /**
  30320. * Options passed when calling customShaderNameResolve
  30321. */
  30322. export interface ICustomShaderNameResolveOptions {
  30323. /**
  30324. * 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
  30325. */
  30326. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30327. }
  30328. /**
  30329. * Base class for the main features of a material in Babylon.js
  30330. */
  30331. export class Material implements IAnimatable {
  30332. /**
  30333. * Returns the triangle fill mode
  30334. */
  30335. static readonly TriangleFillMode: number;
  30336. /**
  30337. * Returns the wireframe mode
  30338. */
  30339. static readonly WireFrameFillMode: number;
  30340. /**
  30341. * Returns the point fill mode
  30342. */
  30343. static readonly PointFillMode: number;
  30344. /**
  30345. * Returns the point list draw mode
  30346. */
  30347. static readonly PointListDrawMode: number;
  30348. /**
  30349. * Returns the line list draw mode
  30350. */
  30351. static readonly LineListDrawMode: number;
  30352. /**
  30353. * Returns the line loop draw mode
  30354. */
  30355. static readonly LineLoopDrawMode: number;
  30356. /**
  30357. * Returns the line strip draw mode
  30358. */
  30359. static readonly LineStripDrawMode: number;
  30360. /**
  30361. * Returns the triangle strip draw mode
  30362. */
  30363. static readonly TriangleStripDrawMode: number;
  30364. /**
  30365. * Returns the triangle fan draw mode
  30366. */
  30367. static readonly TriangleFanDrawMode: number;
  30368. /**
  30369. * Stores the clock-wise side orientation
  30370. */
  30371. static readonly ClockWiseSideOrientation: number;
  30372. /**
  30373. * Stores the counter clock-wise side orientation
  30374. */
  30375. static readonly CounterClockWiseSideOrientation: number;
  30376. /**
  30377. * The dirty texture flag value
  30378. */
  30379. static readonly TextureDirtyFlag: number;
  30380. /**
  30381. * The dirty light flag value
  30382. */
  30383. static readonly LightDirtyFlag: number;
  30384. /**
  30385. * The dirty fresnel flag value
  30386. */
  30387. static readonly FresnelDirtyFlag: number;
  30388. /**
  30389. * The dirty attribute flag value
  30390. */
  30391. static readonly AttributesDirtyFlag: number;
  30392. /**
  30393. * The dirty misc flag value
  30394. */
  30395. static readonly MiscDirtyFlag: number;
  30396. /**
  30397. * The dirty prepass flag value
  30398. */
  30399. static readonly PrePassDirtyFlag: number;
  30400. /**
  30401. * The all dirty flag value
  30402. */
  30403. static readonly AllDirtyFlag: number;
  30404. /**
  30405. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30406. */
  30407. static readonly MATERIAL_OPAQUE: number;
  30408. /**
  30409. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30410. */
  30411. static readonly MATERIAL_ALPHATEST: number;
  30412. /**
  30413. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30414. */
  30415. static readonly MATERIAL_ALPHABLEND: number;
  30416. /**
  30417. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30418. * They are also discarded below the alpha cutoff threshold to improve performances.
  30419. */
  30420. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30421. /**
  30422. * The Whiteout method is used to blend normals.
  30423. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30424. */
  30425. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30426. /**
  30427. * The Reoriented Normal Mapping method is used to blend normals.
  30428. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30429. */
  30430. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30431. /**
  30432. * Custom callback helping to override the default shader used in the material.
  30433. */
  30434. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30435. /**
  30436. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30437. */
  30438. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30439. /**
  30440. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30441. * This means that the material can keep using a previous shader while a new one is being compiled.
  30442. * This is mostly used when shader parallel compilation is supported (true by default)
  30443. */
  30444. allowShaderHotSwapping: boolean;
  30445. /**
  30446. * The ID of the material
  30447. */
  30448. id: string;
  30449. /**
  30450. * Gets or sets the unique id of the material
  30451. */
  30452. uniqueId: number;
  30453. /**
  30454. * The name of the material
  30455. */
  30456. name: string;
  30457. /**
  30458. * Gets or sets user defined metadata
  30459. */
  30460. metadata: any;
  30461. /**
  30462. * For internal use only. Please do not use.
  30463. */
  30464. reservedDataStore: any;
  30465. /**
  30466. * Specifies if the ready state should be checked on each call
  30467. */
  30468. checkReadyOnEveryCall: boolean;
  30469. /**
  30470. * Specifies if the ready state should be checked once
  30471. */
  30472. checkReadyOnlyOnce: boolean;
  30473. /**
  30474. * The state of the material
  30475. */
  30476. state: string;
  30477. /**
  30478. * If the material can be rendered to several textures with MRT extension
  30479. */
  30480. get canRenderToMRT(): boolean;
  30481. /**
  30482. * The alpha value of the material
  30483. */
  30484. protected _alpha: number;
  30485. /**
  30486. * List of inspectable custom properties (used by the Inspector)
  30487. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30488. */
  30489. inspectableCustomProperties: IInspectable[];
  30490. /**
  30491. * Sets the alpha value of the material
  30492. */
  30493. set alpha(value: number);
  30494. /**
  30495. * Gets the alpha value of the material
  30496. */
  30497. get alpha(): number;
  30498. /**
  30499. * Specifies if back face culling is enabled
  30500. */
  30501. protected _backFaceCulling: boolean;
  30502. /**
  30503. * Sets the back-face culling state
  30504. */
  30505. set backFaceCulling(value: boolean);
  30506. /**
  30507. * Gets the back-face culling state
  30508. */
  30509. get backFaceCulling(): boolean;
  30510. /**
  30511. * Stores the value for side orientation
  30512. */
  30513. sideOrientation: number;
  30514. /**
  30515. * Callback triggered when the material is compiled
  30516. */
  30517. onCompiled: Nullable<(effect: Effect) => void>;
  30518. /**
  30519. * Callback triggered when an error occurs
  30520. */
  30521. onError: Nullable<(effect: Effect, errors: string) => void>;
  30522. /**
  30523. * Callback triggered to get the render target textures
  30524. */
  30525. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30526. /**
  30527. * Gets a boolean indicating that current material needs to register RTT
  30528. */
  30529. get hasRenderTargetTextures(): boolean;
  30530. /**
  30531. * Specifies if the material should be serialized
  30532. */
  30533. doNotSerialize: boolean;
  30534. /**
  30535. * @hidden
  30536. */
  30537. _storeEffectOnSubMeshes: boolean;
  30538. /**
  30539. * Stores the animations for the material
  30540. */
  30541. animations: Nullable<Array<Animation>>;
  30542. /**
  30543. * An event triggered when the material is disposed
  30544. */
  30545. onDisposeObservable: Observable<Material>;
  30546. /**
  30547. * An observer which watches for dispose events
  30548. */
  30549. private _onDisposeObserver;
  30550. private _onUnBindObservable;
  30551. /**
  30552. * Called during a dispose event
  30553. */
  30554. set onDispose(callback: () => void);
  30555. private _onBindObservable;
  30556. /**
  30557. * An event triggered when the material is bound
  30558. */
  30559. get onBindObservable(): Observable<AbstractMesh>;
  30560. /**
  30561. * An observer which watches for bind events
  30562. */
  30563. private _onBindObserver;
  30564. /**
  30565. * Called during a bind event
  30566. */
  30567. set onBind(callback: (Mesh: AbstractMesh) => void);
  30568. /**
  30569. * An event triggered when the material is unbound
  30570. */
  30571. get onUnBindObservable(): Observable<Material>;
  30572. protected _onEffectCreatedObservable: Nullable<Observable<{
  30573. effect: Effect;
  30574. subMesh: Nullable<SubMesh>;
  30575. }>>;
  30576. /**
  30577. * An event triggered when the effect is (re)created
  30578. */
  30579. get onEffectCreatedObservable(): Observable<{
  30580. effect: Effect;
  30581. subMesh: Nullable<SubMesh>;
  30582. }>;
  30583. /**
  30584. * Stores the value of the alpha mode
  30585. */
  30586. private _alphaMode;
  30587. /**
  30588. * Sets the value of the alpha mode.
  30589. *
  30590. * | Value | Type | Description |
  30591. * | --- | --- | --- |
  30592. * | 0 | ALPHA_DISABLE | |
  30593. * | 1 | ALPHA_ADD | |
  30594. * | 2 | ALPHA_COMBINE | |
  30595. * | 3 | ALPHA_SUBTRACT | |
  30596. * | 4 | ALPHA_MULTIPLY | |
  30597. * | 5 | ALPHA_MAXIMIZED | |
  30598. * | 6 | ALPHA_ONEONE | |
  30599. * | 7 | ALPHA_PREMULTIPLIED | |
  30600. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30601. * | 9 | ALPHA_INTERPOLATE | |
  30602. * | 10 | ALPHA_SCREENMODE | |
  30603. *
  30604. */
  30605. set alphaMode(value: number);
  30606. /**
  30607. * Gets the value of the alpha mode
  30608. */
  30609. get alphaMode(): number;
  30610. /**
  30611. * Stores the state of the need depth pre-pass value
  30612. */
  30613. private _needDepthPrePass;
  30614. /**
  30615. * Sets the need depth pre-pass value
  30616. */
  30617. set needDepthPrePass(value: boolean);
  30618. /**
  30619. * Gets the depth pre-pass value
  30620. */
  30621. get needDepthPrePass(): boolean;
  30622. /**
  30623. * Can this material render to prepass
  30624. */
  30625. get isPrePassCapable(): boolean;
  30626. /**
  30627. * Specifies if depth writing should be disabled
  30628. */
  30629. disableDepthWrite: boolean;
  30630. /**
  30631. * Specifies if color writing should be disabled
  30632. */
  30633. disableColorWrite: boolean;
  30634. /**
  30635. * Specifies if depth writing should be forced
  30636. */
  30637. forceDepthWrite: boolean;
  30638. /**
  30639. * Specifies the depth function that should be used. 0 means the default engine function
  30640. */
  30641. depthFunction: number;
  30642. /**
  30643. * Specifies if there should be a separate pass for culling
  30644. */
  30645. separateCullingPass: boolean;
  30646. /**
  30647. * Stores the state specifying if fog should be enabled
  30648. */
  30649. private _fogEnabled;
  30650. /**
  30651. * Sets the state for enabling fog
  30652. */
  30653. set fogEnabled(value: boolean);
  30654. /**
  30655. * Gets the value of the fog enabled state
  30656. */
  30657. get fogEnabled(): boolean;
  30658. /**
  30659. * Stores the size of points
  30660. */
  30661. pointSize: number;
  30662. /**
  30663. * Stores the z offset value
  30664. */
  30665. zOffset: number;
  30666. get wireframe(): boolean;
  30667. /**
  30668. * Sets the state of wireframe mode
  30669. */
  30670. set wireframe(value: boolean);
  30671. /**
  30672. * Gets the value specifying if point clouds are enabled
  30673. */
  30674. get pointsCloud(): boolean;
  30675. /**
  30676. * Sets the state of point cloud mode
  30677. */
  30678. set pointsCloud(value: boolean);
  30679. /**
  30680. * Gets the material fill mode
  30681. */
  30682. get fillMode(): number;
  30683. /**
  30684. * Sets the material fill mode
  30685. */
  30686. set fillMode(value: number);
  30687. /**
  30688. * @hidden
  30689. * Stores the effects for the material
  30690. */
  30691. _effect: Nullable<Effect>;
  30692. /**
  30693. * Specifies if uniform buffers should be used
  30694. */
  30695. private _useUBO;
  30696. /**
  30697. * Stores a reference to the scene
  30698. */
  30699. private _scene;
  30700. private _needToBindSceneUbo;
  30701. /**
  30702. * Stores the fill mode state
  30703. */
  30704. private _fillMode;
  30705. /**
  30706. * Specifies if the depth write state should be cached
  30707. */
  30708. private _cachedDepthWriteState;
  30709. /**
  30710. * Specifies if the color write state should be cached
  30711. */
  30712. private _cachedColorWriteState;
  30713. /**
  30714. * Specifies if the depth function state should be cached
  30715. */
  30716. private _cachedDepthFunctionState;
  30717. /**
  30718. * Stores the uniform buffer
  30719. */
  30720. protected _uniformBuffer: UniformBuffer;
  30721. /** @hidden */
  30722. _indexInSceneMaterialArray: number;
  30723. /** @hidden */
  30724. meshMap: Nullable<{
  30725. [id: string]: AbstractMesh | undefined;
  30726. }>;
  30727. /**
  30728. * Creates a material instance
  30729. * @param name defines the name of the material
  30730. * @param scene defines the scene to reference
  30731. * @param doNotAdd specifies if the material should be added to the scene
  30732. */
  30733. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30734. /**
  30735. * Returns a string representation of the current material
  30736. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30737. * @returns a string with material information
  30738. */
  30739. toString(fullDetails?: boolean): string;
  30740. /**
  30741. * Gets the class name of the material
  30742. * @returns a string with the class name of the material
  30743. */
  30744. getClassName(): string;
  30745. /**
  30746. * Specifies if updates for the material been locked
  30747. */
  30748. get isFrozen(): boolean;
  30749. /**
  30750. * Locks updates for the material
  30751. */
  30752. freeze(): void;
  30753. /**
  30754. * Unlocks updates for the material
  30755. */
  30756. unfreeze(): void;
  30757. /**
  30758. * Specifies if the material is ready to be used
  30759. * @param mesh defines the mesh to check
  30760. * @param useInstances specifies if instances should be used
  30761. * @returns a boolean indicating if the material is ready to be used
  30762. */
  30763. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30764. /**
  30765. * Specifies that the submesh is ready to be used
  30766. * @param mesh defines the mesh to check
  30767. * @param subMesh defines which submesh to check
  30768. * @param useInstances specifies that instances should be used
  30769. * @returns a boolean indicating that the submesh is ready or not
  30770. */
  30771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30772. /**
  30773. * Returns the material effect
  30774. * @returns the effect associated with the material
  30775. */
  30776. getEffect(): Nullable<Effect>;
  30777. /**
  30778. * Returns the current scene
  30779. * @returns a Scene
  30780. */
  30781. getScene(): Scene;
  30782. /**
  30783. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30784. */
  30785. protected _forceAlphaTest: boolean;
  30786. /**
  30787. * The transparency mode of the material.
  30788. */
  30789. protected _transparencyMode: Nullable<number>;
  30790. /**
  30791. * Gets the current transparency mode.
  30792. */
  30793. get transparencyMode(): Nullable<number>;
  30794. /**
  30795. * Sets the transparency mode of the material.
  30796. *
  30797. * | Value | Type | Description |
  30798. * | ----- | ----------------------------------- | ----------- |
  30799. * | 0 | OPAQUE | |
  30800. * | 1 | ALPHATEST | |
  30801. * | 2 | ALPHABLEND | |
  30802. * | 3 | ALPHATESTANDBLEND | |
  30803. *
  30804. */
  30805. set transparencyMode(value: Nullable<number>);
  30806. /**
  30807. * Returns true if alpha blending should be disabled.
  30808. */
  30809. protected get _disableAlphaBlending(): boolean;
  30810. /**
  30811. * Specifies whether or not this material should be rendered in alpha blend mode.
  30812. * @returns a boolean specifying if alpha blending is needed
  30813. */
  30814. needAlphaBlending(): boolean;
  30815. /**
  30816. * Specifies if the mesh will require alpha blending
  30817. * @param mesh defines the mesh to check
  30818. * @returns a boolean specifying if alpha blending is needed for the mesh
  30819. */
  30820. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30821. /**
  30822. * Specifies whether or not this material should be rendered in alpha test mode.
  30823. * @returns a boolean specifying if an alpha test is needed.
  30824. */
  30825. needAlphaTesting(): boolean;
  30826. /**
  30827. * Specifies if material alpha testing should be turned on for the mesh
  30828. * @param mesh defines the mesh to check
  30829. */
  30830. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30831. /**
  30832. * Gets the texture used for the alpha test
  30833. * @returns the texture to use for alpha testing
  30834. */
  30835. getAlphaTestTexture(): Nullable<BaseTexture>;
  30836. /**
  30837. * Marks the material to indicate that it needs to be re-calculated
  30838. */
  30839. markDirty(): void;
  30840. /** @hidden */
  30841. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30842. /**
  30843. * Binds the material to the mesh
  30844. * @param world defines the world transformation matrix
  30845. * @param mesh defines the mesh to bind the material to
  30846. */
  30847. bind(world: Matrix, mesh?: Mesh): void;
  30848. /**
  30849. * Binds the submesh to the material
  30850. * @param world defines the world transformation matrix
  30851. * @param mesh defines the mesh containing the submesh
  30852. * @param subMesh defines the submesh to bind the material to
  30853. */
  30854. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30855. /**
  30856. * Binds the world matrix to the material
  30857. * @param world defines the world transformation matrix
  30858. */
  30859. bindOnlyWorldMatrix(world: Matrix): void;
  30860. /**
  30861. * Binds the view matrix to the effect
  30862. * @param effect defines the effect to bind the view matrix to
  30863. */
  30864. bindView(effect: Effect): void;
  30865. /**
  30866. * Binds the view projection and projection matrices to the effect
  30867. * @param effect defines the effect to bind the view projection and projection matrices to
  30868. */
  30869. bindViewProjection(effect: Effect): void;
  30870. /**
  30871. * Binds the view matrix to the effect
  30872. * @param effect defines the effect to bind the view matrix to
  30873. * @param variableName name of the shader variable that will hold the eye position
  30874. */
  30875. bindEyePosition(effect: Effect, variableName?: string): void;
  30876. /**
  30877. * Processes to execute after binding the material to a mesh
  30878. * @param mesh defines the rendered mesh
  30879. */
  30880. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30881. /**
  30882. * Unbinds the material from the mesh
  30883. */
  30884. unbind(): void;
  30885. /**
  30886. * Gets the active textures from the material
  30887. * @returns an array of textures
  30888. */
  30889. getActiveTextures(): BaseTexture[];
  30890. /**
  30891. * Specifies if the material uses a texture
  30892. * @param texture defines the texture to check against the material
  30893. * @returns a boolean specifying if the material uses the texture
  30894. */
  30895. hasTexture(texture: BaseTexture): boolean;
  30896. /**
  30897. * Makes a duplicate of the material, and gives it a new name
  30898. * @param name defines the new name for the duplicated material
  30899. * @returns the cloned material
  30900. */
  30901. clone(name: string): Nullable<Material>;
  30902. /**
  30903. * Gets the meshes bound to the material
  30904. * @returns an array of meshes bound to the material
  30905. */
  30906. getBindedMeshes(): AbstractMesh[];
  30907. /**
  30908. * Force shader compilation
  30909. * @param mesh defines the mesh associated with this material
  30910. * @param onCompiled defines a function to execute once the material is compiled
  30911. * @param options defines the options to configure the compilation
  30912. * @param onError defines a function to execute if the material fails compiling
  30913. */
  30914. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30915. /**
  30916. * Force shader compilation
  30917. * @param mesh defines the mesh that will use this material
  30918. * @param options defines additional options for compiling the shaders
  30919. * @returns a promise that resolves when the compilation completes
  30920. */
  30921. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30922. private static readonly _AllDirtyCallBack;
  30923. private static readonly _ImageProcessingDirtyCallBack;
  30924. private static readonly _TextureDirtyCallBack;
  30925. private static readonly _FresnelDirtyCallBack;
  30926. private static readonly _MiscDirtyCallBack;
  30927. private static readonly _PrePassDirtyCallBack;
  30928. private static readonly _LightsDirtyCallBack;
  30929. private static readonly _AttributeDirtyCallBack;
  30930. private static _FresnelAndMiscDirtyCallBack;
  30931. private static _TextureAndMiscDirtyCallBack;
  30932. private static readonly _DirtyCallbackArray;
  30933. private static readonly _RunDirtyCallBacks;
  30934. /**
  30935. * Marks a define in the material to indicate that it needs to be re-computed
  30936. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30937. */
  30938. markAsDirty(flag: number): void;
  30939. /**
  30940. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30941. * @param func defines a function which checks material defines against the submeshes
  30942. */
  30943. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30944. /**
  30945. * Indicates that the scene should check if the rendering now needs a prepass
  30946. */
  30947. protected _markScenePrePassDirty(): void;
  30948. /**
  30949. * Indicates that we need to re-calculated for all submeshes
  30950. */
  30951. protected _markAllSubMeshesAsAllDirty(): void;
  30952. /**
  30953. * Indicates that image processing needs to be re-calculated for all submeshes
  30954. */
  30955. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30956. /**
  30957. * Indicates that textures need to be re-calculated for all submeshes
  30958. */
  30959. protected _markAllSubMeshesAsTexturesDirty(): void;
  30960. /**
  30961. * Indicates that fresnel needs to be re-calculated for all submeshes
  30962. */
  30963. protected _markAllSubMeshesAsFresnelDirty(): void;
  30964. /**
  30965. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30966. */
  30967. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30968. /**
  30969. * Indicates that lights need to be re-calculated for all submeshes
  30970. */
  30971. protected _markAllSubMeshesAsLightsDirty(): void;
  30972. /**
  30973. * Indicates that attributes need to be re-calculated for all submeshes
  30974. */
  30975. protected _markAllSubMeshesAsAttributesDirty(): void;
  30976. /**
  30977. * Indicates that misc needs to be re-calculated for all submeshes
  30978. */
  30979. protected _markAllSubMeshesAsMiscDirty(): void;
  30980. /**
  30981. * Indicates that prepass needs to be re-calculated for all submeshes
  30982. */
  30983. protected _markAllSubMeshesAsPrePassDirty(): void;
  30984. /**
  30985. * Indicates that textures and misc need to be re-calculated for all submeshes
  30986. */
  30987. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30988. /**
  30989. * Sets the required values to the prepass renderer.
  30990. * @param prePassRenderer defines the prepass renderer to setup.
  30991. * @returns true if the pre pass is needed.
  30992. */
  30993. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30994. /**
  30995. * Disposes the material
  30996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30999. */
  31000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31001. /** @hidden */
  31002. private releaseVertexArrayObject;
  31003. /**
  31004. * Serializes this material
  31005. * @returns the serialized material object
  31006. */
  31007. serialize(): any;
  31008. /**
  31009. * Creates a material from parsed material data
  31010. * @param parsedMaterial defines parsed material data
  31011. * @param scene defines the hosting scene
  31012. * @param rootUrl defines the root URL to use to load textures
  31013. * @returns a new material
  31014. */
  31015. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31021. * separate meshes. This can be use to improve performances.
  31022. * @see https://doc.babylonjs.com/how_to/multi_materials
  31023. */
  31024. export class MultiMaterial extends Material {
  31025. private _subMaterials;
  31026. /**
  31027. * Gets or Sets the list of Materials used within the multi material.
  31028. * They need to be ordered according to the submeshes order in the associated mesh
  31029. */
  31030. get subMaterials(): Nullable<Material>[];
  31031. set subMaterials(value: Nullable<Material>[]);
  31032. /**
  31033. * Function used to align with Node.getChildren()
  31034. * @returns the list of Materials used within the multi material
  31035. */
  31036. getChildren(): Nullable<Material>[];
  31037. /**
  31038. * Instantiates a new Multi Material
  31039. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31040. * separate meshes. This can be use to improve performances.
  31041. * @see https://doc.babylonjs.com/how_to/multi_materials
  31042. * @param name Define the name in the scene
  31043. * @param scene Define the scene the material belongs to
  31044. */
  31045. constructor(name: string, scene: Scene);
  31046. private _hookArray;
  31047. /**
  31048. * Get one of the submaterial by its index in the submaterials array
  31049. * @param index The index to look the sub material at
  31050. * @returns The Material if the index has been defined
  31051. */
  31052. getSubMaterial(index: number): Nullable<Material>;
  31053. /**
  31054. * Get the list of active textures for the whole sub materials list.
  31055. * @returns All the textures that will be used during the rendering
  31056. */
  31057. getActiveTextures(): BaseTexture[];
  31058. /**
  31059. * Specifies if any sub-materials of this multi-material use a given texture.
  31060. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31061. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31062. */
  31063. hasTexture(texture: BaseTexture): boolean;
  31064. /**
  31065. * Gets the current class name of the material e.g. "MultiMaterial"
  31066. * Mainly use in serialization.
  31067. * @returns the class name
  31068. */
  31069. getClassName(): string;
  31070. /**
  31071. * Checks if the material is ready to render the requested sub mesh
  31072. * @param mesh Define the mesh the submesh belongs to
  31073. * @param subMesh Define the sub mesh to look readiness for
  31074. * @param useInstances Define whether or not the material is used with instances
  31075. * @returns true if ready, otherwise false
  31076. */
  31077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31078. /**
  31079. * Clones the current material and its related sub materials
  31080. * @param name Define the name of the newly cloned material
  31081. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31082. * @returns the cloned material
  31083. */
  31084. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31085. /**
  31086. * Serializes the materials into a JSON representation.
  31087. * @returns the JSON representation
  31088. */
  31089. serialize(): any;
  31090. /**
  31091. * Dispose the material and release its associated resources
  31092. * @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)
  31093. * @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)
  31094. * @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)
  31095. */
  31096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31097. /**
  31098. * Creates a MultiMaterial from parsed MultiMaterial data.
  31099. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31100. * @param scene defines the hosting scene
  31101. * @returns a new MultiMaterial
  31102. */
  31103. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31104. }
  31105. }
  31106. declare module BABYLON {
  31107. /** @hidden */
  31108. export interface ICustomEffect {
  31109. effect: Effect;
  31110. defines: string;
  31111. }
  31112. /**
  31113. * Defines a subdivision inside a mesh
  31114. */
  31115. export class SubMesh implements ICullable {
  31116. /** the material index to use */
  31117. materialIndex: number;
  31118. /** vertex index start */
  31119. verticesStart: number;
  31120. /** vertices count */
  31121. verticesCount: number;
  31122. /** index start */
  31123. indexStart: number;
  31124. /** indices count */
  31125. indexCount: number;
  31126. /** @hidden */
  31127. _materialDefines: Nullable<MaterialDefines>;
  31128. /** @hidden */
  31129. _materialEffect: Nullable<Effect>;
  31130. /** @hidden */
  31131. _effectOverride: Nullable<Effect>;
  31132. private _customEffects;
  31133. /**
  31134. * Gets material defines used by the effect associated to the sub mesh
  31135. */
  31136. get materialDefines(): Nullable<MaterialDefines>;
  31137. /**
  31138. * Sets material defines used by the effect associated to the sub mesh
  31139. */
  31140. set materialDefines(defines: Nullable<MaterialDefines>);
  31141. /** @hidden */
  31142. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31143. /** @hidden */
  31144. _removeCustomEffect(name: string): void;
  31145. /**
  31146. * Gets associated effect
  31147. */
  31148. get effect(): Nullable<Effect>;
  31149. /**
  31150. * Sets associated effect (effect used to render this submesh)
  31151. * @param effect defines the effect to associate with
  31152. * @param defines defines the set of defines used to compile this effect
  31153. */
  31154. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31155. /** @hidden */
  31156. _linesIndexCount: number;
  31157. private _mesh;
  31158. private _renderingMesh;
  31159. private _boundingInfo;
  31160. private _linesIndexBuffer;
  31161. /** @hidden */
  31162. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31163. /** @hidden */
  31164. _trianglePlanes: Plane[];
  31165. /** @hidden */
  31166. _lastColliderTransformMatrix: Nullable<Matrix>;
  31167. /** @hidden */
  31168. _renderId: number;
  31169. /** @hidden */
  31170. _alphaIndex: number;
  31171. /** @hidden */
  31172. _distanceToCamera: number;
  31173. /** @hidden */
  31174. _id: number;
  31175. private _currentMaterial;
  31176. /**
  31177. * Add a new submesh to a mesh
  31178. * @param materialIndex defines the material index to use
  31179. * @param verticesStart defines vertex index start
  31180. * @param verticesCount defines vertices count
  31181. * @param indexStart defines index start
  31182. * @param indexCount defines indices count
  31183. * @param mesh defines the parent mesh
  31184. * @param renderingMesh defines an optional rendering mesh
  31185. * @param createBoundingBox defines if bounding box should be created for this submesh
  31186. * @returns the new submesh
  31187. */
  31188. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31189. /**
  31190. * Creates a new submesh
  31191. * @param materialIndex defines the material index to use
  31192. * @param verticesStart defines vertex index start
  31193. * @param verticesCount defines vertices count
  31194. * @param indexStart defines index start
  31195. * @param indexCount defines indices count
  31196. * @param mesh defines the parent mesh
  31197. * @param renderingMesh defines an optional rendering mesh
  31198. * @param createBoundingBox defines if bounding box should be created for this submesh
  31199. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31200. */
  31201. constructor(
  31202. /** the material index to use */
  31203. materialIndex: number,
  31204. /** vertex index start */
  31205. verticesStart: number,
  31206. /** vertices count */
  31207. verticesCount: number,
  31208. /** index start */
  31209. indexStart: number,
  31210. /** indices count */
  31211. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31212. /**
  31213. * Returns true if this submesh covers the entire parent mesh
  31214. * @ignorenaming
  31215. */
  31216. get IsGlobal(): boolean;
  31217. /**
  31218. * Returns the submesh BoundingInfo object
  31219. * @returns current bounding info (or mesh's one if the submesh is global)
  31220. */
  31221. getBoundingInfo(): BoundingInfo;
  31222. /**
  31223. * Sets the submesh BoundingInfo
  31224. * @param boundingInfo defines the new bounding info to use
  31225. * @returns the SubMesh
  31226. */
  31227. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31228. /**
  31229. * Returns the mesh of the current submesh
  31230. * @return the parent mesh
  31231. */
  31232. getMesh(): AbstractMesh;
  31233. /**
  31234. * Returns the rendering mesh of the submesh
  31235. * @returns the rendering mesh (could be different from parent mesh)
  31236. */
  31237. getRenderingMesh(): Mesh;
  31238. /**
  31239. * Returns the replacement mesh of the submesh
  31240. * @returns the replacement mesh (could be different from parent mesh)
  31241. */
  31242. getReplacementMesh(): Nullable<AbstractMesh>;
  31243. /**
  31244. * Returns the effective mesh of the submesh
  31245. * @returns the effective mesh (could be different from parent mesh)
  31246. */
  31247. getEffectiveMesh(): AbstractMesh;
  31248. /**
  31249. * Returns the submesh material
  31250. * @returns null or the current material
  31251. */
  31252. getMaterial(): Nullable<Material>;
  31253. private _IsMultiMaterial;
  31254. /**
  31255. * Sets a new updated BoundingInfo object to the submesh
  31256. * @param data defines an optional position array to use to determine the bounding info
  31257. * @returns the SubMesh
  31258. */
  31259. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31260. /** @hidden */
  31261. _checkCollision(collider: Collider): boolean;
  31262. /**
  31263. * Updates the submesh BoundingInfo
  31264. * @param world defines the world matrix to use to update the bounding info
  31265. * @returns the submesh
  31266. */
  31267. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31268. /**
  31269. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31270. * @param frustumPlanes defines the frustum planes
  31271. * @returns true if the submesh is intersecting with the frustum
  31272. */
  31273. isInFrustum(frustumPlanes: Plane[]): boolean;
  31274. /**
  31275. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31276. * @param frustumPlanes defines the frustum planes
  31277. * @returns true if the submesh is inside the frustum
  31278. */
  31279. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31280. /**
  31281. * Renders the submesh
  31282. * @param enableAlphaMode defines if alpha needs to be used
  31283. * @returns the submesh
  31284. */
  31285. render(enableAlphaMode: boolean): SubMesh;
  31286. /**
  31287. * @hidden
  31288. */
  31289. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31290. /**
  31291. * Checks if the submesh intersects with a ray
  31292. * @param ray defines the ray to test
  31293. * @returns true is the passed ray intersects the submesh bounding box
  31294. */
  31295. canIntersects(ray: Ray): boolean;
  31296. /**
  31297. * Intersects current submesh with a ray
  31298. * @param ray defines the ray to test
  31299. * @param positions defines mesh's positions array
  31300. * @param indices defines mesh's indices array
  31301. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31302. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31303. * @returns intersection info or null if no intersection
  31304. */
  31305. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31306. /** @hidden */
  31307. private _intersectLines;
  31308. /** @hidden */
  31309. private _intersectUnIndexedLines;
  31310. /** @hidden */
  31311. private _intersectTriangles;
  31312. /** @hidden */
  31313. private _intersectUnIndexedTriangles;
  31314. /** @hidden */
  31315. _rebuild(): void;
  31316. /**
  31317. * Creates a new submesh from the passed mesh
  31318. * @param newMesh defines the new hosting mesh
  31319. * @param newRenderingMesh defines an optional rendering mesh
  31320. * @returns the new submesh
  31321. */
  31322. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31323. /**
  31324. * Release associated resources
  31325. */
  31326. dispose(): void;
  31327. /**
  31328. * Gets the class name
  31329. * @returns the string "SubMesh".
  31330. */
  31331. getClassName(): string;
  31332. /**
  31333. * Creates a new submesh from indices data
  31334. * @param materialIndex the index of the main mesh material
  31335. * @param startIndex the index where to start the copy in the mesh indices array
  31336. * @param indexCount the number of indices to copy then from the startIndex
  31337. * @param mesh the main mesh to create the submesh from
  31338. * @param renderingMesh the optional rendering mesh
  31339. * @returns a new submesh
  31340. */
  31341. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31342. }
  31343. }
  31344. declare module BABYLON {
  31345. /**
  31346. * Class used to represent data loading progression
  31347. */
  31348. export class SceneLoaderFlags {
  31349. private static _ForceFullSceneLoadingForIncremental;
  31350. private static _ShowLoadingScreen;
  31351. private static _CleanBoneMatrixWeights;
  31352. private static _loggingLevel;
  31353. /**
  31354. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31355. */
  31356. static get ForceFullSceneLoadingForIncremental(): boolean;
  31357. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31358. /**
  31359. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31360. */
  31361. static get ShowLoadingScreen(): boolean;
  31362. static set ShowLoadingScreen(value: boolean);
  31363. /**
  31364. * Defines the current logging level (while loading the scene)
  31365. * @ignorenaming
  31366. */
  31367. static get loggingLevel(): number;
  31368. static set loggingLevel(value: number);
  31369. /**
  31370. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31371. */
  31372. static get CleanBoneMatrixWeights(): boolean;
  31373. static set CleanBoneMatrixWeights(value: boolean);
  31374. }
  31375. }
  31376. declare module BABYLON {
  31377. /**
  31378. * Class used to store geometry data (vertex buffers + index buffer)
  31379. */
  31380. export class Geometry implements IGetSetVerticesData {
  31381. /**
  31382. * Gets or sets the ID of the geometry
  31383. */
  31384. id: string;
  31385. /**
  31386. * Gets or sets the unique ID of the geometry
  31387. */
  31388. uniqueId: number;
  31389. /**
  31390. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31391. */
  31392. delayLoadState: number;
  31393. /**
  31394. * Gets the file containing the data to load when running in delay load state
  31395. */
  31396. delayLoadingFile: Nullable<string>;
  31397. /**
  31398. * Callback called when the geometry is updated
  31399. */
  31400. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31401. private _scene;
  31402. private _engine;
  31403. private _meshes;
  31404. private _totalVertices;
  31405. /** @hidden */
  31406. _indices: IndicesArray;
  31407. /** @hidden */
  31408. _vertexBuffers: {
  31409. [key: string]: VertexBuffer;
  31410. };
  31411. private _isDisposed;
  31412. private _extend;
  31413. private _boundingBias;
  31414. /** @hidden */
  31415. _delayInfo: Array<string>;
  31416. private _indexBuffer;
  31417. private _indexBufferIsUpdatable;
  31418. /** @hidden */
  31419. _boundingInfo: Nullable<BoundingInfo>;
  31420. /** @hidden */
  31421. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31422. /** @hidden */
  31423. _softwareSkinningFrameId: number;
  31424. private _vertexArrayObjects;
  31425. private _updatable;
  31426. /** @hidden */
  31427. _positions: Nullable<Vector3[]>;
  31428. private _positionsCache;
  31429. /**
  31430. * 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
  31431. */
  31432. get boundingBias(): Vector2;
  31433. /**
  31434. * 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
  31435. */
  31436. set boundingBias(value: Vector2);
  31437. /**
  31438. * Static function used to attach a new empty geometry to a mesh
  31439. * @param mesh defines the mesh to attach the geometry to
  31440. * @returns the new Geometry
  31441. */
  31442. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31443. /** Get the list of meshes using this geometry */
  31444. get meshes(): Mesh[];
  31445. /**
  31446. * 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
  31447. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31448. */
  31449. useBoundingInfoFromGeometry: boolean;
  31450. /**
  31451. * Creates a new geometry
  31452. * @param id defines the unique ID
  31453. * @param scene defines the hosting scene
  31454. * @param vertexData defines the VertexData used to get geometry data
  31455. * @param updatable defines if geometry must be updatable (false by default)
  31456. * @param mesh defines the mesh that will be associated with the geometry
  31457. */
  31458. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31459. /**
  31460. * Gets the current extend of the geometry
  31461. */
  31462. get extend(): {
  31463. minimum: Vector3;
  31464. maximum: Vector3;
  31465. };
  31466. /**
  31467. * Gets the hosting scene
  31468. * @returns the hosting Scene
  31469. */
  31470. getScene(): Scene;
  31471. /**
  31472. * Gets the hosting engine
  31473. * @returns the hosting Engine
  31474. */
  31475. getEngine(): Engine;
  31476. /**
  31477. * Defines if the geometry is ready to use
  31478. * @returns true if the geometry is ready to be used
  31479. */
  31480. isReady(): boolean;
  31481. /**
  31482. * Gets a value indicating that the geometry should not be serialized
  31483. */
  31484. get doNotSerialize(): boolean;
  31485. /** @hidden */
  31486. _rebuild(): void;
  31487. /**
  31488. * Affects all geometry data in one call
  31489. * @param vertexData defines the geometry data
  31490. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31491. */
  31492. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31493. /**
  31494. * Set specific vertex data
  31495. * @param kind defines the data kind (Position, normal, etc...)
  31496. * @param data defines the vertex data to use
  31497. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31498. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31499. */
  31500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31501. /**
  31502. * Removes a specific vertex data
  31503. * @param kind defines the data kind (Position, normal, etc...)
  31504. */
  31505. removeVerticesData(kind: string): void;
  31506. /**
  31507. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31508. * @param buffer defines the vertex buffer to use
  31509. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31510. */
  31511. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31512. /**
  31513. * Update a specific vertex buffer
  31514. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31515. * It will do nothing if the buffer is not updatable
  31516. * @param kind defines the data kind (Position, normal, etc...)
  31517. * @param data defines the data to use
  31518. * @param offset defines the offset in the target buffer where to store the data
  31519. * @param useBytes set to true if the offset is in bytes
  31520. */
  31521. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31522. /**
  31523. * Update a specific vertex buffer
  31524. * This function will create a new buffer if the current one is not updatable
  31525. * @param kind defines the data kind (Position, normal, etc...)
  31526. * @param data defines the data to use
  31527. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31528. */
  31529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31530. private _updateBoundingInfo;
  31531. /** @hidden */
  31532. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31533. [kind: string]: Nullable<VertexBuffer>;
  31534. }, overrideVertexArrayObjects?: {
  31535. [key: string]: WebGLVertexArrayObject;
  31536. }): void;
  31537. /**
  31538. * Gets total number of vertices
  31539. * @returns the total number of vertices
  31540. */
  31541. getTotalVertices(): number;
  31542. /**
  31543. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31544. * @param kind defines the data kind (Position, normal, etc...)
  31545. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31546. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31547. * @returns a float array containing vertex data
  31548. */
  31549. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31550. /**
  31551. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31552. * @param kind defines the data kind (Position, normal, etc...)
  31553. * @returns true if the vertex buffer with the specified kind is updatable
  31554. */
  31555. isVertexBufferUpdatable(kind: string): boolean;
  31556. /**
  31557. * Gets a specific vertex buffer
  31558. * @param kind defines the data kind (Position, normal, etc...)
  31559. * @returns a VertexBuffer
  31560. */
  31561. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31562. /**
  31563. * Returns all vertex buffers
  31564. * @return an object holding all vertex buffers indexed by kind
  31565. */
  31566. getVertexBuffers(): Nullable<{
  31567. [key: string]: VertexBuffer;
  31568. }>;
  31569. /**
  31570. * Gets a boolean indicating if specific vertex buffer is present
  31571. * @param kind defines the data kind (Position, normal, etc...)
  31572. * @returns true if data is present
  31573. */
  31574. isVerticesDataPresent(kind: string): boolean;
  31575. /**
  31576. * Gets a list of all attached data kinds (Position, normal, etc...)
  31577. * @returns a list of string containing all kinds
  31578. */
  31579. getVerticesDataKinds(): string[];
  31580. /**
  31581. * Update index buffer
  31582. * @param indices defines the indices to store in the index buffer
  31583. * @param offset defines the offset in the target buffer where to store the data
  31584. * @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)
  31585. */
  31586. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31587. /**
  31588. * Creates a new index buffer
  31589. * @param indices defines the indices to store in the index buffer
  31590. * @param totalVertices defines the total number of vertices (could be null)
  31591. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31592. */
  31593. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31594. /**
  31595. * Return the total number of indices
  31596. * @returns the total number of indices
  31597. */
  31598. getTotalIndices(): number;
  31599. /**
  31600. * Gets the index buffer array
  31601. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31602. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31603. * @returns the index buffer array
  31604. */
  31605. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31606. /**
  31607. * Gets the index buffer
  31608. * @return the index buffer
  31609. */
  31610. getIndexBuffer(): Nullable<DataBuffer>;
  31611. /** @hidden */
  31612. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31613. /**
  31614. * Release the associated resources for a specific mesh
  31615. * @param mesh defines the source mesh
  31616. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31617. */
  31618. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31619. /**
  31620. * Apply current geometry to a given mesh
  31621. * @param mesh defines the mesh to apply geometry to
  31622. */
  31623. applyToMesh(mesh: Mesh): void;
  31624. private _updateExtend;
  31625. private _applyToMesh;
  31626. private notifyUpdate;
  31627. /**
  31628. * Load the geometry if it was flagged as delay loaded
  31629. * @param scene defines the hosting scene
  31630. * @param onLoaded defines a callback called when the geometry is loaded
  31631. */
  31632. load(scene: Scene, onLoaded?: () => void): void;
  31633. private _queueLoad;
  31634. /**
  31635. * Invert the geometry to move from a right handed system to a left handed one.
  31636. */
  31637. toLeftHanded(): void;
  31638. /** @hidden */
  31639. _resetPointsArrayCache(): void;
  31640. /** @hidden */
  31641. _generatePointsArray(): boolean;
  31642. /**
  31643. * Gets a value indicating if the geometry is disposed
  31644. * @returns true if the geometry was disposed
  31645. */
  31646. isDisposed(): boolean;
  31647. private _disposeVertexArrayObjects;
  31648. /**
  31649. * Free all associated resources
  31650. */
  31651. dispose(): void;
  31652. /**
  31653. * Clone the current geometry into a new geometry
  31654. * @param id defines the unique ID of the new geometry
  31655. * @returns a new geometry object
  31656. */
  31657. copy(id: string): Geometry;
  31658. /**
  31659. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31660. * @return a JSON representation of the current geometry data (without the vertices data)
  31661. */
  31662. serialize(): any;
  31663. private toNumberArray;
  31664. /**
  31665. * Serialize all vertices data into a JSON object
  31666. * @returns a JSON representation of the current geometry data
  31667. */
  31668. serializeVerticeData(): any;
  31669. /**
  31670. * Extracts a clone of a mesh geometry
  31671. * @param mesh defines the source mesh
  31672. * @param id defines the unique ID of the new geometry object
  31673. * @returns the new geometry object
  31674. */
  31675. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31676. /**
  31677. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31678. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31679. * Be aware Math.random() could cause collisions, but:
  31680. * "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"
  31681. * @returns a string containing a new GUID
  31682. */
  31683. static RandomId(): string;
  31684. /** @hidden */
  31685. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31686. private static _CleanMatricesWeights;
  31687. /**
  31688. * Create a new geometry from persisted data (Using .babylon file format)
  31689. * @param parsedVertexData defines the persisted data
  31690. * @param scene defines the hosting scene
  31691. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31692. * @returns the new geometry object
  31693. */
  31694. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31695. }
  31696. }
  31697. declare module BABYLON {
  31698. /**
  31699. * Defines a target to use with MorphTargetManager
  31700. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31701. */
  31702. export class MorphTarget implements IAnimatable {
  31703. /** defines the name of the target */
  31704. name: string;
  31705. /**
  31706. * Gets or sets the list of animations
  31707. */
  31708. animations: Animation[];
  31709. private _scene;
  31710. private _positions;
  31711. private _normals;
  31712. private _tangents;
  31713. private _uvs;
  31714. private _influence;
  31715. private _uniqueId;
  31716. /**
  31717. * Observable raised when the influence changes
  31718. */
  31719. onInfluenceChanged: Observable<boolean>;
  31720. /** @hidden */
  31721. _onDataLayoutChanged: Observable<void>;
  31722. /**
  31723. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31724. */
  31725. get influence(): number;
  31726. set influence(influence: number);
  31727. /**
  31728. * Gets or sets the id of the morph Target
  31729. */
  31730. id: string;
  31731. private _animationPropertiesOverride;
  31732. /**
  31733. * Gets or sets the animation properties override
  31734. */
  31735. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31736. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31737. /**
  31738. * Creates a new MorphTarget
  31739. * @param name defines the name of the target
  31740. * @param influence defines the influence to use
  31741. * @param scene defines the scene the morphtarget belongs to
  31742. */
  31743. constructor(
  31744. /** defines the name of the target */
  31745. name: string, influence?: number, scene?: Nullable<Scene>);
  31746. /**
  31747. * Gets the unique ID of this manager
  31748. */
  31749. get uniqueId(): number;
  31750. /**
  31751. * Gets a boolean defining if the target contains position data
  31752. */
  31753. get hasPositions(): boolean;
  31754. /**
  31755. * Gets a boolean defining if the target contains normal data
  31756. */
  31757. get hasNormals(): boolean;
  31758. /**
  31759. * Gets a boolean defining if the target contains tangent data
  31760. */
  31761. get hasTangents(): boolean;
  31762. /**
  31763. * Gets a boolean defining if the target contains texture coordinates data
  31764. */
  31765. get hasUVs(): boolean;
  31766. /**
  31767. * Affects position data to this target
  31768. * @param data defines the position data to use
  31769. */
  31770. setPositions(data: Nullable<FloatArray>): void;
  31771. /**
  31772. * Gets the position data stored in this target
  31773. * @returns a FloatArray containing the position data (or null if not present)
  31774. */
  31775. getPositions(): Nullable<FloatArray>;
  31776. /**
  31777. * Affects normal data to this target
  31778. * @param data defines the normal data to use
  31779. */
  31780. setNormals(data: Nullable<FloatArray>): void;
  31781. /**
  31782. * Gets the normal data stored in this target
  31783. * @returns a FloatArray containing the normal data (or null if not present)
  31784. */
  31785. getNormals(): Nullable<FloatArray>;
  31786. /**
  31787. * Affects tangent data to this target
  31788. * @param data defines the tangent data to use
  31789. */
  31790. setTangents(data: Nullable<FloatArray>): void;
  31791. /**
  31792. * Gets the tangent data stored in this target
  31793. * @returns a FloatArray containing the tangent data (or null if not present)
  31794. */
  31795. getTangents(): Nullable<FloatArray>;
  31796. /**
  31797. * Affects texture coordinates data to this target
  31798. * @param data defines the texture coordinates data to use
  31799. */
  31800. setUVs(data: Nullable<FloatArray>): void;
  31801. /**
  31802. * Gets the texture coordinates data stored in this target
  31803. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31804. */
  31805. getUVs(): Nullable<FloatArray>;
  31806. /**
  31807. * Clone the current target
  31808. * @returns a new MorphTarget
  31809. */
  31810. clone(): MorphTarget;
  31811. /**
  31812. * Serializes the current target into a Serialization object
  31813. * @returns the serialized object
  31814. */
  31815. serialize(): any;
  31816. /**
  31817. * Returns the string "MorphTarget"
  31818. * @returns "MorphTarget"
  31819. */
  31820. getClassName(): string;
  31821. /**
  31822. * Creates a new target from serialized data
  31823. * @param serializationObject defines the serialized data to use
  31824. * @returns a new MorphTarget
  31825. */
  31826. static Parse(serializationObject: any): MorphTarget;
  31827. /**
  31828. * Creates a MorphTarget from mesh data
  31829. * @param mesh defines the source mesh
  31830. * @param name defines the name to use for the new target
  31831. * @param influence defines the influence to attach to the target
  31832. * @returns a new MorphTarget
  31833. */
  31834. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31835. }
  31836. }
  31837. declare module BABYLON {
  31838. /**
  31839. * This class is used to deform meshes using morphing between different targets
  31840. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31841. */
  31842. export class MorphTargetManager {
  31843. private _targets;
  31844. private _targetInfluenceChangedObservers;
  31845. private _targetDataLayoutChangedObservers;
  31846. private _activeTargets;
  31847. private _scene;
  31848. private _influences;
  31849. private _supportsNormals;
  31850. private _supportsTangents;
  31851. private _supportsUVs;
  31852. private _vertexCount;
  31853. private _uniqueId;
  31854. private _tempInfluences;
  31855. /**
  31856. * Gets or sets a boolean indicating if normals must be morphed
  31857. */
  31858. enableNormalMorphing: boolean;
  31859. /**
  31860. * Gets or sets a boolean indicating if tangents must be morphed
  31861. */
  31862. enableTangentMorphing: boolean;
  31863. /**
  31864. * Gets or sets a boolean indicating if UV must be morphed
  31865. */
  31866. enableUVMorphing: boolean;
  31867. /**
  31868. * Creates a new MorphTargetManager
  31869. * @param scene defines the current scene
  31870. */
  31871. constructor(scene?: Nullable<Scene>);
  31872. /**
  31873. * Gets the unique ID of this manager
  31874. */
  31875. get uniqueId(): number;
  31876. /**
  31877. * Gets the number of vertices handled by this manager
  31878. */
  31879. get vertexCount(): number;
  31880. /**
  31881. * Gets a boolean indicating if this manager supports morphing of normals
  31882. */
  31883. get supportsNormals(): boolean;
  31884. /**
  31885. * Gets a boolean indicating if this manager supports morphing of tangents
  31886. */
  31887. get supportsTangents(): boolean;
  31888. /**
  31889. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31890. */
  31891. get supportsUVs(): boolean;
  31892. /**
  31893. * Gets the number of targets stored in this manager
  31894. */
  31895. get numTargets(): number;
  31896. /**
  31897. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31898. */
  31899. get numInfluencers(): number;
  31900. /**
  31901. * Gets the list of influences (one per target)
  31902. */
  31903. get influences(): Float32Array;
  31904. /**
  31905. * Gets the active target at specified index. An active target is a target with an influence > 0
  31906. * @param index defines the index to check
  31907. * @returns the requested target
  31908. */
  31909. getActiveTarget(index: number): MorphTarget;
  31910. /**
  31911. * Gets the target at specified index
  31912. * @param index defines the index to check
  31913. * @returns the requested target
  31914. */
  31915. getTarget(index: number): MorphTarget;
  31916. /**
  31917. * Add a new target to this manager
  31918. * @param target defines the target to add
  31919. */
  31920. addTarget(target: MorphTarget): void;
  31921. /**
  31922. * Removes a target from the manager
  31923. * @param target defines the target to remove
  31924. */
  31925. removeTarget(target: MorphTarget): void;
  31926. /**
  31927. * Clone the current manager
  31928. * @returns a new MorphTargetManager
  31929. */
  31930. clone(): MorphTargetManager;
  31931. /**
  31932. * Serializes the current manager into a Serialization object
  31933. * @returns the serialized object
  31934. */
  31935. serialize(): any;
  31936. private _syncActiveTargets;
  31937. /**
  31938. * Syncrhonize the targets with all the meshes using this morph target manager
  31939. */
  31940. synchronize(): void;
  31941. /**
  31942. * Creates a new MorphTargetManager from serialized data
  31943. * @param serializationObject defines the serialized data
  31944. * @param scene defines the hosting scene
  31945. * @returns the new MorphTargetManager
  31946. */
  31947. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31948. }
  31949. }
  31950. declare module BABYLON {
  31951. /**
  31952. * Class used to represent a specific level of detail of a mesh
  31953. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31954. */
  31955. export class MeshLODLevel {
  31956. /** Defines the distance where this level should start being displayed */
  31957. distance: number;
  31958. /** Defines the mesh to use to render this level */
  31959. mesh: Nullable<Mesh>;
  31960. /**
  31961. * Creates a new LOD level
  31962. * @param distance defines the distance where this level should star being displayed
  31963. * @param mesh defines the mesh to use to render this level
  31964. */
  31965. constructor(
  31966. /** Defines the distance where this level should start being displayed */
  31967. distance: number,
  31968. /** Defines the mesh to use to render this level */
  31969. mesh: Nullable<Mesh>);
  31970. }
  31971. }
  31972. declare module BABYLON {
  31973. /**
  31974. * Helper class used to generate a canvas to manipulate images
  31975. */
  31976. export class CanvasGenerator {
  31977. /**
  31978. * Create a new canvas (or offscreen canvas depending on the context)
  31979. * @param width defines the expected width
  31980. * @param height defines the expected height
  31981. * @return a new canvas or offscreen canvas
  31982. */
  31983. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31984. }
  31985. }
  31986. declare module BABYLON {
  31987. /**
  31988. * Mesh representing the ground
  31989. */
  31990. export class GroundMesh extends Mesh {
  31991. /** If octree should be generated */
  31992. generateOctree: boolean;
  31993. private _heightQuads;
  31994. /** @hidden */
  31995. _subdivisionsX: number;
  31996. /** @hidden */
  31997. _subdivisionsY: number;
  31998. /** @hidden */
  31999. _width: number;
  32000. /** @hidden */
  32001. _height: number;
  32002. /** @hidden */
  32003. _minX: number;
  32004. /** @hidden */
  32005. _maxX: number;
  32006. /** @hidden */
  32007. _minZ: number;
  32008. /** @hidden */
  32009. _maxZ: number;
  32010. constructor(name: string, scene: Scene);
  32011. /**
  32012. * "GroundMesh"
  32013. * @returns "GroundMesh"
  32014. */
  32015. getClassName(): string;
  32016. /**
  32017. * The minimum of x and y subdivisions
  32018. */
  32019. get subdivisions(): number;
  32020. /**
  32021. * X subdivisions
  32022. */
  32023. get subdivisionsX(): number;
  32024. /**
  32025. * Y subdivisions
  32026. */
  32027. get subdivisionsY(): number;
  32028. /**
  32029. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32030. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32031. * @param chunksCount the number of subdivisions for x and y
  32032. * @param octreeBlocksSize (Default: 32)
  32033. */
  32034. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32035. /**
  32036. * Returns a height (y) value in the World system :
  32037. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32038. * @param x x coordinate
  32039. * @param z z coordinate
  32040. * @returns the ground y position if (x, z) are outside the ground surface.
  32041. */
  32042. getHeightAtCoordinates(x: number, z: number): number;
  32043. /**
  32044. * Returns a normalized vector (Vector3) orthogonal to the ground
  32045. * at the ground coordinates (x, z) expressed in the World system.
  32046. * @param x x coordinate
  32047. * @param z z coordinate
  32048. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32049. */
  32050. getNormalAtCoordinates(x: number, z: number): Vector3;
  32051. /**
  32052. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32053. * at the ground coordinates (x, z) expressed in the World system.
  32054. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32055. * @param x x coordinate
  32056. * @param z z coordinate
  32057. * @param ref vector to store the result
  32058. * @returns the GroundMesh.
  32059. */
  32060. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32061. /**
  32062. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32063. * if the ground has been updated.
  32064. * This can be used in the render loop.
  32065. * @returns the GroundMesh.
  32066. */
  32067. updateCoordinateHeights(): GroundMesh;
  32068. private _getFacetAt;
  32069. private _initHeightQuads;
  32070. private _computeHeightQuads;
  32071. /**
  32072. * Serializes this ground mesh
  32073. * @param serializationObject object to write serialization to
  32074. */
  32075. serialize(serializationObject: any): void;
  32076. /**
  32077. * Parses a serialized ground mesh
  32078. * @param parsedMesh the serialized mesh
  32079. * @param scene the scene to create the ground mesh in
  32080. * @returns the created ground mesh
  32081. */
  32082. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32083. }
  32084. }
  32085. declare module BABYLON {
  32086. /**
  32087. * Interface for Physics-Joint data
  32088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32089. */
  32090. export interface PhysicsJointData {
  32091. /**
  32092. * The main pivot of the joint
  32093. */
  32094. mainPivot?: Vector3;
  32095. /**
  32096. * The connected pivot of the joint
  32097. */
  32098. connectedPivot?: Vector3;
  32099. /**
  32100. * The main axis of the joint
  32101. */
  32102. mainAxis?: Vector3;
  32103. /**
  32104. * The connected axis of the joint
  32105. */
  32106. connectedAxis?: Vector3;
  32107. /**
  32108. * The collision of the joint
  32109. */
  32110. collision?: boolean;
  32111. /**
  32112. * Native Oimo/Cannon/Energy data
  32113. */
  32114. nativeParams?: any;
  32115. }
  32116. /**
  32117. * This is a holder class for the physics joint created by the physics plugin
  32118. * It holds a set of functions to control the underlying joint
  32119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32120. */
  32121. export class PhysicsJoint {
  32122. /**
  32123. * The type of the physics joint
  32124. */
  32125. type: number;
  32126. /**
  32127. * The data for the physics joint
  32128. */
  32129. jointData: PhysicsJointData;
  32130. private _physicsJoint;
  32131. protected _physicsPlugin: IPhysicsEnginePlugin;
  32132. /**
  32133. * Initializes the physics joint
  32134. * @param type The type of the physics joint
  32135. * @param jointData The data for the physics joint
  32136. */
  32137. constructor(
  32138. /**
  32139. * The type of the physics joint
  32140. */
  32141. type: number,
  32142. /**
  32143. * The data for the physics joint
  32144. */
  32145. jointData: PhysicsJointData);
  32146. /**
  32147. * Gets the physics joint
  32148. */
  32149. get physicsJoint(): any;
  32150. /**
  32151. * Sets the physics joint
  32152. */
  32153. set physicsJoint(newJoint: any);
  32154. /**
  32155. * Sets the physics plugin
  32156. */
  32157. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32158. /**
  32159. * Execute a function that is physics-plugin specific.
  32160. * @param {Function} func the function that will be executed.
  32161. * It accepts two parameters: the physics world and the physics joint
  32162. */
  32163. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32164. /**
  32165. * Distance-Joint type
  32166. */
  32167. static DistanceJoint: number;
  32168. /**
  32169. * Hinge-Joint type
  32170. */
  32171. static HingeJoint: number;
  32172. /**
  32173. * Ball-and-Socket joint type
  32174. */
  32175. static BallAndSocketJoint: number;
  32176. /**
  32177. * Wheel-Joint type
  32178. */
  32179. static WheelJoint: number;
  32180. /**
  32181. * Slider-Joint type
  32182. */
  32183. static SliderJoint: number;
  32184. /**
  32185. * Prismatic-Joint type
  32186. */
  32187. static PrismaticJoint: number;
  32188. /**
  32189. * Universal-Joint type
  32190. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32191. */
  32192. static UniversalJoint: number;
  32193. /**
  32194. * Hinge-Joint 2 type
  32195. */
  32196. static Hinge2Joint: number;
  32197. /**
  32198. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32199. */
  32200. static PointToPointJoint: number;
  32201. /**
  32202. * Spring-Joint type
  32203. */
  32204. static SpringJoint: number;
  32205. /**
  32206. * Lock-Joint type
  32207. */
  32208. static LockJoint: number;
  32209. }
  32210. /**
  32211. * A class representing a physics distance joint
  32212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32213. */
  32214. export class DistanceJoint extends PhysicsJoint {
  32215. /**
  32216. *
  32217. * @param jointData The data for the Distance-Joint
  32218. */
  32219. constructor(jointData: DistanceJointData);
  32220. /**
  32221. * Update the predefined distance.
  32222. * @param maxDistance The maximum preferred distance
  32223. * @param minDistance The minimum preferred distance
  32224. */
  32225. updateDistance(maxDistance: number, minDistance?: number): void;
  32226. }
  32227. /**
  32228. * Represents a Motor-Enabled Joint
  32229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32230. */
  32231. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32232. /**
  32233. * Initializes the Motor-Enabled Joint
  32234. * @param type The type of the joint
  32235. * @param jointData The physical joint data for the joint
  32236. */
  32237. constructor(type: number, jointData: PhysicsJointData);
  32238. /**
  32239. * Set the motor values.
  32240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32241. * @param force the force to apply
  32242. * @param maxForce max force for this motor.
  32243. */
  32244. setMotor(force?: number, maxForce?: number): void;
  32245. /**
  32246. * Set the motor's limits.
  32247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32248. * @param upperLimit The upper limit of the motor
  32249. * @param lowerLimit The lower limit of the motor
  32250. */
  32251. setLimit(upperLimit: number, lowerLimit?: number): void;
  32252. }
  32253. /**
  32254. * This class represents a single physics Hinge-Joint
  32255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32256. */
  32257. export class HingeJoint extends MotorEnabledJoint {
  32258. /**
  32259. * Initializes the Hinge-Joint
  32260. * @param jointData The joint data for the Hinge-Joint
  32261. */
  32262. constructor(jointData: PhysicsJointData);
  32263. /**
  32264. * Set the motor values.
  32265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32266. * @param {number} force the force to apply
  32267. * @param {number} maxForce max force for this motor.
  32268. */
  32269. setMotor(force?: number, maxForce?: number): void;
  32270. /**
  32271. * Set the motor's limits.
  32272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32273. * @param upperLimit The upper limit of the motor
  32274. * @param lowerLimit The lower limit of the motor
  32275. */
  32276. setLimit(upperLimit: number, lowerLimit?: number): void;
  32277. }
  32278. /**
  32279. * This class represents a dual hinge physics joint (same as wheel joint)
  32280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32281. */
  32282. export class Hinge2Joint extends MotorEnabledJoint {
  32283. /**
  32284. * Initializes the Hinge2-Joint
  32285. * @param jointData The joint data for the Hinge2-Joint
  32286. */
  32287. constructor(jointData: PhysicsJointData);
  32288. /**
  32289. * Set the motor values.
  32290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32291. * @param {number} targetSpeed the speed the motor is to reach
  32292. * @param {number} maxForce max force for this motor.
  32293. * @param {motorIndex} the motor's index, 0 or 1.
  32294. */
  32295. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32296. /**
  32297. * Set the motor limits.
  32298. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32299. * @param {number} upperLimit the upper limit
  32300. * @param {number} lowerLimit lower limit
  32301. * @param {motorIndex} the motor's index, 0 or 1.
  32302. */
  32303. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32304. }
  32305. /**
  32306. * Interface for a motor enabled joint
  32307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32308. */
  32309. export interface IMotorEnabledJoint {
  32310. /**
  32311. * Physics joint
  32312. */
  32313. physicsJoint: any;
  32314. /**
  32315. * Sets the motor of the motor-enabled joint
  32316. * @param force The force of the motor
  32317. * @param maxForce The maximum force of the motor
  32318. * @param motorIndex The index of the motor
  32319. */
  32320. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32321. /**
  32322. * Sets the limit of the motor
  32323. * @param upperLimit The upper limit of the motor
  32324. * @param lowerLimit The lower limit of the motor
  32325. * @param motorIndex The index of the motor
  32326. */
  32327. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32328. }
  32329. /**
  32330. * Joint data for a Distance-Joint
  32331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32332. */
  32333. export interface DistanceJointData extends PhysicsJointData {
  32334. /**
  32335. * Max distance the 2 joint objects can be apart
  32336. */
  32337. maxDistance: number;
  32338. }
  32339. /**
  32340. * Joint data from a spring joint
  32341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32342. */
  32343. export interface SpringJointData extends PhysicsJointData {
  32344. /**
  32345. * Length of the spring
  32346. */
  32347. length: number;
  32348. /**
  32349. * Stiffness of the spring
  32350. */
  32351. stiffness: number;
  32352. /**
  32353. * Damping of the spring
  32354. */
  32355. damping: number;
  32356. /** this callback will be called when applying the force to the impostors. */
  32357. forceApplicationCallback: () => void;
  32358. }
  32359. }
  32360. declare module BABYLON {
  32361. /**
  32362. * Holds the data for the raycast result
  32363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32364. */
  32365. export class PhysicsRaycastResult {
  32366. private _hasHit;
  32367. private _hitDistance;
  32368. private _hitNormalWorld;
  32369. private _hitPointWorld;
  32370. private _rayFromWorld;
  32371. private _rayToWorld;
  32372. /**
  32373. * Gets if there was a hit
  32374. */
  32375. get hasHit(): boolean;
  32376. /**
  32377. * Gets the distance from the hit
  32378. */
  32379. get hitDistance(): number;
  32380. /**
  32381. * Gets the hit normal/direction in the world
  32382. */
  32383. get hitNormalWorld(): Vector3;
  32384. /**
  32385. * Gets the hit point in the world
  32386. */
  32387. get hitPointWorld(): Vector3;
  32388. /**
  32389. * Gets the ray "start point" of the ray in the world
  32390. */
  32391. get rayFromWorld(): Vector3;
  32392. /**
  32393. * Gets the ray "end point" of the ray in the world
  32394. */
  32395. get rayToWorld(): Vector3;
  32396. /**
  32397. * Sets the hit data (normal & point in world space)
  32398. * @param hitNormalWorld defines the normal in world space
  32399. * @param hitPointWorld defines the point in world space
  32400. */
  32401. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32402. /**
  32403. * Sets the distance from the start point to the hit point
  32404. * @param distance
  32405. */
  32406. setHitDistance(distance: number): void;
  32407. /**
  32408. * Calculates the distance manually
  32409. */
  32410. calculateHitDistance(): void;
  32411. /**
  32412. * Resets all the values to default
  32413. * @param from The from point on world space
  32414. * @param to The to point on world space
  32415. */
  32416. reset(from?: Vector3, to?: Vector3): void;
  32417. }
  32418. /**
  32419. * Interface for the size containing width and height
  32420. */
  32421. interface IXYZ {
  32422. /**
  32423. * X
  32424. */
  32425. x: number;
  32426. /**
  32427. * Y
  32428. */
  32429. y: number;
  32430. /**
  32431. * Z
  32432. */
  32433. z: number;
  32434. }
  32435. }
  32436. declare module BABYLON {
  32437. /**
  32438. * Interface used to describe a physics joint
  32439. */
  32440. export interface PhysicsImpostorJoint {
  32441. /** Defines the main impostor to which the joint is linked */
  32442. mainImpostor: PhysicsImpostor;
  32443. /** Defines the impostor that is connected to the main impostor using this joint */
  32444. connectedImpostor: PhysicsImpostor;
  32445. /** Defines the joint itself */
  32446. joint: PhysicsJoint;
  32447. }
  32448. /** @hidden */
  32449. export interface IPhysicsEnginePlugin {
  32450. world: any;
  32451. name: string;
  32452. setGravity(gravity: Vector3): void;
  32453. setTimeStep(timeStep: number): void;
  32454. getTimeStep(): number;
  32455. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32456. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32457. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32458. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32459. removePhysicsBody(impostor: PhysicsImpostor): void;
  32460. generateJoint(joint: PhysicsImpostorJoint): void;
  32461. removeJoint(joint: PhysicsImpostorJoint): void;
  32462. isSupported(): boolean;
  32463. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32464. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32465. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32466. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32467. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32468. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32469. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32470. getBodyMass(impostor: PhysicsImpostor): number;
  32471. getBodyFriction(impostor: PhysicsImpostor): number;
  32472. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32473. getBodyRestitution(impostor: PhysicsImpostor): number;
  32474. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32475. getBodyPressure?(impostor: PhysicsImpostor): number;
  32476. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32477. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32478. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32479. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32480. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32481. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32482. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32483. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32484. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32485. sleepBody(impostor: PhysicsImpostor): void;
  32486. wakeUpBody(impostor: PhysicsImpostor): void;
  32487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32488. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32489. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32490. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32491. getRadius(impostor: PhysicsImpostor): number;
  32492. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32493. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32494. dispose(): void;
  32495. }
  32496. /**
  32497. * Interface used to define a physics engine
  32498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32499. */
  32500. export interface IPhysicsEngine {
  32501. /**
  32502. * Gets the gravity vector used by the simulation
  32503. */
  32504. gravity: Vector3;
  32505. /**
  32506. * Sets the gravity vector used by the simulation
  32507. * @param gravity defines the gravity vector to use
  32508. */
  32509. setGravity(gravity: Vector3): void;
  32510. /**
  32511. * Set the time step of the physics engine.
  32512. * Default is 1/60.
  32513. * To slow it down, enter 1/600 for example.
  32514. * To speed it up, 1/30
  32515. * @param newTimeStep the new timestep to apply to this world.
  32516. */
  32517. setTimeStep(newTimeStep: number): void;
  32518. /**
  32519. * Get the time step of the physics engine.
  32520. * @returns the current time step
  32521. */
  32522. getTimeStep(): number;
  32523. /**
  32524. * Set the sub time step of the physics engine.
  32525. * Default is 0 meaning there is no sub steps
  32526. * To increase physics resolution precision, set a small value (like 1 ms)
  32527. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32528. */
  32529. setSubTimeStep(subTimeStep: number): void;
  32530. /**
  32531. * Get the sub time step of the physics engine.
  32532. * @returns the current sub time step
  32533. */
  32534. getSubTimeStep(): number;
  32535. /**
  32536. * Release all resources
  32537. */
  32538. dispose(): void;
  32539. /**
  32540. * Gets the name of the current physics plugin
  32541. * @returns the name of the plugin
  32542. */
  32543. getPhysicsPluginName(): string;
  32544. /**
  32545. * Adding a new impostor for the impostor tracking.
  32546. * This will be done by the impostor itself.
  32547. * @param impostor the impostor to add
  32548. */
  32549. addImpostor(impostor: PhysicsImpostor): void;
  32550. /**
  32551. * Remove an impostor from the engine.
  32552. * This impostor and its mesh will not longer be updated by the physics engine.
  32553. * @param impostor the impostor to remove
  32554. */
  32555. removeImpostor(impostor: PhysicsImpostor): void;
  32556. /**
  32557. * Add a joint to the physics engine
  32558. * @param mainImpostor defines the main impostor to which the joint is added.
  32559. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32560. * @param joint defines the joint that will connect both impostors.
  32561. */
  32562. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32563. /**
  32564. * Removes a joint from the simulation
  32565. * @param mainImpostor defines the impostor used with the joint
  32566. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32567. * @param joint defines the joint to remove
  32568. */
  32569. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32570. /**
  32571. * Gets the current plugin used to run the simulation
  32572. * @returns current plugin
  32573. */
  32574. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32575. /**
  32576. * Gets the list of physic impostors
  32577. * @returns an array of PhysicsImpostor
  32578. */
  32579. getImpostors(): Array<PhysicsImpostor>;
  32580. /**
  32581. * Gets the impostor for a physics enabled object
  32582. * @param object defines the object impersonated by the impostor
  32583. * @returns the PhysicsImpostor or null if not found
  32584. */
  32585. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32586. /**
  32587. * Gets the impostor for a physics body object
  32588. * @param body defines physics body used by the impostor
  32589. * @returns the PhysicsImpostor or null if not found
  32590. */
  32591. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32592. /**
  32593. * Does a raycast in the physics world
  32594. * @param from when should the ray start?
  32595. * @param to when should the ray end?
  32596. * @returns PhysicsRaycastResult
  32597. */
  32598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32599. /**
  32600. * Called by the scene. No need to call it.
  32601. * @param delta defines the timespan between frames
  32602. */
  32603. _step(delta: number): void;
  32604. }
  32605. }
  32606. declare module BABYLON {
  32607. /**
  32608. * The interface for the physics imposter parameters
  32609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32610. */
  32611. export interface PhysicsImpostorParameters {
  32612. /**
  32613. * The mass of the physics imposter
  32614. */
  32615. mass: number;
  32616. /**
  32617. * The friction of the physics imposter
  32618. */
  32619. friction?: number;
  32620. /**
  32621. * The coefficient of restitution of the physics imposter
  32622. */
  32623. restitution?: number;
  32624. /**
  32625. * The native options of the physics imposter
  32626. */
  32627. nativeOptions?: any;
  32628. /**
  32629. * Specifies if the parent should be ignored
  32630. */
  32631. ignoreParent?: boolean;
  32632. /**
  32633. * Specifies if bi-directional transformations should be disabled
  32634. */
  32635. disableBidirectionalTransformation?: boolean;
  32636. /**
  32637. * The pressure inside the physics imposter, soft object only
  32638. */
  32639. pressure?: number;
  32640. /**
  32641. * The stiffness the physics imposter, soft object only
  32642. */
  32643. stiffness?: number;
  32644. /**
  32645. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32646. */
  32647. velocityIterations?: number;
  32648. /**
  32649. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32650. */
  32651. positionIterations?: number;
  32652. /**
  32653. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32654. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32655. * Add to fix multiple points
  32656. */
  32657. fixedPoints?: number;
  32658. /**
  32659. * The collision margin around a soft object
  32660. */
  32661. margin?: number;
  32662. /**
  32663. * The collision margin around a soft object
  32664. */
  32665. damping?: number;
  32666. /**
  32667. * The path for a rope based on an extrusion
  32668. */
  32669. path?: any;
  32670. /**
  32671. * The shape of an extrusion used for a rope based on an extrusion
  32672. */
  32673. shape?: any;
  32674. }
  32675. /**
  32676. * Interface for a physics-enabled object
  32677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32678. */
  32679. export interface IPhysicsEnabledObject {
  32680. /**
  32681. * The position of the physics-enabled object
  32682. */
  32683. position: Vector3;
  32684. /**
  32685. * The rotation of the physics-enabled object
  32686. */
  32687. rotationQuaternion: Nullable<Quaternion>;
  32688. /**
  32689. * The scale of the physics-enabled object
  32690. */
  32691. scaling: Vector3;
  32692. /**
  32693. * The rotation of the physics-enabled object
  32694. */
  32695. rotation?: Vector3;
  32696. /**
  32697. * The parent of the physics-enabled object
  32698. */
  32699. parent?: any;
  32700. /**
  32701. * The bounding info of the physics-enabled object
  32702. * @returns The bounding info of the physics-enabled object
  32703. */
  32704. getBoundingInfo(): BoundingInfo;
  32705. /**
  32706. * Computes the world matrix
  32707. * @param force Specifies if the world matrix should be computed by force
  32708. * @returns A world matrix
  32709. */
  32710. computeWorldMatrix(force: boolean): Matrix;
  32711. /**
  32712. * Gets the world matrix
  32713. * @returns A world matrix
  32714. */
  32715. getWorldMatrix?(): Matrix;
  32716. /**
  32717. * Gets the child meshes
  32718. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32719. * @returns An array of abstract meshes
  32720. */
  32721. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32722. /**
  32723. * Gets the vertex data
  32724. * @param kind The type of vertex data
  32725. * @returns A nullable array of numbers, or a float32 array
  32726. */
  32727. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32728. /**
  32729. * Gets the indices from the mesh
  32730. * @returns A nullable array of index arrays
  32731. */
  32732. getIndices?(): Nullable<IndicesArray>;
  32733. /**
  32734. * Gets the scene from the mesh
  32735. * @returns the indices array or null
  32736. */
  32737. getScene?(): Scene;
  32738. /**
  32739. * Gets the absolute position from the mesh
  32740. * @returns the absolute position
  32741. */
  32742. getAbsolutePosition(): Vector3;
  32743. /**
  32744. * Gets the absolute pivot point from the mesh
  32745. * @returns the absolute pivot point
  32746. */
  32747. getAbsolutePivotPoint(): Vector3;
  32748. /**
  32749. * Rotates the mesh
  32750. * @param axis The axis of rotation
  32751. * @param amount The amount of rotation
  32752. * @param space The space of the rotation
  32753. * @returns The rotation transform node
  32754. */
  32755. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32756. /**
  32757. * Translates the mesh
  32758. * @param axis The axis of translation
  32759. * @param distance The distance of translation
  32760. * @param space The space of the translation
  32761. * @returns The transform node
  32762. */
  32763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32764. /**
  32765. * Sets the absolute position of the mesh
  32766. * @param absolutePosition The absolute position of the mesh
  32767. * @returns The transform node
  32768. */
  32769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32770. /**
  32771. * Gets the class name of the mesh
  32772. * @returns The class name
  32773. */
  32774. getClassName(): string;
  32775. }
  32776. /**
  32777. * Represents a physics imposter
  32778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32779. */
  32780. export class PhysicsImpostor {
  32781. /**
  32782. * The physics-enabled object used as the physics imposter
  32783. */
  32784. object: IPhysicsEnabledObject;
  32785. /**
  32786. * The type of the physics imposter
  32787. */
  32788. type: number;
  32789. private _options;
  32790. private _scene?;
  32791. /**
  32792. * The default object size of the imposter
  32793. */
  32794. static DEFAULT_OBJECT_SIZE: Vector3;
  32795. /**
  32796. * The identity quaternion of the imposter
  32797. */
  32798. static IDENTITY_QUATERNION: Quaternion;
  32799. /** @hidden */
  32800. _pluginData: any;
  32801. private _physicsEngine;
  32802. private _physicsBody;
  32803. private _bodyUpdateRequired;
  32804. private _onBeforePhysicsStepCallbacks;
  32805. private _onAfterPhysicsStepCallbacks;
  32806. /** @hidden */
  32807. _onPhysicsCollideCallbacks: Array<{
  32808. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32809. otherImpostors: Array<PhysicsImpostor>;
  32810. }>;
  32811. private _deltaPosition;
  32812. private _deltaRotation;
  32813. private _deltaRotationConjugated;
  32814. /** @hidden */
  32815. _isFromLine: boolean;
  32816. private _parent;
  32817. private _isDisposed;
  32818. private static _tmpVecs;
  32819. private static _tmpQuat;
  32820. /**
  32821. * Specifies if the physics imposter is disposed
  32822. */
  32823. get isDisposed(): boolean;
  32824. /**
  32825. * Gets the mass of the physics imposter
  32826. */
  32827. get mass(): number;
  32828. set mass(value: number);
  32829. /**
  32830. * Gets the coefficient of friction
  32831. */
  32832. get friction(): number;
  32833. /**
  32834. * Sets the coefficient of friction
  32835. */
  32836. set friction(value: number);
  32837. /**
  32838. * Gets the coefficient of restitution
  32839. */
  32840. get restitution(): number;
  32841. /**
  32842. * Sets the coefficient of restitution
  32843. */
  32844. set restitution(value: number);
  32845. /**
  32846. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32847. */
  32848. get pressure(): number;
  32849. /**
  32850. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32851. */
  32852. set pressure(value: number);
  32853. /**
  32854. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32855. */
  32856. get stiffness(): number;
  32857. /**
  32858. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32859. */
  32860. set stiffness(value: number);
  32861. /**
  32862. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32863. */
  32864. get velocityIterations(): number;
  32865. /**
  32866. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32867. */
  32868. set velocityIterations(value: number);
  32869. /**
  32870. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32871. */
  32872. get positionIterations(): number;
  32873. /**
  32874. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32875. */
  32876. set positionIterations(value: number);
  32877. /**
  32878. * The unique id of the physics imposter
  32879. * set by the physics engine when adding this impostor to the array
  32880. */
  32881. uniqueId: number;
  32882. /**
  32883. * @hidden
  32884. */
  32885. soft: boolean;
  32886. /**
  32887. * @hidden
  32888. */
  32889. segments: number;
  32890. private _joints;
  32891. /**
  32892. * Initializes the physics imposter
  32893. * @param object The physics-enabled object used as the physics imposter
  32894. * @param type The type of the physics imposter
  32895. * @param _options The options for the physics imposter
  32896. * @param _scene The Babylon scene
  32897. */
  32898. constructor(
  32899. /**
  32900. * The physics-enabled object used as the physics imposter
  32901. */
  32902. object: IPhysicsEnabledObject,
  32903. /**
  32904. * The type of the physics imposter
  32905. */
  32906. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32907. /**
  32908. * This function will completely initialize this impostor.
  32909. * It will create a new body - but only if this mesh has no parent.
  32910. * If it has, this impostor will not be used other than to define the impostor
  32911. * of the child mesh.
  32912. * @hidden
  32913. */
  32914. _init(): void;
  32915. private _getPhysicsParent;
  32916. /**
  32917. * Should a new body be generated.
  32918. * @returns boolean specifying if body initialization is required
  32919. */
  32920. isBodyInitRequired(): boolean;
  32921. /**
  32922. * Sets the updated scaling
  32923. * @param updated Specifies if the scaling is updated
  32924. */
  32925. setScalingUpdated(): void;
  32926. /**
  32927. * Force a regeneration of this or the parent's impostor's body.
  32928. * Use under cautious - This will remove all joints already implemented.
  32929. */
  32930. forceUpdate(): void;
  32931. /**
  32932. * Gets the body that holds this impostor. Either its own, or its parent.
  32933. */
  32934. get physicsBody(): any;
  32935. /**
  32936. * Get the parent of the physics imposter
  32937. * @returns Physics imposter or null
  32938. */
  32939. get parent(): Nullable<PhysicsImpostor>;
  32940. /**
  32941. * Sets the parent of the physics imposter
  32942. */
  32943. set parent(value: Nullable<PhysicsImpostor>);
  32944. /**
  32945. * Set the physics body. Used mainly by the physics engine/plugin
  32946. */
  32947. set physicsBody(physicsBody: any);
  32948. /**
  32949. * Resets the update flags
  32950. */
  32951. resetUpdateFlags(): void;
  32952. /**
  32953. * Gets the object extend size
  32954. * @returns the object extend size
  32955. */
  32956. getObjectExtendSize(): Vector3;
  32957. /**
  32958. * Gets the object center
  32959. * @returns The object center
  32960. */
  32961. getObjectCenter(): Vector3;
  32962. /**
  32963. * Get a specific parameter from the options parameters
  32964. * @param paramName The object parameter name
  32965. * @returns The object parameter
  32966. */
  32967. getParam(paramName: string): any;
  32968. /**
  32969. * Sets a specific parameter in the options given to the physics plugin
  32970. * @param paramName The parameter name
  32971. * @param value The value of the parameter
  32972. */
  32973. setParam(paramName: string, value: number): void;
  32974. /**
  32975. * Specifically change the body's mass option. Won't recreate the physics body object
  32976. * @param mass The mass of the physics imposter
  32977. */
  32978. setMass(mass: number): void;
  32979. /**
  32980. * Gets the linear velocity
  32981. * @returns linear velocity or null
  32982. */
  32983. getLinearVelocity(): Nullable<Vector3>;
  32984. /**
  32985. * Sets the linear velocity
  32986. * @param velocity linear velocity or null
  32987. */
  32988. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32989. /**
  32990. * Gets the angular velocity
  32991. * @returns angular velocity or null
  32992. */
  32993. getAngularVelocity(): Nullable<Vector3>;
  32994. /**
  32995. * Sets the angular velocity
  32996. * @param velocity The velocity or null
  32997. */
  32998. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32999. /**
  33000. * Execute a function with the physics plugin native code
  33001. * Provide a function the will have two variables - the world object and the physics body object
  33002. * @param func The function to execute with the physics plugin native code
  33003. */
  33004. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33005. /**
  33006. * Register a function that will be executed before the physics world is stepping forward
  33007. * @param func The function to execute before the physics world is stepped forward
  33008. */
  33009. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33010. /**
  33011. * Unregister a function that will be executed before the physics world is stepping forward
  33012. * @param func The function to execute before the physics world is stepped forward
  33013. */
  33014. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33015. /**
  33016. * Register a function that will be executed after the physics step
  33017. * @param func The function to execute after physics step
  33018. */
  33019. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33020. /**
  33021. * Unregisters a function that will be executed after the physics step
  33022. * @param func The function to execute after physics step
  33023. */
  33024. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33025. /**
  33026. * register a function that will be executed when this impostor collides against a different body
  33027. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33028. * @param func Callback that is executed on collision
  33029. */
  33030. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33031. /**
  33032. * Unregisters the physics imposter on contact
  33033. * @param collideAgainst The physics object to collide against
  33034. * @param func Callback to execute on collision
  33035. */
  33036. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33037. private _tmpQuat;
  33038. private _tmpQuat2;
  33039. /**
  33040. * Get the parent rotation
  33041. * @returns The parent rotation
  33042. */
  33043. getParentsRotation(): Quaternion;
  33044. /**
  33045. * this function is executed by the physics engine.
  33046. */
  33047. beforeStep: () => void;
  33048. /**
  33049. * this function is executed by the physics engine
  33050. */
  33051. afterStep: () => void;
  33052. /**
  33053. * Legacy collision detection event support
  33054. */
  33055. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33056. /**
  33057. * event and body object due to cannon's event-based architecture.
  33058. */
  33059. onCollide: (e: {
  33060. body: any;
  33061. point: Nullable<Vector3>;
  33062. }) => void;
  33063. /**
  33064. * Apply a force
  33065. * @param force The force to apply
  33066. * @param contactPoint The contact point for the force
  33067. * @returns The physics imposter
  33068. */
  33069. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33070. /**
  33071. * Apply an impulse
  33072. * @param force The impulse force
  33073. * @param contactPoint The contact point for the impulse force
  33074. * @returns The physics imposter
  33075. */
  33076. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33077. /**
  33078. * A help function to create a joint
  33079. * @param otherImpostor A physics imposter used to create a joint
  33080. * @param jointType The type of joint
  33081. * @param jointData The data for the joint
  33082. * @returns The physics imposter
  33083. */
  33084. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33085. /**
  33086. * Add a joint to this impostor with a different impostor
  33087. * @param otherImpostor A physics imposter used to add a joint
  33088. * @param joint The joint to add
  33089. * @returns The physics imposter
  33090. */
  33091. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33092. /**
  33093. * Add an anchor to a cloth impostor
  33094. * @param otherImpostor rigid impostor to anchor to
  33095. * @param width ratio across width from 0 to 1
  33096. * @param height ratio up height from 0 to 1
  33097. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33098. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33099. * @returns impostor the soft imposter
  33100. */
  33101. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33102. /**
  33103. * Add a hook to a rope impostor
  33104. * @param otherImpostor rigid impostor to anchor to
  33105. * @param length ratio across rope from 0 to 1
  33106. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33107. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33108. * @returns impostor the rope imposter
  33109. */
  33110. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33111. /**
  33112. * Will keep this body still, in a sleep mode.
  33113. * @returns the physics imposter
  33114. */
  33115. sleep(): PhysicsImpostor;
  33116. /**
  33117. * Wake the body up.
  33118. * @returns The physics imposter
  33119. */
  33120. wakeUp(): PhysicsImpostor;
  33121. /**
  33122. * Clones the physics imposter
  33123. * @param newObject The physics imposter clones to this physics-enabled object
  33124. * @returns A nullable physics imposter
  33125. */
  33126. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33127. /**
  33128. * Disposes the physics imposter
  33129. */
  33130. dispose(): void;
  33131. /**
  33132. * Sets the delta position
  33133. * @param position The delta position amount
  33134. */
  33135. setDeltaPosition(position: Vector3): void;
  33136. /**
  33137. * Sets the delta rotation
  33138. * @param rotation The delta rotation amount
  33139. */
  33140. setDeltaRotation(rotation: Quaternion): void;
  33141. /**
  33142. * Gets the box size of the physics imposter and stores the result in the input parameter
  33143. * @param result Stores the box size
  33144. * @returns The physics imposter
  33145. */
  33146. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33147. /**
  33148. * Gets the radius of the physics imposter
  33149. * @returns Radius of the physics imposter
  33150. */
  33151. getRadius(): number;
  33152. /**
  33153. * Sync a bone with this impostor
  33154. * @param bone The bone to sync to the impostor.
  33155. * @param boneMesh The mesh that the bone is influencing.
  33156. * @param jointPivot The pivot of the joint / bone in local space.
  33157. * @param distToJoint Optional distance from the impostor to the joint.
  33158. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33159. */
  33160. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33161. /**
  33162. * Sync impostor to a bone
  33163. * @param bone The bone that the impostor will be synced to.
  33164. * @param boneMesh The mesh that the bone is influencing.
  33165. * @param jointPivot The pivot of the joint / bone in local space.
  33166. * @param distToJoint Optional distance from the impostor to the joint.
  33167. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33168. * @param boneAxis Optional vector3 axis the bone is aligned with
  33169. */
  33170. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33171. /**
  33172. * No-Imposter type
  33173. */
  33174. static NoImpostor: number;
  33175. /**
  33176. * Sphere-Imposter type
  33177. */
  33178. static SphereImpostor: number;
  33179. /**
  33180. * Box-Imposter type
  33181. */
  33182. static BoxImpostor: number;
  33183. /**
  33184. * Plane-Imposter type
  33185. */
  33186. static PlaneImpostor: number;
  33187. /**
  33188. * Mesh-imposter type
  33189. */
  33190. static MeshImpostor: number;
  33191. /**
  33192. * Capsule-Impostor type (Ammo.js plugin only)
  33193. */
  33194. static CapsuleImpostor: number;
  33195. /**
  33196. * Cylinder-Imposter type
  33197. */
  33198. static CylinderImpostor: number;
  33199. /**
  33200. * Particle-Imposter type
  33201. */
  33202. static ParticleImpostor: number;
  33203. /**
  33204. * Heightmap-Imposter type
  33205. */
  33206. static HeightmapImpostor: number;
  33207. /**
  33208. * ConvexHull-Impostor type (Ammo.js plugin only)
  33209. */
  33210. static ConvexHullImpostor: number;
  33211. /**
  33212. * Custom-Imposter type (Ammo.js plugin only)
  33213. */
  33214. static CustomImpostor: number;
  33215. /**
  33216. * Rope-Imposter type
  33217. */
  33218. static RopeImpostor: number;
  33219. /**
  33220. * Cloth-Imposter type
  33221. */
  33222. static ClothImpostor: number;
  33223. /**
  33224. * Softbody-Imposter type
  33225. */
  33226. static SoftbodyImpostor: number;
  33227. }
  33228. }
  33229. declare module BABYLON {
  33230. /**
  33231. * @hidden
  33232. **/
  33233. export class _CreationDataStorage {
  33234. closePath?: boolean;
  33235. closeArray?: boolean;
  33236. idx: number[];
  33237. dashSize: number;
  33238. gapSize: number;
  33239. path3D: Path3D;
  33240. pathArray: Vector3[][];
  33241. arc: number;
  33242. radius: number;
  33243. cap: number;
  33244. tessellation: number;
  33245. }
  33246. /**
  33247. * @hidden
  33248. **/
  33249. class _InstanceDataStorage {
  33250. visibleInstances: any;
  33251. batchCache: _InstancesBatch;
  33252. instancesBufferSize: number;
  33253. instancesBuffer: Nullable<Buffer>;
  33254. instancesData: Float32Array;
  33255. overridenInstanceCount: number;
  33256. isFrozen: boolean;
  33257. previousBatch: Nullable<_InstancesBatch>;
  33258. hardwareInstancedRendering: boolean;
  33259. sideOrientation: number;
  33260. manualUpdate: boolean;
  33261. previousRenderId: number;
  33262. }
  33263. /**
  33264. * @hidden
  33265. **/
  33266. export class _InstancesBatch {
  33267. mustReturn: boolean;
  33268. visibleInstances: Nullable<InstancedMesh[]>[];
  33269. renderSelf: boolean[];
  33270. hardwareInstancedRendering: boolean[];
  33271. }
  33272. /**
  33273. * @hidden
  33274. **/
  33275. class _ThinInstanceDataStorage {
  33276. instancesCount: number;
  33277. matrixBuffer: Nullable<Buffer>;
  33278. matrixBufferSize: number;
  33279. matrixData: Nullable<Float32Array>;
  33280. boundingVectors: Array<Vector3>;
  33281. worldMatrices: Nullable<Matrix[]>;
  33282. }
  33283. /**
  33284. * Class used to represent renderable models
  33285. */
  33286. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33287. /**
  33288. * Mesh side orientation : usually the external or front surface
  33289. */
  33290. static readonly FRONTSIDE: number;
  33291. /**
  33292. * Mesh side orientation : usually the internal or back surface
  33293. */
  33294. static readonly BACKSIDE: number;
  33295. /**
  33296. * Mesh side orientation : both internal and external or front and back surfaces
  33297. */
  33298. static readonly DOUBLESIDE: number;
  33299. /**
  33300. * Mesh side orientation : by default, `FRONTSIDE`
  33301. */
  33302. static readonly DEFAULTSIDE: number;
  33303. /**
  33304. * Mesh cap setting : no cap
  33305. */
  33306. static readonly NO_CAP: number;
  33307. /**
  33308. * Mesh cap setting : one cap at the beginning of the mesh
  33309. */
  33310. static readonly CAP_START: number;
  33311. /**
  33312. * Mesh cap setting : one cap at the end of the mesh
  33313. */
  33314. static readonly CAP_END: number;
  33315. /**
  33316. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33317. */
  33318. static readonly CAP_ALL: number;
  33319. /**
  33320. * Mesh pattern setting : no flip or rotate
  33321. */
  33322. static readonly NO_FLIP: number;
  33323. /**
  33324. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33325. */
  33326. static readonly FLIP_TILE: number;
  33327. /**
  33328. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33329. */
  33330. static readonly ROTATE_TILE: number;
  33331. /**
  33332. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33333. */
  33334. static readonly FLIP_ROW: number;
  33335. /**
  33336. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33337. */
  33338. static readonly ROTATE_ROW: number;
  33339. /**
  33340. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33341. */
  33342. static readonly FLIP_N_ROTATE_TILE: number;
  33343. /**
  33344. * Mesh pattern setting : rotate pattern and rotate
  33345. */
  33346. static readonly FLIP_N_ROTATE_ROW: number;
  33347. /**
  33348. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33349. */
  33350. static readonly CENTER: number;
  33351. /**
  33352. * Mesh tile positioning : part tiles on left
  33353. */
  33354. static readonly LEFT: number;
  33355. /**
  33356. * Mesh tile positioning : part tiles on right
  33357. */
  33358. static readonly RIGHT: number;
  33359. /**
  33360. * Mesh tile positioning : part tiles on top
  33361. */
  33362. static readonly TOP: number;
  33363. /**
  33364. * Mesh tile positioning : part tiles on bottom
  33365. */
  33366. static readonly BOTTOM: number;
  33367. /**
  33368. * Gets the default side orientation.
  33369. * @param orientation the orientation to value to attempt to get
  33370. * @returns the default orientation
  33371. * @hidden
  33372. */
  33373. static _GetDefaultSideOrientation(orientation?: number): number;
  33374. private _internalMeshDataInfo;
  33375. get computeBonesUsingShaders(): boolean;
  33376. set computeBonesUsingShaders(value: boolean);
  33377. /**
  33378. * An event triggered before rendering the mesh
  33379. */
  33380. get onBeforeRenderObservable(): Observable<Mesh>;
  33381. /**
  33382. * An event triggered before binding the mesh
  33383. */
  33384. get onBeforeBindObservable(): Observable<Mesh>;
  33385. /**
  33386. * An event triggered after rendering the mesh
  33387. */
  33388. get onAfterRenderObservable(): Observable<Mesh>;
  33389. /**
  33390. * An event triggered before drawing the mesh
  33391. */
  33392. get onBeforeDrawObservable(): Observable<Mesh>;
  33393. private _onBeforeDrawObserver;
  33394. /**
  33395. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33396. */
  33397. set onBeforeDraw(callback: () => void);
  33398. get hasInstances(): boolean;
  33399. get hasThinInstances(): boolean;
  33400. /**
  33401. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33402. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33403. */
  33404. delayLoadState: number;
  33405. /**
  33406. * Gets the list of instances created from this mesh
  33407. * it is not supposed to be modified manually.
  33408. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33409. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33410. */
  33411. instances: InstancedMesh[];
  33412. /**
  33413. * Gets the file containing delay loading data for this mesh
  33414. */
  33415. delayLoadingFile: string;
  33416. /** @hidden */
  33417. _binaryInfo: any;
  33418. /**
  33419. * User defined function used to change how LOD level selection is done
  33420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33421. */
  33422. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33423. /**
  33424. * Gets or sets the morph target manager
  33425. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33426. */
  33427. get morphTargetManager(): Nullable<MorphTargetManager>;
  33428. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33429. /** @hidden */
  33430. _creationDataStorage: Nullable<_CreationDataStorage>;
  33431. /** @hidden */
  33432. _geometry: Nullable<Geometry>;
  33433. /** @hidden */
  33434. _delayInfo: Array<string>;
  33435. /** @hidden */
  33436. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33437. /** @hidden */
  33438. _instanceDataStorage: _InstanceDataStorage;
  33439. /** @hidden */
  33440. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33441. private _effectiveMaterial;
  33442. /** @hidden */
  33443. _shouldGenerateFlatShading: boolean;
  33444. /** @hidden */
  33445. _originalBuilderSideOrientation: number;
  33446. /**
  33447. * Use this property to change the original side orientation defined at construction time
  33448. */
  33449. overrideMaterialSideOrientation: Nullable<number>;
  33450. /**
  33451. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33452. * Note this will reduce performance when set to true.
  33453. */
  33454. ignoreCameraMaxZ: boolean;
  33455. /**
  33456. * Gets the source mesh (the one used to clone this one from)
  33457. */
  33458. get source(): Nullable<Mesh>;
  33459. /**
  33460. * Gets the list of clones of this mesh
  33461. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33462. * Note that useClonedMeshMap=true is the default setting
  33463. */
  33464. get cloneMeshMap(): Nullable<{
  33465. [id: string]: Mesh | undefined;
  33466. }>;
  33467. /**
  33468. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33469. */
  33470. get isUnIndexed(): boolean;
  33471. set isUnIndexed(value: boolean);
  33472. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33473. get worldMatrixInstancedBuffer(): Float32Array;
  33474. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33475. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33476. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33477. /**
  33478. * @constructor
  33479. * @param name The value used by scene.getMeshByName() to do a lookup.
  33480. * @param scene The scene to add this mesh to.
  33481. * @param parent The parent of this mesh, if it has one
  33482. * @param source An optional Mesh from which geometry is shared, cloned.
  33483. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33484. * When false, achieved by calling a clone(), also passing False.
  33485. * This will make creation of children, recursive.
  33486. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33487. */
  33488. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33489. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33490. doNotInstantiate: boolean;
  33491. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33492. /**
  33493. * Gets the class name
  33494. * @returns the string "Mesh".
  33495. */
  33496. getClassName(): string;
  33497. /** @hidden */
  33498. get _isMesh(): boolean;
  33499. /**
  33500. * Returns a description of this mesh
  33501. * @param fullDetails define if full details about this mesh must be used
  33502. * @returns a descriptive string representing this mesh
  33503. */
  33504. toString(fullDetails?: boolean): string;
  33505. /** @hidden */
  33506. _unBindEffect(): void;
  33507. /**
  33508. * Gets a boolean indicating if this mesh has LOD
  33509. */
  33510. get hasLODLevels(): boolean;
  33511. /**
  33512. * Gets the list of MeshLODLevel associated with the current mesh
  33513. * @returns an array of MeshLODLevel
  33514. */
  33515. getLODLevels(): MeshLODLevel[];
  33516. private _sortLODLevels;
  33517. /**
  33518. * Add a mesh as LOD level triggered at the given distance.
  33519. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33520. * @param distance The distance from the center of the object to show this level
  33521. * @param mesh The mesh to be added as LOD level (can be null)
  33522. * @return This mesh (for chaining)
  33523. */
  33524. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33525. /**
  33526. * Returns the LOD level mesh at the passed distance or null if not found.
  33527. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33528. * @param distance The distance from the center of the object to show this level
  33529. * @returns a Mesh or `null`
  33530. */
  33531. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33532. /**
  33533. * Remove a mesh from the LOD array
  33534. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33535. * @param mesh defines the mesh to be removed
  33536. * @return This mesh (for chaining)
  33537. */
  33538. removeLODLevel(mesh: Mesh): Mesh;
  33539. /**
  33540. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33541. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33542. * @param camera defines the camera to use to compute distance
  33543. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33544. * @return This mesh (for chaining)
  33545. */
  33546. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33547. /**
  33548. * Gets the mesh internal Geometry object
  33549. */
  33550. get geometry(): Nullable<Geometry>;
  33551. /**
  33552. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33553. * @returns the total number of vertices
  33554. */
  33555. getTotalVertices(): number;
  33556. /**
  33557. * Returns the content of an associated vertex buffer
  33558. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33559. * - VertexBuffer.PositionKind
  33560. * - VertexBuffer.UVKind
  33561. * - VertexBuffer.UV2Kind
  33562. * - VertexBuffer.UV3Kind
  33563. * - VertexBuffer.UV4Kind
  33564. * - VertexBuffer.UV5Kind
  33565. * - VertexBuffer.UV6Kind
  33566. * - VertexBuffer.ColorKind
  33567. * - VertexBuffer.MatricesIndicesKind
  33568. * - VertexBuffer.MatricesIndicesExtraKind
  33569. * - VertexBuffer.MatricesWeightsKind
  33570. * - VertexBuffer.MatricesWeightsExtraKind
  33571. * @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
  33572. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33573. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33574. */
  33575. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33576. /**
  33577. * Returns the mesh VertexBuffer object from the requested `kind`
  33578. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33579. * - VertexBuffer.PositionKind
  33580. * - VertexBuffer.NormalKind
  33581. * - VertexBuffer.UVKind
  33582. * - VertexBuffer.UV2Kind
  33583. * - VertexBuffer.UV3Kind
  33584. * - VertexBuffer.UV4Kind
  33585. * - VertexBuffer.UV5Kind
  33586. * - VertexBuffer.UV6Kind
  33587. * - VertexBuffer.ColorKind
  33588. * - VertexBuffer.MatricesIndicesKind
  33589. * - VertexBuffer.MatricesIndicesExtraKind
  33590. * - VertexBuffer.MatricesWeightsKind
  33591. * - VertexBuffer.MatricesWeightsExtraKind
  33592. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33593. */
  33594. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33595. /**
  33596. * Tests if a specific vertex buffer is associated with this mesh
  33597. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33598. * - VertexBuffer.PositionKind
  33599. * - VertexBuffer.NormalKind
  33600. * - VertexBuffer.UVKind
  33601. * - VertexBuffer.UV2Kind
  33602. * - VertexBuffer.UV3Kind
  33603. * - VertexBuffer.UV4Kind
  33604. * - VertexBuffer.UV5Kind
  33605. * - VertexBuffer.UV6Kind
  33606. * - VertexBuffer.ColorKind
  33607. * - VertexBuffer.MatricesIndicesKind
  33608. * - VertexBuffer.MatricesIndicesExtraKind
  33609. * - VertexBuffer.MatricesWeightsKind
  33610. * - VertexBuffer.MatricesWeightsExtraKind
  33611. * @returns a boolean
  33612. */
  33613. isVerticesDataPresent(kind: string): boolean;
  33614. /**
  33615. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33616. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33617. * - VertexBuffer.PositionKind
  33618. * - VertexBuffer.UVKind
  33619. * - VertexBuffer.UV2Kind
  33620. * - VertexBuffer.UV3Kind
  33621. * - VertexBuffer.UV4Kind
  33622. * - VertexBuffer.UV5Kind
  33623. * - VertexBuffer.UV6Kind
  33624. * - VertexBuffer.ColorKind
  33625. * - VertexBuffer.MatricesIndicesKind
  33626. * - VertexBuffer.MatricesIndicesExtraKind
  33627. * - VertexBuffer.MatricesWeightsKind
  33628. * - VertexBuffer.MatricesWeightsExtraKind
  33629. * @returns a boolean
  33630. */
  33631. isVertexBufferUpdatable(kind: string): boolean;
  33632. /**
  33633. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33634. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33635. * - VertexBuffer.PositionKind
  33636. * - VertexBuffer.NormalKind
  33637. * - VertexBuffer.UVKind
  33638. * - VertexBuffer.UV2Kind
  33639. * - VertexBuffer.UV3Kind
  33640. * - VertexBuffer.UV4Kind
  33641. * - VertexBuffer.UV5Kind
  33642. * - VertexBuffer.UV6Kind
  33643. * - VertexBuffer.ColorKind
  33644. * - VertexBuffer.MatricesIndicesKind
  33645. * - VertexBuffer.MatricesIndicesExtraKind
  33646. * - VertexBuffer.MatricesWeightsKind
  33647. * - VertexBuffer.MatricesWeightsExtraKind
  33648. * @returns an array of strings
  33649. */
  33650. getVerticesDataKinds(): string[];
  33651. /**
  33652. * Returns a positive integer : the total number of indices in this mesh geometry.
  33653. * @returns the numner of indices or zero if the mesh has no geometry.
  33654. */
  33655. getTotalIndices(): number;
  33656. /**
  33657. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33658. * @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.
  33659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33660. * @returns the indices array or an empty array if the mesh has no geometry
  33661. */
  33662. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33663. get isBlocked(): boolean;
  33664. /**
  33665. * Determine if the current mesh is ready to be rendered
  33666. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33667. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33668. * @returns true if all associated assets are ready (material, textures, shaders)
  33669. */
  33670. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33671. /**
  33672. * 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.
  33673. */
  33674. get areNormalsFrozen(): boolean;
  33675. /**
  33676. * 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.
  33677. * @returns the current mesh
  33678. */
  33679. freezeNormals(): Mesh;
  33680. /**
  33681. * 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
  33682. * @returns the current mesh
  33683. */
  33684. unfreezeNormals(): Mesh;
  33685. /**
  33686. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33687. */
  33688. set overridenInstanceCount(count: number);
  33689. /** @hidden */
  33690. _preActivate(): Mesh;
  33691. /** @hidden */
  33692. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33693. /** @hidden */
  33694. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33695. protected _afterComputeWorldMatrix(): void;
  33696. /** @hidden */
  33697. _postActivate(): void;
  33698. /**
  33699. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33700. * This means the mesh underlying bounding box and sphere are recomputed.
  33701. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33702. * @returns the current mesh
  33703. */
  33704. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33705. /** @hidden */
  33706. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33707. /**
  33708. * This function will subdivide the mesh into multiple submeshes
  33709. * @param count defines the expected number of submeshes
  33710. */
  33711. subdivide(count: number): void;
  33712. /**
  33713. * Copy a FloatArray into a specific associated vertex buffer
  33714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33715. * - VertexBuffer.PositionKind
  33716. * - VertexBuffer.UVKind
  33717. * - VertexBuffer.UV2Kind
  33718. * - VertexBuffer.UV3Kind
  33719. * - VertexBuffer.UV4Kind
  33720. * - VertexBuffer.UV5Kind
  33721. * - VertexBuffer.UV6Kind
  33722. * - VertexBuffer.ColorKind
  33723. * - VertexBuffer.MatricesIndicesKind
  33724. * - VertexBuffer.MatricesIndicesExtraKind
  33725. * - VertexBuffer.MatricesWeightsKind
  33726. * - VertexBuffer.MatricesWeightsExtraKind
  33727. * @param data defines the data source
  33728. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33729. * @param stride defines the data stride size (can be null)
  33730. * @returns the current mesh
  33731. */
  33732. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33733. /**
  33734. * Delete a vertex buffer associated with this mesh
  33735. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33736. * - VertexBuffer.PositionKind
  33737. * - VertexBuffer.UVKind
  33738. * - VertexBuffer.UV2Kind
  33739. * - VertexBuffer.UV3Kind
  33740. * - VertexBuffer.UV4Kind
  33741. * - VertexBuffer.UV5Kind
  33742. * - VertexBuffer.UV6Kind
  33743. * - VertexBuffer.ColorKind
  33744. * - VertexBuffer.MatricesIndicesKind
  33745. * - VertexBuffer.MatricesIndicesExtraKind
  33746. * - VertexBuffer.MatricesWeightsKind
  33747. * - VertexBuffer.MatricesWeightsExtraKind
  33748. */
  33749. removeVerticesData(kind: string): void;
  33750. /**
  33751. * Flags an associated vertex buffer as updatable
  33752. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33753. * - VertexBuffer.PositionKind
  33754. * - VertexBuffer.UVKind
  33755. * - VertexBuffer.UV2Kind
  33756. * - VertexBuffer.UV3Kind
  33757. * - VertexBuffer.UV4Kind
  33758. * - VertexBuffer.UV5Kind
  33759. * - VertexBuffer.UV6Kind
  33760. * - VertexBuffer.ColorKind
  33761. * - VertexBuffer.MatricesIndicesKind
  33762. * - VertexBuffer.MatricesIndicesExtraKind
  33763. * - VertexBuffer.MatricesWeightsKind
  33764. * - VertexBuffer.MatricesWeightsExtraKind
  33765. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33766. */
  33767. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33768. /**
  33769. * Sets the mesh global Vertex Buffer
  33770. * @param buffer defines the buffer to use
  33771. * @returns the current mesh
  33772. */
  33773. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33774. /**
  33775. * Update a specific associated vertex buffer
  33776. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33777. * - VertexBuffer.PositionKind
  33778. * - VertexBuffer.UVKind
  33779. * - VertexBuffer.UV2Kind
  33780. * - VertexBuffer.UV3Kind
  33781. * - VertexBuffer.UV4Kind
  33782. * - VertexBuffer.UV5Kind
  33783. * - VertexBuffer.UV6Kind
  33784. * - VertexBuffer.ColorKind
  33785. * - VertexBuffer.MatricesIndicesKind
  33786. * - VertexBuffer.MatricesIndicesExtraKind
  33787. * - VertexBuffer.MatricesWeightsKind
  33788. * - VertexBuffer.MatricesWeightsExtraKind
  33789. * @param data defines the data source
  33790. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33791. * @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)
  33792. * @returns the current mesh
  33793. */
  33794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33795. /**
  33796. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33797. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33798. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33799. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33800. * @returns the current mesh
  33801. */
  33802. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33803. /**
  33804. * Creates a un-shared specific occurence of the geometry for the mesh.
  33805. * @returns the current mesh
  33806. */
  33807. makeGeometryUnique(): Mesh;
  33808. /**
  33809. * Set the index buffer of this mesh
  33810. * @param indices defines the source data
  33811. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33812. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33813. * @returns the current mesh
  33814. */
  33815. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33816. /**
  33817. * Update the current index buffer
  33818. * @param indices defines the source data
  33819. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33820. * @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)
  33821. * @returns the current mesh
  33822. */
  33823. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33824. /**
  33825. * Invert the geometry to move from a right handed system to a left handed one.
  33826. * @returns the current mesh
  33827. */
  33828. toLeftHanded(): Mesh;
  33829. /** @hidden */
  33830. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33831. /** @hidden */
  33832. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33833. /**
  33834. * Registers for this mesh a javascript function called just before the rendering process
  33835. * @param func defines the function to call before rendering this mesh
  33836. * @returns the current mesh
  33837. */
  33838. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33839. /**
  33840. * Disposes a previously registered javascript function called before the rendering
  33841. * @param func defines the function to remove
  33842. * @returns the current mesh
  33843. */
  33844. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33845. /**
  33846. * Registers for this mesh a javascript function called just after the rendering is complete
  33847. * @param func defines the function to call after rendering this mesh
  33848. * @returns the current mesh
  33849. */
  33850. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33851. /**
  33852. * Disposes a previously registered javascript function called after the rendering.
  33853. * @param func defines the function to remove
  33854. * @returns the current mesh
  33855. */
  33856. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33857. /** @hidden */
  33858. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33859. /** @hidden */
  33860. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33861. /** @hidden */
  33862. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33863. /** @hidden */
  33864. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33865. /** @hidden */
  33866. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33867. /** @hidden */
  33868. _rebuild(): void;
  33869. /** @hidden */
  33870. _freeze(): void;
  33871. /** @hidden */
  33872. _unFreeze(): void;
  33873. /**
  33874. * 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
  33875. * @param subMesh defines the subMesh to render
  33876. * @param enableAlphaMode defines if alpha mode can be changed
  33877. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33878. * @returns the current mesh
  33879. */
  33880. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33881. private _onBeforeDraw;
  33882. /**
  33883. * Renormalize the mesh and patch it up if there are no weights
  33884. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33885. * However in the case of zero weights then we set just a single influence to 1.
  33886. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33887. */
  33888. cleanMatrixWeights(): void;
  33889. private normalizeSkinFourWeights;
  33890. private normalizeSkinWeightsAndExtra;
  33891. /**
  33892. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33893. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33894. * the user know there was an issue with importing the mesh
  33895. * @returns a validation object with skinned, valid and report string
  33896. */
  33897. validateSkinning(): {
  33898. skinned: boolean;
  33899. valid: boolean;
  33900. report: string;
  33901. };
  33902. /** @hidden */
  33903. _checkDelayState(): Mesh;
  33904. private _queueLoad;
  33905. /**
  33906. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33907. * A mesh is in the frustum if its bounding box intersects the frustum
  33908. * @param frustumPlanes defines the frustum to test
  33909. * @returns true if the mesh is in the frustum planes
  33910. */
  33911. isInFrustum(frustumPlanes: Plane[]): boolean;
  33912. /**
  33913. * Sets the mesh material by the material or multiMaterial `id` property
  33914. * @param id is a string identifying the material or the multiMaterial
  33915. * @returns the current mesh
  33916. */
  33917. setMaterialByID(id: string): Mesh;
  33918. /**
  33919. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33920. * @returns an array of IAnimatable
  33921. */
  33922. getAnimatables(): IAnimatable[];
  33923. /**
  33924. * Modifies the mesh geometry according to the passed transformation matrix.
  33925. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33926. * The mesh normals are modified using the same transformation.
  33927. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33928. * @param transform defines the transform matrix to use
  33929. * @see https://doc.babylonjs.com/resources/baking_transformations
  33930. * @returns the current mesh
  33931. */
  33932. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33933. /**
  33934. * Modifies the mesh geometry according to its own current World Matrix.
  33935. * The mesh World Matrix is then reset.
  33936. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33937. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33938. * @see https://doc.babylonjs.com/resources/baking_transformations
  33939. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33940. * @returns the current mesh
  33941. */
  33942. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33943. /** @hidden */
  33944. get _positions(): Nullable<Vector3[]>;
  33945. /** @hidden */
  33946. _resetPointsArrayCache(): Mesh;
  33947. /** @hidden */
  33948. _generatePointsArray(): boolean;
  33949. /**
  33950. * Returns a new Mesh object generated from the current mesh properties.
  33951. * This method must not get confused with createInstance()
  33952. * @param name is a string, the name given to the new mesh
  33953. * @param newParent can be any Node object (default `null`)
  33954. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33955. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33956. * @returns a new mesh
  33957. */
  33958. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33959. /**
  33960. * Releases resources associated with this mesh.
  33961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33963. */
  33964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33965. /** @hidden */
  33966. _disposeInstanceSpecificData(): void;
  33967. /** @hidden */
  33968. _disposeThinInstanceSpecificData(): void;
  33969. /**
  33970. * Modifies the mesh geometry according to a displacement map.
  33971. * 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.
  33972. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33973. * @param url is a string, the URL from the image file is to be downloaded.
  33974. * @param minHeight is the lower limit of the displacement.
  33975. * @param maxHeight is the upper limit of the displacement.
  33976. * @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.
  33977. * @param uvOffset is an optional vector2 used to offset UV.
  33978. * @param uvScale is an optional vector2 used to scale UV.
  33979. * @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.
  33980. * @returns the Mesh.
  33981. */
  33982. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33983. /**
  33984. * Modifies the mesh geometry according to a displacementMap buffer.
  33985. * 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.
  33986. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33987. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33988. * @param heightMapWidth is the width of the buffer image.
  33989. * @param heightMapHeight is the height of the buffer image.
  33990. * @param minHeight is the lower limit of the displacement.
  33991. * @param maxHeight is the upper limit of the displacement.
  33992. * @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.
  33993. * @param uvOffset is an optional vector2 used to offset UV.
  33994. * @param uvScale is an optional vector2 used to scale UV.
  33995. * @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.
  33996. * @returns the Mesh.
  33997. */
  33998. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33999. /**
  34000. * Modify the mesh to get a flat shading rendering.
  34001. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34002. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34003. * @returns current mesh
  34004. */
  34005. convertToFlatShadedMesh(): Mesh;
  34006. /**
  34007. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34008. * In other words, more vertices, no more indices and a single bigger VBO.
  34009. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34010. * @returns current mesh
  34011. */
  34012. convertToUnIndexedMesh(): Mesh;
  34013. /**
  34014. * Inverses facet orientations.
  34015. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34016. * @param flipNormals will also inverts the normals
  34017. * @returns current mesh
  34018. */
  34019. flipFaces(flipNormals?: boolean): Mesh;
  34020. /**
  34021. * Increase the number of facets and hence vertices in a mesh
  34022. * Vertex normals are interpolated from existing vertex normals
  34023. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34024. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34025. */
  34026. increaseVertices(numberPerEdge: number): void;
  34027. /**
  34028. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34029. * This will undo any application of covertToFlatShadedMesh
  34030. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34031. */
  34032. forceSharedVertices(): void;
  34033. /** @hidden */
  34034. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34035. /** @hidden */
  34036. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34037. /**
  34038. * Creates a new InstancedMesh object from the mesh model.
  34039. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34040. * @param name defines the name of the new instance
  34041. * @returns a new InstancedMesh
  34042. */
  34043. createInstance(name: string): InstancedMesh;
  34044. /**
  34045. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34046. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34047. * @returns the current mesh
  34048. */
  34049. synchronizeInstances(): Mesh;
  34050. /**
  34051. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34052. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34053. * This should be used together with the simplification to avoid disappearing triangles.
  34054. * @param successCallback an optional success callback to be called after the optimization finished.
  34055. * @returns the current mesh
  34056. */
  34057. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34058. /**
  34059. * Serialize current mesh
  34060. * @param serializationObject defines the object which will receive the serialization data
  34061. */
  34062. serialize(serializationObject: any): void;
  34063. /** @hidden */
  34064. _syncGeometryWithMorphTargetManager(): void;
  34065. /** @hidden */
  34066. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34067. /**
  34068. * Returns a new Mesh object parsed from the source provided.
  34069. * @param parsedMesh is the source
  34070. * @param scene defines the hosting scene
  34071. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34072. * @returns a new Mesh
  34073. */
  34074. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34075. /**
  34076. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34078. * @param name defines the name of the mesh to create
  34079. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34080. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34081. * @param closePath creates a seam between the first and the last points of each path of the path array
  34082. * @param offset is taken in account only if the `pathArray` is containing a single path
  34083. * @param scene defines the hosting scene
  34084. * @param updatable defines if the mesh must be flagged as updatable
  34085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34086. * @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)
  34087. * @returns a new Mesh
  34088. */
  34089. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34090. /**
  34091. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34092. * @param name defines the name of the mesh to create
  34093. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34094. * @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
  34095. * @param scene defines the hosting scene
  34096. * @param updatable defines if the mesh must be flagged as updatable
  34097. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34098. * @returns a new Mesh
  34099. */
  34100. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34101. /**
  34102. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34103. * @param name defines the name of the mesh to create
  34104. * @param size sets the size (float) of each box side (default 1)
  34105. * @param scene defines the hosting scene
  34106. * @param updatable defines if the mesh must be flagged as updatable
  34107. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34108. * @returns a new Mesh
  34109. */
  34110. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34111. /**
  34112. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34113. * @param name defines the name of the mesh to create
  34114. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34115. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34116. * @param scene defines the hosting scene
  34117. * @param updatable defines if the mesh must be flagged as updatable
  34118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34119. * @returns a new Mesh
  34120. */
  34121. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34122. /**
  34123. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34124. * @param name defines the name of the mesh to create
  34125. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34126. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34127. * @param scene defines the hosting scene
  34128. * @returns a new Mesh
  34129. */
  34130. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34131. /**
  34132. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34133. * @param name defines the name of the mesh to create
  34134. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34135. * @param diameterTop set the top cap diameter (floats, default 1)
  34136. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34137. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34138. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34139. * @param scene defines the hosting scene
  34140. * @param updatable defines if the mesh must be flagged as updatable
  34141. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34142. * @returns a new Mesh
  34143. */
  34144. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34145. /**
  34146. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34147. * @param name defines the name of the mesh to create
  34148. * @param diameter sets the diameter size (float) of the torus (default 1)
  34149. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34150. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34151. * @param scene defines the hosting scene
  34152. * @param updatable defines if the mesh must be flagged as updatable
  34153. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34154. * @returns a new Mesh
  34155. */
  34156. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34157. /**
  34158. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34159. * @param name defines the name of the mesh to create
  34160. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34161. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34162. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34163. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34164. * @param p the number of windings on X axis (positive integers, default 2)
  34165. * @param q the number of windings on Y axis (positive integers, default 3)
  34166. * @param scene defines the hosting scene
  34167. * @param updatable defines if the mesh must be flagged as updatable
  34168. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34169. * @returns a new Mesh
  34170. */
  34171. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34172. /**
  34173. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34174. * @param name defines the name of the mesh to create
  34175. * @param points is an array successive Vector3
  34176. * @param scene defines the hosting scene
  34177. * @param updatable defines if the mesh must be flagged as updatable
  34178. * @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).
  34179. * @returns a new Mesh
  34180. */
  34181. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34182. /**
  34183. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34184. * @param name defines the name of the mesh to create
  34185. * @param points is an array successive Vector3
  34186. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34187. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34188. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34189. * @param scene defines the hosting scene
  34190. * @param updatable defines if the mesh must be flagged as updatable
  34191. * @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)
  34192. * @returns a new Mesh
  34193. */
  34194. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34195. /**
  34196. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34197. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34198. * 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.
  34199. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34201. * Remember you can only change the shape positions, not their number when updating a polygon.
  34202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34203. * @param name defines the name of the mesh to create
  34204. * @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
  34205. * @param scene defines the hosting scene
  34206. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34207. * @param updatable defines if the mesh must be flagged as updatable
  34208. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34209. * @param earcutInjection can be used to inject your own earcut reference
  34210. * @returns a new Mesh
  34211. */
  34212. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34213. /**
  34214. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34216. * @param name defines the name of the mesh to create
  34217. * @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
  34218. * @param depth defines the height of extrusion
  34219. * @param scene defines the hosting scene
  34220. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34221. * @param updatable defines if the mesh must be flagged as updatable
  34222. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34223. * @param earcutInjection can be used to inject your own earcut reference
  34224. * @returns a new Mesh
  34225. */
  34226. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34227. /**
  34228. * Creates an extruded shape mesh.
  34229. * 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
  34230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34232. * @param name defines the name of the mesh to create
  34233. * @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
  34234. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34235. * @param scale is the value to scale the shape
  34236. * @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
  34237. * @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
  34238. * @param scene defines the hosting scene
  34239. * @param updatable defines if the mesh must be flagged as updatable
  34240. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34241. * @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)
  34242. * @returns a new Mesh
  34243. */
  34244. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34245. /**
  34246. * Creates an custom extruded shape mesh.
  34247. * The custom extrusion is a parametric shape.
  34248. * It has no predefined shape. Its final shape will depend on the input parameters.
  34249. * Please consider using the same method from the MeshBuilder class instead
  34250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34251. * @param name defines the name of the mesh to create
  34252. * @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
  34253. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34254. * @param scaleFunction is a custom Javascript function called on each path point
  34255. * @param rotationFunction is a custom Javascript function called on each path point
  34256. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34257. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34258. * @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
  34259. * @param scene defines the hosting scene
  34260. * @param updatable defines if the mesh must be flagged as updatable
  34261. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34262. * @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)
  34263. * @returns a new Mesh
  34264. */
  34265. 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;
  34266. /**
  34267. * Creates lathe mesh.
  34268. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34269. * Please consider using the same method from the MeshBuilder class instead
  34270. * @param name defines the name of the mesh to create
  34271. * @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
  34272. * @param radius is the radius value of the lathe
  34273. * @param tessellation is the side number of the lathe.
  34274. * @param scene defines the hosting scene
  34275. * @param updatable defines if the mesh must be flagged as updatable
  34276. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34277. * @returns a new Mesh
  34278. */
  34279. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34280. /**
  34281. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34282. * @param name defines the name of the mesh to create
  34283. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34284. * @param scene defines the hosting scene
  34285. * @param updatable defines if the mesh must be flagged as updatable
  34286. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34287. * @returns a new Mesh
  34288. */
  34289. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34290. /**
  34291. * Creates a ground mesh.
  34292. * Please consider using the same method from the MeshBuilder class instead
  34293. * @param name defines the name of the mesh to create
  34294. * @param width set the width of the ground
  34295. * @param height set the height of the ground
  34296. * @param subdivisions sets the number of subdivisions per side
  34297. * @param scene defines the hosting scene
  34298. * @param updatable defines if the mesh must be flagged as updatable
  34299. * @returns a new Mesh
  34300. */
  34301. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34302. /**
  34303. * Creates a tiled ground mesh.
  34304. * Please consider using the same method from the MeshBuilder class instead
  34305. * @param name defines the name of the mesh to create
  34306. * @param xmin set the ground minimum X coordinate
  34307. * @param zmin set the ground minimum Y coordinate
  34308. * @param xmax set the ground maximum X coordinate
  34309. * @param zmax set the ground maximum Z coordinate
  34310. * @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
  34311. * @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
  34312. * @param scene defines the hosting scene
  34313. * @param updatable defines if the mesh must be flagged as updatable
  34314. * @returns a new Mesh
  34315. */
  34316. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34317. w: number;
  34318. h: number;
  34319. }, precision: {
  34320. w: number;
  34321. h: number;
  34322. }, scene: Scene, updatable?: boolean): Mesh;
  34323. /**
  34324. * Creates a ground mesh from a height map.
  34325. * Please consider using the same method from the MeshBuilder class instead
  34326. * @see https://doc.babylonjs.com/babylon101/height_map
  34327. * @param name defines the name of the mesh to create
  34328. * @param url sets the URL of the height map image resource
  34329. * @param width set the ground width size
  34330. * @param height set the ground height size
  34331. * @param subdivisions sets the number of subdivision per side
  34332. * @param minHeight is the minimum altitude on the ground
  34333. * @param maxHeight is the maximum altitude on the ground
  34334. * @param scene defines the hosting scene
  34335. * @param updatable defines if the mesh must be flagged as updatable
  34336. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34337. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34338. * @returns a new Mesh
  34339. */
  34340. 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;
  34341. /**
  34342. * Creates a tube mesh.
  34343. * The tube is a parametric shape.
  34344. * It has no predefined shape. Its final shape will depend on the input parameters.
  34345. * Please consider using the same method from the MeshBuilder class instead
  34346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34347. * @param name defines the name of the mesh to create
  34348. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34349. * @param radius sets the tube radius size
  34350. * @param tessellation is the number of sides on the tubular surface
  34351. * @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
  34352. * @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
  34353. * @param scene defines the hosting scene
  34354. * @param updatable defines if the mesh must be flagged as updatable
  34355. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34356. * @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)
  34357. * @returns a new Mesh
  34358. */
  34359. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34360. (i: number, distance: number): number;
  34361. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34362. /**
  34363. * Creates a polyhedron mesh.
  34364. * Please consider using the same method from the MeshBuilder class instead.
  34365. * * 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
  34366. * * The parameter `size` (positive float, default 1) sets the polygon size
  34367. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34368. * * 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`
  34369. * * 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
  34370. * * 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)`)
  34371. * * 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
  34372. * * 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
  34373. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34374. * * 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
  34375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34376. * @param name defines the name of the mesh to create
  34377. * @param options defines the options used to create the mesh
  34378. * @param scene defines the hosting scene
  34379. * @returns a new Mesh
  34380. */
  34381. static CreatePolyhedron(name: string, options: {
  34382. type?: number;
  34383. size?: number;
  34384. sizeX?: number;
  34385. sizeY?: number;
  34386. sizeZ?: number;
  34387. custom?: any;
  34388. faceUV?: Vector4[];
  34389. faceColors?: Color4[];
  34390. updatable?: boolean;
  34391. sideOrientation?: number;
  34392. }, scene: Scene): Mesh;
  34393. /**
  34394. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34395. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34396. * * 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`)
  34397. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34398. * * 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
  34399. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34400. * * 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
  34401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34402. * @param name defines the name of the mesh
  34403. * @param options defines the options used to create the mesh
  34404. * @param scene defines the hosting scene
  34405. * @returns a new Mesh
  34406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34407. */
  34408. static CreateIcoSphere(name: string, options: {
  34409. radius?: number;
  34410. flat?: boolean;
  34411. subdivisions?: number;
  34412. sideOrientation?: number;
  34413. updatable?: boolean;
  34414. }, scene: Scene): Mesh;
  34415. /**
  34416. * Creates a decal mesh.
  34417. * Please consider using the same method from the MeshBuilder class instead.
  34418. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34419. * @param name defines the name of the mesh
  34420. * @param sourceMesh defines the mesh receiving the decal
  34421. * @param position sets the position of the decal in world coordinates
  34422. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34423. * @param size sets the decal scaling
  34424. * @param angle sets the angle to rotate the decal
  34425. * @returns a new Mesh
  34426. */
  34427. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34428. /** Creates a Capsule Mesh
  34429. * @param name defines the name of the mesh.
  34430. * @param options the constructors options used to shape the mesh.
  34431. * @param scene defines the scene the mesh is scoped to.
  34432. * @returns the capsule mesh
  34433. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34434. */
  34435. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34436. /**
  34437. * Prepare internal position array for software CPU skinning
  34438. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34439. */
  34440. setPositionsForCPUSkinning(): Float32Array;
  34441. /**
  34442. * Prepare internal normal array for software CPU skinning
  34443. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34444. */
  34445. setNormalsForCPUSkinning(): Float32Array;
  34446. /**
  34447. * Updates the vertex buffer by applying transformation from the bones
  34448. * @param skeleton defines the skeleton to apply to current mesh
  34449. * @returns the current mesh
  34450. */
  34451. applySkeleton(skeleton: Skeleton): Mesh;
  34452. /**
  34453. * 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
  34454. * @param meshes defines the list of meshes to scan
  34455. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34456. */
  34457. static MinMax(meshes: AbstractMesh[]): {
  34458. min: Vector3;
  34459. max: Vector3;
  34460. };
  34461. /**
  34462. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34463. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34464. * @returns a vector3
  34465. */
  34466. static Center(meshesOrMinMaxVector: {
  34467. min: Vector3;
  34468. max: Vector3;
  34469. } | AbstractMesh[]): Vector3;
  34470. /**
  34471. * Merge the array of meshes into a single mesh for performance reasons.
  34472. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34473. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34474. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34475. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34476. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34477. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34478. * @returns a new mesh
  34479. */
  34480. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34481. /** @hidden */
  34482. addInstance(instance: InstancedMesh): void;
  34483. /** @hidden */
  34484. removeInstance(instance: InstancedMesh): void;
  34485. }
  34486. }
  34487. declare module BABYLON {
  34488. /**
  34489. * The options Interface for creating a Capsule Mesh
  34490. */
  34491. export interface ICreateCapsuleOptions {
  34492. /** The Orientation of the capsule. Default : Vector3.Up() */
  34493. orientation?: Vector3;
  34494. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34495. subdivisions: number;
  34496. /** Number of cylindrical segments on the capsule. */
  34497. tessellation: number;
  34498. /** Height or Length of the capsule. */
  34499. height: number;
  34500. /** Radius of the capsule. */
  34501. radius: number;
  34502. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34503. capSubdivisions: number;
  34504. /** Overwrite for the top radius. */
  34505. radiusTop?: number;
  34506. /** Overwrite for the bottom radius. */
  34507. radiusBottom?: number;
  34508. /** Overwrite for the top capSubdivisions. */
  34509. topCapSubdivisions?: number;
  34510. /** Overwrite for the bottom capSubdivisions. */
  34511. bottomCapSubdivisions?: number;
  34512. /** Internal geometry is supposed to change once created. */
  34513. updatable?: boolean;
  34514. }
  34515. /**
  34516. * Class containing static functions to help procedurally build meshes
  34517. */
  34518. export class CapsuleBuilder {
  34519. /**
  34520. * Creates a capsule or a pill mesh
  34521. * @param name defines the name of the mesh
  34522. * @param options The constructors options.
  34523. * @param scene The scene the mesh is scoped to.
  34524. * @returns Capsule Mesh
  34525. */
  34526. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34527. }
  34528. }
  34529. declare module BABYLON {
  34530. /**
  34531. * Define an interface for all classes that will get and set the data on vertices
  34532. */
  34533. export interface IGetSetVerticesData {
  34534. /**
  34535. * Gets a boolean indicating if specific vertex data is present
  34536. * @param kind defines the vertex data kind to use
  34537. * @returns true is data kind is present
  34538. */
  34539. isVerticesDataPresent(kind: string): boolean;
  34540. /**
  34541. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34542. * @param kind defines the data kind (Position, normal, etc...)
  34543. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34545. * @returns a float array containing vertex data
  34546. */
  34547. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34548. /**
  34549. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34550. * @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.
  34551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34552. * @returns the indices array or an empty array if the mesh has no geometry
  34553. */
  34554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34555. /**
  34556. * Set specific vertex data
  34557. * @param kind defines the data kind (Position, normal, etc...)
  34558. * @param data defines the vertex data to use
  34559. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34560. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34561. */
  34562. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34563. /**
  34564. * Update a specific associated vertex buffer
  34565. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34566. * - VertexBuffer.PositionKind
  34567. * - VertexBuffer.UVKind
  34568. * - VertexBuffer.UV2Kind
  34569. * - VertexBuffer.UV3Kind
  34570. * - VertexBuffer.UV4Kind
  34571. * - VertexBuffer.UV5Kind
  34572. * - VertexBuffer.UV6Kind
  34573. * - VertexBuffer.ColorKind
  34574. * - VertexBuffer.MatricesIndicesKind
  34575. * - VertexBuffer.MatricesIndicesExtraKind
  34576. * - VertexBuffer.MatricesWeightsKind
  34577. * - VertexBuffer.MatricesWeightsExtraKind
  34578. * @param data defines the data source
  34579. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34580. * @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)
  34581. */
  34582. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34583. /**
  34584. * Creates a new index buffer
  34585. * @param indices defines the indices to store in the index buffer
  34586. * @param totalVertices defines the total number of vertices (could be null)
  34587. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34588. */
  34589. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34590. }
  34591. /**
  34592. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34593. */
  34594. export class VertexData {
  34595. /**
  34596. * Mesh side orientation : usually the external or front surface
  34597. */
  34598. static readonly FRONTSIDE: number;
  34599. /**
  34600. * Mesh side orientation : usually the internal or back surface
  34601. */
  34602. static readonly BACKSIDE: number;
  34603. /**
  34604. * Mesh side orientation : both internal and external or front and back surfaces
  34605. */
  34606. static readonly DOUBLESIDE: number;
  34607. /**
  34608. * Mesh side orientation : by default, `FRONTSIDE`
  34609. */
  34610. static readonly DEFAULTSIDE: number;
  34611. /**
  34612. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34613. */
  34614. positions: Nullable<FloatArray>;
  34615. /**
  34616. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34617. */
  34618. normals: Nullable<FloatArray>;
  34619. /**
  34620. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34621. */
  34622. tangents: Nullable<FloatArray>;
  34623. /**
  34624. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34625. */
  34626. uvs: Nullable<FloatArray>;
  34627. /**
  34628. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34629. */
  34630. uvs2: Nullable<FloatArray>;
  34631. /**
  34632. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34633. */
  34634. uvs3: Nullable<FloatArray>;
  34635. /**
  34636. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34637. */
  34638. uvs4: Nullable<FloatArray>;
  34639. /**
  34640. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34641. */
  34642. uvs5: Nullable<FloatArray>;
  34643. /**
  34644. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34645. */
  34646. uvs6: Nullable<FloatArray>;
  34647. /**
  34648. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34649. */
  34650. colors: Nullable<FloatArray>;
  34651. /**
  34652. * 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).
  34653. */
  34654. matricesIndices: Nullable<FloatArray>;
  34655. /**
  34656. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34657. */
  34658. matricesWeights: Nullable<FloatArray>;
  34659. /**
  34660. * An array extending the number of possible indices
  34661. */
  34662. matricesIndicesExtra: Nullable<FloatArray>;
  34663. /**
  34664. * An array extending the number of possible weights when the number of indices is extended
  34665. */
  34666. matricesWeightsExtra: Nullable<FloatArray>;
  34667. /**
  34668. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34669. */
  34670. indices: Nullable<IndicesArray>;
  34671. /**
  34672. * Uses the passed data array to set the set the values for the specified kind of data
  34673. * @param data a linear array of floating numbers
  34674. * @param kind the type of data that is being set, eg positions, colors etc
  34675. */
  34676. set(data: FloatArray, kind: string): void;
  34677. /**
  34678. * Associates the vertexData to the passed Mesh.
  34679. * Sets it as updatable or not (default `false`)
  34680. * @param mesh the mesh the vertexData is applied to
  34681. * @param updatable when used and having the value true allows new data to update the vertexData
  34682. * @returns the VertexData
  34683. */
  34684. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34685. /**
  34686. * Associates the vertexData to the passed Geometry.
  34687. * Sets it as updatable or not (default `false`)
  34688. * @param geometry the geometry the vertexData is applied to
  34689. * @param updatable when used and having the value true allows new data to update the vertexData
  34690. * @returns VertexData
  34691. */
  34692. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34693. /**
  34694. * Updates the associated mesh
  34695. * @param mesh the mesh to be updated
  34696. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34697. * @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
  34698. * @returns VertexData
  34699. */
  34700. updateMesh(mesh: Mesh): VertexData;
  34701. /**
  34702. * Updates the associated geometry
  34703. * @param geometry the geometry to be updated
  34704. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34705. * @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
  34706. * @returns VertexData.
  34707. */
  34708. updateGeometry(geometry: Geometry): VertexData;
  34709. private _applyTo;
  34710. private _update;
  34711. /**
  34712. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34713. * @param matrix the transforming matrix
  34714. * @returns the VertexData
  34715. */
  34716. transform(matrix: Matrix): VertexData;
  34717. /**
  34718. * Merges the passed VertexData into the current one
  34719. * @param other the VertexData to be merged into the current one
  34720. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34721. * @returns the modified VertexData
  34722. */
  34723. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34724. private _mergeElement;
  34725. private _validate;
  34726. /**
  34727. * Serializes the VertexData
  34728. * @returns a serialized object
  34729. */
  34730. serialize(): any;
  34731. /**
  34732. * Extracts the vertexData from a mesh
  34733. * @param mesh the mesh from which to extract the VertexData
  34734. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34735. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34736. * @returns the object VertexData associated to the passed mesh
  34737. */
  34738. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34739. /**
  34740. * Extracts the vertexData from the geometry
  34741. * @param geometry the geometry from which to extract the VertexData
  34742. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34743. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34744. * @returns the object VertexData associated to the passed mesh
  34745. */
  34746. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34747. private static _ExtractFrom;
  34748. /**
  34749. * Creates the VertexData for a Ribbon
  34750. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34751. * * pathArray array of paths, each of which an array of successive Vector3
  34752. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34753. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34754. * * 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
  34755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34756. * * 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)
  34757. * * 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)
  34758. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34759. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34760. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34761. * @returns the VertexData of the ribbon
  34762. */
  34763. static CreateRibbon(options: {
  34764. pathArray: Vector3[][];
  34765. closeArray?: boolean;
  34766. closePath?: boolean;
  34767. offset?: number;
  34768. sideOrientation?: number;
  34769. frontUVs?: Vector4;
  34770. backUVs?: Vector4;
  34771. invertUV?: boolean;
  34772. uvs?: Vector2[];
  34773. colors?: Color4[];
  34774. }): VertexData;
  34775. /**
  34776. * Creates the VertexData for a box
  34777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34778. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34779. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34780. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34781. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34782. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34783. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34785. * * 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)
  34786. * * 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)
  34787. * @returns the VertexData of the box
  34788. */
  34789. static CreateBox(options: {
  34790. size?: number;
  34791. width?: number;
  34792. height?: number;
  34793. depth?: number;
  34794. faceUV?: Vector4[];
  34795. faceColors?: Color4[];
  34796. sideOrientation?: number;
  34797. frontUVs?: Vector4;
  34798. backUVs?: Vector4;
  34799. }): VertexData;
  34800. /**
  34801. * Creates the VertexData for a tiled box
  34802. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34803. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34804. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34805. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34807. * @returns the VertexData of the box
  34808. */
  34809. static CreateTiledBox(options: {
  34810. pattern?: number;
  34811. width?: number;
  34812. height?: number;
  34813. depth?: number;
  34814. tileSize?: number;
  34815. tileWidth?: number;
  34816. tileHeight?: number;
  34817. alignHorizontal?: number;
  34818. alignVertical?: number;
  34819. faceUV?: Vector4[];
  34820. faceColors?: Color4[];
  34821. sideOrientation?: number;
  34822. }): VertexData;
  34823. /**
  34824. * Creates the VertexData for a tiled plane
  34825. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34826. * * pattern a limited pattern arrangement depending on the number
  34827. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34828. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34829. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34831. * * 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)
  34832. * * 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)
  34833. * @returns the VertexData of the tiled plane
  34834. */
  34835. static CreateTiledPlane(options: {
  34836. pattern?: number;
  34837. tileSize?: number;
  34838. tileWidth?: number;
  34839. tileHeight?: number;
  34840. size?: number;
  34841. width?: number;
  34842. height?: number;
  34843. alignHorizontal?: number;
  34844. alignVertical?: number;
  34845. sideOrientation?: number;
  34846. frontUVs?: Vector4;
  34847. backUVs?: Vector4;
  34848. }): VertexData;
  34849. /**
  34850. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34852. * * segments sets the number of horizontal strips optional, default 32
  34853. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34854. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34855. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34856. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34857. * * 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
  34858. * * 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
  34859. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34860. * * 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)
  34861. * * 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)
  34862. * @returns the VertexData of the ellipsoid
  34863. */
  34864. static CreateSphere(options: {
  34865. segments?: number;
  34866. diameter?: number;
  34867. diameterX?: number;
  34868. diameterY?: number;
  34869. diameterZ?: number;
  34870. arc?: number;
  34871. slice?: number;
  34872. sideOrientation?: number;
  34873. frontUVs?: Vector4;
  34874. backUVs?: Vector4;
  34875. }): VertexData;
  34876. /**
  34877. * Creates the VertexData for a cylinder, cone or prism
  34878. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34879. * * height sets the height (y direction) of the cylinder, optional, default 2
  34880. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34881. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34882. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34883. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34884. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34885. * * 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
  34886. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34887. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34888. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34889. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34891. * * 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)
  34892. * * 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)
  34893. * @returns the VertexData of the cylinder, cone or prism
  34894. */
  34895. static CreateCylinder(options: {
  34896. height?: number;
  34897. diameterTop?: number;
  34898. diameterBottom?: number;
  34899. diameter?: number;
  34900. tessellation?: number;
  34901. subdivisions?: number;
  34902. arc?: number;
  34903. faceColors?: Color4[];
  34904. faceUV?: Vector4[];
  34905. hasRings?: boolean;
  34906. enclose?: boolean;
  34907. sideOrientation?: number;
  34908. frontUVs?: Vector4;
  34909. backUVs?: Vector4;
  34910. }): VertexData;
  34911. /**
  34912. * Creates the VertexData for a torus
  34913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34914. * * diameter the diameter of the torus, optional default 1
  34915. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34916. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34918. * * 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)
  34919. * * 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)
  34920. * @returns the VertexData of the torus
  34921. */
  34922. static CreateTorus(options: {
  34923. diameter?: number;
  34924. thickness?: number;
  34925. tessellation?: number;
  34926. sideOrientation?: number;
  34927. frontUVs?: Vector4;
  34928. backUVs?: Vector4;
  34929. }): VertexData;
  34930. /**
  34931. * Creates the VertexData of the LineSystem
  34932. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34933. * - lines an array of lines, each line being an array of successive Vector3
  34934. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34935. * @returns the VertexData of the LineSystem
  34936. */
  34937. static CreateLineSystem(options: {
  34938. lines: Vector3[][];
  34939. colors?: Nullable<Color4[][]>;
  34940. }): VertexData;
  34941. /**
  34942. * Create the VertexData for a DashedLines
  34943. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34944. * - points an array successive Vector3
  34945. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34946. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34947. * - dashNb the intended total number of dashes, optional, default 200
  34948. * @returns the VertexData for the DashedLines
  34949. */
  34950. static CreateDashedLines(options: {
  34951. points: Vector3[];
  34952. dashSize?: number;
  34953. gapSize?: number;
  34954. dashNb?: number;
  34955. }): VertexData;
  34956. /**
  34957. * Creates the VertexData for a Ground
  34958. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34959. * - width the width (x direction) of the ground, optional, default 1
  34960. * - height the height (z direction) of the ground, optional, default 1
  34961. * - subdivisions the number of subdivisions per side, optional, default 1
  34962. * @returns the VertexData of the Ground
  34963. */
  34964. static CreateGround(options: {
  34965. width?: number;
  34966. height?: number;
  34967. subdivisions?: number;
  34968. subdivisionsX?: number;
  34969. subdivisionsY?: number;
  34970. }): VertexData;
  34971. /**
  34972. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34973. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34974. * * xmin the ground minimum X coordinate, optional, default -1
  34975. * * zmin the ground minimum Z coordinate, optional, default -1
  34976. * * xmax the ground maximum X coordinate, optional, default 1
  34977. * * zmax the ground maximum Z coordinate, optional, default 1
  34978. * * 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}
  34979. * * 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}
  34980. * @returns the VertexData of the TiledGround
  34981. */
  34982. static CreateTiledGround(options: {
  34983. xmin: number;
  34984. zmin: number;
  34985. xmax: number;
  34986. zmax: number;
  34987. subdivisions?: {
  34988. w: number;
  34989. h: number;
  34990. };
  34991. precision?: {
  34992. w: number;
  34993. h: number;
  34994. };
  34995. }): VertexData;
  34996. /**
  34997. * Creates the VertexData of the Ground designed from a heightmap
  34998. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34999. * * width the width (x direction) of the ground
  35000. * * height the height (z direction) of the ground
  35001. * * subdivisions the number of subdivisions per side
  35002. * * minHeight the minimum altitude on the ground, optional, default 0
  35003. * * maxHeight the maximum altitude on the ground, optional default 1
  35004. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35005. * * buffer the array holding the image color data
  35006. * * bufferWidth the width of image
  35007. * * bufferHeight the height of image
  35008. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35009. * @returns the VertexData of the Ground designed from a heightmap
  35010. */
  35011. static CreateGroundFromHeightMap(options: {
  35012. width: number;
  35013. height: number;
  35014. subdivisions: number;
  35015. minHeight: number;
  35016. maxHeight: number;
  35017. colorFilter: Color3;
  35018. buffer: Uint8Array;
  35019. bufferWidth: number;
  35020. bufferHeight: number;
  35021. alphaFilter: number;
  35022. }): VertexData;
  35023. /**
  35024. * Creates the VertexData for a Plane
  35025. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35026. * * size sets the width and height of the plane to the value of size, optional default 1
  35027. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35028. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35030. * * 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)
  35031. * * 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)
  35032. * @returns the VertexData of the box
  35033. */
  35034. static CreatePlane(options: {
  35035. size?: number;
  35036. width?: number;
  35037. height?: number;
  35038. sideOrientation?: number;
  35039. frontUVs?: Vector4;
  35040. backUVs?: Vector4;
  35041. }): VertexData;
  35042. /**
  35043. * Creates the VertexData of the Disc or regular Polygon
  35044. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35045. * * radius the radius of the disc, optional default 0.5
  35046. * * tessellation the number of polygon sides, optional, default 64
  35047. * * 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
  35048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35049. * * 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)
  35050. * * 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)
  35051. * @returns the VertexData of the box
  35052. */
  35053. static CreateDisc(options: {
  35054. radius?: number;
  35055. tessellation?: number;
  35056. arc?: number;
  35057. sideOrientation?: number;
  35058. frontUVs?: Vector4;
  35059. backUVs?: Vector4;
  35060. }): VertexData;
  35061. /**
  35062. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35063. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35064. * @param polygon a mesh built from polygonTriangulation.build()
  35065. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35066. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35067. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35068. * @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)
  35069. * @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)
  35070. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35071. * @returns the VertexData of the Polygon
  35072. */
  35073. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35074. /**
  35075. * Creates the VertexData of the IcoSphere
  35076. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35077. * * radius the radius of the IcoSphere, optional default 1
  35078. * * radiusX allows stretching in the x direction, optional, default radius
  35079. * * radiusY allows stretching in the y direction, optional, default radius
  35080. * * radiusZ allows stretching in the z direction, optional, default radius
  35081. * * flat when true creates a flat shaded mesh, optional, default true
  35082. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35084. * * 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)
  35085. * * 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)
  35086. * @returns the VertexData of the IcoSphere
  35087. */
  35088. static CreateIcoSphere(options: {
  35089. radius?: number;
  35090. radiusX?: number;
  35091. radiusY?: number;
  35092. radiusZ?: number;
  35093. flat?: boolean;
  35094. subdivisions?: number;
  35095. sideOrientation?: number;
  35096. frontUVs?: Vector4;
  35097. backUVs?: Vector4;
  35098. }): VertexData;
  35099. /**
  35100. * Creates the VertexData for a Polyhedron
  35101. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35102. * * type provided types are:
  35103. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35104. * * 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)
  35105. * * size the size of the IcoSphere, optional default 1
  35106. * * sizeX allows stretching in the x direction, optional, default size
  35107. * * sizeY allows stretching in the y direction, optional, default size
  35108. * * sizeZ allows stretching in the z direction, optional, default size
  35109. * * 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
  35110. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35111. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35112. * * flat when true creates a flat shaded mesh, optional, default true
  35113. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35115. * * 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)
  35116. * * 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)
  35117. * @returns the VertexData of the Polyhedron
  35118. */
  35119. static CreatePolyhedron(options: {
  35120. type?: number;
  35121. size?: number;
  35122. sizeX?: number;
  35123. sizeY?: number;
  35124. sizeZ?: number;
  35125. custom?: any;
  35126. faceUV?: Vector4[];
  35127. faceColors?: Color4[];
  35128. flat?: boolean;
  35129. sideOrientation?: number;
  35130. frontUVs?: Vector4;
  35131. backUVs?: Vector4;
  35132. }): VertexData;
  35133. /**
  35134. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35135. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35136. * @returns the VertexData of the Capsule
  35137. */
  35138. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35139. /**
  35140. * Creates the VertexData for a TorusKnot
  35141. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35142. * * radius the radius of the torus knot, optional, default 2
  35143. * * tube the thickness of the tube, optional, default 0.5
  35144. * * radialSegments the number of sides on each tube segments, optional, default 32
  35145. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35146. * * p the number of windings around the z axis, optional, default 2
  35147. * * q the number of windings around the x axis, optional, default 3
  35148. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35149. * * 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)
  35150. * * 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)
  35151. * @returns the VertexData of the Torus Knot
  35152. */
  35153. static CreateTorusKnot(options: {
  35154. radius?: number;
  35155. tube?: number;
  35156. radialSegments?: number;
  35157. tubularSegments?: number;
  35158. p?: number;
  35159. q?: number;
  35160. sideOrientation?: number;
  35161. frontUVs?: Vector4;
  35162. backUVs?: Vector4;
  35163. }): VertexData;
  35164. /**
  35165. * Compute normals for given positions and indices
  35166. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35167. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35168. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35169. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35170. * * facetNormals : optional array of facet normals (vector3)
  35171. * * facetPositions : optional array of facet positions (vector3)
  35172. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35173. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35174. * * bInfo : optional bounding info, required for facetPartitioning computation
  35175. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35176. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35177. * * useRightHandedSystem: optional boolean to for right handed system computation
  35178. * * depthSort : optional boolean to enable the facet depth sort computation
  35179. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35180. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35181. */
  35182. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35183. facetNormals?: any;
  35184. facetPositions?: any;
  35185. facetPartitioning?: any;
  35186. ratio?: number;
  35187. bInfo?: any;
  35188. bbSize?: Vector3;
  35189. subDiv?: any;
  35190. useRightHandedSystem?: boolean;
  35191. depthSort?: boolean;
  35192. distanceTo?: Vector3;
  35193. depthSortedFacets?: any;
  35194. }): void;
  35195. /** @hidden */
  35196. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35197. /**
  35198. * Applies VertexData created from the imported parameters to the geometry
  35199. * @param parsedVertexData the parsed data from an imported file
  35200. * @param geometry the geometry to apply the VertexData to
  35201. */
  35202. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35203. }
  35204. }
  35205. declare module BABYLON {
  35206. /**
  35207. * Class containing static functions to help procedurally build meshes
  35208. */
  35209. export class DiscBuilder {
  35210. /**
  35211. * Creates a plane polygonal mesh. By default, this is a disc
  35212. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35213. * * 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
  35214. * * 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
  35215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35216. * * 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
  35217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35218. * @param name defines the name of the mesh
  35219. * @param options defines the options used to create the mesh
  35220. * @param scene defines the hosting scene
  35221. * @returns the plane polygonal mesh
  35222. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35223. */
  35224. static CreateDisc(name: string, options: {
  35225. radius?: number;
  35226. tessellation?: number;
  35227. arc?: number;
  35228. updatable?: boolean;
  35229. sideOrientation?: number;
  35230. frontUVs?: Vector4;
  35231. backUVs?: Vector4;
  35232. }, scene?: Nullable<Scene>): Mesh;
  35233. }
  35234. }
  35235. declare module BABYLON {
  35236. /**
  35237. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35238. *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.
  35239. * The SPS is also a particle system. It provides some methods to manage the particles.
  35240. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35241. *
  35242. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35243. */
  35244. export class SolidParticleSystem implements IDisposable {
  35245. /**
  35246. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35247. * Example : var p = SPS.particles[i];
  35248. */
  35249. particles: SolidParticle[];
  35250. /**
  35251. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35252. */
  35253. nbParticles: number;
  35254. /**
  35255. * If the particles must ever face the camera (default false). Useful for planar particles.
  35256. */
  35257. billboard: boolean;
  35258. /**
  35259. * Recompute normals when adding a shape
  35260. */
  35261. recomputeNormals: boolean;
  35262. /**
  35263. * This a counter ofr your own usage. It's not set by any SPS functions.
  35264. */
  35265. counter: number;
  35266. /**
  35267. * The SPS name. This name is also given to the underlying mesh.
  35268. */
  35269. name: string;
  35270. /**
  35271. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35272. */
  35273. mesh: Mesh;
  35274. /**
  35275. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35276. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35277. */
  35278. vars: any;
  35279. /**
  35280. * This array is populated when the SPS is set as 'pickable'.
  35281. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35282. * Each element of this array is an object `{idx: int, faceId: int}`.
  35283. * `idx` is the picked particle index in the `SPS.particles` array
  35284. * `faceId` is the picked face index counted within this particle.
  35285. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35286. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35287. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35288. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35289. */
  35290. pickedParticles: {
  35291. idx: number;
  35292. faceId: number;
  35293. }[];
  35294. /**
  35295. * This array is populated when the SPS is set as 'pickable'
  35296. * Each key of this array is a submesh index.
  35297. * Each element of this array is a second array defined like this :
  35298. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35299. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35300. * `idx` is the picked particle index in the `SPS.particles` array
  35301. * `faceId` is the picked face index counted within this particle.
  35302. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35303. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35304. */
  35305. pickedBySubMesh: {
  35306. idx: number;
  35307. faceId: number;
  35308. }[][];
  35309. /**
  35310. * This array is populated when `enableDepthSort` is set to true.
  35311. * Each element of this array is an instance of the class DepthSortedParticle.
  35312. */
  35313. depthSortedParticles: DepthSortedParticle[];
  35314. /**
  35315. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35316. * @hidden
  35317. */
  35318. _bSphereOnly: boolean;
  35319. /**
  35320. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35321. * @hidden
  35322. */
  35323. _bSphereRadiusFactor: number;
  35324. private _scene;
  35325. private _positions;
  35326. private _indices;
  35327. private _normals;
  35328. private _colors;
  35329. private _uvs;
  35330. private _indices32;
  35331. private _positions32;
  35332. private _normals32;
  35333. private _fixedNormal32;
  35334. private _colors32;
  35335. private _uvs32;
  35336. private _index;
  35337. private _updatable;
  35338. private _pickable;
  35339. private _isVisibilityBoxLocked;
  35340. private _alwaysVisible;
  35341. private _depthSort;
  35342. private _expandable;
  35343. private _shapeCounter;
  35344. private _copy;
  35345. private _color;
  35346. private _computeParticleColor;
  35347. private _computeParticleTexture;
  35348. private _computeParticleRotation;
  35349. private _computeParticleVertex;
  35350. private _computeBoundingBox;
  35351. private _depthSortParticles;
  35352. private _camera;
  35353. private _mustUnrotateFixedNormals;
  35354. private _particlesIntersect;
  35355. private _needs32Bits;
  35356. private _isNotBuilt;
  35357. private _lastParticleId;
  35358. private _idxOfId;
  35359. private _multimaterialEnabled;
  35360. private _useModelMaterial;
  35361. private _indicesByMaterial;
  35362. private _materialIndexes;
  35363. private _depthSortFunction;
  35364. private _materialSortFunction;
  35365. private _materials;
  35366. private _multimaterial;
  35367. private _materialIndexesById;
  35368. private _defaultMaterial;
  35369. private _autoUpdateSubMeshes;
  35370. private _tmpVertex;
  35371. /**
  35372. * Creates a SPS (Solid Particle System) object.
  35373. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35374. * @param scene (Scene) is the scene in which the SPS is added.
  35375. * @param options defines the options of the sps e.g.
  35376. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35377. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35378. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35379. * * 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.
  35380. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35381. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35382. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35383. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35384. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35385. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35386. */
  35387. constructor(name: string, scene: Scene, options?: {
  35388. updatable?: boolean;
  35389. isPickable?: boolean;
  35390. enableDepthSort?: boolean;
  35391. particleIntersection?: boolean;
  35392. boundingSphereOnly?: boolean;
  35393. bSphereRadiusFactor?: number;
  35394. expandable?: boolean;
  35395. useModelMaterial?: boolean;
  35396. enableMultiMaterial?: boolean;
  35397. });
  35398. /**
  35399. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35400. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35401. * @returns the created mesh
  35402. */
  35403. buildMesh(): Mesh;
  35404. /**
  35405. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35406. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35407. * Thus the particles generated from `digest()` have their property `position` set yet.
  35408. * @param mesh ( Mesh ) is the mesh to be digested
  35409. * @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
  35410. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35411. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35412. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35413. * @returns the current SPS
  35414. */
  35415. digest(mesh: Mesh, options?: {
  35416. facetNb?: number;
  35417. number?: number;
  35418. delta?: number;
  35419. storage?: [];
  35420. }): SolidParticleSystem;
  35421. /**
  35422. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35423. * @hidden
  35424. */
  35425. private _unrotateFixedNormals;
  35426. /**
  35427. * Resets the temporary working copy particle
  35428. * @hidden
  35429. */
  35430. private _resetCopy;
  35431. /**
  35432. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35433. * @param p the current index in the positions array to be updated
  35434. * @param ind the current index in the indices array
  35435. * @param shape a Vector3 array, the shape geometry
  35436. * @param positions the positions array to be updated
  35437. * @param meshInd the shape indices array
  35438. * @param indices the indices array to be updated
  35439. * @param meshUV the shape uv array
  35440. * @param uvs the uv array to be updated
  35441. * @param meshCol the shape color array
  35442. * @param colors the color array to be updated
  35443. * @param meshNor the shape normals array
  35444. * @param normals the normals array to be updated
  35445. * @param idx the particle index
  35446. * @param idxInShape the particle index in its shape
  35447. * @param options the addShape() method passed options
  35448. * @model the particle model
  35449. * @hidden
  35450. */
  35451. private _meshBuilder;
  35452. /**
  35453. * Returns a shape Vector3 array from positions float array
  35454. * @param positions float array
  35455. * @returns a vector3 array
  35456. * @hidden
  35457. */
  35458. private _posToShape;
  35459. /**
  35460. * Returns a shapeUV array from a float uvs (array deep copy)
  35461. * @param uvs as a float array
  35462. * @returns a shapeUV array
  35463. * @hidden
  35464. */
  35465. private _uvsToShapeUV;
  35466. /**
  35467. * Adds a new particle object in the particles array
  35468. * @param idx particle index in particles array
  35469. * @param id particle id
  35470. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35471. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35472. * @param model particle ModelShape object
  35473. * @param shapeId model shape identifier
  35474. * @param idxInShape index of the particle in the current model
  35475. * @param bInfo model bounding info object
  35476. * @param storage target storage array, if any
  35477. * @hidden
  35478. */
  35479. private _addParticle;
  35480. /**
  35481. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35482. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35483. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35484. * @param nb (positive integer) the number of particles to be created from this model
  35485. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35486. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35487. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35488. * @returns the number of shapes in the system
  35489. */
  35490. addShape(mesh: Mesh, nb: number, options?: {
  35491. positionFunction?: any;
  35492. vertexFunction?: any;
  35493. storage?: [];
  35494. }): number;
  35495. /**
  35496. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35497. * @hidden
  35498. */
  35499. private _rebuildParticle;
  35500. /**
  35501. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35502. * @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.
  35503. * @returns the SPS.
  35504. */
  35505. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35506. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35507. * Returns an array with the removed particles.
  35508. * 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.
  35509. * The SPS can't be empty so at least one particle needs to remain in place.
  35510. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35511. * @param start index of the first particle to remove
  35512. * @param end index of the last particle to remove (included)
  35513. * @returns an array populated with the removed particles
  35514. */
  35515. removeParticles(start: number, end: number): SolidParticle[];
  35516. /**
  35517. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35518. * @param solidParticleArray an array populated with Solid Particles objects
  35519. * @returns the SPS
  35520. */
  35521. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35522. /**
  35523. * Creates a new particle and modifies the SPS mesh geometry :
  35524. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35525. * - calls _addParticle() to populate the particle array
  35526. * factorized code from addShape() and insertParticlesFromArray()
  35527. * @param idx particle index in the particles array
  35528. * @param i particle index in its shape
  35529. * @param modelShape particle ModelShape object
  35530. * @param shape shape vertex array
  35531. * @param meshInd shape indices array
  35532. * @param meshUV shape uv array
  35533. * @param meshCol shape color array
  35534. * @param meshNor shape normals array
  35535. * @param bbInfo shape bounding info
  35536. * @param storage target particle storage
  35537. * @options addShape() passed options
  35538. * @hidden
  35539. */
  35540. private _insertNewParticle;
  35541. /**
  35542. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35543. * This method calls `updateParticle()` for each particle of the SPS.
  35544. * For an animated SPS, it is usually called within the render loop.
  35545. * 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.
  35546. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35547. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35548. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35549. * @returns the SPS.
  35550. */
  35551. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35552. /**
  35553. * Disposes the SPS.
  35554. */
  35555. dispose(): void;
  35556. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35557. * idx is the particle index in the SPS
  35558. * faceId is the picked face index counted within this particle.
  35559. * Returns null if the pickInfo can't identify a picked particle.
  35560. * @param pickingInfo (PickingInfo object)
  35561. * @returns {idx: number, faceId: number} or null
  35562. */
  35563. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35564. idx: number;
  35565. faceId: number;
  35566. }>;
  35567. /**
  35568. * Returns a SolidParticle object from its identifier : particle.id
  35569. * @param id (integer) the particle Id
  35570. * @returns the searched particle or null if not found in the SPS.
  35571. */
  35572. getParticleById(id: number): Nullable<SolidParticle>;
  35573. /**
  35574. * Returns a new array populated with the particles having the passed shapeId.
  35575. * @param shapeId (integer) the shape identifier
  35576. * @returns a new solid particle array
  35577. */
  35578. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35579. /**
  35580. * Populates the passed array "ref" with the particles having the passed shapeId.
  35581. * @param shapeId the shape identifier
  35582. * @returns the SPS
  35583. * @param ref
  35584. */
  35585. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35586. /**
  35587. * Computes the required SubMeshes according the materials assigned to the particles.
  35588. * @returns the solid particle system.
  35589. * Does nothing if called before the SPS mesh is built.
  35590. */
  35591. computeSubMeshes(): SolidParticleSystem;
  35592. /**
  35593. * Sorts the solid particles by material when MultiMaterial is enabled.
  35594. * Updates the indices32 array.
  35595. * Updates the indicesByMaterial array.
  35596. * Updates the mesh indices array.
  35597. * @returns the SPS
  35598. * @hidden
  35599. */
  35600. private _sortParticlesByMaterial;
  35601. /**
  35602. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35603. * @hidden
  35604. */
  35605. private _setMaterialIndexesById;
  35606. /**
  35607. * Returns an array with unique values of Materials from the passed array
  35608. * @param array the material array to be checked and filtered
  35609. * @hidden
  35610. */
  35611. private _filterUniqueMaterialId;
  35612. /**
  35613. * Sets a new Standard Material as _defaultMaterial if not already set.
  35614. * @hidden
  35615. */
  35616. private _setDefaultMaterial;
  35617. /**
  35618. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35620. * @returns the SPS.
  35621. */
  35622. refreshVisibleSize(): SolidParticleSystem;
  35623. /**
  35624. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35625. * @param size the size (float) of the visibility box
  35626. * note : this doesn't lock the SPS mesh bounding box.
  35627. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35628. */
  35629. setVisibilityBox(size: number): void;
  35630. /**
  35631. * Gets whether the SPS as always visible or not
  35632. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35633. */
  35634. get isAlwaysVisible(): boolean;
  35635. /**
  35636. * Sets the SPS as always visible or not
  35637. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35638. */
  35639. set isAlwaysVisible(val: boolean);
  35640. /**
  35641. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35642. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35643. */
  35644. set isVisibilityBoxLocked(val: boolean);
  35645. /**
  35646. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35647. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35648. */
  35649. get isVisibilityBoxLocked(): boolean;
  35650. /**
  35651. * Tells to `setParticles()` to compute the particle rotations or not.
  35652. * Default value : true. The SPS is faster when it's set to false.
  35653. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35654. */
  35655. set computeParticleRotation(val: boolean);
  35656. /**
  35657. * Tells to `setParticles()` to compute the particle colors or not.
  35658. * Default value : true. The SPS is faster when it's set to false.
  35659. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35660. */
  35661. set computeParticleColor(val: boolean);
  35662. set computeParticleTexture(val: boolean);
  35663. /**
  35664. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35665. * Default value : false. The SPS is faster when it's set to false.
  35666. * Note : the particle custom vertex positions aren't stored values.
  35667. */
  35668. set computeParticleVertex(val: boolean);
  35669. /**
  35670. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35671. */
  35672. set computeBoundingBox(val: boolean);
  35673. /**
  35674. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35675. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35676. * Default : `true`
  35677. */
  35678. set depthSortParticles(val: boolean);
  35679. /**
  35680. * Gets if `setParticles()` computes the particle rotations or not.
  35681. * Default value : true. The SPS is faster when it's set to false.
  35682. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35683. */
  35684. get computeParticleRotation(): boolean;
  35685. /**
  35686. * Gets if `setParticles()` computes the particle colors or not.
  35687. * Default value : true. The SPS is faster when it's set to false.
  35688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35689. */
  35690. get computeParticleColor(): boolean;
  35691. /**
  35692. * Gets if `setParticles()` computes the particle textures or not.
  35693. * Default value : true. The SPS is faster when it's set to false.
  35694. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35695. */
  35696. get computeParticleTexture(): boolean;
  35697. /**
  35698. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35699. * Default value : false. The SPS is faster when it's set to false.
  35700. * Note : the particle custom vertex positions aren't stored values.
  35701. */
  35702. get computeParticleVertex(): boolean;
  35703. /**
  35704. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35705. */
  35706. get computeBoundingBox(): boolean;
  35707. /**
  35708. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35709. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35710. * Default : `true`
  35711. */
  35712. get depthSortParticles(): boolean;
  35713. /**
  35714. * Gets if the SPS is created as expandable at construction time.
  35715. * Default : `false`
  35716. */
  35717. get expandable(): boolean;
  35718. /**
  35719. * Gets if the SPS supports the Multi Materials
  35720. */
  35721. get multimaterialEnabled(): boolean;
  35722. /**
  35723. * Gets if the SPS uses the model materials for its own multimaterial.
  35724. */
  35725. get useModelMaterial(): boolean;
  35726. /**
  35727. * The SPS used material array.
  35728. */
  35729. get materials(): Material[];
  35730. /**
  35731. * Sets the SPS MultiMaterial from the passed materials.
  35732. * Note : the passed array is internally copied and not used then by reference.
  35733. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35734. */
  35735. setMultiMaterial(materials: Material[]): void;
  35736. /**
  35737. * The SPS computed multimaterial object
  35738. */
  35739. get multimaterial(): MultiMaterial;
  35740. set multimaterial(mm: MultiMaterial);
  35741. /**
  35742. * If the subMeshes must be updated on the next call to setParticles()
  35743. */
  35744. get autoUpdateSubMeshes(): boolean;
  35745. set autoUpdateSubMeshes(val: boolean);
  35746. /**
  35747. * This function does nothing. It may be overwritten to set all the particle first values.
  35748. * The SPS doesn't call this function, you may have to call it by your own.
  35749. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35750. */
  35751. initParticles(): void;
  35752. /**
  35753. * This function does nothing. It may be overwritten to recycle a particle.
  35754. * The SPS doesn't call this function, you may have to call it by your own.
  35755. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35756. * @param particle The particle to recycle
  35757. * @returns the recycled particle
  35758. */
  35759. recycleParticle(particle: SolidParticle): SolidParticle;
  35760. /**
  35761. * Updates a particle : this function should be overwritten by the user.
  35762. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35763. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35764. * @example : just set a particle position or velocity and recycle conditions
  35765. * @param particle The particle to update
  35766. * @returns the updated particle
  35767. */
  35768. updateParticle(particle: SolidParticle): SolidParticle;
  35769. /**
  35770. * Updates a vertex of a particle : it can be overwritten by the user.
  35771. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35772. * @param particle the current particle
  35773. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35774. * @param pt the index of the current vertex in the particle shape
  35775. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35776. * @example : just set a vertex particle position or color
  35777. * @returns the sps
  35778. */
  35779. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35780. /**
  35781. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35782. * This does nothing and may be overwritten by the user.
  35783. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35784. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35785. * @param update the boolean update value actually passed to setParticles()
  35786. */
  35787. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35788. /**
  35789. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35790. * This will be passed three parameters.
  35791. * This does nothing and may be overwritten by the user.
  35792. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35793. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35794. * @param update the boolean update value actually passed to setParticles()
  35795. */
  35796. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35797. }
  35798. }
  35799. declare module BABYLON {
  35800. /**
  35801. * Represents one particle of a solid particle system.
  35802. */
  35803. export class SolidParticle {
  35804. /**
  35805. * particle global index
  35806. */
  35807. idx: number;
  35808. /**
  35809. * particle identifier
  35810. */
  35811. id: number;
  35812. /**
  35813. * The color of the particle
  35814. */
  35815. color: Nullable<Color4>;
  35816. /**
  35817. * The world space position of the particle.
  35818. */
  35819. position: Vector3;
  35820. /**
  35821. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35822. */
  35823. rotation: Vector3;
  35824. /**
  35825. * The world space rotation quaternion of the particle.
  35826. */
  35827. rotationQuaternion: Nullable<Quaternion>;
  35828. /**
  35829. * The scaling of the particle.
  35830. */
  35831. scaling: Vector3;
  35832. /**
  35833. * The uvs of the particle.
  35834. */
  35835. uvs: Vector4;
  35836. /**
  35837. * The current speed of the particle.
  35838. */
  35839. velocity: Vector3;
  35840. /**
  35841. * The pivot point in the particle local space.
  35842. */
  35843. pivot: Vector3;
  35844. /**
  35845. * Must the particle be translated from its pivot point in its local space ?
  35846. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35847. * Default : false
  35848. */
  35849. translateFromPivot: boolean;
  35850. /**
  35851. * Is the particle active or not ?
  35852. */
  35853. alive: boolean;
  35854. /**
  35855. * Is the particle visible or not ?
  35856. */
  35857. isVisible: boolean;
  35858. /**
  35859. * Index of this particle in the global "positions" array (Internal use)
  35860. * @hidden
  35861. */
  35862. _pos: number;
  35863. /**
  35864. * @hidden Index of this particle in the global "indices" array (Internal use)
  35865. */
  35866. _ind: number;
  35867. /**
  35868. * @hidden ModelShape of this particle (Internal use)
  35869. */
  35870. _model: ModelShape;
  35871. /**
  35872. * ModelShape id of this particle
  35873. */
  35874. shapeId: number;
  35875. /**
  35876. * Index of the particle in its shape id
  35877. */
  35878. idxInShape: number;
  35879. /**
  35880. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35881. */
  35882. _modelBoundingInfo: BoundingInfo;
  35883. /**
  35884. * @hidden Particle BoundingInfo object (Internal use)
  35885. */
  35886. _boundingInfo: BoundingInfo;
  35887. /**
  35888. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35889. */
  35890. _sps: SolidParticleSystem;
  35891. /**
  35892. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35893. */
  35894. _stillInvisible: boolean;
  35895. /**
  35896. * @hidden Last computed particle rotation matrix
  35897. */
  35898. _rotationMatrix: number[];
  35899. /**
  35900. * Parent particle Id, if any.
  35901. * Default null.
  35902. */
  35903. parentId: Nullable<number>;
  35904. /**
  35905. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35906. */
  35907. materialIndex: Nullable<number>;
  35908. /**
  35909. * Custom object or properties.
  35910. */
  35911. props: Nullable<any>;
  35912. /**
  35913. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35914. * The possible values are :
  35915. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35916. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35918. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35919. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35920. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35921. * */
  35922. cullingStrategy: number;
  35923. /**
  35924. * @hidden Internal global position in the SPS.
  35925. */
  35926. _globalPosition: Vector3;
  35927. /**
  35928. * Creates a Solid Particle object.
  35929. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35930. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35931. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35932. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35933. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35934. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35935. * @param shapeId (integer) is the model shape identifier in the SPS.
  35936. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35937. * @param sps defines the sps it is associated to
  35938. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35939. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35940. */
  35941. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35942. /**
  35943. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35944. * @param target the particle target
  35945. * @returns the current particle
  35946. */
  35947. copyToRef(target: SolidParticle): SolidParticle;
  35948. /**
  35949. * Legacy support, changed scale to scaling
  35950. */
  35951. get scale(): Vector3;
  35952. /**
  35953. * Legacy support, changed scale to scaling
  35954. */
  35955. set scale(scale: Vector3);
  35956. /**
  35957. * Legacy support, changed quaternion to rotationQuaternion
  35958. */
  35959. get quaternion(): Nullable<Quaternion>;
  35960. /**
  35961. * Legacy support, changed quaternion to rotationQuaternion
  35962. */
  35963. set quaternion(q: Nullable<Quaternion>);
  35964. /**
  35965. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35966. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35967. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35968. * @returns true if it intersects
  35969. */
  35970. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35971. /**
  35972. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35973. * A particle is in the frustum if its bounding box intersects the frustum
  35974. * @param frustumPlanes defines the frustum to test
  35975. * @returns true if the particle is in the frustum planes
  35976. */
  35977. isInFrustum(frustumPlanes: Plane[]): boolean;
  35978. /**
  35979. * get the rotation matrix of the particle
  35980. * @hidden
  35981. */
  35982. getRotationMatrix(m: Matrix): void;
  35983. }
  35984. /**
  35985. * Represents the shape of the model used by one particle of a solid particle system.
  35986. * SPS internal tool, don't use it manually.
  35987. */
  35988. export class ModelShape {
  35989. /**
  35990. * The shape id
  35991. * @hidden
  35992. */
  35993. shapeID: number;
  35994. /**
  35995. * flat array of model positions (internal use)
  35996. * @hidden
  35997. */
  35998. _shape: Vector3[];
  35999. /**
  36000. * flat array of model UVs (internal use)
  36001. * @hidden
  36002. */
  36003. _shapeUV: number[];
  36004. /**
  36005. * color array of the model
  36006. * @hidden
  36007. */
  36008. _shapeColors: number[];
  36009. /**
  36010. * indices array of the model
  36011. * @hidden
  36012. */
  36013. _indices: number[];
  36014. /**
  36015. * normals array of the model
  36016. * @hidden
  36017. */
  36018. _normals: number[];
  36019. /**
  36020. * length of the shape in the model indices array (internal use)
  36021. * @hidden
  36022. */
  36023. _indicesLength: number;
  36024. /**
  36025. * Custom position function (internal use)
  36026. * @hidden
  36027. */
  36028. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36029. /**
  36030. * Custom vertex function (internal use)
  36031. * @hidden
  36032. */
  36033. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36034. /**
  36035. * Model material (internal use)
  36036. * @hidden
  36037. */
  36038. _material: Nullable<Material>;
  36039. /**
  36040. * 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.
  36041. * SPS internal tool, don't use it manually.
  36042. * @hidden
  36043. */
  36044. 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>);
  36045. }
  36046. /**
  36047. * Represents a Depth Sorted Particle in the solid particle system.
  36048. * @hidden
  36049. */
  36050. export class DepthSortedParticle {
  36051. /**
  36052. * Particle index
  36053. */
  36054. idx: number;
  36055. /**
  36056. * Index of the particle in the "indices" array
  36057. */
  36058. ind: number;
  36059. /**
  36060. * Length of the particle shape in the "indices" array
  36061. */
  36062. indicesLength: number;
  36063. /**
  36064. * Squared distance from the particle to the camera
  36065. */
  36066. sqDistance: number;
  36067. /**
  36068. * Material index when used with MultiMaterials
  36069. */
  36070. materialIndex: number;
  36071. /**
  36072. * Creates a new sorted particle
  36073. * @param materialIndex
  36074. */
  36075. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36076. }
  36077. /**
  36078. * Represents a solid particle vertex
  36079. */
  36080. export class SolidParticleVertex {
  36081. /**
  36082. * Vertex position
  36083. */
  36084. position: Vector3;
  36085. /**
  36086. * Vertex color
  36087. */
  36088. color: Color4;
  36089. /**
  36090. * Vertex UV
  36091. */
  36092. uv: Vector2;
  36093. /**
  36094. * Creates a new solid particle vertex
  36095. */
  36096. constructor();
  36097. /** Vertex x coordinate */
  36098. get x(): number;
  36099. set x(val: number);
  36100. /** Vertex y coordinate */
  36101. get y(): number;
  36102. set y(val: number);
  36103. /** Vertex z coordinate */
  36104. get z(): number;
  36105. set z(val: number);
  36106. }
  36107. }
  36108. declare module BABYLON {
  36109. /**
  36110. * @hidden
  36111. */
  36112. export class _MeshCollisionData {
  36113. _checkCollisions: boolean;
  36114. _collisionMask: number;
  36115. _collisionGroup: number;
  36116. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36117. _collider: Nullable<Collider>;
  36118. _oldPositionForCollisions: Vector3;
  36119. _diffPositionForCollisions: Vector3;
  36120. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36121. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36122. _collisionResponse: boolean;
  36123. }
  36124. }
  36125. declare module BABYLON {
  36126. /** @hidden */
  36127. class _FacetDataStorage {
  36128. facetPositions: Vector3[];
  36129. facetNormals: Vector3[];
  36130. facetPartitioning: number[][];
  36131. facetNb: number;
  36132. partitioningSubdivisions: number;
  36133. partitioningBBoxRatio: number;
  36134. facetDataEnabled: boolean;
  36135. facetParameters: any;
  36136. bbSize: Vector3;
  36137. subDiv: {
  36138. max: number;
  36139. X: number;
  36140. Y: number;
  36141. Z: number;
  36142. };
  36143. facetDepthSort: boolean;
  36144. facetDepthSortEnabled: boolean;
  36145. depthSortedIndices: IndicesArray;
  36146. depthSortedFacets: {
  36147. ind: number;
  36148. sqDistance: number;
  36149. }[];
  36150. facetDepthSortFunction: (f1: {
  36151. ind: number;
  36152. sqDistance: number;
  36153. }, f2: {
  36154. ind: number;
  36155. sqDistance: number;
  36156. }) => number;
  36157. facetDepthSortFrom: Vector3;
  36158. facetDepthSortOrigin: Vector3;
  36159. invertedMatrix: Matrix;
  36160. }
  36161. /**
  36162. * @hidden
  36163. **/
  36164. class _InternalAbstractMeshDataInfo {
  36165. _hasVertexAlpha: boolean;
  36166. _useVertexColors: boolean;
  36167. _numBoneInfluencers: number;
  36168. _applyFog: boolean;
  36169. _receiveShadows: boolean;
  36170. _facetData: _FacetDataStorage;
  36171. _visibility: number;
  36172. _skeleton: Nullable<Skeleton>;
  36173. _layerMask: number;
  36174. _computeBonesUsingShaders: boolean;
  36175. _isActive: boolean;
  36176. _onlyForInstances: boolean;
  36177. _isActiveIntermediate: boolean;
  36178. _onlyForInstancesIntermediate: boolean;
  36179. _actAsRegularMesh: boolean;
  36180. _currentLOD: Nullable<AbstractMesh>;
  36181. _currentLODIsUpToDate: boolean;
  36182. }
  36183. /**
  36184. * Class used to store all common mesh properties
  36185. */
  36186. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36187. /** No occlusion */
  36188. static OCCLUSION_TYPE_NONE: number;
  36189. /** Occlusion set to optimistic */
  36190. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36191. /** Occlusion set to strict */
  36192. static OCCLUSION_TYPE_STRICT: number;
  36193. /** Use an accurate occlusion algorithm */
  36194. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36195. /** Use a conservative occlusion algorithm */
  36196. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36197. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36198. * Test order :
  36199. * Is the bounding sphere outside the frustum ?
  36200. * If not, are the bounding box vertices outside the frustum ?
  36201. * It not, then the cullable object is in the frustum.
  36202. */
  36203. static readonly CULLINGSTRATEGY_STANDARD: number;
  36204. /** Culling strategy : Bounding Sphere Only.
  36205. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36206. * It's also less accurate than the standard because some not visible objects can still be selected.
  36207. * Test : is the bounding sphere outside the frustum ?
  36208. * If not, then the cullable object is in the frustum.
  36209. */
  36210. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36211. /** Culling strategy : Optimistic Inclusion.
  36212. * This in an inclusion test first, then the standard exclusion test.
  36213. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36214. * 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.
  36215. * Anyway, it's as accurate as the standard strategy.
  36216. * Test :
  36217. * Is the cullable object bounding sphere center in the frustum ?
  36218. * If not, apply the default culling strategy.
  36219. */
  36220. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36221. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36222. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36223. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36224. * 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.
  36225. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36226. * Test :
  36227. * Is the cullable object bounding sphere center in the frustum ?
  36228. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36229. */
  36230. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36231. /**
  36232. * No billboard
  36233. */
  36234. static get BILLBOARDMODE_NONE(): number;
  36235. /** Billboard on X axis */
  36236. static get BILLBOARDMODE_X(): number;
  36237. /** Billboard on Y axis */
  36238. static get BILLBOARDMODE_Y(): number;
  36239. /** Billboard on Z axis */
  36240. static get BILLBOARDMODE_Z(): number;
  36241. /** Billboard on all axes */
  36242. static get BILLBOARDMODE_ALL(): number;
  36243. /** Billboard on using position instead of orientation */
  36244. static get BILLBOARDMODE_USE_POSITION(): number;
  36245. /** @hidden */
  36246. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36247. /**
  36248. * The culling strategy to use to check whether the mesh must be rendered or not.
  36249. * This value can be changed at any time and will be used on the next render mesh selection.
  36250. * The possible values are :
  36251. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36252. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36253. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36254. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36255. * Please read each static variable documentation to get details about the culling process.
  36256. * */
  36257. cullingStrategy: number;
  36258. /**
  36259. * Gets the number of facets in the mesh
  36260. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36261. */
  36262. get facetNb(): number;
  36263. /**
  36264. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36265. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36266. */
  36267. get partitioningSubdivisions(): number;
  36268. set partitioningSubdivisions(nb: number);
  36269. /**
  36270. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36271. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36272. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36273. */
  36274. get partitioningBBoxRatio(): number;
  36275. set partitioningBBoxRatio(ratio: number);
  36276. /**
  36277. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36278. * Works only for updatable meshes.
  36279. * Doesn't work with multi-materials
  36280. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36281. */
  36282. get mustDepthSortFacets(): boolean;
  36283. set mustDepthSortFacets(sort: boolean);
  36284. /**
  36285. * The location (Vector3) where the facet depth sort must be computed from.
  36286. * By default, the active camera position.
  36287. * Used only when facet depth sort is enabled
  36288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36289. */
  36290. get facetDepthSortFrom(): Vector3;
  36291. set facetDepthSortFrom(location: Vector3);
  36292. /**
  36293. * gets a boolean indicating if facetData is enabled
  36294. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36295. */
  36296. get isFacetDataEnabled(): boolean;
  36297. /** @hidden */
  36298. _updateNonUniformScalingState(value: boolean): boolean;
  36299. /**
  36300. * An event triggered when this mesh collides with another one
  36301. */
  36302. onCollideObservable: Observable<AbstractMesh>;
  36303. /** Set a function to call when this mesh collides with another one */
  36304. set onCollide(callback: () => void);
  36305. /**
  36306. * An event triggered when the collision's position changes
  36307. */
  36308. onCollisionPositionChangeObservable: Observable<Vector3>;
  36309. /** Set a function to call when the collision's position changes */
  36310. set onCollisionPositionChange(callback: () => void);
  36311. /**
  36312. * An event triggered when material is changed
  36313. */
  36314. onMaterialChangedObservable: Observable<AbstractMesh>;
  36315. /**
  36316. * Gets or sets the orientation for POV movement & rotation
  36317. */
  36318. definedFacingForward: boolean;
  36319. /** @hidden */
  36320. _occlusionQuery: Nullable<WebGLQuery>;
  36321. /** @hidden */
  36322. _renderingGroup: Nullable<RenderingGroup>;
  36323. /**
  36324. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36325. */
  36326. get visibility(): number;
  36327. /**
  36328. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36329. */
  36330. set visibility(value: number);
  36331. /** Gets or sets the alpha index used to sort transparent meshes
  36332. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36333. */
  36334. alphaIndex: number;
  36335. /**
  36336. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36337. */
  36338. isVisible: boolean;
  36339. /**
  36340. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36341. */
  36342. isPickable: boolean;
  36343. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36344. showSubMeshesBoundingBox: boolean;
  36345. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36346. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36347. */
  36348. isBlocker: boolean;
  36349. /**
  36350. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36351. */
  36352. enablePointerMoveEvents: boolean;
  36353. private _renderingGroupId;
  36354. /**
  36355. * Specifies the rendering group id for this mesh (0 by default)
  36356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36357. */
  36358. get renderingGroupId(): number;
  36359. set renderingGroupId(value: number);
  36360. private _material;
  36361. /** Gets or sets current material */
  36362. get material(): Nullable<Material>;
  36363. set material(value: Nullable<Material>);
  36364. /**
  36365. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36366. * @see https://doc.babylonjs.com/babylon101/shadows
  36367. */
  36368. get receiveShadows(): boolean;
  36369. set receiveShadows(value: boolean);
  36370. /** Defines color to use when rendering outline */
  36371. outlineColor: Color3;
  36372. /** Define width to use when rendering outline */
  36373. outlineWidth: number;
  36374. /** Defines color to use when rendering overlay */
  36375. overlayColor: Color3;
  36376. /** Defines alpha to use when rendering overlay */
  36377. overlayAlpha: number;
  36378. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36379. get hasVertexAlpha(): boolean;
  36380. set hasVertexAlpha(value: boolean);
  36381. /** 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) */
  36382. get useVertexColors(): boolean;
  36383. set useVertexColors(value: boolean);
  36384. /**
  36385. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36386. */
  36387. get computeBonesUsingShaders(): boolean;
  36388. set computeBonesUsingShaders(value: boolean);
  36389. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36390. get numBoneInfluencers(): number;
  36391. set numBoneInfluencers(value: number);
  36392. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36393. get applyFog(): boolean;
  36394. set applyFog(value: boolean);
  36395. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36396. useOctreeForRenderingSelection: boolean;
  36397. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36398. useOctreeForPicking: boolean;
  36399. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36400. useOctreeForCollisions: boolean;
  36401. /**
  36402. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36403. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36404. */
  36405. get layerMask(): number;
  36406. set layerMask(value: number);
  36407. /**
  36408. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36409. */
  36410. alwaysSelectAsActiveMesh: boolean;
  36411. /**
  36412. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36413. */
  36414. doNotSyncBoundingInfo: boolean;
  36415. /**
  36416. * Gets or sets the current action manager
  36417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36418. */
  36419. actionManager: Nullable<AbstractActionManager>;
  36420. private _meshCollisionData;
  36421. /**
  36422. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36423. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36424. */
  36425. ellipsoid: Vector3;
  36426. /**
  36427. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36428. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36429. */
  36430. ellipsoidOffset: Vector3;
  36431. /**
  36432. * Gets or sets a collision mask used to mask collisions (default is -1).
  36433. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36434. */
  36435. get collisionMask(): number;
  36436. set collisionMask(mask: number);
  36437. /**
  36438. * Gets or sets a collision response flag (default is true).
  36439. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36440. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36441. * to respond to the collision.
  36442. */
  36443. get collisionResponse(): boolean;
  36444. set collisionResponse(response: boolean);
  36445. /**
  36446. * Gets or sets the current collision group mask (-1 by default).
  36447. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36448. */
  36449. get collisionGroup(): number;
  36450. set collisionGroup(mask: number);
  36451. /**
  36452. * Gets or sets current surrounding meshes (null by default).
  36453. *
  36454. * By default collision detection is tested against every mesh in the scene.
  36455. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36456. * meshes will be tested for the collision.
  36457. *
  36458. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36459. */
  36460. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36461. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36462. /**
  36463. * Defines edge width used when edgesRenderer is enabled
  36464. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36465. */
  36466. edgesWidth: number;
  36467. /**
  36468. * Defines edge color used when edgesRenderer is enabled
  36469. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36470. */
  36471. edgesColor: Color4;
  36472. /** @hidden */
  36473. _edgesRenderer: Nullable<IEdgesRenderer>;
  36474. /** @hidden */
  36475. _masterMesh: Nullable<AbstractMesh>;
  36476. /** @hidden */
  36477. _boundingInfo: Nullable<BoundingInfo>;
  36478. /** @hidden */
  36479. _renderId: number;
  36480. /**
  36481. * Gets or sets the list of subMeshes
  36482. * @see https://doc.babylonjs.com/how_to/multi_materials
  36483. */
  36484. subMeshes: SubMesh[];
  36485. /** @hidden */
  36486. _intersectionsInProgress: AbstractMesh[];
  36487. /** @hidden */
  36488. _unIndexed: boolean;
  36489. /** @hidden */
  36490. _lightSources: Light[];
  36491. /** Gets the list of lights affecting that mesh */
  36492. get lightSources(): Light[];
  36493. /** @hidden */
  36494. get _positions(): Nullable<Vector3[]>;
  36495. /** @hidden */
  36496. _waitingData: {
  36497. lods: Nullable<any>;
  36498. actions: Nullable<any>;
  36499. freezeWorldMatrix: Nullable<boolean>;
  36500. };
  36501. /** @hidden */
  36502. _bonesTransformMatrices: Nullable<Float32Array>;
  36503. /** @hidden */
  36504. _transformMatrixTexture: Nullable<RawTexture>;
  36505. /**
  36506. * Gets or sets a skeleton to apply skinning transformations
  36507. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36508. */
  36509. set skeleton(value: Nullable<Skeleton>);
  36510. get skeleton(): Nullable<Skeleton>;
  36511. /**
  36512. * An event triggered when the mesh is rebuilt.
  36513. */
  36514. onRebuildObservable: Observable<AbstractMesh>;
  36515. /**
  36516. * The current mesh uniform buffer.
  36517. * @hidden Internal use only.
  36518. */
  36519. _uniformBuffer: UniformBuffer;
  36520. /**
  36521. * Creates a new AbstractMesh
  36522. * @param name defines the name of the mesh
  36523. * @param scene defines the hosting scene
  36524. */
  36525. constructor(name: string, scene?: Nullable<Scene>);
  36526. protected _buildUniformLayout(): void;
  36527. /**
  36528. * Transfer the mesh values to its UBO.
  36529. * @param world The world matrix associated with the mesh
  36530. */
  36531. transferToEffect(world: Matrix): void;
  36532. /**
  36533. * Gets the mesh uniform buffer.
  36534. * @return the uniform buffer of the mesh.
  36535. */
  36536. getMeshUniformBuffer(): UniformBuffer;
  36537. /**
  36538. * Returns the string "AbstractMesh"
  36539. * @returns "AbstractMesh"
  36540. */
  36541. getClassName(): string;
  36542. /**
  36543. * Gets a string representation of the current mesh
  36544. * @param fullDetails defines a boolean indicating if full details must be included
  36545. * @returns a string representation of the current mesh
  36546. */
  36547. toString(fullDetails?: boolean): string;
  36548. /**
  36549. * @hidden
  36550. */
  36551. protected _getEffectiveParent(): Nullable<Node>;
  36552. /** @hidden */
  36553. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36554. /** @hidden */
  36555. _rebuild(): void;
  36556. /** @hidden */
  36557. _resyncLightSources(): void;
  36558. /** @hidden */
  36559. _resyncLightSource(light: Light): void;
  36560. /** @hidden */
  36561. _unBindEffect(): void;
  36562. /** @hidden */
  36563. _removeLightSource(light: Light, dispose: boolean): void;
  36564. private _markSubMeshesAsDirty;
  36565. /** @hidden */
  36566. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36567. /** @hidden */
  36568. _markSubMeshesAsAttributesDirty(): void;
  36569. /** @hidden */
  36570. _markSubMeshesAsMiscDirty(): void;
  36571. /**
  36572. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36573. */
  36574. get scaling(): Vector3;
  36575. set scaling(newScaling: Vector3);
  36576. /**
  36577. * Returns true if the mesh is blocked. Implemented by child classes
  36578. */
  36579. get isBlocked(): boolean;
  36580. /**
  36581. * Returns the mesh itself by default. Implemented by child classes
  36582. * @param camera defines the camera to use to pick the right LOD level
  36583. * @returns the currentAbstractMesh
  36584. */
  36585. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36586. /**
  36587. * Returns 0 by default. Implemented by child classes
  36588. * @returns an integer
  36589. */
  36590. getTotalVertices(): number;
  36591. /**
  36592. * Returns a positive integer : the total number of indices in this mesh geometry.
  36593. * @returns the number of indices or zero if the mesh has no geometry.
  36594. */
  36595. getTotalIndices(): number;
  36596. /**
  36597. * Returns null by default. Implemented by child classes
  36598. * @returns null
  36599. */
  36600. getIndices(): Nullable<IndicesArray>;
  36601. /**
  36602. * Returns the array of the requested vertex data kind. Implemented by child classes
  36603. * @param kind defines the vertex data kind to use
  36604. * @returns null
  36605. */
  36606. getVerticesData(kind: string): Nullable<FloatArray>;
  36607. /**
  36608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36610. * Note that a new underlying VertexBuffer object is created each call.
  36611. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36612. * @param kind defines vertex data kind:
  36613. * * VertexBuffer.PositionKind
  36614. * * VertexBuffer.UVKind
  36615. * * VertexBuffer.UV2Kind
  36616. * * VertexBuffer.UV3Kind
  36617. * * VertexBuffer.UV4Kind
  36618. * * VertexBuffer.UV5Kind
  36619. * * VertexBuffer.UV6Kind
  36620. * * VertexBuffer.ColorKind
  36621. * * VertexBuffer.MatricesIndicesKind
  36622. * * VertexBuffer.MatricesIndicesExtraKind
  36623. * * VertexBuffer.MatricesWeightsKind
  36624. * * VertexBuffer.MatricesWeightsExtraKind
  36625. * @param data defines the data source
  36626. * @param updatable defines if the data must be flagged as updatable (or static)
  36627. * @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
  36628. * @returns the current mesh
  36629. */
  36630. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36631. /**
  36632. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36633. * If the mesh has no geometry, it is simply returned as it is.
  36634. * @param kind defines vertex data kind:
  36635. * * VertexBuffer.PositionKind
  36636. * * VertexBuffer.UVKind
  36637. * * VertexBuffer.UV2Kind
  36638. * * VertexBuffer.UV3Kind
  36639. * * VertexBuffer.UV4Kind
  36640. * * VertexBuffer.UV5Kind
  36641. * * VertexBuffer.UV6Kind
  36642. * * VertexBuffer.ColorKind
  36643. * * VertexBuffer.MatricesIndicesKind
  36644. * * VertexBuffer.MatricesIndicesExtraKind
  36645. * * VertexBuffer.MatricesWeightsKind
  36646. * * VertexBuffer.MatricesWeightsExtraKind
  36647. * @param data defines the data source
  36648. * @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
  36649. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36650. * @returns the current mesh
  36651. */
  36652. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36653. /**
  36654. * Sets the mesh indices,
  36655. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36656. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36657. * @param totalVertices Defines the total number of vertices
  36658. * @returns the current mesh
  36659. */
  36660. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36661. /**
  36662. * Gets a boolean indicating if specific vertex data is present
  36663. * @param kind defines the vertex data kind to use
  36664. * @returns true is data kind is present
  36665. */
  36666. isVerticesDataPresent(kind: string): boolean;
  36667. /**
  36668. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36669. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36670. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36671. * @returns a BoundingInfo
  36672. */
  36673. getBoundingInfo(): BoundingInfo;
  36674. /**
  36675. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36676. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36677. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36678. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36679. * @returns the current mesh
  36680. */
  36681. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36682. /**
  36683. * Overwrite the current bounding info
  36684. * @param boundingInfo defines the new bounding info
  36685. * @returns the current mesh
  36686. */
  36687. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36688. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36689. get useBones(): boolean;
  36690. /** @hidden */
  36691. _preActivate(): void;
  36692. /** @hidden */
  36693. _preActivateForIntermediateRendering(renderId: number): void;
  36694. /** @hidden */
  36695. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36696. /** @hidden */
  36697. _postActivate(): void;
  36698. /** @hidden */
  36699. _freeze(): void;
  36700. /** @hidden */
  36701. _unFreeze(): void;
  36702. /**
  36703. * Gets the current world matrix
  36704. * @returns a Matrix
  36705. */
  36706. getWorldMatrix(): Matrix;
  36707. /** @hidden */
  36708. _getWorldMatrixDeterminant(): number;
  36709. /**
  36710. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36711. */
  36712. get isAnInstance(): boolean;
  36713. /**
  36714. * Gets a boolean indicating if this mesh has instances
  36715. */
  36716. get hasInstances(): boolean;
  36717. /**
  36718. * Gets a boolean indicating if this mesh has thin instances
  36719. */
  36720. get hasThinInstances(): boolean;
  36721. /**
  36722. * Perform relative position change from the point of view of behind the front of the mesh.
  36723. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36724. * Supports definition of mesh facing forward or backward
  36725. * @param amountRight defines the distance on the right axis
  36726. * @param amountUp defines the distance on the up axis
  36727. * @param amountForward defines the distance on the forward axis
  36728. * @returns the current mesh
  36729. */
  36730. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36731. /**
  36732. * Calculate relative position change from the point of view of behind the front of the mesh.
  36733. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36734. * Supports definition of mesh facing forward or backward
  36735. * @param amountRight defines the distance on the right axis
  36736. * @param amountUp defines the distance on the up axis
  36737. * @param amountForward defines the distance on the forward axis
  36738. * @returns the new displacement vector
  36739. */
  36740. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36741. /**
  36742. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36743. * Supports definition of mesh facing forward or backward
  36744. * @param flipBack defines the flip
  36745. * @param twirlClockwise defines the twirl
  36746. * @param tiltRight defines the tilt
  36747. * @returns the current mesh
  36748. */
  36749. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36750. /**
  36751. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36752. * Supports definition of mesh facing forward or backward.
  36753. * @param flipBack defines the flip
  36754. * @param twirlClockwise defines the twirl
  36755. * @param tiltRight defines the tilt
  36756. * @returns the new rotation vector
  36757. */
  36758. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36759. /**
  36760. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36761. * This means the mesh underlying bounding box and sphere are recomputed.
  36762. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36763. * @returns the current mesh
  36764. */
  36765. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36766. /** @hidden */
  36767. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36768. /** @hidden */
  36769. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36770. /** @hidden */
  36771. _updateBoundingInfo(): AbstractMesh;
  36772. /** @hidden */
  36773. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36774. /** @hidden */
  36775. protected _afterComputeWorldMatrix(): void;
  36776. /** @hidden */
  36777. get _effectiveMesh(): AbstractMesh;
  36778. /**
  36779. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36780. * A mesh is in the frustum if its bounding box intersects the frustum
  36781. * @param frustumPlanes defines the frustum to test
  36782. * @returns true if the mesh is in the frustum planes
  36783. */
  36784. isInFrustum(frustumPlanes: Plane[]): boolean;
  36785. /**
  36786. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36787. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36788. * @param frustumPlanes defines the frustum to test
  36789. * @returns true if the mesh is completely in the frustum planes
  36790. */
  36791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36792. /**
  36793. * True if the mesh intersects another mesh or a SolidParticle object
  36794. * @param mesh defines a target mesh or SolidParticle to test
  36795. * @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)
  36796. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36797. * @returns true if there is an intersection
  36798. */
  36799. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36800. /**
  36801. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36802. * @param point defines the point to test
  36803. * @returns true if there is an intersection
  36804. */
  36805. intersectsPoint(point: Vector3): boolean;
  36806. /**
  36807. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36808. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36809. */
  36810. get checkCollisions(): boolean;
  36811. set checkCollisions(collisionEnabled: boolean);
  36812. /**
  36813. * Gets Collider object used to compute collisions (not physics)
  36814. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36815. */
  36816. get collider(): Nullable<Collider>;
  36817. /**
  36818. * Move the mesh using collision engine
  36819. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36820. * @param displacement defines the requested displacement vector
  36821. * @returns the current mesh
  36822. */
  36823. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36824. private _onCollisionPositionChange;
  36825. /** @hidden */
  36826. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36827. /** @hidden */
  36828. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36829. /** @hidden */
  36830. _checkCollision(collider: Collider): AbstractMesh;
  36831. /** @hidden */
  36832. _generatePointsArray(): boolean;
  36833. /**
  36834. * Checks if the passed Ray intersects with the mesh
  36835. * @param ray defines the ray to use
  36836. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36837. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36838. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36839. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36840. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36841. * @returns the picking info
  36842. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36843. */
  36844. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36845. /**
  36846. * Clones the current mesh
  36847. * @param name defines the mesh name
  36848. * @param newParent defines the new mesh parent
  36849. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36850. * @returns the new mesh
  36851. */
  36852. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36853. /**
  36854. * Disposes all the submeshes of the current meshnp
  36855. * @returns the current mesh
  36856. */
  36857. releaseSubMeshes(): AbstractMesh;
  36858. /**
  36859. * Releases resources associated with this abstract mesh.
  36860. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36861. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36862. */
  36863. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36864. /**
  36865. * Adds the passed mesh as a child to the current mesh
  36866. * @param mesh defines the child mesh
  36867. * @returns the current mesh
  36868. */
  36869. addChild(mesh: AbstractMesh): AbstractMesh;
  36870. /**
  36871. * Removes the passed mesh from the current mesh children list
  36872. * @param mesh defines the child mesh
  36873. * @returns the current mesh
  36874. */
  36875. removeChild(mesh: AbstractMesh): AbstractMesh;
  36876. /** @hidden */
  36877. private _initFacetData;
  36878. /**
  36879. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36880. * This method can be called within the render loop.
  36881. * 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
  36882. * @returns the current mesh
  36883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36884. */
  36885. updateFacetData(): AbstractMesh;
  36886. /**
  36887. * Returns the facetLocalNormals array.
  36888. * The normals are expressed in the mesh local spac
  36889. * @returns an array of Vector3
  36890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36891. */
  36892. getFacetLocalNormals(): Vector3[];
  36893. /**
  36894. * Returns the facetLocalPositions array.
  36895. * The facet positions are expressed in the mesh local space
  36896. * @returns an array of Vector3
  36897. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36898. */
  36899. getFacetLocalPositions(): Vector3[];
  36900. /**
  36901. * Returns the facetLocalPartitioning array
  36902. * @returns an array of array of numbers
  36903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36904. */
  36905. getFacetLocalPartitioning(): number[][];
  36906. /**
  36907. * Returns the i-th facet position in the world system.
  36908. * This method allocates a new Vector3 per call
  36909. * @param i defines the facet index
  36910. * @returns a new Vector3
  36911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36912. */
  36913. getFacetPosition(i: number): Vector3;
  36914. /**
  36915. * Sets the reference Vector3 with the i-th facet position in the world system
  36916. * @param i defines the facet index
  36917. * @param ref defines the target vector
  36918. * @returns the current mesh
  36919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36920. */
  36921. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36922. /**
  36923. * Returns the i-th facet normal in the world system.
  36924. * This method allocates a new Vector3 per call
  36925. * @param i defines the facet index
  36926. * @returns a new Vector3
  36927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36928. */
  36929. getFacetNormal(i: number): Vector3;
  36930. /**
  36931. * Sets the reference Vector3 with the i-th facet normal in the world system
  36932. * @param i defines the facet index
  36933. * @param ref defines the target vector
  36934. * @returns the current mesh
  36935. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36936. */
  36937. getFacetNormalToRef(i: number, ref: Vector3): this;
  36938. /**
  36939. * 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)
  36940. * @param x defines x coordinate
  36941. * @param y defines y coordinate
  36942. * @param z defines z coordinate
  36943. * @returns the array of facet indexes
  36944. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36945. */
  36946. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36947. /**
  36948. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36949. * @param projected sets as the (x,y,z) world projection on the facet
  36950. * @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
  36951. * @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
  36952. * @param x defines x coordinate
  36953. * @param y defines y coordinate
  36954. * @param z defines z coordinate
  36955. * @returns the face index if found (or null instead)
  36956. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36957. */
  36958. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36959. /**
  36960. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36961. * @param projected sets as the (x,y,z) local projection on the facet
  36962. * @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
  36963. * @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
  36964. * @param x defines x coordinate
  36965. * @param y defines y coordinate
  36966. * @param z defines z coordinate
  36967. * @returns the face index if found (or null instead)
  36968. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36969. */
  36970. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36971. /**
  36972. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36973. * @returns the parameters
  36974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36975. */
  36976. getFacetDataParameters(): any;
  36977. /**
  36978. * Disables the feature FacetData and frees the related memory
  36979. * @returns the current mesh
  36980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36981. */
  36982. disableFacetData(): AbstractMesh;
  36983. /**
  36984. * Updates the AbstractMesh indices array
  36985. * @param indices defines the data source
  36986. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36987. * @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)
  36988. * @returns the current mesh
  36989. */
  36990. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36991. /**
  36992. * Creates new normals data for the mesh
  36993. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36994. * @returns the current mesh
  36995. */
  36996. createNormals(updatable: boolean): AbstractMesh;
  36997. /**
  36998. * Align the mesh with a normal
  36999. * @param normal defines the normal to use
  37000. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37001. * @returns the current mesh
  37002. */
  37003. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37004. /** @hidden */
  37005. _checkOcclusionQuery(): boolean;
  37006. /**
  37007. * Disables the mesh edge rendering mode
  37008. * @returns the currentAbstractMesh
  37009. */
  37010. disableEdgesRendering(): AbstractMesh;
  37011. /**
  37012. * Enables the edge rendering mode on the mesh.
  37013. * This mode makes the mesh edges visible
  37014. * @param epsilon defines the maximal distance between two angles to detect a face
  37015. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37016. * @param options options to the edge renderer
  37017. * @returns the currentAbstractMesh
  37018. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37019. */
  37020. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37021. /**
  37022. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37023. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37024. */
  37025. getConnectedParticleSystems(): IParticleSystem[];
  37026. }
  37027. }
  37028. declare module BABYLON {
  37029. /**
  37030. * Interface used to define ActionEvent
  37031. */
  37032. export interface IActionEvent {
  37033. /** The mesh or sprite that triggered the action */
  37034. source: any;
  37035. /** The X mouse cursor position at the time of the event */
  37036. pointerX: number;
  37037. /** The Y mouse cursor position at the time of the event */
  37038. pointerY: number;
  37039. /** The mesh that is currently pointed at (can be null) */
  37040. meshUnderPointer: Nullable<AbstractMesh>;
  37041. /** the original (browser) event that triggered the ActionEvent */
  37042. sourceEvent?: any;
  37043. /** additional data for the event */
  37044. additionalData?: any;
  37045. }
  37046. /**
  37047. * ActionEvent is the event being sent when an action is triggered.
  37048. */
  37049. export class ActionEvent implements IActionEvent {
  37050. /** The mesh or sprite that triggered the action */
  37051. source: any;
  37052. /** The X mouse cursor position at the time of the event */
  37053. pointerX: number;
  37054. /** The Y mouse cursor position at the time of the event */
  37055. pointerY: number;
  37056. /** The mesh that is currently pointed at (can be null) */
  37057. meshUnderPointer: Nullable<AbstractMesh>;
  37058. /** the original (browser) event that triggered the ActionEvent */
  37059. sourceEvent?: any;
  37060. /** additional data for the event */
  37061. additionalData?: any;
  37062. /**
  37063. * Creates a new ActionEvent
  37064. * @param source The mesh or sprite that triggered the action
  37065. * @param pointerX The X mouse cursor position at the time of the event
  37066. * @param pointerY The Y mouse cursor position at the time of the event
  37067. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37068. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37069. * @param additionalData additional data for the event
  37070. */
  37071. constructor(
  37072. /** The mesh or sprite that triggered the action */
  37073. source: any,
  37074. /** The X mouse cursor position at the time of the event */
  37075. pointerX: number,
  37076. /** The Y mouse cursor position at the time of the event */
  37077. pointerY: number,
  37078. /** The mesh that is currently pointed at (can be null) */
  37079. meshUnderPointer: Nullable<AbstractMesh>,
  37080. /** the original (browser) event that triggered the ActionEvent */
  37081. sourceEvent?: any,
  37082. /** additional data for the event */
  37083. additionalData?: any);
  37084. /**
  37085. * Helper function to auto-create an ActionEvent from a source mesh.
  37086. * @param source The source mesh that triggered the event
  37087. * @param evt The original (browser) event
  37088. * @param additionalData additional data for the event
  37089. * @returns the new ActionEvent
  37090. */
  37091. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37092. /**
  37093. * Helper function to auto-create an ActionEvent from a source sprite
  37094. * @param source The source sprite that triggered the event
  37095. * @param scene Scene associated with the sprite
  37096. * @param evt The original (browser) event
  37097. * @param additionalData additional data for the event
  37098. * @returns the new ActionEvent
  37099. */
  37100. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37101. /**
  37102. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37103. * @param scene the scene where the event occurred
  37104. * @param evt The original (browser) event
  37105. * @returns the new ActionEvent
  37106. */
  37107. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37108. /**
  37109. * Helper function to auto-create an ActionEvent from a primitive
  37110. * @param prim defines the target primitive
  37111. * @param pointerPos defines the pointer position
  37112. * @param evt The original (browser) event
  37113. * @param additionalData additional data for the event
  37114. * @returns the new ActionEvent
  37115. */
  37116. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37117. }
  37118. }
  37119. declare module BABYLON {
  37120. /**
  37121. * Abstract class used to decouple action Manager from scene and meshes.
  37122. * Do not instantiate.
  37123. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37124. */
  37125. export abstract class AbstractActionManager implements IDisposable {
  37126. /** Gets the list of active triggers */
  37127. static Triggers: {
  37128. [key: string]: number;
  37129. };
  37130. /** Gets the cursor to use when hovering items */
  37131. hoverCursor: string;
  37132. /** Gets the list of actions */
  37133. actions: IAction[];
  37134. /**
  37135. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37136. */
  37137. isRecursive: boolean;
  37138. /**
  37139. * Releases all associated resources
  37140. */
  37141. abstract dispose(): void;
  37142. /**
  37143. * Does this action manager has pointer triggers
  37144. */
  37145. abstract get hasPointerTriggers(): boolean;
  37146. /**
  37147. * Does this action manager has pick triggers
  37148. */
  37149. abstract get hasPickTriggers(): boolean;
  37150. /**
  37151. * Process a specific trigger
  37152. * @param trigger defines the trigger to process
  37153. * @param evt defines the event details to be processed
  37154. */
  37155. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37156. /**
  37157. * Does this action manager handles actions of any of the given triggers
  37158. * @param triggers defines the triggers to be tested
  37159. * @return a boolean indicating whether one (or more) of the triggers is handled
  37160. */
  37161. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37162. /**
  37163. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37164. * speed.
  37165. * @param triggerA defines the trigger to be tested
  37166. * @param triggerB defines the trigger to be tested
  37167. * @return a boolean indicating whether one (or more) of the triggers is handled
  37168. */
  37169. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37170. /**
  37171. * Does this action manager handles actions of a given trigger
  37172. * @param trigger defines the trigger to be tested
  37173. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37174. * @return whether the trigger is handled
  37175. */
  37176. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37177. /**
  37178. * Serialize this manager to a JSON object
  37179. * @param name defines the property name to store this manager
  37180. * @returns a JSON representation of this manager
  37181. */
  37182. abstract serialize(name: string): any;
  37183. /**
  37184. * Registers an action to this action manager
  37185. * @param action defines the action to be registered
  37186. * @return the action amended (prepared) after registration
  37187. */
  37188. abstract registerAction(action: IAction): Nullable<IAction>;
  37189. /**
  37190. * Unregisters an action to this action manager
  37191. * @param action defines the action to be unregistered
  37192. * @return a boolean indicating whether the action has been unregistered
  37193. */
  37194. abstract unregisterAction(action: IAction): Boolean;
  37195. /**
  37196. * Does exist one action manager with at least one trigger
  37197. **/
  37198. static get HasTriggers(): boolean;
  37199. /**
  37200. * Does exist one action manager with at least one pick trigger
  37201. **/
  37202. static get HasPickTriggers(): boolean;
  37203. /**
  37204. * Does exist one action manager that handles actions of a given trigger
  37205. * @param trigger defines the trigger to be tested
  37206. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37207. **/
  37208. static HasSpecificTrigger(trigger: number): boolean;
  37209. }
  37210. }
  37211. declare module BABYLON {
  37212. /**
  37213. * Defines how a node can be built from a string name.
  37214. */
  37215. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37216. /**
  37217. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37218. */
  37219. export class Node implements IBehaviorAware<Node> {
  37220. /** @hidden */
  37221. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37222. private static _NodeConstructors;
  37223. /**
  37224. * Add a new node constructor
  37225. * @param type defines the type name of the node to construct
  37226. * @param constructorFunc defines the constructor function
  37227. */
  37228. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37229. /**
  37230. * Returns a node constructor based on type name
  37231. * @param type defines the type name
  37232. * @param name defines the new node name
  37233. * @param scene defines the hosting scene
  37234. * @param options defines optional options to transmit to constructors
  37235. * @returns the new constructor or null
  37236. */
  37237. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37238. /**
  37239. * Gets or sets the name of the node
  37240. */
  37241. name: string;
  37242. /**
  37243. * Gets or sets the id of the node
  37244. */
  37245. id: string;
  37246. /**
  37247. * Gets or sets the unique id of the node
  37248. */
  37249. uniqueId: number;
  37250. /**
  37251. * Gets or sets a string used to store user defined state for the node
  37252. */
  37253. state: string;
  37254. /**
  37255. * Gets or sets an object used to store user defined information for the node
  37256. */
  37257. metadata: any;
  37258. /**
  37259. * For internal use only. Please do not use.
  37260. */
  37261. reservedDataStore: any;
  37262. /**
  37263. * List of inspectable custom properties (used by the Inspector)
  37264. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37265. */
  37266. inspectableCustomProperties: IInspectable[];
  37267. private _doNotSerialize;
  37268. /**
  37269. * Gets or sets a boolean used to define if the node must be serialized
  37270. */
  37271. get doNotSerialize(): boolean;
  37272. set doNotSerialize(value: boolean);
  37273. /** @hidden */
  37274. _isDisposed: boolean;
  37275. /**
  37276. * Gets a list of Animations associated with the node
  37277. */
  37278. animations: Animation[];
  37279. protected _ranges: {
  37280. [name: string]: Nullable<AnimationRange>;
  37281. };
  37282. /**
  37283. * Callback raised when the node is ready to be used
  37284. */
  37285. onReady: Nullable<(node: Node) => void>;
  37286. private _isEnabled;
  37287. private _isParentEnabled;
  37288. private _isReady;
  37289. /** @hidden */
  37290. _currentRenderId: number;
  37291. private _parentUpdateId;
  37292. /** @hidden */
  37293. _childUpdateId: number;
  37294. /** @hidden */
  37295. _waitingParentId: Nullable<string>;
  37296. /** @hidden */
  37297. _scene: Scene;
  37298. /** @hidden */
  37299. _cache: any;
  37300. private _parentNode;
  37301. private _children;
  37302. /** @hidden */
  37303. _worldMatrix: Matrix;
  37304. /** @hidden */
  37305. _worldMatrixDeterminant: number;
  37306. /** @hidden */
  37307. _worldMatrixDeterminantIsDirty: boolean;
  37308. /** @hidden */
  37309. private _sceneRootNodesIndex;
  37310. /**
  37311. * Gets a boolean indicating if the node has been disposed
  37312. * @returns true if the node was disposed
  37313. */
  37314. isDisposed(): boolean;
  37315. /**
  37316. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37317. * @see https://doc.babylonjs.com/how_to/parenting
  37318. */
  37319. set parent(parent: Nullable<Node>);
  37320. get parent(): Nullable<Node>;
  37321. /** @hidden */
  37322. _addToSceneRootNodes(): void;
  37323. /** @hidden */
  37324. _removeFromSceneRootNodes(): void;
  37325. private _animationPropertiesOverride;
  37326. /**
  37327. * Gets or sets the animation properties override
  37328. */
  37329. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37330. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37331. /**
  37332. * Gets a string identifying the name of the class
  37333. * @returns "Node" string
  37334. */
  37335. getClassName(): string;
  37336. /** @hidden */
  37337. readonly _isNode: boolean;
  37338. /**
  37339. * An event triggered when the mesh is disposed
  37340. */
  37341. onDisposeObservable: Observable<Node>;
  37342. private _onDisposeObserver;
  37343. /**
  37344. * Sets a callback that will be raised when the node will be disposed
  37345. */
  37346. set onDispose(callback: () => void);
  37347. /**
  37348. * Creates a new Node
  37349. * @param name the name and id to be given to this node
  37350. * @param scene the scene this node will be added to
  37351. */
  37352. constructor(name: string, scene?: Nullable<Scene>);
  37353. /**
  37354. * Gets the scene of the node
  37355. * @returns a scene
  37356. */
  37357. getScene(): Scene;
  37358. /**
  37359. * Gets the engine of the node
  37360. * @returns a Engine
  37361. */
  37362. getEngine(): Engine;
  37363. private _behaviors;
  37364. /**
  37365. * Attach a behavior to the node
  37366. * @see https://doc.babylonjs.com/features/behaviour
  37367. * @param behavior defines the behavior to attach
  37368. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37369. * @returns the current Node
  37370. */
  37371. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37372. /**
  37373. * Remove an attached behavior
  37374. * @see https://doc.babylonjs.com/features/behaviour
  37375. * @param behavior defines the behavior to attach
  37376. * @returns the current Node
  37377. */
  37378. removeBehavior(behavior: Behavior<Node>): Node;
  37379. /**
  37380. * Gets the list of attached behaviors
  37381. * @see https://doc.babylonjs.com/features/behaviour
  37382. */
  37383. get behaviors(): Behavior<Node>[];
  37384. /**
  37385. * Gets an attached behavior by name
  37386. * @param name defines the name of the behavior to look for
  37387. * @see https://doc.babylonjs.com/features/behaviour
  37388. * @returns null if behavior was not found else the requested behavior
  37389. */
  37390. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37391. /**
  37392. * Returns the latest update of the World matrix
  37393. * @returns a Matrix
  37394. */
  37395. getWorldMatrix(): Matrix;
  37396. /** @hidden */
  37397. _getWorldMatrixDeterminant(): number;
  37398. /**
  37399. * Returns directly the latest state of the mesh World matrix.
  37400. * A Matrix is returned.
  37401. */
  37402. get worldMatrixFromCache(): Matrix;
  37403. /** @hidden */
  37404. _initCache(): void;
  37405. /** @hidden */
  37406. updateCache(force?: boolean): void;
  37407. /** @hidden */
  37408. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37409. /** @hidden */
  37410. _updateCache(ignoreParentClass?: boolean): void;
  37411. /** @hidden */
  37412. _isSynchronized(): boolean;
  37413. /** @hidden */
  37414. _markSyncedWithParent(): void;
  37415. /** @hidden */
  37416. isSynchronizedWithParent(): boolean;
  37417. /** @hidden */
  37418. isSynchronized(): boolean;
  37419. /**
  37420. * Is this node ready to be used/rendered
  37421. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37422. * @return true if the node is ready
  37423. */
  37424. isReady(completeCheck?: boolean): boolean;
  37425. /**
  37426. * Is this node enabled?
  37427. * 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
  37428. * @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
  37429. * @return whether this node (and its parent) is enabled
  37430. */
  37431. isEnabled(checkAncestors?: boolean): boolean;
  37432. /** @hidden */
  37433. protected _syncParentEnabledState(): void;
  37434. /**
  37435. * Set the enabled state of this node
  37436. * @param value defines the new enabled state
  37437. */
  37438. setEnabled(value: boolean): void;
  37439. /**
  37440. * Is this node a descendant of the given node?
  37441. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37442. * @param ancestor defines the parent node to inspect
  37443. * @returns a boolean indicating if this node is a descendant of the given node
  37444. */
  37445. isDescendantOf(ancestor: Node): boolean;
  37446. /** @hidden */
  37447. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37448. /**
  37449. * Will return all nodes that have this node as ascendant
  37450. * @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
  37451. * @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
  37452. * @return all children nodes of all types
  37453. */
  37454. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37455. /**
  37456. * Get all child-meshes of this node
  37457. * @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)
  37458. * @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
  37459. * @returns an array of AbstractMesh
  37460. */
  37461. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37462. /**
  37463. * Get all direct children of this node
  37464. * @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
  37465. * @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)
  37466. * @returns an array of Node
  37467. */
  37468. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37469. /** @hidden */
  37470. _setReady(state: boolean): void;
  37471. /**
  37472. * Get an animation by name
  37473. * @param name defines the name of the animation to look for
  37474. * @returns null if not found else the requested animation
  37475. */
  37476. getAnimationByName(name: string): Nullable<Animation>;
  37477. /**
  37478. * Creates an animation range for this node
  37479. * @param name defines the name of the range
  37480. * @param from defines the starting key
  37481. * @param to defines the end key
  37482. */
  37483. createAnimationRange(name: string, from: number, to: number): void;
  37484. /**
  37485. * Delete a specific animation range
  37486. * @param name defines the name of the range to delete
  37487. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37488. */
  37489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37490. /**
  37491. * Get an animation range by name
  37492. * @param name defines the name of the animation range to look for
  37493. * @returns null if not found else the requested animation range
  37494. */
  37495. getAnimationRange(name: string): Nullable<AnimationRange>;
  37496. /**
  37497. * Gets the list of all animation ranges defined on this node
  37498. * @returns an array
  37499. */
  37500. getAnimationRanges(): Nullable<AnimationRange>[];
  37501. /**
  37502. * Will start the animation sequence
  37503. * @param name defines the range frames for animation sequence
  37504. * @param loop defines if the animation should loop (false by default)
  37505. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37506. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37507. * @returns the object created for this animation. If range does not exist, it will return null
  37508. */
  37509. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37510. /**
  37511. * Serialize animation ranges into a JSON compatible object
  37512. * @returns serialization object
  37513. */
  37514. serializeAnimationRanges(): any;
  37515. /**
  37516. * Computes the world matrix of the node
  37517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37518. * @returns the world matrix
  37519. */
  37520. computeWorldMatrix(force?: boolean): Matrix;
  37521. /**
  37522. * Releases resources associated with this node.
  37523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37525. */
  37526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37527. /**
  37528. * Parse animation range data from a serialization object and store them into a given node
  37529. * @param node defines where to store the animation ranges
  37530. * @param parsedNode defines the serialization object to read data from
  37531. * @param scene defines the hosting scene
  37532. */
  37533. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37534. /**
  37535. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37536. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37537. * @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
  37538. * @returns the new bounding vectors
  37539. */
  37540. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37541. min: Vector3;
  37542. max: Vector3;
  37543. };
  37544. }
  37545. }
  37546. declare module BABYLON {
  37547. /**
  37548. * @hidden
  37549. */
  37550. export class _IAnimationState {
  37551. key: number;
  37552. repeatCount: number;
  37553. workValue?: any;
  37554. loopMode?: number;
  37555. offsetValue?: any;
  37556. highLimitValue?: any;
  37557. }
  37558. /**
  37559. * Class used to store any kind of animation
  37560. */
  37561. export class Animation {
  37562. /**Name of the animation */
  37563. name: string;
  37564. /**Property to animate */
  37565. targetProperty: string;
  37566. /**The frames per second of the animation */
  37567. framePerSecond: number;
  37568. /**The data type of the animation */
  37569. dataType: number;
  37570. /**The loop mode of the animation */
  37571. loopMode?: number | undefined;
  37572. /**Specifies if blending should be enabled */
  37573. enableBlending?: boolean | undefined;
  37574. /**
  37575. * Use matrix interpolation instead of using direct key value when animating matrices
  37576. */
  37577. static AllowMatricesInterpolation: boolean;
  37578. /**
  37579. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37580. */
  37581. static AllowMatrixDecomposeForInterpolation: boolean;
  37582. /** Define the Url to load snippets */
  37583. static SnippetUrl: string;
  37584. /** Snippet ID if the animation was created from the snippet server */
  37585. snippetId: string;
  37586. /**
  37587. * Stores the key frames of the animation
  37588. */
  37589. private _keys;
  37590. /**
  37591. * Stores the easing function of the animation
  37592. */
  37593. private _easingFunction;
  37594. /**
  37595. * @hidden Internal use only
  37596. */
  37597. _runtimeAnimations: RuntimeAnimation[];
  37598. /**
  37599. * The set of event that will be linked to this animation
  37600. */
  37601. private _events;
  37602. /**
  37603. * Stores an array of target property paths
  37604. */
  37605. targetPropertyPath: string[];
  37606. /**
  37607. * Stores the blending speed of the animation
  37608. */
  37609. blendingSpeed: number;
  37610. /**
  37611. * Stores the animation ranges for the animation
  37612. */
  37613. private _ranges;
  37614. /**
  37615. * @hidden Internal use
  37616. */
  37617. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37618. /**
  37619. * Sets up an animation
  37620. * @param property The property to animate
  37621. * @param animationType The animation type to apply
  37622. * @param framePerSecond The frames per second of the animation
  37623. * @param easingFunction The easing function used in the animation
  37624. * @returns The created animation
  37625. */
  37626. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37627. /**
  37628. * Create and start an animation on a node
  37629. * @param name defines the name of the global animation that will be run on all nodes
  37630. * @param node defines the root node where the animation will take place
  37631. * @param targetProperty defines property to animate
  37632. * @param framePerSecond defines the number of frame per second yo use
  37633. * @param totalFrame defines the number of frames in total
  37634. * @param from defines the initial value
  37635. * @param to defines the final value
  37636. * @param loopMode defines which loop mode you want to use (off by default)
  37637. * @param easingFunction defines the easing function to use (linear by default)
  37638. * @param onAnimationEnd defines the callback to call when animation end
  37639. * @returns the animatable created for this animation
  37640. */
  37641. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37642. /**
  37643. * Create and start an animation on a node and its descendants
  37644. * @param name defines the name of the global animation that will be run on all nodes
  37645. * @param node defines the root node where the animation will take place
  37646. * @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
  37647. * @param targetProperty defines property to animate
  37648. * @param framePerSecond defines the number of frame per second to use
  37649. * @param totalFrame defines the number of frames in total
  37650. * @param from defines the initial value
  37651. * @param to defines the final value
  37652. * @param loopMode defines which loop mode you want to use (off by default)
  37653. * @param easingFunction defines the easing function to use (linear by default)
  37654. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37655. * @returns the list of animatables created for all nodes
  37656. * @example https://www.babylonjs-playground.com/#MH0VLI
  37657. */
  37658. 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[]>;
  37659. /**
  37660. * Creates a new animation, merges it with the existing animations and starts it
  37661. * @param name Name of the animation
  37662. * @param node Node which contains the scene that begins the animations
  37663. * @param targetProperty Specifies which property to animate
  37664. * @param framePerSecond The frames per second of the animation
  37665. * @param totalFrame The total number of frames
  37666. * @param from The frame at the beginning of the animation
  37667. * @param to The frame at the end of the animation
  37668. * @param loopMode Specifies the loop mode of the animation
  37669. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37670. * @param onAnimationEnd Callback to run once the animation is complete
  37671. * @returns Nullable animation
  37672. */
  37673. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37674. /**
  37675. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37676. * @param sourceAnimation defines the Animation containing keyframes to convert
  37677. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37678. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37679. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37680. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37681. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37682. */
  37683. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37684. /**
  37685. * Transition property of an host to the target Value
  37686. * @param property The property to transition
  37687. * @param targetValue The target Value of the property
  37688. * @param host The object where the property to animate belongs
  37689. * @param scene Scene used to run the animation
  37690. * @param frameRate Framerate (in frame/s) to use
  37691. * @param transition The transition type we want to use
  37692. * @param duration The duration of the animation, in milliseconds
  37693. * @param onAnimationEnd Callback trigger at the end of the animation
  37694. * @returns Nullable animation
  37695. */
  37696. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37697. /**
  37698. * Return the array of runtime animations currently using this animation
  37699. */
  37700. get runtimeAnimations(): RuntimeAnimation[];
  37701. /**
  37702. * Specifies if any of the runtime animations are currently running
  37703. */
  37704. get hasRunningRuntimeAnimations(): boolean;
  37705. /**
  37706. * Initializes the animation
  37707. * @param name Name of the animation
  37708. * @param targetProperty Property to animate
  37709. * @param framePerSecond The frames per second of the animation
  37710. * @param dataType The data type of the animation
  37711. * @param loopMode The loop mode of the animation
  37712. * @param enableBlending Specifies if blending should be enabled
  37713. */
  37714. constructor(
  37715. /**Name of the animation */
  37716. name: string,
  37717. /**Property to animate */
  37718. targetProperty: string,
  37719. /**The frames per second of the animation */
  37720. framePerSecond: number,
  37721. /**The data type of the animation */
  37722. dataType: number,
  37723. /**The loop mode of the animation */
  37724. loopMode?: number | undefined,
  37725. /**Specifies if blending should be enabled */
  37726. enableBlending?: boolean | undefined);
  37727. /**
  37728. * Converts the animation to a string
  37729. * @param fullDetails support for multiple levels of logging within scene loading
  37730. * @returns String form of the animation
  37731. */
  37732. toString(fullDetails?: boolean): string;
  37733. /**
  37734. * Add an event to this animation
  37735. * @param event Event to add
  37736. */
  37737. addEvent(event: AnimationEvent): void;
  37738. /**
  37739. * Remove all events found at the given frame
  37740. * @param frame The frame to remove events from
  37741. */
  37742. removeEvents(frame: number): void;
  37743. /**
  37744. * Retrieves all the events from the animation
  37745. * @returns Events from the animation
  37746. */
  37747. getEvents(): AnimationEvent[];
  37748. /**
  37749. * Creates an animation range
  37750. * @param name Name of the animation range
  37751. * @param from Starting frame of the animation range
  37752. * @param to Ending frame of the animation
  37753. */
  37754. createRange(name: string, from: number, to: number): void;
  37755. /**
  37756. * Deletes an animation range by name
  37757. * @param name Name of the animation range to delete
  37758. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37759. */
  37760. deleteRange(name: string, deleteFrames?: boolean): void;
  37761. /**
  37762. * Gets the animation range by name, or null if not defined
  37763. * @param name Name of the animation range
  37764. * @returns Nullable animation range
  37765. */
  37766. getRange(name: string): Nullable<AnimationRange>;
  37767. /**
  37768. * Gets the key frames from the animation
  37769. * @returns The key frames of the animation
  37770. */
  37771. getKeys(): Array<IAnimationKey>;
  37772. /**
  37773. * Gets the highest frame rate of the animation
  37774. * @returns Highest frame rate of the animation
  37775. */
  37776. getHighestFrame(): number;
  37777. /**
  37778. * Gets the easing function of the animation
  37779. * @returns Easing function of the animation
  37780. */
  37781. getEasingFunction(): IEasingFunction;
  37782. /**
  37783. * Sets the easing function of the animation
  37784. * @param easingFunction A custom mathematical formula for animation
  37785. */
  37786. setEasingFunction(easingFunction: EasingFunction): void;
  37787. /**
  37788. * Interpolates a scalar linearly
  37789. * @param startValue Start value of the animation curve
  37790. * @param endValue End value of the animation curve
  37791. * @param gradient Scalar amount to interpolate
  37792. * @returns Interpolated scalar value
  37793. */
  37794. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37795. /**
  37796. * Interpolates a scalar cubically
  37797. * @param startValue Start value of the animation curve
  37798. * @param outTangent End tangent of the animation
  37799. * @param endValue End value of the animation curve
  37800. * @param inTangent Start tangent of the animation curve
  37801. * @param gradient Scalar amount to interpolate
  37802. * @returns Interpolated scalar value
  37803. */
  37804. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37805. /**
  37806. * Interpolates a quaternion using a spherical linear interpolation
  37807. * @param startValue Start value of the animation curve
  37808. * @param endValue End value of the animation curve
  37809. * @param gradient Scalar amount to interpolate
  37810. * @returns Interpolated quaternion value
  37811. */
  37812. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37813. /**
  37814. * Interpolates a quaternion cubically
  37815. * @param startValue Start value of the animation curve
  37816. * @param outTangent End tangent of the animation curve
  37817. * @param endValue End value of the animation curve
  37818. * @param inTangent Start tangent of the animation curve
  37819. * @param gradient Scalar amount to interpolate
  37820. * @returns Interpolated quaternion value
  37821. */
  37822. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37823. /**
  37824. * Interpolates a Vector3 linearly
  37825. * @param startValue Start value of the animation curve
  37826. * @param endValue End value of the animation curve
  37827. * @param gradient Scalar amount to interpolate
  37828. * @returns Interpolated scalar value
  37829. */
  37830. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37831. /**
  37832. * Interpolates a Vector3 cubically
  37833. * @param startValue Start value of the animation curve
  37834. * @param outTangent End tangent of the animation
  37835. * @param endValue End value of the animation curve
  37836. * @param inTangent Start tangent of the animation curve
  37837. * @param gradient Scalar amount to interpolate
  37838. * @returns InterpolatedVector3 value
  37839. */
  37840. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37841. /**
  37842. * Interpolates a Vector2 linearly
  37843. * @param startValue Start value of the animation curve
  37844. * @param endValue End value of the animation curve
  37845. * @param gradient Scalar amount to interpolate
  37846. * @returns Interpolated Vector2 value
  37847. */
  37848. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37849. /**
  37850. * Interpolates a Vector2 cubically
  37851. * @param startValue Start value of the animation curve
  37852. * @param outTangent End tangent of the animation
  37853. * @param endValue End value of the animation curve
  37854. * @param inTangent Start tangent of the animation curve
  37855. * @param gradient Scalar amount to interpolate
  37856. * @returns Interpolated Vector2 value
  37857. */
  37858. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37859. /**
  37860. * Interpolates a size linearly
  37861. * @param startValue Start value of the animation curve
  37862. * @param endValue End value of the animation curve
  37863. * @param gradient Scalar amount to interpolate
  37864. * @returns Interpolated Size value
  37865. */
  37866. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37867. /**
  37868. * Interpolates a Color3 linearly
  37869. * @param startValue Start value of the animation curve
  37870. * @param endValue End value of the animation curve
  37871. * @param gradient Scalar amount to interpolate
  37872. * @returns Interpolated Color3 value
  37873. */
  37874. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37875. /**
  37876. * Interpolates a Color4 linearly
  37877. * @param startValue Start value of the animation curve
  37878. * @param endValue End value of the animation curve
  37879. * @param gradient Scalar amount to interpolate
  37880. * @returns Interpolated Color3 value
  37881. */
  37882. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37883. /**
  37884. * @hidden Internal use only
  37885. */
  37886. _getKeyValue(value: any): any;
  37887. /**
  37888. * @hidden Internal use only
  37889. */
  37890. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37891. /**
  37892. * Defines the function to use to interpolate matrices
  37893. * @param startValue defines the start matrix
  37894. * @param endValue defines the end matrix
  37895. * @param gradient defines the gradient between both matrices
  37896. * @param result defines an optional target matrix where to store the interpolation
  37897. * @returns the interpolated matrix
  37898. */
  37899. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37900. /**
  37901. * Makes a copy of the animation
  37902. * @returns Cloned animation
  37903. */
  37904. clone(): Animation;
  37905. /**
  37906. * Sets the key frames of the animation
  37907. * @param values The animation key frames to set
  37908. */
  37909. setKeys(values: Array<IAnimationKey>): void;
  37910. /**
  37911. * Serializes the animation to an object
  37912. * @returns Serialized object
  37913. */
  37914. serialize(): any;
  37915. /**
  37916. * Float animation type
  37917. */
  37918. static readonly ANIMATIONTYPE_FLOAT: number;
  37919. /**
  37920. * Vector3 animation type
  37921. */
  37922. static readonly ANIMATIONTYPE_VECTOR3: number;
  37923. /**
  37924. * Quaternion animation type
  37925. */
  37926. static readonly ANIMATIONTYPE_QUATERNION: number;
  37927. /**
  37928. * Matrix animation type
  37929. */
  37930. static readonly ANIMATIONTYPE_MATRIX: number;
  37931. /**
  37932. * Color3 animation type
  37933. */
  37934. static readonly ANIMATIONTYPE_COLOR3: number;
  37935. /**
  37936. * Color3 animation type
  37937. */
  37938. static readonly ANIMATIONTYPE_COLOR4: number;
  37939. /**
  37940. * Vector2 animation type
  37941. */
  37942. static readonly ANIMATIONTYPE_VECTOR2: number;
  37943. /**
  37944. * Size animation type
  37945. */
  37946. static readonly ANIMATIONTYPE_SIZE: number;
  37947. /**
  37948. * Relative Loop Mode
  37949. */
  37950. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37951. /**
  37952. * Cycle Loop Mode
  37953. */
  37954. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37955. /**
  37956. * Constant Loop Mode
  37957. */
  37958. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37959. /** @hidden */
  37960. static _UniversalLerp(left: any, right: any, amount: number): any;
  37961. /**
  37962. * Parses an animation object and creates an animation
  37963. * @param parsedAnimation Parsed animation object
  37964. * @returns Animation object
  37965. */
  37966. static Parse(parsedAnimation: any): Animation;
  37967. /**
  37968. * Appends the serialized animations from the source animations
  37969. * @param source Source containing the animations
  37970. * @param destination Target to store the animations
  37971. */
  37972. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37973. /**
  37974. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37975. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37976. * @param url defines the url to load from
  37977. * @returns a promise that will resolve to the new animation or an array of animations
  37978. */
  37979. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37980. /**
  37981. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37982. * @param snippetId defines the snippet to load
  37983. * @returns a promise that will resolve to the new animation or a new array of animations
  37984. */
  37985. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37986. }
  37987. }
  37988. declare module BABYLON {
  37989. /**
  37990. * Interface containing an array of animations
  37991. */
  37992. export interface IAnimatable {
  37993. /**
  37994. * Array of animations
  37995. */
  37996. animations: Nullable<Array<Animation>>;
  37997. }
  37998. }
  37999. declare module BABYLON {
  38000. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38001. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38002. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38003. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38004. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38005. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38006. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38007. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38008. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38009. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38010. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38011. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38012. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38013. /**
  38014. * Decorator used to define property that can be serialized as reference to a camera
  38015. * @param sourceName defines the name of the property to decorate
  38016. */
  38017. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38018. /**
  38019. * Class used to help serialization objects
  38020. */
  38021. export class SerializationHelper {
  38022. /** @hidden */
  38023. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38024. /** @hidden */
  38025. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38026. /** @hidden */
  38027. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38028. /** @hidden */
  38029. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38030. /**
  38031. * Appends the serialized animations from the source animations
  38032. * @param source Source containing the animations
  38033. * @param destination Target to store the animations
  38034. */
  38035. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38036. /**
  38037. * Static function used to serialized a specific entity
  38038. * @param entity defines the entity to serialize
  38039. * @param serializationObject defines the optional target object where serialization data will be stored
  38040. * @returns a JSON compatible object representing the serialization of the entity
  38041. */
  38042. static Serialize<T>(entity: T, serializationObject?: any): any;
  38043. /**
  38044. * Creates a new entity from a serialization data object
  38045. * @param creationFunction defines a function used to instanciated the new entity
  38046. * @param source defines the source serialization data
  38047. * @param scene defines the hosting scene
  38048. * @param rootUrl defines the root url for resources
  38049. * @returns a new entity
  38050. */
  38051. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38052. /**
  38053. * Clones an object
  38054. * @param creationFunction defines the function used to instanciate the new object
  38055. * @param source defines the source object
  38056. * @returns the cloned object
  38057. */
  38058. static Clone<T>(creationFunction: () => T, source: T): T;
  38059. /**
  38060. * Instanciates a new object based on a source one (some data will be shared between both object)
  38061. * @param creationFunction defines the function used to instanciate the new object
  38062. * @param source defines the source object
  38063. * @returns the new object
  38064. */
  38065. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * This is the base class of all the camera used in the application.
  38071. * @see https://doc.babylonjs.com/features/cameras
  38072. */
  38073. export class Camera extends Node {
  38074. /** @hidden */
  38075. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38076. /**
  38077. * This is the default projection mode used by the cameras.
  38078. * It helps recreating a feeling of perspective and better appreciate depth.
  38079. * This is the best way to simulate real life cameras.
  38080. */
  38081. static readonly PERSPECTIVE_CAMERA: number;
  38082. /**
  38083. * This helps creating camera with an orthographic mode.
  38084. * 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.
  38085. */
  38086. static readonly ORTHOGRAPHIC_CAMERA: number;
  38087. /**
  38088. * This is the default FOV mode for perspective cameras.
  38089. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38090. */
  38091. static readonly FOVMODE_VERTICAL_FIXED: number;
  38092. /**
  38093. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38094. */
  38095. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38096. /**
  38097. * This specifies there is no need for a camera rig.
  38098. * Basically only one eye is rendered corresponding to the camera.
  38099. */
  38100. static readonly RIG_MODE_NONE: number;
  38101. /**
  38102. * Simulates a camera Rig with one blue eye and one red eye.
  38103. * This can be use with 3d blue and red glasses.
  38104. */
  38105. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38106. /**
  38107. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38108. */
  38109. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38110. /**
  38111. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38112. */
  38113. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38114. /**
  38115. * Defines that both eyes of the camera will be rendered over under each other.
  38116. */
  38117. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38118. /**
  38119. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38120. */
  38121. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38122. /**
  38123. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38124. */
  38125. static readonly RIG_MODE_VR: number;
  38126. /**
  38127. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38128. */
  38129. static readonly RIG_MODE_WEBVR: number;
  38130. /**
  38131. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38132. */
  38133. static readonly RIG_MODE_CUSTOM: number;
  38134. /**
  38135. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38136. */
  38137. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38138. /**
  38139. * Define the input manager associated with the camera.
  38140. */
  38141. inputs: CameraInputsManager<Camera>;
  38142. /** @hidden */
  38143. _position: Vector3;
  38144. /**
  38145. * Define the current local position of the camera in the scene
  38146. */
  38147. get position(): Vector3;
  38148. set position(newPosition: Vector3);
  38149. protected _upVector: Vector3;
  38150. /**
  38151. * The vector the camera should consider as up.
  38152. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38153. */
  38154. set upVector(vec: Vector3);
  38155. get upVector(): Vector3;
  38156. /**
  38157. * Define the current limit on the left side for an orthographic camera
  38158. * In scene unit
  38159. */
  38160. orthoLeft: Nullable<number>;
  38161. /**
  38162. * Define the current limit on the right side for an orthographic camera
  38163. * In scene unit
  38164. */
  38165. orthoRight: Nullable<number>;
  38166. /**
  38167. * Define the current limit on the bottom side for an orthographic camera
  38168. * In scene unit
  38169. */
  38170. orthoBottom: Nullable<number>;
  38171. /**
  38172. * Define the current limit on the top side for an orthographic camera
  38173. * In scene unit
  38174. */
  38175. orthoTop: Nullable<number>;
  38176. /**
  38177. * Field Of View is set in Radians. (default is 0.8)
  38178. */
  38179. fov: number;
  38180. /**
  38181. * Define the minimum distance the camera can see from.
  38182. * This is important to note that the depth buffer are not infinite and the closer it starts
  38183. * the more your scene might encounter depth fighting issue.
  38184. */
  38185. minZ: number;
  38186. /**
  38187. * Define the maximum distance the camera can see to.
  38188. * This is important to note that the depth buffer are not infinite and the further it end
  38189. * the more your scene might encounter depth fighting issue.
  38190. */
  38191. maxZ: number;
  38192. /**
  38193. * Define the default inertia of the camera.
  38194. * This helps giving a smooth feeling to the camera movement.
  38195. */
  38196. inertia: number;
  38197. /**
  38198. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38199. */
  38200. mode: number;
  38201. /**
  38202. * Define whether the camera is intermediate.
  38203. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38204. */
  38205. isIntermediate: boolean;
  38206. /**
  38207. * Define the viewport of the camera.
  38208. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38209. */
  38210. viewport: Viewport;
  38211. /**
  38212. * Restricts the camera to viewing objects with the same layerMask.
  38213. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38214. */
  38215. layerMask: number;
  38216. /**
  38217. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38218. */
  38219. fovMode: number;
  38220. /**
  38221. * Rig mode of the camera.
  38222. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38223. * This is normally controlled byt the camera themselves as internal use.
  38224. */
  38225. cameraRigMode: number;
  38226. /**
  38227. * Defines the distance between both "eyes" in case of a RIG
  38228. */
  38229. interaxialDistance: number;
  38230. /**
  38231. * Defines if stereoscopic rendering is done side by side or over under.
  38232. */
  38233. isStereoscopicSideBySide: boolean;
  38234. /**
  38235. * 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
  38236. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38237. * else in the scene. (Eg. security camera)
  38238. *
  38239. * 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)
  38240. */
  38241. customRenderTargets: RenderTargetTexture[];
  38242. /**
  38243. * When set, the camera will render to this render target instead of the default canvas
  38244. *
  38245. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38246. */
  38247. outputRenderTarget: Nullable<RenderTargetTexture>;
  38248. /**
  38249. * Observable triggered when the camera view matrix has changed.
  38250. */
  38251. onViewMatrixChangedObservable: Observable<Camera>;
  38252. /**
  38253. * Observable triggered when the camera Projection matrix has changed.
  38254. */
  38255. onProjectionMatrixChangedObservable: Observable<Camera>;
  38256. /**
  38257. * Observable triggered when the inputs have been processed.
  38258. */
  38259. onAfterCheckInputsObservable: Observable<Camera>;
  38260. /**
  38261. * Observable triggered when reset has been called and applied to the camera.
  38262. */
  38263. onRestoreStateObservable: Observable<Camera>;
  38264. /**
  38265. * Is this camera a part of a rig system?
  38266. */
  38267. isRigCamera: boolean;
  38268. /**
  38269. * If isRigCamera set to true this will be set with the parent camera.
  38270. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38271. */
  38272. rigParent?: Camera;
  38273. /** @hidden */
  38274. _cameraRigParams: any;
  38275. /** @hidden */
  38276. _rigCameras: Camera[];
  38277. /** @hidden */
  38278. _rigPostProcess: Nullable<PostProcess>;
  38279. protected _webvrViewMatrix: Matrix;
  38280. /** @hidden */
  38281. _skipRendering: boolean;
  38282. /** @hidden */
  38283. _projectionMatrix: Matrix;
  38284. /** @hidden */
  38285. _postProcesses: Nullable<PostProcess>[];
  38286. /** @hidden */
  38287. _activeMeshes: SmartArray<AbstractMesh>;
  38288. protected _globalPosition: Vector3;
  38289. /** @hidden */
  38290. _computedViewMatrix: Matrix;
  38291. private _doNotComputeProjectionMatrix;
  38292. private _transformMatrix;
  38293. private _frustumPlanes;
  38294. private _refreshFrustumPlanes;
  38295. private _storedFov;
  38296. private _stateStored;
  38297. /**
  38298. * Instantiates a new camera object.
  38299. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38300. * @see https://doc.babylonjs.com/features/cameras
  38301. * @param name Defines the name of the camera in the scene
  38302. * @param position Defines the position of the camera
  38303. * @param scene Defines the scene the camera belongs too
  38304. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38305. */
  38306. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38307. /**
  38308. * Store current camera state (fov, position, etc..)
  38309. * @returns the camera
  38310. */
  38311. storeState(): Camera;
  38312. /**
  38313. * Restores the camera state values if it has been stored. You must call storeState() first
  38314. */
  38315. protected _restoreStateValues(): boolean;
  38316. /**
  38317. * Restored camera state. You must call storeState() first.
  38318. * @returns true if restored and false otherwise
  38319. */
  38320. restoreState(): boolean;
  38321. /**
  38322. * Gets the class name of the camera.
  38323. * @returns the class name
  38324. */
  38325. getClassName(): string;
  38326. /** @hidden */
  38327. readonly _isCamera: boolean;
  38328. /**
  38329. * Gets a string representation of the camera useful for debug purpose.
  38330. * @param fullDetails Defines that a more verboe level of logging is required
  38331. * @returns the string representation
  38332. */
  38333. toString(fullDetails?: boolean): string;
  38334. /**
  38335. * Gets the current world space position of the camera.
  38336. */
  38337. get globalPosition(): Vector3;
  38338. /**
  38339. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38340. * @returns the active meshe list
  38341. */
  38342. getActiveMeshes(): SmartArray<AbstractMesh>;
  38343. /**
  38344. * Check whether a mesh is part of the current active mesh list of the camera
  38345. * @param mesh Defines the mesh to check
  38346. * @returns true if active, false otherwise
  38347. */
  38348. isActiveMesh(mesh: Mesh): boolean;
  38349. /**
  38350. * Is this camera ready to be used/rendered
  38351. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38352. * @return true if the camera is ready
  38353. */
  38354. isReady(completeCheck?: boolean): boolean;
  38355. /** @hidden */
  38356. _initCache(): void;
  38357. /** @hidden */
  38358. _updateCache(ignoreParentClass?: boolean): void;
  38359. /** @hidden */
  38360. _isSynchronized(): boolean;
  38361. /** @hidden */
  38362. _isSynchronizedViewMatrix(): boolean;
  38363. /** @hidden */
  38364. _isSynchronizedProjectionMatrix(): boolean;
  38365. /**
  38366. * Attach the input controls to a specific dom element to get the input from.
  38367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38368. */
  38369. attachControl(noPreventDefault?: boolean): void;
  38370. /**
  38371. * Attach the input controls to a specific dom element to get the input from.
  38372. * @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
  38373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38374. * BACK COMPAT SIGNATURE ONLY.
  38375. */
  38376. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38377. /**
  38378. * Detach the current controls from the specified dom element.
  38379. */
  38380. detachControl(): void;
  38381. /**
  38382. * Detach the current controls from the specified dom element.
  38383. * @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
  38384. */
  38385. detachControl(ignored: any): void;
  38386. /**
  38387. * Update the camera state according to the different inputs gathered during the frame.
  38388. */
  38389. update(): void;
  38390. /** @hidden */
  38391. _checkInputs(): void;
  38392. /** @hidden */
  38393. get rigCameras(): Camera[];
  38394. /**
  38395. * Gets the post process used by the rig cameras
  38396. */
  38397. get rigPostProcess(): Nullable<PostProcess>;
  38398. /**
  38399. * Internal, gets the first post process.
  38400. * @returns the first post process to be run on this camera.
  38401. */
  38402. _getFirstPostProcess(): Nullable<PostProcess>;
  38403. private _cascadePostProcessesToRigCams;
  38404. /**
  38405. * Attach a post process to the camera.
  38406. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38407. * @param postProcess The post process to attach to the camera
  38408. * @param insertAt The position of the post process in case several of them are in use in the scene
  38409. * @returns the position the post process has been inserted at
  38410. */
  38411. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38412. /**
  38413. * Detach a post process to the camera.
  38414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38415. * @param postProcess The post process to detach from the camera
  38416. */
  38417. detachPostProcess(postProcess: PostProcess): void;
  38418. /**
  38419. * Gets the current world matrix of the camera
  38420. */
  38421. getWorldMatrix(): Matrix;
  38422. /** @hidden */
  38423. _getViewMatrix(): Matrix;
  38424. /**
  38425. * Gets the current view matrix of the camera.
  38426. * @param force forces the camera to recompute the matrix without looking at the cached state
  38427. * @returns the view matrix
  38428. */
  38429. getViewMatrix(force?: boolean): Matrix;
  38430. /**
  38431. * Freeze the projection matrix.
  38432. * It will prevent the cache check of the camera projection compute and can speed up perf
  38433. * if no parameter of the camera are meant to change
  38434. * @param projection Defines manually a projection if necessary
  38435. */
  38436. freezeProjectionMatrix(projection?: Matrix): void;
  38437. /**
  38438. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38439. */
  38440. unfreezeProjectionMatrix(): void;
  38441. /**
  38442. * Gets the current projection matrix of the camera.
  38443. * @param force forces the camera to recompute the matrix without looking at the cached state
  38444. * @returns the projection matrix
  38445. */
  38446. getProjectionMatrix(force?: boolean): Matrix;
  38447. /**
  38448. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38449. * @returns a Matrix
  38450. */
  38451. getTransformationMatrix(): Matrix;
  38452. private _updateFrustumPlanes;
  38453. /**
  38454. * Checks if a cullable object (mesh...) is in the camera frustum
  38455. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38456. * @param target The object to check
  38457. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38458. * @returns true if the object is in frustum otherwise false
  38459. */
  38460. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38461. /**
  38462. * Checks if a cullable object (mesh...) is in the camera frustum
  38463. * Unlike isInFrustum this checks the full bounding box
  38464. * @param target The object to check
  38465. * @returns true if the object is in frustum otherwise false
  38466. */
  38467. isCompletelyInFrustum(target: ICullable): boolean;
  38468. /**
  38469. * Gets a ray in the forward direction from the camera.
  38470. * @param length Defines the length of the ray to create
  38471. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38472. * @param origin Defines the start point of the ray which defaults to the camera position
  38473. * @returns the forward ray
  38474. */
  38475. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38476. /**
  38477. * Gets a ray in the forward direction from the camera.
  38478. * @param refRay the ray to (re)use when setting the values
  38479. * @param length Defines the length of the ray to create
  38480. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38481. * @param origin Defines the start point of the ray which defaults to the camera position
  38482. * @returns the forward ray
  38483. */
  38484. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38485. /**
  38486. * Releases resources associated with this node.
  38487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38489. */
  38490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38491. /** @hidden */
  38492. _isLeftCamera: boolean;
  38493. /**
  38494. * Gets the left camera of a rig setup in case of Rigged Camera
  38495. */
  38496. get isLeftCamera(): boolean;
  38497. /** @hidden */
  38498. _isRightCamera: boolean;
  38499. /**
  38500. * Gets the right camera of a rig setup in case of Rigged Camera
  38501. */
  38502. get isRightCamera(): boolean;
  38503. /**
  38504. * Gets the left camera of a rig setup in case of Rigged Camera
  38505. */
  38506. get leftCamera(): Nullable<FreeCamera>;
  38507. /**
  38508. * Gets the right camera of a rig setup in case of Rigged Camera
  38509. */
  38510. get rightCamera(): Nullable<FreeCamera>;
  38511. /**
  38512. * Gets the left camera target of a rig setup in case of Rigged Camera
  38513. * @returns the target position
  38514. */
  38515. getLeftTarget(): Nullable<Vector3>;
  38516. /**
  38517. * Gets the right camera target of a rig setup in case of Rigged Camera
  38518. * @returns the target position
  38519. */
  38520. getRightTarget(): Nullable<Vector3>;
  38521. /**
  38522. * @hidden
  38523. */
  38524. setCameraRigMode(mode: number, rigParams: any): void;
  38525. /** @hidden */
  38526. static _setStereoscopicRigMode(camera: Camera): void;
  38527. /** @hidden */
  38528. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38529. /** @hidden */
  38530. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38531. /** @hidden */
  38532. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38533. /** @hidden */
  38534. _getVRProjectionMatrix(): Matrix;
  38535. protected _updateCameraRotationMatrix(): void;
  38536. protected _updateWebVRCameraRotationMatrix(): void;
  38537. /**
  38538. * This function MUST be overwritten by the different WebVR cameras available.
  38539. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38540. * @hidden
  38541. */
  38542. _getWebVRProjectionMatrix(): Matrix;
  38543. /**
  38544. * This function MUST be overwritten by the different WebVR cameras available.
  38545. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38546. * @hidden
  38547. */
  38548. _getWebVRViewMatrix(): Matrix;
  38549. /** @hidden */
  38550. setCameraRigParameter(name: string, value: any): void;
  38551. /**
  38552. * needs to be overridden by children so sub has required properties to be copied
  38553. * @hidden
  38554. */
  38555. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38556. /**
  38557. * May need to be overridden by children
  38558. * @hidden
  38559. */
  38560. _updateRigCameras(): void;
  38561. /** @hidden */
  38562. _setupInputs(): void;
  38563. /**
  38564. * Serialiaze the camera setup to a json representation
  38565. * @returns the JSON representation
  38566. */
  38567. serialize(): any;
  38568. /**
  38569. * Clones the current camera.
  38570. * @param name The cloned camera name
  38571. * @returns the cloned camera
  38572. */
  38573. clone(name: string): Camera;
  38574. /**
  38575. * Gets the direction of the camera relative to a given local axis.
  38576. * @param localAxis Defines the reference axis to provide a relative direction.
  38577. * @return the direction
  38578. */
  38579. getDirection(localAxis: Vector3): Vector3;
  38580. /**
  38581. * Returns the current camera absolute rotation
  38582. */
  38583. get absoluteRotation(): Quaternion;
  38584. /**
  38585. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38586. * @param localAxis Defines the reference axis to provide a relative direction.
  38587. * @param result Defines the vector to store the result in
  38588. */
  38589. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38590. /**
  38591. * Gets a camera constructor for a given camera type
  38592. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38593. * @param name The name of the camera the result will be able to instantiate
  38594. * @param scene The scene the result will construct the camera in
  38595. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38596. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38597. * @returns a factory method to construct the camera
  38598. */
  38599. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38600. /**
  38601. * Compute the world matrix of the camera.
  38602. * @returns the camera world matrix
  38603. */
  38604. computeWorldMatrix(): Matrix;
  38605. /**
  38606. * Parse a JSON and creates the camera from the parsed information
  38607. * @param parsedCamera The JSON to parse
  38608. * @param scene The scene to instantiate the camera in
  38609. * @returns the newly constructed camera
  38610. */
  38611. static Parse(parsedCamera: any, scene: Scene): Camera;
  38612. }
  38613. }
  38614. declare module BABYLON {
  38615. /**
  38616. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38617. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38618. */
  38619. export class PostProcessManager {
  38620. private _scene;
  38621. private _indexBuffer;
  38622. private _vertexBuffers;
  38623. /**
  38624. * Creates a new instance PostProcess
  38625. * @param scene The scene that the post process is associated with.
  38626. */
  38627. constructor(scene: Scene);
  38628. private _prepareBuffers;
  38629. private _buildIndexBuffer;
  38630. /**
  38631. * Rebuilds the vertex buffers of the manager.
  38632. * @hidden
  38633. */
  38634. _rebuild(): void;
  38635. /**
  38636. * Prepares a frame to be run through a post process.
  38637. * @param sourceTexture The input texture to the post processes. (default: null)
  38638. * @param postProcesses An array of post processes to be run. (default: null)
  38639. * @returns True if the post processes were able to be run.
  38640. * @hidden
  38641. */
  38642. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38643. /**
  38644. * Manually render a set of post processes to a texture.
  38645. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38646. * @param postProcesses An array of post processes to be run.
  38647. * @param targetTexture The target texture to render to.
  38648. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38649. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38650. * @param lodLevel defines which lod of the texture to render to
  38651. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38652. */
  38653. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38654. /**
  38655. * Finalize the result of the output of the postprocesses.
  38656. * @param doNotPresent If true the result will not be displayed to the screen.
  38657. * @param targetTexture The target texture to render to.
  38658. * @param faceIndex The index of the face to bind the target texture to.
  38659. * @param postProcesses The array of post processes to render.
  38660. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38661. * @hidden
  38662. */
  38663. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38664. /**
  38665. * Disposes of the post process manager.
  38666. */
  38667. dispose(): void;
  38668. }
  38669. }
  38670. declare module BABYLON {
  38671. /**
  38672. * This Helps creating a texture that will be created from a camera in your scene.
  38673. * It is basically a dynamic texture that could be used to create special effects for instance.
  38674. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38675. */
  38676. export class RenderTargetTexture extends Texture {
  38677. /**
  38678. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38679. */
  38680. static readonly REFRESHRATE_RENDER_ONCE: number;
  38681. /**
  38682. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38683. */
  38684. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38685. /**
  38686. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38687. * the central point of your effect and can save a lot of performances.
  38688. */
  38689. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38690. /**
  38691. * Use this predicate to dynamically define the list of mesh you want to render.
  38692. * If set, the renderList property will be overwritten.
  38693. */
  38694. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38695. private _renderList;
  38696. /**
  38697. * Use this list to define the list of mesh you want to render.
  38698. */
  38699. get renderList(): Nullable<Array<AbstractMesh>>;
  38700. set renderList(value: Nullable<Array<AbstractMesh>>);
  38701. /**
  38702. * Use this function to overload the renderList array at rendering time.
  38703. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38704. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38705. * the cube (if the RTT is a cube, else layerOrFace=0).
  38706. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38707. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38708. * hold dummy elements!
  38709. */
  38710. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38711. private _hookArray;
  38712. /**
  38713. * Define if particles should be rendered in your texture.
  38714. */
  38715. renderParticles: boolean;
  38716. /**
  38717. * Define if sprites should be rendered in your texture.
  38718. */
  38719. renderSprites: boolean;
  38720. /**
  38721. * Define the camera used to render the texture.
  38722. */
  38723. activeCamera: Nullable<Camera>;
  38724. /**
  38725. * Override the mesh isReady function with your own one.
  38726. */
  38727. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38728. /**
  38729. * Override the render function of the texture with your own one.
  38730. */
  38731. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38732. /**
  38733. * Define if camera post processes should be use while rendering the texture.
  38734. */
  38735. useCameraPostProcesses: boolean;
  38736. /**
  38737. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38738. */
  38739. ignoreCameraViewport: boolean;
  38740. private _postProcessManager;
  38741. /**
  38742. * Post-processes for this render target
  38743. */
  38744. get postProcesses(): PostProcess[];
  38745. private _postProcesses;
  38746. private _resizeObserver;
  38747. private get _prePassEnabled();
  38748. /**
  38749. * An event triggered when the texture is unbind.
  38750. */
  38751. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38752. /**
  38753. * An event triggered when the texture is unbind.
  38754. */
  38755. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38756. private _onAfterUnbindObserver;
  38757. /**
  38758. * Set a after unbind callback in the texture.
  38759. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38760. */
  38761. set onAfterUnbind(callback: () => void);
  38762. /**
  38763. * An event triggered before rendering the texture
  38764. */
  38765. onBeforeRenderObservable: Observable<number>;
  38766. private _onBeforeRenderObserver;
  38767. /**
  38768. * Set a before render callback in the texture.
  38769. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38770. */
  38771. set onBeforeRender(callback: (faceIndex: number) => void);
  38772. /**
  38773. * An event triggered after rendering the texture
  38774. */
  38775. onAfterRenderObservable: Observable<number>;
  38776. private _onAfterRenderObserver;
  38777. /**
  38778. * Set a after render callback in the texture.
  38779. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38780. */
  38781. set onAfterRender(callback: (faceIndex: number) => void);
  38782. /**
  38783. * An event triggered after the texture clear
  38784. */
  38785. onClearObservable: Observable<Engine>;
  38786. private _onClearObserver;
  38787. /**
  38788. * Set a clear callback in the texture.
  38789. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38790. */
  38791. set onClear(callback: (Engine: Engine) => void);
  38792. /**
  38793. * An event triggered when the texture is resized.
  38794. */
  38795. onResizeObservable: Observable<RenderTargetTexture>;
  38796. /**
  38797. * Define the clear color of the Render Target if it should be different from the scene.
  38798. */
  38799. clearColor: Color4;
  38800. protected _size: number | {
  38801. width: number;
  38802. height: number;
  38803. layers?: number;
  38804. };
  38805. protected _initialSizeParameter: number | {
  38806. width: number;
  38807. height: number;
  38808. } | {
  38809. ratio: number;
  38810. };
  38811. protected _sizeRatio: Nullable<number>;
  38812. /** @hidden */
  38813. _generateMipMaps: boolean;
  38814. protected _renderingManager: RenderingManager;
  38815. /** @hidden */
  38816. _waitingRenderList?: string[];
  38817. protected _doNotChangeAspectRatio: boolean;
  38818. protected _currentRefreshId: number;
  38819. protected _refreshRate: number;
  38820. protected _textureMatrix: Matrix;
  38821. protected _samples: number;
  38822. protected _renderTargetOptions: RenderTargetCreationOptions;
  38823. /**
  38824. * Gets render target creation options that were used.
  38825. */
  38826. get renderTargetOptions(): RenderTargetCreationOptions;
  38827. protected _onRatioRescale(): void;
  38828. /**
  38829. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38830. * It must define where the camera used to render the texture is set
  38831. */
  38832. boundingBoxPosition: Vector3;
  38833. private _boundingBoxSize;
  38834. /**
  38835. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38836. * When defined, the cubemap will switch to local mode
  38837. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38838. * @example https://www.babylonjs-playground.com/#RNASML
  38839. */
  38840. set boundingBoxSize(value: Vector3);
  38841. get boundingBoxSize(): Vector3;
  38842. /**
  38843. * In case the RTT has been created with a depth texture, get the associated
  38844. * depth texture.
  38845. * Otherwise, return null.
  38846. */
  38847. get depthStencilTexture(): Nullable<InternalTexture>;
  38848. /**
  38849. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38850. * or used a shadow, depth texture...
  38851. * @param name The friendly name of the texture
  38852. * @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)
  38853. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38854. * @param generateMipMaps True if mip maps need to be generated after render.
  38855. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38856. * @param type The type of the buffer in the RTT (int, half float, float...)
  38857. * @param isCube True if a cube texture needs to be created
  38858. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38859. * @param generateDepthBuffer True to generate a depth buffer
  38860. * @param generateStencilBuffer True to generate a stencil buffer
  38861. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38862. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38863. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38864. * @param samples sample count to use when creating the RTT
  38865. */
  38866. constructor(name: string, size: number | {
  38867. width: number;
  38868. height: number;
  38869. layers?: number;
  38870. } | {
  38871. ratio: number;
  38872. }, 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);
  38873. /**
  38874. * Creates a depth stencil texture.
  38875. * This is only available in WebGL 2 or with the depth texture extension available.
  38876. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38877. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38878. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38879. * @param samples sample count of the depth/stencil texture
  38880. */
  38881. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38882. private _processSizeParameter;
  38883. /**
  38884. * Define the number of samples to use in case of MSAA.
  38885. * It defaults to one meaning no MSAA has been enabled.
  38886. */
  38887. get samples(): number;
  38888. set samples(value: number);
  38889. /**
  38890. * Resets the refresh counter of the texture and start bak from scratch.
  38891. * Could be useful to regenerate the texture if it is setup to render only once.
  38892. */
  38893. resetRefreshCounter(): void;
  38894. /**
  38895. * Define the refresh rate of the texture or the rendering frequency.
  38896. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38897. */
  38898. get refreshRate(): number;
  38899. set refreshRate(value: number);
  38900. /**
  38901. * Adds a post process to the render target rendering passes.
  38902. * @param postProcess define the post process to add
  38903. */
  38904. addPostProcess(postProcess: PostProcess): void;
  38905. /**
  38906. * Clear all the post processes attached to the render target
  38907. * @param dispose define if the cleared post processes should also be disposed (false by default)
  38908. */
  38909. clearPostProcesses(dispose?: boolean): void;
  38910. /**
  38911. * Remove one of the post process from the list of attached post processes to the texture
  38912. * @param postProcess define the post process to remove from the list
  38913. */
  38914. removePostProcess(postProcess: PostProcess): void;
  38915. /** @hidden */
  38916. _shouldRender(): boolean;
  38917. /**
  38918. * Gets the actual render size of the texture.
  38919. * @returns the width of the render size
  38920. */
  38921. getRenderSize(): number;
  38922. /**
  38923. * Gets the actual render width of the texture.
  38924. * @returns the width of the render size
  38925. */
  38926. getRenderWidth(): number;
  38927. /**
  38928. * Gets the actual render height of the texture.
  38929. * @returns the height of the render size
  38930. */
  38931. getRenderHeight(): number;
  38932. /**
  38933. * Gets the actual number of layers of the texture.
  38934. * @returns the number of layers
  38935. */
  38936. getRenderLayers(): number;
  38937. /**
  38938. * Get if the texture can be rescaled or not.
  38939. */
  38940. get canRescale(): boolean;
  38941. /**
  38942. * Resize the texture using a ratio.
  38943. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38944. */
  38945. scale(ratio: number): void;
  38946. /**
  38947. * Get the texture reflection matrix used to rotate/transform the reflection.
  38948. * @returns the reflection matrix
  38949. */
  38950. getReflectionTextureMatrix(): Matrix;
  38951. /**
  38952. * Resize the texture to a new desired size.
  38953. * Be careful as it will recreate all the data in the new texture.
  38954. * @param size Define the new size. It can be:
  38955. * - a number for squared texture,
  38956. * - an object containing { width: number, height: number }
  38957. * - or an object containing a ratio { ratio: number }
  38958. */
  38959. resize(size: number | {
  38960. width: number;
  38961. height: number;
  38962. } | {
  38963. ratio: number;
  38964. }): void;
  38965. private _defaultRenderListPrepared;
  38966. /**
  38967. * Renders all the objects from the render list into the texture.
  38968. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38969. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38970. */
  38971. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38972. private _bestReflectionRenderTargetDimension;
  38973. private _prepareRenderingManager;
  38974. /**
  38975. * @hidden
  38976. * @param faceIndex face index to bind to if this is a cubetexture
  38977. * @param layer defines the index of the texture to bind in the array
  38978. */
  38979. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38980. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38981. /**
  38982. * @hidden
  38983. */
  38984. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  38985. private renderToTarget;
  38986. /**
  38987. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  38988. * This allowed control for front to back rendering or reversely depending of the special needs.
  38989. *
  38990. * @param renderingGroupId The rendering group id corresponding to its index
  38991. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38992. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38993. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38994. */
  38995. 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;
  38996. /**
  38997. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38998. *
  38999. * @param renderingGroupId The rendering group id corresponding to its index
  39000. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39001. */
  39002. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39003. /**
  39004. * Clones the texture.
  39005. * @returns the cloned texture
  39006. */
  39007. clone(): RenderTargetTexture;
  39008. /**
  39009. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39010. * @returns The JSON representation of the texture
  39011. */
  39012. serialize(): any;
  39013. /**
  39014. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39015. */
  39016. disposeFramebufferObjects(): void;
  39017. /**
  39018. * Dispose the texture and release its associated resources.
  39019. */
  39020. dispose(): void;
  39021. /** @hidden */
  39022. _rebuild(): void;
  39023. /**
  39024. * Clear the info related to rendering groups preventing retention point in material dispose.
  39025. */
  39026. freeRenderingGroups(): void;
  39027. /**
  39028. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39029. * @returns the view count
  39030. */
  39031. getViewCount(): number;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * Options to be used when creating an effect.
  39037. */
  39038. export interface IEffectCreationOptions {
  39039. /**
  39040. * Attributes that will be used in the shader.
  39041. */
  39042. attributes: string[];
  39043. /**
  39044. * Uniform variable names that will be set in the shader.
  39045. */
  39046. uniformsNames: string[];
  39047. /**
  39048. * Uniform buffer variable names that will be set in the shader.
  39049. */
  39050. uniformBuffersNames: string[];
  39051. /**
  39052. * Sampler texture variable names that will be set in the shader.
  39053. */
  39054. samplers: string[];
  39055. /**
  39056. * Define statements that will be set in the shader.
  39057. */
  39058. defines: any;
  39059. /**
  39060. * Possible fallbacks for this effect to improve performance when needed.
  39061. */
  39062. fallbacks: Nullable<IEffectFallbacks>;
  39063. /**
  39064. * Callback that will be called when the shader is compiled.
  39065. */
  39066. onCompiled: Nullable<(effect: Effect) => void>;
  39067. /**
  39068. * Callback that will be called if an error occurs during shader compilation.
  39069. */
  39070. onError: Nullable<(effect: Effect, errors: string) => void>;
  39071. /**
  39072. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39073. */
  39074. indexParameters?: any;
  39075. /**
  39076. * Max number of lights that can be used in the shader.
  39077. */
  39078. maxSimultaneousLights?: number;
  39079. /**
  39080. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39081. */
  39082. transformFeedbackVaryings?: Nullable<string[]>;
  39083. /**
  39084. * 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
  39085. */
  39086. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39087. /**
  39088. * Is this effect rendering to several color attachments ?
  39089. */
  39090. multiTarget?: boolean;
  39091. }
  39092. /**
  39093. * Effect containing vertex and fragment shader that can be executed on an object.
  39094. */
  39095. export class Effect implements IDisposable {
  39096. /**
  39097. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39098. */
  39099. static ShadersRepository: string;
  39100. /**
  39101. * Enable logging of the shader code when a compilation error occurs
  39102. */
  39103. static LogShaderCodeOnCompilationError: boolean;
  39104. /**
  39105. * Name of the effect.
  39106. */
  39107. name: any;
  39108. /**
  39109. * String container all the define statements that should be set on the shader.
  39110. */
  39111. defines: string;
  39112. /**
  39113. * Callback that will be called when the shader is compiled.
  39114. */
  39115. onCompiled: Nullable<(effect: Effect) => void>;
  39116. /**
  39117. * Callback that will be called if an error occurs during shader compilation.
  39118. */
  39119. onError: Nullable<(effect: Effect, errors: string) => void>;
  39120. /**
  39121. * Callback that will be called when effect is bound.
  39122. */
  39123. onBind: Nullable<(effect: Effect) => void>;
  39124. /**
  39125. * Unique ID of the effect.
  39126. */
  39127. uniqueId: number;
  39128. /**
  39129. * Observable that will be called when the shader is compiled.
  39130. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39131. */
  39132. onCompileObservable: Observable<Effect>;
  39133. /**
  39134. * Observable that will be called if an error occurs during shader compilation.
  39135. */
  39136. onErrorObservable: Observable<Effect>;
  39137. /** @hidden */
  39138. _onBindObservable: Nullable<Observable<Effect>>;
  39139. /**
  39140. * @hidden
  39141. * Specifies if the effect was previously ready
  39142. */
  39143. _wasPreviouslyReady: boolean;
  39144. /**
  39145. * Observable that will be called when effect is bound.
  39146. */
  39147. get onBindObservable(): Observable<Effect>;
  39148. /** @hidden */
  39149. _bonesComputationForcedToCPU: boolean;
  39150. /** @hidden */
  39151. _uniformBuffersNames: {
  39152. [key: string]: number;
  39153. };
  39154. /** @hidden */
  39155. _samplerList: string[];
  39156. /** @hidden */
  39157. _multiTarget: boolean;
  39158. private static _uniqueIdSeed;
  39159. private _engine;
  39160. private _uniformBuffersNamesList;
  39161. private _uniformsNames;
  39162. private _samplers;
  39163. private _isReady;
  39164. private _compilationError;
  39165. private _allFallbacksProcessed;
  39166. private _attributesNames;
  39167. private _attributes;
  39168. private _attributeLocationByName;
  39169. private _uniforms;
  39170. /**
  39171. * Key for the effect.
  39172. * @hidden
  39173. */
  39174. _key: string;
  39175. private _indexParameters;
  39176. private _fallbacks;
  39177. private _vertexSourceCodeOverride;
  39178. private _fragmentSourceCodeOverride;
  39179. private _transformFeedbackVaryings;
  39180. /**
  39181. * Compiled shader to webGL program.
  39182. * @hidden
  39183. */
  39184. _pipelineContext: Nullable<IPipelineContext>;
  39185. /** @hidden */
  39186. _vertexSourceCode: string;
  39187. /** @hidden */
  39188. _fragmentSourceCode: string;
  39189. /** @hidden */
  39190. private _rawVertexSourceCode;
  39191. /** @hidden */
  39192. private _rawFragmentSourceCode;
  39193. private static _baseCache;
  39194. private _processingContext;
  39195. /**
  39196. * Instantiates an effect.
  39197. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39198. * @param baseName Name of the effect.
  39199. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39200. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39201. * @param samplers List of sampler variables that will be passed to the shader.
  39202. * @param engine Engine to be used to render the effect
  39203. * @param defines Define statements to be added to the shader.
  39204. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39205. * @param onCompiled Callback that will be called when the shader is compiled.
  39206. * @param onError Callback that will be called if an error occurs during shader compilation.
  39207. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39208. * @param key Effect Key identifying uniquely compiled shader variants
  39209. */
  39210. 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);
  39211. private _useFinalCode;
  39212. /**
  39213. * Unique key for this effect
  39214. */
  39215. get key(): string;
  39216. /**
  39217. * If the effect has been compiled and prepared.
  39218. * @returns if the effect is compiled and prepared.
  39219. */
  39220. isReady(): boolean;
  39221. private _isReadyInternal;
  39222. /**
  39223. * The engine the effect was initialized with.
  39224. * @returns the engine.
  39225. */
  39226. getEngine(): Engine;
  39227. /**
  39228. * The pipeline context for this effect
  39229. * @returns the associated pipeline context
  39230. */
  39231. getPipelineContext(): Nullable<IPipelineContext>;
  39232. /**
  39233. * The set of names of attribute variables for the shader.
  39234. * @returns An array of attribute names.
  39235. */
  39236. getAttributesNames(): string[];
  39237. /**
  39238. * Returns the attribute at the given index.
  39239. * @param index The index of the attribute.
  39240. * @returns The location of the attribute.
  39241. */
  39242. getAttributeLocation(index: number): number;
  39243. /**
  39244. * Returns the attribute based on the name of the variable.
  39245. * @param name of the attribute to look up.
  39246. * @returns the attribute location.
  39247. */
  39248. getAttributeLocationByName(name: string): number;
  39249. /**
  39250. * The number of attributes.
  39251. * @returns the number of attributes.
  39252. */
  39253. getAttributesCount(): number;
  39254. /**
  39255. * Gets the index of a uniform variable.
  39256. * @param uniformName of the uniform to look up.
  39257. * @returns the index.
  39258. */
  39259. getUniformIndex(uniformName: string): number;
  39260. /**
  39261. * Returns the attribute based on the name of the variable.
  39262. * @param uniformName of the uniform to look up.
  39263. * @returns the location of the uniform.
  39264. */
  39265. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39266. /**
  39267. * Returns an array of sampler variable names
  39268. * @returns The array of sampler variable names.
  39269. */
  39270. getSamplers(): string[];
  39271. /**
  39272. * Returns an array of uniform variable names
  39273. * @returns The array of uniform variable names.
  39274. */
  39275. getUniformNames(): string[];
  39276. /**
  39277. * Returns an array of uniform buffer variable names
  39278. * @returns The array of uniform buffer variable names.
  39279. */
  39280. getUniformBuffersNames(): string[];
  39281. /**
  39282. * Returns the index parameters used to create the effect
  39283. * @returns The index parameters object
  39284. */
  39285. getIndexParameters(): any;
  39286. /**
  39287. * The error from the last compilation.
  39288. * @returns the error string.
  39289. */
  39290. getCompilationError(): string;
  39291. /**
  39292. * Gets a boolean indicating that all fallbacks were used during compilation
  39293. * @returns true if all fallbacks were used
  39294. */
  39295. allFallbacksProcessed(): boolean;
  39296. /**
  39297. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39298. * @param func The callback to be used.
  39299. */
  39300. executeWhenCompiled(func: (effect: Effect) => void): void;
  39301. private _checkIsReady;
  39302. private _loadShader;
  39303. /**
  39304. * Gets the vertex shader source code of this effect
  39305. */
  39306. get vertexSourceCode(): string;
  39307. /**
  39308. * Gets the fragment shader source code of this effect
  39309. */
  39310. get fragmentSourceCode(): string;
  39311. /**
  39312. * Gets the vertex shader source code before it has been processed by the preprocessor
  39313. */
  39314. get rawVertexSourceCode(): string;
  39315. /**
  39316. * Gets the fragment shader source code before it has been processed by the preprocessor
  39317. */
  39318. get rawFragmentSourceCode(): string;
  39319. /**
  39320. * Recompiles the webGL program
  39321. * @param vertexSourceCode The source code for the vertex shader.
  39322. * @param fragmentSourceCode The source code for the fragment shader.
  39323. * @param onCompiled Callback called when completed.
  39324. * @param onError Callback called on error.
  39325. * @hidden
  39326. */
  39327. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39328. /**
  39329. * Prepares the effect
  39330. * @hidden
  39331. */
  39332. _prepareEffect(): void;
  39333. private _getShaderCodeAndErrorLine;
  39334. private _processCompilationErrors;
  39335. /**
  39336. * Checks if the effect is supported. (Must be called after compilation)
  39337. */
  39338. get isSupported(): boolean;
  39339. /**
  39340. * Binds a texture to the engine to be used as output of the shader.
  39341. * @param channel Name of the output variable.
  39342. * @param texture Texture to bind.
  39343. * @hidden
  39344. */
  39345. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39346. /**
  39347. * Sets a texture on the engine to be used in the shader.
  39348. * @param channel Name of the sampler variable.
  39349. * @param texture Texture to set.
  39350. */
  39351. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39352. /**
  39353. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39354. * @param channel Name of the sampler variable.
  39355. * @param texture Texture to set.
  39356. */
  39357. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39358. /**
  39359. * Sets an array of textures on the engine to be used in the shader.
  39360. * @param channel Name of the variable.
  39361. * @param textures Textures to set.
  39362. */
  39363. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39364. /**
  39365. * 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)
  39366. * @param channel Name of the sampler variable.
  39367. * @param postProcess Post process to get the input texture from.
  39368. */
  39369. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39370. /**
  39371. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39372. * 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)
  39373. * @param channel Name of the sampler variable.
  39374. * @param postProcess Post process to get the output texture from.
  39375. */
  39376. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39377. /**
  39378. * Binds a buffer to a uniform.
  39379. * @param buffer Buffer to bind.
  39380. * @param name Name of the uniform variable to bind to.
  39381. */
  39382. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39383. /**
  39384. * Binds block to a uniform.
  39385. * @param blockName Name of the block to bind.
  39386. * @param index Index to bind.
  39387. */
  39388. bindUniformBlock(blockName: string, index: number): void;
  39389. /**
  39390. * Sets an integer value on a uniform variable.
  39391. * @param uniformName Name of the variable.
  39392. * @param value Value to be set.
  39393. * @returns this effect.
  39394. */
  39395. setInt(uniformName: string, value: number): Effect;
  39396. /**
  39397. * Sets an int2 value on a uniform variable.
  39398. * @param uniformName Name of the variable.
  39399. * @param x First int in int2.
  39400. * @param y Second int in int2.
  39401. * @returns this effect.
  39402. */
  39403. setInt2(uniformName: string, x: number, y: number): Effect;
  39404. /**
  39405. * Sets an int3 value on a uniform variable.
  39406. * @param uniformName Name of the variable.
  39407. * @param x First int in int3.
  39408. * @param y Second int in int3.
  39409. * @param z Third int in int3.
  39410. * @returns this effect.
  39411. */
  39412. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39413. /**
  39414. * Sets an int4 value on a uniform variable.
  39415. * @param uniformName Name of the variable.
  39416. * @param x First int in int4.
  39417. * @param y Second int in int4.
  39418. * @param z Third int in int4.
  39419. * @param w Fourth int in int4.
  39420. * @returns this effect.
  39421. */
  39422. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39423. /**
  39424. * Sets an int array on a uniform variable.
  39425. * @param uniformName Name of the variable.
  39426. * @param array array to be set.
  39427. * @returns this effect.
  39428. */
  39429. setIntArray(uniformName: string, array: Int32Array): Effect;
  39430. /**
  39431. * 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)
  39432. * @param uniformName Name of the variable.
  39433. * @param array array to be set.
  39434. * @returns this effect.
  39435. */
  39436. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39437. /**
  39438. * 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)
  39439. * @param uniformName Name of the variable.
  39440. * @param array array to be set.
  39441. * @returns this effect.
  39442. */
  39443. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39444. /**
  39445. * 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)
  39446. * @param uniformName Name of the variable.
  39447. * @param array array to be set.
  39448. * @returns this effect.
  39449. */
  39450. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39451. /**
  39452. * Sets an float array on a uniform variable.
  39453. * @param uniformName Name of the variable.
  39454. * @param array array to be set.
  39455. * @returns this effect.
  39456. */
  39457. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39458. /**
  39459. * 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)
  39460. * @param uniformName Name of the variable.
  39461. * @param array array to be set.
  39462. * @returns this effect.
  39463. */
  39464. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39465. /**
  39466. * 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)
  39467. * @param uniformName Name of the variable.
  39468. * @param array array to be set.
  39469. * @returns this effect.
  39470. */
  39471. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39472. /**
  39473. * 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)
  39474. * @param uniformName Name of the variable.
  39475. * @param array array to be set.
  39476. * @returns this effect.
  39477. */
  39478. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39479. /**
  39480. * Sets an array on a uniform variable.
  39481. * @param uniformName Name of the variable.
  39482. * @param array array to be set.
  39483. * @returns this effect.
  39484. */
  39485. setArray(uniformName: string, array: number[]): Effect;
  39486. /**
  39487. * 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)
  39488. * @param uniformName Name of the variable.
  39489. * @param array array to be set.
  39490. * @returns this effect.
  39491. */
  39492. setArray2(uniformName: string, array: number[]): Effect;
  39493. /**
  39494. * 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)
  39495. * @param uniformName Name of the variable.
  39496. * @param array array to be set.
  39497. * @returns this effect.
  39498. */
  39499. setArray3(uniformName: string, array: number[]): Effect;
  39500. /**
  39501. * 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)
  39502. * @param uniformName Name of the variable.
  39503. * @param array array to be set.
  39504. * @returns this effect.
  39505. */
  39506. setArray4(uniformName: string, array: number[]): Effect;
  39507. /**
  39508. * Sets matrices on a uniform variable.
  39509. * @param uniformName Name of the variable.
  39510. * @param matrices matrices to be set.
  39511. * @returns this effect.
  39512. */
  39513. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39514. /**
  39515. * Sets matrix on a uniform variable.
  39516. * @param uniformName Name of the variable.
  39517. * @param matrix matrix to be set.
  39518. * @returns this effect.
  39519. */
  39520. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39521. /**
  39522. * 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)
  39523. * @param uniformName Name of the variable.
  39524. * @param matrix matrix to be set.
  39525. * @returns this effect.
  39526. */
  39527. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39528. /**
  39529. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39530. * @param uniformName Name of the variable.
  39531. * @param matrix matrix to be set.
  39532. * @returns this effect.
  39533. */
  39534. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39535. /**
  39536. * Sets a float on a uniform variable.
  39537. * @param uniformName Name of the variable.
  39538. * @param value value to be set.
  39539. * @returns this effect.
  39540. */
  39541. setFloat(uniformName: string, value: number): Effect;
  39542. /**
  39543. * Sets a boolean on a uniform variable.
  39544. * @param uniformName Name of the variable.
  39545. * @param bool value to be set.
  39546. * @returns this effect.
  39547. */
  39548. setBool(uniformName: string, bool: boolean): Effect;
  39549. /**
  39550. * Sets a Vector2 on a uniform variable.
  39551. * @param uniformName Name of the variable.
  39552. * @param vector2 vector2 to be set.
  39553. * @returns this effect.
  39554. */
  39555. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39556. /**
  39557. * Sets a float2 on a uniform variable.
  39558. * @param uniformName Name of the variable.
  39559. * @param x First float in float2.
  39560. * @param y Second float in float2.
  39561. * @returns this effect.
  39562. */
  39563. setFloat2(uniformName: string, x: number, y: number): Effect;
  39564. /**
  39565. * Sets a Vector3 on a uniform variable.
  39566. * @param uniformName Name of the variable.
  39567. * @param vector3 Value to be set.
  39568. * @returns this effect.
  39569. */
  39570. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39571. /**
  39572. * Sets a float3 on a uniform variable.
  39573. * @param uniformName Name of the variable.
  39574. * @param x First float in float3.
  39575. * @param y Second float in float3.
  39576. * @param z Third float in float3.
  39577. * @returns this effect.
  39578. */
  39579. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39580. /**
  39581. * Sets a Vector4 on a uniform variable.
  39582. * @param uniformName Name of the variable.
  39583. * @param vector4 Value to be set.
  39584. * @returns this effect.
  39585. */
  39586. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39587. /**
  39588. * Sets a float4 on a uniform variable.
  39589. * @param uniformName Name of the variable.
  39590. * @param x First float in float4.
  39591. * @param y Second float in float4.
  39592. * @param z Third float in float4.
  39593. * @param w Fourth float in float4.
  39594. * @returns this effect.
  39595. */
  39596. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39597. /**
  39598. * Sets a Color3 on a uniform variable.
  39599. * @param uniformName Name of the variable.
  39600. * @param color3 Value to be set.
  39601. * @returns this effect.
  39602. */
  39603. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39604. /**
  39605. * Sets a Color4 on a uniform variable.
  39606. * @param uniformName Name of the variable.
  39607. * @param color3 Value to be set.
  39608. * @param alpha Alpha value to be set.
  39609. * @returns this effect.
  39610. */
  39611. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39612. /**
  39613. * Sets a Color4 on a uniform variable
  39614. * @param uniformName defines the name of the variable
  39615. * @param color4 defines the value to be set
  39616. * @returns this effect.
  39617. */
  39618. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39619. /**
  39620. * Release all associated resources.
  39621. **/
  39622. dispose(): void;
  39623. /**
  39624. * This function will add a new shader to the shader store
  39625. * @param name the name of the shader
  39626. * @param pixelShader optional pixel shader content
  39627. * @param vertexShader optional vertex shader content
  39628. */
  39629. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39630. /**
  39631. * Store of each shader (The can be looked up using effect.key)
  39632. */
  39633. static ShadersStore: {
  39634. [key: string]: string;
  39635. };
  39636. /**
  39637. * Store of each included file for a shader (The can be looked up using effect.key)
  39638. */
  39639. static IncludesShadersStore: {
  39640. [key: string]: string;
  39641. };
  39642. /**
  39643. * Resets the cache of effects.
  39644. */
  39645. static ResetCache(): void;
  39646. }
  39647. }
  39648. declare module BABYLON {
  39649. /**
  39650. * Interface used to describe the capabilities of the engine relatively to the current browser
  39651. */
  39652. export interface EngineCapabilities {
  39653. /** Maximum textures units per fragment shader */
  39654. maxTexturesImageUnits: number;
  39655. /** Maximum texture units per vertex shader */
  39656. maxVertexTextureImageUnits: number;
  39657. /** Maximum textures units in the entire pipeline */
  39658. maxCombinedTexturesImageUnits: number;
  39659. /** Maximum texture size */
  39660. maxTextureSize: number;
  39661. /** Maximum texture samples */
  39662. maxSamples?: number;
  39663. /** Maximum cube texture size */
  39664. maxCubemapTextureSize: number;
  39665. /** Maximum render texture size */
  39666. maxRenderTextureSize: number;
  39667. /** Maximum number of vertex attributes */
  39668. maxVertexAttribs: number;
  39669. /** Maximum number of varyings */
  39670. maxVaryingVectors: number;
  39671. /** Maximum number of uniforms per vertex shader */
  39672. maxVertexUniformVectors: number;
  39673. /** Maximum number of uniforms per fragment shader */
  39674. maxFragmentUniformVectors: number;
  39675. /** Defines if standard derivatives (dx/dy) are supported */
  39676. standardDerivatives: boolean;
  39677. /** Defines if s3tc texture compression is supported */
  39678. s3tc?: WEBGL_compressed_texture_s3tc;
  39679. /** Defines if pvrtc texture compression is supported */
  39680. pvrtc: any;
  39681. /** Defines if etc1 texture compression is supported */
  39682. etc1: any;
  39683. /** Defines if etc2 texture compression is supported */
  39684. etc2: any;
  39685. /** Defines if astc texture compression is supported */
  39686. astc: any;
  39687. /** Defines if bptc texture compression is supported */
  39688. bptc: any;
  39689. /** Defines if float textures are supported */
  39690. textureFloat: boolean;
  39691. /** Defines if vertex array objects are supported */
  39692. vertexArrayObject: boolean;
  39693. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39694. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39695. /** Gets the maximum level of anisotropy supported */
  39696. maxAnisotropy: number;
  39697. /** Defines if instancing is supported */
  39698. instancedArrays: boolean;
  39699. /** Defines if 32 bits indices are supported */
  39700. uintIndices: boolean;
  39701. /** Defines if high precision shaders are supported */
  39702. highPrecisionShaderSupported: boolean;
  39703. /** Defines if depth reading in the fragment shader is supported */
  39704. fragmentDepthSupported: boolean;
  39705. /** Defines if float texture linear filtering is supported*/
  39706. textureFloatLinearFiltering: boolean;
  39707. /** Defines if rendering to float textures is supported */
  39708. textureFloatRender: boolean;
  39709. /** Defines if half float textures are supported*/
  39710. textureHalfFloat: boolean;
  39711. /** Defines if half float texture linear filtering is supported*/
  39712. textureHalfFloatLinearFiltering: boolean;
  39713. /** Defines if rendering to half float textures is supported */
  39714. textureHalfFloatRender: boolean;
  39715. /** Defines if textureLOD shader command is supported */
  39716. textureLOD: boolean;
  39717. /** Defines if draw buffers extension is supported */
  39718. drawBuffersExtension: boolean;
  39719. /** Defines if depth textures are supported */
  39720. depthTextureExtension: boolean;
  39721. /** Defines if float color buffer are supported */
  39722. colorBufferFloat: boolean;
  39723. /** Gets disjoint timer query extension (null if not supported) */
  39724. timerQuery?: EXT_disjoint_timer_query;
  39725. /** Defines if timestamp can be used with timer query */
  39726. canUseTimestampForTimerQuery: boolean;
  39727. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39728. multiview?: any;
  39729. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39730. oculusMultiview?: any;
  39731. /** Function used to let the system compiles shaders in background */
  39732. parallelShaderCompile?: {
  39733. COMPLETION_STATUS_KHR: number;
  39734. };
  39735. /** Max number of texture samples for MSAA */
  39736. maxMSAASamples: number;
  39737. /** Defines if the blend min max extension is supported */
  39738. blendMinMax: boolean;
  39739. /** 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 */
  39740. canUseGLInstanceID: boolean;
  39741. }
  39742. }
  39743. declare module BABYLON {
  39744. /**
  39745. * @hidden
  39746. **/
  39747. export class DepthCullingState {
  39748. protected _isDepthTestDirty: boolean;
  39749. protected _isDepthMaskDirty: boolean;
  39750. protected _isDepthFuncDirty: boolean;
  39751. protected _isCullFaceDirty: boolean;
  39752. protected _isCullDirty: boolean;
  39753. protected _isZOffsetDirty: boolean;
  39754. protected _isFrontFaceDirty: boolean;
  39755. protected _depthTest: boolean;
  39756. protected _depthMask: boolean;
  39757. protected _depthFunc: Nullable<number>;
  39758. protected _cull: Nullable<boolean>;
  39759. protected _cullFace: Nullable<number>;
  39760. protected _zOffset: number;
  39761. protected _frontFace: Nullable<number>;
  39762. /**
  39763. * Initializes the state.
  39764. */
  39765. constructor(reset?: boolean);
  39766. get isDirty(): boolean;
  39767. get zOffset(): number;
  39768. set zOffset(value: number);
  39769. get cullFace(): Nullable<number>;
  39770. set cullFace(value: Nullable<number>);
  39771. get cull(): Nullable<boolean>;
  39772. set cull(value: Nullable<boolean>);
  39773. get depthFunc(): Nullable<number>;
  39774. set depthFunc(value: Nullable<number>);
  39775. get depthMask(): boolean;
  39776. set depthMask(value: boolean);
  39777. get depthTest(): boolean;
  39778. set depthTest(value: boolean);
  39779. get frontFace(): Nullable<number>;
  39780. set frontFace(value: Nullable<number>);
  39781. reset(): void;
  39782. apply(gl: WebGLRenderingContext): void;
  39783. }
  39784. }
  39785. declare module BABYLON {
  39786. /**
  39787. * @hidden
  39788. **/
  39789. export class StencilState {
  39790. /** 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 */
  39791. static readonly ALWAYS: number;
  39792. /** Passed to stencilOperation to specify that stencil value must be kept */
  39793. static readonly KEEP: number;
  39794. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39795. static readonly REPLACE: number;
  39796. protected _isStencilTestDirty: boolean;
  39797. protected _isStencilMaskDirty: boolean;
  39798. protected _isStencilFuncDirty: boolean;
  39799. protected _isStencilOpDirty: boolean;
  39800. protected _stencilTest: boolean;
  39801. protected _stencilMask: number;
  39802. protected _stencilFunc: number;
  39803. protected _stencilFuncRef: number;
  39804. protected _stencilFuncMask: number;
  39805. protected _stencilOpStencilFail: number;
  39806. protected _stencilOpDepthFail: number;
  39807. protected _stencilOpStencilDepthPass: number;
  39808. get isDirty(): boolean;
  39809. get stencilFunc(): number;
  39810. set stencilFunc(value: number);
  39811. get stencilFuncRef(): number;
  39812. set stencilFuncRef(value: number);
  39813. get stencilFuncMask(): number;
  39814. set stencilFuncMask(value: number);
  39815. get stencilOpStencilFail(): number;
  39816. set stencilOpStencilFail(value: number);
  39817. get stencilOpDepthFail(): number;
  39818. set stencilOpDepthFail(value: number);
  39819. get stencilOpStencilDepthPass(): number;
  39820. set stencilOpStencilDepthPass(value: number);
  39821. get stencilMask(): number;
  39822. set stencilMask(value: number);
  39823. get stencilTest(): boolean;
  39824. set stencilTest(value: boolean);
  39825. constructor(reset?: boolean);
  39826. reset(): void;
  39827. apply(gl: WebGLRenderingContext): void;
  39828. }
  39829. }
  39830. declare module BABYLON {
  39831. /**
  39832. * @hidden
  39833. **/
  39834. export class AlphaState {
  39835. _blendFunctionParameters: Nullable<number>[];
  39836. _blendEquationParameters: Nullable<number>[];
  39837. _blendConstants: Nullable<number>[];
  39838. _isBlendConstantsDirty: boolean;
  39839. private _alphaBlend;
  39840. private _isAlphaBlendDirty;
  39841. private _isBlendFunctionParametersDirty;
  39842. private _isBlendEquationParametersDirty;
  39843. /**
  39844. * Initializes the state.
  39845. */
  39846. constructor();
  39847. get isDirty(): boolean;
  39848. get alphaBlend(): boolean;
  39849. set alphaBlend(value: boolean);
  39850. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39851. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39852. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39853. reset(): void;
  39854. apply(gl: WebGLRenderingContext): void;
  39855. }
  39856. }
  39857. declare module BABYLON {
  39858. /** @hidden */
  39859. export class WebGLShaderProcessor implements IShaderProcessor {
  39860. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39861. }
  39862. }
  39863. declare module BABYLON {
  39864. /** @hidden */
  39865. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39866. attributeProcessor(attribute: string): string;
  39867. varyingProcessor(varying: string, isFragment: boolean): string;
  39868. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39869. }
  39870. }
  39871. declare module BABYLON {
  39872. /**
  39873. * Interface for attribute information associated with buffer instantiation
  39874. */
  39875. export interface InstancingAttributeInfo {
  39876. /**
  39877. * Name of the GLSL attribute
  39878. * if attribute index is not specified, this is used to retrieve the index from the effect
  39879. */
  39880. attributeName: string;
  39881. /**
  39882. * Index/offset of the attribute in the vertex shader
  39883. * if not specified, this will be computes from the name.
  39884. */
  39885. index?: number;
  39886. /**
  39887. * size of the attribute, 1, 2, 3 or 4
  39888. */
  39889. attributeSize: number;
  39890. /**
  39891. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39892. */
  39893. offset: number;
  39894. /**
  39895. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39896. * default to 1
  39897. */
  39898. divisor?: number;
  39899. /**
  39900. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39901. * default is FLOAT
  39902. */
  39903. attributeType?: number;
  39904. /**
  39905. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39906. */
  39907. normalized?: boolean;
  39908. }
  39909. }
  39910. declare module BABYLON {
  39911. /** @hidden */
  39912. export interface EngineFeatures {
  39913. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39914. forceBitmapOverHTMLImageElement: boolean;
  39915. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39916. supportRenderAndCopyToLodForFloatTextures: boolean;
  39917. /** Indicates that the engine support handling depth/stencil textures */
  39918. supportDepthStencilTexture: boolean;
  39919. /** Indicates that the engine support shadow samplers */
  39920. supportShadowSamplers: boolean;
  39921. /** 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 */
  39922. uniformBufferHardCheckMatrix: boolean;
  39923. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39924. allowTexturePrefiltering: boolean;
  39925. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39926. trackUbosInFrame: boolean;
  39927. /** Indicates that the Cascaded Shadow Map technic is supported */
  39928. supportCSM: boolean;
  39929. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39930. basisNeedsPOT: boolean;
  39931. /** Indicates that the engine supports 3D textures */
  39932. support3DTextures: boolean;
  39933. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39934. needTypeSuffixInShaderConstants: boolean;
  39935. /** Indicates that MSAA is supported */
  39936. supportMSAA: boolean;
  39937. /** Indicates that SSAO2 is supported */
  39938. supportSSAO2: boolean;
  39939. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39940. supportExtendedTextureFormats: boolean;
  39941. /** Indicates that the switch/case construct is supported in shaders */
  39942. supportSwitchCaseInShader: boolean;
  39943. /** Indicates that synchronous texture reading is supported */
  39944. supportSyncTextureRead: boolean;
  39945. /** @hidden */
  39946. _collectUbosUpdatedInFrame: boolean;
  39947. }
  39948. }
  39949. declare module BABYLON {
  39950. /** @hidden */
  39951. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39952. private _webGLTexture;
  39953. private _context;
  39954. get underlyingResource(): Nullable<WebGLTexture>;
  39955. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39956. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39957. set(hardwareTexture: WebGLTexture): void;
  39958. reset(): void;
  39959. release(): void;
  39960. }
  39961. }
  39962. declare module BABYLON {
  39963. interface ThinEngine {
  39964. /**
  39965. * Update a video texture
  39966. * @param texture defines the texture to update
  39967. * @param video defines the video element to use
  39968. * @param invertY defines if data must be stored with Y axis inverted
  39969. */
  39970. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39971. }
  39972. }
  39973. declare module BABYLON {
  39974. interface ThinEngine {
  39975. /**
  39976. * Creates a dynamic texture
  39977. * @param width defines the width of the texture
  39978. * @param height defines the height of the texture
  39979. * @param generateMipMaps defines if the engine should generate the mip levels
  39980. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39981. * @returns the dynamic texture inside an InternalTexture
  39982. */
  39983. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39984. /**
  39985. * Update the content of a dynamic texture
  39986. * @param texture defines the texture to update
  39987. * @param source defines the source containing the data
  39988. * @param invertY defines if data must be stored with Y axis inverted
  39989. * @param premulAlpha defines if alpha is stored as premultiplied
  39990. * @param format defines the format of the data
  39991. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39992. */
  39993. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39994. }
  39995. }
  39996. declare module BABYLON {
  39997. /**
  39998. * Settings for finer control over video usage
  39999. */
  40000. export interface VideoTextureSettings {
  40001. /**
  40002. * Applies `autoplay` to video, if specified
  40003. */
  40004. autoPlay?: boolean;
  40005. /**
  40006. * Applies `muted` to video, if specified
  40007. */
  40008. muted?: boolean;
  40009. /**
  40010. * Applies `loop` to video, if specified
  40011. */
  40012. loop?: boolean;
  40013. /**
  40014. * Automatically updates internal texture from video at every frame in the render loop
  40015. */
  40016. autoUpdateTexture: boolean;
  40017. /**
  40018. * Image src displayed during the video loading or until the user interacts with the video.
  40019. */
  40020. poster?: string;
  40021. }
  40022. /**
  40023. * If you want to display a video in your scene, this is the special texture for that.
  40024. * This special texture works similar to other textures, with the exception of a few parameters.
  40025. * @see https://doc.babylonjs.com/how_to/video_texture
  40026. */
  40027. export class VideoTexture extends Texture {
  40028. /**
  40029. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40030. */
  40031. readonly autoUpdateTexture: boolean;
  40032. /**
  40033. * The video instance used by the texture internally
  40034. */
  40035. readonly video: HTMLVideoElement;
  40036. private _onUserActionRequestedObservable;
  40037. /**
  40038. * Event triggered when a dom action is required by the user to play the video.
  40039. * This happens due to recent changes in browser policies preventing video to auto start.
  40040. */
  40041. get onUserActionRequestedObservable(): Observable<Texture>;
  40042. private _generateMipMaps;
  40043. private _stillImageCaptured;
  40044. private _displayingPosterTexture;
  40045. private _settings;
  40046. private _createInternalTextureOnEvent;
  40047. private _frameId;
  40048. private _currentSrc;
  40049. /**
  40050. * Creates a video texture.
  40051. * If you want to display a video in your scene, this is the special texture for that.
  40052. * This special texture works similar to other textures, with the exception of a few parameters.
  40053. * @see https://doc.babylonjs.com/how_to/video_texture
  40054. * @param name optional name, will detect from video source, if not defined
  40055. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40056. * @param scene is obviously the current scene.
  40057. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40058. * @param invertY is false by default but can be used to invert video on Y axis
  40059. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40060. * @param settings allows finer control over video usage
  40061. */
  40062. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40063. private _getName;
  40064. private _getVideo;
  40065. private _createInternalTexture;
  40066. private reset;
  40067. /**
  40068. * @hidden Internal method to initiate `update`.
  40069. */
  40070. _rebuild(): void;
  40071. /**
  40072. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40073. */
  40074. update(): void;
  40075. /**
  40076. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40077. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40078. */
  40079. updateTexture(isVisible: boolean): void;
  40080. protected _updateInternalTexture: () => void;
  40081. /**
  40082. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40083. * @param url New url.
  40084. */
  40085. updateURL(url: string): void;
  40086. /**
  40087. * Clones the texture.
  40088. * @returns the cloned texture
  40089. */
  40090. clone(): VideoTexture;
  40091. /**
  40092. * Dispose the texture and release its associated resources.
  40093. */
  40094. dispose(): void;
  40095. /**
  40096. * Creates a video texture straight from a stream.
  40097. * @param scene Define the scene the texture should be created in
  40098. * @param stream Define the stream the texture should be created from
  40099. * @returns The created video texture as a promise
  40100. */
  40101. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40102. /**
  40103. * Creates a video texture straight from your WebCam video feed.
  40104. * @param scene Define the scene the texture should be created in
  40105. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40106. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40107. * @returns The created video texture as a promise
  40108. */
  40109. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40110. minWidth: number;
  40111. maxWidth: number;
  40112. minHeight: number;
  40113. maxHeight: number;
  40114. deviceId: string;
  40115. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40116. /**
  40117. * Creates a video texture straight from your WebCam video feed.
  40118. * @param scene Define the scene the texture should be created in
  40119. * @param onReady Define a callback to triggered once the texture will be ready
  40120. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40121. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40122. */
  40123. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40124. minWidth: number;
  40125. maxWidth: number;
  40126. minHeight: number;
  40127. maxHeight: number;
  40128. deviceId: string;
  40129. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40130. }
  40131. }
  40132. declare module BABYLON {
  40133. /**
  40134. * Defines the interface used by objects working like Scene
  40135. * @hidden
  40136. */
  40137. export interface ISceneLike {
  40138. _addPendingData(data: any): void;
  40139. _removePendingData(data: any): void;
  40140. offlineProvider: IOfflineProvider;
  40141. }
  40142. /**
  40143. * Information about the current host
  40144. */
  40145. export interface HostInformation {
  40146. /**
  40147. * Defines if the current host is a mobile
  40148. */
  40149. isMobile: boolean;
  40150. }
  40151. /** Interface defining initialization parameters for Engine class */
  40152. export interface EngineOptions extends WebGLContextAttributes {
  40153. /**
  40154. * Defines if the engine should no exceed a specified device ratio
  40155. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40156. */
  40157. limitDeviceRatio?: number;
  40158. /**
  40159. * Defines if webvr should be enabled automatically
  40160. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40161. */
  40162. autoEnableWebVR?: boolean;
  40163. /**
  40164. * Defines if webgl2 should be turned off even if supported
  40165. * @see https://doc.babylonjs.com/features/webgl2
  40166. */
  40167. disableWebGL2Support?: boolean;
  40168. /**
  40169. * Defines if webaudio should be initialized as well
  40170. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40171. */
  40172. audioEngine?: boolean;
  40173. /**
  40174. * Defines if animations should run using a deterministic lock step
  40175. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40176. */
  40177. deterministicLockstep?: boolean;
  40178. /** Defines the maximum steps to use with deterministic lock step mode */
  40179. lockstepMaxSteps?: number;
  40180. /** Defines the seconds between each deterministic lock step */
  40181. timeStep?: number;
  40182. /**
  40183. * Defines that engine should ignore context lost events
  40184. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40185. */
  40186. doNotHandleContextLost?: boolean;
  40187. /**
  40188. * Defines that engine should ignore modifying touch action attribute and style
  40189. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40190. */
  40191. doNotHandleTouchAction?: boolean;
  40192. /**
  40193. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40194. */
  40195. useHighPrecisionFloats?: boolean;
  40196. /**
  40197. * Make the canvas XR Compatible for XR sessions
  40198. */
  40199. xrCompatible?: boolean;
  40200. /**
  40201. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40202. */
  40203. useHighPrecisionMatrix?: boolean;
  40204. /**
  40205. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40206. */
  40207. failIfMajorPerformanceCaveat?: boolean;
  40208. /**
  40209. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40210. */
  40211. adaptToDeviceRatio?: boolean;
  40212. }
  40213. /**
  40214. * The base engine class (root of all engines)
  40215. */
  40216. export class ThinEngine {
  40217. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40218. static ExceptionList: ({
  40219. key: string;
  40220. capture: string;
  40221. captureConstraint: number;
  40222. targets: string[];
  40223. } | {
  40224. key: string;
  40225. capture: null;
  40226. captureConstraint: null;
  40227. targets: string[];
  40228. })[];
  40229. /** @hidden */
  40230. static _TextureLoaders: IInternalTextureLoader[];
  40231. /**
  40232. * Returns the current npm package of the sdk
  40233. */
  40234. static get NpmPackage(): string;
  40235. /**
  40236. * Returns the current version of the framework
  40237. */
  40238. static get Version(): string;
  40239. /**
  40240. * Returns a string describing the current engine
  40241. */
  40242. get description(): string;
  40243. /**
  40244. * Returns the name of the engine
  40245. */
  40246. get name(): string;
  40247. /**
  40248. * Returns the version of the engine
  40249. */
  40250. get version(): number;
  40251. /**
  40252. * Gets or sets the epsilon value used by collision engine
  40253. */
  40254. static CollisionsEpsilon: number;
  40255. /**
  40256. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40257. */
  40258. static get ShadersRepository(): string;
  40259. static set ShadersRepository(value: string);
  40260. /** @hidden */
  40261. _shaderProcessor: Nullable<IShaderProcessor>;
  40262. /**
  40263. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40264. */
  40265. forcePOTTextures: boolean;
  40266. /**
  40267. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40268. */
  40269. isFullscreen: boolean;
  40270. /**
  40271. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40272. */
  40273. cullBackFaces: boolean;
  40274. /**
  40275. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40276. */
  40277. renderEvenInBackground: boolean;
  40278. /**
  40279. * Gets or sets a boolean indicating that cache can be kept between frames
  40280. */
  40281. preventCacheWipeBetweenFrames: boolean;
  40282. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40283. validateShaderPrograms: boolean;
  40284. /**
  40285. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40286. * This can provide greater z depth for distant objects.
  40287. */
  40288. useReverseDepthBuffer: boolean;
  40289. /**
  40290. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40291. */
  40292. disableUniformBuffers: boolean;
  40293. private _frameId;
  40294. /**
  40295. * Gets the current frame id
  40296. */
  40297. get frameId(): number;
  40298. /** @hidden */
  40299. _uniformBuffers: UniformBuffer[];
  40300. /**
  40301. * Gets a boolean indicating that the engine supports uniform buffers
  40302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40303. */
  40304. get supportsUniformBuffers(): boolean;
  40305. /** @hidden */
  40306. _gl: WebGLRenderingContext;
  40307. /** @hidden */
  40308. _webGLVersion: number;
  40309. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40310. protected _windowIsBackground: boolean;
  40311. protected _creationOptions: EngineOptions;
  40312. protected _highPrecisionShadersAllowed: boolean;
  40313. /** @hidden */
  40314. get _shouldUseHighPrecisionShader(): boolean;
  40315. /**
  40316. * Gets a boolean indicating that only power of 2 textures are supported
  40317. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40318. */
  40319. get needPOTTextures(): boolean;
  40320. /** @hidden */
  40321. _badOS: boolean;
  40322. /** @hidden */
  40323. _badDesktopOS: boolean;
  40324. protected _hardwareScalingLevel: number;
  40325. /** @hidden */
  40326. _caps: EngineCapabilities;
  40327. /** @hidden */
  40328. _features: EngineFeatures;
  40329. protected _isStencilEnable: boolean;
  40330. private _glVersion;
  40331. private _glRenderer;
  40332. private _glVendor;
  40333. /** @hidden */
  40334. _videoTextureSupported: boolean;
  40335. protected _renderingQueueLaunched: boolean;
  40336. protected _activeRenderLoops: (() => void)[];
  40337. /**
  40338. * Observable signaled when a context lost event is raised
  40339. */
  40340. onContextLostObservable: Observable<ThinEngine>;
  40341. /**
  40342. * Observable signaled when a context restored event is raised
  40343. */
  40344. onContextRestoredObservable: Observable<ThinEngine>;
  40345. private _onContextLost;
  40346. private _onContextRestored;
  40347. protected _contextWasLost: boolean;
  40348. /** @hidden */
  40349. _doNotHandleContextLost: boolean;
  40350. /**
  40351. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40353. */
  40354. get doNotHandleContextLost(): boolean;
  40355. set doNotHandleContextLost(value: boolean);
  40356. /**
  40357. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40358. */
  40359. disableVertexArrayObjects: boolean;
  40360. /** @hidden */
  40361. protected _colorWrite: boolean;
  40362. /** @hidden */
  40363. protected _colorWriteChanged: boolean;
  40364. /** @hidden */
  40365. protected _depthCullingState: DepthCullingState;
  40366. /** @hidden */
  40367. protected _stencilState: StencilState;
  40368. /** @hidden */
  40369. _alphaState: AlphaState;
  40370. /** @hidden */
  40371. _alphaMode: number;
  40372. /** @hidden */
  40373. _alphaEquation: number;
  40374. /** @hidden */
  40375. _internalTexturesCache: InternalTexture[];
  40376. /** @hidden */
  40377. protected _activeChannel: number;
  40378. private _currentTextureChannel;
  40379. /** @hidden */
  40380. protected _boundTexturesCache: {
  40381. [key: string]: Nullable<InternalTexture>;
  40382. };
  40383. /** @hidden */
  40384. protected _currentEffect: Nullable<Effect>;
  40385. /** @hidden */
  40386. protected _currentProgram: Nullable<WebGLProgram>;
  40387. protected _compiledEffects: {
  40388. [key: string]: Effect;
  40389. };
  40390. private _vertexAttribArraysEnabled;
  40391. /** @hidden */
  40392. protected _cachedViewport: Nullable<IViewportLike>;
  40393. private _cachedVertexArrayObject;
  40394. /** @hidden */
  40395. protected _cachedVertexBuffers: any;
  40396. /** @hidden */
  40397. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40398. /** @hidden */
  40399. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40400. /** @hidden */
  40401. _currentRenderTarget: Nullable<InternalTexture>;
  40402. private _uintIndicesCurrentlySet;
  40403. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40404. /** @hidden */
  40405. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40406. /** @hidden */
  40407. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40408. private _currentBufferPointers;
  40409. private _currentInstanceLocations;
  40410. private _currentInstanceBuffers;
  40411. private _textureUnits;
  40412. /** @hidden */
  40413. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40414. /** @hidden */
  40415. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40416. /** @hidden */
  40417. _boundRenderFunction: any;
  40418. private _vaoRecordInProgress;
  40419. private _mustWipeVertexAttributes;
  40420. private _emptyTexture;
  40421. private _emptyCubeTexture;
  40422. private _emptyTexture3D;
  40423. private _emptyTexture2DArray;
  40424. /** @hidden */
  40425. _frameHandler: number;
  40426. private _nextFreeTextureSlots;
  40427. private _maxSimultaneousTextures;
  40428. private _activeRequests;
  40429. /** @hidden */
  40430. _transformTextureUrl: Nullable<(url: string) => string>;
  40431. /**
  40432. * Gets information about the current host
  40433. */
  40434. hostInformation: HostInformation;
  40435. protected get _supportsHardwareTextureRescaling(): boolean;
  40436. private _framebufferDimensionsObject;
  40437. /**
  40438. * sets the object from which width and height will be taken from when getting render width and height
  40439. * Will fallback to the gl object
  40440. * @param dimensions the framebuffer width and height that will be used.
  40441. */
  40442. set framebufferDimensionsObject(dimensions: Nullable<{
  40443. framebufferWidth: number;
  40444. framebufferHeight: number;
  40445. }>);
  40446. /**
  40447. * Gets the current viewport
  40448. */
  40449. get currentViewport(): Nullable<IViewportLike>;
  40450. /**
  40451. * Gets the default empty texture
  40452. */
  40453. get emptyTexture(): InternalTexture;
  40454. /**
  40455. * Gets the default empty 3D texture
  40456. */
  40457. get emptyTexture3D(): InternalTexture;
  40458. /**
  40459. * Gets the default empty 2D array texture
  40460. */
  40461. get emptyTexture2DArray(): InternalTexture;
  40462. /**
  40463. * Gets the default empty cube texture
  40464. */
  40465. get emptyCubeTexture(): InternalTexture;
  40466. /**
  40467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40468. */
  40469. premultipliedAlpha: boolean;
  40470. /**
  40471. * Observable event triggered before each texture is initialized
  40472. */
  40473. onBeforeTextureInitObservable: Observable<Texture>;
  40474. /** @hidden */
  40475. protected _isWebGPU: boolean;
  40476. /**
  40477. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40478. */
  40479. get isWebGPU(): boolean;
  40480. /** @hidden */
  40481. protected _shaderPlatformName: string;
  40482. /**
  40483. * Gets the shader platfrom name used by the effects.
  40484. */
  40485. get shaderPlatformName(): string;
  40486. /**
  40487. * Creates a new engine
  40488. * @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
  40489. * @param antialias defines enable antialiasing (default: false)
  40490. * @param options defines further options to be sent to the getContext() function
  40491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40492. */
  40493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40494. /**
  40495. * @hidden
  40496. */
  40497. _debugPushGroup(groupName: string, targetObject?: number): void;
  40498. /**
  40499. * @hidden
  40500. */
  40501. _debugPopGroup(targetObject?: number): void;
  40502. /**
  40503. * @hidden
  40504. */
  40505. _debugInsertMarker(text: string, targetObject?: number): void;
  40506. /**
  40507. * Shared initialization across engines types.
  40508. * @param canvas The canvas associated with this instance of the engine.
  40509. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40510. * @param audioEngine Defines if an audio engine should be created by default
  40511. */
  40512. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40513. /**
  40514. * Gets a shader processor implementation fitting with the current engine type.
  40515. * @returns The shader processor implementation.
  40516. */
  40517. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40518. /** @hidden */
  40519. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40520. private _rebuildInternalTextures;
  40521. private _rebuildEffects;
  40522. /**
  40523. * Gets a boolean indicating if all created effects are ready
  40524. * @returns true if all effects are ready
  40525. */
  40526. areAllEffectsReady(): boolean;
  40527. protected _rebuildBuffers(): void;
  40528. protected _initGLContext(): void;
  40529. protected _initFeatures(): void;
  40530. /**
  40531. * Gets version of the current webGL context
  40532. * Keep it for back compat - use version instead
  40533. */
  40534. get webGLVersion(): number;
  40535. /**
  40536. * Gets a string identifying the name of the class
  40537. * @returns "Engine" string
  40538. */
  40539. getClassName(): string;
  40540. /**
  40541. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40542. */
  40543. get isStencilEnable(): boolean;
  40544. /** @hidden */
  40545. _prepareWorkingCanvas(): void;
  40546. /**
  40547. * Reset the texture cache to empty state
  40548. */
  40549. resetTextureCache(): void;
  40550. /**
  40551. * Gets an object containing information about the current webGL context
  40552. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40553. */
  40554. getGlInfo(): {
  40555. vendor: string;
  40556. renderer: string;
  40557. version: string;
  40558. };
  40559. /**
  40560. * Defines the hardware scaling level.
  40561. * By default the hardware scaling level is computed from the window device ratio.
  40562. * 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.
  40563. * @param level defines the level to use
  40564. */
  40565. setHardwareScalingLevel(level: number): void;
  40566. /**
  40567. * Gets the current hardware scaling level.
  40568. * By default the hardware scaling level is computed from the window device ratio.
  40569. * 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.
  40570. * @returns a number indicating the current hardware scaling level
  40571. */
  40572. getHardwareScalingLevel(): number;
  40573. /**
  40574. * Gets the list of loaded textures
  40575. * @returns an array containing all loaded textures
  40576. */
  40577. getLoadedTexturesCache(): InternalTexture[];
  40578. /**
  40579. * Gets the object containing all engine capabilities
  40580. * @returns the EngineCapabilities object
  40581. */
  40582. getCaps(): EngineCapabilities;
  40583. /**
  40584. * stop executing a render loop function and remove it from the execution array
  40585. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40586. */
  40587. stopRenderLoop(renderFunction?: () => void): void;
  40588. /** @hidden */
  40589. _renderLoop(): void;
  40590. /**
  40591. * Gets the HTML canvas attached with the current webGL context
  40592. * @returns a HTML canvas
  40593. */
  40594. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40595. /**
  40596. * Gets host window
  40597. * @returns the host window object
  40598. */
  40599. getHostWindow(): Nullable<Window>;
  40600. /**
  40601. * Gets the current render width
  40602. * @param useScreen defines if screen size must be used (or the current render target if any)
  40603. * @returns a number defining the current render width
  40604. */
  40605. getRenderWidth(useScreen?: boolean): number;
  40606. /**
  40607. * Gets the current render height
  40608. * @param useScreen defines if screen size must be used (or the current render target if any)
  40609. * @returns a number defining the current render height
  40610. */
  40611. getRenderHeight(useScreen?: boolean): number;
  40612. /**
  40613. * Can be used to override the current requestAnimationFrame requester.
  40614. * @hidden
  40615. */
  40616. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40617. /**
  40618. * Register and execute a render loop. The engine can have more than one render function
  40619. * @param renderFunction defines the function to continuously execute
  40620. */
  40621. runRenderLoop(renderFunction: () => void): void;
  40622. /**
  40623. * Clear the current render buffer or the current render target (if any is set up)
  40624. * @param color defines the color to use
  40625. * @param backBuffer defines if the back buffer must be cleared
  40626. * @param depth defines if the depth buffer must be cleared
  40627. * @param stencil defines if the stencil buffer must be cleared
  40628. */
  40629. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40630. protected _viewportCached: {
  40631. x: number;
  40632. y: number;
  40633. z: number;
  40634. w: number;
  40635. };
  40636. /** @hidden */
  40637. _viewport(x: number, y: number, width: number, height: number): void;
  40638. /**
  40639. * Set the WebGL's viewport
  40640. * @param viewport defines the viewport element to be used
  40641. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40642. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40643. */
  40644. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40645. /**
  40646. * Begin a new frame
  40647. */
  40648. beginFrame(): void;
  40649. /**
  40650. * Enf the current frame
  40651. */
  40652. endFrame(): void;
  40653. /**
  40654. * Resize the view according to the canvas' size
  40655. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40656. */
  40657. resize(forceSetSize?: boolean): void;
  40658. /**
  40659. * Force a specific size of the canvas
  40660. * @param width defines the new canvas' width
  40661. * @param height defines the new canvas' height
  40662. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40663. * @returns true if the size was changed
  40664. */
  40665. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40666. /**
  40667. * Binds the frame buffer to the specified texture.
  40668. * @param texture The texture to render to or null for the default canvas
  40669. * @param faceIndex The face of the texture to render to in case of cube texture
  40670. * @param requiredWidth The width of the target to render to
  40671. * @param requiredHeight The height of the target to render to
  40672. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40673. * @param lodLevel defines the lod level to bind to the frame buffer
  40674. * @param layer defines the 2d array index to bind to frame buffer to
  40675. */
  40676. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40677. /** @hidden */
  40678. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40679. /**
  40680. * Unbind the current render target texture from the webGL context
  40681. * @param texture defines the render target texture to unbind
  40682. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40683. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40684. */
  40685. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40686. /**
  40687. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40688. */
  40689. flushFramebuffer(): void;
  40690. /**
  40691. * Unbind the current render target and bind the default framebuffer
  40692. */
  40693. restoreDefaultFramebuffer(): void;
  40694. /** @hidden */
  40695. protected _resetVertexBufferBinding(): void;
  40696. /**
  40697. * Creates a vertex buffer
  40698. * @param data the data for the vertex buffer
  40699. * @returns the new WebGL static buffer
  40700. */
  40701. createVertexBuffer(data: DataArray): DataBuffer;
  40702. private _createVertexBuffer;
  40703. /**
  40704. * Creates a dynamic vertex buffer
  40705. * @param data the data for the dynamic vertex buffer
  40706. * @returns the new WebGL dynamic buffer
  40707. */
  40708. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40709. protected _resetIndexBufferBinding(): void;
  40710. /**
  40711. * Creates a new index buffer
  40712. * @param indices defines the content of the index buffer
  40713. * @param updatable defines if the index buffer must be updatable
  40714. * @returns a new webGL buffer
  40715. */
  40716. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40717. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40718. /**
  40719. * Bind a webGL buffer to the webGL context
  40720. * @param buffer defines the buffer to bind
  40721. */
  40722. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40723. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40724. private bindBuffer;
  40725. /**
  40726. * update the bound buffer with the given data
  40727. * @param data defines the data to update
  40728. */
  40729. updateArrayBuffer(data: Float32Array): void;
  40730. private _vertexAttribPointer;
  40731. /** @hidden */
  40732. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40733. private _bindVertexBuffersAttributes;
  40734. /**
  40735. * Records a vertex array object
  40736. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40737. * @param vertexBuffers defines the list of vertex buffers to store
  40738. * @param indexBuffer defines the index buffer to store
  40739. * @param effect defines the effect to store
  40740. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40741. * @returns the new vertex array object
  40742. */
  40743. recordVertexArrayObject(vertexBuffers: {
  40744. [key: string]: VertexBuffer;
  40745. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40746. [kind: string]: Nullable<VertexBuffer>;
  40747. }): WebGLVertexArrayObject;
  40748. /**
  40749. * Bind a specific vertex array object
  40750. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40751. * @param vertexArrayObject defines the vertex array object to bind
  40752. * @param indexBuffer defines the index buffer to bind
  40753. */
  40754. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40755. /**
  40756. * Bind webGl buffers directly to the webGL context
  40757. * @param vertexBuffer defines the vertex buffer to bind
  40758. * @param indexBuffer defines the index buffer to bind
  40759. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40760. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40761. * @param effect defines the effect associated with the vertex buffer
  40762. */
  40763. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40764. private _unbindVertexArrayObject;
  40765. /**
  40766. * Bind a list of vertex buffers to the webGL context
  40767. * @param vertexBuffers defines the list of vertex buffers to bind
  40768. * @param indexBuffer defines the index buffer to bind
  40769. * @param effect defines the effect associated with the vertex buffers
  40770. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40771. */
  40772. bindBuffers(vertexBuffers: {
  40773. [key: string]: Nullable<VertexBuffer>;
  40774. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40775. [kind: string]: Nullable<VertexBuffer>;
  40776. }): void;
  40777. /**
  40778. * Unbind all instance attributes
  40779. */
  40780. unbindInstanceAttributes(): void;
  40781. /**
  40782. * Release and free the memory of a vertex array object
  40783. * @param vao defines the vertex array object to delete
  40784. */
  40785. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40786. /** @hidden */
  40787. _releaseBuffer(buffer: DataBuffer): boolean;
  40788. protected _deleteBuffer(buffer: DataBuffer): void;
  40789. /**
  40790. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40791. * @param instancesBuffer defines the webGL buffer to update and bind
  40792. * @param data defines the data to store in the buffer
  40793. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40794. */
  40795. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40796. /**
  40797. * Bind the content of a webGL buffer used with instantiation
  40798. * @param instancesBuffer defines the webGL buffer to bind
  40799. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40800. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40801. */
  40802. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40803. /**
  40804. * Disable the instance attribute corresponding to the name in parameter
  40805. * @param name defines the name of the attribute to disable
  40806. */
  40807. disableInstanceAttributeByName(name: string): void;
  40808. /**
  40809. * Disable the instance attribute corresponding to the location in parameter
  40810. * @param attributeLocation defines the attribute location of the attribute to disable
  40811. */
  40812. disableInstanceAttribute(attributeLocation: number): void;
  40813. /**
  40814. * Disable the attribute corresponding to the location in parameter
  40815. * @param attributeLocation defines the attribute location of the attribute to disable
  40816. */
  40817. disableAttributeByIndex(attributeLocation: number): void;
  40818. /**
  40819. * Send a draw order
  40820. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40821. * @param indexStart defines the starting index
  40822. * @param indexCount defines the number of index to draw
  40823. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40824. */
  40825. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40826. /**
  40827. * Draw a list of points
  40828. * @param verticesStart defines the index of first vertex to draw
  40829. * @param verticesCount defines the count of vertices to draw
  40830. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40831. */
  40832. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40833. /**
  40834. * Draw a list of unindexed primitives
  40835. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40836. * @param verticesStart defines the index of first vertex to draw
  40837. * @param verticesCount defines the count of vertices to draw
  40838. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40839. */
  40840. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40841. /**
  40842. * Draw a list of indexed primitives
  40843. * @param fillMode defines the primitive to use
  40844. * @param indexStart defines the starting index
  40845. * @param indexCount defines the number of index to draw
  40846. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40847. */
  40848. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40849. /**
  40850. * Draw a list of unindexed primitives
  40851. * @param fillMode defines the primitive to use
  40852. * @param verticesStart defines the index of first vertex to draw
  40853. * @param verticesCount defines the count of vertices to draw
  40854. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40855. */
  40856. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40857. private _drawMode;
  40858. /** @hidden */
  40859. protected _reportDrawCall(): void;
  40860. /** @hidden */
  40861. _releaseEffect(effect: Effect): void;
  40862. /** @hidden */
  40863. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40864. /**
  40865. * Create a new effect (used to store vertex/fragment shaders)
  40866. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40867. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40868. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40869. * @param samplers defines an array of string used to represent textures
  40870. * @param defines defines the string containing the defines to use to compile the shaders
  40871. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40872. * @param onCompiled defines a function to call when the effect creation is successful
  40873. * @param onError defines a function to call when the effect creation has failed
  40874. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40875. * @returns the new Effect
  40876. */
  40877. 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;
  40878. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40879. private _compileShader;
  40880. private _compileRawShader;
  40881. /** @hidden */
  40882. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40883. /**
  40884. * Directly creates a webGL program
  40885. * @param pipelineContext defines the pipeline context to attach to
  40886. * @param vertexCode defines the vertex shader code to use
  40887. * @param fragmentCode defines the fragment shader code to use
  40888. * @param context defines the webGL context to use (if not set, the current one will be used)
  40889. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40890. * @returns the new webGL program
  40891. */
  40892. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40893. /**
  40894. * Creates a webGL program
  40895. * @param pipelineContext defines the pipeline context to attach to
  40896. * @param vertexCode defines the vertex shader code to use
  40897. * @param fragmentCode defines the fragment shader code to use
  40898. * @param defines defines the string containing the defines to use to compile the shaders
  40899. * @param context defines the webGL context to use (if not set, the current one will be used)
  40900. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40901. * @returns the new webGL program
  40902. */
  40903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40904. /**
  40905. * Creates a new pipeline context
  40906. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40907. * @returns the new pipeline
  40908. */
  40909. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40910. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40911. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40912. /** @hidden */
  40913. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40914. /** @hidden */
  40915. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40916. /** @hidden */
  40917. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40918. /**
  40919. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40920. * @param pipelineContext defines the pipeline context to use
  40921. * @param uniformsNames defines the list of uniform names
  40922. * @returns an array of webGL uniform locations
  40923. */
  40924. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40925. /**
  40926. * Gets the list of active attributes for a given webGL program
  40927. * @param pipelineContext defines the pipeline context to use
  40928. * @param attributesNames defines the list of attribute names to get
  40929. * @returns an array of indices indicating the offset of each attribute
  40930. */
  40931. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40932. /**
  40933. * Activates an effect, making it the current one (ie. the one used for rendering)
  40934. * @param effect defines the effect to activate
  40935. */
  40936. enableEffect(effect: Nullable<Effect>): void;
  40937. /**
  40938. * Set the value of an uniform to a number (int)
  40939. * @param uniform defines the webGL uniform location where to store the value
  40940. * @param value defines the int number to store
  40941. * @returns true if the value was set
  40942. */
  40943. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40944. /**
  40945. * Set the value of an uniform to a int2
  40946. * @param uniform defines the webGL uniform location where to store the value
  40947. * @param x defines the 1st component of the value
  40948. * @param y defines the 2nd component of the value
  40949. * @returns true if the value was set
  40950. */
  40951. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40952. /**
  40953. * Set the value of an uniform to a int3
  40954. * @param uniform defines the webGL uniform location where to store the value
  40955. * @param x defines the 1st component of the value
  40956. * @param y defines the 2nd component of the value
  40957. * @param z defines the 3rd component of the value
  40958. * @returns true if the value was set
  40959. */
  40960. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40961. /**
  40962. * Set the value of an uniform to a int4
  40963. * @param uniform defines the webGL uniform location where to store the value
  40964. * @param x defines the 1st component of the value
  40965. * @param y defines the 2nd component of the value
  40966. * @param z defines the 3rd component of the value
  40967. * @param w defines the 4th component of the value
  40968. * @returns true if the value was set
  40969. */
  40970. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40971. /**
  40972. * Set the value of an uniform to an array of int32
  40973. * @param uniform defines the webGL uniform location where to store the value
  40974. * @param array defines the array of int32 to store
  40975. * @returns true if the value was set
  40976. */
  40977. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40978. /**
  40979. * Set the value of an uniform to an array of int32 (stored as vec2)
  40980. * @param uniform defines the webGL uniform location where to store the value
  40981. * @param array defines the array of int32 to store
  40982. * @returns true if the value was set
  40983. */
  40984. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40985. /**
  40986. * Set the value of an uniform to an array of int32 (stored as vec3)
  40987. * @param uniform defines the webGL uniform location where to store the value
  40988. * @param array defines the array of int32 to store
  40989. * @returns true if the value was set
  40990. */
  40991. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40992. /**
  40993. * Set the value of an uniform to an array of int32 (stored as vec4)
  40994. * @param uniform defines the webGL uniform location where to store the value
  40995. * @param array defines the array of int32 to store
  40996. * @returns true if the value was set
  40997. */
  40998. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40999. /**
  41000. * Set the value of an uniform to an array of number
  41001. * @param uniform defines the webGL uniform location where to store the value
  41002. * @param array defines the array of number to store
  41003. * @returns true if the value was set
  41004. */
  41005. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41006. /**
  41007. * Set the value of an uniform to an array of number (stored as vec2)
  41008. * @param uniform defines the webGL uniform location where to store the value
  41009. * @param array defines the array of number to store
  41010. * @returns true if the value was set
  41011. */
  41012. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41013. /**
  41014. * Set the value of an uniform to an array of number (stored as vec3)
  41015. * @param uniform defines the webGL uniform location where to store the value
  41016. * @param array defines the array of number to store
  41017. * @returns true if the value was set
  41018. */
  41019. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41020. /**
  41021. * Set the value of an uniform to an array of number (stored as vec4)
  41022. * @param uniform defines the webGL uniform location where to store the value
  41023. * @param array defines the array of number to store
  41024. * @returns true if the value was set
  41025. */
  41026. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41027. /**
  41028. * Set the value of an uniform to an array of float32 (stored as matrices)
  41029. * @param uniform defines the webGL uniform location where to store the value
  41030. * @param matrices defines the array of float32 to store
  41031. * @returns true if the value was set
  41032. */
  41033. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41034. /**
  41035. * Set the value of an uniform to a matrix (3x3)
  41036. * @param uniform defines the webGL uniform location where to store the value
  41037. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41038. * @returns true if the value was set
  41039. */
  41040. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41041. /**
  41042. * Set the value of an uniform to a matrix (2x2)
  41043. * @param uniform defines the webGL uniform location where to store the value
  41044. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41045. * @returns true if the value was set
  41046. */
  41047. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41048. /**
  41049. * Set the value of an uniform to a number (float)
  41050. * @param uniform defines the webGL uniform location where to store the value
  41051. * @param value defines the float number to store
  41052. * @returns true if the value was transferred
  41053. */
  41054. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41055. /**
  41056. * Set the value of an uniform to a vec2
  41057. * @param uniform defines the webGL uniform location where to store the value
  41058. * @param x defines the 1st component of the value
  41059. * @param y defines the 2nd component of the value
  41060. * @returns true if the value was set
  41061. */
  41062. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41063. /**
  41064. * Set the value of an uniform to a vec3
  41065. * @param uniform defines the webGL uniform location where to store the value
  41066. * @param x defines the 1st component of the value
  41067. * @param y defines the 2nd component of the value
  41068. * @param z defines the 3rd component of the value
  41069. * @returns true if the value was set
  41070. */
  41071. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41072. /**
  41073. * Set the value of an uniform to a vec4
  41074. * @param uniform defines the webGL uniform location where to store the value
  41075. * @param x defines the 1st component of the value
  41076. * @param y defines the 2nd component of the value
  41077. * @param z defines the 3rd component of the value
  41078. * @param w defines the 4th component of the value
  41079. * @returns true if the value was set
  41080. */
  41081. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41082. /**
  41083. * Apply all cached states (depth, culling, stencil and alpha)
  41084. */
  41085. applyStates(): void;
  41086. /**
  41087. * Enable or disable color writing
  41088. * @param enable defines the state to set
  41089. */
  41090. setColorWrite(enable: boolean): void;
  41091. /**
  41092. * Gets a boolean indicating if color writing is enabled
  41093. * @returns the current color writing state
  41094. */
  41095. getColorWrite(): boolean;
  41096. /**
  41097. * Gets the depth culling state manager
  41098. */
  41099. get depthCullingState(): DepthCullingState;
  41100. /**
  41101. * Gets the alpha state manager
  41102. */
  41103. get alphaState(): AlphaState;
  41104. /**
  41105. * Gets the stencil state manager
  41106. */
  41107. get stencilState(): StencilState;
  41108. /**
  41109. * Clears the list of texture accessible through engine.
  41110. * This can help preventing texture load conflict due to name collision.
  41111. */
  41112. clearInternalTexturesCache(): void;
  41113. /**
  41114. * Force the entire cache to be cleared
  41115. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41116. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41117. */
  41118. wipeCaches(bruteForce?: boolean): void;
  41119. /** @hidden */
  41120. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41121. min: number;
  41122. mag: number;
  41123. };
  41124. /** @hidden */
  41125. protected _createTexture(): WebGLTexture;
  41126. /** @hidden */
  41127. _createHardwareTexture(): HardwareTextureWrapper;
  41128. 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 | {
  41129. width: number;
  41130. height: number;
  41131. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41132. width: number;
  41133. height: number;
  41134. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41135. width: number;
  41136. height: number;
  41137. }, 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;
  41138. /**
  41139. * Usually called from Texture.ts.
  41140. * Passed information to create a WebGLTexture
  41141. * @param url defines a value which contains one of the following:
  41142. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41143. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41144. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41145. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41146. * @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)
  41147. * @param scene needed for loading to the correct scene
  41148. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41149. * @param onLoad optional callback to be called upon successful completion
  41150. * @param onError optional callback to be called upon failure
  41151. * @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
  41152. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41153. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41154. * @param forcedExtension defines the extension to use to pick the right loader
  41155. * @param mimeType defines an optional mime type
  41156. * @param loaderOptions options to be passed to the loader
  41157. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41158. */
  41159. 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;
  41160. /**
  41161. * Loads an image as an HTMLImageElement.
  41162. * @param input url string, ArrayBuffer, or Blob to load
  41163. * @param onLoad callback called when the image successfully loads
  41164. * @param onError callback called when the image fails to load
  41165. * @param offlineProvider offline provider for caching
  41166. * @param mimeType optional mime type
  41167. * @returns the HTMLImageElement of the loaded image
  41168. * @hidden
  41169. */
  41170. 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>;
  41171. /**
  41172. * @hidden
  41173. */
  41174. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41175. private _unpackFlipYCached;
  41176. /**
  41177. * In case you are sharing the context with other applications, it might
  41178. * be interested to not cache the unpack flip y state to ensure a consistent
  41179. * value would be set.
  41180. */
  41181. enableUnpackFlipYCached: boolean;
  41182. /** @hidden */
  41183. _unpackFlipY(value: boolean): void;
  41184. /** @hidden */
  41185. _getUnpackAlignement(): number;
  41186. private _getTextureTarget;
  41187. /**
  41188. * Update the sampling mode of a given texture
  41189. * @param samplingMode defines the required sampling mode
  41190. * @param texture defines the texture to update
  41191. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41192. */
  41193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41194. /**
  41195. * Update the dimensions of a texture
  41196. * @param texture texture to update
  41197. * @param width new width of the texture
  41198. * @param height new height of the texture
  41199. * @param depth new depth of the texture
  41200. */
  41201. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41202. /**
  41203. * Update the sampling mode of a given texture
  41204. * @param texture defines the texture to update
  41205. * @param wrapU defines the texture wrap mode of the u coordinates
  41206. * @param wrapV defines the texture wrap mode of the v coordinates
  41207. * @param wrapR defines the texture wrap mode of the r coordinates
  41208. */
  41209. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41210. /** @hidden */
  41211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41212. width: number;
  41213. height: number;
  41214. layers?: number;
  41215. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41216. /** @hidden */
  41217. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41218. /** @hidden */
  41219. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41220. /**
  41221. * Update a portion of an internal texture
  41222. * @param texture defines the texture to update
  41223. * @param imageData defines the data to store into the texture
  41224. * @param xOffset defines the x coordinates of the update rectangle
  41225. * @param yOffset defines the y coordinates of the update rectangle
  41226. * @param width defines the width of the update rectangle
  41227. * @param height defines the height of the update rectangle
  41228. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41229. * @param lod defines the lod level to update (0 by default)
  41230. */
  41231. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41232. /** @hidden */
  41233. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41234. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41235. private _prepareWebGLTexture;
  41236. /** @hidden */
  41237. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41238. private _getDepthStencilBuffer;
  41239. /** @hidden */
  41240. _releaseFramebufferObjects(texture: InternalTexture): void;
  41241. /** @hidden */
  41242. _releaseTexture(texture: InternalTexture): void;
  41243. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41244. protected _setProgram(program: WebGLProgram): void;
  41245. protected _boundUniforms: {
  41246. [key: number]: WebGLUniformLocation;
  41247. };
  41248. /**
  41249. * Binds an effect to the webGL context
  41250. * @param effect defines the effect to bind
  41251. */
  41252. bindSamplers(effect: Effect): void;
  41253. private _activateCurrentTexture;
  41254. /** @hidden */
  41255. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41256. /** @hidden */
  41257. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41258. /**
  41259. * Unbind all textures from the webGL context
  41260. */
  41261. unbindAllTextures(): void;
  41262. /**
  41263. * Sets a texture to the according uniform.
  41264. * @param channel The texture channel
  41265. * @param uniform The uniform to set
  41266. * @param texture The texture to apply
  41267. * @param name The name of the uniform in the effect
  41268. */
  41269. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41270. private _bindSamplerUniformToChannel;
  41271. private _getTextureWrapMode;
  41272. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41273. /**
  41274. * Sets an array of texture to the webGL context
  41275. * @param channel defines the channel where the texture array must be set
  41276. * @param uniform defines the associated uniform location
  41277. * @param textures defines the array of textures to bind
  41278. * @param name name of the channel
  41279. */
  41280. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41281. /** @hidden */
  41282. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41283. private _setTextureParameterFloat;
  41284. private _setTextureParameterInteger;
  41285. /**
  41286. * Unbind all vertex attributes from the webGL context
  41287. */
  41288. unbindAllAttributes(): void;
  41289. /**
  41290. * 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
  41291. */
  41292. releaseEffects(): void;
  41293. /**
  41294. * Dispose and release all associated resources
  41295. */
  41296. dispose(): void;
  41297. /**
  41298. * Attach a new callback raised when context lost event is fired
  41299. * @param callback defines the callback to call
  41300. */
  41301. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41302. /**
  41303. * Attach a new callback raised when context restored event is fired
  41304. * @param callback defines the callback to call
  41305. */
  41306. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41307. /**
  41308. * Get the current error code of the webGL context
  41309. * @returns the error code
  41310. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41311. */
  41312. getError(): number;
  41313. private _canRenderToFloatFramebuffer;
  41314. private _canRenderToHalfFloatFramebuffer;
  41315. private _canRenderToFramebuffer;
  41316. /** @hidden */
  41317. _getWebGLTextureType(type: number): number;
  41318. /** @hidden */
  41319. _getInternalFormat(format: number): number;
  41320. /** @hidden */
  41321. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41322. /** @hidden */
  41323. _getRGBAMultiSampleBufferFormat(type: number): number;
  41324. /** @hidden */
  41325. _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;
  41326. /**
  41327. * Loads a file from a url
  41328. * @param url url to load
  41329. * @param onSuccess callback called when the file successfully loads
  41330. * @param onProgress callback called while file is loading (if the server supports this mode)
  41331. * @param offlineProvider defines the offline provider for caching
  41332. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41333. * @param onError callback called when the file fails to load
  41334. * @returns a file request object
  41335. * @hidden
  41336. */
  41337. 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;
  41338. /**
  41339. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41340. * @param x defines the x coordinate of the rectangle where pixels must be read
  41341. * @param y defines the y coordinate of the rectangle where pixels must be read
  41342. * @param width defines the width of the rectangle where pixels must be read
  41343. * @param height defines the height of the rectangle where pixels must be read
  41344. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41345. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41346. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41347. */
  41348. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41349. private static _IsSupported;
  41350. private static _HasMajorPerformanceCaveat;
  41351. /**
  41352. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41353. */
  41354. static get IsSupported(): boolean;
  41355. /**
  41356. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41357. * @returns true if the engine can be created
  41358. * @ignorenaming
  41359. */
  41360. static isSupported(): boolean;
  41361. /**
  41362. * 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)
  41363. */
  41364. static get HasMajorPerformanceCaveat(): boolean;
  41365. /**
  41366. * Find the next highest power of two.
  41367. * @param x Number to start search from.
  41368. * @return Next highest power of two.
  41369. */
  41370. static CeilingPOT(x: number): number;
  41371. /**
  41372. * Find the next lowest power of two.
  41373. * @param x Number to start search from.
  41374. * @return Next lowest power of two.
  41375. */
  41376. static FloorPOT(x: number): number;
  41377. /**
  41378. * Find the nearest power of two.
  41379. * @param x Number to start search from.
  41380. * @return Next nearest power of two.
  41381. */
  41382. static NearestPOT(x: number): number;
  41383. /**
  41384. * Get the closest exponent of two
  41385. * @param value defines the value to approximate
  41386. * @param max defines the maximum value to return
  41387. * @param mode defines how to define the closest value
  41388. * @returns closest exponent of two of the given value
  41389. */
  41390. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41391. /**
  41392. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41393. * @param func - the function to be called
  41394. * @param requester - the object that will request the next frame. Falls back to window.
  41395. * @returns frame number
  41396. */
  41397. static QueueNewFrame(func: () => void, requester?: any): number;
  41398. /**
  41399. * Gets host document
  41400. * @returns the host document object
  41401. */
  41402. getHostDocument(): Nullable<Document>;
  41403. }
  41404. }
  41405. declare module BABYLON {
  41406. /**
  41407. * Defines the source of the internal texture
  41408. */
  41409. export enum InternalTextureSource {
  41410. /**
  41411. * The source of the texture data is unknown
  41412. */
  41413. Unknown = 0,
  41414. /**
  41415. * Texture data comes from an URL
  41416. */
  41417. Url = 1,
  41418. /**
  41419. * Texture data is only used for temporary storage
  41420. */
  41421. Temp = 2,
  41422. /**
  41423. * Texture data comes from raw data (ArrayBuffer)
  41424. */
  41425. Raw = 3,
  41426. /**
  41427. * Texture content is dynamic (video or dynamic texture)
  41428. */
  41429. Dynamic = 4,
  41430. /**
  41431. * Texture content is generated by rendering to it
  41432. */
  41433. RenderTarget = 5,
  41434. /**
  41435. * Texture content is part of a multi render target process
  41436. */
  41437. MultiRenderTarget = 6,
  41438. /**
  41439. * Texture data comes from a cube data file
  41440. */
  41441. Cube = 7,
  41442. /**
  41443. * Texture data comes from a raw cube data
  41444. */
  41445. CubeRaw = 8,
  41446. /**
  41447. * Texture data come from a prefiltered cube data file
  41448. */
  41449. CubePrefiltered = 9,
  41450. /**
  41451. * Texture content is raw 3D data
  41452. */
  41453. Raw3D = 10,
  41454. /**
  41455. * Texture content is raw 2D array data
  41456. */
  41457. Raw2DArray = 11,
  41458. /**
  41459. * Texture content is a depth texture
  41460. */
  41461. Depth = 12,
  41462. /**
  41463. * Texture data comes from a raw cube data encoded with RGBD
  41464. */
  41465. CubeRawRGBD = 13
  41466. }
  41467. /**
  41468. * Class used to store data associated with WebGL texture data for the engine
  41469. * This class should not be used directly
  41470. */
  41471. export class InternalTexture {
  41472. /** @hidden */
  41473. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41474. /**
  41475. * Defines if the texture is ready
  41476. */
  41477. isReady: boolean;
  41478. /**
  41479. * Defines if the texture is a cube texture
  41480. */
  41481. isCube: boolean;
  41482. /**
  41483. * Defines if the texture contains 3D data
  41484. */
  41485. is3D: boolean;
  41486. /**
  41487. * Defines if the texture contains 2D array data
  41488. */
  41489. is2DArray: boolean;
  41490. /**
  41491. * Defines if the texture contains multiview data
  41492. */
  41493. isMultiview: boolean;
  41494. /**
  41495. * Gets the URL used to load this texture
  41496. */
  41497. url: string;
  41498. /** @hidden */
  41499. _originalUrl: string;
  41500. /**
  41501. * Gets the sampling mode of the texture
  41502. */
  41503. samplingMode: number;
  41504. /**
  41505. * Gets a boolean indicating if the texture needs mipmaps generation
  41506. */
  41507. generateMipMaps: boolean;
  41508. /**
  41509. * Gets the number of samples used by the texture (WebGL2+ only)
  41510. */
  41511. samples: number;
  41512. /**
  41513. * Gets the type of the texture (int, float...)
  41514. */
  41515. type: number;
  41516. /**
  41517. * Gets the format of the texture (RGB, RGBA...)
  41518. */
  41519. format: number;
  41520. /**
  41521. * Observable called when the texture is loaded
  41522. */
  41523. onLoadedObservable: Observable<InternalTexture>;
  41524. /**
  41525. * Gets the width of the texture
  41526. */
  41527. width: number;
  41528. /**
  41529. * Gets the height of the texture
  41530. */
  41531. height: number;
  41532. /**
  41533. * Gets the depth of the texture
  41534. */
  41535. depth: number;
  41536. /**
  41537. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41538. */
  41539. baseWidth: number;
  41540. /**
  41541. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41542. */
  41543. baseHeight: number;
  41544. /**
  41545. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41546. */
  41547. baseDepth: number;
  41548. /**
  41549. * Gets a boolean indicating if the texture is inverted on Y axis
  41550. */
  41551. invertY: boolean;
  41552. /** @hidden */
  41553. _invertVScale: boolean;
  41554. /** @hidden */
  41555. _associatedChannel: number;
  41556. /** @hidden */
  41557. _source: InternalTextureSource;
  41558. /** @hidden */
  41559. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41560. /** @hidden */
  41561. _bufferView: Nullable<ArrayBufferView>;
  41562. /** @hidden */
  41563. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41564. /** @hidden */
  41565. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41566. /** @hidden */
  41567. _size: number;
  41568. /** @hidden */
  41569. _extension: string;
  41570. /** @hidden */
  41571. _files: Nullable<string[]>;
  41572. /** @hidden */
  41573. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41574. /** @hidden */
  41575. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41576. /** @hidden */
  41577. _framebuffer: Nullable<WebGLFramebuffer>;
  41578. /** @hidden */
  41579. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41580. /** @hidden */
  41581. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41582. /** @hidden */
  41583. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41584. /** @hidden */
  41585. _attachments: Nullable<number[]>;
  41586. /** @hidden */
  41587. _textureArray: Nullable<InternalTexture[]>;
  41588. /** @hidden */
  41589. _cachedCoordinatesMode: Nullable<number>;
  41590. /** @hidden */
  41591. _cachedWrapU: Nullable<number>;
  41592. /** @hidden */
  41593. _cachedWrapV: Nullable<number>;
  41594. /** @hidden */
  41595. _cachedWrapR: Nullable<number>;
  41596. /** @hidden */
  41597. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41598. /** @hidden */
  41599. _isDisabled: boolean;
  41600. /** @hidden */
  41601. _compression: Nullable<string>;
  41602. /** @hidden */
  41603. _generateStencilBuffer: boolean;
  41604. /** @hidden */
  41605. _generateDepthBuffer: boolean;
  41606. /** @hidden */
  41607. _comparisonFunction: number;
  41608. /** @hidden */
  41609. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41610. /** @hidden */
  41611. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41612. /** @hidden */
  41613. _sphericalPolynomialComputed: boolean;
  41614. /** @hidden */
  41615. _lodGenerationScale: number;
  41616. /** @hidden */
  41617. _lodGenerationOffset: number;
  41618. /** @hidden */
  41619. _depthStencilTexture: Nullable<InternalTexture>;
  41620. /** @hidden */
  41621. _colorTextureArray: Nullable<WebGLTexture>;
  41622. /** @hidden */
  41623. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41624. /** @hidden */
  41625. _lodTextureHigh: Nullable<BaseTexture>;
  41626. /** @hidden */
  41627. _lodTextureMid: Nullable<BaseTexture>;
  41628. /** @hidden */
  41629. _lodTextureLow: Nullable<BaseTexture>;
  41630. /** @hidden */
  41631. _isRGBD: boolean;
  41632. /** @hidden */
  41633. _linearSpecularLOD: boolean;
  41634. /** @hidden */
  41635. _irradianceTexture: Nullable<BaseTexture>;
  41636. /** @hidden */
  41637. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41638. /** @hidden */
  41639. _references: number;
  41640. /** @hidden */
  41641. _gammaSpace: Nullable<boolean>;
  41642. private _engine;
  41643. private _uniqueId;
  41644. private static _Counter;
  41645. /** Gets the unique id of the internal texture */
  41646. get uniqueId(): number;
  41647. /**
  41648. * Gets the Engine the texture belongs to.
  41649. * @returns The babylon engine
  41650. */
  41651. getEngine(): ThinEngine;
  41652. /**
  41653. * Gets the data source type of the texture
  41654. */
  41655. get source(): InternalTextureSource;
  41656. /**
  41657. * Creates a new InternalTexture
  41658. * @param engine defines the engine to use
  41659. * @param source defines the type of data that will be used
  41660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41661. */
  41662. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41663. /**
  41664. * Increments the number of references (ie. the number of Texture that point to it)
  41665. */
  41666. incrementReferences(): void;
  41667. /**
  41668. * Change the size of the texture (not the size of the content)
  41669. * @param width defines the new width
  41670. * @param height defines the new height
  41671. * @param depth defines the new depth (1 by default)
  41672. */
  41673. updateSize(width: int, height: int, depth?: int): void;
  41674. /** @hidden */
  41675. _rebuild(): void;
  41676. /** @hidden */
  41677. _swapAndDie(target: InternalTexture): void;
  41678. /**
  41679. * Dispose the current allocated resources
  41680. */
  41681. dispose(): void;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. /**
  41686. * Interface used to present a loading screen while loading a scene
  41687. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41688. */
  41689. export interface ILoadingScreen {
  41690. /**
  41691. * Function called to display the loading screen
  41692. */
  41693. displayLoadingUI: () => void;
  41694. /**
  41695. * Function called to hide the loading screen
  41696. */
  41697. hideLoadingUI: () => void;
  41698. /**
  41699. * Gets or sets the color to use for the background
  41700. */
  41701. loadingUIBackgroundColor: string;
  41702. /**
  41703. * Gets or sets the text to display while loading
  41704. */
  41705. loadingUIText: string;
  41706. }
  41707. /**
  41708. * Class used for the default loading screen
  41709. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41710. */
  41711. export class DefaultLoadingScreen implements ILoadingScreen {
  41712. private _renderingCanvas;
  41713. private _loadingText;
  41714. private _loadingDivBackgroundColor;
  41715. private _loadingDiv;
  41716. private _loadingTextDiv;
  41717. /** Gets or sets the logo url to use for the default loading screen */
  41718. static DefaultLogoUrl: string;
  41719. /** Gets or sets the spinner url to use for the default loading screen */
  41720. static DefaultSpinnerUrl: string;
  41721. /**
  41722. * Creates a new default loading screen
  41723. * @param _renderingCanvas defines the canvas used to render the scene
  41724. * @param _loadingText defines the default text to display
  41725. * @param _loadingDivBackgroundColor defines the default background color
  41726. */
  41727. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41728. /**
  41729. * Function called to display the loading screen
  41730. */
  41731. displayLoadingUI(): void;
  41732. /**
  41733. * Function called to hide the loading screen
  41734. */
  41735. hideLoadingUI(): void;
  41736. /**
  41737. * Gets or sets the text to display while loading
  41738. */
  41739. set loadingUIText(text: string);
  41740. get loadingUIText(): string;
  41741. /**
  41742. * Gets or sets the color to use for the background
  41743. */
  41744. get loadingUIBackgroundColor(): string;
  41745. set loadingUIBackgroundColor(color: string);
  41746. private _resizeLoadingUI;
  41747. }
  41748. }
  41749. declare module BABYLON {
  41750. /**
  41751. * Interface for any object that can request an animation frame
  41752. */
  41753. export interface ICustomAnimationFrameRequester {
  41754. /**
  41755. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41756. */
  41757. renderFunction?: Function;
  41758. /**
  41759. * Called to request the next frame to render to
  41760. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41761. */
  41762. requestAnimationFrame: Function;
  41763. /**
  41764. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41765. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41766. */
  41767. requestID?: number;
  41768. }
  41769. }
  41770. declare module BABYLON {
  41771. /**
  41772. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41773. */
  41774. export class PerformanceMonitor {
  41775. private _enabled;
  41776. private _rollingFrameTime;
  41777. private _lastFrameTimeMs;
  41778. /**
  41779. * constructor
  41780. * @param frameSampleSize The number of samples required to saturate the sliding window
  41781. */
  41782. constructor(frameSampleSize?: number);
  41783. /**
  41784. * Samples current frame
  41785. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41786. */
  41787. sampleFrame(timeMs?: number): void;
  41788. /**
  41789. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41790. */
  41791. get averageFrameTime(): number;
  41792. /**
  41793. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41794. */
  41795. get averageFrameTimeVariance(): number;
  41796. /**
  41797. * Returns the frame time of the most recent frame
  41798. */
  41799. get instantaneousFrameTime(): number;
  41800. /**
  41801. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41802. */
  41803. get averageFPS(): number;
  41804. /**
  41805. * Returns the average framerate in frames per second using the most recent frame time
  41806. */
  41807. get instantaneousFPS(): number;
  41808. /**
  41809. * Returns true if enough samples have been taken to completely fill the sliding window
  41810. */
  41811. get isSaturated(): boolean;
  41812. /**
  41813. * Enables contributions to the sliding window sample set
  41814. */
  41815. enable(): void;
  41816. /**
  41817. * Disables contributions to the sliding window sample set
  41818. * Samples will not be interpolated over the disabled period
  41819. */
  41820. disable(): void;
  41821. /**
  41822. * Returns true if sampling is enabled
  41823. */
  41824. get isEnabled(): boolean;
  41825. /**
  41826. * Resets performance monitor
  41827. */
  41828. reset(): void;
  41829. }
  41830. /**
  41831. * RollingAverage
  41832. *
  41833. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41834. */
  41835. export class RollingAverage {
  41836. /**
  41837. * Current average
  41838. */
  41839. average: number;
  41840. /**
  41841. * Current variance
  41842. */
  41843. variance: number;
  41844. protected _samples: Array<number>;
  41845. protected _sampleCount: number;
  41846. protected _pos: number;
  41847. protected _m2: number;
  41848. /**
  41849. * constructor
  41850. * @param length The number of samples required to saturate the sliding window
  41851. */
  41852. constructor(length: number);
  41853. /**
  41854. * Adds a sample to the sample set
  41855. * @param v The sample value
  41856. */
  41857. add(v: number): void;
  41858. /**
  41859. * Returns previously added values or null if outside of history or outside the sliding window domain
  41860. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41861. * @return Value previously recorded with add() or null if outside of range
  41862. */
  41863. history(i: number): number;
  41864. /**
  41865. * Returns true if enough samples have been taken to completely fill the sliding window
  41866. * @return true if sample-set saturated
  41867. */
  41868. isSaturated(): boolean;
  41869. /**
  41870. * Resets the rolling average (equivalent to 0 samples taken so far)
  41871. */
  41872. reset(): void;
  41873. /**
  41874. * Wraps a value around the sample range boundaries
  41875. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41876. * @return Wrapped position in sample range
  41877. */
  41878. protected _wrapPosition(i: number): number;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * This class is used to track a performance counter which is number based.
  41884. * The user has access to many properties which give statistics of different nature.
  41885. *
  41886. * The implementer can track two kinds of Performance Counter: time and count.
  41887. * 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.
  41888. * 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.
  41889. */
  41890. export class PerfCounter {
  41891. /**
  41892. * Gets or sets a global boolean to turn on and off all the counters
  41893. */
  41894. static Enabled: boolean;
  41895. /**
  41896. * Returns the smallest value ever
  41897. */
  41898. get min(): number;
  41899. /**
  41900. * Returns the biggest value ever
  41901. */
  41902. get max(): number;
  41903. /**
  41904. * Returns the average value since the performance counter is running
  41905. */
  41906. get average(): number;
  41907. /**
  41908. * Returns the average value of the last second the counter was monitored
  41909. */
  41910. get lastSecAverage(): number;
  41911. /**
  41912. * Returns the current value
  41913. */
  41914. get current(): number;
  41915. /**
  41916. * Gets the accumulated total
  41917. */
  41918. get total(): number;
  41919. /**
  41920. * Gets the total value count
  41921. */
  41922. get count(): number;
  41923. /**
  41924. * Creates a new counter
  41925. */
  41926. constructor();
  41927. /**
  41928. * Call this method to start monitoring a new frame.
  41929. * 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.
  41930. */
  41931. fetchNewFrame(): void;
  41932. /**
  41933. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41934. * @param newCount the count value to add to the monitored count
  41935. * @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.
  41936. */
  41937. addCount(newCount: number, fetchResult: boolean): void;
  41938. /**
  41939. * Start monitoring this performance counter
  41940. */
  41941. beginMonitoring(): void;
  41942. /**
  41943. * Compute the time lapsed since the previous beginMonitoring() call.
  41944. * @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
  41945. */
  41946. endMonitoring(newFrame?: boolean): void;
  41947. private _fetchResult;
  41948. private _startMonitoringTime;
  41949. private _min;
  41950. private _max;
  41951. private _average;
  41952. private _current;
  41953. private _totalValueCount;
  41954. private _totalAccumulated;
  41955. private _lastSecAverage;
  41956. private _lastSecAccumulated;
  41957. private _lastSecTime;
  41958. private _lastSecValueCount;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. interface ThinEngine {
  41963. /** @hidden */
  41964. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41965. /** @hidden */
  41966. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  41967. }
  41968. }
  41969. declare module BABYLON {
  41970. /**
  41971. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41973. */
  41974. export class Analyser {
  41975. /**
  41976. * Gets or sets the smoothing
  41977. * @ignorenaming
  41978. */
  41979. SMOOTHING: number;
  41980. /**
  41981. * Gets or sets the FFT table size
  41982. * @ignorenaming
  41983. */
  41984. FFT_SIZE: number;
  41985. /**
  41986. * Gets or sets the bar graph amplitude
  41987. * @ignorenaming
  41988. */
  41989. BARGRAPHAMPLITUDE: number;
  41990. /**
  41991. * Gets or sets the position of the debug canvas
  41992. * @ignorenaming
  41993. */
  41994. DEBUGCANVASPOS: {
  41995. x: number;
  41996. y: number;
  41997. };
  41998. /**
  41999. * Gets or sets the debug canvas size
  42000. * @ignorenaming
  42001. */
  42002. DEBUGCANVASSIZE: {
  42003. width: number;
  42004. height: number;
  42005. };
  42006. private _byteFreqs;
  42007. private _byteTime;
  42008. private _floatFreqs;
  42009. private _webAudioAnalyser;
  42010. private _debugCanvas;
  42011. private _debugCanvasContext;
  42012. private _scene;
  42013. private _registerFunc;
  42014. private _audioEngine;
  42015. /**
  42016. * Creates a new analyser
  42017. * @param scene defines hosting scene
  42018. */
  42019. constructor(scene: Scene);
  42020. /**
  42021. * Get the number of data values you will have to play with for the visualization
  42022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42023. * @returns a number
  42024. */
  42025. getFrequencyBinCount(): number;
  42026. /**
  42027. * Gets the current frequency data as a byte array
  42028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42029. * @returns a Uint8Array
  42030. */
  42031. getByteFrequencyData(): Uint8Array;
  42032. /**
  42033. * Gets the current waveform as a byte array
  42034. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42035. * @returns a Uint8Array
  42036. */
  42037. getByteTimeDomainData(): Uint8Array;
  42038. /**
  42039. * Gets the current frequency data as a float array
  42040. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42041. * @returns a Float32Array
  42042. */
  42043. getFloatFrequencyData(): Float32Array;
  42044. /**
  42045. * Renders the debug canvas
  42046. */
  42047. drawDebugCanvas(): void;
  42048. /**
  42049. * Stops rendering the debug canvas and removes it
  42050. */
  42051. stopDebugCanvas(): void;
  42052. /**
  42053. * Connects two audio nodes
  42054. * @param inputAudioNode defines first node to connect
  42055. * @param outputAudioNode defines second node to connect
  42056. */
  42057. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42058. /**
  42059. * Releases all associated resources
  42060. */
  42061. dispose(): void;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * This represents an audio engine and it is responsible
  42067. * to play, synchronize and analyse sounds throughout the application.
  42068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42069. */
  42070. export interface IAudioEngine extends IDisposable {
  42071. /**
  42072. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42073. */
  42074. readonly canUseWebAudio: boolean;
  42075. /**
  42076. * Gets the current AudioContext if available.
  42077. */
  42078. readonly audioContext: Nullable<AudioContext>;
  42079. /**
  42080. * The master gain node defines the global audio volume of your audio engine.
  42081. */
  42082. readonly masterGain: GainNode;
  42083. /**
  42084. * Gets whether or not mp3 are supported by your browser.
  42085. */
  42086. readonly isMP3supported: boolean;
  42087. /**
  42088. * Gets whether or not ogg are supported by your browser.
  42089. */
  42090. readonly isOGGsupported: boolean;
  42091. /**
  42092. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42093. * @ignoreNaming
  42094. */
  42095. WarnedWebAudioUnsupported: boolean;
  42096. /**
  42097. * Defines if the audio engine relies on a custom unlocked button.
  42098. * In this case, the embedded button will not be displayed.
  42099. */
  42100. useCustomUnlockedButton: boolean;
  42101. /**
  42102. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42103. */
  42104. readonly unlocked: boolean;
  42105. /**
  42106. * Event raised when audio has been unlocked on the browser.
  42107. */
  42108. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42109. /**
  42110. * Event raised when audio has been locked on the browser.
  42111. */
  42112. onAudioLockedObservable: Observable<IAudioEngine>;
  42113. /**
  42114. * Flags the audio engine in Locked state.
  42115. * This happens due to new browser policies preventing audio to autoplay.
  42116. */
  42117. lock(): void;
  42118. /**
  42119. * Unlocks the audio engine once a user action has been done on the dom.
  42120. * This is helpful to resume play once browser policies have been satisfied.
  42121. */
  42122. unlock(): void;
  42123. /**
  42124. * Gets the global volume sets on the master gain.
  42125. * @returns the global volume if set or -1 otherwise
  42126. */
  42127. getGlobalVolume(): number;
  42128. /**
  42129. * Sets the global volume of your experience (sets on the master gain).
  42130. * @param newVolume Defines the new global volume of the application
  42131. */
  42132. setGlobalVolume(newVolume: number): void;
  42133. /**
  42134. * Connect the audio engine to an audio analyser allowing some amazing
  42135. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42137. * @param analyser The analyser to connect to the engine
  42138. */
  42139. connectToAnalyser(analyser: Analyser): void;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Defines the interface used by display changed events
  42145. */
  42146. export interface IDisplayChangedEventArgs {
  42147. /** Gets the vrDisplay object (if any) */
  42148. vrDisplay: Nullable<any>;
  42149. /** Gets a boolean indicating if webVR is supported */
  42150. vrSupported: boolean;
  42151. }
  42152. /**
  42153. * Defines the interface used by objects containing a viewport (like a camera)
  42154. */
  42155. interface IViewportOwnerLike {
  42156. /**
  42157. * Gets or sets the viewport
  42158. */
  42159. viewport: IViewportLike;
  42160. }
  42161. /**
  42162. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42163. */
  42164. export class Engine extends ThinEngine {
  42165. /** Defines that alpha blending is disabled */
  42166. static readonly ALPHA_DISABLE: number;
  42167. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42168. static readonly ALPHA_ADD: number;
  42169. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42170. static readonly ALPHA_COMBINE: number;
  42171. /** Defines that alpha blending to DEST - SRC * DEST */
  42172. static readonly ALPHA_SUBTRACT: number;
  42173. /** Defines that alpha blending to SRC * DEST */
  42174. static readonly ALPHA_MULTIPLY: number;
  42175. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42176. static readonly ALPHA_MAXIMIZED: number;
  42177. /** Defines that alpha blending to SRC + DEST */
  42178. static readonly ALPHA_ONEONE: number;
  42179. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42180. static readonly ALPHA_PREMULTIPLIED: number;
  42181. /**
  42182. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42183. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42184. */
  42185. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42186. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42187. static readonly ALPHA_INTERPOLATE: number;
  42188. /**
  42189. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42190. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42191. */
  42192. static readonly ALPHA_SCREENMODE: number;
  42193. /** Defines that the resource is not delayed*/
  42194. static readonly DELAYLOADSTATE_NONE: number;
  42195. /** Defines that the resource was successfully delay loaded */
  42196. static readonly DELAYLOADSTATE_LOADED: number;
  42197. /** Defines that the resource is currently delay loading */
  42198. static readonly DELAYLOADSTATE_LOADING: number;
  42199. /** Defines that the resource is delayed and has not started loading */
  42200. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42201. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42202. static readonly NEVER: number;
  42203. /** 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 */
  42204. static readonly ALWAYS: number;
  42205. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42206. static readonly LESS: number;
  42207. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42208. static readonly EQUAL: number;
  42209. /** 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 */
  42210. static readonly LEQUAL: number;
  42211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42212. static readonly GREATER: number;
  42213. /** 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 */
  42214. static readonly GEQUAL: number;
  42215. /** 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 */
  42216. static readonly NOTEQUAL: number;
  42217. /** Passed to stencilOperation to specify that stencil value must be kept */
  42218. static readonly KEEP: number;
  42219. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42220. static readonly REPLACE: number;
  42221. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42222. static readonly INCR: number;
  42223. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42224. static readonly DECR: number;
  42225. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42226. static readonly INVERT: number;
  42227. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42228. static readonly INCR_WRAP: number;
  42229. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42230. static readonly DECR_WRAP: number;
  42231. /** Texture is not repeating outside of 0..1 UVs */
  42232. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42233. /** Texture is repeating outside of 0..1 UVs */
  42234. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42235. /** Texture is repeating and mirrored */
  42236. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42237. /** ALPHA */
  42238. static readonly TEXTUREFORMAT_ALPHA: number;
  42239. /** LUMINANCE */
  42240. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42241. /** LUMINANCE_ALPHA */
  42242. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42243. /** RGB */
  42244. static readonly TEXTUREFORMAT_RGB: number;
  42245. /** RGBA */
  42246. static readonly TEXTUREFORMAT_RGBA: number;
  42247. /** RED */
  42248. static readonly TEXTUREFORMAT_RED: number;
  42249. /** RED (2nd reference) */
  42250. static readonly TEXTUREFORMAT_R: number;
  42251. /** RG */
  42252. static readonly TEXTUREFORMAT_RG: number;
  42253. /** RED_INTEGER */
  42254. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42255. /** RED_INTEGER (2nd reference) */
  42256. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42257. /** RG_INTEGER */
  42258. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42259. /** RGB_INTEGER */
  42260. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42261. /** RGBA_INTEGER */
  42262. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42263. /** UNSIGNED_BYTE */
  42264. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42265. /** UNSIGNED_BYTE (2nd reference) */
  42266. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42267. /** FLOAT */
  42268. static readonly TEXTURETYPE_FLOAT: number;
  42269. /** HALF_FLOAT */
  42270. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42271. /** BYTE */
  42272. static readonly TEXTURETYPE_BYTE: number;
  42273. /** SHORT */
  42274. static readonly TEXTURETYPE_SHORT: number;
  42275. /** UNSIGNED_SHORT */
  42276. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42277. /** INT */
  42278. static readonly TEXTURETYPE_INT: number;
  42279. /** UNSIGNED_INT */
  42280. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42281. /** UNSIGNED_SHORT_4_4_4_4 */
  42282. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42283. /** UNSIGNED_SHORT_5_5_5_1 */
  42284. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42285. /** UNSIGNED_SHORT_5_6_5 */
  42286. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42287. /** UNSIGNED_INT_2_10_10_10_REV */
  42288. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42289. /** UNSIGNED_INT_24_8 */
  42290. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42291. /** UNSIGNED_INT_10F_11F_11F_REV */
  42292. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42293. /** UNSIGNED_INT_5_9_9_9_REV */
  42294. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42295. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42296. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42297. /** nearest is mag = nearest and min = nearest and mip = none */
  42298. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42299. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42300. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42301. /** Trilinear is mag = linear and min = linear and mip = linear */
  42302. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42303. /** nearest is mag = nearest and min = nearest and mip = linear */
  42304. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42305. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42306. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42307. /** Trilinear is mag = linear and min = linear and mip = linear */
  42308. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42309. /** mag = nearest and min = nearest and mip = nearest */
  42310. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42311. /** mag = nearest and min = linear and mip = nearest */
  42312. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42313. /** mag = nearest and min = linear and mip = linear */
  42314. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42315. /** mag = nearest and min = linear and mip = none */
  42316. static readonly TEXTURE_NEAREST_LINEAR: number;
  42317. /** mag = nearest and min = nearest and mip = none */
  42318. static readonly TEXTURE_NEAREST_NEAREST: number;
  42319. /** mag = linear and min = nearest and mip = nearest */
  42320. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42321. /** mag = linear and min = nearest and mip = linear */
  42322. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42323. /** mag = linear and min = linear and mip = none */
  42324. static readonly TEXTURE_LINEAR_LINEAR: number;
  42325. /** mag = linear and min = nearest and mip = none */
  42326. static readonly TEXTURE_LINEAR_NEAREST: number;
  42327. /** Explicit coordinates mode */
  42328. static readonly TEXTURE_EXPLICIT_MODE: number;
  42329. /** Spherical coordinates mode */
  42330. static readonly TEXTURE_SPHERICAL_MODE: number;
  42331. /** Planar coordinates mode */
  42332. static readonly TEXTURE_PLANAR_MODE: number;
  42333. /** Cubic coordinates mode */
  42334. static readonly TEXTURE_CUBIC_MODE: number;
  42335. /** Projection coordinates mode */
  42336. static readonly TEXTURE_PROJECTION_MODE: number;
  42337. /** Skybox coordinates mode */
  42338. static readonly TEXTURE_SKYBOX_MODE: number;
  42339. /** Inverse Cubic coordinates mode */
  42340. static readonly TEXTURE_INVCUBIC_MODE: number;
  42341. /** Equirectangular coordinates mode */
  42342. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42343. /** Equirectangular Fixed coordinates mode */
  42344. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42345. /** Equirectangular Fixed Mirrored coordinates mode */
  42346. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42347. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42348. static readonly SCALEMODE_FLOOR: number;
  42349. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42350. static readonly SCALEMODE_NEAREST: number;
  42351. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42352. static readonly SCALEMODE_CEILING: number;
  42353. /**
  42354. * Returns the current npm package of the sdk
  42355. */
  42356. static get NpmPackage(): string;
  42357. /**
  42358. * Returns the current version of the framework
  42359. */
  42360. static get Version(): string;
  42361. /** Gets the list of created engines */
  42362. static get Instances(): Engine[];
  42363. /**
  42364. * Gets the latest created engine
  42365. */
  42366. static get LastCreatedEngine(): Nullable<Engine>;
  42367. /**
  42368. * Gets the latest created scene
  42369. */
  42370. static get LastCreatedScene(): Nullable<Scene>;
  42371. /**
  42372. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42373. * @param flag defines which part of the materials must be marked as dirty
  42374. * @param predicate defines a predicate used to filter which materials should be affected
  42375. */
  42376. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42377. /**
  42378. * Method called to create the default loading screen.
  42379. * This can be overridden in your own app.
  42380. * @param canvas The rendering canvas element
  42381. * @returns The loading screen
  42382. */
  42383. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42384. /**
  42385. * Method called to create the default rescale post process on each engine.
  42386. */
  42387. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42388. /**
  42389. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42390. **/
  42391. enableOfflineSupport: boolean;
  42392. /**
  42393. * 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)
  42394. **/
  42395. disableManifestCheck: boolean;
  42396. /**
  42397. * Gets the list of created scenes
  42398. */
  42399. scenes: Scene[];
  42400. /**
  42401. * Event raised when a new scene is created
  42402. */
  42403. onNewSceneAddedObservable: Observable<Scene>;
  42404. /**
  42405. * Gets the list of created postprocesses
  42406. */
  42407. postProcesses: PostProcess[];
  42408. /**
  42409. * Gets a boolean indicating if the pointer is currently locked
  42410. */
  42411. isPointerLock: boolean;
  42412. /**
  42413. * Observable event triggered each time the rendering canvas is resized
  42414. */
  42415. onResizeObservable: Observable<Engine>;
  42416. /**
  42417. * Observable event triggered each time the canvas loses focus
  42418. */
  42419. onCanvasBlurObservable: Observable<Engine>;
  42420. /**
  42421. * Observable event triggered each time the canvas gains focus
  42422. */
  42423. onCanvasFocusObservable: Observable<Engine>;
  42424. /**
  42425. * Observable event triggered each time the canvas receives pointerout event
  42426. */
  42427. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42428. /**
  42429. * Observable raised when the engine begins a new frame
  42430. */
  42431. onBeginFrameObservable: Observable<Engine>;
  42432. /**
  42433. * If set, will be used to request the next animation frame for the render loop
  42434. */
  42435. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42436. /**
  42437. * Observable raised when the engine ends the current frame
  42438. */
  42439. onEndFrameObservable: Observable<Engine>;
  42440. /**
  42441. * Observable raised when the engine is about to compile a shader
  42442. */
  42443. onBeforeShaderCompilationObservable: Observable<Engine>;
  42444. /**
  42445. * Observable raised when the engine has just compiled a shader
  42446. */
  42447. onAfterShaderCompilationObservable: Observable<Engine>;
  42448. /**
  42449. * Gets the audio engine
  42450. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42451. * @ignorenaming
  42452. */
  42453. static audioEngine: IAudioEngine;
  42454. /**
  42455. * Default AudioEngine factory responsible of creating the Audio Engine.
  42456. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42457. */
  42458. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42459. /**
  42460. * Default offline support factory responsible of creating a tool used to store data locally.
  42461. * By default, this will create a Database object if the workload has been embedded.
  42462. */
  42463. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42464. private _loadingScreen;
  42465. private _pointerLockRequested;
  42466. private _rescalePostProcess;
  42467. protected _deterministicLockstep: boolean;
  42468. protected _lockstepMaxSteps: number;
  42469. protected _timeStep: number;
  42470. protected get _supportsHardwareTextureRescaling(): boolean;
  42471. private _fps;
  42472. private _deltaTime;
  42473. /** @hidden */
  42474. _drawCalls: PerfCounter;
  42475. /** 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 */
  42476. canvasTabIndex: number;
  42477. /**
  42478. * Turn this value on if you want to pause FPS computation when in background
  42479. */
  42480. disablePerformanceMonitorInBackground: boolean;
  42481. private _performanceMonitor;
  42482. /**
  42483. * Gets the performance monitor attached to this engine
  42484. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42485. */
  42486. get performanceMonitor(): PerformanceMonitor;
  42487. private _onFocus;
  42488. private _onBlur;
  42489. private _onCanvasPointerOut;
  42490. private _onCanvasBlur;
  42491. private _onCanvasFocus;
  42492. private _onFullscreenChange;
  42493. private _onPointerLockChange;
  42494. /**
  42495. * Gets the HTML element used to attach event listeners
  42496. * @returns a HTML element
  42497. */
  42498. getInputElement(): Nullable<HTMLElement>;
  42499. /**
  42500. * Creates a new engine
  42501. * @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
  42502. * @param antialias defines enable antialiasing (default: false)
  42503. * @param options defines further options to be sent to the getContext() function
  42504. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42505. */
  42506. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42507. /**
  42508. * Shared initialization across engines types.
  42509. * @param canvas The canvas associated with this instance of the engine.
  42510. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42511. * @param audioEngine Defines if an audio engine should be created by default
  42512. */
  42513. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42514. /**
  42515. * Gets current aspect ratio
  42516. * @param viewportOwner defines the camera to use to get the aspect ratio
  42517. * @param useScreen defines if screen size must be used (or the current render target if any)
  42518. * @returns a number defining the aspect ratio
  42519. */
  42520. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42521. /**
  42522. * Gets current screen aspect ratio
  42523. * @returns a number defining the aspect ratio
  42524. */
  42525. getScreenAspectRatio(): number;
  42526. /**
  42527. * Gets the client rect of the HTML canvas attached with the current webGL context
  42528. * @returns a client rectangle
  42529. */
  42530. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42531. /**
  42532. * Gets the client rect of the HTML element used for events
  42533. * @returns a client rectangle
  42534. */
  42535. getInputElementClientRect(): Nullable<ClientRect>;
  42536. /**
  42537. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42538. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42539. * @returns true if engine is in deterministic lock step mode
  42540. */
  42541. isDeterministicLockStep(): boolean;
  42542. /**
  42543. * Gets the max steps when engine is running in deterministic lock step
  42544. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42545. * @returns the max steps
  42546. */
  42547. getLockstepMaxSteps(): number;
  42548. /**
  42549. * Returns the time in ms between steps when using deterministic lock step.
  42550. * @returns time step in (ms)
  42551. */
  42552. getTimeStep(): number;
  42553. /**
  42554. * Force the mipmap generation for the given render target texture
  42555. * @param texture defines the render target texture to use
  42556. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42557. */
  42558. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42559. /** States */
  42560. /**
  42561. * Set various states to the webGL context
  42562. * @param culling defines backface culling state
  42563. * @param zOffset defines the value to apply to zOffset (0 by default)
  42564. * @param force defines if states must be applied even if cache is up to date
  42565. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42566. */
  42567. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42568. /**
  42569. * Set the z offset to apply to current rendering
  42570. * @param value defines the offset to apply
  42571. */
  42572. setZOffset(value: number): void;
  42573. /**
  42574. * Gets the current value of the zOffset
  42575. * @returns the current zOffset state
  42576. */
  42577. getZOffset(): number;
  42578. /**
  42579. * Gets a boolean indicating if depth testing is enabled
  42580. * @returns the current state
  42581. */
  42582. getDepthBuffer(): boolean;
  42583. /**
  42584. * Enable or disable depth buffering
  42585. * @param enable defines the state to set
  42586. */
  42587. setDepthBuffer(enable: boolean): void;
  42588. /**
  42589. * Gets a boolean indicating if depth writing is enabled
  42590. * @returns the current depth writing state
  42591. */
  42592. getDepthWrite(): boolean;
  42593. /**
  42594. * Enable or disable depth writing
  42595. * @param enable defines the state to set
  42596. */
  42597. setDepthWrite(enable: boolean): void;
  42598. /**
  42599. * Gets a boolean indicating if stencil buffer is enabled
  42600. * @returns the current stencil buffer state
  42601. */
  42602. getStencilBuffer(): boolean;
  42603. /**
  42604. * Enable or disable the stencil buffer
  42605. * @param enable defines if the stencil buffer must be enabled or disabled
  42606. */
  42607. setStencilBuffer(enable: boolean): void;
  42608. /**
  42609. * Gets the current stencil mask
  42610. * @returns a number defining the new stencil mask to use
  42611. */
  42612. getStencilMask(): number;
  42613. /**
  42614. * Sets the current stencil mask
  42615. * @param mask defines the new stencil mask to use
  42616. */
  42617. setStencilMask(mask: number): void;
  42618. /**
  42619. * Gets the current stencil function
  42620. * @returns a number defining the stencil function to use
  42621. */
  42622. getStencilFunction(): number;
  42623. /**
  42624. * Gets the current stencil reference value
  42625. * @returns a number defining the stencil reference value to use
  42626. */
  42627. getStencilFunctionReference(): number;
  42628. /**
  42629. * Gets the current stencil mask
  42630. * @returns a number defining the stencil mask to use
  42631. */
  42632. getStencilFunctionMask(): number;
  42633. /**
  42634. * Sets the current stencil function
  42635. * @param stencilFunc defines the new stencil function to use
  42636. */
  42637. setStencilFunction(stencilFunc: number): void;
  42638. /**
  42639. * Sets the current stencil reference
  42640. * @param reference defines the new stencil reference to use
  42641. */
  42642. setStencilFunctionReference(reference: number): void;
  42643. /**
  42644. * Sets the current stencil mask
  42645. * @param mask defines the new stencil mask to use
  42646. */
  42647. setStencilFunctionMask(mask: number): void;
  42648. /**
  42649. * Gets the current stencil operation when stencil fails
  42650. * @returns a number defining stencil operation to use when stencil fails
  42651. */
  42652. getStencilOperationFail(): number;
  42653. /**
  42654. * Gets the current stencil operation when depth fails
  42655. * @returns a number defining stencil operation to use when depth fails
  42656. */
  42657. getStencilOperationDepthFail(): number;
  42658. /**
  42659. * Gets the current stencil operation when stencil passes
  42660. * @returns a number defining stencil operation to use when stencil passes
  42661. */
  42662. getStencilOperationPass(): number;
  42663. /**
  42664. * Sets the stencil operation to use when stencil fails
  42665. * @param operation defines the stencil operation to use when stencil fails
  42666. */
  42667. setStencilOperationFail(operation: number): void;
  42668. /**
  42669. * Sets the stencil operation to use when depth fails
  42670. * @param operation defines the stencil operation to use when depth fails
  42671. */
  42672. setStencilOperationDepthFail(operation: number): void;
  42673. /**
  42674. * Sets the stencil operation to use when stencil passes
  42675. * @param operation defines the stencil operation to use when stencil passes
  42676. */
  42677. setStencilOperationPass(operation: number): void;
  42678. /**
  42679. * Sets a boolean indicating if the dithering state is enabled or disabled
  42680. * @param value defines the dithering state
  42681. */
  42682. setDitheringState(value: boolean): void;
  42683. /**
  42684. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42685. * @param value defines the rasterizer state
  42686. */
  42687. setRasterizerState(value: boolean): void;
  42688. /**
  42689. * Gets the current depth function
  42690. * @returns a number defining the depth function
  42691. */
  42692. getDepthFunction(): Nullable<number>;
  42693. /**
  42694. * Sets the current depth function
  42695. * @param depthFunc defines the function to use
  42696. */
  42697. setDepthFunction(depthFunc: number): void;
  42698. /**
  42699. * Sets the current depth function to GREATER
  42700. */
  42701. setDepthFunctionToGreater(): void;
  42702. /**
  42703. * Sets the current depth function to GEQUAL
  42704. */
  42705. setDepthFunctionToGreaterOrEqual(): void;
  42706. /**
  42707. * Sets the current depth function to LESS
  42708. */
  42709. setDepthFunctionToLess(): void;
  42710. /**
  42711. * Sets the current depth function to LEQUAL
  42712. */
  42713. setDepthFunctionToLessOrEqual(): void;
  42714. private _cachedStencilBuffer;
  42715. private _cachedStencilFunction;
  42716. private _cachedStencilMask;
  42717. private _cachedStencilOperationPass;
  42718. private _cachedStencilOperationFail;
  42719. private _cachedStencilOperationDepthFail;
  42720. private _cachedStencilReference;
  42721. /**
  42722. * Caches the the state of the stencil buffer
  42723. */
  42724. cacheStencilState(): void;
  42725. /**
  42726. * Restores the state of the stencil buffer
  42727. */
  42728. restoreStencilState(): void;
  42729. /**
  42730. * Directly set the WebGL Viewport
  42731. * @param x defines the x coordinate of the viewport (in screen space)
  42732. * @param y defines the y coordinate of the viewport (in screen space)
  42733. * @param width defines the width of the viewport (in screen space)
  42734. * @param height defines the height of the viewport (in screen space)
  42735. * @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
  42736. */
  42737. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42738. /**
  42739. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42740. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42741. * @param y defines the y-coordinate of the corner of the clear rectangle
  42742. * @param width defines the width of the clear rectangle
  42743. * @param height defines the height of the clear rectangle
  42744. * @param clearColor defines the clear color
  42745. */
  42746. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42747. /**
  42748. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42749. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42750. * @param y defines the y-coordinate of the corner of the clear rectangle
  42751. * @param width defines the width of the clear rectangle
  42752. * @param height defines the height of the clear rectangle
  42753. */
  42754. enableScissor(x: number, y: number, width: number, height: number): void;
  42755. /**
  42756. * Disable previously set scissor test rectangle
  42757. */
  42758. disableScissor(): void;
  42759. protected _reportDrawCall(): void;
  42760. /**
  42761. * Initializes a webVR display and starts listening to display change events
  42762. * The onVRDisplayChangedObservable will be notified upon these changes
  42763. * @returns The onVRDisplayChangedObservable
  42764. */
  42765. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42766. /** @hidden */
  42767. _prepareVRComponent(): void;
  42768. /** @hidden */
  42769. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42770. /** @hidden */
  42771. _submitVRFrame(): void;
  42772. /**
  42773. * Call this function to leave webVR mode
  42774. * Will do nothing if webVR is not supported or if there is no webVR device
  42775. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42776. */
  42777. disableVR(): void;
  42778. /**
  42779. * Gets a boolean indicating that the system is in VR mode and is presenting
  42780. * @returns true if VR mode is engaged
  42781. */
  42782. isVRPresenting(): boolean;
  42783. /** @hidden */
  42784. _requestVRFrame(): void;
  42785. /** @hidden */
  42786. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42787. /**
  42788. * Gets the source code of the vertex shader associated with a specific webGL program
  42789. * @param program defines the program to use
  42790. * @returns a string containing the source code of the vertex shader associated with the program
  42791. */
  42792. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42793. /**
  42794. * Gets the source code of the fragment shader associated with a specific webGL program
  42795. * @param program defines the program to use
  42796. * @returns a string containing the source code of the fragment shader associated with the program
  42797. */
  42798. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42799. /**
  42800. * Sets a depth stencil texture from a render target to the according uniform.
  42801. * @param channel The texture channel
  42802. * @param uniform The uniform to set
  42803. * @param texture The render target texture containing the depth stencil texture to apply
  42804. * @param name The texture name
  42805. */
  42806. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42807. /**
  42808. * Sets a texture to the webGL context from a postprocess
  42809. * @param channel defines the channel to use
  42810. * @param postProcess defines the source postprocess
  42811. * @param name name of the channel
  42812. */
  42813. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42814. /**
  42815. * Binds the output of the passed in post process to the texture channel specified
  42816. * @param channel The channel the texture should be bound to
  42817. * @param postProcess The post process which's output should be bound
  42818. * @param name name of the channel
  42819. */
  42820. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42821. protected _rebuildBuffers(): void;
  42822. /** @hidden */
  42823. _renderFrame(): void;
  42824. _renderLoop(): void;
  42825. /** @hidden */
  42826. _renderViews(): boolean;
  42827. /**
  42828. * Toggle full screen mode
  42829. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42830. */
  42831. switchFullscreen(requestPointerLock: boolean): void;
  42832. /**
  42833. * Enters full screen mode
  42834. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42835. */
  42836. enterFullscreen(requestPointerLock: boolean): void;
  42837. /**
  42838. * Exits full screen mode
  42839. */
  42840. exitFullscreen(): void;
  42841. /**
  42842. * Enters Pointerlock mode
  42843. */
  42844. enterPointerlock(): void;
  42845. /**
  42846. * Exits Pointerlock mode
  42847. */
  42848. exitPointerlock(): void;
  42849. /**
  42850. * Begin a new frame
  42851. */
  42852. beginFrame(): void;
  42853. /**
  42854. * End the current frame
  42855. */
  42856. endFrame(): void;
  42857. /**
  42858. * Resize the view according to the canvas' size
  42859. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42860. */
  42861. resize(forceSetSize?: boolean): void;
  42862. /**
  42863. * Force a specific size of the canvas
  42864. * @param width defines the new canvas' width
  42865. * @param height defines the new canvas' height
  42866. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42867. * @returns true if the size was changed
  42868. */
  42869. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42870. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42871. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42872. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42873. _releaseTexture(texture: InternalTexture): void;
  42874. /**
  42875. * @hidden
  42876. * Rescales a texture
  42877. * @param source input texture
  42878. * @param destination destination texture
  42879. * @param scene scene to use to render the resize
  42880. * @param internalFormat format to use when resizing
  42881. * @param onComplete callback to be called when resize has completed
  42882. */
  42883. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42884. /**
  42885. * Gets the current framerate
  42886. * @returns a number representing the framerate
  42887. */
  42888. getFps(): number;
  42889. /**
  42890. * Gets the time spent between current and previous frame
  42891. * @returns a number representing the delta time in ms
  42892. */
  42893. getDeltaTime(): number;
  42894. private _measureFps;
  42895. /** @hidden */
  42896. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42897. /**
  42898. * Updates the sample count of a render target texture
  42899. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42900. * @param texture defines the texture to update
  42901. * @param samples defines the sample count to set
  42902. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42903. */
  42904. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42905. /**
  42906. * Updates a depth texture Comparison Mode and Function.
  42907. * If the comparison Function is equal to 0, the mode will be set to none.
  42908. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42909. * @param texture The texture to set the comparison function for
  42910. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42911. */
  42912. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42913. /**
  42914. * Creates a webGL buffer to use with instantiation
  42915. * @param capacity defines the size of the buffer
  42916. * @returns the webGL buffer
  42917. */
  42918. createInstancesBuffer(capacity: number): DataBuffer;
  42919. /**
  42920. * Delete a webGL buffer used with instantiation
  42921. * @param buffer defines the webGL buffer to delete
  42922. */
  42923. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42924. private _clientWaitAsync;
  42925. /** @hidden */
  42926. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42927. dispose(): void;
  42928. private _disableTouchAction;
  42929. /**
  42930. * Display the loading screen
  42931. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42932. */
  42933. displayLoadingUI(): void;
  42934. /**
  42935. * Hide the loading screen
  42936. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42937. */
  42938. hideLoadingUI(): void;
  42939. /**
  42940. * Gets the current loading screen object
  42941. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42942. */
  42943. get loadingScreen(): ILoadingScreen;
  42944. /**
  42945. * Sets the current loading screen object
  42946. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42947. */
  42948. set loadingScreen(loadingScreen: ILoadingScreen);
  42949. /**
  42950. * Sets the current loading screen text
  42951. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42952. */
  42953. set loadingUIText(text: string);
  42954. /**
  42955. * Sets the current loading screen background color
  42956. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42957. */
  42958. set loadingUIBackgroundColor(color: string);
  42959. /** Pointerlock and fullscreen */
  42960. /**
  42961. * Ask the browser to promote the current element to pointerlock mode
  42962. * @param element defines the DOM element to promote
  42963. */
  42964. static _RequestPointerlock(element: HTMLElement): void;
  42965. /**
  42966. * Asks the browser to exit pointerlock mode
  42967. */
  42968. static _ExitPointerlock(): void;
  42969. /**
  42970. * Ask the browser to promote the current element to fullscreen rendering mode
  42971. * @param element defines the DOM element to promote
  42972. */
  42973. static _RequestFullscreen(element: HTMLElement): void;
  42974. /**
  42975. * Asks the browser to exit fullscreen mode
  42976. */
  42977. static _ExitFullscreen(): void;
  42978. }
  42979. }
  42980. declare module BABYLON {
  42981. /**
  42982. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42983. * during the life time of the application.
  42984. */
  42985. export class EngineStore {
  42986. /** Gets the list of created engines */
  42987. static Instances: Engine[];
  42988. /** @hidden */
  42989. static _LastCreatedScene: Nullable<Scene>;
  42990. /**
  42991. * Gets the latest created engine
  42992. */
  42993. static get LastCreatedEngine(): Nullable<Engine>;
  42994. /**
  42995. * Gets the latest created scene
  42996. */
  42997. static get LastCreatedScene(): Nullable<Scene>;
  42998. /**
  42999. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43000. * @ignorenaming
  43001. */
  43002. static UseFallbackTexture: boolean;
  43003. /**
  43004. * Texture content used if a texture cannot loaded
  43005. * @ignorenaming
  43006. */
  43007. static FallbackTexture: string;
  43008. }
  43009. }
  43010. declare module BABYLON {
  43011. /**
  43012. * Helper class that provides a small promise polyfill
  43013. */
  43014. export class PromisePolyfill {
  43015. /**
  43016. * Static function used to check if the polyfill is required
  43017. * If this is the case then the function will inject the polyfill to window.Promise
  43018. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43019. */
  43020. static Apply(force?: boolean): void;
  43021. }
  43022. }
  43023. declare module BABYLON {
  43024. /**
  43025. * Interface for screenshot methods with describe argument called `size` as object with options
  43026. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43027. */
  43028. export interface IScreenshotSize {
  43029. /**
  43030. * number in pixels for canvas height
  43031. */
  43032. height?: number;
  43033. /**
  43034. * multiplier allowing render at a higher or lower resolution
  43035. * If value is defined then height and width will be ignored and taken from camera
  43036. */
  43037. precision?: number;
  43038. /**
  43039. * number in pixels for canvas width
  43040. */
  43041. width?: number;
  43042. }
  43043. }
  43044. declare module BABYLON {
  43045. interface IColor4Like {
  43046. r: float;
  43047. g: float;
  43048. b: float;
  43049. a: float;
  43050. }
  43051. /**
  43052. * Class containing a set of static utilities functions
  43053. */
  43054. export class Tools {
  43055. /**
  43056. * Gets or sets the base URL to use to load assets
  43057. */
  43058. static get BaseUrl(): string;
  43059. static set BaseUrl(value: string);
  43060. /**
  43061. * Enable/Disable Custom HTTP Request Headers globally.
  43062. * default = false
  43063. * @see CustomRequestHeaders
  43064. */
  43065. static UseCustomRequestHeaders: boolean;
  43066. /**
  43067. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43068. * i.e. when loading files, where the server/service expects an Authorization header
  43069. */
  43070. static CustomRequestHeaders: {
  43071. [key: string]: string;
  43072. };
  43073. /**
  43074. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43075. */
  43076. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43077. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43078. /**
  43079. * Default behaviour for cors in the application.
  43080. * It can be a string if the expected behavior is identical in the entire app.
  43081. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43082. */
  43083. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43084. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43085. /**
  43086. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43087. * @ignorenaming
  43088. */
  43089. static get UseFallbackTexture(): boolean;
  43090. static set UseFallbackTexture(value: boolean);
  43091. /**
  43092. * Use this object to register external classes like custom textures or material
  43093. * to allow the loaders to instantiate them
  43094. */
  43095. static get RegisteredExternalClasses(): {
  43096. [key: string]: Object;
  43097. };
  43098. static set RegisteredExternalClasses(classes: {
  43099. [key: string]: Object;
  43100. });
  43101. /**
  43102. * Texture content used if a texture cannot loaded
  43103. * @ignorenaming
  43104. */
  43105. static get fallbackTexture(): string;
  43106. static set fallbackTexture(value: string);
  43107. /**
  43108. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43109. * @param u defines the coordinate on X axis
  43110. * @param v defines the coordinate on Y axis
  43111. * @param width defines the width of the source data
  43112. * @param height defines the height of the source data
  43113. * @param pixels defines the source byte array
  43114. * @param color defines the output color
  43115. */
  43116. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43117. /**
  43118. * Interpolates between a and b via alpha
  43119. * @param a The lower value (returned when alpha = 0)
  43120. * @param b The upper value (returned when alpha = 1)
  43121. * @param alpha The interpolation-factor
  43122. * @return The mixed value
  43123. */
  43124. static Mix(a: number, b: number, alpha: number): number;
  43125. /**
  43126. * Tries to instantiate a new object from a given class name
  43127. * @param className defines the class name to instantiate
  43128. * @returns the new object or null if the system was not able to do the instantiation
  43129. */
  43130. static Instantiate(className: string): any;
  43131. /**
  43132. * Provides a slice function that will work even on IE
  43133. * @param data defines the array to slice
  43134. * @param start defines the start of the data (optional)
  43135. * @param end defines the end of the data (optional)
  43136. * @returns the new sliced array
  43137. */
  43138. static Slice<T>(data: T, start?: number, end?: number): T;
  43139. /**
  43140. * Provides a slice function that will work even on IE
  43141. * The difference between this and Slice is that this will force-convert to array
  43142. * @param data defines the array to slice
  43143. * @param start defines the start of the data (optional)
  43144. * @param end defines the end of the data (optional)
  43145. * @returns the new sliced array
  43146. */
  43147. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43148. /**
  43149. * Polyfill for setImmediate
  43150. * @param action defines the action to execute after the current execution block
  43151. */
  43152. static SetImmediate(action: () => void): void;
  43153. /**
  43154. * Function indicating if a number is an exponent of 2
  43155. * @param value defines the value to test
  43156. * @returns true if the value is an exponent of 2
  43157. */
  43158. static IsExponentOfTwo(value: number): boolean;
  43159. private static _tmpFloatArray;
  43160. /**
  43161. * Returns the nearest 32-bit single precision float representation of a Number
  43162. * @param value A Number. If the parameter is of a different type, it will get converted
  43163. * to a number or to NaN if it cannot be converted
  43164. * @returns number
  43165. */
  43166. static FloatRound(value: number): number;
  43167. /**
  43168. * Extracts the filename from a path
  43169. * @param path defines the path to use
  43170. * @returns the filename
  43171. */
  43172. static GetFilename(path: string): string;
  43173. /**
  43174. * Extracts the "folder" part of a path (everything before the filename).
  43175. * @param uri The URI to extract the info from
  43176. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43177. * @returns The "folder" part of the path
  43178. */
  43179. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43180. /**
  43181. * Extracts text content from a DOM element hierarchy
  43182. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43183. */
  43184. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43185. /**
  43186. * Convert an angle in radians to degrees
  43187. * @param angle defines the angle to convert
  43188. * @returns the angle in degrees
  43189. */
  43190. static ToDegrees(angle: number): number;
  43191. /**
  43192. * Convert an angle in degrees to radians
  43193. * @param angle defines the angle to convert
  43194. * @returns the angle in radians
  43195. */
  43196. static ToRadians(angle: number): number;
  43197. /**
  43198. * Returns an array if obj is not an array
  43199. * @param obj defines the object to evaluate as an array
  43200. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43201. * @returns either obj directly if obj is an array or a new array containing obj
  43202. */
  43203. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43204. /**
  43205. * Gets the pointer prefix to use
  43206. * @param engine defines the engine we are finding the prefix for
  43207. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43208. */
  43209. static GetPointerPrefix(engine: Engine): string;
  43210. /**
  43211. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43212. * @param url define the url we are trying
  43213. * @param element define the dom element where to configure the cors policy
  43214. */
  43215. static SetCorsBehavior(url: string | string[], element: {
  43216. crossOrigin: string | null;
  43217. }): void;
  43218. /**
  43219. * Removes unwanted characters from an url
  43220. * @param url defines the url to clean
  43221. * @returns the cleaned url
  43222. */
  43223. static CleanUrl(url: string): string;
  43224. /**
  43225. * Gets or sets a function used to pre-process url before using them to load assets
  43226. */
  43227. static get PreprocessUrl(): (url: string) => string;
  43228. static set PreprocessUrl(processor: (url: string) => string);
  43229. /**
  43230. * Loads an image as an HTMLImageElement.
  43231. * @param input url string, ArrayBuffer, or Blob to load
  43232. * @param onLoad callback called when the image successfully loads
  43233. * @param onError callback called when the image fails to load
  43234. * @param offlineProvider offline provider for caching
  43235. * @param mimeType optional mime type
  43236. * @returns the HTMLImageElement of the loaded image
  43237. */
  43238. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43239. /**
  43240. * Loads a file from a url
  43241. * @param url url string, ArrayBuffer, or Blob to load
  43242. * @param onSuccess callback called when the file successfully loads
  43243. * @param onProgress callback called while file is loading (if the server supports this mode)
  43244. * @param offlineProvider defines the offline provider for caching
  43245. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43246. * @param onError callback called when the file fails to load
  43247. * @returns a file request object
  43248. */
  43249. 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;
  43250. /**
  43251. * Loads a file from a url
  43252. * @param url the file url to load
  43253. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43254. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43255. */
  43256. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43257. /**
  43258. * Load a script (identified by an url). When the url returns, the
  43259. * content of this file is added into a new script element, attached to the DOM (body element)
  43260. * @param scriptUrl defines the url of the script to laod
  43261. * @param onSuccess defines the callback called when the script is loaded
  43262. * @param onError defines the callback to call if an error occurs
  43263. * @param scriptId defines the id of the script element
  43264. */
  43265. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43266. /**
  43267. * Load an asynchronous script (identified by an url). When the url returns, the
  43268. * content of this file is added into a new script element, attached to the DOM (body element)
  43269. * @param scriptUrl defines the url of the script to laod
  43270. * @param scriptId defines the id of the script element
  43271. * @returns a promise request object
  43272. */
  43273. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43274. /**
  43275. * Loads a file from a blob
  43276. * @param fileToLoad defines the blob to use
  43277. * @param callback defines the callback to call when data is loaded
  43278. * @param progressCallback defines the callback to call during loading process
  43279. * @returns a file request object
  43280. */
  43281. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43282. /**
  43283. * Reads a file from a File object
  43284. * @param file defines the file to load
  43285. * @param onSuccess defines the callback to call when data is loaded
  43286. * @param onProgress defines the callback to call during loading process
  43287. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43288. * @param onError defines the callback to call when an error occurs
  43289. * @returns a file request object
  43290. */
  43291. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43292. /**
  43293. * Creates a data url from a given string content
  43294. * @param content defines the content to convert
  43295. * @returns the new data url link
  43296. */
  43297. static FileAsURL(content: string): string;
  43298. /**
  43299. * Format the given number to a specific decimal format
  43300. * @param value defines the number to format
  43301. * @param decimals defines the number of decimals to use
  43302. * @returns the formatted string
  43303. */
  43304. static Format(value: number, decimals?: number): string;
  43305. /**
  43306. * Tries to copy an object by duplicating every property
  43307. * @param source defines the source object
  43308. * @param destination defines the target object
  43309. * @param doNotCopyList defines a list of properties to avoid
  43310. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43311. */
  43312. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43313. /**
  43314. * Gets a boolean indicating if the given object has no own property
  43315. * @param obj defines the object to test
  43316. * @returns true if object has no own property
  43317. */
  43318. static IsEmpty(obj: any): boolean;
  43319. /**
  43320. * Function used to register events at window level
  43321. * @param windowElement defines the Window object to use
  43322. * @param events defines the events to register
  43323. */
  43324. static RegisterTopRootEvents(windowElement: Window, events: {
  43325. name: string;
  43326. handler: Nullable<(e: FocusEvent) => any>;
  43327. }[]): void;
  43328. /**
  43329. * Function used to unregister events from window level
  43330. * @param windowElement defines the Window object to use
  43331. * @param events defines the events to unregister
  43332. */
  43333. static UnregisterTopRootEvents(windowElement: Window, events: {
  43334. name: string;
  43335. handler: Nullable<(e: FocusEvent) => any>;
  43336. }[]): void;
  43337. /**
  43338. * @ignore
  43339. */
  43340. static _ScreenshotCanvas: HTMLCanvasElement;
  43341. /**
  43342. * Dumps the current bound framebuffer
  43343. * @param width defines the rendering width
  43344. * @param height defines the rendering height
  43345. * @param engine defines the hosting engine
  43346. * @param successCallback defines the callback triggered once the data are available
  43347. * @param mimeType defines the mime type of the result
  43348. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43349. * @return a void promise
  43350. */
  43351. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43352. /**
  43353. * Dumps an array buffer
  43354. * @param width defines the rendering width
  43355. * @param height defines the rendering height
  43356. * @param data the data array
  43357. * @param successCallback defines the callback triggered once the data are available
  43358. * @param mimeType defines the mime type of the result
  43359. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43360. * @param invertY true to invert the picture in the Y dimension
  43361. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43362. */
  43363. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43364. /**
  43365. * Dumps an array buffer
  43366. * @param width defines the rendering width
  43367. * @param height defines the rendering height
  43368. * @param data the data array
  43369. * @param successCallback defines the callback triggered once the data are available
  43370. * @param mimeType defines the mime type of the result
  43371. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43372. * @param invertY true to invert the picture in the Y dimension
  43373. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43374. * @return a promise that resolve to the final data
  43375. */
  43376. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43377. /**
  43378. * Converts the canvas data to blob.
  43379. * This acts as a polyfill for browsers not supporting the to blob function.
  43380. * @param canvas Defines the canvas to extract the data from
  43381. * @param successCallback Defines the callback triggered once the data are available
  43382. * @param mimeType Defines the mime type of the result
  43383. */
  43384. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43385. /**
  43386. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43387. * @param successCallback defines the callback triggered once the data are available
  43388. * @param mimeType defines the mime type of the result
  43389. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43390. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43391. */
  43392. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43393. /**
  43394. * Downloads a blob in the browser
  43395. * @param blob defines the blob to download
  43396. * @param fileName defines the name of the downloaded file
  43397. */
  43398. static Download(blob: Blob, fileName: string): void;
  43399. /**
  43400. * Will return the right value of the noPreventDefault variable
  43401. * Needed to keep backwards compatibility to the old API.
  43402. *
  43403. * @param args arguments passed to the attachControl function
  43404. * @returns the correct value for noPreventDefault
  43405. */
  43406. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43407. /**
  43408. * Captures a screenshot of the current rendering
  43409. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43410. * @param engine defines the rendering engine
  43411. * @param camera defines the source camera
  43412. * @param size This parameter can be set to a single number or to an object with the
  43413. * following (optional) properties: precision, width, height. If a single number is passed,
  43414. * it will be used for both width and height. If an object is passed, the screenshot size
  43415. * will be derived from the parameters. The precision property is a multiplier allowing
  43416. * rendering at a higher or lower resolution
  43417. * @param successCallback defines the callback receives a single parameter which contains the
  43418. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43419. * src parameter of an <img> to display it
  43420. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43421. * Check your browser for supported MIME types
  43422. */
  43423. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43424. /**
  43425. * Captures a screenshot of the current rendering
  43426. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43427. * @param engine defines the rendering engine
  43428. * @param camera defines the source camera
  43429. * @param size This parameter can be set to a single number or to an object with the
  43430. * following (optional) properties: precision, width, height. If a single number is passed,
  43431. * it will be used for both width and height. If an object is passed, the screenshot size
  43432. * will be derived from the parameters. The precision property is a multiplier allowing
  43433. * rendering at a higher or lower resolution
  43434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43435. * Check your browser for supported MIME types
  43436. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43437. * to the src parameter of an <img> to display it
  43438. */
  43439. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43440. /**
  43441. * Generates an image screenshot from the specified camera.
  43442. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43443. * @param engine The engine to use for rendering
  43444. * @param camera The camera to use for rendering
  43445. * @param size This parameter can be set to a single number or to an object with the
  43446. * following (optional) properties: precision, width, height. If a single number is passed,
  43447. * it will be used for both width and height. If an object is passed, the screenshot size
  43448. * will be derived from the parameters. The precision property is a multiplier allowing
  43449. * rendering at a higher or lower resolution
  43450. * @param successCallback The callback receives a single parameter which contains the
  43451. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43452. * src parameter of an <img> to display it
  43453. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43454. * Check your browser for supported MIME types
  43455. * @param samples Texture samples (default: 1)
  43456. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43457. * @param fileName A name for for the downloaded file.
  43458. */
  43459. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43460. /**
  43461. * Generates an image screenshot from the specified camera.
  43462. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43463. * @param engine The engine to use for rendering
  43464. * @param camera The camera to use for rendering
  43465. * @param size This parameter can be set to a single number or to an object with the
  43466. * following (optional) properties: precision, width, height. If a single number is passed,
  43467. * it will be used for both width and height. If an object is passed, the screenshot size
  43468. * will be derived from the parameters. The precision property is a multiplier allowing
  43469. * rendering at a higher or lower resolution
  43470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43471. * Check your browser for supported MIME types
  43472. * @param samples Texture samples (default: 1)
  43473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43474. * @param fileName A name for for the downloaded file.
  43475. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43476. * to the src parameter of an <img> to display it
  43477. */
  43478. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43479. /**
  43480. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43481. * Be aware Math.random() could cause collisions, but:
  43482. * "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"
  43483. * @returns a pseudo random id
  43484. */
  43485. static RandomId(): string;
  43486. /**
  43487. * Test if the given uri is a base64 string
  43488. * @param uri The uri to test
  43489. * @return True if the uri is a base64 string or false otherwise
  43490. */
  43491. static IsBase64(uri: string): boolean;
  43492. /**
  43493. * Decode the given base64 uri.
  43494. * @param uri The uri to decode
  43495. * @return The decoded base64 data.
  43496. */
  43497. static DecodeBase64(uri: string): ArrayBuffer;
  43498. /**
  43499. * Gets the absolute url.
  43500. * @param url the input url
  43501. * @return the absolute url
  43502. */
  43503. static GetAbsoluteUrl(url: string): string;
  43504. /**
  43505. * No log
  43506. */
  43507. static readonly NoneLogLevel: number;
  43508. /**
  43509. * Only message logs
  43510. */
  43511. static readonly MessageLogLevel: number;
  43512. /**
  43513. * Only warning logs
  43514. */
  43515. static readonly WarningLogLevel: number;
  43516. /**
  43517. * Only error logs
  43518. */
  43519. static readonly ErrorLogLevel: number;
  43520. /**
  43521. * All logs
  43522. */
  43523. static readonly AllLogLevel: number;
  43524. /**
  43525. * Gets a value indicating the number of loading errors
  43526. * @ignorenaming
  43527. */
  43528. static get errorsCount(): number;
  43529. /**
  43530. * Callback called when a new log is added
  43531. */
  43532. static OnNewCacheEntry: (entry: string) => void;
  43533. /**
  43534. * Log a message to the console
  43535. * @param message defines the message to log
  43536. */
  43537. static Log(message: string): void;
  43538. /**
  43539. * Write a warning message to the console
  43540. * @param message defines the message to log
  43541. */
  43542. static Warn(message: string): void;
  43543. /**
  43544. * Write an error message to the console
  43545. * @param message defines the message to log
  43546. */
  43547. static Error(message: string): void;
  43548. /**
  43549. * Gets current log cache (list of logs)
  43550. */
  43551. static get LogCache(): string;
  43552. /**
  43553. * Clears the log cache
  43554. */
  43555. static ClearLogCache(): void;
  43556. /**
  43557. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43558. */
  43559. static set LogLevels(level: number);
  43560. /**
  43561. * Checks if the window object exists
  43562. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43563. */
  43564. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43565. /**
  43566. * No performance log
  43567. */
  43568. static readonly PerformanceNoneLogLevel: number;
  43569. /**
  43570. * Use user marks to log performance
  43571. */
  43572. static readonly PerformanceUserMarkLogLevel: number;
  43573. /**
  43574. * Log performance to the console
  43575. */
  43576. static readonly PerformanceConsoleLogLevel: number;
  43577. private static _performance;
  43578. /**
  43579. * Sets the current performance log level
  43580. */
  43581. static set PerformanceLogLevel(level: number);
  43582. private static _StartPerformanceCounterDisabled;
  43583. private static _EndPerformanceCounterDisabled;
  43584. private static _StartUserMark;
  43585. private static _EndUserMark;
  43586. private static _StartPerformanceConsole;
  43587. private static _EndPerformanceConsole;
  43588. /**
  43589. * Starts a performance counter
  43590. */
  43591. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43592. /**
  43593. * Ends a specific performance counter
  43594. */
  43595. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43596. /**
  43597. * Gets either window.performance.now() if supported or Date.now() else
  43598. */
  43599. static get Now(): number;
  43600. /**
  43601. * This method will return the name of the class used to create the instance of the given object.
  43602. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43603. * @param object the object to get the class name from
  43604. * @param isType defines if the object is actually a type
  43605. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43606. */
  43607. static GetClassName(object: any, isType?: boolean): string;
  43608. /**
  43609. * Gets the first element of an array satisfying a given predicate
  43610. * @param array defines the array to browse
  43611. * @param predicate defines the predicate to use
  43612. * @returns null if not found or the element
  43613. */
  43614. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43615. /**
  43616. * This method will return the name of the full name of the class, including its owning module (if any).
  43617. * 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).
  43618. * @param object the object to get the class name from
  43619. * @param isType defines if the object is actually a type
  43620. * @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.
  43621. * @ignorenaming
  43622. */
  43623. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43624. /**
  43625. * Returns a promise that resolves after the given amount of time.
  43626. * @param delay Number of milliseconds to delay
  43627. * @returns Promise that resolves after the given amount of time
  43628. */
  43629. static DelayAsync(delay: number): Promise<void>;
  43630. /**
  43631. * Utility function to detect if the current user agent is Safari
  43632. * @returns whether or not the current user agent is safari
  43633. */
  43634. static IsSafari(): boolean;
  43635. }
  43636. /**
  43637. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43638. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43639. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43640. * @param name The name of the class, case should be preserved
  43641. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43642. */
  43643. export function className(name: string, module?: string): (target: Object) => void;
  43644. /**
  43645. * An implementation of a loop for asynchronous functions.
  43646. */
  43647. export class AsyncLoop {
  43648. /**
  43649. * Defines the number of iterations for the loop
  43650. */
  43651. iterations: number;
  43652. /**
  43653. * Defines the current index of the loop.
  43654. */
  43655. index: number;
  43656. private _done;
  43657. private _fn;
  43658. private _successCallback;
  43659. /**
  43660. * Constructor.
  43661. * @param iterations the number of iterations.
  43662. * @param func the function to run each iteration
  43663. * @param successCallback the callback that will be called upon successful execution
  43664. * @param offset starting offset.
  43665. */
  43666. constructor(
  43667. /**
  43668. * Defines the number of iterations for the loop
  43669. */
  43670. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43671. /**
  43672. * Execute the next iteration. Must be called after the last iteration was finished.
  43673. */
  43674. executeNext(): void;
  43675. /**
  43676. * Break the loop and run the success callback.
  43677. */
  43678. breakLoop(): void;
  43679. /**
  43680. * Create and run an async loop.
  43681. * @param iterations the number of iterations.
  43682. * @param fn the function to run each iteration
  43683. * @param successCallback the callback that will be called upon successful execution
  43684. * @param offset starting offset.
  43685. * @returns the created async loop object
  43686. */
  43687. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43688. /**
  43689. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43690. * @param iterations total number of iterations
  43691. * @param syncedIterations number of synchronous iterations in each async iteration.
  43692. * @param fn the function to call each iteration.
  43693. * @param callback a success call back that will be called when iterating stops.
  43694. * @param breakFunction a break condition (optional)
  43695. * @param timeout timeout settings for the setTimeout function. default - 0.
  43696. * @returns the created async loop object
  43697. */
  43698. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43699. }
  43700. }
  43701. declare module BABYLON {
  43702. /**
  43703. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43704. * The underlying implementation relies on an associative array to ensure the best performances.
  43705. * The value can be anything including 'null' but except 'undefined'
  43706. */
  43707. export class StringDictionary<T> {
  43708. /**
  43709. * This will clear this dictionary and copy the content from the 'source' one.
  43710. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43711. * @param source the dictionary to take the content from and copy to this dictionary
  43712. */
  43713. copyFrom(source: StringDictionary<T>): void;
  43714. /**
  43715. * Get a value based from its key
  43716. * @param key the given key to get the matching value from
  43717. * @return the value if found, otherwise undefined is returned
  43718. */
  43719. get(key: string): T | undefined;
  43720. /**
  43721. * Get a value from its key or add it if it doesn't exist.
  43722. * This method will ensure you that a given key/data will be present in the dictionary.
  43723. * @param key the given key to get the matching value from
  43724. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43725. * The factory will only be invoked if there's no data for the given key.
  43726. * @return the value corresponding to the key.
  43727. */
  43728. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43729. /**
  43730. * Get a value from its key if present in the dictionary otherwise add it
  43731. * @param key the key to get the value from
  43732. * @param val if there's no such key/value pair in the dictionary add it with this value
  43733. * @return the value corresponding to the key
  43734. */
  43735. getOrAdd(key: string, val: T): T;
  43736. /**
  43737. * Check if there's a given key in the dictionary
  43738. * @param key the key to check for
  43739. * @return true if the key is present, false otherwise
  43740. */
  43741. contains(key: string): boolean;
  43742. /**
  43743. * Add a new key and its corresponding value
  43744. * @param key the key to add
  43745. * @param value the value corresponding to the key
  43746. * @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
  43747. */
  43748. add(key: string, value: T): boolean;
  43749. /**
  43750. * Update a specific value associated to a key
  43751. * @param key defines the key to use
  43752. * @param value defines the value to store
  43753. * @returns true if the value was updated (or false if the key was not found)
  43754. */
  43755. set(key: string, value: T): boolean;
  43756. /**
  43757. * Get the element of the given key and remove it from the dictionary
  43758. * @param key defines the key to search
  43759. * @returns the value associated with the key or null if not found
  43760. */
  43761. getAndRemove(key: string): Nullable<T>;
  43762. /**
  43763. * Remove a key/value from the dictionary.
  43764. * @param key the key to remove
  43765. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43766. */
  43767. remove(key: string): boolean;
  43768. /**
  43769. * Clear the whole content of the dictionary
  43770. */
  43771. clear(): void;
  43772. /**
  43773. * Gets the current count
  43774. */
  43775. get count(): number;
  43776. /**
  43777. * Execute a callback on each key/val of the dictionary.
  43778. * Note that you can remove any element in this dictionary in the callback implementation
  43779. * @param callback the callback to execute on a given key/value pair
  43780. */
  43781. forEach(callback: (key: string, val: T) => void): void;
  43782. /**
  43783. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43784. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43785. * Note that you can remove any element in this dictionary in the callback implementation
  43786. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43787. * @returns the first item
  43788. */
  43789. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43790. private _count;
  43791. private _data;
  43792. }
  43793. }
  43794. declare module BABYLON {
  43795. /** @hidden */
  43796. export interface ICollisionCoordinator {
  43797. createCollider(): Collider;
  43798. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43799. init(scene: Scene): void;
  43800. }
  43801. /** @hidden */
  43802. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43803. private _scene;
  43804. private _scaledPosition;
  43805. private _scaledVelocity;
  43806. private _finalPosition;
  43807. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43808. createCollider(): Collider;
  43809. init(scene: Scene): void;
  43810. private _collideWithWorld;
  43811. }
  43812. }
  43813. declare module BABYLON {
  43814. /**
  43815. * Class used to manage all inputs for the scene.
  43816. */
  43817. export class InputManager {
  43818. /** The distance in pixel that you have to move to prevent some events */
  43819. static DragMovementThreshold: number;
  43820. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43821. static LongPressDelay: number;
  43822. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43823. static DoubleClickDelay: number;
  43824. /** If you need to check double click without raising a single click at first click, enable this flag */
  43825. static ExclusiveDoubleClickMode: boolean;
  43826. /** 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. */
  43827. private _alreadyAttached;
  43828. private _alreadyAttachedTo;
  43829. private _wheelEventName;
  43830. private _onPointerMove;
  43831. private _onPointerDown;
  43832. private _onPointerUp;
  43833. private _initClickEvent;
  43834. private _initActionManager;
  43835. private _delayedSimpleClick;
  43836. private _delayedSimpleClickTimeout;
  43837. private _previousDelayedSimpleClickTimeout;
  43838. private _meshPickProceed;
  43839. private _previousButtonPressed;
  43840. private _currentPickResult;
  43841. private _previousPickResult;
  43842. private _totalPointersPressed;
  43843. private _doubleClickOccured;
  43844. private _pointerOverMesh;
  43845. private _pickedDownMesh;
  43846. private _pickedUpMesh;
  43847. private _pointerX;
  43848. private _pointerY;
  43849. private _unTranslatedPointerX;
  43850. private _unTranslatedPointerY;
  43851. private _startingPointerPosition;
  43852. private _previousStartingPointerPosition;
  43853. private _startingPointerTime;
  43854. private _previousStartingPointerTime;
  43855. private _pointerCaptures;
  43856. private _meshUnderPointerId;
  43857. private _onKeyDown;
  43858. private _onKeyUp;
  43859. private _keyboardIsAttached;
  43860. private _onCanvasFocusObserver;
  43861. private _onCanvasBlurObserver;
  43862. private _scene;
  43863. /**
  43864. * Creates a new InputManager
  43865. * @param scene defines the hosting scene
  43866. */
  43867. constructor(scene: Scene);
  43868. /**
  43869. * Gets the mesh that is currently under the pointer
  43870. */
  43871. get meshUnderPointer(): Nullable<AbstractMesh>;
  43872. /**
  43873. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43874. * @param pointerId the pointer id to use
  43875. * @returns The mesh under this pointer id or null if not found
  43876. */
  43877. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43878. /**
  43879. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43880. */
  43881. get unTranslatedPointer(): Vector2;
  43882. /**
  43883. * Gets or sets the current on-screen X position of the pointer
  43884. */
  43885. get pointerX(): number;
  43886. set pointerX(value: number);
  43887. /**
  43888. * Gets or sets the current on-screen Y position of the pointer
  43889. */
  43890. get pointerY(): number;
  43891. set pointerY(value: number);
  43892. private _updatePointerPosition;
  43893. private _processPointerMove;
  43894. private _setRayOnPointerInfo;
  43895. private _checkPrePointerObservable;
  43896. /**
  43897. * Use this method to simulate a pointer move on a mesh
  43898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43901. */
  43902. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43903. /**
  43904. * Use this method to simulate a pointer down on a mesh
  43905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43908. */
  43909. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43910. private _processPointerDown;
  43911. /** @hidden */
  43912. _isPointerSwiping(): boolean;
  43913. /**
  43914. * Use this method to simulate a pointer up on a mesh
  43915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43916. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43917. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43918. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43919. */
  43920. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43921. private _processPointerUp;
  43922. /**
  43923. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43924. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43925. * @returns true if the pointer was captured
  43926. */
  43927. isPointerCaptured(pointerId?: number): boolean;
  43928. /**
  43929. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43930. * @param attachUp defines if you want to attach events to pointerup
  43931. * @param attachDown defines if you want to attach events to pointerdown
  43932. * @param attachMove defines if you want to attach events to pointermove
  43933. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43934. */
  43935. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43936. /**
  43937. * Detaches all event handlers
  43938. */
  43939. detachControl(): void;
  43940. /**
  43941. * Force the value of meshUnderPointer
  43942. * @param mesh defines the mesh to use
  43943. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43944. */
  43945. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43946. /**
  43947. * Gets the mesh under the pointer
  43948. * @returns a Mesh or null if no mesh is under the pointer
  43949. */
  43950. getPointerOverMesh(): Nullable<AbstractMesh>;
  43951. }
  43952. }
  43953. declare module BABYLON {
  43954. /**
  43955. * This class defines the direct association between an animation and a target
  43956. */
  43957. export class TargetedAnimation {
  43958. /**
  43959. * Animation to perform
  43960. */
  43961. animation: Animation;
  43962. /**
  43963. * Target to animate
  43964. */
  43965. target: any;
  43966. /**
  43967. * Returns the string "TargetedAnimation"
  43968. * @returns "TargetedAnimation"
  43969. */
  43970. getClassName(): string;
  43971. /**
  43972. * Serialize the object
  43973. * @returns the JSON object representing the current entity
  43974. */
  43975. serialize(): any;
  43976. }
  43977. /**
  43978. * Use this class to create coordinated animations on multiple targets
  43979. */
  43980. export class AnimationGroup implements IDisposable {
  43981. /** The name of the animation group */
  43982. name: string;
  43983. private _scene;
  43984. private _targetedAnimations;
  43985. private _animatables;
  43986. private _from;
  43987. private _to;
  43988. private _isStarted;
  43989. private _isPaused;
  43990. private _speedRatio;
  43991. private _loopAnimation;
  43992. private _isAdditive;
  43993. /**
  43994. * Gets or sets the unique id of the node
  43995. */
  43996. uniqueId: number;
  43997. /**
  43998. * This observable will notify when one animation have ended
  43999. */
  44000. onAnimationEndObservable: Observable<TargetedAnimation>;
  44001. /**
  44002. * Observer raised when one animation loops
  44003. */
  44004. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44005. /**
  44006. * Observer raised when all animations have looped
  44007. */
  44008. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44009. /**
  44010. * This observable will notify when all animations have ended.
  44011. */
  44012. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44013. /**
  44014. * This observable will notify when all animations have paused.
  44015. */
  44016. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44017. /**
  44018. * This observable will notify when all animations are playing.
  44019. */
  44020. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44021. /**
  44022. * Gets the first frame
  44023. */
  44024. get from(): number;
  44025. /**
  44026. * Gets the last frame
  44027. */
  44028. get to(): number;
  44029. /**
  44030. * Define if the animations are started
  44031. */
  44032. get isStarted(): boolean;
  44033. /**
  44034. * Gets a value indicating that the current group is playing
  44035. */
  44036. get isPlaying(): boolean;
  44037. /**
  44038. * Gets or sets the speed ratio to use for all animations
  44039. */
  44040. get speedRatio(): number;
  44041. /**
  44042. * Gets or sets the speed ratio to use for all animations
  44043. */
  44044. set speedRatio(value: number);
  44045. /**
  44046. * Gets or sets if all animations should loop or not
  44047. */
  44048. get loopAnimation(): boolean;
  44049. set loopAnimation(value: boolean);
  44050. /**
  44051. * Gets or sets if all animations should be evaluated additively
  44052. */
  44053. get isAdditive(): boolean;
  44054. set isAdditive(value: boolean);
  44055. /**
  44056. * Gets the targeted animations for this animation group
  44057. */
  44058. get targetedAnimations(): Array<TargetedAnimation>;
  44059. /**
  44060. * returning the list of animatables controlled by this animation group.
  44061. */
  44062. get animatables(): Array<Animatable>;
  44063. /**
  44064. * Gets the list of target animations
  44065. */
  44066. get children(): TargetedAnimation[];
  44067. /**
  44068. * Instantiates a new Animation Group.
  44069. * This helps managing several animations at once.
  44070. * @see https://doc.babylonjs.com/how_to/group
  44071. * @param name Defines the name of the group
  44072. * @param scene Defines the scene the group belongs to
  44073. */
  44074. constructor(
  44075. /** The name of the animation group */
  44076. name: string, scene?: Nullable<Scene>);
  44077. /**
  44078. * Add an animation (with its target) in the group
  44079. * @param animation defines the animation we want to add
  44080. * @param target defines the target of the animation
  44081. * @returns the TargetedAnimation object
  44082. */
  44083. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44084. /**
  44085. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44086. * It can add constant keys at begin or end
  44087. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44088. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44089. * @returns the animation group
  44090. */
  44091. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44092. private _animationLoopCount;
  44093. private _animationLoopFlags;
  44094. private _processLoop;
  44095. /**
  44096. * Start all animations on given targets
  44097. * @param loop defines if animations must loop
  44098. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44099. * @param from defines the from key (optional)
  44100. * @param to defines the to key (optional)
  44101. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44102. * @returns the current animation group
  44103. */
  44104. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44105. /**
  44106. * Pause all animations
  44107. * @returns the animation group
  44108. */
  44109. pause(): AnimationGroup;
  44110. /**
  44111. * Play all animations to initial state
  44112. * This function will start() the animations if they were not started or will restart() them if they were paused
  44113. * @param loop defines if animations must loop
  44114. * @returns the animation group
  44115. */
  44116. play(loop?: boolean): AnimationGroup;
  44117. /**
  44118. * Reset all animations to initial state
  44119. * @returns the animation group
  44120. */
  44121. reset(): AnimationGroup;
  44122. /**
  44123. * Restart animations from key 0
  44124. * @returns the animation group
  44125. */
  44126. restart(): AnimationGroup;
  44127. /**
  44128. * Stop all animations
  44129. * @returns the animation group
  44130. */
  44131. stop(): AnimationGroup;
  44132. /**
  44133. * Set animation weight for all animatables
  44134. * @param weight defines the weight to use
  44135. * @return the animationGroup
  44136. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44137. */
  44138. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44139. /**
  44140. * Synchronize and normalize all animatables with a source animatable
  44141. * @param root defines the root animatable to synchronize with
  44142. * @return the animationGroup
  44143. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44144. */
  44145. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44146. /**
  44147. * Goes to a specific frame in this animation group
  44148. * @param frame the frame number to go to
  44149. * @return the animationGroup
  44150. */
  44151. goToFrame(frame: number): AnimationGroup;
  44152. /**
  44153. * Dispose all associated resources
  44154. */
  44155. dispose(): void;
  44156. private _checkAnimationGroupEnded;
  44157. /**
  44158. * Clone the current animation group and returns a copy
  44159. * @param newName defines the name of the new group
  44160. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44161. * @returns the new animation group
  44162. */
  44163. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44164. /**
  44165. * Serializes the animationGroup to an object
  44166. * @returns Serialized object
  44167. */
  44168. serialize(): any;
  44169. /**
  44170. * Returns a new AnimationGroup object parsed from the source provided.
  44171. * @param parsedAnimationGroup defines the source
  44172. * @param scene defines the scene that will receive the animationGroup
  44173. * @returns a new AnimationGroup
  44174. */
  44175. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44176. /**
  44177. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44178. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44179. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44180. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44181. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44182. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44183. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44184. */
  44185. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44186. /**
  44187. * Returns the string "AnimationGroup"
  44188. * @returns "AnimationGroup"
  44189. */
  44190. getClassName(): string;
  44191. /**
  44192. * Creates a detailed string about the object
  44193. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44194. * @returns a string representing the object
  44195. */
  44196. toString(fullDetails?: boolean): string;
  44197. }
  44198. }
  44199. declare module BABYLON {
  44200. /**
  44201. * @hidden
  44202. **/
  44203. export class _TimeToken {
  44204. _startTimeQuery: Nullable<WebGLQuery>;
  44205. _endTimeQuery: Nullable<WebGLQuery>;
  44206. _timeElapsedQuery: Nullable<WebGLQuery>;
  44207. _timeElapsedQueryEnded: boolean;
  44208. }
  44209. }
  44210. declare module BABYLON {
  44211. /** @hidden */
  44212. export enum ExtensionName {
  44213. DepthClamping = "depth-clamping",
  44214. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44215. Depth32FloatStencil8 = "depth32float-stencil8",
  44216. PipelineStatisticsQuery = "pipeline-statistics-query",
  44217. TextureCompressionBC = "texture-compression-bc",
  44218. TimestampQuery = "timestamp-query"
  44219. }
  44220. /** @hidden */
  44221. export enum AddressMode {
  44222. ClampToEdge = "clamp-to-edge",
  44223. Repeat = "repeat",
  44224. MirrorRepeat = "mirror-repeat"
  44225. }
  44226. /** @hidden */
  44227. export enum BindingType {
  44228. UniformBuffer = "uniform-buffer",
  44229. StorageBuffer = "storage-buffer",
  44230. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44231. Sampler = "sampler",
  44232. ComparisonSampler = "comparison-sampler",
  44233. SampledTexture = "sampled-texture",
  44234. ReadonlyStorageTexture = "readonly-storage-texture",
  44235. WriteonlyStorageTexture = "writeonly-storage-texture"
  44236. }
  44237. /** @hidden */
  44238. export enum BlendFactor {
  44239. Zero = "zero",
  44240. One = "one",
  44241. SrcColor = "src-color",
  44242. OneMinusSrcColor = "one-minus-src-color",
  44243. SrcAlpha = "src-alpha",
  44244. OneMinusSrcAlpha = "one-minus-src-alpha",
  44245. DstColor = "dst-color",
  44246. OneMinusDstColor = "one-minus-dst-color",
  44247. DstAlpha = "dst-alpha",
  44248. OneMinusDstAlpha = "one-minus-dst-alpha",
  44249. SrcAlphaSaturated = "src-alpha-saturated",
  44250. BlendColor = "blend-color",
  44251. OneMinusBlendColor = "one-minus-blend-color"
  44252. }
  44253. /** @hidden */
  44254. export enum BlendOperation {
  44255. Add = "add",
  44256. Subtract = "subtract",
  44257. ReverseSubtract = "reverse-subtract",
  44258. Min = "min",
  44259. Max = "max"
  44260. }
  44261. /** @hidden */
  44262. export enum CompareFunction {
  44263. Never = "never",
  44264. Less = "less",
  44265. Equal = "equal",
  44266. LessEqual = "less-equal",
  44267. Greater = "greater",
  44268. NotEqual = "not-equal",
  44269. GreaterEqual = "greater-equal",
  44270. Always = "always"
  44271. }
  44272. /** @hidden */
  44273. export enum CullMode {
  44274. None = "none",
  44275. Front = "front",
  44276. Back = "back"
  44277. }
  44278. /** @hidden */
  44279. export enum FilterMode {
  44280. Nearest = "nearest",
  44281. Linear = "linear"
  44282. }
  44283. /** @hidden */
  44284. export enum FrontFace {
  44285. CCW = "ccw",
  44286. CW = "cw"
  44287. }
  44288. /** @hidden */
  44289. export enum IndexFormat {
  44290. Uint16 = "uint16",
  44291. Uint32 = "uint32"
  44292. }
  44293. /** @hidden */
  44294. export enum InputStepMode {
  44295. Vertex = "vertex",
  44296. Instance = "instance"
  44297. }
  44298. /** @hidden */
  44299. export enum LoadOp {
  44300. Load = "load"
  44301. }
  44302. /** @hidden */
  44303. export enum PrimitiveTopology {
  44304. PointList = "point-list",
  44305. LineList = "line-list",
  44306. LineStrip = "line-strip",
  44307. TriangleList = "triangle-list",
  44308. TriangleStrip = "triangle-strip"
  44309. }
  44310. /** @hidden */
  44311. export enum StencilOperation {
  44312. Keep = "keep",
  44313. Zero = "zero",
  44314. Replace = "replace",
  44315. Invert = "invert",
  44316. IncrementClamp = "increment-clamp",
  44317. DecrementClamp = "decrement-clamp",
  44318. IncrementWrap = "increment-wrap",
  44319. DecrementWrap = "decrement-wrap"
  44320. }
  44321. /** @hidden */
  44322. export enum StoreOp {
  44323. Store = "store",
  44324. Clear = "clear"
  44325. }
  44326. /** @hidden */
  44327. export enum TextureDimension {
  44328. E1d = "1d",
  44329. E2d = "2d",
  44330. E3d = "3d"
  44331. }
  44332. /** @hidden */
  44333. export enum TextureFormat {
  44334. R8Unorm = "r8unorm",
  44335. R8Snorm = "r8snorm",
  44336. R8Uint = "r8uint",
  44337. R8Sint = "r8sint",
  44338. R16Uint = "r16uint",
  44339. R16Sint = "r16sint",
  44340. R16Float = "r16float",
  44341. RG8Unorm = "rg8unorm",
  44342. RG8Snorm = "rg8snorm",
  44343. RG8Uint = "rg8uint",
  44344. RG8Sint = "rg8sint",
  44345. R32Uint = "r32uint",
  44346. R32Sint = "r32sint",
  44347. R32Float = "r32float",
  44348. RG16Uint = "rg16uint",
  44349. RG16Sint = "rg16sint",
  44350. RG16Float = "rg16float",
  44351. RGBA8Unorm = "rgba8unorm",
  44352. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44353. RGBA8Snorm = "rgba8snorm",
  44354. RGBA8Uint = "rgba8uint",
  44355. RGBA8Sint = "rgba8sint",
  44356. BGRA8Unorm = "bgra8unorm",
  44357. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44358. RGB9E5UFloat = "rgb9e5ufloat",
  44359. RGB10A2Unorm = "rgb10a2unorm",
  44360. RG11B10UFloat = "rg11b10ufloat",
  44361. RG32Uint = "rg32uint",
  44362. RG32Sint = "rg32sint",
  44363. RG32Float = "rg32float",
  44364. RGBA16Uint = "rgba16uint",
  44365. RGBA16Sint = "rgba16sint",
  44366. RGBA16Float = "rgba16float",
  44367. RGBA32Uint = "rgba32uint",
  44368. RGBA32Sint = "rgba32sint",
  44369. RGBA32Float = "rgba32float",
  44370. Stencil8 = "stencil8",
  44371. Depth16Unorm = "depth16unorm",
  44372. Depth24Plus = "depth24plus",
  44373. Depth24PlusStencil8 = "depth24plus-stencil8",
  44374. Depth32Float = "depth32float",
  44375. BC1RGBAUNorm = "bc1-rgba-unorm",
  44376. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44377. BC2RGBAUnorm = "bc2-rgba-unorm",
  44378. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44379. BC3RGBAUnorm = "bc3-rgba-unorm",
  44380. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44381. BC4RUnorm = "bc4-r-unorm",
  44382. BC4RSnorm = "bc4-r-snorm",
  44383. BC5RGUnorm = "bc5-rg-unorm",
  44384. BC5RGSnorm = "bc5-rg-snorm",
  44385. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44386. BC6HRGBFloat = "bc6h-rgb-float",
  44387. BC7RGBAUnorm = "bc7-rgba-unorm",
  44388. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44389. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44390. Depth32FloatStencil8 = "depth32float-stencil8"
  44391. }
  44392. /** @hidden */
  44393. export enum TextureComponentType {
  44394. Float = "float",
  44395. Sint = "sint",
  44396. Uint = "uint",
  44397. DepthComparison = "depth-comparison"
  44398. }
  44399. /** @hidden */
  44400. export enum TextureViewDimension {
  44401. E1d = "1d",
  44402. E2d = "2d",
  44403. E2dArray = "2d-array",
  44404. Cube = "cube",
  44405. CubeArray = "cube-array",
  44406. E3d = "3d"
  44407. }
  44408. /** @hidden */
  44409. export enum VertexFormat {
  44410. Uchar2 = "uchar2",
  44411. Uchar4 = "uchar4",
  44412. Char2 = "char2",
  44413. Char4 = "char4",
  44414. Uchar2Norm = "uchar2norm",
  44415. Uchar4Norm = "uchar4norm",
  44416. Char2Norm = "char2norm",
  44417. Char4Norm = "char4norm",
  44418. Ushort2 = "ushort2",
  44419. Ushort4 = "ushort4",
  44420. Short2 = "short2",
  44421. Short4 = "short4",
  44422. Ushort2Norm = "ushort2norm",
  44423. Ushort4Norm = "ushort4norm",
  44424. Short2Norm = "short2norm",
  44425. Short4Norm = "short4norm",
  44426. Half2 = "half2",
  44427. Half4 = "half4",
  44428. Float = "float",
  44429. Float2 = "float2",
  44430. Float3 = "float3",
  44431. Float4 = "float4",
  44432. Uint = "uint",
  44433. Uint2 = "uint2",
  44434. Uint3 = "uint3",
  44435. Uint4 = "uint4",
  44436. Int = "int",
  44437. Int2 = "int2",
  44438. Int3 = "int3",
  44439. Int4 = "int4"
  44440. }
  44441. /** @hidden */
  44442. export enum TextureAspect {
  44443. All = "all",
  44444. StencilOnly = "stencil-only",
  44445. DepthOnly = "depth-only"
  44446. }
  44447. /** @hidden */
  44448. export enum CompilationMessageType {
  44449. Error = "error",
  44450. Warning = "warning",
  44451. Info = "info"
  44452. }
  44453. /** @hidden */
  44454. export enum QueryType {
  44455. Occlusion = "occlusion"
  44456. }
  44457. /** @hidden */
  44458. export enum BufferUsage {
  44459. MapRead = 1,
  44460. MapWrite = 2,
  44461. CopySrc = 4,
  44462. CopyDst = 8,
  44463. Index = 16,
  44464. Vertex = 32,
  44465. Uniform = 64,
  44466. Storage = 128,
  44467. Indirect = 256,
  44468. QueryResolve = 512
  44469. }
  44470. /** @hidden */
  44471. export enum ColorWrite {
  44472. Red = 1,
  44473. Green = 2,
  44474. Blue = 4,
  44475. Alpha = 8,
  44476. All = 15
  44477. }
  44478. /** @hidden */
  44479. export enum ShaderStage {
  44480. Vertex = 1,
  44481. Fragment = 2,
  44482. Compute = 4
  44483. }
  44484. /** @hidden */
  44485. export enum TextureUsage {
  44486. CopySrc = 1,
  44487. CopyDst = 2,
  44488. Sampled = 4,
  44489. Storage = 8,
  44490. OutputAttachment = 16
  44491. }
  44492. /** @hidden */
  44493. export enum MapMode {
  44494. Read = 1,
  44495. Write = 2
  44496. }
  44497. }
  44498. declare module BABYLON {
  44499. /** @hidden */
  44500. export interface WebGPUBindingInfo {
  44501. setIndex: number;
  44502. bindingIndex: number;
  44503. }
  44504. /** @hidden */
  44505. export interface WebGPUTextureSamplerBindingDescription {
  44506. sampler: WebGPUBindingInfo;
  44507. isTextureArray: boolean;
  44508. textures: Array<WebGPUBindingInfo>;
  44509. }
  44510. /** @hidden
  44511. * If the binding is a UBO, isSampler=isTexture=false
  44512. */
  44513. export interface WebGPUBindingDescription {
  44514. name: string;
  44515. usedInVertex: boolean;
  44516. usedInFragment: boolean;
  44517. isSampler: boolean;
  44518. isComparisonSampler?: boolean;
  44519. isTexture: boolean;
  44520. componentType?: GPUTextureComponentType;
  44521. textureDimension?: GPUTextureViewDimension;
  44522. }
  44523. /**
  44524. * @hidden
  44525. */
  44526. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44527. uboNextBindingIndex: number;
  44528. freeSetIndex: number;
  44529. freeBindingIndex: number;
  44530. availableVaryings: {
  44531. [key: string]: number;
  44532. };
  44533. availableAttributes: {
  44534. [key: string]: number;
  44535. };
  44536. availableUBOs: {
  44537. [key: string]: {
  44538. setIndex: number;
  44539. bindingIndex: number;
  44540. };
  44541. };
  44542. availableSamplers: {
  44543. [key: string]: WebGPUTextureSamplerBindingDescription;
  44544. };
  44545. leftOverUniforms: {
  44546. name: string;
  44547. type: string;
  44548. length: number;
  44549. }[];
  44550. orderedAttributes: string[];
  44551. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44552. uniformBufferNames: string[];
  44553. attributeNamesFromEffect: string[];
  44554. attributeLocationsFromEffect: number[];
  44555. private _attributeNextLocation;
  44556. private _varyingNextLocation;
  44557. constructor();
  44558. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44559. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44560. getNextFreeUBOBinding(): {
  44561. setIndex: number;
  44562. bindingIndex: number;
  44563. };
  44564. private _getNextFreeBinding;
  44565. }
  44566. }
  44567. declare module BABYLON {
  44568. /** @hidden */
  44569. export interface IWebGPUPipelineContextSamplerCache {
  44570. samplerBinding: number;
  44571. firstTextureName: string;
  44572. }
  44573. /** @hidden */
  44574. export interface IWebGPUPipelineContextTextureCache {
  44575. textureBinding: number;
  44576. texture: InternalTexture;
  44577. }
  44578. /** @hidden */
  44579. export interface IWebGPUPipelineContextVertexInputsCache {
  44580. indexBuffer: Nullable<GPUBuffer>;
  44581. indexOffset: number;
  44582. vertexStartSlot: number;
  44583. vertexBuffers: GPUBuffer[];
  44584. vertexOffsets: number[];
  44585. }
  44586. /** @hidden */
  44587. export interface IWebGPURenderPipelineStageDescriptor {
  44588. vertexStage: GPUProgrammableStageDescriptor;
  44589. fragmentStage?: GPUProgrammableStageDescriptor;
  44590. }
  44591. /** @hidden */
  44592. export class WebGPUBindGroupCacheNode {
  44593. values: {
  44594. [id: number]: WebGPUBindGroupCacheNode;
  44595. };
  44596. bindGroups: GPUBindGroup[];
  44597. constructor();
  44598. }
  44599. /** @hidden */
  44600. export class WebGPUPipelineContext implements IPipelineContext {
  44601. engine: WebGPUEngine;
  44602. shaderProcessingContext: WebGPUShaderProcessingContext;
  44603. leftOverUniformsByName: {
  44604. [name: string]: string;
  44605. };
  44606. sources: {
  44607. vertex: string;
  44608. fragment: string;
  44609. rawVertex: string;
  44610. rawFragment: string;
  44611. };
  44612. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44613. samplers: {
  44614. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44615. };
  44616. textures: {
  44617. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44618. };
  44619. bindGroupLayouts: GPUBindGroupLayout[];
  44620. bindGroupsCache: WebGPUBindGroupCacheNode;
  44621. /**
  44622. * Stores the uniform buffer
  44623. */
  44624. uniformBuffer: Nullable<UniformBuffer>;
  44625. onCompiled?: () => void;
  44626. get isAsync(): boolean;
  44627. get isReady(): boolean;
  44628. /** @hidden */
  44629. _name: string;
  44630. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44631. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44632. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44633. [key: string]: number;
  44634. }, uniformsNames: string[], uniforms: {
  44635. [key: string]: Nullable<WebGLUniformLocation>;
  44636. }, samplerList: string[], samplers: {
  44637. [key: string]: number;
  44638. }, attributesNames: string[], attributes: number[]): void;
  44639. /** @hidden */
  44640. /**
  44641. * Build the uniform buffer used in the material.
  44642. */
  44643. buildUniformLayout(): void;
  44644. /**
  44645. * Release all associated resources.
  44646. **/
  44647. dispose(): void;
  44648. /**
  44649. * Sets an integer value on a uniform variable.
  44650. * @param uniformName Name of the variable.
  44651. * @param value Value to be set.
  44652. */
  44653. setInt(uniformName: string, value: number): void;
  44654. /**
  44655. * Sets an int2 value on a uniform variable.
  44656. * @param uniformName Name of the variable.
  44657. * @param x First int in int2.
  44658. * @param y Second int in int2.
  44659. */
  44660. setInt2(uniformName: string, x: number, y: number): void;
  44661. /**
  44662. * Sets an int3 value on a uniform variable.
  44663. * @param uniformName Name of the variable.
  44664. * @param x First int in int3.
  44665. * @param y Second int in int3.
  44666. * @param z Third int in int3.
  44667. */
  44668. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44669. /**
  44670. * Sets an int4 value on a uniform variable.
  44671. * @param uniformName Name of the variable.
  44672. * @param x First int in int4.
  44673. * @param y Second int in int4.
  44674. * @param z Third int in int4.
  44675. * @param w Fourth int in int4.
  44676. */
  44677. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44678. /**
  44679. * Sets an int array on a uniform variable.
  44680. * @param uniformName Name of the variable.
  44681. * @param array array to be set.
  44682. */
  44683. setIntArray(uniformName: string, array: Int32Array): void;
  44684. /**
  44685. * 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)
  44686. * @param uniformName Name of the variable.
  44687. * @param array array to be set.
  44688. */
  44689. setIntArray2(uniformName: string, array: Int32Array): void;
  44690. /**
  44691. * 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)
  44692. * @param uniformName Name of the variable.
  44693. * @param array array to be set.
  44694. */
  44695. setIntArray3(uniformName: string, array: Int32Array): void;
  44696. /**
  44697. * 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)
  44698. * @param uniformName Name of the variable.
  44699. * @param array array to be set.
  44700. */
  44701. setIntArray4(uniformName: string, array: Int32Array): void;
  44702. /**
  44703. * Sets an array on a uniform variable.
  44704. * @param uniformName Name of the variable.
  44705. * @param array array to be set.
  44706. */
  44707. setArray(uniformName: string, array: number[]): void;
  44708. /**
  44709. * 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)
  44710. * @param uniformName Name of the variable.
  44711. * @param array array to be set.
  44712. */
  44713. setArray2(uniformName: string, array: number[]): void;
  44714. /**
  44715. * 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)
  44716. * @param uniformName Name of the variable.
  44717. * @param array array to be set.
  44718. * @returns this effect.
  44719. */
  44720. setArray3(uniformName: string, array: number[]): void;
  44721. /**
  44722. * 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)
  44723. * @param uniformName Name of the variable.
  44724. * @param array array to be set.
  44725. */
  44726. setArray4(uniformName: string, array: number[]): void;
  44727. /**
  44728. * Sets matrices on a uniform variable.
  44729. * @param uniformName Name of the variable.
  44730. * @param matrices matrices to be set.
  44731. */
  44732. setMatrices(uniformName: string, matrices: Float32Array): void;
  44733. /**
  44734. * Sets matrix on a uniform variable.
  44735. * @param uniformName Name of the variable.
  44736. * @param matrix matrix to be set.
  44737. */
  44738. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44739. /**
  44740. * 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)
  44741. * @param uniformName Name of the variable.
  44742. * @param matrix matrix to be set.
  44743. */
  44744. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44745. /**
  44746. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44747. * @param uniformName Name of the variable.
  44748. * @param matrix matrix to be set.
  44749. */
  44750. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44751. /**
  44752. * Sets a float on a uniform variable.
  44753. * @param uniformName Name of the variable.
  44754. * @param value value to be set.
  44755. * @returns this effect.
  44756. */
  44757. setFloat(uniformName: string, value: number): void;
  44758. /**
  44759. * Sets a Vector2 on a uniform variable.
  44760. * @param uniformName Name of the variable.
  44761. * @param vector2 vector2 to be set.
  44762. */
  44763. setVector2(uniformName: string, vector2: IVector2Like): void;
  44764. /**
  44765. * Sets a float2 on a uniform variable.
  44766. * @param uniformName Name of the variable.
  44767. * @param x First float in float2.
  44768. * @param y Second float in float2.
  44769. */
  44770. setFloat2(uniformName: string, x: number, y: number): void;
  44771. /**
  44772. * Sets a Vector3 on a uniform variable.
  44773. * @param uniformName Name of the variable.
  44774. * @param vector3 Value to be set.
  44775. */
  44776. setVector3(uniformName: string, vector3: IVector3Like): void;
  44777. /**
  44778. * Sets a float3 on a uniform variable.
  44779. * @param uniformName Name of the variable.
  44780. * @param x First float in float3.
  44781. * @param y Second float in float3.
  44782. * @param z Third float in float3.
  44783. */
  44784. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44785. /**
  44786. * Sets a Vector4 on a uniform variable.
  44787. * @param uniformName Name of the variable.
  44788. * @param vector4 Value to be set.
  44789. */
  44790. setVector4(uniformName: string, vector4: IVector4Like): void;
  44791. /**
  44792. * Sets a float4 on a uniform variable.
  44793. * @param uniformName Name of the variable.
  44794. * @param x First float in float4.
  44795. * @param y Second float in float4.
  44796. * @param z Third float in float4.
  44797. * @param w Fourth float in float4.
  44798. * @returns this effect.
  44799. */
  44800. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44801. /**
  44802. * Sets a Color3 on a uniform variable.
  44803. * @param uniformName Name of the variable.
  44804. * @param color3 Value to be set.
  44805. */
  44806. setColor3(uniformName: string, color3: IColor3Like): void;
  44807. /**
  44808. * Sets a Color4 on a uniform variable.
  44809. * @param uniformName Name of the variable.
  44810. * @param color3 Value to be set.
  44811. * @param alpha Alpha value to be set.
  44812. */
  44813. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44814. /**
  44815. * Sets a Color4 on a uniform variable
  44816. * @param uniformName defines the name of the variable
  44817. * @param color4 defines the value to be set
  44818. */
  44819. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44820. _getVertexShaderCode(): string | null;
  44821. _getFragmentShaderCode(): string | null;
  44822. }
  44823. }
  44824. declare module BABYLON {
  44825. /** @hidden */
  44826. export class WebGPUDataBuffer extends DataBuffer {
  44827. private _buffer;
  44828. constructor(resource: GPUBuffer);
  44829. get underlyingResource(): any;
  44830. }
  44831. }
  44832. declare module BABYLON {
  44833. /**
  44834. * Class used to inline functions in shader code
  44835. */
  44836. export class ShaderCodeInliner {
  44837. private static readonly _RegexpFindFunctionNameAndType;
  44838. private _sourceCode;
  44839. private _functionDescr;
  44840. private _numMaxIterations;
  44841. /** Gets or sets the token used to mark the functions to inline */
  44842. inlineToken: string;
  44843. /** Gets or sets the debug mode */
  44844. debug: boolean;
  44845. /** Gets the code after the inlining process */
  44846. get code(): string;
  44847. /**
  44848. * Initializes the inliner
  44849. * @param sourceCode shader code source to inline
  44850. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44851. */
  44852. constructor(sourceCode: string, numMaxIterations?: number);
  44853. /**
  44854. * Start the processing of the shader code
  44855. */
  44856. processCode(): void;
  44857. private _collectFunctions;
  44858. private _processInlining;
  44859. private _extractBetweenMarkers;
  44860. private _skipWhitespaces;
  44861. private _isIdentifierChar;
  44862. private _removeComments;
  44863. private _replaceFunctionCallsByCode;
  44864. private _findBackward;
  44865. private _escapeRegExp;
  44866. private _replaceNames;
  44867. }
  44868. }
  44869. declare module BABYLON {
  44870. /** @hidden */
  44871. export class WebGPUShaderProcessor implements IShaderProcessor {
  44872. protected _missingVaryings: Array<string>;
  44873. protected _textureArrayProcessing: Array<string>;
  44874. protected _preProcessors: {
  44875. [key: string]: string;
  44876. };
  44877. private _getArraySize;
  44878. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44879. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44880. [key: string]: string;
  44881. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44882. attributeProcessor(attribute: string, preProcessors: {
  44883. [key: string]: string;
  44884. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44885. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44886. [key: string]: string;
  44887. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44888. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44889. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44890. private _applyTextureArrayProcessing;
  44891. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44892. vertexCode: string;
  44893. fragmentCode: string;
  44894. };
  44895. }
  44896. }
  44897. declare module BABYLON {
  44898. /** @hidden */
  44899. export class WebGPUBufferManager {
  44900. private _device;
  44901. private _deferredReleaseBuffers;
  44902. private static _IsGPUBuffer;
  44903. constructor(device: GPUDevice);
  44904. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44905. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44906. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44907. private _FromHalfFloat;
  44908. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44909. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44910. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44911. destroyDeferredBuffers(): void;
  44912. }
  44913. }
  44914. declare module BABYLON {
  44915. /** @hidden */
  44916. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44917. private _webgpuTexture;
  44918. private _webgpuMSAATexture;
  44919. get underlyingResource(): Nullable<GPUTexture>;
  44920. get msaaTexture(): Nullable<GPUTexture>;
  44921. set msaaTexture(texture: Nullable<GPUTexture>);
  44922. view: Nullable<GPUTextureView>;
  44923. format: GPUTextureFormat;
  44924. textureUsages: number;
  44925. constructor(existingTexture?: Nullable<GPUTexture>);
  44926. set(hardwareTexture: GPUTexture): void;
  44927. setMSAATexture(hardwareTexture: GPUTexture): void;
  44928. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44929. createView(descriptor?: GPUTextureViewDescriptor): void;
  44930. reset(): void;
  44931. release(): void;
  44932. }
  44933. }
  44934. declare module BABYLON {
  44935. /** @hidden */
  44936. export class WebGPUTextureHelper {
  44937. private _device;
  44938. private _glslang;
  44939. private _bufferManager;
  44940. private _mipmapSampler;
  44941. private _invertYPreMultiplyAlphaSampler;
  44942. private _pipelines;
  44943. private _compiledShaders;
  44944. private _deferredReleaseTextures;
  44945. private _commandEncoderForCreation;
  44946. static ComputeNumMipmapLevels(width: number, height: number): number;
  44947. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44948. private _getPipeline;
  44949. private static _GetTextureTypeFromFormat;
  44950. private static _GetBlockInformationFromFormat;
  44951. private static _IsHardwareTexture;
  44952. private static _IsInternalTexture;
  44953. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44954. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44955. width: number;
  44956. height: number;
  44957. }): imageBitmap is ImageBitmap;
  44958. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44959. width: number;
  44960. height: number;
  44961. }): imageBitmap is ImageBitmap[];
  44962. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44963. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44964. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44965. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44966. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44967. createTexture(imageBitmap: ImageBitmap | {
  44968. width: number;
  44969. height: number;
  44970. layers: number;
  44971. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44972. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44973. width: number;
  44974. height: number;
  44975. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44976. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44977. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44978. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44979. createMSAATexture(texture: InternalTexture, samples: number): void;
  44980. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44981. 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;
  44982. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44983. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44984. destroyDeferredTextures(): void;
  44985. }
  44986. }
  44987. declare module BABYLON {
  44988. /** @hidden */
  44989. export class WebGPURenderPassWrapper {
  44990. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44991. renderPass: Nullable<GPURenderPassEncoder>;
  44992. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44993. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44994. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44995. depthTextureFormat: GPUTextureFormat | undefined;
  44996. constructor();
  44997. reset(fullReset?: boolean): void;
  44998. }
  44999. }
  45000. declare module BABYLON {
  45001. /** @hidden */
  45002. export class WebGPUCacheSampler {
  45003. private _samplers;
  45004. private _device;
  45005. disabled: boolean;
  45006. constructor(device: GPUDevice);
  45007. private static _GetSamplerHashCode;
  45008. private static _GetSamplerFilterDescriptor;
  45009. private static _GetWrappingMode;
  45010. private static _GetSamplerWrappingDescriptor;
  45011. private static _GetSamplerDescriptor;
  45012. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45013. }
  45014. }
  45015. declare module BABYLON {
  45016. /** @hidden */
  45017. export class WebGPUShaderManager {
  45018. private _shaders;
  45019. private _device;
  45020. constructor(device: GPUDevice);
  45021. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45022. }
  45023. }
  45024. declare module BABYLON {
  45025. /** @hidden */
  45026. export abstract class WebGPUCacheRenderPipeline {
  45027. static NumCacheHitWithoutHash: number;
  45028. static NumCacheHitWithHash: number;
  45029. static NumCacheMiss: number;
  45030. static NumPipelineCreationLastFrame: number;
  45031. disabled: boolean;
  45032. private static _NumPipelineCreationCurrentFrame;
  45033. protected _states: number[];
  45034. protected _stateDirtyLowestIndex: number;
  45035. lastStateDirtyLowestIndex: number;
  45036. private _device;
  45037. private _isDirty;
  45038. private _emptyVertexBuffer;
  45039. private _parameter;
  45040. private _shaderId;
  45041. private _alphaToCoverageEnabled;
  45042. private _frontFace;
  45043. private _cullEnabled;
  45044. private _cullFace;
  45045. private _clampDepth;
  45046. private _rasterizationState;
  45047. private _depthBias;
  45048. private _depthBiasClamp;
  45049. private _depthBiasSlopeScale;
  45050. private _colorFormat;
  45051. private _webgpuColorFormat;
  45052. private _mrtAttachments1;
  45053. private _mrtAttachments2;
  45054. private _mrtFormats;
  45055. private _alphaBlendEnabled;
  45056. private _alphaBlendFuncParams;
  45057. private _alphaBlendEqParams;
  45058. private _writeMask;
  45059. private _colorStates;
  45060. private _depthStencilFormat;
  45061. private _webgpuDepthStencilFormat;
  45062. private _depthTestEnabled;
  45063. private _depthWriteEnabled;
  45064. private _depthCompare;
  45065. private _stencilEnabled;
  45066. private _stencilFrontCompare;
  45067. private _stencilFrontDepthFailOp;
  45068. private _stencilFrontPassOp;
  45069. private _stencilFrontFailOp;
  45070. private _stencilReadMask;
  45071. private _stencilWriteMask;
  45072. private _depthStencilState;
  45073. private _vertexBuffers;
  45074. private _overrideVertexBuffers;
  45075. private _indexBuffer;
  45076. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45077. reset(): void;
  45078. protected abstract _getRenderPipeline(param: {
  45079. token: any;
  45080. pipeline: Nullable<GPURenderPipeline>;
  45081. }): void;
  45082. protected abstract _setRenderPipeline(param: {
  45083. token: any;
  45084. pipeline: Nullable<GPURenderPipeline>;
  45085. }): void;
  45086. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45087. endFrame(): void;
  45088. setAlphaToCoverage(enabled: boolean): void;
  45089. setFrontFace(frontFace: number): void;
  45090. setCullEnabled(enabled: boolean): void;
  45091. setCullFace(cullFace: number): void;
  45092. setClampDepth(clampDepth: boolean): void;
  45093. resetDepthCullingState(): void;
  45094. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45095. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45096. setColorFormat(format: GPUTextureFormat): void;
  45097. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45098. setAlphaBlendEnabled(enabled: boolean): void;
  45099. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45100. setWriteMask(mask: number): void;
  45101. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45102. setDepthTestEnabled(enabled: boolean): void;
  45103. setDepthWriteEnabled(enabled: boolean): void;
  45104. setDepthCompare(func: Nullable<number>): void;
  45105. setStencilEnabled(enabled: boolean): void;
  45106. setStencilCompare(func: Nullable<number>): void;
  45107. setStencilDepthFailOp(op: Nullable<number>): void;
  45108. setStencilPassOp(op: Nullable<number>): void;
  45109. setStencilFailOp(op: Nullable<number>): void;
  45110. setStencilReadMask(mask: number): void;
  45111. setStencilWriteMask(mask: number): void;
  45112. resetStencilState(): void;
  45113. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45114. setBuffers(vertexBuffers: Nullable<{
  45115. [key: string]: Nullable<VertexBuffer>;
  45116. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45117. [key: string]: Nullable<VertexBuffer>;
  45118. }>): void;
  45119. private static _GetTopology;
  45120. private static _GetAphaBlendOperation;
  45121. private static _GetAphaBlendFactor;
  45122. private static _GetCompareFunction;
  45123. private static _GetStencilOpFunction;
  45124. private static _GetVertexInputDescriptorFormat;
  45125. private _getAphaBlendState;
  45126. private _getColorBlendState;
  45127. private _setShaderStage;
  45128. private _setRasterizationState;
  45129. private _setColorStates;
  45130. private _setDepthStencilState;
  45131. private _setVertexState;
  45132. private _createPipelineLayout;
  45133. private _getVertexInputDescriptor;
  45134. private _createRenderPipeline;
  45135. }
  45136. }
  45137. declare module BABYLON {
  45138. /** @hidden */
  45139. class NodeState {
  45140. values: {
  45141. [name: number]: NodeState;
  45142. };
  45143. pipeline: GPURenderPipeline;
  45144. constructor();
  45145. count(): [number, number];
  45146. }
  45147. /** @hidden */
  45148. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45149. private static _Cache;
  45150. private _nodeStack;
  45151. static GetNodeCounts(): {
  45152. nodeCount: number;
  45153. pipelineCount: number;
  45154. };
  45155. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45156. protected _getRenderPipeline(param: {
  45157. token: any;
  45158. pipeline: Nullable<GPURenderPipeline>;
  45159. }): void;
  45160. protected _setRenderPipeline(param: {
  45161. token: NodeState;
  45162. pipeline: Nullable<GPURenderPipeline>;
  45163. }): void;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * @hidden
  45169. **/
  45170. export class WebGPUStencilState extends StencilState {
  45171. private _cache;
  45172. constructor(cache: WebGPUCacheRenderPipeline);
  45173. get stencilFunc(): number;
  45174. set stencilFunc(value: number);
  45175. get stencilFuncRef(): number;
  45176. set stencilFuncRef(value: number);
  45177. get stencilFuncMask(): number;
  45178. set stencilFuncMask(value: number);
  45179. get stencilOpStencilFail(): number;
  45180. set stencilOpStencilFail(value: number);
  45181. get stencilOpDepthFail(): number;
  45182. set stencilOpDepthFail(value: number);
  45183. get stencilOpStencilDepthPass(): number;
  45184. set stencilOpStencilDepthPass(value: number);
  45185. get stencilMask(): number;
  45186. set stencilMask(value: number);
  45187. get stencilTest(): boolean;
  45188. set stencilTest(value: boolean);
  45189. reset(): void;
  45190. apply(gl: WebGLRenderingContext): void;
  45191. }
  45192. }
  45193. declare module BABYLON {
  45194. /**
  45195. * @hidden
  45196. **/
  45197. export class WebGPUDepthCullingState extends DepthCullingState {
  45198. private _cache;
  45199. /**
  45200. * Initializes the state.
  45201. */
  45202. constructor(cache: WebGPUCacheRenderPipeline);
  45203. get zOffset(): number;
  45204. set zOffset(value: number);
  45205. get cullFace(): Nullable<number>;
  45206. set cullFace(value: Nullable<number>);
  45207. get cull(): Nullable<boolean>;
  45208. set cull(value: Nullable<boolean>);
  45209. get depthFunc(): Nullable<number>;
  45210. set depthFunc(value: Nullable<number>);
  45211. get depthMask(): boolean;
  45212. set depthMask(value: boolean);
  45213. get depthTest(): boolean;
  45214. set depthTest(value: boolean);
  45215. get frontFace(): Nullable<number>;
  45216. set frontFace(value: Nullable<number>);
  45217. reset(): void;
  45218. apply(gl: WebGLRenderingContext): void;
  45219. }
  45220. }
  45221. declare module BABYLON {
  45222. /** @hidden */
  45223. export var clearQuadVertexShader: {
  45224. name: string;
  45225. shader: string;
  45226. };
  45227. }
  45228. declare module BABYLON {
  45229. /** @hidden */
  45230. export var clearQuadPixelShader: {
  45231. name: string;
  45232. shader: string;
  45233. };
  45234. }
  45235. declare module BABYLON {
  45236. /**
  45237. * Options to load the associated Glslang library
  45238. */
  45239. export interface GlslangOptions {
  45240. /**
  45241. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45242. */
  45243. glslang?: any;
  45244. /**
  45245. * Defines the URL of the glslang JS File.
  45246. */
  45247. jsPath?: string;
  45248. /**
  45249. * Defines the URL of the glslang WASM File.
  45250. */
  45251. wasmPath?: string;
  45252. }
  45253. /**
  45254. * Options to create the WebGPU engine
  45255. */
  45256. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45257. /**
  45258. * If delta time between frames should be constant
  45259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45260. */
  45261. deterministicLockstep?: boolean;
  45262. /**
  45263. * Maximum about of steps between frames (Default: 4)
  45264. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45265. */
  45266. lockstepMaxSteps?: number;
  45267. /**
  45268. * Defines the seconds between each deterministic lock step
  45269. */
  45270. timeStep?: number;
  45271. /**
  45272. * Defines that engine should ignore modifying touch action attribute and style
  45273. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45274. */
  45275. doNotHandleTouchAction?: boolean;
  45276. /**
  45277. * Defines if webaudio should be initialized as well
  45278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45279. */
  45280. audioEngine?: boolean;
  45281. /**
  45282. * Defines the category of adapter to use.
  45283. * Is it the discrete or integrated device.
  45284. */
  45285. powerPreference?: GPUPowerPreference;
  45286. /**
  45287. * Defines the device descriptor used to create a device.
  45288. */
  45289. deviceDescriptor?: GPUDeviceDescriptor;
  45290. /**
  45291. * Defines the requested Swap Chain Format.
  45292. */
  45293. swapChainFormat?: GPUTextureFormat;
  45294. /**
  45295. * Defines whether MSAA is enabled on the canvas.
  45296. */
  45297. antialiasing?: boolean;
  45298. /**
  45299. * Defines whether the stencil buffer should be enabled.
  45300. */
  45301. stencil?: boolean;
  45302. /**
  45303. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45304. */
  45305. enableGPUDebugMarkers?: boolean;
  45306. /**
  45307. * Options to load the associated Glslang library
  45308. */
  45309. glslangOptions?: GlslangOptions;
  45310. }
  45311. /**
  45312. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45313. */
  45314. export class WebGPUEngine extends Engine {
  45315. private static readonly _glslangDefaultOptions;
  45316. private readonly _uploadEncoderDescriptor;
  45317. private readonly _renderEncoderDescriptor;
  45318. private readonly _renderTargetEncoderDescriptor;
  45319. private readonly _clearDepthValue;
  45320. private readonly _clearReverseDepthValue;
  45321. private readonly _clearStencilValue;
  45322. private readonly _defaultSampleCount;
  45323. private _canvas;
  45324. private _options;
  45325. private _glslang;
  45326. private _adapter;
  45327. private _adapterSupportedExtensions;
  45328. private _device;
  45329. private _deviceEnabledExtensions;
  45330. private _context;
  45331. private _swapChain;
  45332. private _swapChainTexture;
  45333. private _mainPassSampleCount;
  45334. private _textureHelper;
  45335. private _bufferManager;
  45336. private _shaderManager;
  45337. private _cacheSampler;
  45338. private _cacheRenderPipeline;
  45339. private _emptyVertexBuffer;
  45340. private _lastCachedWrapU;
  45341. private _lastCachedWrapV;
  45342. private _lastCachedWrapR;
  45343. private _mrtAttachments;
  45344. private _counters;
  45345. private _mainTexture;
  45346. private _depthTexture;
  45347. private _mainTextureExtends;
  45348. private _depthTextureFormat;
  45349. private _colorFormat;
  45350. private _uploadEncoder;
  45351. private _renderEncoder;
  45352. private _renderTargetEncoder;
  45353. private _commandBuffers;
  45354. private _currentRenderPass;
  45355. private _mainRenderPassWrapper;
  45356. private _rttRenderPassWrapper;
  45357. private _pendingDebugCommands;
  45358. private _currentVertexBuffers;
  45359. private _currentOverrideVertexBuffers;
  45360. private _currentIndexBuffer;
  45361. private __colorWrite;
  45362. private _uniformsBuffers;
  45363. private _forceEnableEffect;
  45364. /** @hidden */
  45365. dbgShowShaderCode: boolean;
  45366. /** @hidden */
  45367. dbgSanityChecks: boolean;
  45368. /** @hidden */
  45369. dbgGenerateLogs: boolean;
  45370. /** @hidden */
  45371. dbgVerboseLogsForFirstFrames: boolean;
  45372. /** @hidden */
  45373. dbgVerboseLogsNumFrames: number;
  45374. /** @hidden */
  45375. dbgShowWarningsNotImplemented: boolean;
  45376. /**
  45377. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45378. */
  45379. get disableCacheSamplers(): boolean;
  45380. set disableCacheSamplers(disable: boolean);
  45381. /**
  45382. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45383. */
  45384. get disableCacheRenderPipelines(): boolean;
  45385. set disableCacheRenderPipelines(disable: boolean);
  45386. /**
  45387. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45388. * @returns true if the engine can be created
  45389. */
  45390. static get IsSupported(): boolean;
  45391. /**
  45392. * Gets a boolean indicating that the engine supports uniform buffers
  45393. */
  45394. get supportsUniformBuffers(): boolean;
  45395. /** Gets the supported extensions by the WebGPU adapter */
  45396. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45397. /** Gets the currently enabled extensions on the WebGPU device */
  45398. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45399. /**
  45400. * Returns the name of the engine
  45401. */
  45402. get name(): string;
  45403. /**
  45404. * Returns a string describing the current engine
  45405. */
  45406. get description(): string;
  45407. /**
  45408. * Returns the version of the engine
  45409. */
  45410. get version(): number;
  45411. /**
  45412. * Create a new instance of the gpu engine asynchronously
  45413. * @param canvas Defines the canvas to use to display the result
  45414. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45415. * @returns a promise that resolves with the created engine
  45416. */
  45417. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45418. /**
  45419. * Create a new instance of the gpu engine.
  45420. * @param canvas Defines the canvas to use to display the result
  45421. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45422. */
  45423. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45424. /**
  45425. * Initializes the WebGPU context and dependencies.
  45426. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45427. * @returns a promise notifying the readiness of the engine.
  45428. */
  45429. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45430. private _initGlslang;
  45431. private _initializeLimits;
  45432. private _initializeContextAndSwapChain;
  45433. private _initializeMainAttachments;
  45434. /**
  45435. * Force a specific size of the canvas
  45436. * @param width defines the new canvas' width
  45437. * @param height defines the new canvas' height
  45438. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45439. * @returns true if the size was changed
  45440. */
  45441. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45442. /**
  45443. * Gets a shader processor implementation fitting with the current engine type.
  45444. * @returns The shader processor implementation.
  45445. */
  45446. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45447. /** @hidden */
  45448. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45449. /**
  45450. * Force the entire cache to be cleared
  45451. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45452. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45453. */
  45454. wipeCaches(bruteForce?: boolean): void;
  45455. /**
  45456. * Enable or disable color writing
  45457. * @param enable defines the state to set
  45458. */
  45459. setColorWrite(enable: boolean): void;
  45460. /**
  45461. * Gets a boolean indicating if color writing is enabled
  45462. * @returns the current color writing state
  45463. */
  45464. getColorWrite(): boolean;
  45465. private _viewportsCurrent;
  45466. private _resetCurrentViewport;
  45467. private _applyViewport;
  45468. /** @hidden */
  45469. _viewport(x: number, y: number, width: number, height: number): void;
  45470. private _scissorsCurrent;
  45471. protected _scissorCached: {
  45472. x: number;
  45473. y: number;
  45474. z: number;
  45475. w: number;
  45476. };
  45477. private _resetCurrentScissor;
  45478. private _applyScissor;
  45479. private _scissorIsActive;
  45480. enableScissor(x: number, y: number, width: number, height: number): void;
  45481. disableScissor(): void;
  45482. /**
  45483. * Clear the current render buffer or the current render target (if any is set up)
  45484. * @param color defines the color to use
  45485. * @param backBuffer defines if the back buffer must be cleared
  45486. * @param depth defines if the depth buffer must be cleared
  45487. * @param stencil defines if the stencil buffer must be cleared
  45488. */
  45489. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45490. /**
  45491. * Clears a list of attachments
  45492. * @param attachments list of the attachments
  45493. * @param colorMain clear color for the main attachment (the first one)
  45494. * @param colorOthers clear color for the other attachments
  45495. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45496. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45497. */
  45498. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45499. /**
  45500. * Creates a vertex buffer
  45501. * @param data the data for the vertex buffer
  45502. * @returns the new buffer
  45503. */
  45504. createVertexBuffer(data: DataArray): DataBuffer;
  45505. /**
  45506. * Creates a vertex buffer
  45507. * @param data the data for the dynamic vertex buffer
  45508. * @returns the new buffer
  45509. */
  45510. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45511. /**
  45512. * Updates a vertex buffer.
  45513. * @param vertexBuffer the vertex buffer to update
  45514. * @param data the data used to update the vertex buffer
  45515. * @param byteOffset the byte offset of the data
  45516. * @param byteLength the byte length of the data
  45517. */
  45518. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45519. /**
  45520. * Creates a new index buffer
  45521. * @param indices defines the content of the index buffer
  45522. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45523. * @returns a new buffer
  45524. */
  45525. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45526. /**
  45527. * Update an index buffer
  45528. * @param indexBuffer defines the target index buffer
  45529. * @param indices defines the data to update
  45530. * @param offset defines the offset in the target index buffer where update should start
  45531. */
  45532. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45533. /** @hidden */
  45534. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45535. /** @hidden */
  45536. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45537. /**
  45538. * Bind a list of vertex buffers with the engine
  45539. * @param vertexBuffers defines the list of vertex buffers to bind
  45540. * @param indexBuffer defines the index buffer to bind
  45541. * @param effect defines the effect associated with the vertex buffers
  45542. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45543. */
  45544. bindBuffers(vertexBuffers: {
  45545. [key: string]: Nullable<VertexBuffer>;
  45546. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45547. [kind: string]: Nullable<VertexBuffer>;
  45548. }): void;
  45549. /** @hidden */
  45550. _releaseBuffer(buffer: DataBuffer): boolean;
  45551. createUniformBuffer(elements: FloatArray): DataBuffer;
  45552. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45553. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45554. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45555. /**
  45556. * Create a new effect (used to store vertex/fragment shaders)
  45557. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45558. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45559. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45560. * @param samplers defines an array of string used to represent textures
  45561. * @param defines defines the string containing the defines to use to compile the shaders
  45562. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45563. * @param onCompiled defines a function to call when the effect creation is successful
  45564. * @param onError defines a function to call when the effect creation has failed
  45565. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45566. * @returns the new Effect
  45567. */
  45568. 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;
  45569. private _compileRawShaderToSpirV;
  45570. private _compileShaderToSpirV;
  45571. private _createPipelineStageDescriptor;
  45572. private _compileRawPipelineStageDescriptor;
  45573. private _compilePipelineStageDescriptor;
  45574. /** @hidden */
  45575. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45576. /** @hidden */
  45577. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45578. /**
  45579. * Creates a new pipeline context
  45580. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45581. * @returns the new pipeline
  45582. */
  45583. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45584. /** @hidden */
  45585. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45586. /**
  45587. * Gets the list of active attributes for a given WebGPU program
  45588. * @param pipelineContext defines the pipeline context to use
  45589. * @param attributesNames defines the list of attribute names to get
  45590. * @returns an array of indices indicating the offset of each attribute
  45591. */
  45592. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45593. /**
  45594. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45595. * @param effect defines the effect to activate
  45596. */
  45597. enableEffect(effect: Nullable<Effect>): void;
  45598. /** @hidden */
  45599. _releaseEffect(effect: Effect): void;
  45600. /**
  45601. * 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
  45602. */
  45603. releaseEffects(): void;
  45604. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45605. /**
  45606. * Gets a boolean indicating that only power of 2 textures are supported
  45607. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45608. */
  45609. get needPOTTextures(): boolean;
  45610. /** @hidden */
  45611. _createHardwareTexture(): HardwareTextureWrapper;
  45612. /** @hidden */
  45613. _releaseTexture(texture: InternalTexture): void;
  45614. /** @hidden */
  45615. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45616. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45617. /**
  45618. * Usually called from Texture.ts.
  45619. * Passed information to create a hardware texture
  45620. * @param url defines a value which contains one of the following:
  45621. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45622. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45623. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45625. * @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)
  45626. * @param scene needed for loading to the correct scene
  45627. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45628. * @param onLoad optional callback to be called upon successful completion
  45629. * @param onError optional callback to be called upon failure
  45630. * @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
  45631. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45632. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45633. * @param forcedExtension defines the extension to use to pick the right loader
  45634. * @param mimeType defines an optional mime type
  45635. * @param loaderOptions options to be passed to the loader
  45636. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45637. */
  45638. 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;
  45639. /** @hidden */
  45640. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45641. /**
  45642. * Creates a cube texture
  45643. * @param rootUrl defines the url where the files to load is located
  45644. * @param scene defines the current scene
  45645. * @param files defines the list of files to load (1 per face)
  45646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45647. * @param onLoad defines an optional callback raised when the texture is loaded
  45648. * @param onError defines an optional callback raised if there is an issue to load the texture
  45649. * @param format defines the format of the data
  45650. * @param forcedExtension defines the extension to use to pick the right loader
  45651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45655. * @param loaderOptions options to be passed to the loader
  45656. * @returns the cube texture as an InternalTexture
  45657. */
  45658. 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;
  45659. /**
  45660. * Creates a raw texture
  45661. * @param data defines the data to store in the texture
  45662. * @param width defines the width of the texture
  45663. * @param height defines the height of the texture
  45664. * @param format defines the format of the data
  45665. * @param generateMipMaps defines if the engine should generate the mip levels
  45666. * @param invertY defines if data must be stored with Y axis inverted
  45667. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45668. * @param compression defines the compression used (null by default)
  45669. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45670. * @returns the raw texture inside an InternalTexture
  45671. */
  45672. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45673. /**
  45674. * Creates a new raw cube texture
  45675. * @param data defines the array of data to use to create each face
  45676. * @param size defines the size of the textures
  45677. * @param format defines the format of the data
  45678. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45679. * @param generateMipMaps defines if the engine should generate the mip levels
  45680. * @param invertY defines if data must be stored with Y axis inverted
  45681. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45682. * @param compression defines the compression used (null by default)
  45683. * @returns the cube texture as an InternalTexture
  45684. */
  45685. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45686. /**
  45687. * Creates a new raw cube texture from a specified url
  45688. * @param url defines the url where the data is located
  45689. * @param scene defines the current scene
  45690. * @param size defines the size of the textures
  45691. * @param format defines the format of the data
  45692. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45693. * @param noMipmap defines if the engine should avoid generating the mip levels
  45694. * @param callback defines a callback used to extract texture data from loaded data
  45695. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45696. * @param onLoad defines a callback called when texture is loaded
  45697. * @param onError defines a callback called if there is an error
  45698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45699. * @param invertY defines if data must be stored with Y axis inverted
  45700. * @returns the cube texture as an InternalTexture
  45701. */
  45702. 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;
  45703. /**
  45704. * Creates a new raw 2D array texture
  45705. * @param data defines the data used to create the texture
  45706. * @param width defines the width of the texture
  45707. * @param height defines the height of the texture
  45708. * @param depth defines the number of layers of the texture
  45709. * @param format defines the format of the texture
  45710. * @param generateMipMaps defines if the engine must generate mip levels
  45711. * @param invertY defines if data must be stored with Y axis inverted
  45712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45713. * @param compression defines the compressed used (can be null)
  45714. * @param textureType defines the compressed used (can be null)
  45715. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45716. */
  45717. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45718. /**
  45719. * Creates a new raw 3D texture
  45720. * @param data defines the data used to create the texture
  45721. * @param width defines the width of the texture
  45722. * @param height defines the height of the texture
  45723. * @param depth defines the depth of the texture
  45724. * @param format defines the format of the texture
  45725. * @param generateMipMaps defines if the engine must generate mip levels
  45726. * @param invertY defines if data must be stored with Y axis inverted
  45727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45728. * @param compression defines the compressed used (can be null)
  45729. * @param textureType defines the compressed used (can be null)
  45730. * @returns a new raw 3D texture (stored in an InternalTexture)
  45731. */
  45732. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45733. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45734. /**
  45735. * Update the sampling mode of a given texture
  45736. * @param samplingMode defines the required sampling mode
  45737. * @param texture defines the texture to update
  45738. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45739. */
  45740. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45741. /**
  45742. * Update the sampling mode of a given texture
  45743. * @param texture defines the texture to update
  45744. * @param wrapU defines the texture wrap mode of the u coordinates
  45745. * @param wrapV defines the texture wrap mode of the v coordinates
  45746. * @param wrapR defines the texture wrap mode of the r coordinates
  45747. */
  45748. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45749. /**
  45750. * Update the dimensions of a texture
  45751. * @param texture texture to update
  45752. * @param width new width of the texture
  45753. * @param height new height of the texture
  45754. * @param depth new depth of the texture
  45755. */
  45756. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45757. private _setInternalTexture;
  45758. /**
  45759. * Sets a texture to the according uniform.
  45760. * @param channel The texture channel
  45761. * @param unused unused parameter
  45762. * @param texture The texture to apply
  45763. * @param name The name of the uniform in the effect
  45764. */
  45765. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45766. /**
  45767. * Sets an array of texture to the WebGPU context
  45768. * @param channel defines the channel where the texture array must be set
  45769. * @param unused unused parameter
  45770. * @param textures defines the array of textures to bind
  45771. * @param name name of the channel
  45772. */
  45773. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45774. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45775. /** @hidden */
  45776. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45777. /** @hidden */
  45778. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45779. private _generateMipmaps;
  45780. /**
  45781. * Update the content of a texture
  45782. * @param texture defines the texture to update
  45783. * @param canvas defines the source containing the data
  45784. * @param invertY defines if data must be stored with Y axis inverted
  45785. * @param premulAlpha defines if alpha is stored as premultiplied
  45786. * @param format defines the format of the data
  45787. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45788. */
  45789. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45790. /**
  45791. * Update a portion of an internal texture
  45792. * @param texture defines the texture to update
  45793. * @param imageData defines the data to store into the texture
  45794. * @param xOffset defines the x coordinates of the update rectangle
  45795. * @param yOffset defines the y coordinates of the update rectangle
  45796. * @param width defines the width of the update rectangle
  45797. * @param height defines the height of the update rectangle
  45798. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45799. * @param lod defines the lod level to update (0 by default)
  45800. */
  45801. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45802. /**
  45803. * Update a video texture
  45804. * @param texture defines the texture to update
  45805. * @param video defines the video element to use
  45806. * @param invertY defines if data must be stored with Y axis inverted
  45807. */
  45808. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45809. /** @hidden */
  45810. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45811. /** @hidden */
  45812. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45813. /** @hidden */
  45814. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45815. /** @hidden */
  45816. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45817. /**
  45818. * Update a raw texture
  45819. * @param texture defines the texture to update
  45820. * @param bufferView defines the data to store in the texture
  45821. * @param format defines the format of the data
  45822. * @param invertY defines if data must be stored with Y axis inverted
  45823. * @param compression defines the compression used (null by default)
  45824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45825. */
  45826. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45827. /**
  45828. * Update a raw cube texture
  45829. * @param texture defines the texture to update
  45830. * @param bufferView defines the data to store
  45831. * @param format defines the data format
  45832. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45833. * @param invertY defines if data must be stored with Y axis inverted
  45834. * @param compression defines the compression used (null by default)
  45835. * @param level defines which level of the texture to update
  45836. */
  45837. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45838. /**
  45839. * Update a raw 2D array texture
  45840. * @param texture defines the texture to update
  45841. * @param bufferView defines the data to store
  45842. * @param format defines the data format
  45843. * @param invertY defines if data must be stored with Y axis inverted
  45844. * @param compression defines the used compression (can be null)
  45845. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45846. */
  45847. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45848. /**
  45849. * Update a raw 3D texture
  45850. * @param texture defines the texture to update
  45851. * @param bufferView defines the data to store
  45852. * @param format defines the data format
  45853. * @param invertY defines if data must be stored with Y axis inverted
  45854. * @param compression defines the used compression (can be null)
  45855. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45856. */
  45857. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45858. /**
  45859. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45860. * @param x defines the x coordinate of the rectangle where pixels must be read
  45861. * @param y defines the y coordinate of the rectangle where pixels must be read
  45862. * @param width defines the width of the rectangle where pixels must be read
  45863. * @param height defines the height of the rectangle where pixels must be read
  45864. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45865. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45866. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45867. */
  45868. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45869. /** @hidden */
  45870. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45871. /** @hidden */
  45872. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45873. /**
  45874. * Creates a new render target texture
  45875. * @param size defines the size of the texture
  45876. * @param options defines the options used to create the texture
  45877. * @returns a new render target texture stored in an InternalTexture
  45878. */
  45879. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45880. /**
  45881. * Create a multi render target texture
  45882. * @param size defines the size of the texture
  45883. * @param options defines the creation options
  45884. * @returns the cube texture as an InternalTexture
  45885. */
  45886. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45887. /**
  45888. * Creates a new render target cube texture
  45889. * @param size defines the size of the texture
  45890. * @param options defines the options used to create the texture
  45891. * @returns a new render target cube texture stored in an InternalTexture
  45892. */
  45893. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45894. /** @hidden */
  45895. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45896. width: number;
  45897. height: number;
  45898. layers?: number;
  45899. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45900. /** @hidden */
  45901. _createDepthStencilTexture(size: number | {
  45902. width: number;
  45903. height: number;
  45904. layers?: number;
  45905. }, options: DepthTextureCreationOptions): InternalTexture;
  45906. /** @hidden */
  45907. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45908. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45909. /**
  45910. * Update the sample count for a given multiple render target texture
  45911. * @param textures defines the textures to update
  45912. * @param samples defines the sample count to set
  45913. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45914. */
  45915. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45916. /**
  45917. * Begin a new frame
  45918. */
  45919. beginFrame(): void;
  45920. /**
  45921. * End the current frame
  45922. */
  45923. endFrame(): void;
  45924. /**
  45925. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45926. */
  45927. flushFramebuffer(): void;
  45928. private _startRenderTargetRenderPass;
  45929. private _endRenderTargetRenderPass;
  45930. private _getCurrentRenderPass;
  45931. private _startMainRenderPass;
  45932. private _endMainRenderPass;
  45933. /**
  45934. * Restores the WebGPU state to only draw on the main color attachment
  45935. */
  45936. restoreSingleAttachment(): void;
  45937. /**
  45938. * Creates a layout object to draw/clear on specific textures in a MRT
  45939. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45940. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45941. */
  45942. buildTextureLayout(textureStatus: boolean[]): number[];
  45943. /**
  45944. * Select a subsets of attachments to draw to.
  45945. * @param attachments index of attachments
  45946. */
  45947. bindAttachments(attachments: number[]): void;
  45948. /**
  45949. * Binds the frame buffer to the specified texture.
  45950. * @param texture The texture to render to or null for the default canvas
  45951. * @param faceIndex The face of the texture to render to in case of cube texture
  45952. * @param requiredWidth The width of the target to render to
  45953. * @param requiredHeight The height of the target to render to
  45954. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45955. * @param lodLevel defines the lod level to bind to the frame buffer
  45956. * @param layer defines the 2d array index to bind to frame buffer to
  45957. */
  45958. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45959. /**
  45960. * Unbind the current render target texture from the WebGPU context
  45961. * @param texture defines the render target texture to unbind
  45962. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45963. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45964. */
  45965. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45966. /**
  45967. * Unbind a list of render target textures from the WebGPU context
  45968. * @param textures defines the render target textures to unbind
  45969. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45970. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45971. */
  45972. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45973. /**
  45974. * Unbind the current render target and bind the default framebuffer
  45975. */
  45976. restoreDefaultFramebuffer(): void;
  45977. private _setColorFormat;
  45978. private _setDepthTextureFormat;
  45979. setDitheringState(value: boolean): void;
  45980. setRasterizerState(value: boolean): void;
  45981. /**
  45982. * Set various states to the context
  45983. * @param culling defines backface culling state
  45984. * @param zOffset defines the value to apply to zOffset (0 by default)
  45985. * @param force defines if states must be applied even if cache is up to date
  45986. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45987. */
  45988. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45989. /**
  45990. * Sets the current alpha mode
  45991. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45992. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45993. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45994. */
  45995. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45996. /**
  45997. * Sets the current alpha equation
  45998. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45999. */
  46000. setAlphaEquation(equation: number): void;
  46001. private _getBindGroupsToRender;
  46002. private _bindVertexInputs;
  46003. private _setRenderBindGroups;
  46004. private _setRenderPipeline;
  46005. /**
  46006. * Draw a list of indexed primitives
  46007. * @param fillMode defines the primitive to use
  46008. * @param indexStart defines the starting index
  46009. * @param indexCount defines the number of index to draw
  46010. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46011. */
  46012. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46013. /**
  46014. * Draw a list of unindexed primitives
  46015. * @param fillMode defines the primitive to use
  46016. * @param verticesStart defines the index of first vertex to draw
  46017. * @param verticesCount defines the count of vertices to draw
  46018. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46019. */
  46020. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46021. private _bundleEncoder;
  46022. /**
  46023. * Start recording all the gpu calls into a bundle.
  46024. */
  46025. startRecordBundle(): void;
  46026. /**
  46027. * Stops recording the bundle.
  46028. * @returns the recorded bundle
  46029. */
  46030. stopRecordBundle(): GPURenderBundle;
  46031. /**
  46032. * Execute the previously recorded bundle.
  46033. * @param bundles defines the bundle to replay
  46034. */
  46035. executeBundles(bundles: GPURenderBundle[]): void;
  46036. /**
  46037. * Dispose and release all associated resources
  46038. */
  46039. dispose(): void;
  46040. /**
  46041. * Gets the current render width
  46042. * @param useScreen defines if screen size must be used (or the current render target if any)
  46043. * @returns a number defining the current render width
  46044. */
  46045. getRenderWidth(useScreen?: boolean): number;
  46046. /**
  46047. * Gets the current render height
  46048. * @param useScreen defines if screen size must be used (or the current render target if any)
  46049. * @returns a number defining the current render height
  46050. */
  46051. getRenderHeight(useScreen?: boolean): number;
  46052. /**
  46053. * Gets the HTML canvas attached with the current WebGPU context
  46054. * @returns a HTML canvas
  46055. */
  46056. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46057. /** @hidden */
  46058. _debugPushGroup(groupName: string, targetObject?: number): void;
  46059. /** @hidden */
  46060. _debugPopGroup(targetObject?: number): void;
  46061. /** @hidden */
  46062. _debugInsertMarker(text: string, targetObject?: number): void;
  46063. private _debugFlushPendingCommands;
  46064. /**
  46065. * Get the current error code of the WebGPU context
  46066. * @returns the error code
  46067. */
  46068. getError(): number;
  46069. /** @hidden */
  46070. bindSamplers(effect: Effect): void;
  46071. /** @hidden */
  46072. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46073. /** @hidden */
  46074. _releaseFramebufferObjects(texture: InternalTexture): void;
  46075. /** @hidden */
  46076. applyStates(): void;
  46077. /**
  46078. * Gets a boolean indicating if all created effects are ready
  46079. * @returns always true - No parallel shader compilation
  46080. */
  46081. areAllEffectsReady(): boolean;
  46082. /** @hidden */
  46083. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46084. /** @hidden */
  46085. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46086. /** @hidden */
  46087. _getUnpackAlignement(): number;
  46088. /** @hidden */
  46089. _unpackFlipY(value: boolean): void;
  46090. /** @hidden */
  46091. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46092. min: number;
  46093. mag: number;
  46094. };
  46095. /** @hidden */
  46096. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46097. /** @hidden */
  46098. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46099. /** @hidden */
  46100. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46101. /** @hidden */
  46102. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46103. /** @hidden */
  46104. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46105. /** @hidden */
  46106. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46107. /** @hidden */
  46108. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46109. /** @hidden */
  46110. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46111. /** @hidden */
  46112. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46113. /** @hidden */
  46114. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46115. /** @hidden */
  46116. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46117. /** @hidden */
  46118. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46119. /** @hidden */
  46120. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46121. /** @hidden */
  46122. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46123. /** @hidden */
  46124. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46125. /** @hidden */
  46126. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46127. /** @hidden */
  46128. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46129. }
  46130. }
  46131. declare module BABYLON {
  46132. /**
  46133. * Define an interface for all classes that will hold resources
  46134. */
  46135. export interface IDisposable {
  46136. /**
  46137. * Releases all held resources
  46138. */
  46139. dispose(): void;
  46140. }
  46141. /** Interface defining initialization parameters for Scene class */
  46142. export interface SceneOptions {
  46143. /**
  46144. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46145. * It will improve performance when the number of geometries becomes important.
  46146. */
  46147. useGeometryUniqueIdsMap?: boolean;
  46148. /**
  46149. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46150. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46151. */
  46152. useMaterialMeshMap?: boolean;
  46153. /**
  46154. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46155. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46156. */
  46157. useClonedMeshMap?: boolean;
  46158. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46159. virtual?: boolean;
  46160. }
  46161. /**
  46162. * Represents a scene to be rendered by the engine.
  46163. * @see https://doc.babylonjs.com/features/scene
  46164. */
  46165. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46166. /** The fog is deactivated */
  46167. static readonly FOGMODE_NONE: number;
  46168. /** The fog density is following an exponential function */
  46169. static readonly FOGMODE_EXP: number;
  46170. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46171. static readonly FOGMODE_EXP2: number;
  46172. /** The fog density is following a linear function. */
  46173. static readonly FOGMODE_LINEAR: number;
  46174. /**
  46175. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46176. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46177. */
  46178. static MinDeltaTime: number;
  46179. /**
  46180. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46182. */
  46183. static MaxDeltaTime: number;
  46184. /**
  46185. * Factory used to create the default material.
  46186. * @param name The name of the material to create
  46187. * @param scene The scene to create the material for
  46188. * @returns The default material
  46189. */
  46190. static DefaultMaterialFactory(scene: Scene): Material;
  46191. /**
  46192. * Factory used to create the a collision coordinator.
  46193. * @returns The collision coordinator
  46194. */
  46195. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46196. /** @hidden */
  46197. _inputManager: InputManager;
  46198. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46199. cameraToUseForPointers: Nullable<Camera>;
  46200. /** @hidden */
  46201. readonly _isScene: boolean;
  46202. /** @hidden */
  46203. _blockEntityCollection: boolean;
  46204. /**
  46205. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46206. */
  46207. autoClear: boolean;
  46208. /**
  46209. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46210. */
  46211. autoClearDepthAndStencil: boolean;
  46212. /**
  46213. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46214. */
  46215. clearColor: Color4;
  46216. /**
  46217. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46218. */
  46219. ambientColor: Color3;
  46220. /**
  46221. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46222. * It should only be one of the following (if not the default embedded one):
  46223. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46224. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46225. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46226. * The material properties need to be setup according to the type of texture in use.
  46227. */
  46228. environmentBRDFTexture: BaseTexture;
  46229. /**
  46230. * Texture used in all pbr material as the reflection texture.
  46231. * As in the majority of the scene they are the same (exception for multi room and so on),
  46232. * this is easier to reference from here than from all the materials.
  46233. */
  46234. get environmentTexture(): Nullable<BaseTexture>;
  46235. /**
  46236. * Texture used in all pbr material as the reflection texture.
  46237. * As in the majority of the scene they are the same (exception for multi room and so on),
  46238. * this is easier to set here than in all the materials.
  46239. */
  46240. set environmentTexture(value: Nullable<BaseTexture>);
  46241. /** @hidden */
  46242. protected _environmentIntensity: number;
  46243. /**
  46244. * Intensity of the environment in all pbr material.
  46245. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46246. * As in the majority of the scene they are the same (exception for multi room and so on),
  46247. * this is easier to reference from here than from all the materials.
  46248. */
  46249. get environmentIntensity(): number;
  46250. /**
  46251. * Intensity of the environment in all pbr material.
  46252. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46253. * As in the majority of the scene they are the same (exception for multi room and so on),
  46254. * this is easier to set here than in all the materials.
  46255. */
  46256. set environmentIntensity(value: number);
  46257. /** @hidden */
  46258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46259. /**
  46260. * Default image processing configuration used either in the rendering
  46261. * Forward main pass or through the imageProcessingPostProcess if present.
  46262. * As in the majority of the scene they are the same (exception for multi camera),
  46263. * this is easier to reference from here than from all the materials and post process.
  46264. *
  46265. * No setter as we it is a shared configuration, you can set the values instead.
  46266. */
  46267. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46268. private _forceWireframe;
  46269. /**
  46270. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46271. */
  46272. set forceWireframe(value: boolean);
  46273. get forceWireframe(): boolean;
  46274. private _skipFrustumClipping;
  46275. /**
  46276. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46277. */
  46278. set skipFrustumClipping(value: boolean);
  46279. get skipFrustumClipping(): boolean;
  46280. private _forcePointsCloud;
  46281. /**
  46282. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46283. */
  46284. set forcePointsCloud(value: boolean);
  46285. get forcePointsCloud(): boolean;
  46286. /**
  46287. * Gets or sets the active clipplane 1
  46288. */
  46289. clipPlane: Nullable<Plane>;
  46290. /**
  46291. * Gets or sets the active clipplane 2
  46292. */
  46293. clipPlane2: Nullable<Plane>;
  46294. /**
  46295. * Gets or sets the active clipplane 3
  46296. */
  46297. clipPlane3: Nullable<Plane>;
  46298. /**
  46299. * Gets or sets the active clipplane 4
  46300. */
  46301. clipPlane4: Nullable<Plane>;
  46302. /**
  46303. * Gets or sets the active clipplane 5
  46304. */
  46305. clipPlane5: Nullable<Plane>;
  46306. /**
  46307. * Gets or sets the active clipplane 6
  46308. */
  46309. clipPlane6: Nullable<Plane>;
  46310. /**
  46311. * Gets or sets a boolean indicating if animations are enabled
  46312. */
  46313. animationsEnabled: boolean;
  46314. private _animationPropertiesOverride;
  46315. /**
  46316. * Gets or sets the animation properties override
  46317. */
  46318. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46319. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46320. /**
  46321. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46322. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46323. */
  46324. useConstantAnimationDeltaTime: boolean;
  46325. /**
  46326. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46327. * Please note that it requires to run a ray cast through the scene on every frame
  46328. */
  46329. constantlyUpdateMeshUnderPointer: boolean;
  46330. /**
  46331. * Defines the HTML cursor to use when hovering over interactive elements
  46332. */
  46333. hoverCursor: string;
  46334. /**
  46335. * Defines the HTML default cursor to use (empty by default)
  46336. */
  46337. defaultCursor: string;
  46338. /**
  46339. * Defines whether cursors are handled by the scene.
  46340. */
  46341. doNotHandleCursors: boolean;
  46342. /**
  46343. * This is used to call preventDefault() on pointer down
  46344. * in order to block unwanted artifacts like system double clicks
  46345. */
  46346. preventDefaultOnPointerDown: boolean;
  46347. /**
  46348. * This is used to call preventDefault() on pointer up
  46349. * in order to block unwanted artifacts like system double clicks
  46350. */
  46351. preventDefaultOnPointerUp: boolean;
  46352. /**
  46353. * Gets or sets user defined metadata
  46354. */
  46355. metadata: any;
  46356. /**
  46357. * For internal use only. Please do not use.
  46358. */
  46359. reservedDataStore: any;
  46360. /**
  46361. * Gets the name of the plugin used to load this scene (null by default)
  46362. */
  46363. loadingPluginName: string;
  46364. /**
  46365. * Use this array to add regular expressions used to disable offline support for specific urls
  46366. */
  46367. disableOfflineSupportExceptionRules: RegExp[];
  46368. /**
  46369. * An event triggered when the scene is disposed.
  46370. */
  46371. onDisposeObservable: Observable<Scene>;
  46372. private _onDisposeObserver;
  46373. /** Sets a function to be executed when this scene is disposed. */
  46374. set onDispose(callback: () => void);
  46375. /**
  46376. * An event triggered before rendering the scene (right after animations and physics)
  46377. */
  46378. onBeforeRenderObservable: Observable<Scene>;
  46379. private _onBeforeRenderObserver;
  46380. /** Sets a function to be executed before rendering this scene */
  46381. set beforeRender(callback: Nullable<() => void>);
  46382. /**
  46383. * An event triggered after rendering the scene
  46384. */
  46385. onAfterRenderObservable: Observable<Scene>;
  46386. /**
  46387. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46388. */
  46389. onAfterRenderCameraObservable: Observable<Camera>;
  46390. private _onAfterRenderObserver;
  46391. /** Sets a function to be executed after rendering this scene */
  46392. set afterRender(callback: Nullable<() => void>);
  46393. /**
  46394. * An event triggered before animating the scene
  46395. */
  46396. onBeforeAnimationsObservable: Observable<Scene>;
  46397. /**
  46398. * An event triggered after animations processing
  46399. */
  46400. onAfterAnimationsObservable: Observable<Scene>;
  46401. /**
  46402. * An event triggered before draw calls are ready to be sent
  46403. */
  46404. onBeforeDrawPhaseObservable: Observable<Scene>;
  46405. /**
  46406. * An event triggered after draw calls have been sent
  46407. */
  46408. onAfterDrawPhaseObservable: Observable<Scene>;
  46409. /**
  46410. * An event triggered when the scene is ready
  46411. */
  46412. onReadyObservable: Observable<Scene>;
  46413. /**
  46414. * An event triggered before rendering a camera
  46415. */
  46416. onBeforeCameraRenderObservable: Observable<Camera>;
  46417. private _onBeforeCameraRenderObserver;
  46418. /** Sets a function to be executed before rendering a camera*/
  46419. set beforeCameraRender(callback: () => void);
  46420. /**
  46421. * An event triggered after rendering a camera
  46422. */
  46423. onAfterCameraRenderObservable: Observable<Camera>;
  46424. private _onAfterCameraRenderObserver;
  46425. /** Sets a function to be executed after rendering a camera*/
  46426. set afterCameraRender(callback: () => void);
  46427. /**
  46428. * An event triggered when active meshes evaluation is about to start
  46429. */
  46430. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46431. /**
  46432. * An event triggered when active meshes evaluation is done
  46433. */
  46434. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46435. /**
  46436. * An event triggered when particles rendering is about to start
  46437. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46438. */
  46439. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46440. /**
  46441. * An event triggered when particles rendering is done
  46442. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46443. */
  46444. onAfterParticlesRenderingObservable: Observable<Scene>;
  46445. /**
  46446. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46447. */
  46448. onDataLoadedObservable: Observable<Scene>;
  46449. /**
  46450. * An event triggered when a camera is created
  46451. */
  46452. onNewCameraAddedObservable: Observable<Camera>;
  46453. /**
  46454. * An event triggered when a camera is removed
  46455. */
  46456. onCameraRemovedObservable: Observable<Camera>;
  46457. /**
  46458. * An event triggered when a light is created
  46459. */
  46460. onNewLightAddedObservable: Observable<Light>;
  46461. /**
  46462. * An event triggered when a light is removed
  46463. */
  46464. onLightRemovedObservable: Observable<Light>;
  46465. /**
  46466. * An event triggered when a geometry is created
  46467. */
  46468. onNewGeometryAddedObservable: Observable<Geometry>;
  46469. /**
  46470. * An event triggered when a geometry is removed
  46471. */
  46472. onGeometryRemovedObservable: Observable<Geometry>;
  46473. /**
  46474. * An event triggered when a transform node is created
  46475. */
  46476. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46477. /**
  46478. * An event triggered when a transform node is removed
  46479. */
  46480. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46481. /**
  46482. * An event triggered when a mesh is created
  46483. */
  46484. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46485. /**
  46486. * An event triggered when a mesh is removed
  46487. */
  46488. onMeshRemovedObservable: Observable<AbstractMesh>;
  46489. /**
  46490. * An event triggered when a skeleton is created
  46491. */
  46492. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46493. /**
  46494. * An event triggered when a skeleton is removed
  46495. */
  46496. onSkeletonRemovedObservable: Observable<Skeleton>;
  46497. /**
  46498. * An event triggered when a material is created
  46499. */
  46500. onNewMaterialAddedObservable: Observable<Material>;
  46501. /**
  46502. * An event triggered when a multi material is created
  46503. */
  46504. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46505. /**
  46506. * An event triggered when a material is removed
  46507. */
  46508. onMaterialRemovedObservable: Observable<Material>;
  46509. /**
  46510. * An event triggered when a multi material is removed
  46511. */
  46512. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46513. /**
  46514. * An event triggered when a texture is created
  46515. */
  46516. onNewTextureAddedObservable: Observable<BaseTexture>;
  46517. /**
  46518. * An event triggered when a texture is removed
  46519. */
  46520. onTextureRemovedObservable: Observable<BaseTexture>;
  46521. /**
  46522. * An event triggered when render targets are about to be rendered
  46523. * Can happen multiple times per frame.
  46524. */
  46525. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46526. /**
  46527. * An event triggered when render targets were rendered.
  46528. * Can happen multiple times per frame.
  46529. */
  46530. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46531. /**
  46532. * An event triggered before calculating deterministic simulation step
  46533. */
  46534. onBeforeStepObservable: Observable<Scene>;
  46535. /**
  46536. * An event triggered after calculating deterministic simulation step
  46537. */
  46538. onAfterStepObservable: Observable<Scene>;
  46539. /**
  46540. * An event triggered when the activeCamera property is updated
  46541. */
  46542. onActiveCameraChanged: Observable<Scene>;
  46543. /**
  46544. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46545. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46546. * 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)
  46547. */
  46548. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46549. /**
  46550. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46551. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46552. * 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)
  46553. */
  46554. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46555. /**
  46556. * This Observable will when a mesh has been imported into the scene.
  46557. */
  46558. onMeshImportedObservable: Observable<AbstractMesh>;
  46559. /**
  46560. * This Observable will when an animation file has been imported into the scene.
  46561. */
  46562. onAnimationFileImportedObservable: Observable<Scene>;
  46563. /**
  46564. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46565. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46566. */
  46567. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46568. /** @hidden */
  46569. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46570. /**
  46571. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46572. */
  46573. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46574. /**
  46575. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46576. */
  46577. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46578. /**
  46579. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46580. */
  46581. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46582. /** Callback called when a pointer move is detected */
  46583. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46584. /** Callback called when a pointer down is detected */
  46585. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46586. /** Callback called when a pointer up is detected */
  46587. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46588. /** Callback called when a pointer pick is detected */
  46589. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46590. /**
  46591. * 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).
  46592. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46593. */
  46594. onPrePointerObservable: Observable<PointerInfoPre>;
  46595. /**
  46596. * Observable event triggered each time an input event is received from the rendering canvas
  46597. */
  46598. onPointerObservable: Observable<PointerInfo>;
  46599. /**
  46600. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46601. */
  46602. get unTranslatedPointer(): Vector2;
  46603. /**
  46604. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46605. */
  46606. static get DragMovementThreshold(): number;
  46607. static set DragMovementThreshold(value: number);
  46608. /**
  46609. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46610. */
  46611. static get LongPressDelay(): number;
  46612. static set LongPressDelay(value: number);
  46613. /**
  46614. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46615. */
  46616. static get DoubleClickDelay(): number;
  46617. static set DoubleClickDelay(value: number);
  46618. /** If you need to check double click without raising a single click at first click, enable this flag */
  46619. static get ExclusiveDoubleClickMode(): boolean;
  46620. static set ExclusiveDoubleClickMode(value: boolean);
  46621. /** @hidden */
  46622. _mirroredCameraPosition: Nullable<Vector3>;
  46623. /**
  46624. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46625. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46626. */
  46627. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46628. /**
  46629. * Observable event triggered each time an keyboard event is received from the hosting window
  46630. */
  46631. onKeyboardObservable: Observable<KeyboardInfo>;
  46632. private _useRightHandedSystem;
  46633. /**
  46634. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46635. */
  46636. set useRightHandedSystem(value: boolean);
  46637. get useRightHandedSystem(): boolean;
  46638. private _timeAccumulator;
  46639. private _currentStepId;
  46640. private _currentInternalStep;
  46641. /**
  46642. * Sets the step Id used by deterministic lock step
  46643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46644. * @param newStepId defines the step Id
  46645. */
  46646. setStepId(newStepId: number): void;
  46647. /**
  46648. * Gets the step Id used by deterministic lock step
  46649. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46650. * @returns the step Id
  46651. */
  46652. getStepId(): number;
  46653. /**
  46654. * Gets the internal step used by deterministic lock step
  46655. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46656. * @returns the internal step
  46657. */
  46658. getInternalStep(): number;
  46659. private _fogEnabled;
  46660. /**
  46661. * Gets or sets a boolean indicating if fog is enabled on this scene
  46662. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46663. * (Default is true)
  46664. */
  46665. set fogEnabled(value: boolean);
  46666. get fogEnabled(): boolean;
  46667. private _fogMode;
  46668. /**
  46669. * Gets or sets the fog mode to use
  46670. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46671. * | mode | value |
  46672. * | --- | --- |
  46673. * | FOGMODE_NONE | 0 |
  46674. * | FOGMODE_EXP | 1 |
  46675. * | FOGMODE_EXP2 | 2 |
  46676. * | FOGMODE_LINEAR | 3 |
  46677. */
  46678. set fogMode(value: number);
  46679. get fogMode(): number;
  46680. /**
  46681. * Gets or sets the fog color to use
  46682. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46683. * (Default is Color3(0.2, 0.2, 0.3))
  46684. */
  46685. fogColor: Color3;
  46686. /**
  46687. * Gets or sets the fog density to use
  46688. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46689. * (Default is 0.1)
  46690. */
  46691. fogDensity: number;
  46692. /**
  46693. * Gets or sets the fog start distance to use
  46694. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46695. * (Default is 0)
  46696. */
  46697. fogStart: number;
  46698. /**
  46699. * Gets or sets the fog end distance to use
  46700. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46701. * (Default is 1000)
  46702. */
  46703. fogEnd: number;
  46704. /**
  46705. * Flag indicating that the frame buffer binding is handled by another component
  46706. */
  46707. get prePass(): boolean;
  46708. private _shadowsEnabled;
  46709. /**
  46710. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46711. */
  46712. set shadowsEnabled(value: boolean);
  46713. get shadowsEnabled(): boolean;
  46714. private _lightsEnabled;
  46715. /**
  46716. * Gets or sets a boolean indicating if lights are enabled on this scene
  46717. */
  46718. set lightsEnabled(value: boolean);
  46719. get lightsEnabled(): boolean;
  46720. /** All of the active cameras added to this scene. */
  46721. activeCameras: Nullable<Camera[]>;
  46722. /** @hidden */
  46723. _activeCamera: Nullable<Camera>;
  46724. /** Gets or sets the current active camera */
  46725. get activeCamera(): Nullable<Camera>;
  46726. set activeCamera(value: Nullable<Camera>);
  46727. private _defaultMaterial;
  46728. /** The default material used on meshes when no material is affected */
  46729. get defaultMaterial(): Material;
  46730. /** The default material used on meshes when no material is affected */
  46731. set defaultMaterial(value: Material);
  46732. private _texturesEnabled;
  46733. /**
  46734. * Gets or sets a boolean indicating if textures are enabled on this scene
  46735. */
  46736. set texturesEnabled(value: boolean);
  46737. get texturesEnabled(): boolean;
  46738. /**
  46739. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46740. */
  46741. physicsEnabled: boolean;
  46742. /**
  46743. * Gets or sets a boolean indicating if particles are enabled on this scene
  46744. */
  46745. particlesEnabled: boolean;
  46746. /**
  46747. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46748. */
  46749. spritesEnabled: boolean;
  46750. private _skeletonsEnabled;
  46751. /**
  46752. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46753. */
  46754. set skeletonsEnabled(value: boolean);
  46755. get skeletonsEnabled(): boolean;
  46756. /**
  46757. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46758. */
  46759. lensFlaresEnabled: boolean;
  46760. /**
  46761. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46762. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46763. */
  46764. collisionsEnabled: boolean;
  46765. private _collisionCoordinator;
  46766. /** @hidden */
  46767. get collisionCoordinator(): ICollisionCoordinator;
  46768. /**
  46769. * Defines the gravity applied to this scene (used only for collisions)
  46770. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46771. */
  46772. gravity: Vector3;
  46773. /**
  46774. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46775. */
  46776. postProcessesEnabled: boolean;
  46777. /**
  46778. * Gets the current postprocess manager
  46779. */
  46780. postProcessManager: PostProcessManager;
  46781. /**
  46782. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46783. */
  46784. renderTargetsEnabled: boolean;
  46785. /**
  46786. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46787. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46788. */
  46789. dumpNextRenderTargets: boolean;
  46790. /**
  46791. * The list of user defined render targets added to the scene
  46792. */
  46793. customRenderTargets: RenderTargetTexture[];
  46794. /**
  46795. * Defines if texture loading must be delayed
  46796. * If true, textures will only be loaded when they need to be rendered
  46797. */
  46798. useDelayedTextureLoading: boolean;
  46799. /**
  46800. * Gets the list of meshes imported to the scene through SceneLoader
  46801. */
  46802. importedMeshesFiles: String[];
  46803. /**
  46804. * Gets or sets a boolean indicating if probes are enabled on this scene
  46805. */
  46806. probesEnabled: boolean;
  46807. /**
  46808. * Gets or sets the current offline provider to use to store scene data
  46809. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46810. */
  46811. offlineProvider: IOfflineProvider;
  46812. /**
  46813. * Gets or sets the action manager associated with the scene
  46814. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46815. */
  46816. actionManager: AbstractActionManager;
  46817. private _meshesForIntersections;
  46818. /**
  46819. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46820. */
  46821. proceduralTexturesEnabled: boolean;
  46822. private _engine;
  46823. private _totalVertices;
  46824. /** @hidden */
  46825. _activeIndices: PerfCounter;
  46826. /** @hidden */
  46827. _activeParticles: PerfCounter;
  46828. /** @hidden */
  46829. _activeBones: PerfCounter;
  46830. private _animationRatio;
  46831. /** @hidden */
  46832. _animationTimeLast: number;
  46833. /** @hidden */
  46834. _animationTime: number;
  46835. /**
  46836. * Gets or sets a general scale for animation speed
  46837. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46838. */
  46839. animationTimeScale: number;
  46840. /** @hidden */
  46841. _cachedMaterial: Nullable<Material>;
  46842. /** @hidden */
  46843. _cachedEffect: Nullable<Effect>;
  46844. /** @hidden */
  46845. _cachedVisibility: Nullable<number>;
  46846. private _renderId;
  46847. private _frameId;
  46848. private _executeWhenReadyTimeoutId;
  46849. private _intermediateRendering;
  46850. private _viewUpdateFlag;
  46851. private _projectionUpdateFlag;
  46852. /** @hidden */
  46853. _toBeDisposed: Nullable<IDisposable>[];
  46854. private _activeRequests;
  46855. /** @hidden */
  46856. _pendingData: any[];
  46857. private _isDisposed;
  46858. /**
  46859. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46860. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46861. */
  46862. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46863. private _activeMeshes;
  46864. private _processedMaterials;
  46865. private _renderTargets;
  46866. /** @hidden */
  46867. _activeParticleSystems: SmartArray<IParticleSystem>;
  46868. private _activeSkeletons;
  46869. private _softwareSkinnedMeshes;
  46870. private _renderingManager;
  46871. /** @hidden */
  46872. _activeAnimatables: Animatable[];
  46873. private _transformMatrix;
  46874. private _sceneUbo;
  46875. /** @hidden */
  46876. _viewMatrix: Matrix;
  46877. /** @hidden */
  46878. _projectionMatrix: Matrix;
  46879. /** @hidden */
  46880. _forcedViewPosition: Nullable<Vector3>;
  46881. /** @hidden */
  46882. _frustumPlanes: Plane[];
  46883. /**
  46884. * Gets the list of frustum planes (built from the active camera)
  46885. */
  46886. get frustumPlanes(): Plane[];
  46887. /**
  46888. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46889. * This is useful if there are more lights that the maximum simulteanous authorized
  46890. */
  46891. requireLightSorting: boolean;
  46892. /** @hidden */
  46893. readonly useMaterialMeshMap: boolean;
  46894. /** @hidden */
  46895. readonly useClonedMeshMap: boolean;
  46896. private _externalData;
  46897. private _uid;
  46898. /**
  46899. * @hidden
  46900. * Backing store of defined scene components.
  46901. */
  46902. _components: ISceneComponent[];
  46903. /**
  46904. * @hidden
  46905. * Backing store of defined scene components.
  46906. */
  46907. _serializableComponents: ISceneSerializableComponent[];
  46908. /**
  46909. * List of components to register on the next registration step.
  46910. */
  46911. private _transientComponents;
  46912. /**
  46913. * Registers the transient components if needed.
  46914. */
  46915. private _registerTransientComponents;
  46916. /**
  46917. * @hidden
  46918. * Add a component to the scene.
  46919. * Note that the ccomponent could be registered on th next frame if this is called after
  46920. * the register component stage.
  46921. * @param component Defines the component to add to the scene
  46922. */
  46923. _addComponent(component: ISceneComponent): void;
  46924. /**
  46925. * @hidden
  46926. * Gets a component from the scene.
  46927. * @param name defines the name of the component to retrieve
  46928. * @returns the component or null if not present
  46929. */
  46930. _getComponent(name: string): Nullable<ISceneComponent>;
  46931. /**
  46932. * @hidden
  46933. * Defines the actions happening before camera updates.
  46934. */
  46935. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46936. /**
  46937. * @hidden
  46938. * Defines the actions happening before clear the canvas.
  46939. */
  46940. _beforeClearStage: Stage<SimpleStageAction>;
  46941. /**
  46942. * @hidden
  46943. * Defines the actions happening before clear the canvas.
  46944. */
  46945. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  46946. /**
  46947. * @hidden
  46948. * Defines the actions when collecting render targets for the frame.
  46949. */
  46950. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46951. /**
  46952. * @hidden
  46953. * Defines the actions happening for one camera in the frame.
  46954. */
  46955. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46956. /**
  46957. * @hidden
  46958. * Defines the actions happening during the per mesh ready checks.
  46959. */
  46960. _isReadyForMeshStage: Stage<MeshStageAction>;
  46961. /**
  46962. * @hidden
  46963. * Defines the actions happening before evaluate active mesh checks.
  46964. */
  46965. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46966. /**
  46967. * @hidden
  46968. * Defines the actions happening during the evaluate sub mesh checks.
  46969. */
  46970. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46971. /**
  46972. * @hidden
  46973. * Defines the actions happening during the active mesh stage.
  46974. */
  46975. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46976. /**
  46977. * @hidden
  46978. * Defines the actions happening during the per camera render target step.
  46979. */
  46980. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46981. /**
  46982. * @hidden
  46983. * Defines the actions happening just before the active camera is drawing.
  46984. */
  46985. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46986. /**
  46987. * @hidden
  46988. * Defines the actions happening just before a render target is drawing.
  46989. */
  46990. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46991. /**
  46992. * @hidden
  46993. * Defines the actions happening just before a rendering group is drawing.
  46994. */
  46995. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46996. /**
  46997. * @hidden
  46998. * Defines the actions happening just before a mesh is drawing.
  46999. */
  47000. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47001. /**
  47002. * @hidden
  47003. * Defines the actions happening just after a mesh has been drawn.
  47004. */
  47005. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47006. /**
  47007. * @hidden
  47008. * Defines the actions happening just after a rendering group has been drawn.
  47009. */
  47010. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47011. /**
  47012. * @hidden
  47013. * Defines the actions happening just after the active camera has been drawn.
  47014. */
  47015. _afterCameraDrawStage: Stage<CameraStageAction>;
  47016. /**
  47017. * @hidden
  47018. * Defines the actions happening just after a render target has been drawn.
  47019. */
  47020. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47021. /**
  47022. * @hidden
  47023. * Defines the actions happening just after rendering all cameras and computing intersections.
  47024. */
  47025. _afterRenderStage: Stage<SimpleStageAction>;
  47026. /**
  47027. * @hidden
  47028. * Defines the actions happening when a pointer move event happens.
  47029. */
  47030. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47031. /**
  47032. * @hidden
  47033. * Defines the actions happening when a pointer down event happens.
  47034. */
  47035. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47036. /**
  47037. * @hidden
  47038. * Defines the actions happening when a pointer up event happens.
  47039. */
  47040. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47041. /**
  47042. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47043. */
  47044. private geometriesByUniqueId;
  47045. private _renderBundles;
  47046. /**
  47047. * Creates a new Scene
  47048. * @param engine defines the engine to use to render this scene
  47049. * @param options defines the scene options
  47050. */
  47051. constructor(engine: Engine, options?: SceneOptions);
  47052. /**
  47053. * Gets a string identifying the name of the class
  47054. * @returns "Scene" string
  47055. */
  47056. getClassName(): string;
  47057. private _defaultMeshCandidates;
  47058. /**
  47059. * @hidden
  47060. */
  47061. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47062. private _defaultSubMeshCandidates;
  47063. /**
  47064. * @hidden
  47065. */
  47066. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47067. /**
  47068. * Sets the default candidate providers for the scene.
  47069. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47070. * and getCollidingSubMeshCandidates to their default function
  47071. */
  47072. setDefaultCandidateProviders(): void;
  47073. /**
  47074. * Gets the mesh that is currently under the pointer
  47075. */
  47076. get meshUnderPointer(): Nullable<AbstractMesh>;
  47077. /**
  47078. * Gets or sets the current on-screen X position of the pointer
  47079. */
  47080. get pointerX(): number;
  47081. set pointerX(value: number);
  47082. /**
  47083. * Gets or sets the current on-screen Y position of the pointer
  47084. */
  47085. get pointerY(): number;
  47086. set pointerY(value: number);
  47087. /**
  47088. * Gets the cached material (ie. the latest rendered one)
  47089. * @returns the cached material
  47090. */
  47091. getCachedMaterial(): Nullable<Material>;
  47092. /**
  47093. * Gets the cached effect (ie. the latest rendered one)
  47094. * @returns the cached effect
  47095. */
  47096. getCachedEffect(): Nullable<Effect>;
  47097. /**
  47098. * Gets the cached visibility state (ie. the latest rendered one)
  47099. * @returns the cached visibility state
  47100. */
  47101. getCachedVisibility(): Nullable<number>;
  47102. /**
  47103. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47104. * @param material defines the current material
  47105. * @param effect defines the current effect
  47106. * @param visibility defines the current visibility state
  47107. * @returns true if one parameter is not cached
  47108. */
  47109. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47110. /**
  47111. * Gets the engine associated with the scene
  47112. * @returns an Engine
  47113. */
  47114. getEngine(): Engine;
  47115. /**
  47116. * Gets the total number of vertices rendered per frame
  47117. * @returns the total number of vertices rendered per frame
  47118. */
  47119. getTotalVertices(): number;
  47120. /**
  47121. * Gets the performance counter for total vertices
  47122. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47123. */
  47124. get totalVerticesPerfCounter(): PerfCounter;
  47125. /**
  47126. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47127. * @returns the total number of active indices rendered per frame
  47128. */
  47129. getActiveIndices(): number;
  47130. /**
  47131. * Gets the performance counter for active indices
  47132. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47133. */
  47134. get totalActiveIndicesPerfCounter(): PerfCounter;
  47135. /**
  47136. * Gets the total number of active particles rendered per frame
  47137. * @returns the total number of active particles rendered per frame
  47138. */
  47139. getActiveParticles(): number;
  47140. /**
  47141. * Gets the performance counter for active particles
  47142. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47143. */
  47144. get activeParticlesPerfCounter(): PerfCounter;
  47145. /**
  47146. * Gets the total number of active bones rendered per frame
  47147. * @returns the total number of active bones rendered per frame
  47148. */
  47149. getActiveBones(): number;
  47150. /**
  47151. * Gets the performance counter for active bones
  47152. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47153. */
  47154. get activeBonesPerfCounter(): PerfCounter;
  47155. /**
  47156. * Gets the array of active meshes
  47157. * @returns an array of AbstractMesh
  47158. */
  47159. getActiveMeshes(): SmartArray<AbstractMesh>;
  47160. /**
  47161. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47162. * @returns a number
  47163. */
  47164. getAnimationRatio(): number;
  47165. /**
  47166. * Gets an unique Id for the current render phase
  47167. * @returns a number
  47168. */
  47169. getRenderId(): number;
  47170. /**
  47171. * Gets an unique Id for the current frame
  47172. * @returns a number
  47173. */
  47174. getFrameId(): number;
  47175. /** Call this function if you want to manually increment the render Id*/
  47176. incrementRenderId(): void;
  47177. private _createUbo;
  47178. /**
  47179. * Use this method to simulate a pointer move on a mesh
  47180. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47181. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47182. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47183. * @returns the current scene
  47184. */
  47185. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47186. /**
  47187. * Use this method to simulate a pointer down on a mesh
  47188. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47189. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47190. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47191. * @returns the current scene
  47192. */
  47193. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47194. /**
  47195. * Use this method to simulate a pointer up on a mesh
  47196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47199. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47200. * @returns the current scene
  47201. */
  47202. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47203. /**
  47204. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47205. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47206. * @returns true if the pointer was captured
  47207. */
  47208. isPointerCaptured(pointerId?: number): boolean;
  47209. /**
  47210. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47211. * @param attachUp defines if you want to attach events to pointerup
  47212. * @param attachDown defines if you want to attach events to pointerdown
  47213. * @param attachMove defines if you want to attach events to pointermove
  47214. */
  47215. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47216. /** Detaches all event handlers*/
  47217. detachControl(): void;
  47218. /**
  47219. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47220. * Delay loaded resources are not taking in account
  47221. * @return true if all required resources are ready
  47222. */
  47223. isReady(): boolean;
  47224. /** Resets all cached information relative to material (including effect and visibility) */
  47225. resetCachedMaterial(): void;
  47226. /**
  47227. * Registers a function to be called before every frame render
  47228. * @param func defines the function to register
  47229. */
  47230. registerBeforeRender(func: () => void): void;
  47231. /**
  47232. * Unregisters a function called before every frame render
  47233. * @param func defines the function to unregister
  47234. */
  47235. unregisterBeforeRender(func: () => void): void;
  47236. /**
  47237. * Registers a function to be called after every frame render
  47238. * @param func defines the function to register
  47239. */
  47240. registerAfterRender(func: () => void): void;
  47241. /**
  47242. * Unregisters a function called after every frame render
  47243. * @param func defines the function to unregister
  47244. */
  47245. unregisterAfterRender(func: () => void): void;
  47246. private _executeOnceBeforeRender;
  47247. /**
  47248. * The provided function will run before render once and will be disposed afterwards.
  47249. * A timeout delay can be provided so that the function will be executed in N ms.
  47250. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47251. * @param func The function to be executed.
  47252. * @param timeout optional delay in ms
  47253. */
  47254. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47255. /** @hidden */
  47256. _addPendingData(data: any): void;
  47257. /** @hidden */
  47258. _removePendingData(data: any): void;
  47259. /**
  47260. * Returns the number of items waiting to be loaded
  47261. * @returns the number of items waiting to be loaded
  47262. */
  47263. getWaitingItemsCount(): number;
  47264. /**
  47265. * Returns a boolean indicating if the scene is still loading data
  47266. */
  47267. get isLoading(): boolean;
  47268. /**
  47269. * Registers a function to be executed when the scene is ready
  47270. * @param {Function} func - the function to be executed
  47271. */
  47272. executeWhenReady(func: () => void): void;
  47273. /**
  47274. * Returns a promise that resolves when the scene is ready
  47275. * @returns A promise that resolves when the scene is ready
  47276. */
  47277. whenReadyAsync(): Promise<void>;
  47278. /** @hidden */
  47279. _checkIsReady(): void;
  47280. /**
  47281. * Gets all animatable attached to the scene
  47282. */
  47283. get animatables(): Animatable[];
  47284. /**
  47285. * Resets the last animation time frame.
  47286. * Useful to override when animations start running when loading a scene for the first time.
  47287. */
  47288. resetLastAnimationTimeFrame(): void;
  47289. /**
  47290. * Gets the current view matrix
  47291. * @returns a Matrix
  47292. */
  47293. getViewMatrix(): Matrix;
  47294. /**
  47295. * Gets the current projection matrix
  47296. * @returns a Matrix
  47297. */
  47298. getProjectionMatrix(): Matrix;
  47299. /**
  47300. * Gets the current transform matrix
  47301. * @returns a Matrix made of View * Projection
  47302. */
  47303. getTransformMatrix(): Matrix;
  47304. /**
  47305. * Sets the current transform matrix
  47306. * @param viewL defines the View matrix to use
  47307. * @param projectionL defines the Projection matrix to use
  47308. * @param viewR defines the right View matrix to use (if provided)
  47309. * @param projectionR defines the right Projection matrix to use (if provided)
  47310. */
  47311. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47312. /**
  47313. * Gets the uniform buffer used to store scene data
  47314. * @returns a UniformBuffer
  47315. */
  47316. getSceneUniformBuffer(): UniformBuffer;
  47317. /**
  47318. * Gets an unique (relatively to the current scene) Id
  47319. * @returns an unique number for the scene
  47320. */
  47321. getUniqueId(): number;
  47322. /**
  47323. * Add a mesh to the list of scene's meshes
  47324. * @param newMesh defines the mesh to add
  47325. * @param recursive if all child meshes should also be added to the scene
  47326. */
  47327. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47328. /**
  47329. * Remove a mesh for the list of scene's meshes
  47330. * @param toRemove defines the mesh to remove
  47331. * @param recursive if all child meshes should also be removed from the scene
  47332. * @returns the index where the mesh was in the mesh list
  47333. */
  47334. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47335. /**
  47336. * Add a transform node to the list of scene's transform nodes
  47337. * @param newTransformNode defines the transform node to add
  47338. */
  47339. addTransformNode(newTransformNode: TransformNode): void;
  47340. /**
  47341. * Remove a transform node for the list of scene's transform nodes
  47342. * @param toRemove defines the transform node to remove
  47343. * @returns the index where the transform node was in the transform node list
  47344. */
  47345. removeTransformNode(toRemove: TransformNode): number;
  47346. /**
  47347. * Remove a skeleton for the list of scene's skeletons
  47348. * @param toRemove defines the skeleton to remove
  47349. * @returns the index where the skeleton was in the skeleton list
  47350. */
  47351. removeSkeleton(toRemove: Skeleton): number;
  47352. /**
  47353. * Remove a morph target for the list of scene's morph targets
  47354. * @param toRemove defines the morph target to remove
  47355. * @returns the index where the morph target was in the morph target list
  47356. */
  47357. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47358. /**
  47359. * Remove a light for the list of scene's lights
  47360. * @param toRemove defines the light to remove
  47361. * @returns the index where the light was in the light list
  47362. */
  47363. removeLight(toRemove: Light): number;
  47364. /**
  47365. * Remove a camera for the list of scene's cameras
  47366. * @param toRemove defines the camera to remove
  47367. * @returns the index where the camera was in the camera list
  47368. */
  47369. removeCamera(toRemove: Camera): number;
  47370. /**
  47371. * Remove a particle system for the list of scene's particle systems
  47372. * @param toRemove defines the particle system to remove
  47373. * @returns the index where the particle system was in the particle system list
  47374. */
  47375. removeParticleSystem(toRemove: IParticleSystem): number;
  47376. /**
  47377. * Remove a animation for the list of scene's animations
  47378. * @param toRemove defines the animation to remove
  47379. * @returns the index where the animation was in the animation list
  47380. */
  47381. removeAnimation(toRemove: Animation): number;
  47382. /**
  47383. * Will stop the animation of the given target
  47384. * @param target - the target
  47385. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47386. * @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)
  47387. */
  47388. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47389. /**
  47390. * Removes the given animation group from this scene.
  47391. * @param toRemove The animation group to remove
  47392. * @returns The index of the removed animation group
  47393. */
  47394. removeAnimationGroup(toRemove: AnimationGroup): number;
  47395. /**
  47396. * Removes the given multi-material from this scene.
  47397. * @param toRemove The multi-material to remove
  47398. * @returns The index of the removed multi-material
  47399. */
  47400. removeMultiMaterial(toRemove: MultiMaterial): number;
  47401. /**
  47402. * Removes the given material from this scene.
  47403. * @param toRemove The material to remove
  47404. * @returns The index of the removed material
  47405. */
  47406. removeMaterial(toRemove: Material): number;
  47407. /**
  47408. * Removes the given action manager from this scene.
  47409. * @param toRemove The action manager to remove
  47410. * @returns The index of the removed action manager
  47411. */
  47412. removeActionManager(toRemove: AbstractActionManager): number;
  47413. /**
  47414. * Removes the given texture from this scene.
  47415. * @param toRemove The texture to remove
  47416. * @returns The index of the removed texture
  47417. */
  47418. removeTexture(toRemove: BaseTexture): number;
  47419. /**
  47420. * Adds the given light to this scene
  47421. * @param newLight The light to add
  47422. */
  47423. addLight(newLight: Light): void;
  47424. /**
  47425. * Sorts the list list based on light priorities
  47426. */
  47427. sortLightsByPriority(): void;
  47428. /**
  47429. * Adds the given camera to this scene
  47430. * @param newCamera The camera to add
  47431. */
  47432. addCamera(newCamera: Camera): void;
  47433. /**
  47434. * Adds the given skeleton to this scene
  47435. * @param newSkeleton The skeleton to add
  47436. */
  47437. addSkeleton(newSkeleton: Skeleton): void;
  47438. /**
  47439. * Adds the given particle system to this scene
  47440. * @param newParticleSystem The particle system to add
  47441. */
  47442. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47443. /**
  47444. * Adds the given animation to this scene
  47445. * @param newAnimation The animation to add
  47446. */
  47447. addAnimation(newAnimation: Animation): void;
  47448. /**
  47449. * Adds the given animation group to this scene.
  47450. * @param newAnimationGroup The animation group to add
  47451. */
  47452. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47453. /**
  47454. * Adds the given multi-material to this scene
  47455. * @param newMultiMaterial The multi-material to add
  47456. */
  47457. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47458. /**
  47459. * Adds the given material to this scene
  47460. * @param newMaterial The material to add
  47461. */
  47462. addMaterial(newMaterial: Material): void;
  47463. /**
  47464. * Adds the given morph target to this scene
  47465. * @param newMorphTargetManager The morph target to add
  47466. */
  47467. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47468. /**
  47469. * Adds the given geometry to this scene
  47470. * @param newGeometry The geometry to add
  47471. */
  47472. addGeometry(newGeometry: Geometry): void;
  47473. /**
  47474. * Adds the given action manager to this scene
  47475. * @param newActionManager The action manager to add
  47476. */
  47477. addActionManager(newActionManager: AbstractActionManager): void;
  47478. /**
  47479. * Adds the given texture to this scene.
  47480. * @param newTexture The texture to add
  47481. */
  47482. addTexture(newTexture: BaseTexture): void;
  47483. /**
  47484. * Switch active camera
  47485. * @param newCamera defines the new active camera
  47486. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47487. */
  47488. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47489. /**
  47490. * sets the active camera of the scene using its ID
  47491. * @param id defines the camera's ID
  47492. * @return the new active camera or null if none found.
  47493. */
  47494. setActiveCameraByID(id: string): Nullable<Camera>;
  47495. /**
  47496. * sets the active camera of the scene using its name
  47497. * @param name defines the camera's name
  47498. * @returns the new active camera or null if none found.
  47499. */
  47500. setActiveCameraByName(name: string): Nullable<Camera>;
  47501. /**
  47502. * get an animation group using its name
  47503. * @param name defines the material's name
  47504. * @return the animation group or null if none found.
  47505. */
  47506. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47507. /**
  47508. * Get a material using its unique id
  47509. * @param uniqueId defines the material's unique id
  47510. * @return the material or null if none found.
  47511. */
  47512. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47513. /**
  47514. * get a material using its id
  47515. * @param id defines the material's ID
  47516. * @return the material or null if none found.
  47517. */
  47518. getMaterialByID(id: string): Nullable<Material>;
  47519. /**
  47520. * Gets a the last added material using a given id
  47521. * @param id defines the material's ID
  47522. * @return the last material with the given id or null if none found.
  47523. */
  47524. getLastMaterialByID(id: string): Nullable<Material>;
  47525. /**
  47526. * Gets a material using its name
  47527. * @param name defines the material's name
  47528. * @return the material or null if none found.
  47529. */
  47530. getMaterialByName(name: string): Nullable<Material>;
  47531. /**
  47532. * Get a texture using its unique id
  47533. * @param uniqueId defines the texture's unique id
  47534. * @return the texture or null if none found.
  47535. */
  47536. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47537. /**
  47538. * Gets a camera using its id
  47539. * @param id defines the id to look for
  47540. * @returns the camera or null if not found
  47541. */
  47542. getCameraByID(id: string): Nullable<Camera>;
  47543. /**
  47544. * Gets a camera using its unique id
  47545. * @param uniqueId defines the unique id to look for
  47546. * @returns the camera or null if not found
  47547. */
  47548. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47549. /**
  47550. * Gets a camera using its name
  47551. * @param name defines the camera's name
  47552. * @return the camera or null if none found.
  47553. */
  47554. getCameraByName(name: string): Nullable<Camera>;
  47555. /**
  47556. * Gets a bone using its id
  47557. * @param id defines the bone's id
  47558. * @return the bone or null if not found
  47559. */
  47560. getBoneByID(id: string): Nullable<Bone>;
  47561. /**
  47562. * Gets a bone using its id
  47563. * @param name defines the bone's name
  47564. * @return the bone or null if not found
  47565. */
  47566. getBoneByName(name: string): Nullable<Bone>;
  47567. /**
  47568. * Gets a light node using its name
  47569. * @param name defines the the light's name
  47570. * @return the light or null if none found.
  47571. */
  47572. getLightByName(name: string): Nullable<Light>;
  47573. /**
  47574. * Gets a light node using its id
  47575. * @param id defines the light's id
  47576. * @return the light or null if none found.
  47577. */
  47578. getLightByID(id: string): Nullable<Light>;
  47579. /**
  47580. * Gets a light node using its scene-generated unique ID
  47581. * @param uniqueId defines the light's unique id
  47582. * @return the light or null if none found.
  47583. */
  47584. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47585. /**
  47586. * Gets a particle system by id
  47587. * @param id defines the particle system id
  47588. * @return the corresponding system or null if none found
  47589. */
  47590. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47591. /**
  47592. * Gets a geometry using its ID
  47593. * @param id defines the geometry's id
  47594. * @return the geometry or null if none found.
  47595. */
  47596. getGeometryByID(id: string): Nullable<Geometry>;
  47597. private _getGeometryByUniqueID;
  47598. /**
  47599. * Add a new geometry to this scene
  47600. * @param geometry defines the geometry to be added to the scene.
  47601. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47602. * @return a boolean defining if the geometry was added or not
  47603. */
  47604. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47605. /**
  47606. * Removes an existing geometry
  47607. * @param geometry defines the geometry to be removed from the scene
  47608. * @return a boolean defining if the geometry was removed or not
  47609. */
  47610. removeGeometry(geometry: Geometry): boolean;
  47611. /**
  47612. * Gets the list of geometries attached to the scene
  47613. * @returns an array of Geometry
  47614. */
  47615. getGeometries(): Geometry[];
  47616. /**
  47617. * Gets the first added mesh found of a given ID
  47618. * @param id defines the id to search for
  47619. * @return the mesh found or null if not found at all
  47620. */
  47621. getMeshByID(id: string): Nullable<AbstractMesh>;
  47622. /**
  47623. * Gets a list of meshes using their id
  47624. * @param id defines the id to search for
  47625. * @returns a list of meshes
  47626. */
  47627. getMeshesByID(id: string): Array<AbstractMesh>;
  47628. /**
  47629. * Gets the first added transform node found of a given ID
  47630. * @param id defines the id to search for
  47631. * @return the found transform node or null if not found at all.
  47632. */
  47633. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47634. /**
  47635. * Gets a transform node with its auto-generated unique id
  47636. * @param uniqueId efines the unique id to search for
  47637. * @return the found transform node or null if not found at all.
  47638. */
  47639. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47640. /**
  47641. * Gets a list of transform nodes using their id
  47642. * @param id defines the id to search for
  47643. * @returns a list of transform nodes
  47644. */
  47645. getTransformNodesByID(id: string): Array<TransformNode>;
  47646. /**
  47647. * Gets a mesh with its auto-generated unique id
  47648. * @param uniqueId defines the unique id to search for
  47649. * @return the found mesh or null if not found at all.
  47650. */
  47651. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47652. /**
  47653. * Gets a the last added mesh using a given id
  47654. * @param id defines the id to search for
  47655. * @return the found mesh or null if not found at all.
  47656. */
  47657. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47658. /**
  47659. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47660. * @param id defines the id to search for
  47661. * @return the found node or null if not found at all
  47662. */
  47663. getLastEntryByID(id: string): Nullable<Node>;
  47664. /**
  47665. * Gets a node (Mesh, Camera, Light) using a given id
  47666. * @param id defines the id to search for
  47667. * @return the found node or null if not found at all
  47668. */
  47669. getNodeByID(id: string): Nullable<Node>;
  47670. /**
  47671. * Gets a node (Mesh, Camera, Light) using a given name
  47672. * @param name defines the name to search for
  47673. * @return the found node or null if not found at all.
  47674. */
  47675. getNodeByName(name: string): Nullable<Node>;
  47676. /**
  47677. * Gets a mesh using a given name
  47678. * @param name defines the name to search for
  47679. * @return the found mesh or null if not found at all.
  47680. */
  47681. getMeshByName(name: string): Nullable<AbstractMesh>;
  47682. /**
  47683. * Gets a transform node using a given name
  47684. * @param name defines the name to search for
  47685. * @return the found transform node or null if not found at all.
  47686. */
  47687. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47688. /**
  47689. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47690. * @param id defines the id to search for
  47691. * @return the found skeleton or null if not found at all.
  47692. */
  47693. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47694. /**
  47695. * Gets a skeleton using a given auto generated unique id
  47696. * @param uniqueId defines the unique id to search for
  47697. * @return the found skeleton or null if not found at all.
  47698. */
  47699. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47700. /**
  47701. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47702. * @param id defines the id to search for
  47703. * @return the found skeleton or null if not found at all.
  47704. */
  47705. getSkeletonById(id: string): Nullable<Skeleton>;
  47706. /**
  47707. * Gets a skeleton using a given name
  47708. * @param name defines the name to search for
  47709. * @return the found skeleton or null if not found at all.
  47710. */
  47711. getSkeletonByName(name: string): Nullable<Skeleton>;
  47712. /**
  47713. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47714. * @param id defines the id to search for
  47715. * @return the found morph target manager or null if not found at all.
  47716. */
  47717. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47718. /**
  47719. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47720. * @param id defines the id to search for
  47721. * @return the found morph target or null if not found at all.
  47722. */
  47723. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47724. /**
  47725. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47726. * @param name defines the name to search for
  47727. * @return the found morph target or null if not found at all.
  47728. */
  47729. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47730. /**
  47731. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47732. * @param name defines the name to search for
  47733. * @return the found post process or null if not found at all.
  47734. */
  47735. getPostProcessByName(name: string): Nullable<PostProcess>;
  47736. /**
  47737. * Gets a boolean indicating if the given mesh is active
  47738. * @param mesh defines the mesh to look for
  47739. * @returns true if the mesh is in the active list
  47740. */
  47741. isActiveMesh(mesh: AbstractMesh): boolean;
  47742. /**
  47743. * Return a unique id as a string which can serve as an identifier for the scene
  47744. */
  47745. get uid(): string;
  47746. /**
  47747. * Add an externaly attached data from its key.
  47748. * This method call will fail and return false, if such key already exists.
  47749. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47750. * @param key the unique key that identifies the data
  47751. * @param data the data object to associate to the key for this Engine instance
  47752. * @return true if no such key were already present and the data was added successfully, false otherwise
  47753. */
  47754. addExternalData<T>(key: string, data: T): boolean;
  47755. /**
  47756. * Get an externaly attached data from its key
  47757. * @param key the unique key that identifies the data
  47758. * @return the associated data, if present (can be null), or undefined if not present
  47759. */
  47760. getExternalData<T>(key: string): Nullable<T>;
  47761. /**
  47762. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47763. * @param key the unique key that identifies the data
  47764. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47765. * @return the associated data, can be null if the factory returned null.
  47766. */
  47767. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47768. /**
  47769. * Remove an externaly attached data from the Engine instance
  47770. * @param key the unique key that identifies the data
  47771. * @return true if the data was successfully removed, false if it doesn't exist
  47772. */
  47773. removeExternalData(key: string): boolean;
  47774. private _evaluateSubMesh;
  47775. /**
  47776. * Clear the processed materials smart array preventing retention point in material dispose.
  47777. */
  47778. freeProcessedMaterials(): void;
  47779. private _preventFreeActiveMeshesAndRenderingGroups;
  47780. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47781. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47782. * when disposing several meshes in a row or a hierarchy of meshes.
  47783. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47784. */
  47785. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47786. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47787. /**
  47788. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47789. */
  47790. freeActiveMeshes(): void;
  47791. /**
  47792. * Clear the info related to rendering groups preventing retention points during dispose.
  47793. */
  47794. freeRenderingGroups(): void;
  47795. /** @hidden */
  47796. _isInIntermediateRendering(): boolean;
  47797. /**
  47798. * Lambda returning the list of potentially active meshes.
  47799. */
  47800. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47801. /**
  47802. * Lambda returning the list of potentially active sub meshes.
  47803. */
  47804. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47805. /**
  47806. * Lambda returning the list of potentially intersecting sub meshes.
  47807. */
  47808. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47809. /**
  47810. * Lambda returning the list of potentially colliding sub meshes.
  47811. */
  47812. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47813. /** @hidden */
  47814. _activeMeshesFrozen: boolean;
  47815. private _skipEvaluateActiveMeshesCompletely;
  47816. /**
  47817. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47818. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47819. * @param onSuccess optional success callback
  47820. * @param onError optional error callback
  47821. * @returns the current scene
  47822. */
  47823. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47824. /**
  47825. * Use this function to restart evaluating active meshes on every frame
  47826. * @returns the current scene
  47827. */
  47828. unfreezeActiveMeshes(): Scene;
  47829. private _evaluateActiveMeshes;
  47830. private _activeMesh;
  47831. /**
  47832. * Update the transform matrix to update from the current active camera
  47833. * @param force defines a boolean used to force the update even if cache is up to date
  47834. */
  47835. updateTransformMatrix(force?: boolean): void;
  47836. private _bindFrameBuffer;
  47837. /** @hidden */
  47838. _allowPostProcessClearColor: boolean;
  47839. /** @hidden */
  47840. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47841. private _processSubCameras;
  47842. private _checkIntersections;
  47843. /** @hidden */
  47844. _advancePhysicsEngineStep(step: number): void;
  47845. /**
  47846. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47847. */
  47848. getDeterministicFrameTime: () => number;
  47849. /** @hidden */
  47850. _animate(): void;
  47851. /** Execute all animations (for a frame) */
  47852. animate(): void;
  47853. /**
  47854. * Render the scene
  47855. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47856. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47857. */
  47858. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47859. /**
  47860. * Freeze all materials
  47861. * A frozen material will not be updatable but should be faster to render
  47862. */
  47863. freezeMaterials(): void;
  47864. /**
  47865. * Unfreeze all materials
  47866. * A frozen material will not be updatable but should be faster to render
  47867. */
  47868. unfreezeMaterials(): void;
  47869. /**
  47870. * Releases all held ressources
  47871. */
  47872. dispose(): void;
  47873. /**
  47874. * Gets if the scene is already disposed
  47875. */
  47876. get isDisposed(): boolean;
  47877. /**
  47878. * Call this function to reduce memory footprint of the scene.
  47879. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47880. */
  47881. clearCachedVertexData(): void;
  47882. /**
  47883. * This function will remove the local cached buffer data from texture.
  47884. * It will save memory but will prevent the texture from being rebuilt
  47885. */
  47886. cleanCachedTextureBuffer(): void;
  47887. /**
  47888. * Get the world extend vectors with an optional filter
  47889. *
  47890. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47891. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47892. */
  47893. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47894. min: Vector3;
  47895. max: Vector3;
  47896. };
  47897. /**
  47898. * Creates a ray that can be used to pick in the scene
  47899. * @param x defines the x coordinate of the origin (on-screen)
  47900. * @param y defines the y coordinate of the origin (on-screen)
  47901. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47902. * @param camera defines the camera to use for the picking
  47903. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47904. * @returns a Ray
  47905. */
  47906. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47907. /**
  47908. * Creates a ray that can be used to pick in the scene
  47909. * @param x defines the x coordinate of the origin (on-screen)
  47910. * @param y defines the y coordinate of the origin (on-screen)
  47911. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47912. * @param result defines the ray where to store the picking ray
  47913. * @param camera defines the camera to use for the picking
  47914. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47915. * @returns the current scene
  47916. */
  47917. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47918. /**
  47919. * Creates a ray that can be used to pick in the scene
  47920. * @param x defines the x coordinate of the origin (on-screen)
  47921. * @param y defines the y coordinate of the origin (on-screen)
  47922. * @param camera defines the camera to use for the picking
  47923. * @returns a Ray
  47924. */
  47925. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47926. /**
  47927. * Creates a ray that can be used to pick in the scene
  47928. * @param x defines the x coordinate of the origin (on-screen)
  47929. * @param y defines the y coordinate of the origin (on-screen)
  47930. * @param result defines the ray where to store the picking ray
  47931. * @param camera defines the camera to use for the picking
  47932. * @returns the current scene
  47933. */
  47934. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47935. /** Launch a ray to try to pick a mesh in the scene
  47936. * @param x position on screen
  47937. * @param y position on screen
  47938. * @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
  47939. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47940. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47942. * @returns a PickingInfo
  47943. */
  47944. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47945. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47946. * @param x position on screen
  47947. * @param y position on screen
  47948. * @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
  47949. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47950. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47951. * @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)
  47952. */
  47953. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47954. /** Use the given ray to pick a mesh in the scene
  47955. * @param ray The ray to use to pick meshes
  47956. * @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
  47957. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47959. * @returns a PickingInfo
  47960. */
  47961. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47962. /**
  47963. * Launch a ray to try to pick a mesh in the scene
  47964. * @param x X position on screen
  47965. * @param y Y position on screen
  47966. * @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
  47967. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47968. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47969. * @returns an array of PickingInfo
  47970. */
  47971. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47972. /**
  47973. * Launch a ray to try to pick a mesh in the scene
  47974. * @param ray Ray to use
  47975. * @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
  47976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47977. * @returns an array of PickingInfo
  47978. */
  47979. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47980. /**
  47981. * Force the value of meshUnderPointer
  47982. * @param mesh defines the mesh to use
  47983. * @param pointerId optional pointer id when using more than one pointer
  47984. */
  47985. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47986. /**
  47987. * Gets the mesh under the pointer
  47988. * @returns a Mesh or null if no mesh is under the pointer
  47989. */
  47990. getPointerOverMesh(): Nullable<AbstractMesh>;
  47991. /** @hidden */
  47992. _rebuildGeometries(): void;
  47993. /** @hidden */
  47994. _rebuildTextures(): void;
  47995. private _getByTags;
  47996. /**
  47997. * Get a list of meshes by tags
  47998. * @param tagsQuery defines the tags query to use
  47999. * @param forEach defines a predicate used to filter results
  48000. * @returns an array of Mesh
  48001. */
  48002. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48003. /**
  48004. * Get a list of cameras by tags
  48005. * @param tagsQuery defines the tags query to use
  48006. * @param forEach defines a predicate used to filter results
  48007. * @returns an array of Camera
  48008. */
  48009. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48010. /**
  48011. * Get a list of lights by tags
  48012. * @param tagsQuery defines the tags query to use
  48013. * @param forEach defines a predicate used to filter results
  48014. * @returns an array of Light
  48015. */
  48016. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48017. /**
  48018. * Get a list of materials by tags
  48019. * @param tagsQuery defines the tags query to use
  48020. * @param forEach defines a predicate used to filter results
  48021. * @returns an array of Material
  48022. */
  48023. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48024. /**
  48025. * Get a list of transform nodes by tags
  48026. * @param tagsQuery defines the tags query to use
  48027. * @param forEach defines a predicate used to filter results
  48028. * @returns an array of TransformNode
  48029. */
  48030. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48031. /**
  48032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48033. * This allowed control for front to back rendering or reversly depending of the special needs.
  48034. *
  48035. * @param renderingGroupId The rendering group id corresponding to its index
  48036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48039. */
  48040. 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;
  48041. /**
  48042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48043. *
  48044. * @param renderingGroupId The rendering group id corresponding to its index
  48045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48048. */
  48049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48050. /**
  48051. * Gets the current auto clear configuration for one rendering group of the rendering
  48052. * manager.
  48053. * @param index the rendering group index to get the information for
  48054. * @returns The auto clear setup for the requested rendering group
  48055. */
  48056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48057. private _blockMaterialDirtyMechanism;
  48058. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48059. get blockMaterialDirtyMechanism(): boolean;
  48060. set blockMaterialDirtyMechanism(value: boolean);
  48061. /**
  48062. * Will flag all materials as dirty to trigger new shader compilation
  48063. * @param flag defines the flag used to specify which material part must be marked as dirty
  48064. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48065. */
  48066. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48067. /** @hidden */
  48068. _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;
  48069. /** @hidden */
  48070. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48071. /** @hidden */
  48072. _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;
  48073. /** @hidden */
  48074. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48075. /** @hidden */
  48076. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48077. /** @hidden */
  48078. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48079. }
  48080. }
  48081. declare module BABYLON {
  48082. /**
  48083. * Set of assets to keep when moving a scene into an asset container.
  48084. */
  48085. export class KeepAssets extends AbstractScene {
  48086. }
  48087. /**
  48088. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48089. */
  48090. export class InstantiatedEntries {
  48091. /**
  48092. * List of new root nodes (eg. nodes with no parent)
  48093. */
  48094. rootNodes: TransformNode[];
  48095. /**
  48096. * List of new skeletons
  48097. */
  48098. skeletons: Skeleton[];
  48099. /**
  48100. * List of new animation groups
  48101. */
  48102. animationGroups: AnimationGroup[];
  48103. }
  48104. /**
  48105. * Container with a set of assets that can be added or removed from a scene.
  48106. */
  48107. export class AssetContainer extends AbstractScene {
  48108. private _wasAddedToScene;
  48109. /**
  48110. * The scene the AssetContainer belongs to.
  48111. */
  48112. scene: Scene;
  48113. /**
  48114. * Instantiates an AssetContainer.
  48115. * @param scene The scene the AssetContainer belongs to.
  48116. */
  48117. constructor(scene: Scene);
  48118. /**
  48119. * Instantiate or clone all meshes and add the new ones to the scene.
  48120. * Skeletons and animation groups will all be cloned
  48121. * @param nameFunction defines an optional function used to get new names for clones
  48122. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48123. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48124. */
  48125. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48126. /**
  48127. * Adds all the assets from the container to the scene.
  48128. */
  48129. addAllToScene(): void;
  48130. /**
  48131. * Removes all the assets in the container from the scene
  48132. */
  48133. removeAllFromScene(): void;
  48134. /**
  48135. * Disposes all the assets in the container
  48136. */
  48137. dispose(): void;
  48138. private _moveAssets;
  48139. /**
  48140. * Removes all the assets contained in the scene and adds them to the container.
  48141. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48142. */
  48143. moveAllFromScene(keepAssets?: KeepAssets): void;
  48144. /**
  48145. * 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.
  48146. * @returns the root mesh
  48147. */
  48148. createRootMesh(): Mesh;
  48149. /**
  48150. * Merge animations (direct and animation groups) from this asset container into a scene
  48151. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48152. * @param animatables set of animatables to retarget to a node from the scene
  48153. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48154. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48155. */
  48156. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48157. }
  48158. }
  48159. declare module BABYLON {
  48160. /**
  48161. * Defines how the parser contract is defined.
  48162. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48163. */
  48164. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48165. /**
  48166. * Defines how the individual parser contract is defined.
  48167. * These parser can parse an individual asset
  48168. */
  48169. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48170. /**
  48171. * Base class of the scene acting as a container for the different elements composing a scene.
  48172. * This class is dynamically extended by the different components of the scene increasing
  48173. * flexibility and reducing coupling
  48174. */
  48175. export abstract class AbstractScene {
  48176. /**
  48177. * Stores the list of available parsers in the application.
  48178. */
  48179. private static _BabylonFileParsers;
  48180. /**
  48181. * Stores the list of available individual parsers in the application.
  48182. */
  48183. private static _IndividualBabylonFileParsers;
  48184. /**
  48185. * Adds a parser in the list of available ones
  48186. * @param name Defines the name of the parser
  48187. * @param parser Defines the parser to add
  48188. */
  48189. static AddParser(name: string, parser: BabylonFileParser): void;
  48190. /**
  48191. * Gets a general parser from the list of avaialble ones
  48192. * @param name Defines the name of the parser
  48193. * @returns the requested parser or null
  48194. */
  48195. static GetParser(name: string): Nullable<BabylonFileParser>;
  48196. /**
  48197. * Adds n individual parser in the list of available ones
  48198. * @param name Defines the name of the parser
  48199. * @param parser Defines the parser to add
  48200. */
  48201. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48202. /**
  48203. * Gets an individual parser from the list of avaialble ones
  48204. * @param name Defines the name of the parser
  48205. * @returns the requested parser or null
  48206. */
  48207. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48208. /**
  48209. * Parser json data and populate both a scene and its associated container object
  48210. * @param jsonData Defines the data to parse
  48211. * @param scene Defines the scene to parse the data for
  48212. * @param container Defines the container attached to the parsing sequence
  48213. * @param rootUrl Defines the root url of the data
  48214. */
  48215. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48216. /**
  48217. * Gets the list of root nodes (ie. nodes with no parent)
  48218. */
  48219. rootNodes: Node[];
  48220. /** All of the cameras added to this scene
  48221. * @see https://doc.babylonjs.com/babylon101/cameras
  48222. */
  48223. cameras: Camera[];
  48224. /**
  48225. * All of the lights added to this scene
  48226. * @see https://doc.babylonjs.com/babylon101/lights
  48227. */
  48228. lights: Light[];
  48229. /**
  48230. * All of the (abstract) meshes added to this scene
  48231. */
  48232. meshes: AbstractMesh[];
  48233. /**
  48234. * The list of skeletons added to the scene
  48235. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48236. */
  48237. skeletons: Skeleton[];
  48238. /**
  48239. * All of the particle systems added to this scene
  48240. * @see https://doc.babylonjs.com/babylon101/particles
  48241. */
  48242. particleSystems: IParticleSystem[];
  48243. /**
  48244. * Gets a list of Animations associated with the scene
  48245. */
  48246. animations: Animation[];
  48247. /**
  48248. * All of the animation groups added to this scene
  48249. * @see https://doc.babylonjs.com/how_to/group
  48250. */
  48251. animationGroups: AnimationGroup[];
  48252. /**
  48253. * All of the multi-materials added to this scene
  48254. * @see https://doc.babylonjs.com/how_to/multi_materials
  48255. */
  48256. multiMaterials: MultiMaterial[];
  48257. /**
  48258. * All of the materials added to this scene
  48259. * In the context of a Scene, it is not supposed to be modified manually.
  48260. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48261. * Note also that the order of the Material within the array is not significant and might change.
  48262. * @see https://doc.babylonjs.com/babylon101/materials
  48263. */
  48264. materials: Material[];
  48265. /**
  48266. * The list of morph target managers added to the scene
  48267. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48268. */
  48269. morphTargetManagers: MorphTargetManager[];
  48270. /**
  48271. * The list of geometries used in the scene.
  48272. */
  48273. geometries: Geometry[];
  48274. /**
  48275. * All of the tranform nodes added to this scene
  48276. * In the context of a Scene, it is not supposed to be modified manually.
  48277. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48278. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48279. * @see https://doc.babylonjs.com/how_to/transformnode
  48280. */
  48281. transformNodes: TransformNode[];
  48282. /**
  48283. * ActionManagers available on the scene.
  48284. */
  48285. actionManagers: AbstractActionManager[];
  48286. /**
  48287. * Textures to keep.
  48288. */
  48289. textures: BaseTexture[];
  48290. /** @hidden */
  48291. protected _environmentTexture: Nullable<BaseTexture>;
  48292. /**
  48293. * Texture used in all pbr material as the reflection texture.
  48294. * As in the majority of the scene they are the same (exception for multi room and so on),
  48295. * this is easier to reference from here than from all the materials.
  48296. */
  48297. get environmentTexture(): Nullable<BaseTexture>;
  48298. set environmentTexture(value: Nullable<BaseTexture>);
  48299. /**
  48300. * The list of postprocesses added to the scene
  48301. */
  48302. postProcesses: PostProcess[];
  48303. /**
  48304. * @returns all meshes, lights, cameras, transformNodes and bones
  48305. */
  48306. getNodes(): Array<Node>;
  48307. }
  48308. }
  48309. declare module BABYLON {
  48310. /**
  48311. * Interface used to define options for Sound class
  48312. */
  48313. export interface ISoundOptions {
  48314. /**
  48315. * Does the sound autoplay once loaded.
  48316. */
  48317. autoplay?: boolean;
  48318. /**
  48319. * Does the sound loop after it finishes playing once.
  48320. */
  48321. loop?: boolean;
  48322. /**
  48323. * Sound's volume
  48324. */
  48325. volume?: number;
  48326. /**
  48327. * Is it a spatial sound?
  48328. */
  48329. spatialSound?: boolean;
  48330. /**
  48331. * Maximum distance to hear that sound
  48332. */
  48333. maxDistance?: number;
  48334. /**
  48335. * Uses user defined attenuation function
  48336. */
  48337. useCustomAttenuation?: boolean;
  48338. /**
  48339. * Define the roll off factor of spatial sounds.
  48340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48341. */
  48342. rolloffFactor?: number;
  48343. /**
  48344. * Define the reference distance the sound should be heard perfectly.
  48345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48346. */
  48347. refDistance?: number;
  48348. /**
  48349. * Define the distance attenuation model the sound will follow.
  48350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48351. */
  48352. distanceModel?: string;
  48353. /**
  48354. * Defines the playback speed (1 by default)
  48355. */
  48356. playbackRate?: number;
  48357. /**
  48358. * Defines if the sound is from a streaming source
  48359. */
  48360. streaming?: boolean;
  48361. /**
  48362. * Defines an optional length (in seconds) inside the sound file
  48363. */
  48364. length?: number;
  48365. /**
  48366. * Defines an optional offset (in seconds) inside the sound file
  48367. */
  48368. offset?: number;
  48369. /**
  48370. * If true, URLs will not be required to state the audio file codec to use.
  48371. */
  48372. skipCodecCheck?: boolean;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * Defines a sound that can be played in the application.
  48378. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48379. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48380. */
  48381. export class Sound {
  48382. /**
  48383. * The name of the sound in the scene.
  48384. */
  48385. name: string;
  48386. /**
  48387. * Does the sound autoplay once loaded.
  48388. */
  48389. autoplay: boolean;
  48390. private _loop;
  48391. /**
  48392. * Does the sound loop after it finishes playing once.
  48393. */
  48394. get loop(): boolean;
  48395. set loop(value: boolean);
  48396. /**
  48397. * Does the sound use a custom attenuation curve to simulate the falloff
  48398. * happening when the source gets further away from the camera.
  48399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48400. */
  48401. useCustomAttenuation: boolean;
  48402. /**
  48403. * The sound track id this sound belongs to.
  48404. */
  48405. soundTrackId: number;
  48406. /**
  48407. * Is this sound currently played.
  48408. */
  48409. isPlaying: boolean;
  48410. /**
  48411. * Is this sound currently paused.
  48412. */
  48413. isPaused: boolean;
  48414. /**
  48415. * Does this sound enables spatial sound.
  48416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48417. */
  48418. spatialSound: boolean;
  48419. /**
  48420. * Define the reference distance the sound should be heard perfectly.
  48421. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48422. */
  48423. refDistance: number;
  48424. /**
  48425. * Define the roll off factor of spatial sounds.
  48426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48427. */
  48428. rolloffFactor: number;
  48429. /**
  48430. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48431. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48432. */
  48433. maxDistance: number;
  48434. /**
  48435. * Define the distance attenuation model the sound will follow.
  48436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48437. */
  48438. distanceModel: string;
  48439. /**
  48440. * @hidden
  48441. * Back Compat
  48442. **/
  48443. onended: () => any;
  48444. /**
  48445. * Gets or sets an object used to store user defined information for the sound.
  48446. */
  48447. metadata: any;
  48448. /**
  48449. * Observable event when the current playing sound finishes.
  48450. */
  48451. onEndedObservable: Observable<Sound>;
  48452. /**
  48453. * Gets the current time for the sound.
  48454. */
  48455. get currentTime(): number;
  48456. private _panningModel;
  48457. private _playbackRate;
  48458. private _streaming;
  48459. private _startTime;
  48460. private _startOffset;
  48461. private _position;
  48462. /** @hidden */
  48463. _positionInEmitterSpace: boolean;
  48464. private _localDirection;
  48465. private _volume;
  48466. private _isReadyToPlay;
  48467. private _isDirectional;
  48468. private _readyToPlayCallback;
  48469. private _audioBuffer;
  48470. private _soundSource;
  48471. private _streamingSource;
  48472. private _soundPanner;
  48473. private _soundGain;
  48474. private _inputAudioNode;
  48475. private _outputAudioNode;
  48476. private _coneInnerAngle;
  48477. private _coneOuterAngle;
  48478. private _coneOuterGain;
  48479. private _scene;
  48480. private _connectedTransformNode;
  48481. private _customAttenuationFunction;
  48482. private _registerFunc;
  48483. private _isOutputConnected;
  48484. private _htmlAudioElement;
  48485. private _urlType;
  48486. private _length?;
  48487. private _offset?;
  48488. /** @hidden */
  48489. static _SceneComponentInitialization: (scene: Scene) => void;
  48490. /**
  48491. * Create a sound and attach it to a scene
  48492. * @param name Name of your sound
  48493. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48494. * @param scene defines the scene the sound belongs to
  48495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48497. */
  48498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48499. /**
  48500. * Release the sound and its associated resources
  48501. */
  48502. dispose(): void;
  48503. /**
  48504. * Gets if the sounds is ready to be played or not.
  48505. * @returns true if ready, otherwise false
  48506. */
  48507. isReady(): boolean;
  48508. /**
  48509. * Get the current class name.
  48510. * @returns current class name
  48511. */
  48512. getClassName(): string;
  48513. private _soundLoaded;
  48514. /**
  48515. * Sets the data of the sound from an audiobuffer
  48516. * @param audioBuffer The audioBuffer containing the data
  48517. */
  48518. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48519. /**
  48520. * Updates the current sounds options such as maxdistance, loop...
  48521. * @param options A JSON object containing values named as the object properties
  48522. */
  48523. updateOptions(options: ISoundOptions): void;
  48524. private _createSpatialParameters;
  48525. private _updateSpatialParameters;
  48526. /**
  48527. * Switch the panning model to HRTF:
  48528. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48530. */
  48531. switchPanningModelToHRTF(): void;
  48532. /**
  48533. * Switch the panning model to Equal Power:
  48534. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48536. */
  48537. switchPanningModelToEqualPower(): void;
  48538. private _switchPanningModel;
  48539. /**
  48540. * Connect this sound to a sound track audio node like gain...
  48541. * @param soundTrackAudioNode the sound track audio node to connect to
  48542. */
  48543. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48544. /**
  48545. * Transform this sound into a directional source
  48546. * @param coneInnerAngle Size of the inner cone in degree
  48547. * @param coneOuterAngle Size of the outer cone in degree
  48548. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48549. */
  48550. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48551. /**
  48552. * Gets or sets the inner angle for the directional cone.
  48553. */
  48554. get directionalConeInnerAngle(): number;
  48555. /**
  48556. * Gets or sets the inner angle for the directional cone.
  48557. */
  48558. set directionalConeInnerAngle(value: number);
  48559. /**
  48560. * Gets or sets the outer angle for the directional cone.
  48561. */
  48562. get directionalConeOuterAngle(): number;
  48563. /**
  48564. * Gets or sets the outer angle for the directional cone.
  48565. */
  48566. set directionalConeOuterAngle(value: number);
  48567. /**
  48568. * Sets the position of the emitter if spatial sound is enabled
  48569. * @param newPosition Defines the new position
  48570. */
  48571. setPosition(newPosition: Vector3): void;
  48572. /**
  48573. * Sets the local direction of the emitter if spatial sound is enabled
  48574. * @param newLocalDirection Defines the new local direction
  48575. */
  48576. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48577. private _updateDirection;
  48578. /** @hidden */
  48579. updateDistanceFromListener(): void;
  48580. /**
  48581. * Sets a new custom attenuation function for the sound.
  48582. * @param callback Defines the function used for the attenuation
  48583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48584. */
  48585. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48586. /**
  48587. * Play the sound
  48588. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48589. * @param offset (optional) Start the sound at a specific time in seconds
  48590. * @param length (optional) Sound duration (in seconds)
  48591. */
  48592. play(time?: number, offset?: number, length?: number): void;
  48593. private _onended;
  48594. /**
  48595. * Stop the sound
  48596. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48597. */
  48598. stop(time?: number): void;
  48599. /**
  48600. * Put the sound in pause
  48601. */
  48602. pause(): void;
  48603. /**
  48604. * Sets a dedicated volume for this sounds
  48605. * @param newVolume Define the new volume of the sound
  48606. * @param time Define time for gradual change to new volume
  48607. */
  48608. setVolume(newVolume: number, time?: number): void;
  48609. /**
  48610. * Set the sound play back rate
  48611. * @param newPlaybackRate Define the playback rate the sound should be played at
  48612. */
  48613. setPlaybackRate(newPlaybackRate: number): void;
  48614. /**
  48615. * Gets the volume of the sound.
  48616. * @returns the volume of the sound
  48617. */
  48618. getVolume(): number;
  48619. /**
  48620. * Attach the sound to a dedicated mesh
  48621. * @param transformNode The transform node to connect the sound with
  48622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48623. */
  48624. attachToMesh(transformNode: TransformNode): void;
  48625. /**
  48626. * Detach the sound from the previously attached mesh
  48627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48628. */
  48629. detachFromMesh(): void;
  48630. private _onRegisterAfterWorldMatrixUpdate;
  48631. /**
  48632. * Clone the current sound in the scene.
  48633. * @returns the new sound clone
  48634. */
  48635. clone(): Nullable<Sound>;
  48636. /**
  48637. * Gets the current underlying audio buffer containing the data
  48638. * @returns the audio buffer
  48639. */
  48640. getAudioBuffer(): Nullable<AudioBuffer>;
  48641. /**
  48642. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48643. * @returns the source node
  48644. */
  48645. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48646. /**
  48647. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48648. * @returns the gain node
  48649. */
  48650. getSoundGain(): Nullable<GainNode>;
  48651. /**
  48652. * Serializes the Sound in a JSON representation
  48653. * @returns the JSON representation of the sound
  48654. */
  48655. serialize(): any;
  48656. /**
  48657. * Parse a JSON representation of a sound to instantiate in a given scene
  48658. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48659. * @param scene Define the scene the new parsed sound should be created in
  48660. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48661. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48662. * @returns the newly parsed sound
  48663. */
  48664. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48665. }
  48666. }
  48667. declare module BABYLON {
  48668. /**
  48669. * This defines an action helpful to play a defined sound on a triggered action.
  48670. */
  48671. export class PlaySoundAction extends Action {
  48672. private _sound;
  48673. /**
  48674. * Instantiate the action
  48675. * @param triggerOptions defines the trigger options
  48676. * @param sound defines the sound to play
  48677. * @param condition defines the trigger related conditions
  48678. */
  48679. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48680. /** @hidden */
  48681. _prepare(): void;
  48682. /**
  48683. * Execute the action and play the sound.
  48684. */
  48685. execute(): void;
  48686. /**
  48687. * Serializes the actions and its related information.
  48688. * @param parent defines the object to serialize in
  48689. * @returns the serialized object
  48690. */
  48691. serialize(parent: any): any;
  48692. }
  48693. /**
  48694. * This defines an action helpful to stop a defined sound on a triggered action.
  48695. */
  48696. export class StopSoundAction extends Action {
  48697. private _sound;
  48698. /**
  48699. * Instantiate the action
  48700. * @param triggerOptions defines the trigger options
  48701. * @param sound defines the sound to stop
  48702. * @param condition defines the trigger related conditions
  48703. */
  48704. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48705. /** @hidden */
  48706. _prepare(): void;
  48707. /**
  48708. * Execute the action and stop the sound.
  48709. */
  48710. execute(): void;
  48711. /**
  48712. * Serializes the actions and its related information.
  48713. * @param parent defines the object to serialize in
  48714. * @returns the serialized object
  48715. */
  48716. serialize(parent: any): any;
  48717. }
  48718. }
  48719. declare module BABYLON {
  48720. /**
  48721. * This defines an action responsible to change the value of a property
  48722. * by interpolating between its current value and the newly set one once triggered.
  48723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48724. */
  48725. export class InterpolateValueAction extends Action {
  48726. /**
  48727. * Defines the path of the property where the value should be interpolated
  48728. */
  48729. propertyPath: string;
  48730. /**
  48731. * Defines the target value at the end of the interpolation.
  48732. */
  48733. value: any;
  48734. /**
  48735. * Defines the time it will take for the property to interpolate to the value.
  48736. */
  48737. duration: number;
  48738. /**
  48739. * Defines if the other scene animations should be stopped when the action has been triggered
  48740. */
  48741. stopOtherAnimations?: boolean;
  48742. /**
  48743. * Defines a callback raised once the interpolation animation has been done.
  48744. */
  48745. onInterpolationDone?: () => void;
  48746. /**
  48747. * Observable triggered once the interpolation animation has been done.
  48748. */
  48749. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48750. private _target;
  48751. private _effectiveTarget;
  48752. private _property;
  48753. /**
  48754. * Instantiate the action
  48755. * @param triggerOptions defines the trigger options
  48756. * @param target defines the object containing the value to interpolate
  48757. * @param propertyPath defines the path to the property in the target object
  48758. * @param value defines the target value at the end of the interpolation
  48759. * @param duration defines the time it will take for the property to interpolate to the value.
  48760. * @param condition defines the trigger related conditions
  48761. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48762. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48763. */
  48764. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48765. /** @hidden */
  48766. _prepare(): void;
  48767. /**
  48768. * Execute the action starts the value interpolation.
  48769. */
  48770. execute(): void;
  48771. /**
  48772. * Serializes the actions and its related information.
  48773. * @param parent defines the object to serialize in
  48774. * @returns the serialized object
  48775. */
  48776. serialize(parent: any): any;
  48777. }
  48778. }
  48779. declare module BABYLON {
  48780. /**
  48781. * This represents the default audio engine used in babylon.
  48782. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48783. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48784. */
  48785. export class AudioEngine implements IAudioEngine {
  48786. private _audioContext;
  48787. private _audioContextInitialized;
  48788. private _muteButton;
  48789. private _hostElement;
  48790. /**
  48791. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48792. */
  48793. canUseWebAudio: boolean;
  48794. /**
  48795. * The master gain node defines the global audio volume of your audio engine.
  48796. */
  48797. masterGain: GainNode;
  48798. /**
  48799. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48800. * @ignoreNaming
  48801. */
  48802. WarnedWebAudioUnsupported: boolean;
  48803. /**
  48804. * Gets whether or not mp3 are supported by your browser.
  48805. */
  48806. isMP3supported: boolean;
  48807. /**
  48808. * Gets whether or not ogg are supported by your browser.
  48809. */
  48810. isOGGsupported: boolean;
  48811. /**
  48812. * Gets whether audio has been unlocked on the device.
  48813. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48814. * a user interaction has happened.
  48815. */
  48816. unlocked: boolean;
  48817. /**
  48818. * Defines if the audio engine relies on a custom unlocked button.
  48819. * In this case, the embedded button will not be displayed.
  48820. */
  48821. useCustomUnlockedButton: boolean;
  48822. /**
  48823. * Event raised when audio has been unlocked on the browser.
  48824. */
  48825. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48826. /**
  48827. * Event raised when audio has been locked on the browser.
  48828. */
  48829. onAudioLockedObservable: Observable<IAudioEngine>;
  48830. /**
  48831. * Gets the current AudioContext if available.
  48832. */
  48833. get audioContext(): Nullable<AudioContext>;
  48834. private _connectedAnalyser;
  48835. /**
  48836. * Instantiates a new audio engine.
  48837. *
  48838. * There should be only one per page as some browsers restrict the number
  48839. * of audio contexts you can create.
  48840. * @param hostElement defines the host element where to display the mute icon if necessary
  48841. */
  48842. constructor(hostElement?: Nullable<HTMLElement>);
  48843. /**
  48844. * Flags the audio engine in Locked state.
  48845. * This happens due to new browser policies preventing audio to autoplay.
  48846. */
  48847. lock(): void;
  48848. /**
  48849. * Unlocks the audio engine once a user action has been done on the dom.
  48850. * This is helpful to resume play once browser policies have been satisfied.
  48851. */
  48852. unlock(): void;
  48853. private _resumeAudioContext;
  48854. private _initializeAudioContext;
  48855. private _tryToRun;
  48856. private _triggerRunningState;
  48857. private _triggerSuspendedState;
  48858. private _displayMuteButton;
  48859. private _moveButtonToTopLeft;
  48860. private _onResize;
  48861. private _hideMuteButton;
  48862. /**
  48863. * Destroy and release the resources associated with the audio context.
  48864. */
  48865. dispose(): void;
  48866. /**
  48867. * Gets the global volume sets on the master gain.
  48868. * @returns the global volume if set or -1 otherwise
  48869. */
  48870. getGlobalVolume(): number;
  48871. /**
  48872. * Sets the global volume of your experience (sets on the master gain).
  48873. * @param newVolume Defines the new global volume of the application
  48874. */
  48875. setGlobalVolume(newVolume: number): void;
  48876. /**
  48877. * Connect the audio engine to an audio analyser allowing some amazing
  48878. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48879. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48880. * @param analyser The analyser to connect to the engine
  48881. */
  48882. connectToAnalyser(analyser: Analyser): void;
  48883. }
  48884. }
  48885. declare module BABYLON {
  48886. /**
  48887. * Options allowed during the creation of a sound track.
  48888. */
  48889. export interface ISoundTrackOptions {
  48890. /**
  48891. * The volume the sound track should take during creation
  48892. */
  48893. volume?: number;
  48894. /**
  48895. * Define if the sound track is the main sound track of the scene
  48896. */
  48897. mainTrack?: boolean;
  48898. }
  48899. /**
  48900. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48901. * It will be also used in a future release to apply effects on a specific track.
  48902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48903. */
  48904. export class SoundTrack {
  48905. /**
  48906. * The unique identifier of the sound track in the scene.
  48907. */
  48908. id: number;
  48909. /**
  48910. * The list of sounds included in the sound track.
  48911. */
  48912. soundCollection: Array<Sound>;
  48913. private _outputAudioNode;
  48914. private _scene;
  48915. private _connectedAnalyser;
  48916. private _options;
  48917. private _isInitialized;
  48918. /**
  48919. * Creates a new sound track.
  48920. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48921. * @param scene Define the scene the sound track belongs to
  48922. * @param options
  48923. */
  48924. constructor(scene: Scene, options?: ISoundTrackOptions);
  48925. private _initializeSoundTrackAudioGraph;
  48926. /**
  48927. * Release the sound track and its associated resources
  48928. */
  48929. dispose(): void;
  48930. /**
  48931. * Adds a sound to this sound track
  48932. * @param sound define the sound to add
  48933. * @ignoreNaming
  48934. */
  48935. addSound(sound: Sound): void;
  48936. /**
  48937. * Removes a sound to this sound track
  48938. * @param sound define the sound to remove
  48939. * @ignoreNaming
  48940. */
  48941. removeSound(sound: Sound): void;
  48942. /**
  48943. * Set a global volume for the full sound track.
  48944. * @param newVolume Define the new volume of the sound track
  48945. */
  48946. setVolume(newVolume: number): void;
  48947. /**
  48948. * Switch the panning model to HRTF:
  48949. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48951. */
  48952. switchPanningModelToHRTF(): void;
  48953. /**
  48954. * Switch the panning model to Equal Power:
  48955. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48957. */
  48958. switchPanningModelToEqualPower(): void;
  48959. /**
  48960. * Connect the sound track to an audio analyser allowing some amazing
  48961. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48963. * @param analyser The analyser to connect to the engine
  48964. */
  48965. connectToAnalyser(analyser: Analyser): void;
  48966. }
  48967. }
  48968. declare module BABYLON {
  48969. interface AbstractScene {
  48970. /**
  48971. * The list of sounds used in the scene.
  48972. */
  48973. sounds: Nullable<Array<Sound>>;
  48974. }
  48975. interface Scene {
  48976. /**
  48977. * @hidden
  48978. * Backing field
  48979. */
  48980. _mainSoundTrack: SoundTrack;
  48981. /**
  48982. * The main sound track played by the scene.
  48983. * It contains your primary collection of sounds.
  48984. */
  48985. mainSoundTrack: SoundTrack;
  48986. /**
  48987. * The list of sound tracks added to the scene
  48988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48989. */
  48990. soundTracks: Nullable<Array<SoundTrack>>;
  48991. /**
  48992. * Gets a sound using a given name
  48993. * @param name defines the name to search for
  48994. * @return the found sound or null if not found at all.
  48995. */
  48996. getSoundByName(name: string): Nullable<Sound>;
  48997. /**
  48998. * Gets or sets if audio support is enabled
  48999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49000. */
  49001. audioEnabled: boolean;
  49002. /**
  49003. * Gets or sets if audio will be output to headphones
  49004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49005. */
  49006. headphone: boolean;
  49007. /**
  49008. * Gets or sets custom audio listener position provider
  49009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49010. */
  49011. audioListenerPositionProvider: Nullable<() => Vector3>;
  49012. /**
  49013. * Gets or sets a refresh rate when using 3D audio positioning
  49014. */
  49015. audioPositioningRefreshRate: number;
  49016. }
  49017. /**
  49018. * Defines the sound scene component responsible to manage any sounds
  49019. * in a given scene.
  49020. */
  49021. export class AudioSceneComponent implements ISceneSerializableComponent {
  49022. private static _CameraDirectionLH;
  49023. private static _CameraDirectionRH;
  49024. /**
  49025. * The component name helpful to identify the component in the list of scene components.
  49026. */
  49027. readonly name: string;
  49028. /**
  49029. * The scene the component belongs to.
  49030. */
  49031. scene: Scene;
  49032. private _audioEnabled;
  49033. /**
  49034. * Gets whether audio is enabled or not.
  49035. * Please use related enable/disable method to switch state.
  49036. */
  49037. get audioEnabled(): boolean;
  49038. private _headphone;
  49039. /**
  49040. * Gets whether audio is outputting to headphone or not.
  49041. * Please use the according Switch methods to change output.
  49042. */
  49043. get headphone(): boolean;
  49044. /**
  49045. * Gets or sets a refresh rate when using 3D audio positioning
  49046. */
  49047. audioPositioningRefreshRate: number;
  49048. private _audioListenerPositionProvider;
  49049. /**
  49050. * Gets the current audio listener position provider
  49051. */
  49052. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49053. /**
  49054. * Sets a custom listener position for all sounds in the scene
  49055. * By default, this is the position of the first active camera
  49056. */
  49057. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49058. /**
  49059. * Creates a new instance of the component for the given scene
  49060. * @param scene Defines the scene to register the component in
  49061. */
  49062. constructor(scene: Scene);
  49063. /**
  49064. * Registers the component in a given scene
  49065. */
  49066. register(): void;
  49067. /**
  49068. * Rebuilds the elements related to this component in case of
  49069. * context lost for instance.
  49070. */
  49071. rebuild(): void;
  49072. /**
  49073. * Serializes the component data to the specified json object
  49074. * @param serializationObject The object to serialize to
  49075. */
  49076. serialize(serializationObject: any): void;
  49077. /**
  49078. * Adds all the elements from the container to the scene
  49079. * @param container the container holding the elements
  49080. */
  49081. addFromContainer(container: AbstractScene): void;
  49082. /**
  49083. * Removes all the elements in the container from the scene
  49084. * @param container contains the elements to remove
  49085. * @param dispose if the removed element should be disposed (default: false)
  49086. */
  49087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49088. /**
  49089. * Disposes the component and the associated resources.
  49090. */
  49091. dispose(): void;
  49092. /**
  49093. * Disables audio in the associated scene.
  49094. */
  49095. disableAudio(): void;
  49096. /**
  49097. * Enables audio in the associated scene.
  49098. */
  49099. enableAudio(): void;
  49100. /**
  49101. * Switch audio to headphone output.
  49102. */
  49103. switchAudioModeForHeadphones(): void;
  49104. /**
  49105. * Switch audio to normal speakers.
  49106. */
  49107. switchAudioModeForNormalSpeakers(): void;
  49108. private _cachedCameraDirection;
  49109. private _cachedCameraPosition;
  49110. private _lastCheck;
  49111. private _afterRender;
  49112. }
  49113. }
  49114. declare module BABYLON {
  49115. /**
  49116. * Wraps one or more Sound objects and selects one with random weight for playback.
  49117. */
  49118. export class WeightedSound {
  49119. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49120. loop: boolean;
  49121. private _coneInnerAngle;
  49122. private _coneOuterAngle;
  49123. private _volume;
  49124. /** A Sound is currently playing. */
  49125. isPlaying: boolean;
  49126. /** A Sound is currently paused. */
  49127. isPaused: boolean;
  49128. private _sounds;
  49129. private _weights;
  49130. private _currentIndex?;
  49131. /**
  49132. * Creates a new WeightedSound from the list of sounds given.
  49133. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49134. * @param sounds Array of Sounds that will be selected from.
  49135. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49136. */
  49137. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49138. /**
  49139. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49140. */
  49141. get directionalConeInnerAngle(): number;
  49142. /**
  49143. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49144. */
  49145. set directionalConeInnerAngle(value: number);
  49146. /**
  49147. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49148. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49149. */
  49150. get directionalConeOuterAngle(): number;
  49151. /**
  49152. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49153. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49154. */
  49155. set directionalConeOuterAngle(value: number);
  49156. /**
  49157. * Playback volume.
  49158. */
  49159. get volume(): number;
  49160. /**
  49161. * Playback volume.
  49162. */
  49163. set volume(value: number);
  49164. private _onended;
  49165. /**
  49166. * Suspend playback
  49167. */
  49168. pause(): void;
  49169. /**
  49170. * Stop playback
  49171. */
  49172. stop(): void;
  49173. /**
  49174. * Start playback.
  49175. * @param startOffset Position the clip head at a specific time in seconds.
  49176. */
  49177. play(startOffset?: number): void;
  49178. }
  49179. }
  49180. declare module BABYLON {
  49181. /**
  49182. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49183. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49184. */
  49185. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49186. /**
  49187. * Gets the name of the behavior.
  49188. */
  49189. get name(): string;
  49190. /**
  49191. * The easing function used by animations
  49192. */
  49193. static EasingFunction: BackEase;
  49194. /**
  49195. * The easing mode used by animations
  49196. */
  49197. static EasingMode: number;
  49198. /**
  49199. * The duration of the animation, in milliseconds
  49200. */
  49201. transitionDuration: number;
  49202. /**
  49203. * Length of the distance animated by the transition when lower radius is reached
  49204. */
  49205. lowerRadiusTransitionRange: number;
  49206. /**
  49207. * Length of the distance animated by the transition when upper radius is reached
  49208. */
  49209. upperRadiusTransitionRange: number;
  49210. private _autoTransitionRange;
  49211. /**
  49212. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49213. */
  49214. get autoTransitionRange(): boolean;
  49215. /**
  49216. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49217. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49218. */
  49219. set autoTransitionRange(value: boolean);
  49220. private _attachedCamera;
  49221. private _onAfterCheckInputsObserver;
  49222. private _onMeshTargetChangedObserver;
  49223. /**
  49224. * Initializes the behavior.
  49225. */
  49226. init(): void;
  49227. /**
  49228. * Attaches the behavior to its arc rotate camera.
  49229. * @param camera Defines the camera to attach the behavior to
  49230. */
  49231. attach(camera: ArcRotateCamera): void;
  49232. /**
  49233. * Detaches the behavior from its current arc rotate camera.
  49234. */
  49235. detach(): void;
  49236. private _radiusIsAnimating;
  49237. private _radiusBounceTransition;
  49238. private _animatables;
  49239. private _cachedWheelPrecision;
  49240. /**
  49241. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49242. * @param radiusLimit The limit to check against.
  49243. * @return Bool to indicate if at limit.
  49244. */
  49245. private _isRadiusAtLimit;
  49246. /**
  49247. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49248. * @param radiusDelta The delta by which to animate to. Can be negative.
  49249. */
  49250. private _applyBoundRadiusAnimation;
  49251. /**
  49252. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49253. */
  49254. protected _clearAnimationLocks(): void;
  49255. /**
  49256. * Stops and removes all animations that have been applied to the camera
  49257. */
  49258. stopAllAnimations(): void;
  49259. }
  49260. }
  49261. declare module BABYLON {
  49262. /**
  49263. * 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.
  49264. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49265. */
  49266. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49267. /**
  49268. * Gets the name of the behavior.
  49269. */
  49270. get name(): string;
  49271. private _mode;
  49272. private _radiusScale;
  49273. private _positionScale;
  49274. private _defaultElevation;
  49275. private _elevationReturnTime;
  49276. private _elevationReturnWaitTime;
  49277. private _zoomStopsAnimation;
  49278. private _framingTime;
  49279. /**
  49280. * The easing function used by animations
  49281. */
  49282. static EasingFunction: ExponentialEase;
  49283. /**
  49284. * The easing mode used by animations
  49285. */
  49286. static EasingMode: number;
  49287. /**
  49288. * Sets the current mode used by the behavior
  49289. */
  49290. set mode(mode: number);
  49291. /**
  49292. * Gets current mode used by the behavior.
  49293. */
  49294. get mode(): number;
  49295. /**
  49296. * Sets the scale applied to the radius (1 by default)
  49297. */
  49298. set radiusScale(radius: number);
  49299. /**
  49300. * Gets the scale applied to the radius
  49301. */
  49302. get radiusScale(): number;
  49303. /**
  49304. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49305. */
  49306. set positionScale(scale: number);
  49307. /**
  49308. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49309. */
  49310. get positionScale(): number;
  49311. /**
  49312. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49313. * behaviour is triggered, in radians.
  49314. */
  49315. set defaultElevation(elevation: number);
  49316. /**
  49317. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49318. * behaviour is triggered, in radians.
  49319. */
  49320. get defaultElevation(): number;
  49321. /**
  49322. * Sets the time (in milliseconds) taken to return to the default beta position.
  49323. * Negative value indicates camera should not return to default.
  49324. */
  49325. set elevationReturnTime(speed: number);
  49326. /**
  49327. * Gets the time (in milliseconds) taken to return to the default beta position.
  49328. * Negative value indicates camera should not return to default.
  49329. */
  49330. get elevationReturnTime(): number;
  49331. /**
  49332. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49333. */
  49334. set elevationReturnWaitTime(time: number);
  49335. /**
  49336. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49337. */
  49338. get elevationReturnWaitTime(): number;
  49339. /**
  49340. * Sets the flag that indicates if user zooming should stop animation.
  49341. */
  49342. set zoomStopsAnimation(flag: boolean);
  49343. /**
  49344. * Gets the flag that indicates if user zooming should stop animation.
  49345. */
  49346. get zoomStopsAnimation(): boolean;
  49347. /**
  49348. * Sets the transition time when framing the mesh, in milliseconds
  49349. */
  49350. set framingTime(time: number);
  49351. /**
  49352. * Gets the transition time when framing the mesh, in milliseconds
  49353. */
  49354. get framingTime(): number;
  49355. /**
  49356. * Define if the behavior should automatically change the configured
  49357. * camera limits and sensibilities.
  49358. */
  49359. autoCorrectCameraLimitsAndSensibility: boolean;
  49360. private _onPrePointerObservableObserver;
  49361. private _onAfterCheckInputsObserver;
  49362. private _onMeshTargetChangedObserver;
  49363. private _attachedCamera;
  49364. private _isPointerDown;
  49365. private _lastInteractionTime;
  49366. /**
  49367. * Initializes the behavior.
  49368. */
  49369. init(): void;
  49370. /**
  49371. * Attaches the behavior to its arc rotate camera.
  49372. * @param camera Defines the camera to attach the behavior to
  49373. */
  49374. attach(camera: ArcRotateCamera): void;
  49375. /**
  49376. * Detaches the behavior from its current arc rotate camera.
  49377. */
  49378. detach(): void;
  49379. private _animatables;
  49380. private _betaIsAnimating;
  49381. private _betaTransition;
  49382. private _radiusTransition;
  49383. private _vectorTransition;
  49384. /**
  49385. * Targets the given mesh and updates zoom level accordingly.
  49386. * @param mesh The mesh to target.
  49387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49389. */
  49390. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49391. /**
  49392. * Targets the given mesh with its children and updates zoom level accordingly.
  49393. * @param mesh The mesh to target.
  49394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49396. */
  49397. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49398. /**
  49399. * Targets the given meshes with their children and updates zoom level accordingly.
  49400. * @param meshes The mesh to target.
  49401. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49402. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49403. */
  49404. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49405. /**
  49406. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49407. * @param minimumWorld Determines the smaller position of the bounding box extend
  49408. * @param maximumWorld Determines the bigger position of the bounding box extend
  49409. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49410. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49411. */
  49412. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49413. /**
  49414. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49415. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49416. * frustum width.
  49417. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49418. * to fully enclose the mesh in the viewing frustum.
  49419. */
  49420. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49421. /**
  49422. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49423. * is automatically returned to its default position (expected to be above ground plane).
  49424. */
  49425. private _maintainCameraAboveGround;
  49426. /**
  49427. * Returns the frustum slope based on the canvas ratio and camera FOV
  49428. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49429. */
  49430. private _getFrustumSlope;
  49431. /**
  49432. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49433. */
  49434. private _clearAnimationLocks;
  49435. /**
  49436. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49437. */
  49438. private _applyUserInteraction;
  49439. /**
  49440. * Stops and removes all animations that have been applied to the camera
  49441. */
  49442. stopAllAnimations(): void;
  49443. /**
  49444. * Gets a value indicating if the user is moving the camera
  49445. */
  49446. get isUserIsMoving(): boolean;
  49447. /**
  49448. * The camera can move all the way towards the mesh.
  49449. */
  49450. static IgnoreBoundsSizeMode: number;
  49451. /**
  49452. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49453. */
  49454. static FitFrustumSidesMode: number;
  49455. }
  49456. }
  49457. declare module BABYLON {
  49458. /**
  49459. * Base class for Camera Pointer Inputs.
  49460. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49461. * for example usage.
  49462. */
  49463. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49464. /**
  49465. * Defines the camera the input is attached to.
  49466. */
  49467. abstract camera: Camera;
  49468. /**
  49469. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49470. */
  49471. protected _altKey: boolean;
  49472. protected _ctrlKey: boolean;
  49473. protected _metaKey: boolean;
  49474. protected _shiftKey: boolean;
  49475. /**
  49476. * Which mouse buttons were pressed at time of last mouse event.
  49477. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49478. */
  49479. protected _buttonsPressed: number;
  49480. /**
  49481. * Defines the buttons associated with the input to handle camera move.
  49482. */
  49483. buttons: number[];
  49484. /**
  49485. * Attach the input controls to a specific dom element to get the input from.
  49486. * @param element Defines the element the controls should be listened from
  49487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49488. */
  49489. attachControl(noPreventDefault?: boolean): void;
  49490. /**
  49491. * Detach the current controls from the specified dom element.
  49492. */
  49493. detachControl(): void;
  49494. /**
  49495. * Gets the class name of the current input.
  49496. * @returns the class name
  49497. */
  49498. getClassName(): string;
  49499. /**
  49500. * Get the friendly name associated with the input class.
  49501. * @returns the input friendly name
  49502. */
  49503. getSimpleName(): string;
  49504. /**
  49505. * Called on pointer POINTERDOUBLETAP event.
  49506. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49507. */
  49508. protected onDoubleTap(type: string): void;
  49509. /**
  49510. * Called on pointer POINTERMOVE event if only a single touch is active.
  49511. * Override this method to provide functionality.
  49512. */
  49513. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49514. /**
  49515. * Called on pointer POINTERMOVE event if multiple touches are active.
  49516. * Override this method to provide functionality.
  49517. */
  49518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49519. /**
  49520. * Called on JS contextmenu event.
  49521. * Override this method to provide functionality.
  49522. */
  49523. protected onContextMenu(evt: PointerEvent): void;
  49524. /**
  49525. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49526. * press.
  49527. * Override this method to provide functionality.
  49528. */
  49529. protected onButtonDown(evt: PointerEvent): void;
  49530. /**
  49531. * Called each time a new POINTERUP event occurs. Ie, for each button
  49532. * release.
  49533. * Override this method to provide functionality.
  49534. */
  49535. protected onButtonUp(evt: PointerEvent): void;
  49536. /**
  49537. * Called when window becomes inactive.
  49538. * Override this method to provide functionality.
  49539. */
  49540. protected onLostFocus(): void;
  49541. private _pointerInput;
  49542. private _observer;
  49543. private _onLostFocus;
  49544. private pointA;
  49545. private pointB;
  49546. }
  49547. }
  49548. declare module BABYLON {
  49549. /**
  49550. * Manage the pointers inputs to control an arc rotate camera.
  49551. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49552. */
  49553. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49554. /**
  49555. * Defines the camera the input is attached to.
  49556. */
  49557. camera: ArcRotateCamera;
  49558. /**
  49559. * Gets the class name of the current input.
  49560. * @returns the class name
  49561. */
  49562. getClassName(): string;
  49563. /**
  49564. * Defines the buttons associated with the input to handle camera move.
  49565. */
  49566. buttons: number[];
  49567. /**
  49568. * Defines the pointer angular sensibility along the X axis or how fast is
  49569. * the camera rotating.
  49570. */
  49571. angularSensibilityX: number;
  49572. /**
  49573. * Defines the pointer angular sensibility along the Y axis or how fast is
  49574. * the camera rotating.
  49575. */
  49576. angularSensibilityY: number;
  49577. /**
  49578. * Defines the pointer pinch precision or how fast is the camera zooming.
  49579. */
  49580. pinchPrecision: number;
  49581. /**
  49582. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49583. * from 0.
  49584. * It defines the percentage of current camera.radius to use as delta when
  49585. * pinch zoom is used.
  49586. */
  49587. pinchDeltaPercentage: number;
  49588. /**
  49589. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49590. * that any object in the plane at the camera's target point will scale
  49591. * perfectly with finger motion.
  49592. * Overrides pinchDeltaPercentage and pinchPrecision.
  49593. */
  49594. useNaturalPinchZoom: boolean;
  49595. /**
  49596. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49597. */
  49598. pinchZoom: boolean;
  49599. /**
  49600. * Defines the pointer panning sensibility or how fast is the camera moving.
  49601. */
  49602. panningSensibility: number;
  49603. /**
  49604. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49605. */
  49606. multiTouchPanning: boolean;
  49607. /**
  49608. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49609. * zoom (pinch) through multitouch.
  49610. */
  49611. multiTouchPanAndZoom: boolean;
  49612. /**
  49613. * Revers pinch action direction.
  49614. */
  49615. pinchInwards: boolean;
  49616. private _isPanClick;
  49617. private _twoFingerActivityCount;
  49618. private _isPinching;
  49619. /**
  49620. * Move camera from multi touch panning positions.
  49621. */
  49622. private _computeMultiTouchPanning;
  49623. /**
  49624. * Move camera from pinch zoom distances.
  49625. */
  49626. private _computePinchZoom;
  49627. /**
  49628. * Called on pointer POINTERMOVE event if only a single touch is active.
  49629. */
  49630. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49631. /**
  49632. * Called on pointer POINTERDOUBLETAP event.
  49633. */
  49634. protected onDoubleTap(type: string): void;
  49635. /**
  49636. * Called on pointer POINTERMOVE event if multiple touches are active.
  49637. */
  49638. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49639. /**
  49640. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49641. * press.
  49642. */
  49643. protected onButtonDown(evt: PointerEvent): void;
  49644. /**
  49645. * Called each time a new POINTERUP event occurs. Ie, for each button
  49646. * release.
  49647. */
  49648. protected onButtonUp(evt: PointerEvent): void;
  49649. /**
  49650. * Called when window becomes inactive.
  49651. */
  49652. protected onLostFocus(): void;
  49653. }
  49654. }
  49655. declare module BABYLON {
  49656. /**
  49657. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49659. */
  49660. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49661. /**
  49662. * Defines the camera the input is attached to.
  49663. */
  49664. camera: ArcRotateCamera;
  49665. /**
  49666. * Defines the list of key codes associated with the up action (increase alpha)
  49667. */
  49668. keysUp: number[];
  49669. /**
  49670. * Defines the list of key codes associated with the down action (decrease alpha)
  49671. */
  49672. keysDown: number[];
  49673. /**
  49674. * Defines the list of key codes associated with the left action (increase beta)
  49675. */
  49676. keysLeft: number[];
  49677. /**
  49678. * Defines the list of key codes associated with the right action (decrease beta)
  49679. */
  49680. keysRight: number[];
  49681. /**
  49682. * Defines the list of key codes associated with the reset action.
  49683. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49684. */
  49685. keysReset: number[];
  49686. /**
  49687. * Defines the panning sensibility of the inputs.
  49688. * (How fast is the camera panning)
  49689. */
  49690. panningSensibility: number;
  49691. /**
  49692. * Defines the zooming sensibility of the inputs.
  49693. * (How fast is the camera zooming)
  49694. */
  49695. zoomingSensibility: number;
  49696. /**
  49697. * Defines whether maintaining the alt key down switch the movement mode from
  49698. * orientation to zoom.
  49699. */
  49700. useAltToZoom: boolean;
  49701. /**
  49702. * Rotation speed of the camera
  49703. */
  49704. angularSpeed: number;
  49705. private _keys;
  49706. private _ctrlPressed;
  49707. private _altPressed;
  49708. private _onCanvasBlurObserver;
  49709. private _onKeyboardObserver;
  49710. private _engine;
  49711. private _scene;
  49712. /**
  49713. * Attach the input controls to a specific dom element to get the input from.
  49714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49715. */
  49716. attachControl(noPreventDefault?: boolean): void;
  49717. /**
  49718. * Detach the current controls from the specified dom element.
  49719. */
  49720. detachControl(): void;
  49721. /**
  49722. * Update the current camera state depending on the inputs that have been used this frame.
  49723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49724. */
  49725. checkInputs(): void;
  49726. /**
  49727. * Gets the class name of the current input.
  49728. * @returns the class name
  49729. */
  49730. getClassName(): string;
  49731. /**
  49732. * Get the friendly name associated with the input class.
  49733. * @returns the input friendly name
  49734. */
  49735. getSimpleName(): string;
  49736. }
  49737. }
  49738. declare module BABYLON {
  49739. /**
  49740. * Manage the mouse wheel inputs to control an arc rotate camera.
  49741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49742. */
  49743. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49744. /**
  49745. * Defines the camera the input is attached to.
  49746. */
  49747. camera: ArcRotateCamera;
  49748. /**
  49749. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49750. */
  49751. wheelPrecision: number;
  49752. /**
  49753. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49754. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49755. */
  49756. wheelDeltaPercentage: number;
  49757. private _wheel;
  49758. private _observer;
  49759. private computeDeltaFromMouseWheelLegacyEvent;
  49760. /**
  49761. * Attach the input controls to a specific dom element to get the input from.
  49762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49763. */
  49764. attachControl(noPreventDefault?: boolean): void;
  49765. /**
  49766. * Detach the current controls from the specified dom element.
  49767. */
  49768. detachControl(): void;
  49769. /**
  49770. * Gets the class name of the current input.
  49771. * @returns the class name
  49772. */
  49773. getClassName(): string;
  49774. /**
  49775. * Get the friendly name associated with the input class.
  49776. * @returns the input friendly name
  49777. */
  49778. getSimpleName(): string;
  49779. }
  49780. }
  49781. declare module BABYLON {
  49782. /**
  49783. * Default Inputs manager for the ArcRotateCamera.
  49784. * It groups all the default supported inputs for ease of use.
  49785. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49786. */
  49787. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49788. /**
  49789. * Instantiates a new ArcRotateCameraInputsManager.
  49790. * @param camera Defines the camera the inputs belong to
  49791. */
  49792. constructor(camera: ArcRotateCamera);
  49793. /**
  49794. * Add mouse wheel input support to the input manager.
  49795. * @returns the current input manager
  49796. */
  49797. addMouseWheel(): ArcRotateCameraInputsManager;
  49798. /**
  49799. * Add pointers input support to the input manager.
  49800. * @returns the current input manager
  49801. */
  49802. addPointers(): ArcRotateCameraInputsManager;
  49803. /**
  49804. * Add keyboard input support to the input manager.
  49805. * @returns the current input manager
  49806. */
  49807. addKeyboard(): ArcRotateCameraInputsManager;
  49808. }
  49809. }
  49810. declare module BABYLON {
  49811. /**
  49812. * This represents an orbital type of camera.
  49813. *
  49814. * 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.
  49815. * 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.
  49816. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49817. */
  49818. export class ArcRotateCamera extends TargetCamera {
  49819. /**
  49820. * Defines the rotation angle of the camera along the longitudinal axis.
  49821. */
  49822. alpha: number;
  49823. /**
  49824. * Defines the rotation angle of the camera along the latitudinal axis.
  49825. */
  49826. beta: number;
  49827. /**
  49828. * Defines the radius of the camera from it s target point.
  49829. */
  49830. radius: number;
  49831. protected _target: Vector3;
  49832. protected _targetHost: Nullable<AbstractMesh>;
  49833. /**
  49834. * Defines the target point of the camera.
  49835. * The camera looks towards it form the radius distance.
  49836. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49837. */
  49838. get target(): Vector3;
  49839. set target(value: Vector3);
  49840. /**
  49841. * Define the current local position of the camera in the scene
  49842. */
  49843. get position(): Vector3;
  49844. set position(newPosition: Vector3);
  49845. protected _upToYMatrix: Matrix;
  49846. protected _YToUpMatrix: Matrix;
  49847. /**
  49848. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49849. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49850. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49851. */
  49852. set upVector(vec: Vector3);
  49853. get upVector(): Vector3;
  49854. /**
  49855. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49856. */
  49857. setMatUp(): void;
  49858. /**
  49859. * Current inertia value on the longitudinal axis.
  49860. * The bigger this number the longer it will take for the camera to stop.
  49861. */
  49862. inertialAlphaOffset: number;
  49863. /**
  49864. * Current inertia value on the latitudinal axis.
  49865. * The bigger this number the longer it will take for the camera to stop.
  49866. */
  49867. inertialBetaOffset: number;
  49868. /**
  49869. * Current inertia value on the radius axis.
  49870. * The bigger this number the longer it will take for the camera to stop.
  49871. */
  49872. inertialRadiusOffset: number;
  49873. /**
  49874. * Minimum allowed angle on the longitudinal axis.
  49875. * This can help limiting how the Camera is able to move in the scene.
  49876. */
  49877. lowerAlphaLimit: Nullable<number>;
  49878. /**
  49879. * Maximum allowed angle on the longitudinal axis.
  49880. * This can help limiting how the Camera is able to move in the scene.
  49881. */
  49882. upperAlphaLimit: Nullable<number>;
  49883. /**
  49884. * Minimum allowed angle on the latitudinal axis.
  49885. * This can help limiting how the Camera is able to move in the scene.
  49886. */
  49887. lowerBetaLimit: number;
  49888. /**
  49889. * Maximum allowed angle on the latitudinal axis.
  49890. * This can help limiting how the Camera is able to move in the scene.
  49891. */
  49892. upperBetaLimit: number;
  49893. /**
  49894. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49895. * This can help limiting how the Camera is able to move in the scene.
  49896. */
  49897. lowerRadiusLimit: Nullable<number>;
  49898. /**
  49899. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49900. * This can help limiting how the Camera is able to move in the scene.
  49901. */
  49902. upperRadiusLimit: Nullable<number>;
  49903. /**
  49904. * Defines the current inertia value used during panning of the camera along the X axis.
  49905. */
  49906. inertialPanningX: number;
  49907. /**
  49908. * Defines the current inertia value used during panning of the camera along the Y axis.
  49909. */
  49910. inertialPanningY: number;
  49911. /**
  49912. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49913. * Basically if your fingers moves away from more than this distance you will be considered
  49914. * in pinch mode.
  49915. */
  49916. pinchToPanMaxDistance: number;
  49917. /**
  49918. * Defines the maximum distance the camera can pan.
  49919. * This could help keeping the camera always in your scene.
  49920. */
  49921. panningDistanceLimit: Nullable<number>;
  49922. /**
  49923. * Defines the target of the camera before panning.
  49924. */
  49925. panningOriginTarget: Vector3;
  49926. /**
  49927. * Defines the value of the inertia used during panning.
  49928. * 0 would mean stop inertia and one would mean no decelleration at all.
  49929. */
  49930. panningInertia: number;
  49931. /**
  49932. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49933. */
  49934. get angularSensibilityX(): number;
  49935. set angularSensibilityX(value: number);
  49936. /**
  49937. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49938. */
  49939. get angularSensibilityY(): number;
  49940. set angularSensibilityY(value: number);
  49941. /**
  49942. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49943. */
  49944. get pinchPrecision(): number;
  49945. set pinchPrecision(value: number);
  49946. /**
  49947. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49948. * It will be used instead of pinchDeltaPrecision if different from 0.
  49949. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49950. */
  49951. get pinchDeltaPercentage(): number;
  49952. set pinchDeltaPercentage(value: number);
  49953. /**
  49954. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49955. * and pinch delta percentage.
  49956. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49957. * that any object in the plane at the camera's target point will scale
  49958. * perfectly with finger motion.
  49959. */
  49960. get useNaturalPinchZoom(): boolean;
  49961. set useNaturalPinchZoom(value: boolean);
  49962. /**
  49963. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49964. */
  49965. get panningSensibility(): number;
  49966. set panningSensibility(value: number);
  49967. /**
  49968. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49969. */
  49970. get keysUp(): number[];
  49971. set keysUp(value: number[]);
  49972. /**
  49973. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49974. */
  49975. get keysDown(): number[];
  49976. set keysDown(value: number[]);
  49977. /**
  49978. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49979. */
  49980. get keysLeft(): number[];
  49981. set keysLeft(value: number[]);
  49982. /**
  49983. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49984. */
  49985. get keysRight(): number[];
  49986. set keysRight(value: number[]);
  49987. /**
  49988. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49989. */
  49990. get wheelPrecision(): number;
  49991. set wheelPrecision(value: number);
  49992. /**
  49993. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49994. * It will be used instead of pinchDeltaPrecision if different from 0.
  49995. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49996. */
  49997. get wheelDeltaPercentage(): number;
  49998. set wheelDeltaPercentage(value: number);
  49999. /**
  50000. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50001. */
  50002. zoomOnFactor: number;
  50003. /**
  50004. * Defines a screen offset for the camera position.
  50005. */
  50006. targetScreenOffset: Vector2;
  50007. /**
  50008. * Allows the camera to be completely reversed.
  50009. * If false the camera can not arrive upside down.
  50010. */
  50011. allowUpsideDown: boolean;
  50012. /**
  50013. * Define if double tap/click is used to restore the previously saved state of the camera.
  50014. */
  50015. useInputToRestoreState: boolean;
  50016. /** @hidden */
  50017. _viewMatrix: Matrix;
  50018. /** @hidden */
  50019. _useCtrlForPanning: boolean;
  50020. /** @hidden */
  50021. _panningMouseButton: number;
  50022. /**
  50023. * Defines the input associated to the camera.
  50024. */
  50025. inputs: ArcRotateCameraInputsManager;
  50026. /** @hidden */
  50027. _reset: () => void;
  50028. /**
  50029. * Defines the allowed panning axis.
  50030. */
  50031. panningAxis: Vector3;
  50032. protected _transformedDirection: Vector3;
  50033. private _bouncingBehavior;
  50034. /**
  50035. * Gets the bouncing behavior of the camera if it has been enabled.
  50036. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50037. */
  50038. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50039. /**
  50040. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50041. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50042. */
  50043. get useBouncingBehavior(): boolean;
  50044. set useBouncingBehavior(value: boolean);
  50045. private _framingBehavior;
  50046. /**
  50047. * Gets the framing behavior of the camera if it has been enabled.
  50048. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50049. */
  50050. get framingBehavior(): Nullable<FramingBehavior>;
  50051. /**
  50052. * Defines if the framing behavior of the camera is enabled on the camera.
  50053. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50054. */
  50055. get useFramingBehavior(): boolean;
  50056. set useFramingBehavior(value: boolean);
  50057. private _autoRotationBehavior;
  50058. /**
  50059. * Gets the auto rotation behavior of the camera if it has been enabled.
  50060. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50061. */
  50062. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50063. /**
  50064. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50065. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50066. */
  50067. get useAutoRotationBehavior(): boolean;
  50068. set useAutoRotationBehavior(value: boolean);
  50069. /**
  50070. * Observable triggered when the mesh target has been changed on the camera.
  50071. */
  50072. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50073. /**
  50074. * Event raised when the camera is colliding with a mesh.
  50075. */
  50076. onCollide: (collidedMesh: AbstractMesh) => void;
  50077. /**
  50078. * Defines whether the camera should check collision with the objects oh the scene.
  50079. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50080. */
  50081. checkCollisions: boolean;
  50082. /**
  50083. * Defines the collision radius of the camera.
  50084. * This simulates a sphere around the camera.
  50085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50086. */
  50087. collisionRadius: Vector3;
  50088. protected _collider: Collider;
  50089. protected _previousPosition: Vector3;
  50090. protected _collisionVelocity: Vector3;
  50091. protected _newPosition: Vector3;
  50092. protected _previousAlpha: number;
  50093. protected _previousBeta: number;
  50094. protected _previousRadius: number;
  50095. protected _collisionTriggered: boolean;
  50096. protected _targetBoundingCenter: Nullable<Vector3>;
  50097. private _computationVector;
  50098. /**
  50099. * Instantiates a new ArcRotateCamera in a given scene
  50100. * @param name Defines the name of the camera
  50101. * @param alpha Defines the camera rotation along the longitudinal axis
  50102. * @param beta Defines the camera rotation along the latitudinal axis
  50103. * @param radius Defines the camera distance from its target
  50104. * @param target Defines the camera target
  50105. * @param scene Defines the scene the camera belongs to
  50106. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50107. */
  50108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50109. /** @hidden */
  50110. _initCache(): void;
  50111. /** @hidden */
  50112. _updateCache(ignoreParentClass?: boolean): void;
  50113. protected _getTargetPosition(): Vector3;
  50114. private _storedAlpha;
  50115. private _storedBeta;
  50116. private _storedRadius;
  50117. private _storedTarget;
  50118. private _storedTargetScreenOffset;
  50119. /**
  50120. * Stores the current state of the camera (alpha, beta, radius and target)
  50121. * @returns the camera itself
  50122. */
  50123. storeState(): Camera;
  50124. /**
  50125. * @hidden
  50126. * Restored camera state. You must call storeState() first
  50127. */
  50128. _restoreStateValues(): boolean;
  50129. /** @hidden */
  50130. _isSynchronizedViewMatrix(): boolean;
  50131. /**
  50132. * Attach the input controls to a specific dom element to get the input from.
  50133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50134. */
  50135. attachControl(noPreventDefault?: boolean): void;
  50136. /**
  50137. * Attach the input controls to a specific dom element to get the input from.
  50138. * @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
  50139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50140. */
  50141. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50142. /**
  50143. * Attached controls to the current camera.
  50144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50145. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50146. */
  50147. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50148. /**
  50149. * Attached controls to the current camera.
  50150. * @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
  50151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50152. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50153. */
  50154. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50155. /**
  50156. * Attached controls to the current camera.
  50157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50158. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50159. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50160. */
  50161. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50162. /**
  50163. * Detach the current controls from the specified dom element.
  50164. */
  50165. detachControl(): void;
  50166. /**
  50167. * Detach the current controls from the specified dom element.
  50168. * @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
  50169. */
  50170. detachControl(ignored: any): void;
  50171. /** @hidden */
  50172. _checkInputs(): void;
  50173. protected _checkLimits(): void;
  50174. /**
  50175. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50176. */
  50177. rebuildAnglesAndRadius(): void;
  50178. /**
  50179. * Use a position to define the current camera related information like alpha, beta and radius
  50180. * @param position Defines the position to set the camera at
  50181. */
  50182. setPosition(position: Vector3): void;
  50183. /**
  50184. * Defines the target the camera should look at.
  50185. * This will automatically adapt alpha beta and radius to fit within the new target.
  50186. * @param target Defines the new target as a Vector or a mesh
  50187. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50188. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50189. */
  50190. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50191. /** @hidden */
  50192. _getViewMatrix(): Matrix;
  50193. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50194. /**
  50195. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50196. * @param meshes Defines the mesh to zoom on
  50197. * @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)
  50198. */
  50199. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50200. /**
  50201. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50202. * The target will be changed but the radius
  50203. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50204. * @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)
  50205. */
  50206. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50207. min: Vector3;
  50208. max: Vector3;
  50209. distance: number;
  50210. }, doNotUpdateMaxZ?: boolean): void;
  50211. /**
  50212. * @override
  50213. * Override Camera.createRigCamera
  50214. */
  50215. createRigCamera(name: string, cameraIndex: number): Camera;
  50216. /**
  50217. * @hidden
  50218. * @override
  50219. * Override Camera._updateRigCameras
  50220. */
  50221. _updateRigCameras(): void;
  50222. /**
  50223. * Destroy the camera and release the current resources hold by it.
  50224. */
  50225. dispose(): void;
  50226. /**
  50227. * Gets the current object class name.
  50228. * @return the class name
  50229. */
  50230. getClassName(): string;
  50231. }
  50232. }
  50233. declare module BABYLON {
  50234. /**
  50235. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50236. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50237. */
  50238. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50239. /**
  50240. * Gets the name of the behavior.
  50241. */
  50242. get name(): string;
  50243. private _zoomStopsAnimation;
  50244. private _idleRotationSpeed;
  50245. private _idleRotationWaitTime;
  50246. private _idleRotationSpinupTime;
  50247. /**
  50248. * Sets the flag that indicates if user zooming should stop animation.
  50249. */
  50250. set zoomStopsAnimation(flag: boolean);
  50251. /**
  50252. * Gets the flag that indicates if user zooming should stop animation.
  50253. */
  50254. get zoomStopsAnimation(): boolean;
  50255. /**
  50256. * Sets the default speed at which the camera rotates around the model.
  50257. */
  50258. set idleRotationSpeed(speed: number);
  50259. /**
  50260. * Gets the default speed at which the camera rotates around the model.
  50261. */
  50262. get idleRotationSpeed(): number;
  50263. /**
  50264. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50265. */
  50266. set idleRotationWaitTime(time: number);
  50267. /**
  50268. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50269. */
  50270. get idleRotationWaitTime(): number;
  50271. /**
  50272. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50273. */
  50274. set idleRotationSpinupTime(time: number);
  50275. /**
  50276. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50277. */
  50278. get idleRotationSpinupTime(): number;
  50279. /**
  50280. * Gets a value indicating if the camera is currently rotating because of this behavior
  50281. */
  50282. get rotationInProgress(): boolean;
  50283. private _onPrePointerObservableObserver;
  50284. private _onAfterCheckInputsObserver;
  50285. private _attachedCamera;
  50286. private _isPointerDown;
  50287. private _lastFrameTime;
  50288. private _lastInteractionTime;
  50289. private _cameraRotationSpeed;
  50290. /**
  50291. * Initializes the behavior.
  50292. */
  50293. init(): void;
  50294. /**
  50295. * Attaches the behavior to its arc rotate camera.
  50296. * @param camera Defines the camera to attach the behavior to
  50297. */
  50298. attach(camera: ArcRotateCamera): void;
  50299. /**
  50300. * Detaches the behavior from its current arc rotate camera.
  50301. */
  50302. detach(): void;
  50303. /**
  50304. * Returns true if user is scrolling.
  50305. * @return true if user is scrolling.
  50306. */
  50307. private _userIsZooming;
  50308. private _lastFrameRadius;
  50309. private _shouldAnimationStopForInteraction;
  50310. /**
  50311. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50312. */
  50313. private _applyUserInteraction;
  50314. private _userIsMoving;
  50315. }
  50316. }
  50317. declare module BABYLON {
  50318. /**
  50319. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50320. */
  50321. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50322. private ui;
  50323. /**
  50324. * The name of the behavior
  50325. */
  50326. name: string;
  50327. /**
  50328. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50329. */
  50330. distanceAwayFromFace: number;
  50331. /**
  50332. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50333. */
  50334. distanceAwayFromBottomOfFace: number;
  50335. private _faceVectors;
  50336. private _target;
  50337. private _scene;
  50338. private _onRenderObserver;
  50339. private _tmpMatrix;
  50340. private _tmpVector;
  50341. /**
  50342. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50343. * @param ui The transform node that should be attached to the mesh
  50344. */
  50345. constructor(ui: TransformNode);
  50346. /**
  50347. * Initializes the behavior
  50348. */
  50349. init(): void;
  50350. private _closestFace;
  50351. private _zeroVector;
  50352. private _lookAtTmpMatrix;
  50353. private _lookAtToRef;
  50354. /**
  50355. * Attaches the AttachToBoxBehavior to the passed in mesh
  50356. * @param target The mesh that the specified node will be attached to
  50357. */
  50358. attach(target: Mesh): void;
  50359. /**
  50360. * Detaches the behavior from the mesh
  50361. */
  50362. detach(): void;
  50363. }
  50364. }
  50365. declare module BABYLON {
  50366. /**
  50367. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50368. */
  50369. export class FadeInOutBehavior implements Behavior<Mesh> {
  50370. /**
  50371. * Time in milliseconds to delay before fading in (Default: 0)
  50372. */
  50373. delay: number;
  50374. /**
  50375. * Time in milliseconds for the mesh to fade in (Default: 300)
  50376. */
  50377. fadeInTime: number;
  50378. private _millisecondsPerFrame;
  50379. private _hovered;
  50380. private _hoverValue;
  50381. private _ownerNode;
  50382. /**
  50383. * Instantiates the FadeInOutBehavior
  50384. */
  50385. constructor();
  50386. /**
  50387. * The name of the behavior
  50388. */
  50389. get name(): string;
  50390. /**
  50391. * Initializes the behavior
  50392. */
  50393. init(): void;
  50394. /**
  50395. * Attaches the fade behavior on the passed in mesh
  50396. * @param ownerNode The mesh that will be faded in/out once attached
  50397. */
  50398. attach(ownerNode: Mesh): void;
  50399. /**
  50400. * Detaches the behavior from the mesh
  50401. */
  50402. detach(): void;
  50403. /**
  50404. * Triggers the mesh to begin fading in or out
  50405. * @param value if the object should fade in or out (true to fade in)
  50406. */
  50407. fadeIn(value: boolean): void;
  50408. private _update;
  50409. private _setAllVisibility;
  50410. }
  50411. }
  50412. declare module BABYLON {
  50413. /**
  50414. * Class containing a set of static utilities functions for managing Pivots
  50415. * @hidden
  50416. */
  50417. export class PivotTools {
  50418. private static _PivotCached;
  50419. private static _OldPivotPoint;
  50420. private static _PivotTranslation;
  50421. private static _PivotTmpVector;
  50422. private static _PivotPostMultiplyPivotMatrix;
  50423. /** @hidden */
  50424. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50425. /** @hidden */
  50426. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50427. }
  50428. }
  50429. declare module BABYLON {
  50430. /**
  50431. * Class containing static functions to help procedurally build meshes
  50432. */
  50433. export class PlaneBuilder {
  50434. /**
  50435. * Creates a plane mesh
  50436. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50437. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50438. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50440. * * 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
  50441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50442. * @param name defines the name of the mesh
  50443. * @param options defines the options used to create the mesh
  50444. * @param scene defines the hosting scene
  50445. * @returns the plane mesh
  50446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50447. */
  50448. static CreatePlane(name: string, options: {
  50449. size?: number;
  50450. width?: number;
  50451. height?: number;
  50452. sideOrientation?: number;
  50453. frontUVs?: Vector4;
  50454. backUVs?: Vector4;
  50455. updatable?: boolean;
  50456. sourcePlane?: Plane;
  50457. }, scene?: Nullable<Scene>): Mesh;
  50458. }
  50459. }
  50460. declare module BABYLON {
  50461. /**
  50462. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50463. */
  50464. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50465. private static _AnyMouseID;
  50466. /**
  50467. * Abstract mesh the behavior is set on
  50468. */
  50469. attachedNode: AbstractMesh;
  50470. private _dragPlane;
  50471. private _scene;
  50472. private _pointerObserver;
  50473. private _beforeRenderObserver;
  50474. private static _planeScene;
  50475. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50476. /**
  50477. * 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)
  50478. */
  50479. maxDragAngle: number;
  50480. /**
  50481. * @hidden
  50482. */
  50483. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50484. /**
  50485. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50486. */
  50487. currentDraggingPointerID: number;
  50488. /**
  50489. * The last position where the pointer hit the drag plane in world space
  50490. */
  50491. lastDragPosition: Vector3;
  50492. /**
  50493. * If the behavior is currently in a dragging state
  50494. */
  50495. dragging: boolean;
  50496. /**
  50497. * 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)
  50498. */
  50499. dragDeltaRatio: number;
  50500. /**
  50501. * If the drag plane orientation should be updated during the dragging (Default: true)
  50502. */
  50503. updateDragPlane: boolean;
  50504. private _debugMode;
  50505. private _moving;
  50506. /**
  50507. * Fires each time the attached mesh is dragged with the pointer
  50508. * * delta between last drag position and current drag position in world space
  50509. * * dragDistance along the drag axis
  50510. * * dragPlaneNormal normal of the current drag plane used during the drag
  50511. * * dragPlanePoint in world space where the drag intersects the drag plane
  50512. */
  50513. onDragObservable: Observable<{
  50514. delta: Vector3;
  50515. dragPlanePoint: Vector3;
  50516. dragPlaneNormal: Vector3;
  50517. dragDistance: number;
  50518. pointerId: number;
  50519. }>;
  50520. /**
  50521. * Fires each time a drag begins (eg. mouse down on mesh)
  50522. */
  50523. onDragStartObservable: Observable<{
  50524. dragPlanePoint: Vector3;
  50525. pointerId: number;
  50526. }>;
  50527. /**
  50528. * Fires each time a drag ends (eg. mouse release after drag)
  50529. */
  50530. onDragEndObservable: Observable<{
  50531. dragPlanePoint: Vector3;
  50532. pointerId: number;
  50533. }>;
  50534. /**
  50535. * If the attached mesh should be moved when dragged
  50536. */
  50537. moveAttached: boolean;
  50538. /**
  50539. * If the drag behavior will react to drag events (Default: true)
  50540. */
  50541. enabled: boolean;
  50542. /**
  50543. * If pointer events should start and release the drag (Default: true)
  50544. */
  50545. startAndReleaseDragOnPointerEvents: boolean;
  50546. /**
  50547. * If camera controls should be detached during the drag
  50548. */
  50549. detachCameraControls: boolean;
  50550. /**
  50551. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50552. */
  50553. useObjectOrientationForDragging: boolean;
  50554. private _options;
  50555. /**
  50556. * Gets the options used by the behavior
  50557. */
  50558. get options(): {
  50559. dragAxis?: Vector3;
  50560. dragPlaneNormal?: Vector3;
  50561. };
  50562. /**
  50563. * Sets the options used by the behavior
  50564. */
  50565. set options(options: {
  50566. dragAxis?: Vector3;
  50567. dragPlaneNormal?: Vector3;
  50568. });
  50569. /**
  50570. * Creates a pointer drag behavior that can be attached to a mesh
  50571. * @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)
  50572. */
  50573. constructor(options?: {
  50574. dragAxis?: Vector3;
  50575. dragPlaneNormal?: Vector3;
  50576. });
  50577. /**
  50578. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50579. */
  50580. validateDrag: (targetPosition: Vector3) => boolean;
  50581. /**
  50582. * The name of the behavior
  50583. */
  50584. get name(): string;
  50585. /**
  50586. * Initializes the behavior
  50587. */
  50588. init(): void;
  50589. private _tmpVector;
  50590. private _alternatePickedPoint;
  50591. private _worldDragAxis;
  50592. private _targetPosition;
  50593. private _attachedToElement;
  50594. /**
  50595. * Attaches the drag behavior the passed in mesh
  50596. * @param ownerNode The mesh that will be dragged around once attached
  50597. * @param predicate Predicate to use for pick filtering
  50598. */
  50599. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50600. /**
  50601. * Force release the drag action by code.
  50602. */
  50603. releaseDrag(): void;
  50604. private _startDragRay;
  50605. private _lastPointerRay;
  50606. /**
  50607. * Simulates the start of a pointer drag event on the behavior
  50608. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50609. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50610. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50611. */
  50612. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50613. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50614. private _dragDelta;
  50615. protected _moveDrag(ray: Ray): void;
  50616. private _pickWithRayOnDragPlane;
  50617. private _pointA;
  50618. private _pointC;
  50619. private _localAxis;
  50620. private _lookAt;
  50621. private _updateDragPlanePosition;
  50622. /**
  50623. * Detaches the behavior from the mesh
  50624. */
  50625. detach(): void;
  50626. }
  50627. }
  50628. declare module BABYLON {
  50629. /**
  50630. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50631. */
  50632. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50633. private _dragBehaviorA;
  50634. private _dragBehaviorB;
  50635. private _startDistance;
  50636. private _initialScale;
  50637. private _targetScale;
  50638. private _ownerNode;
  50639. private _sceneRenderObserver;
  50640. /**
  50641. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50642. */
  50643. constructor();
  50644. /**
  50645. * The name of the behavior
  50646. */
  50647. get name(): string;
  50648. /**
  50649. * Initializes the behavior
  50650. */
  50651. init(): void;
  50652. private _getCurrentDistance;
  50653. /**
  50654. * Attaches the scale behavior the passed in mesh
  50655. * @param ownerNode The mesh that will be scaled around once attached
  50656. */
  50657. attach(ownerNode: Mesh): void;
  50658. /**
  50659. * Detaches the behavior from the mesh
  50660. */
  50661. detach(): void;
  50662. }
  50663. }
  50664. declare module BABYLON {
  50665. /**
  50666. * 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
  50667. */
  50668. export class SixDofDragBehavior implements Behavior<Mesh> {
  50669. private static _virtualScene;
  50670. private _ownerNode;
  50671. private _sceneRenderObserver;
  50672. private _scene;
  50673. private _targetPosition;
  50674. private _virtualOriginMesh;
  50675. private _virtualDragMesh;
  50676. private _pointerObserver;
  50677. private _moving;
  50678. private _startingOrientation;
  50679. private _attachedToElement;
  50680. /**
  50681. * 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)
  50682. */
  50683. private zDragFactor;
  50684. /**
  50685. * If the object should rotate to face the drag origin
  50686. */
  50687. rotateDraggedObject: boolean;
  50688. /**
  50689. * If the behavior is currently in a dragging state
  50690. */
  50691. dragging: boolean;
  50692. /**
  50693. * 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)
  50694. */
  50695. dragDeltaRatio: number;
  50696. /**
  50697. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50698. */
  50699. currentDraggingPointerID: number;
  50700. /**
  50701. * If camera controls should be detached during the drag
  50702. */
  50703. detachCameraControls: boolean;
  50704. /**
  50705. * Fires each time a drag starts
  50706. */
  50707. onDragStartObservable: Observable<{}>;
  50708. /**
  50709. * Fires each time a drag happens
  50710. */
  50711. onDragObservable: Observable<void>;
  50712. /**
  50713. * Fires each time a drag ends (eg. mouse release after drag)
  50714. */
  50715. onDragEndObservable: Observable<{}>;
  50716. /**
  50717. * 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
  50718. */
  50719. constructor();
  50720. /**
  50721. * The name of the behavior
  50722. */
  50723. get name(): string;
  50724. /**
  50725. * Initializes the behavior
  50726. */
  50727. init(): void;
  50728. /**
  50729. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50730. */
  50731. private get _pointerCamera();
  50732. /**
  50733. * Attaches the scale behavior the passed in mesh
  50734. * @param ownerNode The mesh that will be scaled around once attached
  50735. */
  50736. attach(ownerNode: Mesh): void;
  50737. /**
  50738. * Detaches the behavior from the mesh
  50739. */
  50740. detach(): void;
  50741. }
  50742. }
  50743. declare module BABYLON {
  50744. /**
  50745. * Class used to apply inverse kinematics to bones
  50746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50747. */
  50748. export class BoneIKController {
  50749. private static _tmpVecs;
  50750. private static _tmpQuat;
  50751. private static _tmpMats;
  50752. /**
  50753. * Gets or sets the target mesh
  50754. */
  50755. targetMesh: AbstractMesh;
  50756. /** Gets or sets the mesh used as pole */
  50757. poleTargetMesh: AbstractMesh;
  50758. /**
  50759. * Gets or sets the bone used as pole
  50760. */
  50761. poleTargetBone: Nullable<Bone>;
  50762. /**
  50763. * Gets or sets the target position
  50764. */
  50765. targetPosition: Vector3;
  50766. /**
  50767. * Gets or sets the pole target position
  50768. */
  50769. poleTargetPosition: Vector3;
  50770. /**
  50771. * Gets or sets the pole target local offset
  50772. */
  50773. poleTargetLocalOffset: Vector3;
  50774. /**
  50775. * Gets or sets the pole angle
  50776. */
  50777. poleAngle: number;
  50778. /**
  50779. * Gets or sets the mesh associated with the controller
  50780. */
  50781. mesh: AbstractMesh;
  50782. /**
  50783. * 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)
  50784. */
  50785. slerpAmount: number;
  50786. private _bone1Quat;
  50787. private _bone1Mat;
  50788. private _bone2Ang;
  50789. private _bone1;
  50790. private _bone2;
  50791. private _bone1Length;
  50792. private _bone2Length;
  50793. private _maxAngle;
  50794. private _maxReach;
  50795. private _rightHandedSystem;
  50796. private _bendAxis;
  50797. private _slerping;
  50798. private _adjustRoll;
  50799. /**
  50800. * Gets or sets maximum allowed angle
  50801. */
  50802. get maxAngle(): number;
  50803. set maxAngle(value: number);
  50804. /**
  50805. * Creates a new BoneIKController
  50806. * @param mesh defines the mesh to control
  50807. * @param bone defines the bone to control
  50808. * @param options defines options to set up the controller
  50809. */
  50810. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50811. targetMesh?: AbstractMesh;
  50812. poleTargetMesh?: AbstractMesh;
  50813. poleTargetBone?: Bone;
  50814. poleTargetLocalOffset?: Vector3;
  50815. poleAngle?: number;
  50816. bendAxis?: Vector3;
  50817. maxAngle?: number;
  50818. slerpAmount?: number;
  50819. });
  50820. private _setMaxAngle;
  50821. /**
  50822. * Force the controller to update the bones
  50823. */
  50824. update(): void;
  50825. }
  50826. }
  50827. declare module BABYLON {
  50828. /**
  50829. * Class used to make a bone look toward a point in space
  50830. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50831. */
  50832. export class BoneLookController {
  50833. private static _tmpVecs;
  50834. private static _tmpQuat;
  50835. private static _tmpMats;
  50836. /**
  50837. * The target Vector3 that the bone will look at
  50838. */
  50839. target: Vector3;
  50840. /**
  50841. * The mesh that the bone is attached to
  50842. */
  50843. mesh: AbstractMesh;
  50844. /**
  50845. * The bone that will be looking to the target
  50846. */
  50847. bone: Bone;
  50848. /**
  50849. * The up axis of the coordinate system that is used when the bone is rotated
  50850. */
  50851. upAxis: Vector3;
  50852. /**
  50853. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50854. */
  50855. upAxisSpace: Space;
  50856. /**
  50857. * Used to make an adjustment to the yaw of the bone
  50858. */
  50859. adjustYaw: number;
  50860. /**
  50861. * Used to make an adjustment to the pitch of the bone
  50862. */
  50863. adjustPitch: number;
  50864. /**
  50865. * Used to make an adjustment to the roll of the bone
  50866. */
  50867. adjustRoll: number;
  50868. /**
  50869. * 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)
  50870. */
  50871. slerpAmount: number;
  50872. private _minYaw;
  50873. private _maxYaw;
  50874. private _minPitch;
  50875. private _maxPitch;
  50876. private _minYawSin;
  50877. private _minYawCos;
  50878. private _maxYawSin;
  50879. private _maxYawCos;
  50880. private _midYawConstraint;
  50881. private _minPitchTan;
  50882. private _maxPitchTan;
  50883. private _boneQuat;
  50884. private _slerping;
  50885. private _transformYawPitch;
  50886. private _transformYawPitchInv;
  50887. private _firstFrameSkipped;
  50888. private _yawRange;
  50889. private _fowardAxis;
  50890. /**
  50891. * Gets or sets the minimum yaw angle that the bone can look to
  50892. */
  50893. get minYaw(): number;
  50894. set minYaw(value: number);
  50895. /**
  50896. * Gets or sets the maximum yaw angle that the bone can look to
  50897. */
  50898. get maxYaw(): number;
  50899. set maxYaw(value: number);
  50900. /**
  50901. * Gets or sets the minimum pitch angle that the bone can look to
  50902. */
  50903. get minPitch(): number;
  50904. set minPitch(value: number);
  50905. /**
  50906. * Gets or sets the maximum pitch angle that the bone can look to
  50907. */
  50908. get maxPitch(): number;
  50909. set maxPitch(value: number);
  50910. /**
  50911. * Create a BoneLookController
  50912. * @param mesh the mesh that the bone belongs to
  50913. * @param bone the bone that will be looking to the target
  50914. * @param target the target Vector3 to look at
  50915. * @param options optional settings:
  50916. * * maxYaw: the maximum angle the bone will yaw to
  50917. * * minYaw: the minimum angle the bone will yaw to
  50918. * * maxPitch: the maximum angle the bone will pitch to
  50919. * * minPitch: the minimum angle the bone will yaw to
  50920. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50921. * * upAxis: the up axis of the coordinate system
  50922. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50923. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50924. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50925. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50926. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50927. * * adjustRoll: used to make an adjustment to the roll of the bone
  50928. **/
  50929. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50930. maxYaw?: number;
  50931. minYaw?: number;
  50932. maxPitch?: number;
  50933. minPitch?: number;
  50934. slerpAmount?: number;
  50935. upAxis?: Vector3;
  50936. upAxisSpace?: Space;
  50937. yawAxis?: Vector3;
  50938. pitchAxis?: Vector3;
  50939. adjustYaw?: number;
  50940. adjustPitch?: number;
  50941. adjustRoll?: number;
  50942. });
  50943. /**
  50944. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50945. */
  50946. update(): void;
  50947. private _getAngleDiff;
  50948. private _getAngleBetween;
  50949. private _isAngleBetween;
  50950. }
  50951. }
  50952. declare module BABYLON {
  50953. /**
  50954. * Manage the gamepad inputs to control an arc rotate camera.
  50955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50956. */
  50957. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50958. /**
  50959. * Defines the camera the input is attached to.
  50960. */
  50961. camera: ArcRotateCamera;
  50962. /**
  50963. * Defines the gamepad the input is gathering event from.
  50964. */
  50965. gamepad: Nullable<Gamepad>;
  50966. /**
  50967. * Defines the gamepad rotation sensiblity.
  50968. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50969. */
  50970. gamepadRotationSensibility: number;
  50971. /**
  50972. * Defines the gamepad move sensiblity.
  50973. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50974. */
  50975. gamepadMoveSensibility: number;
  50976. private _yAxisScale;
  50977. /**
  50978. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50979. */
  50980. get invertYAxis(): boolean;
  50981. set invertYAxis(value: boolean);
  50982. private _onGamepadConnectedObserver;
  50983. private _onGamepadDisconnectedObserver;
  50984. /**
  50985. * Attach the input controls to a specific dom element to get the input from.
  50986. */
  50987. attachControl(): void;
  50988. /**
  50989. * Detach the current controls from the specified dom element.
  50990. */
  50991. detachControl(): void;
  50992. /**
  50993. * Update the current camera state depending on the inputs that have been used this frame.
  50994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50995. */
  50996. checkInputs(): void;
  50997. /**
  50998. * Gets the class name of the current intput.
  50999. * @returns the class name
  51000. */
  51001. getClassName(): string;
  51002. /**
  51003. * Get the friendly name associated with the input class.
  51004. * @returns the input friendly name
  51005. */
  51006. getSimpleName(): string;
  51007. }
  51008. }
  51009. declare module BABYLON {
  51010. interface ArcRotateCameraInputsManager {
  51011. /**
  51012. * Add orientation input support to the input manager.
  51013. * @returns the current input manager
  51014. */
  51015. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51016. }
  51017. /**
  51018. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51019. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51020. */
  51021. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51022. /**
  51023. * Defines the camera the input is attached to.
  51024. */
  51025. camera: ArcRotateCamera;
  51026. /**
  51027. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51028. */
  51029. alphaCorrection: number;
  51030. /**
  51031. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51032. */
  51033. gammaCorrection: number;
  51034. private _alpha;
  51035. private _gamma;
  51036. private _dirty;
  51037. private _deviceOrientationHandler;
  51038. /**
  51039. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51040. */
  51041. constructor();
  51042. /**
  51043. * Attach the input controls to a specific dom element to get the input from.
  51044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51045. */
  51046. attachControl(noPreventDefault?: boolean): void;
  51047. /** @hidden */
  51048. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51049. /**
  51050. * Update the current camera state depending on the inputs that have been used this frame.
  51051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51052. */
  51053. checkInputs(): void;
  51054. /**
  51055. * Detach the current controls from the specified dom element.
  51056. */
  51057. detachControl(): void;
  51058. /**
  51059. * Gets the class name of the current input.
  51060. * @returns the class name
  51061. */
  51062. getClassName(): string;
  51063. /**
  51064. * Get the friendly name associated with the input class.
  51065. * @returns the input friendly name
  51066. */
  51067. getSimpleName(): string;
  51068. }
  51069. }
  51070. declare module BABYLON {
  51071. /**
  51072. * Listen to mouse events to control the camera.
  51073. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51074. */
  51075. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51076. /**
  51077. * Defines the camera the input is attached to.
  51078. */
  51079. camera: FlyCamera;
  51080. /**
  51081. * Defines if touch is enabled. (Default is true.)
  51082. */
  51083. touchEnabled: boolean;
  51084. /**
  51085. * Defines the buttons associated with the input to handle camera rotation.
  51086. */
  51087. buttons: number[];
  51088. /**
  51089. * Assign buttons for Yaw control.
  51090. */
  51091. buttonsYaw: number[];
  51092. /**
  51093. * Assign buttons for Pitch control.
  51094. */
  51095. buttonsPitch: number[];
  51096. /**
  51097. * Assign buttons for Roll control.
  51098. */
  51099. buttonsRoll: number[];
  51100. /**
  51101. * Detect if any button is being pressed while mouse is moved.
  51102. * -1 = Mouse locked.
  51103. * 0 = Left button.
  51104. * 1 = Middle Button.
  51105. * 2 = Right Button.
  51106. */
  51107. activeButton: number;
  51108. /**
  51109. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51110. * Higher values reduce its sensitivity.
  51111. */
  51112. angularSensibility: number;
  51113. private _observer;
  51114. private _rollObserver;
  51115. private previousPosition;
  51116. private noPreventDefault;
  51117. private element;
  51118. /**
  51119. * Listen to mouse events to control the camera.
  51120. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51122. */
  51123. constructor(touchEnabled?: boolean);
  51124. /**
  51125. * Attach the mouse control to the HTML DOM element.
  51126. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51127. */
  51128. attachControl(noPreventDefault?: boolean): void;
  51129. /**
  51130. * Detach the current controls from the specified dom element.
  51131. */
  51132. detachControl(): void;
  51133. /**
  51134. * Gets the class name of the current input.
  51135. * @returns the class name.
  51136. */
  51137. getClassName(): string;
  51138. /**
  51139. * Get the friendly name associated with the input class.
  51140. * @returns the input's friendly name.
  51141. */
  51142. getSimpleName(): string;
  51143. private _pointerInput;
  51144. private _onMouseMove;
  51145. /**
  51146. * Rotate camera by mouse offset.
  51147. */
  51148. private rotateCamera;
  51149. }
  51150. }
  51151. declare module BABYLON {
  51152. /**
  51153. * Default Inputs manager for the FlyCamera.
  51154. * It groups all the default supported inputs for ease of use.
  51155. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51156. */
  51157. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51158. /**
  51159. * Instantiates a new FlyCameraInputsManager.
  51160. * @param camera Defines the camera the inputs belong to.
  51161. */
  51162. constructor(camera: FlyCamera);
  51163. /**
  51164. * Add keyboard input support to the input manager.
  51165. * @returns the new FlyCameraKeyboardMoveInput().
  51166. */
  51167. addKeyboard(): FlyCameraInputsManager;
  51168. /**
  51169. * Add mouse input support to the input manager.
  51170. * @param touchEnabled Enable touch screen support.
  51171. * @returns the new FlyCameraMouseInput().
  51172. */
  51173. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51174. }
  51175. }
  51176. declare module BABYLON {
  51177. /**
  51178. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51179. * such as in a 3D Space Shooter or a Flight Simulator.
  51180. */
  51181. export class FlyCamera extends TargetCamera {
  51182. /**
  51183. * Define the collision ellipsoid of the camera.
  51184. * This is helpful for simulating a camera body, like a player's body.
  51185. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51186. */
  51187. ellipsoid: Vector3;
  51188. /**
  51189. * Define an offset for the position of the ellipsoid around the camera.
  51190. * This can be helpful if the camera is attached away from the player's body center,
  51191. * such as at its head.
  51192. */
  51193. ellipsoidOffset: Vector3;
  51194. /**
  51195. * Enable or disable collisions of the camera with the rest of the scene objects.
  51196. */
  51197. checkCollisions: boolean;
  51198. /**
  51199. * Enable or disable gravity on the camera.
  51200. */
  51201. applyGravity: boolean;
  51202. /**
  51203. * Define the current direction the camera is moving to.
  51204. */
  51205. cameraDirection: Vector3;
  51206. /**
  51207. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51208. * This overrides and empties cameraRotation.
  51209. */
  51210. rotationQuaternion: Quaternion;
  51211. /**
  51212. * Track Roll to maintain the wanted Rolling when looking around.
  51213. */
  51214. _trackRoll: number;
  51215. /**
  51216. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51217. */
  51218. rollCorrect: number;
  51219. /**
  51220. * Mimic a banked turn, Rolling the camera when Yawing.
  51221. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51222. */
  51223. bankedTurn: boolean;
  51224. /**
  51225. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51226. */
  51227. bankedTurnLimit: number;
  51228. /**
  51229. * Value of 0 disables the banked Roll.
  51230. * Value of 1 is equal to the Yaw angle in radians.
  51231. */
  51232. bankedTurnMultiplier: number;
  51233. /**
  51234. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51235. */
  51236. inputs: FlyCameraInputsManager;
  51237. /**
  51238. * Gets the input sensibility for mouse input.
  51239. * Higher values reduce sensitivity.
  51240. */
  51241. get angularSensibility(): number;
  51242. /**
  51243. * Sets the input sensibility for a mouse input.
  51244. * Higher values reduce sensitivity.
  51245. */
  51246. set angularSensibility(value: number);
  51247. /**
  51248. * Get the keys for camera movement forward.
  51249. */
  51250. get keysForward(): number[];
  51251. /**
  51252. * Set the keys for camera movement forward.
  51253. */
  51254. set keysForward(value: number[]);
  51255. /**
  51256. * Get the keys for camera movement backward.
  51257. */
  51258. get keysBackward(): number[];
  51259. set keysBackward(value: number[]);
  51260. /**
  51261. * Get the keys for camera movement up.
  51262. */
  51263. get keysUp(): number[];
  51264. /**
  51265. * Set the keys for camera movement up.
  51266. */
  51267. set keysUp(value: number[]);
  51268. /**
  51269. * Get the keys for camera movement down.
  51270. */
  51271. get keysDown(): number[];
  51272. /**
  51273. * Set the keys for camera movement down.
  51274. */
  51275. set keysDown(value: number[]);
  51276. /**
  51277. * Get the keys for camera movement left.
  51278. */
  51279. get keysLeft(): number[];
  51280. /**
  51281. * Set the keys for camera movement left.
  51282. */
  51283. set keysLeft(value: number[]);
  51284. /**
  51285. * Set the keys for camera movement right.
  51286. */
  51287. get keysRight(): number[];
  51288. /**
  51289. * Set the keys for camera movement right.
  51290. */
  51291. set keysRight(value: number[]);
  51292. /**
  51293. * Event raised when the camera collides with a mesh in the scene.
  51294. */
  51295. onCollide: (collidedMesh: AbstractMesh) => void;
  51296. private _collider;
  51297. private _needMoveForGravity;
  51298. private _oldPosition;
  51299. private _diffPosition;
  51300. private _newPosition;
  51301. /** @hidden */
  51302. _localDirection: Vector3;
  51303. /** @hidden */
  51304. _transformedDirection: Vector3;
  51305. /**
  51306. * Instantiates a FlyCamera.
  51307. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51308. * such as in a 3D Space Shooter or a Flight Simulator.
  51309. * @param name Define the name of the camera in the scene.
  51310. * @param position Define the starting position of the camera in the scene.
  51311. * @param scene Define the scene the camera belongs to.
  51312. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51313. */
  51314. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51315. /**
  51316. * Attach the input controls to a specific dom element to get the input from.
  51317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51318. */
  51319. attachControl(noPreventDefault?: boolean): void;
  51320. /**
  51321. * Detach a control from the HTML DOM element.
  51322. * The camera will stop reacting to that input.
  51323. */
  51324. detachControl(): void;
  51325. private _collisionMask;
  51326. /**
  51327. * Get the mask that the camera ignores in collision events.
  51328. */
  51329. get collisionMask(): number;
  51330. /**
  51331. * Set the mask that the camera ignores in collision events.
  51332. */
  51333. set collisionMask(mask: number);
  51334. /** @hidden */
  51335. _collideWithWorld(displacement: Vector3): void;
  51336. /** @hidden */
  51337. private _onCollisionPositionChange;
  51338. /** @hidden */
  51339. _checkInputs(): void;
  51340. /** @hidden */
  51341. _decideIfNeedsToMove(): boolean;
  51342. /** @hidden */
  51343. _updatePosition(): void;
  51344. /**
  51345. * Restore the Roll to its target value at the rate specified.
  51346. * @param rate - Higher means slower restoring.
  51347. * @hidden
  51348. */
  51349. restoreRoll(rate: number): void;
  51350. /**
  51351. * Destroy the camera and release the current resources held by it.
  51352. */
  51353. dispose(): void;
  51354. /**
  51355. * Get the current object class name.
  51356. * @returns the class name.
  51357. */
  51358. getClassName(): string;
  51359. }
  51360. }
  51361. declare module BABYLON {
  51362. /**
  51363. * Listen to keyboard events to control the camera.
  51364. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51365. */
  51366. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51367. /**
  51368. * Defines the camera the input is attached to.
  51369. */
  51370. camera: FlyCamera;
  51371. /**
  51372. * The list of keyboard keys used to control the forward move of the camera.
  51373. */
  51374. keysForward: number[];
  51375. /**
  51376. * The list of keyboard keys used to control the backward move of the camera.
  51377. */
  51378. keysBackward: number[];
  51379. /**
  51380. * The list of keyboard keys used to control the forward move of the camera.
  51381. */
  51382. keysUp: number[];
  51383. /**
  51384. * The list of keyboard keys used to control the backward move of the camera.
  51385. */
  51386. keysDown: number[];
  51387. /**
  51388. * The list of keyboard keys used to control the right strafe move of the camera.
  51389. */
  51390. keysRight: number[];
  51391. /**
  51392. * The list of keyboard keys used to control the left strafe move of the camera.
  51393. */
  51394. keysLeft: number[];
  51395. private _keys;
  51396. private _onCanvasBlurObserver;
  51397. private _onKeyboardObserver;
  51398. private _engine;
  51399. private _scene;
  51400. /**
  51401. * Attach the input controls to a specific dom element to get the input from.
  51402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51403. */
  51404. attachControl(noPreventDefault?: boolean): void;
  51405. /**
  51406. * Detach the current controls from the specified dom element.
  51407. */
  51408. detachControl(): void;
  51409. /**
  51410. * Gets the class name of the current intput.
  51411. * @returns the class name
  51412. */
  51413. getClassName(): string;
  51414. /** @hidden */
  51415. _onLostFocus(e: FocusEvent): void;
  51416. /**
  51417. * Get the friendly name associated with the input class.
  51418. * @returns the input friendly name
  51419. */
  51420. getSimpleName(): string;
  51421. /**
  51422. * Update the current camera state depending on the inputs that have been used this frame.
  51423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51424. */
  51425. checkInputs(): void;
  51426. }
  51427. }
  51428. declare module BABYLON {
  51429. /**
  51430. * Manage the mouse wheel inputs to control a follow camera.
  51431. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51432. */
  51433. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51434. /**
  51435. * Defines the camera the input is attached to.
  51436. */
  51437. camera: FollowCamera;
  51438. /**
  51439. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51440. */
  51441. axisControlRadius: boolean;
  51442. /**
  51443. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51444. */
  51445. axisControlHeight: boolean;
  51446. /**
  51447. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51448. */
  51449. axisControlRotation: boolean;
  51450. /**
  51451. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51452. * relation to mouseWheel events.
  51453. */
  51454. wheelPrecision: number;
  51455. /**
  51456. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51457. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51458. */
  51459. wheelDeltaPercentage: number;
  51460. private _wheel;
  51461. private _observer;
  51462. /**
  51463. * Attach the input controls to a specific dom element to get the input from.
  51464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51465. */
  51466. attachControl(noPreventDefault?: boolean): void;
  51467. /**
  51468. * Detach the current controls from the specified dom element.
  51469. */
  51470. detachControl(): void;
  51471. /**
  51472. * Gets the class name of the current input.
  51473. * @returns the class name
  51474. */
  51475. getClassName(): string;
  51476. /**
  51477. * Get the friendly name associated with the input class.
  51478. * @returns the input friendly name
  51479. */
  51480. getSimpleName(): string;
  51481. }
  51482. }
  51483. declare module BABYLON {
  51484. /**
  51485. * Manage the pointers inputs to control an follow camera.
  51486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51487. */
  51488. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51489. /**
  51490. * Defines the camera the input is attached to.
  51491. */
  51492. camera: FollowCamera;
  51493. /**
  51494. * Gets the class name of the current input.
  51495. * @returns the class name
  51496. */
  51497. getClassName(): string;
  51498. /**
  51499. * Defines the pointer angular sensibility along the X axis or how fast is
  51500. * the camera rotating.
  51501. * A negative number will reverse the axis direction.
  51502. */
  51503. angularSensibilityX: number;
  51504. /**
  51505. * Defines the pointer angular sensibility along the Y axis or how fast is
  51506. * the camera rotating.
  51507. * A negative number will reverse the axis direction.
  51508. */
  51509. angularSensibilityY: number;
  51510. /**
  51511. * Defines the pointer pinch precision or how fast is the camera zooming.
  51512. * A negative number will reverse the axis direction.
  51513. */
  51514. pinchPrecision: number;
  51515. /**
  51516. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51517. * from 0.
  51518. * It defines the percentage of current camera.radius to use as delta when
  51519. * pinch zoom is used.
  51520. */
  51521. pinchDeltaPercentage: number;
  51522. /**
  51523. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51524. */
  51525. axisXControlRadius: boolean;
  51526. /**
  51527. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51528. */
  51529. axisXControlHeight: boolean;
  51530. /**
  51531. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51532. */
  51533. axisXControlRotation: boolean;
  51534. /**
  51535. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51536. */
  51537. axisYControlRadius: boolean;
  51538. /**
  51539. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51540. */
  51541. axisYControlHeight: boolean;
  51542. /**
  51543. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51544. */
  51545. axisYControlRotation: boolean;
  51546. /**
  51547. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51548. */
  51549. axisPinchControlRadius: boolean;
  51550. /**
  51551. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51552. */
  51553. axisPinchControlHeight: boolean;
  51554. /**
  51555. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51556. */
  51557. axisPinchControlRotation: boolean;
  51558. /**
  51559. * Log error messages if basic misconfiguration has occurred.
  51560. */
  51561. warningEnable: boolean;
  51562. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51563. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51564. private _warningCounter;
  51565. private _warning;
  51566. }
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Default Inputs manager for the FollowCamera.
  51571. * It groups all the default supported inputs for ease of use.
  51572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51573. */
  51574. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51575. /**
  51576. * Instantiates a new FollowCameraInputsManager.
  51577. * @param camera Defines the camera the inputs belong to
  51578. */
  51579. constructor(camera: FollowCamera);
  51580. /**
  51581. * Add keyboard input support to the input manager.
  51582. * @returns the current input manager
  51583. */
  51584. addKeyboard(): FollowCameraInputsManager;
  51585. /**
  51586. * Add mouse wheel input support to the input manager.
  51587. * @returns the current input manager
  51588. */
  51589. addMouseWheel(): FollowCameraInputsManager;
  51590. /**
  51591. * Add pointers input support to the input manager.
  51592. * @returns the current input manager
  51593. */
  51594. addPointers(): FollowCameraInputsManager;
  51595. /**
  51596. * Add orientation input support to the input manager.
  51597. * @returns the current input manager
  51598. */
  51599. addVRDeviceOrientation(): FollowCameraInputsManager;
  51600. }
  51601. }
  51602. declare module BABYLON {
  51603. /**
  51604. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51605. * an arc rotate version arcFollowCamera are available.
  51606. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51607. */
  51608. export class FollowCamera extends TargetCamera {
  51609. /**
  51610. * Distance the follow camera should follow an object at
  51611. */
  51612. radius: number;
  51613. /**
  51614. * Minimum allowed distance of the camera to the axis of rotation
  51615. * (The camera can not get closer).
  51616. * This can help limiting how the Camera is able to move in the scene.
  51617. */
  51618. lowerRadiusLimit: Nullable<number>;
  51619. /**
  51620. * Maximum allowed distance of the camera to the axis of rotation
  51621. * (The camera can not get further).
  51622. * This can help limiting how the Camera is able to move in the scene.
  51623. */
  51624. upperRadiusLimit: Nullable<number>;
  51625. /**
  51626. * Define a rotation offset between the camera and the object it follows
  51627. */
  51628. rotationOffset: number;
  51629. /**
  51630. * Minimum allowed angle to camera position relative to target object.
  51631. * This can help limiting how the Camera is able to move in the scene.
  51632. */
  51633. lowerRotationOffsetLimit: Nullable<number>;
  51634. /**
  51635. * Maximum allowed angle to camera position relative to target object.
  51636. * This can help limiting how the Camera is able to move in the scene.
  51637. */
  51638. upperRotationOffsetLimit: Nullable<number>;
  51639. /**
  51640. * Define a height offset between the camera and the object it follows.
  51641. * It can help following an object from the top (like a car chasing a plane)
  51642. */
  51643. heightOffset: number;
  51644. /**
  51645. * Minimum allowed height of camera position relative to target object.
  51646. * This can help limiting how the Camera is able to move in the scene.
  51647. */
  51648. lowerHeightOffsetLimit: Nullable<number>;
  51649. /**
  51650. * Maximum allowed height of camera position relative to target object.
  51651. * This can help limiting how the Camera is able to move in the scene.
  51652. */
  51653. upperHeightOffsetLimit: Nullable<number>;
  51654. /**
  51655. * Define how fast the camera can accelerate to follow it s target.
  51656. */
  51657. cameraAcceleration: number;
  51658. /**
  51659. * Define the speed limit of the camera following an object.
  51660. */
  51661. maxCameraSpeed: number;
  51662. /**
  51663. * Define the target of the camera.
  51664. */
  51665. lockedTarget: Nullable<AbstractMesh>;
  51666. /**
  51667. * Defines the input associated with the camera.
  51668. */
  51669. inputs: FollowCameraInputsManager;
  51670. /**
  51671. * Instantiates the follow camera.
  51672. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51673. * @param name Define the name of the camera in the scene
  51674. * @param position Define the position of the camera
  51675. * @param scene Define the scene the camera belong to
  51676. * @param lockedTarget Define the target of the camera
  51677. */
  51678. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51679. private _follow;
  51680. /**
  51681. * Attach the input controls to a specific dom element to get the input from.
  51682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51683. */
  51684. attachControl(noPreventDefault?: boolean): void;
  51685. /**
  51686. * Detach the current controls from the specified dom element.
  51687. */
  51688. detachControl(): void;
  51689. /** @hidden */
  51690. _checkInputs(): void;
  51691. private _checkLimits;
  51692. /**
  51693. * Gets the camera class name.
  51694. * @returns the class name
  51695. */
  51696. getClassName(): string;
  51697. }
  51698. /**
  51699. * Arc Rotate version of the follow camera.
  51700. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51701. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51702. */
  51703. export class ArcFollowCamera extends TargetCamera {
  51704. /** The longitudinal angle of the camera */
  51705. alpha: number;
  51706. /** The latitudinal angle of the camera */
  51707. beta: number;
  51708. /** The radius of the camera from its target */
  51709. radius: number;
  51710. private _cartesianCoordinates;
  51711. /** Define the camera target (the mesh it should follow) */
  51712. private _meshTarget;
  51713. /**
  51714. * Instantiates a new ArcFollowCamera
  51715. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51716. * @param name Define the name of the camera
  51717. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51718. * @param beta Define the rotation angle of the camera around the elevation axis
  51719. * @param radius Define the radius of the camera from its target point
  51720. * @param target Define the target of the camera
  51721. * @param scene Define the scene the camera belongs to
  51722. */
  51723. constructor(name: string,
  51724. /** The longitudinal angle of the camera */
  51725. alpha: number,
  51726. /** The latitudinal angle of the camera */
  51727. beta: number,
  51728. /** The radius of the camera from its target */
  51729. radius: number,
  51730. /** Define the camera target (the mesh it should follow) */
  51731. target: Nullable<AbstractMesh>, scene: Scene);
  51732. private _follow;
  51733. /** @hidden */
  51734. _checkInputs(): void;
  51735. /**
  51736. * Returns the class name of the object.
  51737. * It is mostly used internally for serialization purposes.
  51738. */
  51739. getClassName(): string;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Manage the keyboard inputs to control the movement of a follow camera.
  51745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51746. */
  51747. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51748. /**
  51749. * Defines the camera the input is attached to.
  51750. */
  51751. camera: FollowCamera;
  51752. /**
  51753. * Defines the list of key codes associated with the up action (increase heightOffset)
  51754. */
  51755. keysHeightOffsetIncr: number[];
  51756. /**
  51757. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51758. */
  51759. keysHeightOffsetDecr: number[];
  51760. /**
  51761. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51762. */
  51763. keysHeightOffsetModifierAlt: boolean;
  51764. /**
  51765. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51766. */
  51767. keysHeightOffsetModifierCtrl: boolean;
  51768. /**
  51769. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51770. */
  51771. keysHeightOffsetModifierShift: boolean;
  51772. /**
  51773. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51774. */
  51775. keysRotationOffsetIncr: number[];
  51776. /**
  51777. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51778. */
  51779. keysRotationOffsetDecr: number[];
  51780. /**
  51781. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51782. */
  51783. keysRotationOffsetModifierAlt: boolean;
  51784. /**
  51785. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51786. */
  51787. keysRotationOffsetModifierCtrl: boolean;
  51788. /**
  51789. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51790. */
  51791. keysRotationOffsetModifierShift: boolean;
  51792. /**
  51793. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51794. */
  51795. keysRadiusIncr: number[];
  51796. /**
  51797. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51798. */
  51799. keysRadiusDecr: number[];
  51800. /**
  51801. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51802. */
  51803. keysRadiusModifierAlt: boolean;
  51804. /**
  51805. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51806. */
  51807. keysRadiusModifierCtrl: boolean;
  51808. /**
  51809. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51810. */
  51811. keysRadiusModifierShift: boolean;
  51812. /**
  51813. * Defines the rate of change of heightOffset.
  51814. */
  51815. heightSensibility: number;
  51816. /**
  51817. * Defines the rate of change of rotationOffset.
  51818. */
  51819. rotationSensibility: number;
  51820. /**
  51821. * Defines the rate of change of radius.
  51822. */
  51823. radiusSensibility: number;
  51824. private _keys;
  51825. private _ctrlPressed;
  51826. private _altPressed;
  51827. private _shiftPressed;
  51828. private _onCanvasBlurObserver;
  51829. private _onKeyboardObserver;
  51830. private _engine;
  51831. private _scene;
  51832. /**
  51833. * Attach the input controls to a specific dom element to get the input from.
  51834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51835. */
  51836. attachControl(noPreventDefault?: boolean): void;
  51837. /**
  51838. * Detach the current controls from the specified dom element.
  51839. */
  51840. detachControl(): void;
  51841. /**
  51842. * Update the current camera state depending on the inputs that have been used this frame.
  51843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51844. */
  51845. checkInputs(): void;
  51846. /**
  51847. * Gets the class name of the current input.
  51848. * @returns the class name
  51849. */
  51850. getClassName(): string;
  51851. /**
  51852. * Get the friendly name associated with the input class.
  51853. * @returns the input friendly name
  51854. */
  51855. getSimpleName(): string;
  51856. /**
  51857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51858. * allow modification of the heightOffset value.
  51859. */
  51860. private _modifierHeightOffset;
  51861. /**
  51862. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51863. * allow modification of the rotationOffset value.
  51864. */
  51865. private _modifierRotationOffset;
  51866. /**
  51867. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51868. * allow modification of the radius value.
  51869. */
  51870. private _modifierRadius;
  51871. }
  51872. }
  51873. declare module BABYLON {
  51874. interface FreeCameraInputsManager {
  51875. /**
  51876. * @hidden
  51877. */
  51878. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51879. /**
  51880. * Add orientation input support to the input manager.
  51881. * @returns the current input manager
  51882. */
  51883. addDeviceOrientation(): FreeCameraInputsManager;
  51884. }
  51885. /**
  51886. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51887. * Screen rotation is taken into account.
  51888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51889. */
  51890. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51891. private _camera;
  51892. private _screenOrientationAngle;
  51893. private _constantTranform;
  51894. private _screenQuaternion;
  51895. private _alpha;
  51896. private _beta;
  51897. private _gamma;
  51898. /**
  51899. * Can be used to detect if a device orientation sensor is available on a device
  51900. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51901. * @returns a promise that will resolve on orientation change
  51902. */
  51903. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51904. /**
  51905. * @hidden
  51906. */
  51907. _onDeviceOrientationChangedObservable: Observable<void>;
  51908. /**
  51909. * Instantiates a new input
  51910. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51911. */
  51912. constructor();
  51913. /**
  51914. * Define the camera controlled by the input.
  51915. */
  51916. get camera(): FreeCamera;
  51917. set camera(camera: FreeCamera);
  51918. /**
  51919. * Attach the input controls to a specific dom element to get the input from.
  51920. */
  51921. attachControl(): void;
  51922. private _orientationChanged;
  51923. private _deviceOrientation;
  51924. /**
  51925. * Detach the current controls from the specified dom element.
  51926. */
  51927. detachControl(): void;
  51928. /**
  51929. * Update the current camera state depending on the inputs that have been used this frame.
  51930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51931. */
  51932. checkInputs(): void;
  51933. /**
  51934. * Gets the class name of the current input.
  51935. * @returns the class name
  51936. */
  51937. getClassName(): string;
  51938. /**
  51939. * Get the friendly name associated with the input class.
  51940. * @returns the input friendly name
  51941. */
  51942. getSimpleName(): string;
  51943. }
  51944. }
  51945. declare module BABYLON {
  51946. /**
  51947. * Manage the gamepad inputs to control a free camera.
  51948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51949. */
  51950. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51951. /**
  51952. * Define the camera the input is attached to.
  51953. */
  51954. camera: FreeCamera;
  51955. /**
  51956. * Define the Gamepad controlling the input
  51957. */
  51958. gamepad: Nullable<Gamepad>;
  51959. /**
  51960. * Defines the gamepad rotation sensiblity.
  51961. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51962. */
  51963. gamepadAngularSensibility: number;
  51964. /**
  51965. * Defines the gamepad move sensiblity.
  51966. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51967. */
  51968. gamepadMoveSensibility: number;
  51969. private _yAxisScale;
  51970. /**
  51971. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51972. */
  51973. get invertYAxis(): boolean;
  51974. set invertYAxis(value: boolean);
  51975. private _onGamepadConnectedObserver;
  51976. private _onGamepadDisconnectedObserver;
  51977. private _cameraTransform;
  51978. private _deltaTransform;
  51979. private _vector3;
  51980. private _vector2;
  51981. /**
  51982. * Attach the input controls to a specific dom element to get the input from.
  51983. */
  51984. attachControl(): void;
  51985. /**
  51986. * Detach the current controls from the specified dom element.
  51987. */
  51988. detachControl(): void;
  51989. /**
  51990. * Update the current camera state depending on the inputs that have been used this frame.
  51991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51992. */
  51993. checkInputs(): void;
  51994. /**
  51995. * Gets the class name of the current input.
  51996. * @returns the class name
  51997. */
  51998. getClassName(): string;
  51999. /**
  52000. * Get the friendly name associated with the input class.
  52001. * @returns the input friendly name
  52002. */
  52003. getSimpleName(): string;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Defines the potential axis of a Joystick
  52009. */
  52010. export enum JoystickAxis {
  52011. /** X axis */
  52012. X = 0,
  52013. /** Y axis */
  52014. Y = 1,
  52015. /** Z axis */
  52016. Z = 2
  52017. }
  52018. /**
  52019. * Represents the different customization options available
  52020. * for VirtualJoystick
  52021. */
  52022. interface VirtualJoystickCustomizations {
  52023. /**
  52024. * Size of the joystick's puck
  52025. */
  52026. puckSize: number;
  52027. /**
  52028. * Size of the joystick's container
  52029. */
  52030. containerSize: number;
  52031. /**
  52032. * Color of the joystick && puck
  52033. */
  52034. color: string;
  52035. /**
  52036. * Image URL for the joystick's puck
  52037. */
  52038. puckImage?: string;
  52039. /**
  52040. * Image URL for the joystick's container
  52041. */
  52042. containerImage?: string;
  52043. /**
  52044. * Defines the unmoving position of the joystick container
  52045. */
  52046. position?: {
  52047. x: number;
  52048. y: number;
  52049. };
  52050. /**
  52051. * Defines whether or not the joystick container is always visible
  52052. */
  52053. alwaysVisible: boolean;
  52054. /**
  52055. * Defines whether or not to limit the movement of the puck to the joystick's container
  52056. */
  52057. limitToContainer: boolean;
  52058. }
  52059. /**
  52060. * Class used to define virtual joystick (used in touch mode)
  52061. */
  52062. export class VirtualJoystick {
  52063. /**
  52064. * Gets or sets a boolean indicating that left and right values must be inverted
  52065. */
  52066. reverseLeftRight: boolean;
  52067. /**
  52068. * Gets or sets a boolean indicating that up and down values must be inverted
  52069. */
  52070. reverseUpDown: boolean;
  52071. /**
  52072. * Gets the offset value for the position (ie. the change of the position value)
  52073. */
  52074. deltaPosition: Vector3;
  52075. /**
  52076. * Gets a boolean indicating if the virtual joystick was pressed
  52077. */
  52078. pressed: boolean;
  52079. /**
  52080. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52081. */
  52082. static Canvas: Nullable<HTMLCanvasElement>;
  52083. /**
  52084. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52085. */
  52086. limitToContainer: boolean;
  52087. private static _globalJoystickIndex;
  52088. private static _alwaysVisibleSticks;
  52089. private static vjCanvasContext;
  52090. private static vjCanvasWidth;
  52091. private static vjCanvasHeight;
  52092. private static halfWidth;
  52093. private static _GetDefaultOptions;
  52094. private _action;
  52095. private _axisTargetedByLeftAndRight;
  52096. private _axisTargetedByUpAndDown;
  52097. private _joystickSensibility;
  52098. private _inversedSensibility;
  52099. private _joystickPointerID;
  52100. private _joystickColor;
  52101. private _joystickPointerPos;
  52102. private _joystickPreviousPointerPos;
  52103. private _joystickPointerStartPos;
  52104. private _deltaJoystickVector;
  52105. private _leftJoystick;
  52106. private _touches;
  52107. private _joystickPosition;
  52108. private _alwaysVisible;
  52109. private _puckImage;
  52110. private _containerImage;
  52111. private _joystickPuckSize;
  52112. private _joystickContainerSize;
  52113. private _clearPuckSize;
  52114. private _clearContainerSize;
  52115. private _clearPuckSizeOffset;
  52116. private _clearContainerSizeOffset;
  52117. private _onPointerDownHandlerRef;
  52118. private _onPointerMoveHandlerRef;
  52119. private _onPointerUpHandlerRef;
  52120. private _onResize;
  52121. /**
  52122. * Creates a new virtual joystick
  52123. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52124. * @param customizations Defines the options we want to customize the VirtualJoystick
  52125. */
  52126. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52127. /**
  52128. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52129. * @param newJoystickSensibility defines the new sensibility
  52130. */
  52131. setJoystickSensibility(newJoystickSensibility: number): void;
  52132. private _onPointerDown;
  52133. private _onPointerMove;
  52134. private _onPointerUp;
  52135. /**
  52136. * Change the color of the virtual joystick
  52137. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52138. */
  52139. setJoystickColor(newColor: string): void;
  52140. /**
  52141. * Size of the joystick's container
  52142. */
  52143. set containerSize(newSize: number);
  52144. get containerSize(): number;
  52145. /**
  52146. * Size of the joystick's puck
  52147. */
  52148. set puckSize(newSize: number);
  52149. get puckSize(): number;
  52150. /**
  52151. * Clears the set position of the joystick
  52152. */
  52153. clearPosition(): void;
  52154. /**
  52155. * Defines whether or not the joystick container is always visible
  52156. */
  52157. set alwaysVisible(value: boolean);
  52158. get alwaysVisible(): boolean;
  52159. /**
  52160. * Sets the constant position of the Joystick container
  52161. * @param x X axis coordinate
  52162. * @param y Y axis coordinate
  52163. */
  52164. setPosition(x: number, y: number): void;
  52165. /**
  52166. * Defines a callback to call when the joystick is touched
  52167. * @param action defines the callback
  52168. */
  52169. setActionOnTouch(action: () => any): void;
  52170. /**
  52171. * Defines which axis you'd like to control for left & right
  52172. * @param axis defines the axis to use
  52173. */
  52174. setAxisForLeftRight(axis: JoystickAxis): void;
  52175. /**
  52176. * Defines which axis you'd like to control for up & down
  52177. * @param axis defines the axis to use
  52178. */
  52179. setAxisForUpDown(axis: JoystickAxis): void;
  52180. /**
  52181. * Clears the canvas from the previous puck / container draw
  52182. */
  52183. private _clearPreviousDraw;
  52184. /**
  52185. * Loads `urlPath` to be used for the container's image
  52186. * @param urlPath defines the urlPath of an image to use
  52187. */
  52188. setContainerImage(urlPath: string): void;
  52189. /**
  52190. * Loads `urlPath` to be used for the puck's image
  52191. * @param urlPath defines the urlPath of an image to use
  52192. */
  52193. setPuckImage(urlPath: string): void;
  52194. /**
  52195. * Draws the Virtual Joystick's container
  52196. */
  52197. private _drawContainer;
  52198. /**
  52199. * Draws the Virtual Joystick's puck
  52200. */
  52201. private _drawPuck;
  52202. private _drawVirtualJoystick;
  52203. /**
  52204. * Release internal HTML canvas
  52205. */
  52206. releaseCanvas(): void;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. interface FreeCameraInputsManager {
  52211. /**
  52212. * Add virtual joystick input support to the input manager.
  52213. * @returns the current input manager
  52214. */
  52215. addVirtualJoystick(): FreeCameraInputsManager;
  52216. }
  52217. /**
  52218. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52219. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52220. */
  52221. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52222. /**
  52223. * Defines the camera the input is attached to.
  52224. */
  52225. camera: FreeCamera;
  52226. private _leftjoystick;
  52227. private _rightjoystick;
  52228. /**
  52229. * Gets the left stick of the virtual joystick.
  52230. * @returns The virtual Joystick
  52231. */
  52232. getLeftJoystick(): VirtualJoystick;
  52233. /**
  52234. * Gets the right stick of the virtual joystick.
  52235. * @returns The virtual Joystick
  52236. */
  52237. getRightJoystick(): VirtualJoystick;
  52238. /**
  52239. * Update the current camera state depending on the inputs that have been used this frame.
  52240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52241. */
  52242. checkInputs(): void;
  52243. /**
  52244. * Attach the input controls to a specific dom element to get the input from.
  52245. */
  52246. attachControl(): void;
  52247. /**
  52248. * Detach the current controls from the specified dom element.
  52249. */
  52250. detachControl(): void;
  52251. /**
  52252. * Gets the class name of the current input.
  52253. * @returns the class name
  52254. */
  52255. getClassName(): string;
  52256. /**
  52257. * Get the friendly name associated with the input class.
  52258. * @returns the input friendly name
  52259. */
  52260. getSimpleName(): string;
  52261. }
  52262. }
  52263. declare module BABYLON {
  52264. /**
  52265. * This represents a FPS type of camera controlled by touch.
  52266. * This is like a universal camera minus the Gamepad controls.
  52267. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52268. */
  52269. export class TouchCamera extends FreeCamera {
  52270. /**
  52271. * Defines the touch sensibility for rotation.
  52272. * The higher the faster.
  52273. */
  52274. get touchAngularSensibility(): number;
  52275. set touchAngularSensibility(value: number);
  52276. /**
  52277. * Defines the touch sensibility for move.
  52278. * The higher the faster.
  52279. */
  52280. get touchMoveSensibility(): number;
  52281. set touchMoveSensibility(value: number);
  52282. /**
  52283. * Instantiates a new touch camera.
  52284. * This represents a FPS type of camera controlled by touch.
  52285. * This is like a universal camera minus the Gamepad controls.
  52286. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52287. * @param name Define the name of the camera in the scene
  52288. * @param position Define the start position of the camera in the scene
  52289. * @param scene Define the scene the camera belongs to
  52290. */
  52291. constructor(name: string, position: Vector3, scene: Scene);
  52292. /**
  52293. * Gets the current object class name.
  52294. * @return the class name
  52295. */
  52296. getClassName(): string;
  52297. /** @hidden */
  52298. _setupInputs(): void;
  52299. }
  52300. }
  52301. declare module BABYLON {
  52302. /**
  52303. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52304. * being tilted forward or back and left or right.
  52305. */
  52306. export class DeviceOrientationCamera extends FreeCamera {
  52307. private _initialQuaternion;
  52308. private _quaternionCache;
  52309. private _tmpDragQuaternion;
  52310. private _disablePointerInputWhenUsingDeviceOrientation;
  52311. /**
  52312. * Creates a new device orientation camera
  52313. * @param name The name of the camera
  52314. * @param position The start position camera
  52315. * @param scene The scene the camera belongs to
  52316. */
  52317. constructor(name: string, position: Vector3, scene: Scene);
  52318. /**
  52319. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52320. */
  52321. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52322. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52323. private _dragFactor;
  52324. /**
  52325. * Enabled turning on the y axis when the orientation sensor is active
  52326. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52327. */
  52328. enableHorizontalDragging(dragFactor?: number): void;
  52329. /**
  52330. * Gets the current instance class name ("DeviceOrientationCamera").
  52331. * This helps avoiding instanceof at run time.
  52332. * @returns the class name
  52333. */
  52334. getClassName(): string;
  52335. /**
  52336. * @hidden
  52337. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52338. */
  52339. _checkInputs(): void;
  52340. /**
  52341. * Reset the camera to its default orientation on the specified axis only.
  52342. * @param axis The axis to reset
  52343. */
  52344. resetToCurrentRotation(axis?: Axis): void;
  52345. }
  52346. }
  52347. declare module BABYLON {
  52348. /**
  52349. * Defines supported buttons for XBox360 compatible gamepads
  52350. */
  52351. export enum Xbox360Button {
  52352. /** A */
  52353. A = 0,
  52354. /** B */
  52355. B = 1,
  52356. /** X */
  52357. X = 2,
  52358. /** Y */
  52359. Y = 3,
  52360. /** Left button */
  52361. LB = 4,
  52362. /** Right button */
  52363. RB = 5,
  52364. /** Back */
  52365. Back = 8,
  52366. /** Start */
  52367. Start = 9,
  52368. /** Left stick */
  52369. LeftStick = 10,
  52370. /** Right stick */
  52371. RightStick = 11
  52372. }
  52373. /** Defines values for XBox360 DPad */
  52374. export enum Xbox360Dpad {
  52375. /** Up */
  52376. Up = 12,
  52377. /** Down */
  52378. Down = 13,
  52379. /** Left */
  52380. Left = 14,
  52381. /** Right */
  52382. Right = 15
  52383. }
  52384. /**
  52385. * Defines a XBox360 gamepad
  52386. */
  52387. export class Xbox360Pad extends Gamepad {
  52388. private _leftTrigger;
  52389. private _rightTrigger;
  52390. private _onlefttriggerchanged;
  52391. private _onrighttriggerchanged;
  52392. private _onbuttondown;
  52393. private _onbuttonup;
  52394. private _ondpaddown;
  52395. private _ondpadup;
  52396. /** Observable raised when a button is pressed */
  52397. onButtonDownObservable: Observable<Xbox360Button>;
  52398. /** Observable raised when a button is released */
  52399. onButtonUpObservable: Observable<Xbox360Button>;
  52400. /** Observable raised when a pad is pressed */
  52401. onPadDownObservable: Observable<Xbox360Dpad>;
  52402. /** Observable raised when a pad is released */
  52403. onPadUpObservable: Observable<Xbox360Dpad>;
  52404. private _buttonA;
  52405. private _buttonB;
  52406. private _buttonX;
  52407. private _buttonY;
  52408. private _buttonBack;
  52409. private _buttonStart;
  52410. private _buttonLB;
  52411. private _buttonRB;
  52412. private _buttonLeftStick;
  52413. private _buttonRightStick;
  52414. private _dPadUp;
  52415. private _dPadDown;
  52416. private _dPadLeft;
  52417. private _dPadRight;
  52418. private _isXboxOnePad;
  52419. /**
  52420. * Creates a new XBox360 gamepad object
  52421. * @param id defines the id of this gamepad
  52422. * @param index defines its index
  52423. * @param gamepad defines the internal HTML gamepad object
  52424. * @param xboxOne defines if it is a XBox One gamepad
  52425. */
  52426. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52427. /**
  52428. * Defines the callback to call when left trigger is pressed
  52429. * @param callback defines the callback to use
  52430. */
  52431. onlefttriggerchanged(callback: (value: number) => void): void;
  52432. /**
  52433. * Defines the callback to call when right trigger is pressed
  52434. * @param callback defines the callback to use
  52435. */
  52436. onrighttriggerchanged(callback: (value: number) => void): void;
  52437. /**
  52438. * Gets the left trigger value
  52439. */
  52440. get leftTrigger(): number;
  52441. /**
  52442. * Sets the left trigger value
  52443. */
  52444. set leftTrigger(newValue: number);
  52445. /**
  52446. * Gets the right trigger value
  52447. */
  52448. get rightTrigger(): number;
  52449. /**
  52450. * Sets the right trigger value
  52451. */
  52452. set rightTrigger(newValue: number);
  52453. /**
  52454. * Defines the callback to call when a button is pressed
  52455. * @param callback defines the callback to use
  52456. */
  52457. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52458. /**
  52459. * Defines the callback to call when a button is released
  52460. * @param callback defines the callback to use
  52461. */
  52462. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52463. /**
  52464. * Defines the callback to call when a pad is pressed
  52465. * @param callback defines the callback to use
  52466. */
  52467. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52468. /**
  52469. * Defines the callback to call when a pad is released
  52470. * @param callback defines the callback to use
  52471. */
  52472. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52473. private _setButtonValue;
  52474. private _setDPadValue;
  52475. /**
  52476. * Gets the value of the `A` button
  52477. */
  52478. get buttonA(): number;
  52479. /**
  52480. * Sets the value of the `A` button
  52481. */
  52482. set buttonA(value: number);
  52483. /**
  52484. * Gets the value of the `B` button
  52485. */
  52486. get buttonB(): number;
  52487. /**
  52488. * Sets the value of the `B` button
  52489. */
  52490. set buttonB(value: number);
  52491. /**
  52492. * Gets the value of the `X` button
  52493. */
  52494. get buttonX(): number;
  52495. /**
  52496. * Sets the value of the `X` button
  52497. */
  52498. set buttonX(value: number);
  52499. /**
  52500. * Gets the value of the `Y` button
  52501. */
  52502. get buttonY(): number;
  52503. /**
  52504. * Sets the value of the `Y` button
  52505. */
  52506. set buttonY(value: number);
  52507. /**
  52508. * Gets the value of the `Start` button
  52509. */
  52510. get buttonStart(): number;
  52511. /**
  52512. * Sets the value of the `Start` button
  52513. */
  52514. set buttonStart(value: number);
  52515. /**
  52516. * Gets the value of the `Back` button
  52517. */
  52518. get buttonBack(): number;
  52519. /**
  52520. * Sets the value of the `Back` button
  52521. */
  52522. set buttonBack(value: number);
  52523. /**
  52524. * Gets the value of the `Left` button
  52525. */
  52526. get buttonLB(): number;
  52527. /**
  52528. * Sets the value of the `Left` button
  52529. */
  52530. set buttonLB(value: number);
  52531. /**
  52532. * Gets the value of the `Right` button
  52533. */
  52534. get buttonRB(): number;
  52535. /**
  52536. * Sets the value of the `Right` button
  52537. */
  52538. set buttonRB(value: number);
  52539. /**
  52540. * Gets the value of the Left joystick
  52541. */
  52542. get buttonLeftStick(): number;
  52543. /**
  52544. * Sets the value of the Left joystick
  52545. */
  52546. set buttonLeftStick(value: number);
  52547. /**
  52548. * Gets the value of the Right joystick
  52549. */
  52550. get buttonRightStick(): number;
  52551. /**
  52552. * Sets the value of the Right joystick
  52553. */
  52554. set buttonRightStick(value: number);
  52555. /**
  52556. * Gets the value of D-pad up
  52557. */
  52558. get dPadUp(): number;
  52559. /**
  52560. * Sets the value of D-pad up
  52561. */
  52562. set dPadUp(value: number);
  52563. /**
  52564. * Gets the value of D-pad down
  52565. */
  52566. get dPadDown(): number;
  52567. /**
  52568. * Sets the value of D-pad down
  52569. */
  52570. set dPadDown(value: number);
  52571. /**
  52572. * Gets the value of D-pad left
  52573. */
  52574. get dPadLeft(): number;
  52575. /**
  52576. * Sets the value of D-pad left
  52577. */
  52578. set dPadLeft(value: number);
  52579. /**
  52580. * Gets the value of D-pad right
  52581. */
  52582. get dPadRight(): number;
  52583. /**
  52584. * Sets the value of D-pad right
  52585. */
  52586. set dPadRight(value: number);
  52587. /**
  52588. * Force the gamepad to synchronize with device values
  52589. */
  52590. update(): void;
  52591. /**
  52592. * Disposes the gamepad
  52593. */
  52594. dispose(): void;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Defines supported buttons for DualShock compatible gamepads
  52600. */
  52601. export enum DualShockButton {
  52602. /** Cross */
  52603. Cross = 0,
  52604. /** Circle */
  52605. Circle = 1,
  52606. /** Square */
  52607. Square = 2,
  52608. /** Triangle */
  52609. Triangle = 3,
  52610. /** L1 */
  52611. L1 = 4,
  52612. /** R1 */
  52613. R1 = 5,
  52614. /** Share */
  52615. Share = 8,
  52616. /** Options */
  52617. Options = 9,
  52618. /** Left stick */
  52619. LeftStick = 10,
  52620. /** Right stick */
  52621. RightStick = 11
  52622. }
  52623. /** Defines values for DualShock DPad */
  52624. export enum DualShockDpad {
  52625. /** Up */
  52626. Up = 12,
  52627. /** Down */
  52628. Down = 13,
  52629. /** Left */
  52630. Left = 14,
  52631. /** Right */
  52632. Right = 15
  52633. }
  52634. /**
  52635. * Defines a DualShock gamepad
  52636. */
  52637. export class DualShockPad extends Gamepad {
  52638. private _leftTrigger;
  52639. private _rightTrigger;
  52640. private _onlefttriggerchanged;
  52641. private _onrighttriggerchanged;
  52642. private _onbuttondown;
  52643. private _onbuttonup;
  52644. private _ondpaddown;
  52645. private _ondpadup;
  52646. /** Observable raised when a button is pressed */
  52647. onButtonDownObservable: Observable<DualShockButton>;
  52648. /** Observable raised when a button is released */
  52649. onButtonUpObservable: Observable<DualShockButton>;
  52650. /** Observable raised when a pad is pressed */
  52651. onPadDownObservable: Observable<DualShockDpad>;
  52652. /** Observable raised when a pad is released */
  52653. onPadUpObservable: Observable<DualShockDpad>;
  52654. private _buttonCross;
  52655. private _buttonCircle;
  52656. private _buttonSquare;
  52657. private _buttonTriangle;
  52658. private _buttonShare;
  52659. private _buttonOptions;
  52660. private _buttonL1;
  52661. private _buttonR1;
  52662. private _buttonLeftStick;
  52663. private _buttonRightStick;
  52664. private _dPadUp;
  52665. private _dPadDown;
  52666. private _dPadLeft;
  52667. private _dPadRight;
  52668. /**
  52669. * Creates a new DualShock gamepad object
  52670. * @param id defines the id of this gamepad
  52671. * @param index defines its index
  52672. * @param gamepad defines the internal HTML gamepad object
  52673. */
  52674. constructor(id: string, index: number, gamepad: any);
  52675. /**
  52676. * Defines the callback to call when left trigger is pressed
  52677. * @param callback defines the callback to use
  52678. */
  52679. onlefttriggerchanged(callback: (value: number) => void): void;
  52680. /**
  52681. * Defines the callback to call when right trigger is pressed
  52682. * @param callback defines the callback to use
  52683. */
  52684. onrighttriggerchanged(callback: (value: number) => void): void;
  52685. /**
  52686. * Gets the left trigger value
  52687. */
  52688. get leftTrigger(): number;
  52689. /**
  52690. * Sets the left trigger value
  52691. */
  52692. set leftTrigger(newValue: number);
  52693. /**
  52694. * Gets the right trigger value
  52695. */
  52696. get rightTrigger(): number;
  52697. /**
  52698. * Sets the right trigger value
  52699. */
  52700. set rightTrigger(newValue: number);
  52701. /**
  52702. * Defines the callback to call when a button is pressed
  52703. * @param callback defines the callback to use
  52704. */
  52705. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52706. /**
  52707. * Defines the callback to call when a button is released
  52708. * @param callback defines the callback to use
  52709. */
  52710. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52711. /**
  52712. * Defines the callback to call when a pad is pressed
  52713. * @param callback defines the callback to use
  52714. */
  52715. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52716. /**
  52717. * Defines the callback to call when a pad is released
  52718. * @param callback defines the callback to use
  52719. */
  52720. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52721. private _setButtonValue;
  52722. private _setDPadValue;
  52723. /**
  52724. * Gets the value of the `Cross` button
  52725. */
  52726. get buttonCross(): number;
  52727. /**
  52728. * Sets the value of the `Cross` button
  52729. */
  52730. set buttonCross(value: number);
  52731. /**
  52732. * Gets the value of the `Circle` button
  52733. */
  52734. get buttonCircle(): number;
  52735. /**
  52736. * Sets the value of the `Circle` button
  52737. */
  52738. set buttonCircle(value: number);
  52739. /**
  52740. * Gets the value of the `Square` button
  52741. */
  52742. get buttonSquare(): number;
  52743. /**
  52744. * Sets the value of the `Square` button
  52745. */
  52746. set buttonSquare(value: number);
  52747. /**
  52748. * Gets the value of the `Triangle` button
  52749. */
  52750. get buttonTriangle(): number;
  52751. /**
  52752. * Sets the value of the `Triangle` button
  52753. */
  52754. set buttonTriangle(value: number);
  52755. /**
  52756. * Gets the value of the `Options` button
  52757. */
  52758. get buttonOptions(): number;
  52759. /**
  52760. * Sets the value of the `Options` button
  52761. */
  52762. set buttonOptions(value: number);
  52763. /**
  52764. * Gets the value of the `Share` button
  52765. */
  52766. get buttonShare(): number;
  52767. /**
  52768. * Sets the value of the `Share` button
  52769. */
  52770. set buttonShare(value: number);
  52771. /**
  52772. * Gets the value of the `L1` button
  52773. */
  52774. get buttonL1(): number;
  52775. /**
  52776. * Sets the value of the `L1` button
  52777. */
  52778. set buttonL1(value: number);
  52779. /**
  52780. * Gets the value of the `R1` button
  52781. */
  52782. get buttonR1(): number;
  52783. /**
  52784. * Sets the value of the `R1` button
  52785. */
  52786. set buttonR1(value: number);
  52787. /**
  52788. * Gets the value of the Left joystick
  52789. */
  52790. get buttonLeftStick(): number;
  52791. /**
  52792. * Sets the value of the Left joystick
  52793. */
  52794. set buttonLeftStick(value: number);
  52795. /**
  52796. * Gets the value of the Right joystick
  52797. */
  52798. get buttonRightStick(): number;
  52799. /**
  52800. * Sets the value of the Right joystick
  52801. */
  52802. set buttonRightStick(value: number);
  52803. /**
  52804. * Gets the value of D-pad up
  52805. */
  52806. get dPadUp(): number;
  52807. /**
  52808. * Sets the value of D-pad up
  52809. */
  52810. set dPadUp(value: number);
  52811. /**
  52812. * Gets the value of D-pad down
  52813. */
  52814. get dPadDown(): number;
  52815. /**
  52816. * Sets the value of D-pad down
  52817. */
  52818. set dPadDown(value: number);
  52819. /**
  52820. * Gets the value of D-pad left
  52821. */
  52822. get dPadLeft(): number;
  52823. /**
  52824. * Sets the value of D-pad left
  52825. */
  52826. set dPadLeft(value: number);
  52827. /**
  52828. * Gets the value of D-pad right
  52829. */
  52830. get dPadRight(): number;
  52831. /**
  52832. * Sets the value of D-pad right
  52833. */
  52834. set dPadRight(value: number);
  52835. /**
  52836. * Force the gamepad to synchronize with device values
  52837. */
  52838. update(): void;
  52839. /**
  52840. * Disposes the gamepad
  52841. */
  52842. dispose(): void;
  52843. }
  52844. }
  52845. declare module BABYLON {
  52846. /**
  52847. * Manager for handling gamepads
  52848. */
  52849. export class GamepadManager {
  52850. private _scene?;
  52851. private _babylonGamepads;
  52852. private _oneGamepadConnected;
  52853. /** @hidden */
  52854. _isMonitoring: boolean;
  52855. private _gamepadEventSupported;
  52856. private _gamepadSupport?;
  52857. /**
  52858. * observable to be triggered when the gamepad controller has been connected
  52859. */
  52860. onGamepadConnectedObservable: Observable<Gamepad>;
  52861. /**
  52862. * observable to be triggered when the gamepad controller has been disconnected
  52863. */
  52864. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52865. private _onGamepadConnectedEvent;
  52866. private _onGamepadDisconnectedEvent;
  52867. /**
  52868. * Initializes the gamepad manager
  52869. * @param _scene BabylonJS scene
  52870. */
  52871. constructor(_scene?: Scene | undefined);
  52872. /**
  52873. * The gamepads in the game pad manager
  52874. */
  52875. get gamepads(): Gamepad[];
  52876. /**
  52877. * Get the gamepad controllers based on type
  52878. * @param type The type of gamepad controller
  52879. * @returns Nullable gamepad
  52880. */
  52881. getGamepadByType(type?: number): Nullable<Gamepad>;
  52882. /**
  52883. * Disposes the gamepad manager
  52884. */
  52885. dispose(): void;
  52886. private _addNewGamepad;
  52887. private _startMonitoringGamepads;
  52888. private _stopMonitoringGamepads;
  52889. /** @hidden */
  52890. _checkGamepadsStatus(): void;
  52891. private _updateGamepadObjects;
  52892. }
  52893. }
  52894. declare module BABYLON {
  52895. interface Scene {
  52896. /** @hidden */
  52897. _gamepadManager: Nullable<GamepadManager>;
  52898. /**
  52899. * Gets the gamepad manager associated with the scene
  52900. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52901. */
  52902. gamepadManager: GamepadManager;
  52903. }
  52904. /**
  52905. * Interface representing a free camera inputs manager
  52906. */
  52907. interface FreeCameraInputsManager {
  52908. /**
  52909. * Adds gamepad input support to the FreeCameraInputsManager.
  52910. * @returns the FreeCameraInputsManager
  52911. */
  52912. addGamepad(): FreeCameraInputsManager;
  52913. }
  52914. /**
  52915. * Interface representing an arc rotate camera inputs manager
  52916. */
  52917. interface ArcRotateCameraInputsManager {
  52918. /**
  52919. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52920. * @returns the camera inputs manager
  52921. */
  52922. addGamepad(): ArcRotateCameraInputsManager;
  52923. }
  52924. /**
  52925. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52926. */
  52927. export class GamepadSystemSceneComponent implements ISceneComponent {
  52928. /**
  52929. * The component name helpfull to identify the component in the list of scene components.
  52930. */
  52931. readonly name: string;
  52932. /**
  52933. * The scene the component belongs to.
  52934. */
  52935. scene: Scene;
  52936. /**
  52937. * Creates a new instance of the component for the given scene
  52938. * @param scene Defines the scene to register the component in
  52939. */
  52940. constructor(scene: Scene);
  52941. /**
  52942. * Registers the component in a given scene
  52943. */
  52944. register(): void;
  52945. /**
  52946. * Rebuilds the elements related to this component in case of
  52947. * context lost for instance.
  52948. */
  52949. rebuild(): void;
  52950. /**
  52951. * Disposes the component and the associated ressources
  52952. */
  52953. dispose(): void;
  52954. private _beforeCameraUpdate;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. /**
  52959. * 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,
  52960. * which still works and will still be found in many Playgrounds.
  52961. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52962. */
  52963. export class UniversalCamera extends TouchCamera {
  52964. /**
  52965. * Defines the gamepad rotation sensiblity.
  52966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52967. */
  52968. get gamepadAngularSensibility(): number;
  52969. set gamepadAngularSensibility(value: number);
  52970. /**
  52971. * Defines the gamepad move sensiblity.
  52972. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52973. */
  52974. get gamepadMoveSensibility(): number;
  52975. set gamepadMoveSensibility(value: number);
  52976. /**
  52977. * 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,
  52978. * which still works and will still be found in many Playgrounds.
  52979. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52980. * @param name Define the name of the camera in the scene
  52981. * @param position Define the start position of the camera in the scene
  52982. * @param scene Define the scene the camera belongs to
  52983. */
  52984. constructor(name: string, position: Vector3, scene: Scene);
  52985. /**
  52986. * Gets the current object class name.
  52987. * @return the class name
  52988. */
  52989. getClassName(): string;
  52990. }
  52991. }
  52992. declare module BABYLON {
  52993. /**
  52994. * This represents a FPS type of camera. This is only here for back compat purpose.
  52995. * Please use the UniversalCamera instead as both are identical.
  52996. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52997. */
  52998. export class GamepadCamera extends UniversalCamera {
  52999. /**
  53000. * Instantiates a new Gamepad Camera
  53001. * This represents a FPS type of camera. This is only here for back compat purpose.
  53002. * Please use the UniversalCamera instead as both are identical.
  53003. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53004. * @param name Define the name of the camera in the scene
  53005. * @param position Define the start position of the camera in the scene
  53006. * @param scene Define the scene the camera belongs to
  53007. */
  53008. constructor(name: string, position: Vector3, scene: Scene);
  53009. /**
  53010. * Gets the current object class name.
  53011. * @return the class name
  53012. */
  53013. getClassName(): string;
  53014. }
  53015. }
  53016. declare module BABYLON {
  53017. /** @hidden */
  53018. export var anaglyphPixelShader: {
  53019. name: string;
  53020. shader: string;
  53021. };
  53022. }
  53023. declare module BABYLON {
  53024. /**
  53025. * Postprocess used to generate anaglyphic rendering
  53026. */
  53027. export class AnaglyphPostProcess extends PostProcess {
  53028. private _passedProcess;
  53029. /**
  53030. * Gets a string identifying the name of the class
  53031. * @returns "AnaglyphPostProcess" string
  53032. */
  53033. getClassName(): string;
  53034. /**
  53035. * Creates a new AnaglyphPostProcess
  53036. * @param name defines postprocess name
  53037. * @param options defines creation options or target ratio scale
  53038. * @param rigCameras defines cameras using this postprocess
  53039. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53040. * @param engine defines hosting engine
  53041. * @param reusable defines if the postprocess will be reused multiple times per frame
  53042. */
  53043. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53044. }
  53045. }
  53046. declare module BABYLON {
  53047. /**
  53048. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53049. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53050. */
  53051. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53052. /**
  53053. * Creates a new AnaglyphArcRotateCamera
  53054. * @param name defines camera name
  53055. * @param alpha defines alpha angle (in radians)
  53056. * @param beta defines beta angle (in radians)
  53057. * @param radius defines radius
  53058. * @param target defines camera target
  53059. * @param interaxialDistance defines distance between each color axis
  53060. * @param scene defines the hosting scene
  53061. */
  53062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53063. /**
  53064. * Gets camera class name
  53065. * @returns AnaglyphArcRotateCamera
  53066. */
  53067. getClassName(): string;
  53068. }
  53069. }
  53070. declare module BABYLON {
  53071. /**
  53072. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53073. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53074. */
  53075. export class AnaglyphFreeCamera extends FreeCamera {
  53076. /**
  53077. * Creates a new AnaglyphFreeCamera
  53078. * @param name defines camera name
  53079. * @param position defines initial position
  53080. * @param interaxialDistance defines distance between each color axis
  53081. * @param scene defines the hosting scene
  53082. */
  53083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53084. /**
  53085. * Gets camera class name
  53086. * @returns AnaglyphFreeCamera
  53087. */
  53088. getClassName(): string;
  53089. }
  53090. }
  53091. declare module BABYLON {
  53092. /**
  53093. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53094. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53095. */
  53096. export class AnaglyphGamepadCamera extends GamepadCamera {
  53097. /**
  53098. * Creates a new AnaglyphGamepadCamera
  53099. * @param name defines camera name
  53100. * @param position defines initial position
  53101. * @param interaxialDistance defines distance between each color axis
  53102. * @param scene defines the hosting scene
  53103. */
  53104. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53105. /**
  53106. * Gets camera class name
  53107. * @returns AnaglyphGamepadCamera
  53108. */
  53109. getClassName(): string;
  53110. }
  53111. }
  53112. declare module BABYLON {
  53113. /**
  53114. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53115. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53116. */
  53117. export class AnaglyphUniversalCamera extends UniversalCamera {
  53118. /**
  53119. * Creates a new AnaglyphUniversalCamera
  53120. * @param name defines camera name
  53121. * @param position defines initial position
  53122. * @param interaxialDistance defines distance between each color axis
  53123. * @param scene defines the hosting scene
  53124. */
  53125. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53126. /**
  53127. * Gets camera class name
  53128. * @returns AnaglyphUniversalCamera
  53129. */
  53130. getClassName(): string;
  53131. }
  53132. }
  53133. declare module BABYLON {
  53134. /** @hidden */
  53135. export var stereoscopicInterlacePixelShader: {
  53136. name: string;
  53137. shader: string;
  53138. };
  53139. }
  53140. declare module BABYLON {
  53141. /**
  53142. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53143. */
  53144. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53145. private _stepSize;
  53146. private _passedProcess;
  53147. /**
  53148. * Gets a string identifying the name of the class
  53149. * @returns "StereoscopicInterlacePostProcessI" string
  53150. */
  53151. getClassName(): string;
  53152. /**
  53153. * Initializes a StereoscopicInterlacePostProcessI
  53154. * @param name The name of the effect.
  53155. * @param rigCameras The rig cameras to be applied to the post process
  53156. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53157. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53159. * @param engine The engine which the post process will be applied. (default: current engine)
  53160. * @param reusable If the post process can be reused on the same frame. (default: false)
  53161. */
  53162. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53163. }
  53164. /**
  53165. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53166. */
  53167. export class StereoscopicInterlacePostProcess extends PostProcess {
  53168. private _stepSize;
  53169. private _passedProcess;
  53170. /**
  53171. * Gets a string identifying the name of the class
  53172. * @returns "StereoscopicInterlacePostProcess" string
  53173. */
  53174. getClassName(): string;
  53175. /**
  53176. * Initializes a StereoscopicInterlacePostProcess
  53177. * @param name The name of the effect.
  53178. * @param rigCameras The rig cameras to be applied to the post process
  53179. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53181. * @param engine The engine which the post process will be applied. (default: current engine)
  53182. * @param reusable If the post process can be reused on the same frame. (default: false)
  53183. */
  53184. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53185. }
  53186. }
  53187. declare module BABYLON {
  53188. /**
  53189. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53190. * @see https://doc.babylonjs.com/features/cameras
  53191. */
  53192. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53193. /**
  53194. * Creates a new StereoscopicArcRotateCamera
  53195. * @param name defines camera name
  53196. * @param alpha defines alpha angle (in radians)
  53197. * @param beta defines beta angle (in radians)
  53198. * @param radius defines radius
  53199. * @param target defines camera target
  53200. * @param interaxialDistance defines distance between each color axis
  53201. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53202. * @param scene defines the hosting scene
  53203. */
  53204. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53205. /**
  53206. * Gets camera class name
  53207. * @returns StereoscopicArcRotateCamera
  53208. */
  53209. getClassName(): string;
  53210. }
  53211. }
  53212. declare module BABYLON {
  53213. /**
  53214. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53215. * @see https://doc.babylonjs.com/features/cameras
  53216. */
  53217. export class StereoscopicFreeCamera extends FreeCamera {
  53218. /**
  53219. * Creates a new StereoscopicFreeCamera
  53220. * @param name defines camera name
  53221. * @param position defines initial position
  53222. * @param interaxialDistance defines distance between each color axis
  53223. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53224. * @param scene defines the hosting scene
  53225. */
  53226. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53227. /**
  53228. * Gets camera class name
  53229. * @returns StereoscopicFreeCamera
  53230. */
  53231. getClassName(): string;
  53232. }
  53233. }
  53234. declare module BABYLON {
  53235. /**
  53236. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53237. * @see https://doc.babylonjs.com/features/cameras
  53238. */
  53239. export class StereoscopicGamepadCamera extends GamepadCamera {
  53240. /**
  53241. * Creates a new StereoscopicGamepadCamera
  53242. * @param name defines camera name
  53243. * @param position defines initial position
  53244. * @param interaxialDistance defines distance between each color axis
  53245. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53246. * @param scene defines the hosting scene
  53247. */
  53248. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53249. /**
  53250. * Gets camera class name
  53251. * @returns StereoscopicGamepadCamera
  53252. */
  53253. getClassName(): string;
  53254. }
  53255. }
  53256. declare module BABYLON {
  53257. /**
  53258. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53259. * @see https://doc.babylonjs.com/features/cameras
  53260. */
  53261. export class StereoscopicUniversalCamera extends UniversalCamera {
  53262. /**
  53263. * Creates a new StereoscopicUniversalCamera
  53264. * @param name defines camera name
  53265. * @param position defines initial position
  53266. * @param interaxialDistance defines distance between each color axis
  53267. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53268. * @param scene defines the hosting scene
  53269. */
  53270. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53271. /**
  53272. * Gets camera class name
  53273. * @returns StereoscopicUniversalCamera
  53274. */
  53275. getClassName(): string;
  53276. }
  53277. }
  53278. declare module BABYLON {
  53279. /**
  53280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53281. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53282. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53283. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53284. */
  53285. export class VirtualJoysticksCamera extends FreeCamera {
  53286. /**
  53287. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53288. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53289. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53290. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53291. * @param name Define the name of the camera in the scene
  53292. * @param position Define the start position of the camera in the scene
  53293. * @param scene Define the scene the camera belongs to
  53294. */
  53295. constructor(name: string, position: Vector3, scene: Scene);
  53296. /**
  53297. * Gets the current object class name.
  53298. * @return the class name
  53299. */
  53300. getClassName(): string;
  53301. }
  53302. }
  53303. declare module BABYLON {
  53304. /**
  53305. * This represents all the required metrics to create a VR camera.
  53306. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53307. */
  53308. export class VRCameraMetrics {
  53309. /**
  53310. * Define the horizontal resolution off the screen.
  53311. */
  53312. hResolution: number;
  53313. /**
  53314. * Define the vertical resolution off the screen.
  53315. */
  53316. vResolution: number;
  53317. /**
  53318. * Define the horizontal screen size.
  53319. */
  53320. hScreenSize: number;
  53321. /**
  53322. * Define the vertical screen size.
  53323. */
  53324. vScreenSize: number;
  53325. /**
  53326. * Define the vertical screen center position.
  53327. */
  53328. vScreenCenter: number;
  53329. /**
  53330. * Define the distance of the eyes to the screen.
  53331. */
  53332. eyeToScreenDistance: number;
  53333. /**
  53334. * Define the distance between both lenses
  53335. */
  53336. lensSeparationDistance: number;
  53337. /**
  53338. * Define the distance between both viewer's eyes.
  53339. */
  53340. interpupillaryDistance: number;
  53341. /**
  53342. * Define the distortion factor of the VR postprocess.
  53343. * Please, touch with care.
  53344. */
  53345. distortionK: number[];
  53346. /**
  53347. * Define the chromatic aberration correction factors for the VR post process.
  53348. */
  53349. chromaAbCorrection: number[];
  53350. /**
  53351. * Define the scale factor of the post process.
  53352. * The smaller the better but the slower.
  53353. */
  53354. postProcessScaleFactor: number;
  53355. /**
  53356. * Define an offset for the lens center.
  53357. */
  53358. lensCenterOffset: number;
  53359. /**
  53360. * Define if the current vr camera should compensate the distortion of the lens or not.
  53361. */
  53362. compensateDistortion: boolean;
  53363. /**
  53364. * Defines if multiview should be enabled when rendering (Default: false)
  53365. */
  53366. multiviewEnabled: boolean;
  53367. /**
  53368. * Gets the rendering aspect ratio based on the provided resolutions.
  53369. */
  53370. get aspectRatio(): number;
  53371. /**
  53372. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53373. */
  53374. get aspectRatioFov(): number;
  53375. /**
  53376. * @hidden
  53377. */
  53378. get leftHMatrix(): Matrix;
  53379. /**
  53380. * @hidden
  53381. */
  53382. get rightHMatrix(): Matrix;
  53383. /**
  53384. * @hidden
  53385. */
  53386. get leftPreViewMatrix(): Matrix;
  53387. /**
  53388. * @hidden
  53389. */
  53390. get rightPreViewMatrix(): Matrix;
  53391. /**
  53392. * Get the default VRMetrics based on the most generic setup.
  53393. * @returns the default vr metrics
  53394. */
  53395. static GetDefault(): VRCameraMetrics;
  53396. }
  53397. }
  53398. declare module BABYLON {
  53399. /** @hidden */
  53400. export var vrDistortionCorrectionPixelShader: {
  53401. name: string;
  53402. shader: string;
  53403. };
  53404. }
  53405. declare module BABYLON {
  53406. /**
  53407. * VRDistortionCorrectionPostProcess used for mobile VR
  53408. */
  53409. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53410. private _isRightEye;
  53411. private _distortionFactors;
  53412. private _postProcessScaleFactor;
  53413. private _lensCenterOffset;
  53414. private _scaleIn;
  53415. private _scaleFactor;
  53416. private _lensCenter;
  53417. /**
  53418. * Gets a string identifying the name of the class
  53419. * @returns "VRDistortionCorrectionPostProcess" string
  53420. */
  53421. getClassName(): string;
  53422. /**
  53423. * Initializes the VRDistortionCorrectionPostProcess
  53424. * @param name The name of the effect.
  53425. * @param camera The camera to apply the render pass to.
  53426. * @param isRightEye If this is for the right eye distortion
  53427. * @param vrMetrics All the required metrics for the VR camera
  53428. */
  53429. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53430. }
  53431. }
  53432. declare module BABYLON {
  53433. /**
  53434. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53435. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53436. */
  53437. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53438. /**
  53439. * Creates a new VRDeviceOrientationArcRotateCamera
  53440. * @param name defines camera name
  53441. * @param alpha defines the camera rotation along the longitudinal axis
  53442. * @param beta defines the camera rotation along the latitudinal axis
  53443. * @param radius defines the camera distance from its target
  53444. * @param target defines the camera target
  53445. * @param scene defines the scene the camera belongs to
  53446. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53447. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53448. */
  53449. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53450. /**
  53451. * Gets camera class name
  53452. * @returns VRDeviceOrientationArcRotateCamera
  53453. */
  53454. getClassName(): string;
  53455. }
  53456. }
  53457. declare module BABYLON {
  53458. /**
  53459. * Camera used to simulate VR rendering (based on FreeCamera)
  53460. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53461. */
  53462. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53463. /**
  53464. * Creates a new VRDeviceOrientationFreeCamera
  53465. * @param name defines camera name
  53466. * @param position defines the start position of the camera
  53467. * @param scene defines the scene the camera belongs to
  53468. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53469. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53470. */
  53471. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53472. /**
  53473. * Gets camera class name
  53474. * @returns VRDeviceOrientationFreeCamera
  53475. */
  53476. getClassName(): string;
  53477. }
  53478. }
  53479. declare module BABYLON {
  53480. /**
  53481. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53482. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53483. */
  53484. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53485. /**
  53486. * Creates a new VRDeviceOrientationGamepadCamera
  53487. * @param name defines camera name
  53488. * @param position defines the start position of the camera
  53489. * @param scene defines the scene the camera belongs to
  53490. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53491. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53492. */
  53493. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53494. /**
  53495. * Gets camera class name
  53496. * @returns VRDeviceOrientationGamepadCamera
  53497. */
  53498. getClassName(): string;
  53499. }
  53500. }
  53501. declare module BABYLON {
  53502. /**
  53503. * A class extending Texture allowing drawing on a texture
  53504. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53505. */
  53506. export class DynamicTexture extends Texture {
  53507. private _generateMipMaps;
  53508. private _canvas;
  53509. private _context;
  53510. /**
  53511. * Creates a DynamicTexture
  53512. * @param name defines the name of the texture
  53513. * @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
  53514. * @param scene defines the scene where you want the texture
  53515. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53516. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53517. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53518. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53519. */
  53520. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53521. /**
  53522. * Get the current class name of the texture useful for serialization or dynamic coding.
  53523. * @returns "DynamicTexture"
  53524. */
  53525. getClassName(): string;
  53526. /**
  53527. * Gets the current state of canRescale
  53528. */
  53529. get canRescale(): boolean;
  53530. private _recreate;
  53531. /**
  53532. * Scales the texture
  53533. * @param ratio the scale factor to apply to both width and height
  53534. */
  53535. scale(ratio: number): void;
  53536. /**
  53537. * Resizes the texture
  53538. * @param width the new width
  53539. * @param height the new height
  53540. */
  53541. scaleTo(width: number, height: number): void;
  53542. /**
  53543. * Gets the context of the canvas used by the texture
  53544. * @returns the canvas context of the dynamic texture
  53545. */
  53546. getContext(): CanvasRenderingContext2D;
  53547. /**
  53548. * Clears the texture
  53549. */
  53550. clear(): void;
  53551. /**
  53552. * Updates the texture
  53553. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53554. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53555. */
  53556. update(invertY?: boolean, premulAlpha?: boolean): void;
  53557. /**
  53558. * Draws text onto the texture
  53559. * @param text defines the text to be drawn
  53560. * @param x defines the placement of the text from the left
  53561. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53562. * @param font defines the font to be used with font-style, font-size, font-name
  53563. * @param color defines the color used for the text
  53564. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53566. * @param update defines whether texture is immediately update (default is true)
  53567. */
  53568. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53569. /**
  53570. * Clones the texture
  53571. * @returns the clone of the texture.
  53572. */
  53573. clone(): DynamicTexture;
  53574. /**
  53575. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53576. * @returns a serialized dynamic texture object
  53577. */
  53578. serialize(): any;
  53579. private _IsCanvasElement;
  53580. /** @hidden */
  53581. _rebuild(): void;
  53582. }
  53583. }
  53584. declare module BABYLON {
  53585. /**
  53586. * Class containing static functions to help procedurally build meshes
  53587. */
  53588. export class GroundBuilder {
  53589. /**
  53590. * Creates a ground mesh
  53591. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53592. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53594. * @param name defines the name of the mesh
  53595. * @param options defines the options used to create the mesh
  53596. * @param scene defines the hosting scene
  53597. * @returns the ground mesh
  53598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53599. */
  53600. static CreateGround(name: string, options: {
  53601. width?: number;
  53602. height?: number;
  53603. subdivisions?: number;
  53604. subdivisionsX?: number;
  53605. subdivisionsY?: number;
  53606. updatable?: boolean;
  53607. }, scene: any): Mesh;
  53608. /**
  53609. * Creates a tiled ground mesh
  53610. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53611. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53612. * * 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
  53613. * * 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
  53614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53615. * @param name defines the name of the mesh
  53616. * @param options defines the options used to create the mesh
  53617. * @param scene defines the hosting scene
  53618. * @returns the tiled ground mesh
  53619. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53620. */
  53621. static CreateTiledGround(name: string, options: {
  53622. xmin: number;
  53623. zmin: number;
  53624. xmax: number;
  53625. zmax: number;
  53626. subdivisions?: {
  53627. w: number;
  53628. h: number;
  53629. };
  53630. precision?: {
  53631. w: number;
  53632. h: number;
  53633. };
  53634. updatable?: boolean;
  53635. }, scene?: Nullable<Scene>): Mesh;
  53636. /**
  53637. * Creates a ground mesh from a height map
  53638. * * The parameter `url` sets the URL of the height map image resource.
  53639. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53640. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53641. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53642. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53643. * * 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.
  53644. * * 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).
  53645. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53647. * @param name defines the name of the mesh
  53648. * @param url defines the url to the height map
  53649. * @param options defines the options used to create the mesh
  53650. * @param scene defines the hosting scene
  53651. * @returns the ground mesh
  53652. * @see https://doc.babylonjs.com/babylon101/height_map
  53653. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53654. */
  53655. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53656. width?: number;
  53657. height?: number;
  53658. subdivisions?: number;
  53659. minHeight?: number;
  53660. maxHeight?: number;
  53661. colorFilter?: Color3;
  53662. alphaFilter?: number;
  53663. updatable?: boolean;
  53664. onReady?: (mesh: GroundMesh) => void;
  53665. }, scene?: Nullable<Scene>): GroundMesh;
  53666. }
  53667. }
  53668. declare module BABYLON {
  53669. /**
  53670. * Class containing static functions to help procedurally build meshes
  53671. */
  53672. export class TorusBuilder {
  53673. /**
  53674. * Creates a torus mesh
  53675. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53676. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53677. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53679. * * 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
  53680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53681. * @param name defines the name of the mesh
  53682. * @param options defines the options used to create the mesh
  53683. * @param scene defines the hosting scene
  53684. * @returns the torus mesh
  53685. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53686. */
  53687. static CreateTorus(name: string, options: {
  53688. diameter?: number;
  53689. thickness?: number;
  53690. tessellation?: number;
  53691. updatable?: boolean;
  53692. sideOrientation?: number;
  53693. frontUVs?: Vector4;
  53694. backUVs?: Vector4;
  53695. }, scene: any): Mesh;
  53696. }
  53697. }
  53698. declare module BABYLON {
  53699. /**
  53700. * Class containing static functions to help procedurally build meshes
  53701. */
  53702. export class CylinderBuilder {
  53703. /**
  53704. * Creates a cylinder or a cone mesh
  53705. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53706. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53707. * * 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.
  53708. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53709. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53710. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53711. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53712. * * 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).
  53713. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53714. * * 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).
  53715. * * 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
  53716. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53717. * * 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
  53718. * * 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.
  53719. * * If `enclose` is false, a ring surface is one element.
  53720. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53721. * * 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
  53722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53723. * * 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
  53724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53725. * @param name defines the name of the mesh
  53726. * @param options defines the options used to create the mesh
  53727. * @param scene defines the hosting scene
  53728. * @returns the cylinder mesh
  53729. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53730. */
  53731. static CreateCylinder(name: string, options: {
  53732. height?: number;
  53733. diameterTop?: number;
  53734. diameterBottom?: number;
  53735. diameter?: number;
  53736. tessellation?: number;
  53737. subdivisions?: number;
  53738. arc?: number;
  53739. faceColors?: Color4[];
  53740. faceUV?: Vector4[];
  53741. updatable?: boolean;
  53742. hasRings?: boolean;
  53743. enclose?: boolean;
  53744. cap?: number;
  53745. sideOrientation?: number;
  53746. frontUVs?: Vector4;
  53747. backUVs?: Vector4;
  53748. }, scene: any): Mesh;
  53749. }
  53750. }
  53751. declare module BABYLON {
  53752. /**
  53753. * States of the webXR experience
  53754. */
  53755. export enum WebXRState {
  53756. /**
  53757. * Transitioning to being in XR mode
  53758. */
  53759. ENTERING_XR = 0,
  53760. /**
  53761. * Transitioning to non XR mode
  53762. */
  53763. EXITING_XR = 1,
  53764. /**
  53765. * In XR mode and presenting
  53766. */
  53767. IN_XR = 2,
  53768. /**
  53769. * Not entered XR mode
  53770. */
  53771. NOT_IN_XR = 3
  53772. }
  53773. /**
  53774. * The state of the XR camera's tracking
  53775. */
  53776. export enum WebXRTrackingState {
  53777. /**
  53778. * No transformation received, device is not being tracked
  53779. */
  53780. NOT_TRACKING = 0,
  53781. /**
  53782. * Tracking lost - using emulated position
  53783. */
  53784. TRACKING_LOST = 1,
  53785. /**
  53786. * Transformation tracking works normally
  53787. */
  53788. TRACKING = 2
  53789. }
  53790. /**
  53791. * Abstraction of the XR render target
  53792. */
  53793. export interface WebXRRenderTarget extends IDisposable {
  53794. /**
  53795. * xrpresent context of the canvas which can be used to display/mirror xr content
  53796. */
  53797. canvasContext: WebGLRenderingContext;
  53798. /**
  53799. * xr layer for the canvas
  53800. */
  53801. xrLayer: Nullable<XRWebGLLayer>;
  53802. /**
  53803. * Initializes the xr layer for the session
  53804. * @param xrSession xr session
  53805. * @returns a promise that will resolve once the XR Layer has been created
  53806. */
  53807. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53808. }
  53809. }
  53810. declare module BABYLON {
  53811. /**
  53812. * Configuration object for WebXR output canvas
  53813. */
  53814. export class WebXRManagedOutputCanvasOptions {
  53815. /**
  53816. * An optional canvas in case you wish to create it yourself and provide it here.
  53817. * If not provided, a new canvas will be created
  53818. */
  53819. canvasElement?: HTMLCanvasElement;
  53820. /**
  53821. * Options for this XR Layer output
  53822. */
  53823. canvasOptions?: XRWebGLLayerInit;
  53824. /**
  53825. * CSS styling for a newly created canvas (if not provided)
  53826. */
  53827. newCanvasCssStyle?: string;
  53828. /**
  53829. * Get the default values of the configuration object
  53830. * @param engine defines the engine to use (can be null)
  53831. * @returns default values of this configuration object
  53832. */
  53833. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53834. }
  53835. /**
  53836. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53837. */
  53838. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53839. private _options;
  53840. private _canvas;
  53841. private _engine;
  53842. private _originalCanvasSize;
  53843. /**
  53844. * Rendering context of the canvas which can be used to display/mirror xr content
  53845. */
  53846. canvasContext: WebGLRenderingContext;
  53847. /**
  53848. * xr layer for the canvas
  53849. */
  53850. xrLayer: Nullable<XRWebGLLayer>;
  53851. /**
  53852. * Observers registered here will be triggered when the xr layer was initialized
  53853. */
  53854. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53855. /**
  53856. * Initializes the canvas to be added/removed upon entering/exiting xr
  53857. * @param _xrSessionManager The XR Session manager
  53858. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53859. */
  53860. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53861. /**
  53862. * Disposes of the object
  53863. */
  53864. dispose(): void;
  53865. /**
  53866. * Initializes the xr layer for the session
  53867. * @param xrSession xr session
  53868. * @returns a promise that will resolve once the XR Layer has been created
  53869. */
  53870. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53871. private _addCanvas;
  53872. private _removeCanvas;
  53873. private _setCanvasSize;
  53874. private _setManagedOutputCanvas;
  53875. }
  53876. }
  53877. declare module BABYLON {
  53878. /**
  53879. * Manages an XRSession to work with Babylon's engine
  53880. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53881. */
  53882. export class WebXRSessionManager implements IDisposable {
  53883. /** The scene which the session should be created for */
  53884. scene: Scene;
  53885. private _referenceSpace;
  53886. private _rttProvider;
  53887. private _sessionEnded;
  53888. private _xrNavigator;
  53889. private baseLayer;
  53890. /**
  53891. * The base reference space from which the session started. good if you want to reset your
  53892. * reference space
  53893. */
  53894. baseReferenceSpace: XRReferenceSpace;
  53895. /**
  53896. * Current XR frame
  53897. */
  53898. currentFrame: Nullable<XRFrame>;
  53899. /** WebXR timestamp updated every frame */
  53900. currentTimestamp: number;
  53901. /**
  53902. * Used just in case of a failure to initialize an immersive session.
  53903. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53904. */
  53905. defaultHeightCompensation: number;
  53906. /**
  53907. * Fires every time a new xrFrame arrives which can be used to update the camera
  53908. */
  53909. onXRFrameObservable: Observable<XRFrame>;
  53910. /**
  53911. * Fires when the reference space changed
  53912. */
  53913. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53914. /**
  53915. * Fires when the xr session is ended either by the device or manually done
  53916. */
  53917. onXRSessionEnded: Observable<any>;
  53918. /**
  53919. * Fires when the xr session is ended either by the device or manually done
  53920. */
  53921. onXRSessionInit: Observable<XRSession>;
  53922. /**
  53923. * Underlying xr session
  53924. */
  53925. session: XRSession;
  53926. /**
  53927. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53928. * or get the offset the player is currently at.
  53929. */
  53930. viewerReferenceSpace: XRReferenceSpace;
  53931. /**
  53932. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53933. * @param scene The scene which the session should be created for
  53934. */
  53935. constructor(
  53936. /** The scene which the session should be created for */
  53937. scene: Scene);
  53938. /**
  53939. * The current reference space used in this session. This reference space can constantly change!
  53940. * It is mainly used to offset the camera's position.
  53941. */
  53942. get referenceSpace(): XRReferenceSpace;
  53943. /**
  53944. * Set a new reference space and triggers the observable
  53945. */
  53946. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53947. /**
  53948. * Disposes of the session manager
  53949. */
  53950. dispose(): void;
  53951. /**
  53952. * Stops the xrSession and restores the render loop
  53953. * @returns Promise which resolves after it exits XR
  53954. */
  53955. exitXRAsync(): Promise<void>;
  53956. /**
  53957. * Gets the correct render target texture to be rendered this frame for this eye
  53958. * @param eye the eye for which to get the render target
  53959. * @returns the render target for the specified eye
  53960. */
  53961. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53962. /**
  53963. * Creates a WebXRRenderTarget object for the XR session
  53964. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53965. * @param options optional options to provide when creating a new render target
  53966. * @returns a WebXR render target to which the session can render
  53967. */
  53968. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53969. /**
  53970. * Initializes the manager
  53971. * After initialization enterXR can be called to start an XR session
  53972. * @returns Promise which resolves after it is initialized
  53973. */
  53974. initializeAsync(): Promise<void>;
  53975. /**
  53976. * Initializes an xr session
  53977. * @param xrSessionMode mode to initialize
  53978. * @param xrSessionInit defines optional and required values to pass to the session builder
  53979. * @returns a promise which will resolve once the session has been initialized
  53980. */
  53981. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53982. /**
  53983. * Checks if a session would be supported for the creation options specified
  53984. * @param sessionMode session mode to check if supported eg. immersive-vr
  53985. * @returns A Promise that resolves to true if supported and false if not
  53986. */
  53987. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53988. /**
  53989. * Resets the reference space to the one started the session
  53990. */
  53991. resetReferenceSpace(): void;
  53992. /**
  53993. * Starts rendering to the xr layer
  53994. */
  53995. runXRRenderLoop(): void;
  53996. /**
  53997. * Sets the reference space on the xr session
  53998. * @param referenceSpaceType space to set
  53999. * @returns a promise that will resolve once the reference space has been set
  54000. */
  54001. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54002. /**
  54003. * Updates the render state of the session
  54004. * @param state state to set
  54005. * @returns a promise that resolves once the render state has been updated
  54006. */
  54007. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54008. /**
  54009. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54010. * @param sessionMode defines the session to test
  54011. * @returns a promise with boolean as final value
  54012. */
  54013. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54014. /**
  54015. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54016. */
  54017. get isNative(): boolean;
  54018. private _createRenderTargetTexture;
  54019. }
  54020. }
  54021. declare module BABYLON {
  54022. /**
  54023. * WebXR Camera which holds the views for the xrSession
  54024. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54025. */
  54026. export class WebXRCamera extends FreeCamera {
  54027. private _xrSessionManager;
  54028. private _firstFrame;
  54029. private _referenceQuaternion;
  54030. private _referencedPosition;
  54031. private _xrInvPositionCache;
  54032. private _xrInvQuaternionCache;
  54033. private _trackingState;
  54034. /**
  54035. * Observable raised before camera teleportation
  54036. */
  54037. onBeforeCameraTeleport: Observable<Vector3>;
  54038. /**
  54039. * Observable raised after camera teleportation
  54040. */
  54041. onAfterCameraTeleport: Observable<Vector3>;
  54042. /**
  54043. * Notifies when the camera's tracking state has changed.
  54044. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54045. */
  54046. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54047. /**
  54048. * Should position compensation execute on first frame.
  54049. * This is used when copying the position from a native (non XR) camera
  54050. */
  54051. compensateOnFirstFrame: boolean;
  54052. /**
  54053. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54054. * @param name the name of the camera
  54055. * @param scene the scene to add the camera to
  54056. * @param _xrSessionManager a constructed xr session manager
  54057. */
  54058. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54059. /**
  54060. * Get the current XR tracking state of the camera
  54061. */
  54062. get trackingState(): WebXRTrackingState;
  54063. private _setTrackingState;
  54064. /**
  54065. * Return the user's height, unrelated to the current ground.
  54066. * This will be the y position of this camera, when ground level is 0.
  54067. */
  54068. get realWorldHeight(): number;
  54069. /** @hidden */
  54070. _updateForDualEyeDebugging(): void;
  54071. /**
  54072. * Sets this camera's transformation based on a non-vr camera
  54073. * @param otherCamera the non-vr camera to copy the transformation from
  54074. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54075. */
  54076. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54077. /**
  54078. * Gets the current instance class name ("WebXRCamera").
  54079. * @returns the class name
  54080. */
  54081. getClassName(): string;
  54082. private _rotate180;
  54083. private _updateFromXRSession;
  54084. private _updateNumberOfRigCameras;
  54085. private _updateReferenceSpace;
  54086. private _updateReferenceSpaceOffset;
  54087. }
  54088. }
  54089. declare module BABYLON {
  54090. /**
  54091. * Defining the interface required for a (webxr) feature
  54092. */
  54093. export interface IWebXRFeature extends IDisposable {
  54094. /**
  54095. * Is this feature attached
  54096. */
  54097. attached: boolean;
  54098. /**
  54099. * Should auto-attach be disabled?
  54100. */
  54101. disableAutoAttach: boolean;
  54102. /**
  54103. * Attach the feature to the session
  54104. * Will usually be called by the features manager
  54105. *
  54106. * @param force should attachment be forced (even when already attached)
  54107. * @returns true if successful.
  54108. */
  54109. attach(force?: boolean): boolean;
  54110. /**
  54111. * Detach the feature from the session
  54112. * Will usually be called by the features manager
  54113. *
  54114. * @returns true if successful.
  54115. */
  54116. detach(): boolean;
  54117. /**
  54118. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54119. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54120. *
  54121. * @returns whether or not the feature is compatible in this environment
  54122. */
  54123. isCompatible(): boolean;
  54124. /**
  54125. * Was this feature disposed;
  54126. */
  54127. isDisposed: boolean;
  54128. /**
  54129. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54130. */
  54131. xrNativeFeatureName?: string;
  54132. /**
  54133. * A list of (Babylon WebXR) features this feature depends on
  54134. */
  54135. dependsOn?: string[];
  54136. /**
  54137. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54138. */
  54139. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54140. }
  54141. /**
  54142. * A list of the currently available features without referencing them
  54143. */
  54144. export class WebXRFeatureName {
  54145. /**
  54146. * The name of the anchor system feature
  54147. */
  54148. static readonly ANCHOR_SYSTEM: string;
  54149. /**
  54150. * The name of the background remover feature
  54151. */
  54152. static readonly BACKGROUND_REMOVER: string;
  54153. /**
  54154. * The name of the hit test feature
  54155. */
  54156. static readonly HIT_TEST: string;
  54157. /**
  54158. * The name of the mesh detection feature
  54159. */
  54160. static readonly MESH_DETECTION: string;
  54161. /**
  54162. * physics impostors for xr controllers feature
  54163. */
  54164. static readonly PHYSICS_CONTROLLERS: string;
  54165. /**
  54166. * The name of the plane detection feature
  54167. */
  54168. static readonly PLANE_DETECTION: string;
  54169. /**
  54170. * The name of the pointer selection feature
  54171. */
  54172. static readonly POINTER_SELECTION: string;
  54173. /**
  54174. * The name of the teleportation feature
  54175. */
  54176. static readonly TELEPORTATION: string;
  54177. /**
  54178. * The name of the feature points feature.
  54179. */
  54180. static readonly FEATURE_POINTS: string;
  54181. /**
  54182. * The name of the hand tracking feature.
  54183. */
  54184. static readonly HAND_TRACKING: string;
  54185. /**
  54186. * The name of the image tracking feature
  54187. */
  54188. static readonly IMAGE_TRACKING: string;
  54189. }
  54190. /**
  54191. * Defining the constructor of a feature. Used to register the modules.
  54192. */
  54193. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54194. /**
  54195. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54196. * It is mainly used in AR sessions.
  54197. *
  54198. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54199. */
  54200. export class WebXRFeaturesManager implements IDisposable {
  54201. private _xrSessionManager;
  54202. private static readonly _AvailableFeatures;
  54203. private _features;
  54204. /**
  54205. * constructs a new features manages.
  54206. *
  54207. * @param _xrSessionManager an instance of WebXRSessionManager
  54208. */
  54209. constructor(_xrSessionManager: WebXRSessionManager);
  54210. /**
  54211. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54212. * Mainly used internally.
  54213. *
  54214. * @param featureName the name of the feature to register
  54215. * @param constructorFunction the function used to construct the module
  54216. * @param version the (babylon) version of the module
  54217. * @param stable is that a stable version of this module
  54218. */
  54219. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54220. /**
  54221. * Returns a constructor of a specific feature.
  54222. *
  54223. * @param featureName the name of the feature to construct
  54224. * @param version the version of the feature to load
  54225. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54226. * @param options optional options provided to the module.
  54227. * @returns a function that, when called, will return a new instance of this feature
  54228. */
  54229. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54230. /**
  54231. * Can be used to return the list of features currently registered
  54232. *
  54233. * @returns an Array of available features
  54234. */
  54235. static GetAvailableFeatures(): string[];
  54236. /**
  54237. * Gets the versions available for a specific feature
  54238. * @param featureName the name of the feature
  54239. * @returns an array with the available versions
  54240. */
  54241. static GetAvailableVersions(featureName: string): string[];
  54242. /**
  54243. * Return the latest unstable version of this feature
  54244. * @param featureName the name of the feature to search
  54245. * @returns the version number. if not found will return -1
  54246. */
  54247. static GetLatestVersionOfFeature(featureName: string): number;
  54248. /**
  54249. * Return the latest stable version of this feature
  54250. * @param featureName the name of the feature to search
  54251. * @returns the version number. if not found will return -1
  54252. */
  54253. static GetStableVersionOfFeature(featureName: string): number;
  54254. /**
  54255. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54256. * Can be used during a session to start a feature
  54257. * @param featureName the name of feature to attach
  54258. */
  54259. attachFeature(featureName: string): void;
  54260. /**
  54261. * Can be used inside a session or when the session ends to detach a specific feature
  54262. * @param featureName the name of the feature to detach
  54263. */
  54264. detachFeature(featureName: string): void;
  54265. /**
  54266. * Used to disable an already-enabled feature
  54267. * The feature will be disposed and will be recreated once enabled.
  54268. * @param featureName the feature to disable
  54269. * @returns true if disable was successful
  54270. */
  54271. disableFeature(featureName: string | {
  54272. Name: string;
  54273. }): boolean;
  54274. /**
  54275. * dispose this features manager
  54276. */
  54277. dispose(): void;
  54278. /**
  54279. * 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.
  54280. * 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.
  54281. *
  54282. * @param featureName the name of the feature to load or the class of the feature
  54283. * @param version optional version to load. if not provided the latest version will be enabled
  54284. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54285. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54286. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54287. * @returns a new constructed feature or throws an error if feature not found.
  54288. */
  54289. enableFeature(featureName: string | {
  54290. Name: string;
  54291. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54292. /**
  54293. * get the implementation of an enabled feature.
  54294. * @param featureName the name of the feature to load
  54295. * @returns the feature class, if found
  54296. */
  54297. getEnabledFeature(featureName: string): IWebXRFeature;
  54298. /**
  54299. * Get the list of enabled features
  54300. * @returns an array of enabled features
  54301. */
  54302. getEnabledFeatures(): string[];
  54303. /**
  54304. * This function will extend the session creation configuration object with enabled features.
  54305. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54306. * according to the defined "required" variable, provided during enableFeature call
  54307. * @param xrSessionInit the xr Session init object to extend
  54308. *
  54309. * @returns an extended XRSessionInit object
  54310. */
  54311. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54312. }
  54313. }
  54314. declare module BABYLON {
  54315. /**
  54316. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54317. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54318. */
  54319. export class WebXRExperienceHelper implements IDisposable {
  54320. private scene;
  54321. private _nonVRCamera;
  54322. private _originalSceneAutoClear;
  54323. private _supported;
  54324. /**
  54325. * Camera used to render xr content
  54326. */
  54327. camera: WebXRCamera;
  54328. /** A features manager for this xr session */
  54329. featuresManager: WebXRFeaturesManager;
  54330. /**
  54331. * Observers registered here will be triggered after the camera's initial transformation is set
  54332. * This can be used to set a different ground level or an extra rotation.
  54333. *
  54334. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54335. * to the position set after this observable is done executing.
  54336. */
  54337. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54338. /**
  54339. * Fires when the state of the experience helper has changed
  54340. */
  54341. onStateChangedObservable: Observable<WebXRState>;
  54342. /** Session manager used to keep track of xr session */
  54343. sessionManager: WebXRSessionManager;
  54344. /**
  54345. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54346. */
  54347. state: WebXRState;
  54348. /**
  54349. * Creates a WebXRExperienceHelper
  54350. * @param scene The scene the helper should be created in
  54351. */
  54352. private constructor();
  54353. /**
  54354. * Creates the experience helper
  54355. * @param scene the scene to attach the experience helper to
  54356. * @returns a promise for the experience helper
  54357. */
  54358. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54359. /**
  54360. * Disposes of the experience helper
  54361. */
  54362. dispose(): void;
  54363. /**
  54364. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54365. * @param sessionMode options for the XR session
  54366. * @param referenceSpaceType frame of reference of the XR session
  54367. * @param renderTarget the output canvas that will be used to enter XR mode
  54368. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54369. * @returns promise that resolves after xr mode has entered
  54370. */
  54371. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54372. /**
  54373. * Exits XR mode and returns the scene to its original state
  54374. * @returns promise that resolves after xr mode has exited
  54375. */
  54376. exitXRAsync(): Promise<void>;
  54377. private _nonXRToXRCamera;
  54378. private _setState;
  54379. }
  54380. }
  54381. declare module BABYLON {
  54382. /**
  54383. * X-Y values for axes in WebXR
  54384. */
  54385. export interface IWebXRMotionControllerAxesValue {
  54386. /**
  54387. * The value of the x axis
  54388. */
  54389. x: number;
  54390. /**
  54391. * The value of the y-axis
  54392. */
  54393. y: number;
  54394. }
  54395. /**
  54396. * changed / previous values for the values of this component
  54397. */
  54398. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54399. /**
  54400. * current (this frame) value
  54401. */
  54402. current: T;
  54403. /**
  54404. * previous (last change) value
  54405. */
  54406. previous: T;
  54407. }
  54408. /**
  54409. * Represents changes in the component between current frame and last values recorded
  54410. */
  54411. export interface IWebXRMotionControllerComponentChanges {
  54412. /**
  54413. * will be populated with previous and current values if axes changed
  54414. */
  54415. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54416. /**
  54417. * will be populated with previous and current values if pressed changed
  54418. */
  54419. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54420. /**
  54421. * will be populated with previous and current values if touched changed
  54422. */
  54423. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54424. /**
  54425. * will be populated with previous and current values if value changed
  54426. */
  54427. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54428. }
  54429. /**
  54430. * This class represents a single component (for example button or thumbstick) of a motion controller
  54431. */
  54432. export class WebXRControllerComponent implements IDisposable {
  54433. /**
  54434. * the id of this component
  54435. */
  54436. id: string;
  54437. /**
  54438. * the type of the component
  54439. */
  54440. type: MotionControllerComponentType;
  54441. private _buttonIndex;
  54442. private _axesIndices;
  54443. private _axes;
  54444. private _changes;
  54445. private _currentValue;
  54446. private _hasChanges;
  54447. private _pressed;
  54448. private _touched;
  54449. /**
  54450. * button component type
  54451. */
  54452. static BUTTON_TYPE: MotionControllerComponentType;
  54453. /**
  54454. * squeeze component type
  54455. */
  54456. static SQUEEZE_TYPE: MotionControllerComponentType;
  54457. /**
  54458. * Thumbstick component type
  54459. */
  54460. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54461. /**
  54462. * Touchpad component type
  54463. */
  54464. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54465. /**
  54466. * trigger component type
  54467. */
  54468. static TRIGGER_TYPE: MotionControllerComponentType;
  54469. /**
  54470. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54471. * the axes data changes
  54472. */
  54473. onAxisValueChangedObservable: Observable<{
  54474. x: number;
  54475. y: number;
  54476. }>;
  54477. /**
  54478. * Observers registered here will be triggered when the state of a button changes
  54479. * State change is either pressed / touched / value
  54480. */
  54481. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54482. /**
  54483. * Creates a new component for a motion controller.
  54484. * It is created by the motion controller itself
  54485. *
  54486. * @param id the id of this component
  54487. * @param type the type of the component
  54488. * @param _buttonIndex index in the buttons array of the gamepad
  54489. * @param _axesIndices indices of the values in the axes array of the gamepad
  54490. */
  54491. constructor(
  54492. /**
  54493. * the id of this component
  54494. */
  54495. id: string,
  54496. /**
  54497. * the type of the component
  54498. */
  54499. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54500. /**
  54501. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54502. */
  54503. get axes(): IWebXRMotionControllerAxesValue;
  54504. /**
  54505. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54506. */
  54507. get changes(): IWebXRMotionControllerComponentChanges;
  54508. /**
  54509. * Return whether or not the component changed the last frame
  54510. */
  54511. get hasChanges(): boolean;
  54512. /**
  54513. * is the button currently pressed
  54514. */
  54515. get pressed(): boolean;
  54516. /**
  54517. * is the button currently touched
  54518. */
  54519. get touched(): boolean;
  54520. /**
  54521. * Get the current value of this component
  54522. */
  54523. get value(): number;
  54524. /**
  54525. * Dispose this component
  54526. */
  54527. dispose(): void;
  54528. /**
  54529. * Are there axes correlating to this component
  54530. * @return true is axes data is available
  54531. */
  54532. isAxes(): boolean;
  54533. /**
  54534. * Is this component a button (hence - pressable)
  54535. * @returns true if can be pressed
  54536. */
  54537. isButton(): boolean;
  54538. /**
  54539. * update this component using the gamepad object it is in. Called on every frame
  54540. * @param nativeController the native gamepad controller object
  54541. */
  54542. update(nativeController: IMinimalMotionControllerObject): void;
  54543. }
  54544. }
  54545. declare module BABYLON {
  54546. /**
  54547. * Type used for the success callback of ImportMesh
  54548. */
  54549. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54550. /**
  54551. * Interface used for the result of ImportMeshAsync
  54552. */
  54553. export interface ISceneLoaderAsyncResult {
  54554. /**
  54555. * The array of loaded meshes
  54556. */
  54557. readonly meshes: AbstractMesh[];
  54558. /**
  54559. * The array of loaded particle systems
  54560. */
  54561. readonly particleSystems: IParticleSystem[];
  54562. /**
  54563. * The array of loaded skeletons
  54564. */
  54565. readonly skeletons: Skeleton[];
  54566. /**
  54567. * The array of loaded animation groups
  54568. */
  54569. readonly animationGroups: AnimationGroup[];
  54570. /**
  54571. * The array of loaded transform nodes
  54572. */
  54573. readonly transformNodes: TransformNode[];
  54574. /**
  54575. * The array of loaded geometries
  54576. */
  54577. readonly geometries: Geometry[];
  54578. /**
  54579. * The array of loaded lights
  54580. */
  54581. readonly lights: Light[];
  54582. }
  54583. /**
  54584. * Interface used to represent data loading progression
  54585. */
  54586. export interface ISceneLoaderProgressEvent {
  54587. /**
  54588. * Defines if data length to load can be evaluated
  54589. */
  54590. readonly lengthComputable: boolean;
  54591. /**
  54592. * Defines the loaded data length
  54593. */
  54594. readonly loaded: number;
  54595. /**
  54596. * Defines the data length to load
  54597. */
  54598. readonly total: number;
  54599. }
  54600. /**
  54601. * Interface used by SceneLoader plugins to define supported file extensions
  54602. */
  54603. export interface ISceneLoaderPluginExtensions {
  54604. /**
  54605. * Defines the list of supported extensions
  54606. */
  54607. [extension: string]: {
  54608. isBinary: boolean;
  54609. };
  54610. }
  54611. /**
  54612. * Interface used by SceneLoader plugin factory
  54613. */
  54614. export interface ISceneLoaderPluginFactory {
  54615. /**
  54616. * Defines the name of the factory
  54617. */
  54618. name: string;
  54619. /**
  54620. * Function called to create a new plugin
  54621. * @return the new plugin
  54622. */
  54623. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54624. /**
  54625. * The callback that returns true if the data can be directly loaded.
  54626. * @param data string containing the file data
  54627. * @returns if the data can be loaded directly
  54628. */
  54629. canDirectLoad?(data: string): boolean;
  54630. }
  54631. /**
  54632. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54633. */
  54634. export interface ISceneLoaderPluginBase {
  54635. /**
  54636. * The friendly name of this plugin.
  54637. */
  54638. name: string;
  54639. /**
  54640. * The file extensions supported by this plugin.
  54641. */
  54642. extensions: string | ISceneLoaderPluginExtensions;
  54643. /**
  54644. * The callback called when loading from a url.
  54645. * @param scene scene loading this url
  54646. * @param url url to load
  54647. * @param onSuccess callback called when the file successfully loads
  54648. * @param onProgress callback called while file is loading (if the server supports this mode)
  54649. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54650. * @param onError callback called when the file fails to load
  54651. * @returns a file request object
  54652. */
  54653. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54654. /**
  54655. * The callback called when loading from a file object.
  54656. * @param scene scene loading this file
  54657. * @param file defines the file to load
  54658. * @param onSuccess defines the callback to call when data is loaded
  54659. * @param onProgress defines the callback to call during loading process
  54660. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54661. * @param onError defines the callback to call when an error occurs
  54662. * @returns a file request object
  54663. */
  54664. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54665. /**
  54666. * The callback that returns true if the data can be directly loaded.
  54667. * @param data string containing the file data
  54668. * @returns if the data can be loaded directly
  54669. */
  54670. canDirectLoad?(data: string): boolean;
  54671. /**
  54672. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54673. * @param scene scene loading this data
  54674. * @param data string containing the data
  54675. * @returns data to pass to the plugin
  54676. */
  54677. directLoad?(scene: Scene, data: string): any;
  54678. /**
  54679. * The callback that allows custom handling of the root url based on the response url.
  54680. * @param rootUrl the original root url
  54681. * @param responseURL the response url if available
  54682. * @returns the new root url
  54683. */
  54684. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54685. }
  54686. /**
  54687. * Interface used to define a SceneLoader plugin
  54688. */
  54689. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54690. /**
  54691. * Import meshes into a scene.
  54692. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54693. * @param scene The scene to import into
  54694. * @param data The data to import
  54695. * @param rootUrl The root url for scene and resources
  54696. * @param meshes The meshes array to import into
  54697. * @param particleSystems The particle systems array to import into
  54698. * @param skeletons The skeletons array to import into
  54699. * @param onError The callback when import fails
  54700. * @returns True if successful or false otherwise
  54701. */
  54702. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54703. /**
  54704. * Load into a scene.
  54705. * @param scene The scene to load into
  54706. * @param data The data to import
  54707. * @param rootUrl The root url for scene and resources
  54708. * @param onError The callback when import fails
  54709. * @returns True if successful or false otherwise
  54710. */
  54711. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54712. /**
  54713. * Load into an asset container.
  54714. * @param scene The scene to load into
  54715. * @param data The data to import
  54716. * @param rootUrl The root url for scene and resources
  54717. * @param onError The callback when import fails
  54718. * @returns The loaded asset container
  54719. */
  54720. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54721. }
  54722. /**
  54723. * Interface used to define an async SceneLoader plugin
  54724. */
  54725. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54726. /**
  54727. * Import meshes into a scene.
  54728. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54729. * @param scene The scene to import into
  54730. * @param data The data to import
  54731. * @param rootUrl The root url for scene and resources
  54732. * @param onProgress The callback when the load progresses
  54733. * @param fileName Defines the name of the file to load
  54734. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54735. */
  54736. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54737. /**
  54738. * Load into a scene.
  54739. * @param scene The scene to load into
  54740. * @param data The data to import
  54741. * @param rootUrl The root url for scene and resources
  54742. * @param onProgress The callback when the load progresses
  54743. * @param fileName Defines the name of the file to load
  54744. * @returns Nothing
  54745. */
  54746. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54747. /**
  54748. * Load into an asset container.
  54749. * @param scene The scene to load into
  54750. * @param data The data to import
  54751. * @param rootUrl The root url for scene and resources
  54752. * @param onProgress The callback when the load progresses
  54753. * @param fileName Defines the name of the file to load
  54754. * @returns The loaded asset container
  54755. */
  54756. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54757. }
  54758. /**
  54759. * Mode that determines how to handle old animation groups before loading new ones.
  54760. */
  54761. export enum SceneLoaderAnimationGroupLoadingMode {
  54762. /**
  54763. * Reset all old animations to initial state then dispose them.
  54764. */
  54765. Clean = 0,
  54766. /**
  54767. * Stop all old animations.
  54768. */
  54769. Stop = 1,
  54770. /**
  54771. * Restart old animations from first frame.
  54772. */
  54773. Sync = 2,
  54774. /**
  54775. * Old animations remains untouched.
  54776. */
  54777. NoSync = 3
  54778. }
  54779. /**
  54780. * Defines a plugin registered by the SceneLoader
  54781. */
  54782. interface IRegisteredPlugin {
  54783. /**
  54784. * Defines the plugin to use
  54785. */
  54786. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54787. /**
  54788. * Defines if the plugin supports binary data
  54789. */
  54790. isBinary: boolean;
  54791. }
  54792. /**
  54793. * Class used to load scene from various file formats using registered plugins
  54794. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54795. */
  54796. export class SceneLoader {
  54797. /**
  54798. * No logging while loading
  54799. */
  54800. static readonly NO_LOGGING: number;
  54801. /**
  54802. * Minimal logging while loading
  54803. */
  54804. static readonly MINIMAL_LOGGING: number;
  54805. /**
  54806. * Summary logging while loading
  54807. */
  54808. static readonly SUMMARY_LOGGING: number;
  54809. /**
  54810. * Detailed logging while loading
  54811. */
  54812. static readonly DETAILED_LOGGING: number;
  54813. /**
  54814. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54815. */
  54816. static get ForceFullSceneLoadingForIncremental(): boolean;
  54817. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54818. /**
  54819. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54820. */
  54821. static get ShowLoadingScreen(): boolean;
  54822. static set ShowLoadingScreen(value: boolean);
  54823. /**
  54824. * Defines the current logging level (while loading the scene)
  54825. * @ignorenaming
  54826. */
  54827. static get loggingLevel(): number;
  54828. static set loggingLevel(value: number);
  54829. /**
  54830. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54831. */
  54832. static get CleanBoneMatrixWeights(): boolean;
  54833. static set CleanBoneMatrixWeights(value: boolean);
  54834. /**
  54835. * Event raised when a plugin is used to load a scene
  54836. */
  54837. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54838. private static _registeredPlugins;
  54839. private static _showingLoadingScreen;
  54840. /**
  54841. * Gets the default plugin (used to load Babylon files)
  54842. * @returns the .babylon plugin
  54843. */
  54844. static GetDefaultPlugin(): IRegisteredPlugin;
  54845. private static _GetPluginForExtension;
  54846. private static _GetPluginForDirectLoad;
  54847. private static _GetPluginForFilename;
  54848. private static _GetDirectLoad;
  54849. private static _LoadData;
  54850. private static _GetFileInfo;
  54851. /**
  54852. * Gets a plugin that can load the given extension
  54853. * @param extension defines the extension to load
  54854. * @returns a plugin or null if none works
  54855. */
  54856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54857. /**
  54858. * Gets a boolean indicating that the given extension can be loaded
  54859. * @param extension defines the extension to load
  54860. * @returns true if the extension is supported
  54861. */
  54862. static IsPluginForExtensionAvailable(extension: string): boolean;
  54863. /**
  54864. * Adds a new plugin to the list of registered plugins
  54865. * @param plugin defines the plugin to add
  54866. */
  54867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54868. /**
  54869. * Import meshes into a scene
  54870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54871. * @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)
  54872. * @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)
  54873. * @param scene the instance of BABYLON.Scene to append to
  54874. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54875. * @param onProgress a callback with a progress event for each file being loaded
  54876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54877. * @param pluginExtension the extension used to determine the plugin
  54878. * @returns The loaded plugin
  54879. */
  54880. 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>;
  54881. /**
  54882. * Import meshes into a scene
  54883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54884. * @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)
  54885. * @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)
  54886. * @param scene the instance of BABYLON.Scene to append to
  54887. * @param onProgress a callback with a progress event for each file being loaded
  54888. * @param pluginExtension the extension used to determine the plugin
  54889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54890. */
  54891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54892. /**
  54893. * Load a scene
  54894. * @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)
  54895. * @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)
  54896. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54897. * @param onSuccess a callback with the scene when import succeeds
  54898. * @param onProgress a callback with a progress event for each file being loaded
  54899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54900. * @param pluginExtension the extension used to determine the plugin
  54901. * @returns The loaded plugin
  54902. */
  54903. 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>;
  54904. /**
  54905. * Load a scene
  54906. * @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)
  54907. * @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)
  54908. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54909. * @param onProgress a callback with a progress event for each file being loaded
  54910. * @param pluginExtension the extension used to determine the plugin
  54911. * @returns The loaded scene
  54912. */
  54913. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54914. /**
  54915. * Append a scene
  54916. * @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)
  54917. * @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)
  54918. * @param scene is the instance of BABYLON.Scene to append to
  54919. * @param onSuccess a callback with the scene when import succeeds
  54920. * @param onProgress a callback with a progress event for each file being loaded
  54921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54922. * @param pluginExtension the extension used to determine the plugin
  54923. * @returns The loaded plugin
  54924. */
  54925. 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>;
  54926. /**
  54927. * Append a scene
  54928. * @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)
  54929. * @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)
  54930. * @param scene is the instance of BABYLON.Scene to append to
  54931. * @param onProgress a callback with a progress event for each file being loaded
  54932. * @param pluginExtension the extension used to determine the plugin
  54933. * @returns The given scene
  54934. */
  54935. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54936. /**
  54937. * Load a scene into an asset container
  54938. * @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)
  54939. * @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)
  54940. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54941. * @param onSuccess a callback with the scene when import succeeds
  54942. * @param onProgress a callback with a progress event for each file being loaded
  54943. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54944. * @param pluginExtension the extension used to determine the plugin
  54945. * @returns The loaded plugin
  54946. */
  54947. 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>;
  54948. /**
  54949. * Load a scene into an asset container
  54950. * @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)
  54951. * @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)
  54952. * @param scene is the instance of Scene to append to
  54953. * @param onProgress a callback with a progress event for each file being loaded
  54954. * @param pluginExtension the extension used to determine the plugin
  54955. * @returns The loaded asset container
  54956. */
  54957. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54958. /**
  54959. * Import animations from a file into a scene
  54960. * @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)
  54961. * @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)
  54962. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54963. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54964. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54965. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54966. * @param onSuccess a callback with the scene when import succeeds
  54967. * @param onProgress a callback with a progress event for each file being loaded
  54968. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54969. * @param pluginExtension the extension used to determine the plugin
  54970. */
  54971. 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;
  54972. /**
  54973. * Import animations from a file into a scene
  54974. * @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)
  54975. * @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)
  54976. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54977. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54978. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54979. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54980. * @param onSuccess a callback with the scene when import succeeds
  54981. * @param onProgress a callback with a progress event for each file being loaded
  54982. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54983. * @param pluginExtension the extension used to determine the plugin
  54984. * @returns the updated scene with imported animations
  54985. */
  54986. 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>;
  54987. }
  54988. }
  54989. declare module BABYLON {
  54990. /**
  54991. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54992. */
  54993. export type MotionControllerHandedness = "none" | "left" | "right";
  54994. /**
  54995. * The type of components available in motion controllers.
  54996. * This is not the name of the component.
  54997. */
  54998. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54999. /**
  55000. * The state of a controller component
  55001. */
  55002. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55003. /**
  55004. * The schema of motion controller layout.
  55005. * No object will be initialized using this interface
  55006. * This is used just to define the profile.
  55007. */
  55008. export interface IMotionControllerLayout {
  55009. /**
  55010. * Path to load the assets. Usually relative to the base path
  55011. */
  55012. assetPath: string;
  55013. /**
  55014. * Available components (unsorted)
  55015. */
  55016. components: {
  55017. /**
  55018. * A map of component Ids
  55019. */
  55020. [componentId: string]: {
  55021. /**
  55022. * The type of input the component outputs
  55023. */
  55024. type: MotionControllerComponentType;
  55025. /**
  55026. * The indices of this component in the gamepad object
  55027. */
  55028. gamepadIndices: {
  55029. /**
  55030. * Index of button
  55031. */
  55032. button?: number;
  55033. /**
  55034. * If available, index of x-axis
  55035. */
  55036. xAxis?: number;
  55037. /**
  55038. * If available, index of y-axis
  55039. */
  55040. yAxis?: number;
  55041. };
  55042. /**
  55043. * The mesh's root node name
  55044. */
  55045. rootNodeName: string;
  55046. /**
  55047. * Animation definitions for this model
  55048. */
  55049. visualResponses: {
  55050. [stateKey: string]: {
  55051. /**
  55052. * What property will be animated
  55053. */
  55054. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55055. /**
  55056. * What states influence this visual response
  55057. */
  55058. states: MotionControllerComponentStateType[];
  55059. /**
  55060. * Type of animation - movement or visibility
  55061. */
  55062. valueNodeProperty: "transform" | "visibility";
  55063. /**
  55064. * Base node name to move. Its position will be calculated according to the min and max nodes
  55065. */
  55066. valueNodeName?: string;
  55067. /**
  55068. * Minimum movement node
  55069. */
  55070. minNodeName?: string;
  55071. /**
  55072. * Max movement node
  55073. */
  55074. maxNodeName?: string;
  55075. };
  55076. };
  55077. /**
  55078. * If touch enabled, what is the name of node to display user feedback
  55079. */
  55080. touchPointNodeName?: string;
  55081. };
  55082. };
  55083. /**
  55084. * Is it xr standard mapping or not
  55085. */
  55086. gamepadMapping: "" | "xr-standard";
  55087. /**
  55088. * Base root node of this entire model
  55089. */
  55090. rootNodeName: string;
  55091. /**
  55092. * Defines the main button component id
  55093. */
  55094. selectComponentId: string;
  55095. }
  55096. /**
  55097. * A definition for the layout map in the input profile
  55098. */
  55099. export interface IMotionControllerLayoutMap {
  55100. /**
  55101. * Layouts with handedness type as a key
  55102. */
  55103. [handedness: string]: IMotionControllerLayout;
  55104. }
  55105. /**
  55106. * The XR Input profile schema
  55107. * Profiles can be found here:
  55108. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55109. */
  55110. export interface IMotionControllerProfile {
  55111. /**
  55112. * fallback profiles for this profileId
  55113. */
  55114. fallbackProfileIds: string[];
  55115. /**
  55116. * The layout map, with handedness as key
  55117. */
  55118. layouts: IMotionControllerLayoutMap;
  55119. /**
  55120. * The id of this profile
  55121. * correlates to the profile(s) in the xrInput.profiles array
  55122. */
  55123. profileId: string;
  55124. }
  55125. /**
  55126. * A helper-interface for the 3 meshes needed for controller button animation
  55127. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55128. */
  55129. export interface IMotionControllerButtonMeshMap {
  55130. /**
  55131. * the mesh that defines the pressed value mesh position.
  55132. * This is used to find the max-position of this button
  55133. */
  55134. pressedMesh: AbstractMesh;
  55135. /**
  55136. * the mesh that defines the unpressed value mesh position.
  55137. * This is used to find the min (or initial) position of this button
  55138. */
  55139. unpressedMesh: AbstractMesh;
  55140. /**
  55141. * The mesh that will be changed when value changes
  55142. */
  55143. valueMesh: AbstractMesh;
  55144. }
  55145. /**
  55146. * A helper-interface for the 3 meshes needed for controller axis animation.
  55147. * This will be expanded when touchpad animations are fully supported
  55148. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55149. */
  55150. export interface IMotionControllerMeshMap {
  55151. /**
  55152. * the mesh that defines the maximum value mesh position.
  55153. */
  55154. maxMesh?: AbstractMesh;
  55155. /**
  55156. * the mesh that defines the minimum value mesh position.
  55157. */
  55158. minMesh?: AbstractMesh;
  55159. /**
  55160. * The mesh that will be changed when axis value changes
  55161. */
  55162. valueMesh?: AbstractMesh;
  55163. }
  55164. /**
  55165. * The elements needed for change-detection of the gamepad objects in motion controllers
  55166. */
  55167. export interface IMinimalMotionControllerObject {
  55168. /**
  55169. * Available axes of this controller
  55170. */
  55171. axes: number[];
  55172. /**
  55173. * An array of available buttons
  55174. */
  55175. buttons: Array<{
  55176. /**
  55177. * Value of the button/trigger
  55178. */
  55179. value: number;
  55180. /**
  55181. * If the button/trigger is currently touched
  55182. */
  55183. touched: boolean;
  55184. /**
  55185. * If the button/trigger is currently pressed
  55186. */
  55187. pressed: boolean;
  55188. }>;
  55189. /**
  55190. * EXPERIMENTAL haptic support.
  55191. */
  55192. hapticActuators?: Array<{
  55193. pulse: (value: number, duration: number) => Promise<boolean>;
  55194. }>;
  55195. }
  55196. /**
  55197. * An Abstract Motion controller
  55198. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55199. * Each component has an observable to check for changes in value and state
  55200. */
  55201. export abstract class WebXRAbstractMotionController implements IDisposable {
  55202. protected scene: Scene;
  55203. protected layout: IMotionControllerLayout;
  55204. /**
  55205. * The gamepad object correlating to this controller
  55206. */
  55207. gamepadObject: IMinimalMotionControllerObject;
  55208. /**
  55209. * handedness (left/right/none) of this controller
  55210. */
  55211. handedness: MotionControllerHandedness;
  55212. private _initComponent;
  55213. private _modelReady;
  55214. /**
  55215. * A map of components (WebXRControllerComponent) in this motion controller
  55216. * Components have a ComponentType and can also have both button and axis definitions
  55217. */
  55218. readonly components: {
  55219. [id: string]: WebXRControllerComponent;
  55220. };
  55221. /**
  55222. * Disable the model's animation. Can be set at any time.
  55223. */
  55224. disableAnimation: boolean;
  55225. /**
  55226. * Observers registered here will be triggered when the model of this controller is done loading
  55227. */
  55228. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55229. /**
  55230. * The profile id of this motion controller
  55231. */
  55232. abstract profileId: string;
  55233. /**
  55234. * The root mesh of the model. It is null if the model was not yet initialized
  55235. */
  55236. rootMesh: Nullable<AbstractMesh>;
  55237. /**
  55238. * constructs a new abstract motion controller
  55239. * @param scene the scene to which the model of the controller will be added
  55240. * @param layout The profile layout to load
  55241. * @param gamepadObject The gamepad object correlating to this controller
  55242. * @param handedness handedness (left/right/none) of this controller
  55243. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55244. */
  55245. constructor(scene: Scene, layout: IMotionControllerLayout,
  55246. /**
  55247. * The gamepad object correlating to this controller
  55248. */
  55249. gamepadObject: IMinimalMotionControllerObject,
  55250. /**
  55251. * handedness (left/right/none) of this controller
  55252. */
  55253. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55254. /**
  55255. * Dispose this controller, the model mesh and all its components
  55256. */
  55257. dispose(): void;
  55258. /**
  55259. * Returns all components of specific type
  55260. * @param type the type to search for
  55261. * @return an array of components with this type
  55262. */
  55263. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55264. /**
  55265. * get a component based an its component id as defined in layout.components
  55266. * @param id the id of the component
  55267. * @returns the component correlates to the id or undefined if not found
  55268. */
  55269. getComponent(id: string): WebXRControllerComponent;
  55270. /**
  55271. * Get the list of components available in this motion controller
  55272. * @returns an array of strings correlating to available components
  55273. */
  55274. getComponentIds(): string[];
  55275. /**
  55276. * Get the first component of specific type
  55277. * @param type type of component to find
  55278. * @return a controller component or null if not found
  55279. */
  55280. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55281. /**
  55282. * Get the main (Select) component of this controller as defined in the layout
  55283. * @returns the main component of this controller
  55284. */
  55285. getMainComponent(): WebXRControllerComponent;
  55286. /**
  55287. * Loads the model correlating to this controller
  55288. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55289. * @returns A promise fulfilled with the result of the model loading
  55290. */
  55291. loadModel(): Promise<boolean>;
  55292. /**
  55293. * Update this model using the current XRFrame
  55294. * @param xrFrame the current xr frame to use and update the model
  55295. */
  55296. updateFromXRFrame(xrFrame: XRFrame): void;
  55297. /**
  55298. * Backwards compatibility due to a deeply-integrated typo
  55299. */
  55300. get handness(): XREye;
  55301. /**
  55302. * Pulse (vibrate) this controller
  55303. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55304. * Consecutive calls to this function will cancel the last pulse call
  55305. *
  55306. * @param value the strength of the pulse in 0.0...1.0 range
  55307. * @param duration Duration of the pulse in milliseconds
  55308. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55309. * @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
  55310. */
  55311. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55312. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55313. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55314. /**
  55315. * Moves the axis on the controller mesh based on its current state
  55316. * @param axis the index of the axis
  55317. * @param axisValue the value of the axis which determines the meshes new position
  55318. * @hidden
  55319. */
  55320. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55321. /**
  55322. * Update the model itself with the current frame data
  55323. * @param xrFrame the frame to use for updating the model mesh
  55324. */
  55325. protected updateModel(xrFrame: XRFrame): void;
  55326. /**
  55327. * Get the filename and path for this controller's model
  55328. * @returns a map of filename and path
  55329. */
  55330. protected abstract _getFilenameAndPath(): {
  55331. filename: string;
  55332. path: string;
  55333. };
  55334. /**
  55335. * This function is called before the mesh is loaded. It checks for loading constraints.
  55336. * For example, this function can check if the GLB loader is available
  55337. * If this function returns false, the generic controller will be loaded instead
  55338. * @returns Is the client ready to load the mesh
  55339. */
  55340. protected abstract _getModelLoadingConstraints(): boolean;
  55341. /**
  55342. * This function will be called after the model was successfully loaded and can be used
  55343. * for mesh transformations before it is available for the user
  55344. * @param meshes the loaded meshes
  55345. */
  55346. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55347. /**
  55348. * Set the root mesh for this controller. Important for the WebXR controller class
  55349. * @param meshes the loaded meshes
  55350. */
  55351. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55352. /**
  55353. * A function executed each frame that updates the mesh (if needed)
  55354. * @param xrFrame the current xrFrame
  55355. */
  55356. protected abstract _updateModel(xrFrame: XRFrame): void;
  55357. private _getGenericFilenameAndPath;
  55358. private _getGenericParentMesh;
  55359. }
  55360. }
  55361. declare module BABYLON {
  55362. /**
  55363. * A generic trigger-only motion controller for WebXR
  55364. */
  55365. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55366. /**
  55367. * Static version of the profile id of this controller
  55368. */
  55369. static ProfileId: string;
  55370. profileId: string;
  55371. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55372. protected _getFilenameAndPath(): {
  55373. filename: string;
  55374. path: string;
  55375. };
  55376. protected _getModelLoadingConstraints(): boolean;
  55377. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55378. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55379. protected _updateModel(): void;
  55380. }
  55381. }
  55382. declare module BABYLON {
  55383. /**
  55384. * Class containing static functions to help procedurally build meshes
  55385. */
  55386. export class SphereBuilder {
  55387. /**
  55388. * Creates a sphere mesh
  55389. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55390. * * 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`)
  55391. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55392. * * 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
  55393. * * 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)
  55394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55395. * * 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
  55396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55397. * @param name defines the name of the mesh
  55398. * @param options defines the options used to create the mesh
  55399. * @param scene defines the hosting scene
  55400. * @returns the sphere mesh
  55401. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55402. */
  55403. static CreateSphere(name: string, options: {
  55404. segments?: number;
  55405. diameter?: number;
  55406. diameterX?: number;
  55407. diameterY?: number;
  55408. diameterZ?: number;
  55409. arc?: number;
  55410. slice?: number;
  55411. sideOrientation?: number;
  55412. frontUVs?: Vector4;
  55413. backUVs?: Vector4;
  55414. updatable?: boolean;
  55415. }, scene?: Nullable<Scene>): Mesh;
  55416. }
  55417. }
  55418. declare module BABYLON {
  55419. /**
  55420. * A profiled motion controller has its profile loaded from an online repository.
  55421. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55422. */
  55423. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55424. private _repositoryUrl;
  55425. private _buttonMeshMapping;
  55426. private _touchDots;
  55427. /**
  55428. * The profile ID of this controller. Will be populated when the controller initializes.
  55429. */
  55430. profileId: string;
  55431. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55432. dispose(): void;
  55433. protected _getFilenameAndPath(): {
  55434. filename: string;
  55435. path: string;
  55436. };
  55437. protected _getModelLoadingConstraints(): boolean;
  55438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55439. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55440. protected _updateModel(_xrFrame: XRFrame): void;
  55441. }
  55442. }
  55443. declare module BABYLON {
  55444. /**
  55445. * A construction function type to create a new controller based on an xrInput object
  55446. */
  55447. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55448. /**
  55449. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55450. *
  55451. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55452. * it should be replaced with auto-loaded controllers.
  55453. *
  55454. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55455. */
  55456. export class WebXRMotionControllerManager {
  55457. private static _AvailableControllers;
  55458. private static _Fallbacks;
  55459. private static _ProfileLoadingPromises;
  55460. private static _ProfilesList;
  55461. /**
  55462. * The base URL of the online controller repository. Can be changed at any time.
  55463. */
  55464. static BaseRepositoryUrl: string;
  55465. /**
  55466. * Which repository gets priority - local or online
  55467. */
  55468. static PrioritizeOnlineRepository: boolean;
  55469. /**
  55470. * Use the online repository, or use only locally-defined controllers
  55471. */
  55472. static UseOnlineRepository: boolean;
  55473. /**
  55474. * Clear the cache used for profile loading and reload when requested again
  55475. */
  55476. static ClearProfilesCache(): void;
  55477. /**
  55478. * Register the default fallbacks.
  55479. * This function is called automatically when this file is imported.
  55480. */
  55481. static DefaultFallbacks(): void;
  55482. /**
  55483. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55484. * @param profileId the profile to which a fallback needs to be found
  55485. * @return an array with corresponding fallback profiles
  55486. */
  55487. static FindFallbackWithProfileId(profileId: string): string[];
  55488. /**
  55489. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55490. * The order of search:
  55491. *
  55492. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55493. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55494. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55495. * 4) return the generic trigger controller if none were found
  55496. *
  55497. * @param xrInput the xrInput to which a new controller is initialized
  55498. * @param scene the scene to which the model will be added
  55499. * @param forceProfile force a certain profile for this controller
  55500. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55501. */
  55502. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55503. /**
  55504. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55505. *
  55506. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55507. *
  55508. * @param type the profile type to register
  55509. * @param constructFunction the function to be called when loading this profile
  55510. */
  55511. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55512. /**
  55513. * Register a fallback to a specific profile.
  55514. * @param profileId the profileId that will receive the fallbacks
  55515. * @param fallbacks A list of fallback profiles
  55516. */
  55517. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55518. /**
  55519. * Will update the list of profiles available in the repository
  55520. * @return a promise that resolves to a map of profiles available online
  55521. */
  55522. static UpdateProfilesList(): Promise<{
  55523. [profile: string]: string;
  55524. }>;
  55525. private static _LoadProfileFromRepository;
  55526. private static _LoadProfilesFromAvailableControllers;
  55527. }
  55528. }
  55529. declare module BABYLON {
  55530. /**
  55531. * Configuration options for the WebXR controller creation
  55532. */
  55533. export interface IWebXRControllerOptions {
  55534. /**
  55535. * Should the controller mesh be animated when a user interacts with it
  55536. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55537. */
  55538. disableMotionControllerAnimation?: boolean;
  55539. /**
  55540. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55541. */
  55542. doNotLoadControllerMesh?: boolean;
  55543. /**
  55544. * Force a specific controller type for this controller.
  55545. * This can be used when creating your own profile or when testing different controllers
  55546. */
  55547. forceControllerProfile?: string;
  55548. /**
  55549. * Defines a rendering group ID for meshes that will be loaded.
  55550. * This is for the default controllers only.
  55551. */
  55552. renderingGroupId?: number;
  55553. }
  55554. /**
  55555. * Represents an XR controller
  55556. */
  55557. export class WebXRInputSource {
  55558. private _scene;
  55559. /** The underlying input source for the controller */
  55560. inputSource: XRInputSource;
  55561. private _options;
  55562. private _tmpVector;
  55563. private _uniqueId;
  55564. private _disposed;
  55565. /**
  55566. * 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
  55567. */
  55568. grip?: AbstractMesh;
  55569. /**
  55570. * If available, this is the gamepad object related to this controller.
  55571. * Using this object it is possible to get click events and trackpad changes of the
  55572. * webxr controller that is currently being used.
  55573. */
  55574. motionController?: WebXRAbstractMotionController;
  55575. /**
  55576. * Event that fires when the controller is removed/disposed.
  55577. * The object provided as event data is this controller, after associated assets were disposed.
  55578. * uniqueId is still available.
  55579. */
  55580. onDisposeObservable: Observable<WebXRInputSource>;
  55581. /**
  55582. * Will be triggered when the mesh associated with the motion controller is done loading.
  55583. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55584. * A shortened version of controller -> motion controller -> on mesh loaded.
  55585. */
  55586. onMeshLoadedObservable: Observable<AbstractMesh>;
  55587. /**
  55588. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55589. */
  55590. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55591. /**
  55592. * Pointer which can be used to select objects or attach a visible laser to
  55593. */
  55594. pointer: AbstractMesh;
  55595. /**
  55596. * Creates the input source object
  55597. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55598. * @param _scene the scene which the controller should be associated to
  55599. * @param inputSource the underlying input source for the controller
  55600. * @param _options options for this controller creation
  55601. */
  55602. constructor(_scene: Scene,
  55603. /** The underlying input source for the controller */
  55604. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55605. /**
  55606. * Get this controllers unique id
  55607. */
  55608. get uniqueId(): string;
  55609. /**
  55610. * Disposes of the object
  55611. */
  55612. dispose(): void;
  55613. /**
  55614. * Gets a world space ray coming from the pointer or grip
  55615. * @param result the resulting ray
  55616. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55617. */
  55618. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55619. /**
  55620. * Updates the controller pose based on the given XRFrame
  55621. * @param xrFrame xr frame to update the pose with
  55622. * @param referenceSpace reference space to use
  55623. */
  55624. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55625. }
  55626. }
  55627. declare module BABYLON {
  55628. /**
  55629. * The schema for initialization options of the XR Input class
  55630. */
  55631. export interface IWebXRInputOptions {
  55632. /**
  55633. * If set to true no model will be automatically loaded
  55634. */
  55635. doNotLoadControllerMeshes?: boolean;
  55636. /**
  55637. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55638. * If not found, the xr input profile data will be used.
  55639. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55640. */
  55641. forceInputProfile?: string;
  55642. /**
  55643. * Do not send a request to the controller repository to load the profile.
  55644. *
  55645. * Instead, use the controllers available in babylon itself.
  55646. */
  55647. disableOnlineControllerRepository?: boolean;
  55648. /**
  55649. * A custom URL for the controllers repository
  55650. */
  55651. customControllersRepositoryURL?: string;
  55652. /**
  55653. * Should the controller model's components not move according to the user input
  55654. */
  55655. disableControllerAnimation?: boolean;
  55656. /**
  55657. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55658. */
  55659. controllerOptions?: IWebXRControllerOptions;
  55660. }
  55661. /**
  55662. * XR input used to track XR inputs such as controllers/rays
  55663. */
  55664. export class WebXRInput implements IDisposable {
  55665. /**
  55666. * the xr session manager for this session
  55667. */
  55668. xrSessionManager: WebXRSessionManager;
  55669. /**
  55670. * the WebXR camera for this session. Mainly used for teleportation
  55671. */
  55672. xrCamera: WebXRCamera;
  55673. private readonly options;
  55674. /**
  55675. * XR controllers being tracked
  55676. */
  55677. controllers: Array<WebXRInputSource>;
  55678. private _frameObserver;
  55679. private _sessionEndedObserver;
  55680. private _sessionInitObserver;
  55681. /**
  55682. * Event when a controller has been connected/added
  55683. */
  55684. onControllerAddedObservable: Observable<WebXRInputSource>;
  55685. /**
  55686. * Event when a controller has been removed/disconnected
  55687. */
  55688. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55689. /**
  55690. * Initializes the WebXRInput
  55691. * @param xrSessionManager the xr session manager for this session
  55692. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55693. * @param options = initialization options for this xr input
  55694. */
  55695. constructor(
  55696. /**
  55697. * the xr session manager for this session
  55698. */
  55699. xrSessionManager: WebXRSessionManager,
  55700. /**
  55701. * the WebXR camera for this session. Mainly used for teleportation
  55702. */
  55703. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55704. private _onInputSourcesChange;
  55705. private _addAndRemoveControllers;
  55706. /**
  55707. * Disposes of the object
  55708. */
  55709. dispose(): void;
  55710. }
  55711. }
  55712. declare module BABYLON {
  55713. /**
  55714. * This is the base class for all WebXR features.
  55715. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55716. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55717. */
  55718. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55719. protected _xrSessionManager: WebXRSessionManager;
  55720. private _attached;
  55721. private _removeOnDetach;
  55722. /**
  55723. * Is this feature disposed?
  55724. */
  55725. isDisposed: boolean;
  55726. /**
  55727. * Should auto-attach be disabled?
  55728. */
  55729. disableAutoAttach: boolean;
  55730. /**
  55731. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55732. */
  55733. xrNativeFeatureName: string;
  55734. /**
  55735. * Construct a new (abstract) WebXR feature
  55736. * @param _xrSessionManager the xr session manager for this feature
  55737. */
  55738. constructor(_xrSessionManager: WebXRSessionManager);
  55739. /**
  55740. * Is this feature attached
  55741. */
  55742. get attached(): boolean;
  55743. /**
  55744. * attach this feature
  55745. *
  55746. * @param force should attachment be forced (even when already attached)
  55747. * @returns true if successful, false is failed or already attached
  55748. */
  55749. attach(force?: boolean): boolean;
  55750. /**
  55751. * detach this feature.
  55752. *
  55753. * @returns true if successful, false if failed or already detached
  55754. */
  55755. detach(): boolean;
  55756. /**
  55757. * Dispose this feature and all of the resources attached
  55758. */
  55759. dispose(): void;
  55760. /**
  55761. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55762. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55763. *
  55764. * @returns whether or not the feature is compatible in this environment
  55765. */
  55766. isCompatible(): boolean;
  55767. /**
  55768. * This is used to register callbacks that will automatically be removed when detach is called.
  55769. * @param observable the observable to which the observer will be attached
  55770. * @param callback the callback to register
  55771. */
  55772. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55773. /**
  55774. * Code in this function will be executed on each xrFrame received from the browser.
  55775. * This function will not execute after the feature is detached.
  55776. * @param _xrFrame the current frame
  55777. */
  55778. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55779. }
  55780. }
  55781. declare module BABYLON {
  55782. /**
  55783. * Renders a layer on top of an existing scene
  55784. */
  55785. export class UtilityLayerRenderer implements IDisposable {
  55786. /** the original scene that will be rendered on top of */
  55787. originalScene: Scene;
  55788. private _pointerCaptures;
  55789. private _lastPointerEvents;
  55790. private static _DefaultUtilityLayer;
  55791. private static _DefaultKeepDepthUtilityLayer;
  55792. private _sharedGizmoLight;
  55793. private _renderCamera;
  55794. /**
  55795. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55796. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55797. * @returns the camera that is used when rendering the utility layer
  55798. */
  55799. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55800. /**
  55801. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55802. * @param cam the camera that should be used when rendering the utility layer
  55803. */
  55804. setRenderCamera(cam: Nullable<Camera>): void;
  55805. /**
  55806. * @hidden
  55807. * Light which used by gizmos to get light shading
  55808. */
  55809. _getSharedGizmoLight(): HemisphericLight;
  55810. /**
  55811. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55812. */
  55813. pickUtilitySceneFirst: boolean;
  55814. /**
  55815. * 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)
  55816. */
  55817. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55818. /**
  55819. * 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)
  55820. */
  55821. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55822. /**
  55823. * The scene that is rendered on top of the original scene
  55824. */
  55825. utilityLayerScene: Scene;
  55826. /**
  55827. * If the utility layer should automatically be rendered on top of existing scene
  55828. */
  55829. shouldRender: boolean;
  55830. /**
  55831. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55832. */
  55833. onlyCheckPointerDownEvents: boolean;
  55834. /**
  55835. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55836. */
  55837. processAllEvents: boolean;
  55838. /**
  55839. * Observable raised when the pointer move from the utility layer scene to the main scene
  55840. */
  55841. onPointerOutObservable: Observable<number>;
  55842. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55843. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55844. private _afterRenderObserver;
  55845. private _sceneDisposeObserver;
  55846. private _originalPointerObserver;
  55847. /**
  55848. * Instantiates a UtilityLayerRenderer
  55849. * @param originalScene the original scene that will be rendered on top of
  55850. * @param handleEvents boolean indicating if the utility layer should handle events
  55851. */
  55852. constructor(
  55853. /** the original scene that will be rendered on top of */
  55854. originalScene: Scene, handleEvents?: boolean);
  55855. private _notifyObservers;
  55856. /**
  55857. * Renders the utility layers scene on top of the original scene
  55858. */
  55859. render(): void;
  55860. /**
  55861. * Disposes of the renderer
  55862. */
  55863. dispose(): void;
  55864. private _updateCamera;
  55865. }
  55866. }
  55867. declare module BABYLON {
  55868. /**
  55869. * Options interface for the pointer selection module
  55870. */
  55871. export interface IWebXRControllerPointerSelectionOptions {
  55872. /**
  55873. * if provided, this scene will be used to render meshes.
  55874. */
  55875. customUtilityLayerScene?: Scene;
  55876. /**
  55877. * 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)
  55878. * If not disabled, the last picked point will be used to execute a pointer up event
  55879. * If disabled, pointer up event will be triggered right after the pointer down event.
  55880. * Used in screen and gaze target ray mode only
  55881. */
  55882. disablePointerUpOnTouchOut: boolean;
  55883. /**
  55884. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55885. */
  55886. forceGazeMode: boolean;
  55887. /**
  55888. * 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
  55889. * to start a new countdown to the pointer down event.
  55890. * Defaults to 1.
  55891. */
  55892. gazeModePointerMovedFactor?: number;
  55893. /**
  55894. * Different button type to use instead of the main component
  55895. */
  55896. overrideButtonId?: string;
  55897. /**
  55898. * use this rendering group id for the meshes (optional)
  55899. */
  55900. renderingGroupId?: number;
  55901. /**
  55902. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55903. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55904. * 3000 means 3 seconds between pointing at something and selecting it
  55905. */
  55906. timeToSelect?: number;
  55907. /**
  55908. * Should meshes created here be added to a utility layer or the main scene
  55909. */
  55910. useUtilityLayer?: boolean;
  55911. /**
  55912. * Optional WebXR camera to be used for gaze selection
  55913. */
  55914. gazeCamera?: WebXRCamera;
  55915. /**
  55916. * the xr input to use with this pointer selection
  55917. */
  55918. xrInput: WebXRInput;
  55919. /**
  55920. * Should the scene pointerX and pointerY update be disabled
  55921. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55922. * Disable in VR, if not needed.
  55923. * The first rig camera (left eye) will be used to calculate the projection
  55924. */
  55925. disableScenePointerVectorUpdate: boolean;
  55926. /**
  55927. * Enable pointer selection on all controllers instead of switching between them
  55928. */
  55929. enablePointerSelectionOnAllControllers?: boolean;
  55930. /**
  55931. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55932. * If switch is enabled, it will still allow the user to switch between the different controllers
  55933. */
  55934. preferredHandedness?: XRHandedness;
  55935. /**
  55936. * Disable switching the pointer selection from one controller to the other.
  55937. * 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
  55938. */
  55939. disableSwitchOnClick?: boolean;
  55940. /**
  55941. * The maximum distance of the pointer selection feature. Defaults to 100.
  55942. */
  55943. maxPointerDistance?: number;
  55944. }
  55945. /**
  55946. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55947. */
  55948. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55949. private readonly _options;
  55950. private static _idCounter;
  55951. private _attachController;
  55952. private _controllers;
  55953. private _scene;
  55954. private _tmpVectorForPickCompare;
  55955. private _attachedController;
  55956. /**
  55957. * The module's name
  55958. */
  55959. static readonly Name: string;
  55960. /**
  55961. * The (Babylon) version of this module.
  55962. * This is an integer representing the implementation version.
  55963. * This number does not correspond to the WebXR specs version
  55964. */
  55965. static readonly Version: number;
  55966. /**
  55967. * Disable lighting on the laser pointer (so it will always be visible)
  55968. */
  55969. disablePointerLighting: boolean;
  55970. /**
  55971. * Disable lighting on the selection mesh (so it will always be visible)
  55972. */
  55973. disableSelectionMeshLighting: boolean;
  55974. /**
  55975. * Should the laser pointer be displayed
  55976. */
  55977. displayLaserPointer: boolean;
  55978. /**
  55979. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55980. */
  55981. displaySelectionMesh: boolean;
  55982. /**
  55983. * This color will be set to the laser pointer when selection is triggered
  55984. */
  55985. laserPointerPickedColor: Color3;
  55986. /**
  55987. * Default color of the laser pointer
  55988. */
  55989. laserPointerDefaultColor: Color3;
  55990. /**
  55991. * default color of the selection ring
  55992. */
  55993. selectionMeshDefaultColor: Color3;
  55994. /**
  55995. * This color will be applied to the selection ring when selection is triggered
  55996. */
  55997. selectionMeshPickedColor: Color3;
  55998. /**
  55999. * Optional filter to be used for ray selection. This predicate shares behavior with
  56000. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56001. */
  56002. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56003. /**
  56004. * constructs a new background remover module
  56005. * @param _xrSessionManager the session manager for this module
  56006. * @param _options read-only options to be used in this module
  56007. */
  56008. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56009. /**
  56010. * attach this feature
  56011. * Will usually be called by the features manager
  56012. *
  56013. * @returns true if successful.
  56014. */
  56015. attach(): boolean;
  56016. /**
  56017. * detach this feature.
  56018. * Will usually be called by the features manager
  56019. *
  56020. * @returns true if successful.
  56021. */
  56022. detach(): boolean;
  56023. /**
  56024. * Will get the mesh under a specific pointer.
  56025. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56026. * @param controllerId the controllerId to check
  56027. * @returns The mesh under pointer or null if no mesh is under the pointer
  56028. */
  56029. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56030. /**
  56031. * Get the xr controller that correlates to the pointer id in the pointer event
  56032. *
  56033. * @param id the pointer id to search for
  56034. * @returns the controller that correlates to this id or null if not found
  56035. */
  56036. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56037. private _identityMatrix;
  56038. private _screenCoordinatesRef;
  56039. private _viewportRef;
  56040. protected _onXRFrame(_xrFrame: XRFrame): void;
  56041. private _attachGazeMode;
  56042. private _attachScreenRayMode;
  56043. private _attachTrackedPointerRayMode;
  56044. private _convertNormalToDirectionOfRay;
  56045. private _detachController;
  56046. private _generateNewMeshPair;
  56047. private _pickingMoved;
  56048. private _updatePointerDistance;
  56049. /** @hidden */
  56050. get lasterPointerDefaultColor(): Color3;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Button which can be used to enter a different mode of XR
  56056. */
  56057. export class WebXREnterExitUIButton {
  56058. /** button element */
  56059. element: HTMLElement;
  56060. /** XR initialization options for the button */
  56061. sessionMode: XRSessionMode;
  56062. /** Reference space type */
  56063. referenceSpaceType: XRReferenceSpaceType;
  56064. /**
  56065. * Creates a WebXREnterExitUIButton
  56066. * @param element button element
  56067. * @param sessionMode XR initialization session mode
  56068. * @param referenceSpaceType the type of reference space to be used
  56069. */
  56070. constructor(
  56071. /** button element */
  56072. element: HTMLElement,
  56073. /** XR initialization options for the button */
  56074. sessionMode: XRSessionMode,
  56075. /** Reference space type */
  56076. referenceSpaceType: XRReferenceSpaceType);
  56077. /**
  56078. * Extendable function which can be used to update the button's visuals when the state changes
  56079. * @param activeButton the current active button in the UI
  56080. */
  56081. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56082. }
  56083. /**
  56084. * Options to create the webXR UI
  56085. */
  56086. export class WebXREnterExitUIOptions {
  56087. /**
  56088. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56089. */
  56090. customButtons?: Array<WebXREnterExitUIButton>;
  56091. /**
  56092. * A reference space type to use when creating the default button.
  56093. * Default is local-floor
  56094. */
  56095. referenceSpaceType?: XRReferenceSpaceType;
  56096. /**
  56097. * Context to enter xr with
  56098. */
  56099. renderTarget?: Nullable<WebXRRenderTarget>;
  56100. /**
  56101. * A session mode to use when creating the default button.
  56102. * Default is immersive-vr
  56103. */
  56104. sessionMode?: XRSessionMode;
  56105. /**
  56106. * A list of optional features to init the session with
  56107. */
  56108. optionalFeatures?: string[];
  56109. /**
  56110. * A list of optional features to init the session with
  56111. */
  56112. requiredFeatures?: string[];
  56113. /**
  56114. * If defined, this function will be executed if the UI encounters an error when entering XR
  56115. */
  56116. onError?: (error: any) => void;
  56117. }
  56118. /**
  56119. * UI to allow the user to enter/exit XR mode
  56120. */
  56121. export class WebXREnterExitUI implements IDisposable {
  56122. private scene;
  56123. /** version of the options passed to this UI */
  56124. options: WebXREnterExitUIOptions;
  56125. private _activeButton;
  56126. private _buttons;
  56127. /**
  56128. * The HTML Div Element to which buttons are added.
  56129. */
  56130. readonly overlay: HTMLDivElement;
  56131. /**
  56132. * Fired every time the active button is changed.
  56133. *
  56134. * When xr is entered via a button that launches xr that button will be the callback parameter
  56135. *
  56136. * When exiting xr the callback parameter will be null)
  56137. */
  56138. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56139. /**
  56140. *
  56141. * @param scene babylon scene object to use
  56142. * @param options (read-only) version of the options passed to this UI
  56143. */
  56144. private constructor();
  56145. /**
  56146. * Creates UI to allow the user to enter/exit XR mode
  56147. * @param scene the scene to add the ui to
  56148. * @param helper the xr experience helper to enter/exit xr with
  56149. * @param options options to configure the UI
  56150. * @returns the created ui
  56151. */
  56152. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56153. /**
  56154. * Disposes of the XR UI component
  56155. */
  56156. dispose(): void;
  56157. private _updateButtons;
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. /**
  56162. * Class containing static functions to help procedurally build meshes
  56163. */
  56164. export class LinesBuilder {
  56165. /**
  56166. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56167. * * 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
  56168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56169. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56170. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56171. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56172. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56173. * * 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
  56174. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56177. * @param name defines the name of the new line system
  56178. * @param options defines the options used to create the line system
  56179. * @param scene defines the hosting scene
  56180. * @returns a new line system mesh
  56181. */
  56182. static CreateLineSystem(name: string, options: {
  56183. lines: Vector3[][];
  56184. updatable?: boolean;
  56185. instance?: Nullable<LinesMesh>;
  56186. colors?: Nullable<Color4[][]>;
  56187. useVertexAlpha?: boolean;
  56188. }, scene: Nullable<Scene>): LinesMesh;
  56189. /**
  56190. * Creates a line mesh
  56191. * 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
  56192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56193. * * The parameter `points` is an array successive Vector3
  56194. * * 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
  56195. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56197. * * When updating an instance, remember that only point positions can change, not the number of points
  56198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56200. * @param name defines the name of the new line system
  56201. * @param options defines the options used to create the line system
  56202. * @param scene defines the hosting scene
  56203. * @returns a new line mesh
  56204. */
  56205. static CreateLines(name: string, options: {
  56206. points: Vector3[];
  56207. updatable?: boolean;
  56208. instance?: Nullable<LinesMesh>;
  56209. colors?: Color4[];
  56210. useVertexAlpha?: boolean;
  56211. }, scene?: Nullable<Scene>): LinesMesh;
  56212. /**
  56213. * Creates a dashed line mesh
  56214. * * 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
  56215. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56216. * * The parameter `points` is an array successive Vector3
  56217. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56218. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56219. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56220. * * 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
  56221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56222. * * When updating an instance, remember that only point positions can change, not the number of points
  56223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56224. * @param name defines the name of the mesh
  56225. * @param options defines the options used to create the mesh
  56226. * @param scene defines the hosting scene
  56227. * @returns the dashed line mesh
  56228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56229. */
  56230. static CreateDashedLines(name: string, options: {
  56231. points: Vector3[];
  56232. dashSize?: number;
  56233. gapSize?: number;
  56234. dashNb?: number;
  56235. updatable?: boolean;
  56236. instance?: LinesMesh;
  56237. useVertexAlpha?: boolean;
  56238. }, scene?: Nullable<Scene>): LinesMesh;
  56239. }
  56240. }
  56241. declare module BABYLON {
  56242. /**
  56243. * Construction options for a timer
  56244. */
  56245. export interface ITimerOptions<T> {
  56246. /**
  56247. * Time-to-end
  56248. */
  56249. timeout: number;
  56250. /**
  56251. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56252. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56253. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56254. */
  56255. contextObservable: Observable<T>;
  56256. /**
  56257. * Optional parameters when adding an observer to the observable
  56258. */
  56259. observableParameters?: {
  56260. mask?: number;
  56261. insertFirst?: boolean;
  56262. scope?: any;
  56263. };
  56264. /**
  56265. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56266. */
  56267. breakCondition?: (data?: ITimerData<T>) => boolean;
  56268. /**
  56269. * Will be triggered when the time condition has met
  56270. */
  56271. onEnded?: (data: ITimerData<any>) => void;
  56272. /**
  56273. * Will be triggered when the break condition has met (prematurely ended)
  56274. */
  56275. onAborted?: (data: ITimerData<any>) => void;
  56276. /**
  56277. * Optional function to execute on each tick (or count)
  56278. */
  56279. onTick?: (data: ITimerData<any>) => void;
  56280. }
  56281. /**
  56282. * An interface defining the data sent by the timer
  56283. */
  56284. export interface ITimerData<T> {
  56285. /**
  56286. * When did it start
  56287. */
  56288. startTime: number;
  56289. /**
  56290. * Time now
  56291. */
  56292. currentTime: number;
  56293. /**
  56294. * Time passed since started
  56295. */
  56296. deltaTime: number;
  56297. /**
  56298. * How much is completed, in [0.0...1.0].
  56299. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56300. */
  56301. completeRate: number;
  56302. /**
  56303. * What the registered observable sent in the last count
  56304. */
  56305. payload: T;
  56306. }
  56307. /**
  56308. * The current state of the timer
  56309. */
  56310. export enum TimerState {
  56311. /**
  56312. * Timer initialized, not yet started
  56313. */
  56314. INIT = 0,
  56315. /**
  56316. * Timer started and counting
  56317. */
  56318. STARTED = 1,
  56319. /**
  56320. * Timer ended (whether aborted or time reached)
  56321. */
  56322. ENDED = 2
  56323. }
  56324. /**
  56325. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56326. *
  56327. * @param options options with which to initialize this timer
  56328. */
  56329. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56330. /**
  56331. * An advanced implementation of a timer class
  56332. */
  56333. export class AdvancedTimer<T = any> implements IDisposable {
  56334. /**
  56335. * Will notify each time the timer calculates the remaining time
  56336. */
  56337. onEachCountObservable: Observable<ITimerData<T>>;
  56338. /**
  56339. * Will trigger when the timer was aborted due to the break condition
  56340. */
  56341. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56342. /**
  56343. * Will trigger when the timer ended successfully
  56344. */
  56345. onTimerEndedObservable: Observable<ITimerData<T>>;
  56346. /**
  56347. * Will trigger when the timer state has changed
  56348. */
  56349. onStateChangedObservable: Observable<TimerState>;
  56350. private _observer;
  56351. private _contextObservable;
  56352. private _observableParameters;
  56353. private _startTime;
  56354. private _timer;
  56355. private _state;
  56356. private _breakCondition;
  56357. private _timeToEnd;
  56358. private _breakOnNextTick;
  56359. /**
  56360. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56361. * @param options construction options for this advanced timer
  56362. */
  56363. constructor(options: ITimerOptions<T>);
  56364. /**
  56365. * set a breaking condition for this timer. Default is to never break during count
  56366. * @param predicate the new break condition. Returns true to break, false otherwise
  56367. */
  56368. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56369. /**
  56370. * Reset ALL associated observables in this advanced timer
  56371. */
  56372. clearObservables(): void;
  56373. /**
  56374. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56375. *
  56376. * @param timeToEnd how much time to measure until timer ended
  56377. */
  56378. start(timeToEnd?: number): void;
  56379. /**
  56380. * Will force a stop on the next tick.
  56381. */
  56382. stop(): void;
  56383. /**
  56384. * Dispose this timer, clearing all resources
  56385. */
  56386. dispose(): void;
  56387. private _setState;
  56388. private _tick;
  56389. private _stop;
  56390. }
  56391. }
  56392. declare module BABYLON {
  56393. /**
  56394. * The options container for the teleportation module
  56395. */
  56396. export interface IWebXRTeleportationOptions {
  56397. /**
  56398. * if provided, this scene will be used to render meshes.
  56399. */
  56400. customUtilityLayerScene?: Scene;
  56401. /**
  56402. * Values to configure the default target mesh
  56403. */
  56404. defaultTargetMeshOptions?: {
  56405. /**
  56406. * Fill color of the teleportation area
  56407. */
  56408. teleportationFillColor?: string;
  56409. /**
  56410. * Border color for the teleportation area
  56411. */
  56412. teleportationBorderColor?: string;
  56413. /**
  56414. * Disable the mesh's animation sequence
  56415. */
  56416. disableAnimation?: boolean;
  56417. /**
  56418. * Disable lighting on the material or the ring and arrow
  56419. */
  56420. disableLighting?: boolean;
  56421. /**
  56422. * Override the default material of the torus and arrow
  56423. */
  56424. torusArrowMaterial?: Material;
  56425. };
  56426. /**
  56427. * A list of meshes to use as floor meshes.
  56428. * Meshes can be added and removed after initializing the feature using the
  56429. * addFloorMesh and removeFloorMesh functions
  56430. * If empty, rotation will still work
  56431. */
  56432. floorMeshes?: AbstractMesh[];
  56433. /**
  56434. * use this rendering group id for the meshes (optional)
  56435. */
  56436. renderingGroupId?: number;
  56437. /**
  56438. * Should teleportation move only to snap points
  56439. */
  56440. snapPointsOnly?: boolean;
  56441. /**
  56442. * An array of points to which the teleportation will snap to.
  56443. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56444. */
  56445. snapPositions?: Vector3[];
  56446. /**
  56447. * How close should the teleportation ray be in order to snap to position.
  56448. * Default to 0.8 units (meters)
  56449. */
  56450. snapToPositionRadius?: number;
  56451. /**
  56452. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56453. * If you want to support rotation, make sure your mesh has a direction indicator.
  56454. *
  56455. * When left untouched, the default mesh will be initialized.
  56456. */
  56457. teleportationTargetMesh?: AbstractMesh;
  56458. /**
  56459. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56460. */
  56461. timeToTeleport?: number;
  56462. /**
  56463. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56464. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56465. */
  56466. useMainComponentOnly?: boolean;
  56467. /**
  56468. * Should meshes created here be added to a utility layer or the main scene
  56469. */
  56470. useUtilityLayer?: boolean;
  56471. /**
  56472. * Babylon XR Input class for controller
  56473. */
  56474. xrInput: WebXRInput;
  56475. /**
  56476. * Meshes that the teleportation ray cannot go through
  56477. */
  56478. pickBlockerMeshes?: AbstractMesh[];
  56479. /**
  56480. * Should teleport work only on a specific hand?
  56481. */
  56482. forceHandedness?: XRHandedness;
  56483. /**
  56484. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56485. */
  56486. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56487. }
  56488. /**
  56489. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56490. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56491. * the input of the attached controllers.
  56492. */
  56493. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56494. private _options;
  56495. private _controllers;
  56496. private _currentTeleportationControllerId;
  56497. private _floorMeshes;
  56498. private _quadraticBezierCurve;
  56499. private _selectionFeature;
  56500. private _snapToPositions;
  56501. private _snappedToPoint;
  56502. private _teleportationRingMaterial?;
  56503. private _tmpRay;
  56504. private _tmpVector;
  56505. private _tmpQuaternion;
  56506. /**
  56507. * The module's name
  56508. */
  56509. static readonly Name: string;
  56510. /**
  56511. * The (Babylon) version of this module.
  56512. * This is an integer representing the implementation version.
  56513. * This number does not correspond to the webxr specs version
  56514. */
  56515. static readonly Version: number;
  56516. /**
  56517. * Is movement backwards enabled
  56518. */
  56519. backwardsMovementEnabled: boolean;
  56520. /**
  56521. * Distance to travel when moving backwards
  56522. */
  56523. backwardsTeleportationDistance: number;
  56524. /**
  56525. * The distance from the user to the inspection point in the direction of the controller
  56526. * A higher number will allow the user to move further
  56527. * defaults to 5 (meters, in xr units)
  56528. */
  56529. parabolicCheckRadius: number;
  56530. /**
  56531. * Should the module support parabolic ray on top of direct ray
  56532. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56533. * Very helpful when moving between floors / different heights
  56534. */
  56535. parabolicRayEnabled: boolean;
  56536. /**
  56537. * The second type of ray - straight line.
  56538. * Should it be enabled or should the parabolic line be the only one.
  56539. */
  56540. straightRayEnabled: boolean;
  56541. /**
  56542. * How much rotation should be applied when rotating right and left
  56543. */
  56544. rotationAngle: number;
  56545. private _rotationEnabled;
  56546. /**
  56547. * Is rotation enabled when moving forward?
  56548. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56549. */
  56550. get rotationEnabled(): boolean;
  56551. /**
  56552. * Sets whether rotation is enabled or not
  56553. * @param enabled is rotation enabled when teleportation is shown
  56554. */
  56555. set rotationEnabled(enabled: boolean);
  56556. /**
  56557. * Exposes the currently set teleportation target mesh.
  56558. */
  56559. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56560. /**
  56561. * constructs a new anchor system
  56562. * @param _xrSessionManager an instance of WebXRSessionManager
  56563. * @param _options configuration object for this feature
  56564. */
  56565. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56566. /**
  56567. * Get the snapPointsOnly flag
  56568. */
  56569. get snapPointsOnly(): boolean;
  56570. /**
  56571. * Sets the snapPointsOnly flag
  56572. * @param snapToPoints should teleportation be exclusively to snap points
  56573. */
  56574. set snapPointsOnly(snapToPoints: boolean);
  56575. /**
  56576. * Add a new mesh to the floor meshes array
  56577. * @param mesh the mesh to use as floor mesh
  56578. */
  56579. addFloorMesh(mesh: AbstractMesh): void;
  56580. /**
  56581. * Add a new snap-to point to fix teleportation to this position
  56582. * @param newSnapPoint The new Snap-To point
  56583. */
  56584. addSnapPoint(newSnapPoint: Vector3): void;
  56585. attach(): boolean;
  56586. detach(): boolean;
  56587. dispose(): void;
  56588. /**
  56589. * Remove a mesh from the floor meshes array
  56590. * @param mesh the mesh to remove
  56591. */
  56592. removeFloorMesh(mesh: AbstractMesh): void;
  56593. /**
  56594. * Remove a mesh from the floor meshes array using its name
  56595. * @param name the mesh name to remove
  56596. */
  56597. removeFloorMeshByName(name: string): void;
  56598. /**
  56599. * 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
  56600. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56601. * @returns was the point found and removed or not
  56602. */
  56603. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56604. /**
  56605. * This function sets a selection feature that will be disabled when
  56606. * the forward ray is shown and will be reattached when hidden.
  56607. * This is used to remove the selection rays when moving.
  56608. * @param selectionFeature the feature to disable when forward movement is enabled
  56609. */
  56610. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56611. protected _onXRFrame(_xrFrame: XRFrame): void;
  56612. private _attachController;
  56613. private _createDefaultTargetMesh;
  56614. private _detachController;
  56615. private _findClosestSnapPointWithRadius;
  56616. private _setTargetMeshPosition;
  56617. private _setTargetMeshVisibility;
  56618. private _showParabolicPath;
  56619. private _teleportForward;
  56620. }
  56621. }
  56622. declare module BABYLON {
  56623. /**
  56624. * Options for the default xr helper
  56625. */
  56626. export class WebXRDefaultExperienceOptions {
  56627. /**
  56628. * Enable or disable default UI to enter XR
  56629. */
  56630. disableDefaultUI?: boolean;
  56631. /**
  56632. * Should teleportation not initialize. defaults to false.
  56633. */
  56634. disableTeleportation?: boolean;
  56635. /**
  56636. * Floor meshes that will be used for teleport
  56637. */
  56638. floorMeshes?: Array<AbstractMesh>;
  56639. /**
  56640. * If set to true, the first frame will not be used to reset position
  56641. * The first frame is mainly used when copying transformation from the old camera
  56642. * Mainly used in AR
  56643. */
  56644. ignoreNativeCameraTransformation?: boolean;
  56645. /**
  56646. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56647. */
  56648. inputOptions?: IWebXRInputOptions;
  56649. /**
  56650. * optional configuration for the output canvas
  56651. */
  56652. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56653. /**
  56654. * optional UI options. This can be used among other to change session mode and reference space type
  56655. */
  56656. uiOptions?: WebXREnterExitUIOptions;
  56657. /**
  56658. * When loading teleportation and pointer select, use stable versions instead of latest.
  56659. */
  56660. useStablePlugins?: boolean;
  56661. /**
  56662. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56663. */
  56664. renderingGroupId?: number;
  56665. /**
  56666. * A list of optional features to init the session with
  56667. * If set to true, all features we support will be added
  56668. */
  56669. optionalFeatures?: boolean | string[];
  56670. }
  56671. /**
  56672. * Default experience which provides a similar setup to the previous webVRExperience
  56673. */
  56674. export class WebXRDefaultExperience {
  56675. /**
  56676. * Base experience
  56677. */
  56678. baseExperience: WebXRExperienceHelper;
  56679. /**
  56680. * Enables ui for entering/exiting xr
  56681. */
  56682. enterExitUI: WebXREnterExitUI;
  56683. /**
  56684. * Input experience extension
  56685. */
  56686. input: WebXRInput;
  56687. /**
  56688. * Enables laser pointer and selection
  56689. */
  56690. pointerSelection: WebXRControllerPointerSelection;
  56691. /**
  56692. * Default target xr should render to
  56693. */
  56694. renderTarget: WebXRRenderTarget;
  56695. /**
  56696. * Enables teleportation
  56697. */
  56698. teleportation: WebXRMotionControllerTeleportation;
  56699. private constructor();
  56700. /**
  56701. * Creates the default xr experience
  56702. * @param scene scene
  56703. * @param options options for basic configuration
  56704. * @returns resulting WebXRDefaultExperience
  56705. */
  56706. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56707. /**
  56708. * Disposes of the experience helper
  56709. */
  56710. dispose(): void;
  56711. }
  56712. }
  56713. declare module BABYLON {
  56714. /**
  56715. * Options to modify the vr teleportation behavior.
  56716. */
  56717. export interface VRTeleportationOptions {
  56718. /**
  56719. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56720. */
  56721. floorMeshName?: string;
  56722. /**
  56723. * A list of meshes to be used as the teleportation floor. (default: empty)
  56724. */
  56725. floorMeshes?: Mesh[];
  56726. /**
  56727. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56728. */
  56729. teleportationMode?: number;
  56730. /**
  56731. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56732. */
  56733. teleportationTime?: number;
  56734. /**
  56735. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56736. */
  56737. teleportationSpeed?: number;
  56738. /**
  56739. * The easing function used in the animation or null for Linear. (default CircleEase)
  56740. */
  56741. easingFunction?: EasingFunction;
  56742. }
  56743. /**
  56744. * Options to modify the vr experience helper's behavior.
  56745. */
  56746. export interface VRExperienceHelperOptions extends WebVROptions {
  56747. /**
  56748. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56749. */
  56750. createDeviceOrientationCamera?: boolean;
  56751. /**
  56752. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56753. */
  56754. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56755. /**
  56756. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56757. */
  56758. laserToggle?: boolean;
  56759. /**
  56760. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56761. */
  56762. floorMeshes?: Mesh[];
  56763. /**
  56764. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56765. */
  56766. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56767. /**
  56768. * Defines if WebXR should be used instead of WebVR (if available)
  56769. */
  56770. useXR?: boolean;
  56771. }
  56772. /**
  56773. * Event containing information after VR has been entered
  56774. */
  56775. export class OnAfterEnteringVRObservableEvent {
  56776. /**
  56777. * If entering vr was successful
  56778. */
  56779. success: boolean;
  56780. }
  56781. /**
  56782. * Helps to quickly add VR support to an existing scene.
  56783. * See https://doc.babylonjs.com/how_to/webvr_helper
  56784. */
  56785. export class VRExperienceHelper {
  56786. /** Options to modify the vr experience helper's behavior. */
  56787. webVROptions: VRExperienceHelperOptions;
  56788. private _scene;
  56789. private _position;
  56790. private _btnVR;
  56791. private _btnVRDisplayed;
  56792. private _webVRsupported;
  56793. private _webVRready;
  56794. private _webVRrequesting;
  56795. private _webVRpresenting;
  56796. private _hasEnteredVR;
  56797. private _fullscreenVRpresenting;
  56798. private _inputElement;
  56799. private _webVRCamera;
  56800. private _vrDeviceOrientationCamera;
  56801. private _deviceOrientationCamera;
  56802. private _existingCamera;
  56803. private _onKeyDown;
  56804. private _onVrDisplayPresentChange;
  56805. private _onVRDisplayChanged;
  56806. private _onVRRequestPresentStart;
  56807. private _onVRRequestPresentComplete;
  56808. /**
  56809. * 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)
  56810. */
  56811. enableGazeEvenWhenNoPointerLock: boolean;
  56812. /**
  56813. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56814. */
  56815. exitVROnDoubleTap: boolean;
  56816. /**
  56817. * Observable raised right before entering VR.
  56818. */
  56819. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56820. /**
  56821. * Observable raised when entering VR has completed.
  56822. */
  56823. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56824. /**
  56825. * Observable raised when exiting VR.
  56826. */
  56827. onExitingVRObservable: Observable<VRExperienceHelper>;
  56828. /**
  56829. * Observable raised when controller mesh is loaded.
  56830. */
  56831. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56832. /** Return this.onEnteringVRObservable
  56833. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56834. */
  56835. get onEnteringVR(): Observable<VRExperienceHelper>;
  56836. /** Return this.onExitingVRObservable
  56837. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56838. */
  56839. get onExitingVR(): Observable<VRExperienceHelper>;
  56840. /** Return this.onControllerMeshLoadedObservable
  56841. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56842. */
  56843. get onControllerMeshLoaded(): Observable<WebVRController>;
  56844. private _rayLength;
  56845. private _useCustomVRButton;
  56846. private _teleportationRequested;
  56847. private _teleportActive;
  56848. private _floorMeshName;
  56849. private _floorMeshesCollection;
  56850. private _teleportationMode;
  56851. private _teleportationTime;
  56852. private _teleportationSpeed;
  56853. private _teleportationEasing;
  56854. private _rotationAllowed;
  56855. private _teleportBackwardsVector;
  56856. private _teleportationTarget;
  56857. private _isDefaultTeleportationTarget;
  56858. private _postProcessMove;
  56859. private _teleportationFillColor;
  56860. private _teleportationBorderColor;
  56861. private _rotationAngle;
  56862. private _haloCenter;
  56863. private _cameraGazer;
  56864. private _padSensibilityUp;
  56865. private _padSensibilityDown;
  56866. private _leftController;
  56867. private _rightController;
  56868. private _gazeColor;
  56869. private _laserColor;
  56870. private _pickedLaserColor;
  56871. private _pickedGazeColor;
  56872. /**
  56873. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56874. */
  56875. onNewMeshSelected: Observable<AbstractMesh>;
  56876. /**
  56877. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56878. * This observable will provide the mesh and the controller used to select the mesh
  56879. */
  56880. onMeshSelectedWithController: Observable<{
  56881. mesh: AbstractMesh;
  56882. controller: WebVRController;
  56883. }>;
  56884. /**
  56885. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56886. */
  56887. onNewMeshPicked: Observable<PickingInfo>;
  56888. private _circleEase;
  56889. /**
  56890. * Observable raised before camera teleportation
  56891. */
  56892. onBeforeCameraTeleport: Observable<Vector3>;
  56893. /**
  56894. * Observable raised after camera teleportation
  56895. */
  56896. onAfterCameraTeleport: Observable<Vector3>;
  56897. /**
  56898. * Observable raised when current selected mesh gets unselected
  56899. */
  56900. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56901. private _raySelectionPredicate;
  56902. /**
  56903. * To be optionally changed by user to define custom ray selection
  56904. */
  56905. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56906. /**
  56907. * To be optionally changed by user to define custom selection logic (after ray selection)
  56908. */
  56909. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56910. /**
  56911. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56912. */
  56913. teleportationEnabled: boolean;
  56914. private _defaultHeight;
  56915. private _teleportationInitialized;
  56916. private _interactionsEnabled;
  56917. private _interactionsRequested;
  56918. private _displayGaze;
  56919. private _displayLaserPointer;
  56920. /**
  56921. * The mesh used to display where the user is going to teleport.
  56922. */
  56923. get teleportationTarget(): Mesh;
  56924. /**
  56925. * Sets the mesh to be used to display where the user is going to teleport.
  56926. */
  56927. set teleportationTarget(value: Mesh);
  56928. /**
  56929. * 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
  56930. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56931. * See https://doc.babylonjs.com/resources/baking_transformations
  56932. */
  56933. get gazeTrackerMesh(): Mesh;
  56934. set gazeTrackerMesh(value: Mesh);
  56935. /**
  56936. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56937. */
  56938. updateGazeTrackerScale: boolean;
  56939. /**
  56940. * If the gaze trackers color should be updated when selecting meshes
  56941. */
  56942. updateGazeTrackerColor: boolean;
  56943. /**
  56944. * If the controller laser color should be updated when selecting meshes
  56945. */
  56946. updateControllerLaserColor: boolean;
  56947. /**
  56948. * The gaze tracking mesh corresponding to the left controller
  56949. */
  56950. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56951. /**
  56952. * The gaze tracking mesh corresponding to the right controller
  56953. */
  56954. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56955. /**
  56956. * If the ray of the gaze should be displayed.
  56957. */
  56958. get displayGaze(): boolean;
  56959. /**
  56960. * Sets if the ray of the gaze should be displayed.
  56961. */
  56962. set displayGaze(value: boolean);
  56963. /**
  56964. * If the ray of the LaserPointer should be displayed.
  56965. */
  56966. get displayLaserPointer(): boolean;
  56967. /**
  56968. * Sets if the ray of the LaserPointer should be displayed.
  56969. */
  56970. set displayLaserPointer(value: boolean);
  56971. /**
  56972. * The deviceOrientationCamera used as the camera when not in VR.
  56973. */
  56974. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56975. /**
  56976. * Based on the current WebVR support, returns the current VR camera used.
  56977. */
  56978. get currentVRCamera(): Nullable<Camera>;
  56979. /**
  56980. * The webVRCamera which is used when in VR.
  56981. */
  56982. get webVRCamera(): WebVRFreeCamera;
  56983. /**
  56984. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56985. */
  56986. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56987. /**
  56988. * The html button that is used to trigger entering into VR.
  56989. */
  56990. get vrButton(): Nullable<HTMLButtonElement>;
  56991. private get _teleportationRequestInitiated();
  56992. /**
  56993. * Defines whether or not Pointer lock should be requested when switching to
  56994. * full screen.
  56995. */
  56996. requestPointerLockOnFullScreen: boolean;
  56997. /**
  56998. * If asking to force XR, this will be populated with the default xr experience
  56999. */
  57000. xr: WebXRDefaultExperience;
  57001. /**
  57002. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57003. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57004. */
  57005. xrTestDone: boolean;
  57006. /**
  57007. * Instantiates a VRExperienceHelper.
  57008. * Helps to quickly add VR support to an existing scene.
  57009. * @param scene The scene the VRExperienceHelper belongs to.
  57010. * @param webVROptions Options to modify the vr experience helper's behavior.
  57011. */
  57012. constructor(scene: Scene,
  57013. /** Options to modify the vr experience helper's behavior. */
  57014. webVROptions?: VRExperienceHelperOptions);
  57015. private completeVRInit;
  57016. private _onDefaultMeshLoaded;
  57017. private _onResize;
  57018. private _onFullscreenChange;
  57019. /**
  57020. * Gets a value indicating if we are currently in VR mode.
  57021. */
  57022. get isInVRMode(): boolean;
  57023. private onVrDisplayPresentChange;
  57024. private onVRDisplayChanged;
  57025. private moveButtonToBottomRight;
  57026. private displayVRButton;
  57027. private updateButtonVisibility;
  57028. private _cachedAngularSensibility;
  57029. /**
  57030. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57031. * Otherwise, will use the fullscreen API.
  57032. */
  57033. enterVR(): void;
  57034. /**
  57035. * Attempt to exit VR, or fullscreen.
  57036. */
  57037. exitVR(): void;
  57038. /**
  57039. * The position of the vr experience helper.
  57040. */
  57041. get position(): Vector3;
  57042. /**
  57043. * Sets the position of the vr experience helper.
  57044. */
  57045. set position(value: Vector3);
  57046. /**
  57047. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57048. */
  57049. enableInteractions(): void;
  57050. private get _noControllerIsActive();
  57051. private beforeRender;
  57052. private _isTeleportationFloor;
  57053. /**
  57054. * Adds a floor mesh to be used for teleportation.
  57055. * @param floorMesh the mesh to be used for teleportation.
  57056. */
  57057. addFloorMesh(floorMesh: Mesh): void;
  57058. /**
  57059. * Removes a floor mesh from being used for teleportation.
  57060. * @param floorMesh the mesh to be removed.
  57061. */
  57062. removeFloorMesh(floorMesh: Mesh): void;
  57063. /**
  57064. * Enables interactions and teleportation using the VR controllers and gaze.
  57065. * @param vrTeleportationOptions options to modify teleportation behavior.
  57066. */
  57067. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57068. private _onNewGamepadConnected;
  57069. private _tryEnableInteractionOnController;
  57070. private _onNewGamepadDisconnected;
  57071. private _enableInteractionOnController;
  57072. private _checkTeleportWithRay;
  57073. private _checkRotate;
  57074. private _checkTeleportBackwards;
  57075. private _enableTeleportationOnController;
  57076. private _createTeleportationCircles;
  57077. private _displayTeleportationTarget;
  57078. private _hideTeleportationTarget;
  57079. private _rotateCamera;
  57080. private _moveTeleportationSelectorTo;
  57081. private _workingVector;
  57082. private _workingQuaternion;
  57083. private _workingMatrix;
  57084. /**
  57085. * Time Constant Teleportation Mode
  57086. */
  57087. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57088. /**
  57089. * Speed Constant Teleportation Mode
  57090. */
  57091. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57092. /**
  57093. * Teleports the users feet to the desired location
  57094. * @param location The location where the user's feet should be placed
  57095. */
  57096. teleportCamera(location: Vector3): void;
  57097. private _convertNormalToDirectionOfRay;
  57098. private _castRayAndSelectObject;
  57099. private _notifySelectedMeshUnselected;
  57100. /**
  57101. * Permanently set new colors for the laser pointer
  57102. * @param color the new laser color
  57103. * @param pickedColor the new laser color when picked mesh detected
  57104. */
  57105. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57106. /**
  57107. * Set lighting enabled / disabled on the laser pointer of both controllers
  57108. * @param enabled should the lighting be enabled on the laser pointer
  57109. */
  57110. setLaserLightingState(enabled?: boolean): void;
  57111. /**
  57112. * Permanently set new colors for the gaze pointer
  57113. * @param color the new gaze color
  57114. * @param pickedColor the new gaze color when picked mesh detected
  57115. */
  57116. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57117. /**
  57118. * Sets the color of the laser ray from the vr controllers.
  57119. * @param color new color for the ray.
  57120. */
  57121. changeLaserColor(color: Color3): void;
  57122. /**
  57123. * Sets the color of the ray from the vr headsets gaze.
  57124. * @param color new color for the ray.
  57125. */
  57126. changeGazeColor(color: Color3): void;
  57127. /**
  57128. * Exits VR and disposes of the vr experience helper
  57129. */
  57130. dispose(): void;
  57131. /**
  57132. * Gets the name of the VRExperienceHelper class
  57133. * @returns "VRExperienceHelper"
  57134. */
  57135. getClassName(): string;
  57136. }
  57137. }
  57138. declare module BABYLON {
  57139. /**
  57140. * Contains an array of blocks representing the octree
  57141. */
  57142. export interface IOctreeContainer<T> {
  57143. /**
  57144. * Blocks within the octree
  57145. */
  57146. blocks: Array<OctreeBlock<T>>;
  57147. }
  57148. /**
  57149. * Class used to store a cell in an octree
  57150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57151. */
  57152. export class OctreeBlock<T> {
  57153. /**
  57154. * Gets the content of the current block
  57155. */
  57156. entries: T[];
  57157. /**
  57158. * Gets the list of block children
  57159. */
  57160. blocks: Array<OctreeBlock<T>>;
  57161. private _depth;
  57162. private _maxDepth;
  57163. private _capacity;
  57164. private _minPoint;
  57165. private _maxPoint;
  57166. private _boundingVectors;
  57167. private _creationFunc;
  57168. /**
  57169. * Creates a new block
  57170. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57171. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57172. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57173. * @param depth defines the current depth of this block in the octree
  57174. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57175. * @param creationFunc defines a callback to call when an element is added to the block
  57176. */
  57177. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57178. /**
  57179. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57180. */
  57181. get capacity(): number;
  57182. /**
  57183. * Gets the minimum vector (in world space) of the block's bounding box
  57184. */
  57185. get minPoint(): Vector3;
  57186. /**
  57187. * Gets the maximum vector (in world space) of the block's bounding box
  57188. */
  57189. get maxPoint(): Vector3;
  57190. /**
  57191. * Add a new element to this block
  57192. * @param entry defines the element to add
  57193. */
  57194. addEntry(entry: T): void;
  57195. /**
  57196. * Remove an element from this block
  57197. * @param entry defines the element to remove
  57198. */
  57199. removeEntry(entry: T): void;
  57200. /**
  57201. * Add an array of elements to this block
  57202. * @param entries defines the array of elements to add
  57203. */
  57204. addEntries(entries: T[]): void;
  57205. /**
  57206. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57207. * @param frustumPlanes defines the frustum planes to test
  57208. * @param selection defines the array to store current content if selection is positive
  57209. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57210. */
  57211. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57212. /**
  57213. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57214. * @param sphereCenter defines the bounding sphere center
  57215. * @param sphereRadius defines the bounding sphere radius
  57216. * @param selection defines the array to store current content if selection is positive
  57217. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57218. */
  57219. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57220. /**
  57221. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57222. * @param ray defines the ray to test with
  57223. * @param selection defines the array to store current content if selection is positive
  57224. */
  57225. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57226. /**
  57227. * Subdivide the content into child blocks (this block will then be empty)
  57228. */
  57229. createInnerBlocks(): void;
  57230. /**
  57231. * @hidden
  57232. */
  57233. 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;
  57234. }
  57235. }
  57236. declare module BABYLON {
  57237. /**
  57238. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57240. */
  57241. export class Octree<T> {
  57242. /** 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.) */
  57243. maxDepth: number;
  57244. /**
  57245. * Blocks within the octree containing objects
  57246. */
  57247. blocks: Array<OctreeBlock<T>>;
  57248. /**
  57249. * Content stored in the octree
  57250. */
  57251. dynamicContent: T[];
  57252. private _maxBlockCapacity;
  57253. private _selectionContent;
  57254. private _creationFunc;
  57255. /**
  57256. * Creates a octree
  57257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57258. * @param creationFunc function to be used to instantiate the octree
  57259. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57260. * @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.)
  57261. */
  57262. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57263. /** 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.) */
  57264. maxDepth?: number);
  57265. /**
  57266. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57267. * @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);
  57268. * @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);
  57269. * @param entries meshes to be added to the octree blocks
  57270. */
  57271. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57272. /**
  57273. * Adds a mesh to the octree
  57274. * @param entry Mesh to add to the octree
  57275. */
  57276. addMesh(entry: T): void;
  57277. /**
  57278. * Remove an element from the octree
  57279. * @param entry defines the element to remove
  57280. */
  57281. removeMesh(entry: T): void;
  57282. /**
  57283. * Selects an array of meshes within the frustum
  57284. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57285. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57286. * @returns array of meshes within the frustum
  57287. */
  57288. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57289. /**
  57290. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57291. * @param sphereCenter defines the bounding sphere center
  57292. * @param sphereRadius defines the bounding sphere radius
  57293. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57294. * @returns an array of objects that intersect the sphere
  57295. */
  57296. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57297. /**
  57298. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57299. * @param ray defines the ray to test with
  57300. * @returns array of intersected objects
  57301. */
  57302. intersectsRay(ray: Ray): SmartArray<T>;
  57303. /**
  57304. * Adds a mesh into the octree block if it intersects the block
  57305. */
  57306. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57307. /**
  57308. * Adds a submesh into the octree block if it intersects the block
  57309. */
  57310. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57311. }
  57312. }
  57313. declare module BABYLON {
  57314. interface Scene {
  57315. /**
  57316. * @hidden
  57317. * Backing Filed
  57318. */
  57319. _selectionOctree: Octree<AbstractMesh>;
  57320. /**
  57321. * Gets the octree used to boost mesh selection (picking)
  57322. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57323. */
  57324. selectionOctree: Octree<AbstractMesh>;
  57325. /**
  57326. * Creates or updates the octree used to boost selection (picking)
  57327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57328. * @param maxCapacity defines the maximum capacity per leaf
  57329. * @param maxDepth defines the maximum depth of the octree
  57330. * @returns an octree of AbstractMesh
  57331. */
  57332. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57333. }
  57334. interface AbstractMesh {
  57335. /**
  57336. * @hidden
  57337. * Backing Field
  57338. */
  57339. _submeshesOctree: Octree<SubMesh>;
  57340. /**
  57341. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57342. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57343. * @param maxCapacity defines the maximum size of each block (64 by default)
  57344. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57345. * @returns the new octree
  57346. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57348. */
  57349. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57350. }
  57351. /**
  57352. * Defines the octree scene component responsible to manage any octrees
  57353. * in a given scene.
  57354. */
  57355. export class OctreeSceneComponent {
  57356. /**
  57357. * The component name help to identify the component in the list of scene components.
  57358. */
  57359. readonly name: string;
  57360. /**
  57361. * The scene the component belongs to.
  57362. */
  57363. scene: Scene;
  57364. /**
  57365. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57366. */
  57367. readonly checksIsEnabled: boolean;
  57368. /**
  57369. * Creates a new instance of the component for the given scene
  57370. * @param scene Defines the scene to register the component in
  57371. */
  57372. constructor(scene: Scene);
  57373. /**
  57374. * Registers the component in a given scene
  57375. */
  57376. register(): void;
  57377. /**
  57378. * Return the list of active meshes
  57379. * @returns the list of active meshes
  57380. */
  57381. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57382. /**
  57383. * Return the list of active sub meshes
  57384. * @param mesh The mesh to get the candidates sub meshes from
  57385. * @returns the list of active sub meshes
  57386. */
  57387. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57388. private _tempRay;
  57389. /**
  57390. * Return the list of sub meshes intersecting with a given local ray
  57391. * @param mesh defines the mesh to find the submesh for
  57392. * @param localRay defines the ray in local space
  57393. * @returns the list of intersecting sub meshes
  57394. */
  57395. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57396. /**
  57397. * Return the list of sub meshes colliding with a collider
  57398. * @param mesh defines the mesh to find the submesh for
  57399. * @param collider defines the collider to evaluate the collision against
  57400. * @returns the list of colliding sub meshes
  57401. */
  57402. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57403. /**
  57404. * Rebuilds the elements related to this component in case of
  57405. * context lost for instance.
  57406. */
  57407. rebuild(): void;
  57408. /**
  57409. * Disposes the component and the associated resources.
  57410. */
  57411. dispose(): void;
  57412. }
  57413. }
  57414. declare module BABYLON {
  57415. /**
  57416. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57417. */
  57418. export interface GizmoAxisCache {
  57419. /** Mesh used to render the Gizmo */
  57420. gizmoMeshes: Mesh[];
  57421. /** Mesh used to detect user interaction with Gizmo */
  57422. colliderMeshes: Mesh[];
  57423. /** Material used to indicate color of gizmo mesh */
  57424. material: StandardMaterial;
  57425. /** Material used to indicate hover state of the Gizmo */
  57426. hoverMaterial: StandardMaterial;
  57427. /** Material used to indicate disabled state of the Gizmo */
  57428. disableMaterial: StandardMaterial;
  57429. /** Used to indicate Active state of the Gizmo */
  57430. active: boolean;
  57431. }
  57432. /**
  57433. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57434. */
  57435. export class Gizmo implements IDisposable {
  57436. /** The utility layer the gizmo will be added to */
  57437. gizmoLayer: UtilityLayerRenderer;
  57438. /**
  57439. * The root mesh of the gizmo
  57440. */
  57441. _rootMesh: Mesh;
  57442. private _attachedMesh;
  57443. private _attachedNode;
  57444. /**
  57445. * Ratio for the scale of the gizmo (Default: 1)
  57446. */
  57447. protected _scaleRatio: number;
  57448. /**
  57449. * boolean updated by pointermove when a gizmo mesh is hovered
  57450. */
  57451. protected _isHovered: boolean;
  57452. /**
  57453. * Ratio for the scale of the gizmo (Default: 1)
  57454. */
  57455. set scaleRatio(value: number);
  57456. get scaleRatio(): number;
  57457. /**
  57458. * True when the mouse pointer is hovered a gizmo mesh
  57459. */
  57460. get isHovered(): boolean;
  57461. /**
  57462. * If a custom mesh has been set (Default: false)
  57463. */
  57464. protected _customMeshSet: boolean;
  57465. /**
  57466. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57467. * * When set, interactions will be enabled
  57468. */
  57469. get attachedMesh(): Nullable<AbstractMesh>;
  57470. set attachedMesh(value: Nullable<AbstractMesh>);
  57471. /**
  57472. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57473. * * When set, interactions will be enabled
  57474. */
  57475. get attachedNode(): Nullable<Node>;
  57476. set attachedNode(value: Nullable<Node>);
  57477. /**
  57478. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57479. * @param mesh The mesh to replace the default mesh of the gizmo
  57480. */
  57481. setCustomMesh(mesh: Mesh): void;
  57482. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57483. /**
  57484. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57485. */
  57486. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57487. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57488. /**
  57489. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57490. */
  57491. updateGizmoPositionToMatchAttachedMesh: boolean;
  57492. /**
  57493. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57494. */
  57495. updateScale: boolean;
  57496. protected _interactionsEnabled: boolean;
  57497. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57498. private _beforeRenderObserver;
  57499. private _tempQuaternion;
  57500. private _tempVector;
  57501. private _tempVector2;
  57502. private _tempMatrix1;
  57503. private _tempMatrix2;
  57504. private _rightHandtoLeftHandMatrix;
  57505. /**
  57506. * Creates a gizmo
  57507. * @param gizmoLayer The utility layer the gizmo will be added to
  57508. */
  57509. constructor(
  57510. /** The utility layer the gizmo will be added to */
  57511. gizmoLayer?: UtilityLayerRenderer);
  57512. /**
  57513. * Updates the gizmo to match the attached mesh's position/rotation
  57514. */
  57515. protected _update(): void;
  57516. /**
  57517. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57518. * @param value Node, TransformNode or mesh
  57519. */
  57520. protected _matrixChanged(): void;
  57521. /**
  57522. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57523. * @param gizmoLayer The utility layer the gizmo will be added to
  57524. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57525. * @returns {Observer<PointerInfo>} pointerObserver
  57526. */
  57527. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57528. /**
  57529. * Disposes of the gizmo
  57530. */
  57531. dispose(): void;
  57532. }
  57533. }
  57534. declare module BABYLON {
  57535. /**
  57536. * Single plane drag gizmo
  57537. */
  57538. export class PlaneDragGizmo extends Gizmo {
  57539. /**
  57540. * Drag behavior responsible for the gizmos dragging interactions
  57541. */
  57542. dragBehavior: PointerDragBehavior;
  57543. private _pointerObserver;
  57544. /**
  57545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57546. */
  57547. snapDistance: number;
  57548. /**
  57549. * Event that fires each time the gizmo snaps to a new location.
  57550. * * snapDistance is the the change in distance
  57551. */
  57552. onSnapObservable: Observable<{
  57553. snapDistance: number;
  57554. }>;
  57555. private _gizmoMesh;
  57556. private _coloredMaterial;
  57557. private _hoverMaterial;
  57558. private _disableMaterial;
  57559. private _isEnabled;
  57560. private _parent;
  57561. private _dragging;
  57562. /** @hidden */
  57563. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57564. /**
  57565. * Creates a PlaneDragGizmo
  57566. * @param gizmoLayer The utility layer the gizmo will be added to
  57567. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57568. * @param color The color of the gizmo
  57569. */
  57570. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57571. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57572. /**
  57573. * If the gizmo is enabled
  57574. */
  57575. set isEnabled(value: boolean);
  57576. get isEnabled(): boolean;
  57577. /**
  57578. * Disposes of the gizmo
  57579. */
  57580. dispose(): void;
  57581. }
  57582. }
  57583. declare module BABYLON {
  57584. /**
  57585. * Single plane rotation gizmo
  57586. */
  57587. export class PlaneRotationGizmo extends Gizmo {
  57588. /**
  57589. * Drag behavior responsible for the gizmos dragging interactions
  57590. */
  57591. dragBehavior: PointerDragBehavior;
  57592. private _pointerObserver;
  57593. /**
  57594. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57595. */
  57596. snapDistance: number;
  57597. /**
  57598. * Event that fires each time the gizmo snaps to a new location.
  57599. * * snapDistance is the the change in distance
  57600. */
  57601. onSnapObservable: Observable<{
  57602. snapDistance: number;
  57603. }>;
  57604. private _isEnabled;
  57605. private _parent;
  57606. private _coloredMaterial;
  57607. private _hoverMaterial;
  57608. private _disableMaterial;
  57609. private _gizmoMesh;
  57610. private _rotationCircle;
  57611. private _dragging;
  57612. private static _CircleConstants;
  57613. /**
  57614. * Creates a PlaneRotationGizmo
  57615. * @param gizmoLayer The utility layer the gizmo will be added to
  57616. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57617. * @param color The color of the gizmo
  57618. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57619. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57620. * @param thickness display gizmo axis thickness
  57621. */
  57622. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57623. /** Create Geometry for Gizmo */
  57624. private _createGizmoMesh;
  57625. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57626. private setupRotationCircle;
  57627. private updateRotationPath;
  57628. private updateRotationCircle;
  57629. /**
  57630. * If the gizmo is enabled
  57631. */
  57632. set isEnabled(value: boolean);
  57633. get isEnabled(): boolean;
  57634. /**
  57635. * Disposes of the gizmo
  57636. */
  57637. dispose(): void;
  57638. }
  57639. }
  57640. declare module BABYLON {
  57641. /**
  57642. * Gizmo that enables rotating a mesh along 3 axis
  57643. */
  57644. export class RotationGizmo extends Gizmo {
  57645. /**
  57646. * Internal gizmo used for interactions on the x axis
  57647. */
  57648. xGizmo: PlaneRotationGizmo;
  57649. /**
  57650. * Internal gizmo used for interactions on the y axis
  57651. */
  57652. yGizmo: PlaneRotationGizmo;
  57653. /**
  57654. * Internal gizmo used for interactions on the z axis
  57655. */
  57656. zGizmo: PlaneRotationGizmo;
  57657. /** Fires an event when any of it's sub gizmos are dragged */
  57658. onDragStartObservable: Observable<unknown>;
  57659. /** Fires an event when any of it's sub gizmos are released from dragging */
  57660. onDragEndObservable: Observable<unknown>;
  57661. private _meshAttached;
  57662. private _nodeAttached;
  57663. private _observables;
  57664. /** Node Caching for quick lookup */
  57665. private _gizmoAxisCache;
  57666. get attachedMesh(): Nullable<AbstractMesh>;
  57667. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57668. get attachedNode(): Nullable<Node>;
  57669. set attachedNode(node: Nullable<Node>);
  57670. protected _checkBillboardTransform(): void;
  57671. /**
  57672. * True when the mouse pointer is hovering a gizmo mesh
  57673. */
  57674. get isHovered(): boolean;
  57675. /**
  57676. * Creates a RotationGizmo
  57677. * @param gizmoLayer The utility layer the gizmo will be added to
  57678. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57679. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57680. * @param thickness display gizmo axis thickness
  57681. */
  57682. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57683. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57684. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57685. /**
  57686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57687. */
  57688. set snapDistance(value: number);
  57689. get snapDistance(): number;
  57690. /**
  57691. * Ratio for the scale of the gizmo (Default: 1)
  57692. */
  57693. set scaleRatio(value: number);
  57694. get scaleRatio(): number;
  57695. /**
  57696. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57697. * @param mesh Axis gizmo mesh
  57698. * @param cache Gizmo axis definition used for reactive gizmo UI
  57699. */
  57700. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57701. /**
  57702. * Disposes of the gizmo
  57703. */
  57704. dispose(): void;
  57705. /**
  57706. * CustomMeshes are not supported by this gizmo
  57707. * @param mesh The mesh to replace the default mesh of the gizmo
  57708. */
  57709. setCustomMesh(mesh: Mesh): void;
  57710. }
  57711. }
  57712. declare module BABYLON {
  57713. /**
  57714. * Class containing static functions to help procedurally build meshes
  57715. */
  57716. export class PolyhedronBuilder {
  57717. /**
  57718. * Creates a polyhedron mesh
  57719. * * 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
  57720. * * The parameter `size` (positive float, default 1) sets the polygon size
  57721. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57722. * * 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`
  57723. * * 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
  57724. * * 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)`)
  57725. * * 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
  57726. * * 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
  57727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57728. * * 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
  57729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57730. * @param name defines the name of the mesh
  57731. * @param options defines the options used to create the mesh
  57732. * @param scene defines the hosting scene
  57733. * @returns the polyhedron mesh
  57734. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57735. */
  57736. static CreatePolyhedron(name: string, options: {
  57737. type?: number;
  57738. size?: number;
  57739. sizeX?: number;
  57740. sizeY?: number;
  57741. sizeZ?: number;
  57742. custom?: any;
  57743. faceUV?: Vector4[];
  57744. faceColors?: Color4[];
  57745. flat?: boolean;
  57746. updatable?: boolean;
  57747. sideOrientation?: number;
  57748. frontUVs?: Vector4;
  57749. backUVs?: Vector4;
  57750. }, scene?: Nullable<Scene>): Mesh;
  57751. }
  57752. }
  57753. declare module BABYLON {
  57754. /**
  57755. * Class containing static functions to help procedurally build meshes
  57756. */
  57757. export class BoxBuilder {
  57758. /**
  57759. * Creates a box mesh
  57760. * * The parameter `size` sets the size (float) of each box side (default 1)
  57761. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57762. * * 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)
  57763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57765. * * 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
  57766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57767. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57768. * @param name defines the name of the mesh
  57769. * @param options defines the options used to create the mesh
  57770. * @param scene defines the hosting scene
  57771. * @returns the box mesh
  57772. */
  57773. static CreateBox(name: string, options: {
  57774. size?: number;
  57775. width?: number;
  57776. height?: number;
  57777. depth?: number;
  57778. faceUV?: Vector4[];
  57779. faceColors?: Color4[];
  57780. sideOrientation?: number;
  57781. frontUVs?: Vector4;
  57782. backUVs?: Vector4;
  57783. wrap?: boolean;
  57784. topBaseAt?: number;
  57785. bottomBaseAt?: number;
  57786. updatable?: boolean;
  57787. }, scene?: Nullable<Scene>): Mesh;
  57788. }
  57789. }
  57790. declare module BABYLON {
  57791. /**
  57792. * Single axis scale gizmo
  57793. */
  57794. export class AxisScaleGizmo extends Gizmo {
  57795. /**
  57796. * Drag behavior responsible for the gizmos dragging interactions
  57797. */
  57798. dragBehavior: PointerDragBehavior;
  57799. private _pointerObserver;
  57800. /**
  57801. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57802. */
  57803. snapDistance: number;
  57804. /**
  57805. * Event that fires each time the gizmo snaps to a new location.
  57806. * * snapDistance is the the change in distance
  57807. */
  57808. onSnapObservable: Observable<{
  57809. snapDistance: number;
  57810. }>;
  57811. /**
  57812. * If the scaling operation should be done on all axis (default: false)
  57813. */
  57814. uniformScaling: boolean;
  57815. /**
  57816. * Custom sensitivity value for the drag strength
  57817. */
  57818. sensitivity: number;
  57819. private _isEnabled;
  57820. private _parent;
  57821. private _gizmoMesh;
  57822. private _coloredMaterial;
  57823. private _hoverMaterial;
  57824. private _disableMaterial;
  57825. private _dragging;
  57826. private _tmpVector;
  57827. private _tmpMatrix;
  57828. private _tmpMatrix2;
  57829. /**
  57830. * Creates an AxisScaleGizmo
  57831. * @param gizmoLayer The utility layer the gizmo will be added to
  57832. * @param dragAxis The axis which the gizmo will be able to scale on
  57833. * @param color The color of the gizmo
  57834. * @param thickness display gizmo axis thickness
  57835. */
  57836. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57837. /** Create Geometry for Gizmo */
  57838. private _createGizmoMesh;
  57839. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57840. /**
  57841. * If the gizmo is enabled
  57842. */
  57843. set isEnabled(value: boolean);
  57844. get isEnabled(): boolean;
  57845. /**
  57846. * Disposes of the gizmo
  57847. */
  57848. dispose(): void;
  57849. /**
  57850. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57851. * @param mesh The mesh to replace the default mesh of the gizmo
  57852. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57853. */
  57854. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57855. }
  57856. }
  57857. declare module BABYLON {
  57858. /**
  57859. * Gizmo that enables scaling a mesh along 3 axis
  57860. */
  57861. export class ScaleGizmo extends Gizmo {
  57862. /**
  57863. * Internal gizmo used for interactions on the x axis
  57864. */
  57865. xGizmo: AxisScaleGizmo;
  57866. /**
  57867. * Internal gizmo used for interactions on the y axis
  57868. */
  57869. yGizmo: AxisScaleGizmo;
  57870. /**
  57871. * Internal gizmo used for interactions on the z axis
  57872. */
  57873. zGizmo: AxisScaleGizmo;
  57874. /**
  57875. * Internal gizmo used to scale all axis equally
  57876. */
  57877. uniformScaleGizmo: AxisScaleGizmo;
  57878. private _meshAttached;
  57879. private _nodeAttached;
  57880. private _snapDistance;
  57881. private _uniformScalingMesh;
  57882. private _octahedron;
  57883. private _sensitivity;
  57884. private _coloredMaterial;
  57885. private _hoverMaterial;
  57886. private _disableMaterial;
  57887. private _observables;
  57888. /** Node Caching for quick lookup */
  57889. private _gizmoAxisCache;
  57890. /** Fires an event when any of it's sub gizmos are dragged */
  57891. onDragStartObservable: Observable<unknown>;
  57892. /** Fires an event when any of it's sub gizmos are released from dragging */
  57893. onDragEndObservable: Observable<unknown>;
  57894. get attachedMesh(): Nullable<AbstractMesh>;
  57895. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57896. get attachedNode(): Nullable<Node>;
  57897. set attachedNode(node: Nullable<Node>);
  57898. /**
  57899. * True when the mouse pointer is hovering a gizmo mesh
  57900. */
  57901. get isHovered(): boolean;
  57902. /**
  57903. * Creates a ScaleGizmo
  57904. * @param gizmoLayer The utility layer the gizmo will be added to
  57905. * @param thickness display gizmo axis thickness
  57906. */
  57907. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57908. /** Create Geometry for Gizmo */
  57909. private _createUniformScaleMesh;
  57910. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57911. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57912. /**
  57913. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57914. */
  57915. set snapDistance(value: number);
  57916. get snapDistance(): number;
  57917. /**
  57918. * Ratio for the scale of the gizmo (Default: 1)
  57919. */
  57920. set scaleRatio(value: number);
  57921. get scaleRatio(): number;
  57922. /**
  57923. * Sensitivity factor for dragging (Default: 1)
  57924. */
  57925. set sensitivity(value: number);
  57926. get sensitivity(): number;
  57927. /**
  57928. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57929. * @param mesh Axis gizmo mesh
  57930. * @param cache Gizmo axis definition used for reactive gizmo UI
  57931. */
  57932. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57933. /**
  57934. * Disposes of the gizmo
  57935. */
  57936. dispose(): void;
  57937. }
  57938. }
  57939. declare module BABYLON {
  57940. /**
  57941. * Bounding box gizmo
  57942. */
  57943. export class BoundingBoxGizmo extends Gizmo {
  57944. private _lineBoundingBox;
  57945. private _rotateSpheresParent;
  57946. private _scaleBoxesParent;
  57947. private _boundingDimensions;
  57948. private _renderObserver;
  57949. private _pointerObserver;
  57950. private _scaleDragSpeed;
  57951. private _tmpQuaternion;
  57952. private _tmpVector;
  57953. private _tmpRotationMatrix;
  57954. /**
  57955. * 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)
  57956. */
  57957. ignoreChildren: boolean;
  57958. /**
  57959. * 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)
  57960. */
  57961. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57962. /**
  57963. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57964. */
  57965. rotationSphereSize: number;
  57966. /**
  57967. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57968. */
  57969. scaleBoxSize: number;
  57970. /**
  57971. * 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)
  57972. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57973. */
  57974. fixedDragMeshScreenSize: boolean;
  57975. /**
  57976. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57977. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57978. */
  57979. fixedDragMeshBoundsSize: boolean;
  57980. /**
  57981. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57982. */
  57983. fixedDragMeshScreenSizeDistanceFactor: number;
  57984. /**
  57985. * Fired when a rotation sphere or scale box is dragged
  57986. */
  57987. onDragStartObservable: Observable<{}>;
  57988. /**
  57989. * Fired when a scale box is dragged
  57990. */
  57991. onScaleBoxDragObservable: Observable<{}>;
  57992. /**
  57993. * Fired when a scale box drag is ended
  57994. */
  57995. onScaleBoxDragEndObservable: Observable<{}>;
  57996. /**
  57997. * Fired when a rotation sphere is dragged
  57998. */
  57999. onRotationSphereDragObservable: Observable<{}>;
  58000. /**
  58001. * Fired when a rotation sphere drag is ended
  58002. */
  58003. onRotationSphereDragEndObservable: Observable<{}>;
  58004. /**
  58005. * 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)
  58006. */
  58007. scalePivot: Nullable<Vector3>;
  58008. /**
  58009. * Mesh used as a pivot to rotate the attached node
  58010. */
  58011. private _anchorMesh;
  58012. private _existingMeshScale;
  58013. private _dragMesh;
  58014. private pointerDragBehavior;
  58015. private coloredMaterial;
  58016. private hoverColoredMaterial;
  58017. /**
  58018. * Sets the color of the bounding box gizmo
  58019. * @param color the color to set
  58020. */
  58021. setColor(color: Color3): void;
  58022. /**
  58023. * Creates an BoundingBoxGizmo
  58024. * @param gizmoLayer The utility layer the gizmo will be added to
  58025. * @param color The color of the gizmo
  58026. */
  58027. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58028. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58029. private _selectNode;
  58030. /**
  58031. * Updates the bounding box information for the Gizmo
  58032. */
  58033. updateBoundingBox(): void;
  58034. private _updateRotationSpheres;
  58035. private _updateScaleBoxes;
  58036. /**
  58037. * Enables rotation on the specified axis and disables rotation on the others
  58038. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58039. */
  58040. setEnabledRotationAxis(axis: string): void;
  58041. /**
  58042. * Enables/disables scaling
  58043. * @param enable if scaling should be enabled
  58044. * @param homogeneousScaling defines if scaling should only be homogeneous
  58045. */
  58046. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58047. private _updateDummy;
  58048. /**
  58049. * Enables a pointer drag behavior on the bounding box of the gizmo
  58050. */
  58051. enableDragBehavior(): void;
  58052. /**
  58053. * Disposes of the gizmo
  58054. */
  58055. dispose(): void;
  58056. /**
  58057. * 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)
  58058. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58059. * @returns the bounding box mesh with the passed in mesh as a child
  58060. */
  58061. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58062. /**
  58063. * CustomMeshes are not supported by this gizmo
  58064. * @param mesh The mesh to replace the default mesh of the gizmo
  58065. */
  58066. setCustomMesh(mesh: Mesh): void;
  58067. }
  58068. }
  58069. declare module BABYLON {
  58070. /**
  58071. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58072. */
  58073. export class GizmoManager implements IDisposable {
  58074. private scene;
  58075. /**
  58076. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58077. */
  58078. gizmos: {
  58079. positionGizmo: Nullable<PositionGizmo>;
  58080. rotationGizmo: Nullable<RotationGizmo>;
  58081. scaleGizmo: Nullable<ScaleGizmo>;
  58082. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58083. };
  58084. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58085. clearGizmoOnEmptyPointerEvent: boolean;
  58086. /** Fires an event when the manager is attached to a mesh */
  58087. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58088. /** Fires an event when the manager is attached to a node */
  58089. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58090. private _gizmosEnabled;
  58091. private _pointerObservers;
  58092. private _attachedMesh;
  58093. private _attachedNode;
  58094. private _boundingBoxColor;
  58095. private _defaultUtilityLayer;
  58096. private _defaultKeepDepthUtilityLayer;
  58097. private _thickness;
  58098. /** Node Caching for quick lookup */
  58099. private _gizmoAxisCache;
  58100. /**
  58101. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58102. */
  58103. boundingBoxDragBehavior: SixDofDragBehavior;
  58104. /**
  58105. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58106. */
  58107. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58108. /**
  58109. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58110. */
  58111. attachableNodes: Nullable<Array<Node>>;
  58112. /**
  58113. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58114. */
  58115. usePointerToAttachGizmos: boolean;
  58116. /**
  58117. * Utility layer that the bounding box gizmo belongs to
  58118. */
  58119. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58120. /**
  58121. * Utility layer that all gizmos besides bounding box belong to
  58122. */
  58123. get utilityLayer(): UtilityLayerRenderer;
  58124. /**
  58125. * True when the mouse pointer is hovering a gizmo mesh
  58126. */
  58127. get isHovered(): boolean;
  58128. /**
  58129. * Instantiates a gizmo manager
  58130. * @param scene the scene to overlay the gizmos on top of
  58131. * @param thickness display gizmo axis thickness
  58132. * @param utilityLayer the layer where gizmos are rendered
  58133. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58134. */
  58135. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58136. /**
  58137. * Subscribes to pointer down events, for attaching and detaching mesh
  58138. * @param scene The scene layer the observer will be added to
  58139. */
  58140. private _attachToMeshPointerObserver;
  58141. /**
  58142. * Attaches a set of gizmos to the specified mesh
  58143. * @param mesh The mesh the gizmo's should be attached to
  58144. */
  58145. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58146. /**
  58147. * Attaches a set of gizmos to the specified node
  58148. * @param node The node the gizmo's should be attached to
  58149. */
  58150. attachToNode(node: Nullable<Node>): void;
  58151. /**
  58152. * If the position gizmo is enabled
  58153. */
  58154. set positionGizmoEnabled(value: boolean);
  58155. get positionGizmoEnabled(): boolean;
  58156. /**
  58157. * If the rotation gizmo is enabled
  58158. */
  58159. set rotationGizmoEnabled(value: boolean);
  58160. get rotationGizmoEnabled(): boolean;
  58161. /**
  58162. * If the scale gizmo is enabled
  58163. */
  58164. set scaleGizmoEnabled(value: boolean);
  58165. get scaleGizmoEnabled(): boolean;
  58166. /**
  58167. * If the boundingBox gizmo is enabled
  58168. */
  58169. set boundingBoxGizmoEnabled(value: boolean);
  58170. get boundingBoxGizmoEnabled(): boolean;
  58171. /**
  58172. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58173. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58174. */
  58175. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58176. /**
  58177. * Disposes of the gizmo manager
  58178. */
  58179. dispose(): void;
  58180. }
  58181. }
  58182. declare module BABYLON {
  58183. /**
  58184. * Gizmo that enables dragging a mesh along 3 axis
  58185. */
  58186. export class PositionGizmo extends Gizmo {
  58187. /**
  58188. * Internal gizmo used for interactions on the x axis
  58189. */
  58190. xGizmo: AxisDragGizmo;
  58191. /**
  58192. * Internal gizmo used for interactions on the y axis
  58193. */
  58194. yGizmo: AxisDragGizmo;
  58195. /**
  58196. * Internal gizmo used for interactions on the z axis
  58197. */
  58198. zGizmo: AxisDragGizmo;
  58199. /**
  58200. * Internal gizmo used for interactions on the yz plane
  58201. */
  58202. xPlaneGizmo: PlaneDragGizmo;
  58203. /**
  58204. * Internal gizmo used for interactions on the xz plane
  58205. */
  58206. yPlaneGizmo: PlaneDragGizmo;
  58207. /**
  58208. * Internal gizmo used for interactions on the xy plane
  58209. */
  58210. zPlaneGizmo: PlaneDragGizmo;
  58211. /**
  58212. * private variables
  58213. */
  58214. private _meshAttached;
  58215. private _nodeAttached;
  58216. private _snapDistance;
  58217. private _observables;
  58218. /** Node Caching for quick lookup */
  58219. private _gizmoAxisCache;
  58220. /** Fires an event when any of it's sub gizmos are dragged */
  58221. onDragStartObservable: Observable<unknown>;
  58222. /** Fires an event when any of it's sub gizmos are released from dragging */
  58223. onDragEndObservable: Observable<unknown>;
  58224. /**
  58225. * If set to true, planar drag is enabled
  58226. */
  58227. private _planarGizmoEnabled;
  58228. get attachedMesh(): Nullable<AbstractMesh>;
  58229. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58230. get attachedNode(): Nullable<Node>;
  58231. set attachedNode(node: Nullable<Node>);
  58232. /**
  58233. * True when the mouse pointer is hovering a gizmo mesh
  58234. */
  58235. get isHovered(): boolean;
  58236. /**
  58237. * Creates a PositionGizmo
  58238. * @param gizmoLayer The utility layer the gizmo will be added to
  58239. @param thickness display gizmo axis thickness
  58240. */
  58241. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58242. /**
  58243. * If the planar drag gizmo is enabled
  58244. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58245. */
  58246. set planarGizmoEnabled(value: boolean);
  58247. get planarGizmoEnabled(): boolean;
  58248. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58249. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58250. /**
  58251. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58252. */
  58253. set snapDistance(value: number);
  58254. get snapDistance(): number;
  58255. /**
  58256. * Ratio for the scale of the gizmo (Default: 1)
  58257. */
  58258. set scaleRatio(value: number);
  58259. get scaleRatio(): number;
  58260. /**
  58261. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58262. * @param mesh Axis gizmo mesh
  58263. * @param cache Gizmo axis definition used for reactive gizmo UI
  58264. */
  58265. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58266. /**
  58267. * Disposes of the gizmo
  58268. */
  58269. dispose(): void;
  58270. /**
  58271. * CustomMeshes are not supported by this gizmo
  58272. * @param mesh The mesh to replace the default mesh of the gizmo
  58273. */
  58274. setCustomMesh(mesh: Mesh): void;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * Single axis drag gizmo
  58280. */
  58281. export class AxisDragGizmo extends Gizmo {
  58282. /**
  58283. * Drag behavior responsible for the gizmos dragging interactions
  58284. */
  58285. dragBehavior: PointerDragBehavior;
  58286. private _pointerObserver;
  58287. /**
  58288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58289. */
  58290. snapDistance: number;
  58291. /**
  58292. * Event that fires each time the gizmo snaps to a new location.
  58293. * * snapDistance is the the change in distance
  58294. */
  58295. onSnapObservable: Observable<{
  58296. snapDistance: number;
  58297. }>;
  58298. private _isEnabled;
  58299. private _parent;
  58300. private _gizmoMesh;
  58301. private _coloredMaterial;
  58302. private _hoverMaterial;
  58303. private _disableMaterial;
  58304. private _dragging;
  58305. /** @hidden */
  58306. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58307. /** @hidden */
  58308. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58309. /**
  58310. * Creates an AxisDragGizmo
  58311. * @param gizmoLayer The utility layer the gizmo will be added to
  58312. * @param dragAxis The axis which the gizmo will be able to drag on
  58313. * @param color The color of the gizmo
  58314. * @param thickness display gizmo axis thickness
  58315. */
  58316. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58317. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58318. /**
  58319. * If the gizmo is enabled
  58320. */
  58321. set isEnabled(value: boolean);
  58322. get isEnabled(): boolean;
  58323. /**
  58324. * Disposes of the gizmo
  58325. */
  58326. dispose(): void;
  58327. }
  58328. }
  58329. declare module BABYLON.Debug {
  58330. /**
  58331. * The Axes viewer will show 3 axes in a specific point in space
  58332. */
  58333. export class AxesViewer {
  58334. private _xAxis;
  58335. private _yAxis;
  58336. private _zAxis;
  58337. private _scaleLinesFactor;
  58338. private _instanced;
  58339. /**
  58340. * Gets the hosting scene
  58341. */
  58342. scene: Nullable<Scene>;
  58343. /**
  58344. * Gets or sets a number used to scale line length
  58345. */
  58346. scaleLines: number;
  58347. /** Gets the node hierarchy used to render x-axis */
  58348. get xAxis(): TransformNode;
  58349. /** Gets the node hierarchy used to render y-axis */
  58350. get yAxis(): TransformNode;
  58351. /** Gets the node hierarchy used to render z-axis */
  58352. get zAxis(): TransformNode;
  58353. /**
  58354. * Creates a new AxesViewer
  58355. * @param scene defines the hosting scene
  58356. * @param scaleLines defines a number used to scale line length (1 by default)
  58357. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58358. * @param xAxis defines the node hierarchy used to render the x-axis
  58359. * @param yAxis defines the node hierarchy used to render the y-axis
  58360. * @param zAxis defines the node hierarchy used to render the z-axis
  58361. */
  58362. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58363. /**
  58364. * Force the viewer to update
  58365. * @param position defines the position of the viewer
  58366. * @param xaxis defines the x axis of the viewer
  58367. * @param yaxis defines the y axis of the viewer
  58368. * @param zaxis defines the z axis of the viewer
  58369. */
  58370. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58371. /**
  58372. * Creates an instance of this axes viewer.
  58373. * @returns a new axes viewer with instanced meshes
  58374. */
  58375. createInstance(): AxesViewer;
  58376. /** Releases resources */
  58377. dispose(): void;
  58378. private static _SetRenderingGroupId;
  58379. }
  58380. }
  58381. declare module BABYLON.Debug {
  58382. /**
  58383. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58384. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58385. */
  58386. export class BoneAxesViewer extends AxesViewer {
  58387. /**
  58388. * Gets or sets the target mesh where to display the axes viewer
  58389. */
  58390. mesh: Nullable<Mesh>;
  58391. /**
  58392. * Gets or sets the target bone where to display the axes viewer
  58393. */
  58394. bone: Nullable<Bone>;
  58395. /** Gets current position */
  58396. pos: Vector3;
  58397. /** Gets direction of X axis */
  58398. xaxis: Vector3;
  58399. /** Gets direction of Y axis */
  58400. yaxis: Vector3;
  58401. /** Gets direction of Z axis */
  58402. zaxis: Vector3;
  58403. /**
  58404. * Creates a new BoneAxesViewer
  58405. * @param scene defines the hosting scene
  58406. * @param bone defines the target bone
  58407. * @param mesh defines the target mesh
  58408. * @param scaleLines defines a scaling factor for line length (1 by default)
  58409. */
  58410. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58411. /**
  58412. * Force the viewer to update
  58413. */
  58414. update(): void;
  58415. /** Releases resources */
  58416. dispose(): void;
  58417. }
  58418. }
  58419. declare module BABYLON {
  58420. /**
  58421. * Interface used to define scene explorer extensibility option
  58422. */
  58423. export interface IExplorerExtensibilityOption {
  58424. /**
  58425. * Define the option label
  58426. */
  58427. label: string;
  58428. /**
  58429. * Defines the action to execute on click
  58430. */
  58431. action: (entity: any) => void;
  58432. }
  58433. /**
  58434. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58435. */
  58436. export interface IExplorerExtensibilityGroup {
  58437. /**
  58438. * Defines a predicate to test if a given type mut be extended
  58439. */
  58440. predicate: (entity: any) => boolean;
  58441. /**
  58442. * Gets the list of options added to a type
  58443. */
  58444. entries: IExplorerExtensibilityOption[];
  58445. }
  58446. /**
  58447. * Interface used to define the options to use to create the Inspector
  58448. */
  58449. export interface IInspectorOptions {
  58450. /**
  58451. * Display in overlay mode (default: false)
  58452. */
  58453. overlay?: boolean;
  58454. /**
  58455. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58456. */
  58457. globalRoot?: HTMLElement;
  58458. /**
  58459. * Display the Scene explorer
  58460. */
  58461. showExplorer?: boolean;
  58462. /**
  58463. * Display the property inspector
  58464. */
  58465. showInspector?: boolean;
  58466. /**
  58467. * Display in embed mode (both panes on the right)
  58468. */
  58469. embedMode?: boolean;
  58470. /**
  58471. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58472. */
  58473. handleResize?: boolean;
  58474. /**
  58475. * Allow the panes to popup (default: true)
  58476. */
  58477. enablePopup?: boolean;
  58478. /**
  58479. * Allow the panes to be closed by users (default: true)
  58480. */
  58481. enableClose?: boolean;
  58482. /**
  58483. * Optional list of extensibility entries
  58484. */
  58485. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58486. /**
  58487. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58488. */
  58489. inspectorURL?: string;
  58490. /**
  58491. * Optional initial tab (default to DebugLayerTab.Properties)
  58492. */
  58493. initialTab?: DebugLayerTab;
  58494. }
  58495. interface Scene {
  58496. /**
  58497. * @hidden
  58498. * Backing field
  58499. */
  58500. _debugLayer: DebugLayer;
  58501. /**
  58502. * Gets the debug layer (aka Inspector) associated with the scene
  58503. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58504. */
  58505. debugLayer: DebugLayer;
  58506. }
  58507. /**
  58508. * Enum of inspector action tab
  58509. */
  58510. export enum DebugLayerTab {
  58511. /**
  58512. * Properties tag (default)
  58513. */
  58514. Properties = 0,
  58515. /**
  58516. * Debug tab
  58517. */
  58518. Debug = 1,
  58519. /**
  58520. * Statistics tab
  58521. */
  58522. Statistics = 2,
  58523. /**
  58524. * Tools tab
  58525. */
  58526. Tools = 3,
  58527. /**
  58528. * Settings tab
  58529. */
  58530. Settings = 4
  58531. }
  58532. /**
  58533. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58534. * what is happening in your scene
  58535. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58536. */
  58537. export class DebugLayer {
  58538. /**
  58539. * Define the url to get the inspector script from.
  58540. * By default it uses the babylonjs CDN.
  58541. * @ignoreNaming
  58542. */
  58543. static InspectorURL: string;
  58544. private _scene;
  58545. private BJSINSPECTOR;
  58546. private _onPropertyChangedObservable?;
  58547. /**
  58548. * Observable triggered when a property is changed through the inspector.
  58549. */
  58550. get onPropertyChangedObservable(): any;
  58551. /**
  58552. * Instantiates a new debug layer.
  58553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58554. * what is happening in your scene
  58555. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58556. * @param scene Defines the scene to inspect
  58557. */
  58558. constructor(scene: Scene);
  58559. /** Creates the inspector window. */
  58560. private _createInspector;
  58561. /**
  58562. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58563. * @param entity defines the entity to select
  58564. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58565. */
  58566. select(entity: any, lineContainerTitles?: string | string[]): void;
  58567. /** Get the inspector from bundle or global */
  58568. private _getGlobalInspector;
  58569. /**
  58570. * Get if the inspector is visible or not.
  58571. * @returns true if visible otherwise, false
  58572. */
  58573. isVisible(): boolean;
  58574. /**
  58575. * Hide the inspector and close its window.
  58576. */
  58577. hide(): void;
  58578. /**
  58579. * Update the scene in the inspector
  58580. */
  58581. setAsActiveScene(): void;
  58582. /**
  58583. * Launch the debugLayer.
  58584. * @param config Define the configuration of the inspector
  58585. * @return a promise fulfilled when the debug layer is visible
  58586. */
  58587. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58588. }
  58589. }
  58590. declare module BABYLON.Debug {
  58591. /**
  58592. * Used to show the physics impostor around the specific mesh
  58593. */
  58594. export class PhysicsViewer {
  58595. /** @hidden */
  58596. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58597. /** @hidden */
  58598. protected _meshes: Array<Nullable<AbstractMesh>>;
  58599. /** @hidden */
  58600. protected _scene: Nullable<Scene>;
  58601. /** @hidden */
  58602. protected _numMeshes: number;
  58603. /** @hidden */
  58604. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58605. private _renderFunction;
  58606. private _utilityLayer;
  58607. private _debugBoxMesh;
  58608. private _debugSphereMesh;
  58609. private _debugCylinderMesh;
  58610. private _debugMaterial;
  58611. private _debugMeshMeshes;
  58612. /**
  58613. * Creates a new PhysicsViewer
  58614. * @param scene defines the hosting scene
  58615. */
  58616. constructor(scene: Scene);
  58617. /** @hidden */
  58618. protected _updateDebugMeshes(): void;
  58619. /**
  58620. * Renders a specified physic impostor
  58621. * @param impostor defines the impostor to render
  58622. * @param targetMesh defines the mesh represented by the impostor
  58623. * @returns the new debug mesh used to render the impostor
  58624. */
  58625. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58626. /**
  58627. * Hides a specified physic impostor
  58628. * @param impostor defines the impostor to hide
  58629. */
  58630. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58631. private _getDebugMaterial;
  58632. private _getDebugBoxMesh;
  58633. private _getDebugSphereMesh;
  58634. private _getDebugCylinderMesh;
  58635. private _getDebugMeshMesh;
  58636. private _getDebugMesh;
  58637. /** Releases all resources */
  58638. dispose(): void;
  58639. }
  58640. }
  58641. declare module BABYLON {
  58642. /**
  58643. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58644. * in order to better appreciate the issue one might have.
  58645. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58646. */
  58647. export class RayHelper {
  58648. /**
  58649. * Defines the ray we are currently tryin to visualize.
  58650. */
  58651. ray: Nullable<Ray>;
  58652. private _renderPoints;
  58653. private _renderLine;
  58654. private _renderFunction;
  58655. private _scene;
  58656. private _onAfterRenderObserver;
  58657. private _onAfterStepObserver;
  58658. private _attachedToMesh;
  58659. private _meshSpaceDirection;
  58660. private _meshSpaceOrigin;
  58661. /**
  58662. * Helper function to create a colored helper in a scene in one line.
  58663. * @param ray Defines the ray we are currently tryin to visualize
  58664. * @param scene Defines the scene the ray is used in
  58665. * @param color Defines the color we want to see the ray in
  58666. * @returns The newly created ray helper.
  58667. */
  58668. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58669. /**
  58670. * Instantiate a new ray helper.
  58671. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58672. * in order to better appreciate the issue one might have.
  58673. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58674. * @param ray Defines the ray we are currently tryin to visualize
  58675. */
  58676. constructor(ray: Ray);
  58677. /**
  58678. * Shows the ray we are willing to debug.
  58679. * @param scene Defines the scene the ray needs to be rendered in
  58680. * @param color Defines the color the ray needs to be rendered in
  58681. */
  58682. show(scene: Scene, color?: Color3): void;
  58683. /**
  58684. * Hides the ray we are debugging.
  58685. */
  58686. hide(): void;
  58687. private _render;
  58688. /**
  58689. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58690. * @param mesh Defines the mesh we want the helper attached to
  58691. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58692. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58693. * @param length Defines the length of the ray
  58694. */
  58695. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58696. /**
  58697. * Detach the ray helper from the mesh it has previously been attached to.
  58698. */
  58699. detachFromMesh(): void;
  58700. private _updateToMesh;
  58701. /**
  58702. * Dispose the helper and release its associated resources.
  58703. */
  58704. dispose(): void;
  58705. }
  58706. }
  58707. declare module BABYLON {
  58708. /**
  58709. * Defines the options associated with the creation of a SkeletonViewer.
  58710. */
  58711. export interface ISkeletonViewerOptions {
  58712. /** Should the system pause animations before building the Viewer? */
  58713. pauseAnimations: boolean;
  58714. /** Should the system return the skeleton to rest before building? */
  58715. returnToRest: boolean;
  58716. /** public Display Mode of the Viewer */
  58717. displayMode: number;
  58718. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58719. displayOptions: ISkeletonViewerDisplayOptions;
  58720. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58721. computeBonesUsingShaders: boolean;
  58722. /** Flag ignore non weighted bones */
  58723. useAllBones: boolean;
  58724. }
  58725. /**
  58726. * Defines how to display the various bone meshes for the viewer.
  58727. */
  58728. export interface ISkeletonViewerDisplayOptions {
  58729. /** How far down to start tapering the bone spurs */
  58730. midStep?: number;
  58731. /** How big is the midStep? */
  58732. midStepFactor?: number;
  58733. /** Base for the Sphere Size */
  58734. sphereBaseSize?: number;
  58735. /** The ratio of the sphere to the longest bone in units */
  58736. sphereScaleUnit?: number;
  58737. /** Ratio for the Sphere Size */
  58738. sphereFactor?: number;
  58739. /** Whether a spur should attach its far end to the child bone position */
  58740. spurFollowsChild?: boolean;
  58741. /** Whether to show local axes or not */
  58742. showLocalAxes?: boolean;
  58743. /** Length of each local axis */
  58744. localAxesSize?: number;
  58745. }
  58746. /**
  58747. * Defines the constructor options for the BoneWeight Shader.
  58748. */
  58749. export interface IBoneWeightShaderOptions {
  58750. /** Skeleton to Map */
  58751. skeleton: Skeleton;
  58752. /** Colors for Uninfluenced bones */
  58753. colorBase?: Color3;
  58754. /** Colors for 0.0-0.25 Weight bones */
  58755. colorZero?: Color3;
  58756. /** Color for 0.25-0.5 Weight Influence */
  58757. colorQuarter?: Color3;
  58758. /** Color for 0.5-0.75 Weight Influence */
  58759. colorHalf?: Color3;
  58760. /** Color for 0.75-1 Weight Influence */
  58761. colorFull?: Color3;
  58762. /** Color for Zero Weight Influence */
  58763. targetBoneIndex?: number;
  58764. }
  58765. /**
  58766. * Simple structure of the gradient steps for the Color Map.
  58767. */
  58768. export interface ISkeletonMapShaderColorMapKnot {
  58769. /** Color of the Knot */
  58770. color: Color3;
  58771. /** Location of the Knot */
  58772. location: number;
  58773. }
  58774. /**
  58775. * Defines the constructor options for the SkeletonMap Shader.
  58776. */
  58777. export interface ISkeletonMapShaderOptions {
  58778. /** Skeleton to Map */
  58779. skeleton: Skeleton;
  58780. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58781. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58782. }
  58783. }
  58784. declare module BABYLON {
  58785. /**
  58786. * Class containing static functions to help procedurally build meshes
  58787. */
  58788. export class RibbonBuilder {
  58789. /**
  58790. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58791. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58792. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58793. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58794. * * 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
  58795. * * 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
  58796. * * 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
  58797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58798. * * 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
  58799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58800. * * 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
  58801. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58802. * * 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
  58803. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58805. * @param name defines the name of the mesh
  58806. * @param options defines the options used to create the mesh
  58807. * @param scene defines the hosting scene
  58808. * @returns the ribbon mesh
  58809. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58811. */
  58812. static CreateRibbon(name: string, options: {
  58813. pathArray: Vector3[][];
  58814. closeArray?: boolean;
  58815. closePath?: boolean;
  58816. offset?: number;
  58817. updatable?: boolean;
  58818. sideOrientation?: number;
  58819. frontUVs?: Vector4;
  58820. backUVs?: Vector4;
  58821. instance?: Mesh;
  58822. invertUV?: boolean;
  58823. uvs?: Vector2[];
  58824. colors?: Color4[];
  58825. }, scene?: Nullable<Scene>): Mesh;
  58826. }
  58827. }
  58828. declare module BABYLON {
  58829. /**
  58830. * Class containing static functions to help procedurally build meshes
  58831. */
  58832. export class ShapeBuilder {
  58833. /**
  58834. * 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.
  58835. * * 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.
  58836. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58837. * * 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.
  58838. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58839. * * 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
  58840. * * 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
  58841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58843. * * 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
  58844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58846. * @param name defines the name of the mesh
  58847. * @param options defines the options used to create the mesh
  58848. * @param scene defines the hosting scene
  58849. * @returns the extruded shape mesh
  58850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58852. */
  58853. static ExtrudeShape(name: string, options: {
  58854. shape: Vector3[];
  58855. path: Vector3[];
  58856. scale?: number;
  58857. rotation?: number;
  58858. cap?: number;
  58859. updatable?: boolean;
  58860. sideOrientation?: number;
  58861. frontUVs?: Vector4;
  58862. backUVs?: Vector4;
  58863. instance?: Mesh;
  58864. invertUV?: boolean;
  58865. }, scene?: Nullable<Scene>): Mesh;
  58866. /**
  58867. * Creates an custom extruded shape mesh.
  58868. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58869. * * 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.
  58870. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58871. * * 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
  58872. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58873. * * 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
  58874. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58875. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58876. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58877. * * 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
  58878. * * 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
  58879. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58881. * * 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
  58882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58884. * @param name defines the name of the mesh
  58885. * @param options defines the options used to create the mesh
  58886. * @param scene defines the hosting scene
  58887. * @returns the custom extruded shape mesh
  58888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58891. */
  58892. static ExtrudeShapeCustom(name: string, options: {
  58893. shape: Vector3[];
  58894. path: Vector3[];
  58895. scaleFunction?: any;
  58896. rotationFunction?: any;
  58897. ribbonCloseArray?: boolean;
  58898. ribbonClosePath?: boolean;
  58899. cap?: number;
  58900. updatable?: boolean;
  58901. sideOrientation?: number;
  58902. frontUVs?: Vector4;
  58903. backUVs?: Vector4;
  58904. instance?: Mesh;
  58905. invertUV?: boolean;
  58906. }, scene?: Nullable<Scene>): Mesh;
  58907. private static _ExtrudeShapeGeneric;
  58908. }
  58909. }
  58910. declare module BABYLON.Debug {
  58911. /**
  58912. * Class used to render a debug view of a given skeleton
  58913. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58914. */
  58915. export class SkeletonViewer {
  58916. /** defines the skeleton to render */
  58917. skeleton: Skeleton;
  58918. /** defines the mesh attached to the skeleton */
  58919. mesh: AbstractMesh;
  58920. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58921. autoUpdateBonesMatrices: boolean;
  58922. /** defines the rendering group id to use with the viewer */
  58923. renderingGroupId: number;
  58924. /** is the options for the viewer */
  58925. options: Partial<ISkeletonViewerOptions>;
  58926. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58927. static readonly DISPLAY_LINES: number;
  58928. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58929. static readonly DISPLAY_SPHERES: number;
  58930. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58931. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58932. /** public static method to create a BoneWeight Shader
  58933. * @param options The constructor options
  58934. * @param scene The scene that the shader is scoped to
  58935. * @returns The created ShaderMaterial
  58936. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58937. */
  58938. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58939. /** public static method to create a BoneWeight Shader
  58940. * @param options The constructor options
  58941. * @param scene The scene that the shader is scoped to
  58942. * @returns The created ShaderMaterial
  58943. */
  58944. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58945. /** private static method to create a BoneWeight Shader
  58946. * @param size The size of the buffer to create (usually the bone count)
  58947. * @param colorMap The gradient data to generate
  58948. * @param scene The scene that the shader is scoped to
  58949. * @returns an Array of floats from the color gradient values
  58950. */
  58951. private static _CreateBoneMapColorBuffer;
  58952. /** If SkeletonViewer scene scope. */
  58953. private _scene;
  58954. /** Gets or sets the color used to render the skeleton */
  58955. color: Color3;
  58956. /** Array of the points of the skeleton fo the line view. */
  58957. private _debugLines;
  58958. /** The SkeletonViewers Mesh. */
  58959. private _debugMesh;
  58960. /** The local axes Meshes. */
  58961. private _localAxes;
  58962. /** If SkeletonViewer is enabled. */
  58963. private _isEnabled;
  58964. /** If SkeletonViewer is ready. */
  58965. private _ready;
  58966. /** SkeletonViewer render observable. */
  58967. private _obs;
  58968. /** The Utility Layer to render the gizmos in. */
  58969. private _utilityLayer;
  58970. private _boneIndices;
  58971. /** Gets the Scene. */
  58972. get scene(): Scene;
  58973. /** Gets the utilityLayer. */
  58974. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58975. /** Checks Ready Status. */
  58976. get isReady(): Boolean;
  58977. /** Sets Ready Status. */
  58978. set ready(value: boolean);
  58979. /** Gets the debugMesh */
  58980. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58981. /** Sets the debugMesh */
  58982. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58983. /** Gets the displayMode */
  58984. get displayMode(): number;
  58985. /** Sets the displayMode */
  58986. set displayMode(value: number);
  58987. /**
  58988. * Creates a new SkeletonViewer
  58989. * @param skeleton defines the skeleton to render
  58990. * @param mesh defines the mesh attached to the skeleton
  58991. * @param scene defines the hosting scene
  58992. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58993. * @param renderingGroupId defines the rendering group id to use with the viewer
  58994. * @param options All of the extra constructor options for the SkeletonViewer
  58995. */
  58996. constructor(
  58997. /** defines the skeleton to render */
  58998. skeleton: Skeleton,
  58999. /** defines the mesh attached to the skeleton */
  59000. mesh: AbstractMesh,
  59001. /** The Scene scope*/
  59002. scene: Scene,
  59003. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59004. autoUpdateBonesMatrices?: boolean,
  59005. /** defines the rendering group id to use with the viewer */
  59006. renderingGroupId?: number,
  59007. /** is the options for the viewer */
  59008. options?: Partial<ISkeletonViewerOptions>);
  59009. /** The Dynamic bindings for the update functions */
  59010. private _bindObs;
  59011. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59012. update(): void;
  59013. /** Gets or sets a boolean indicating if the viewer is enabled */
  59014. set isEnabled(value: boolean);
  59015. get isEnabled(): boolean;
  59016. private _getBonePosition;
  59017. private _getLinesForBonesWithLength;
  59018. private _getLinesForBonesNoLength;
  59019. /** function to revert the mesh and scene back to the initial state. */
  59020. private _revert;
  59021. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59022. private _getAbsoluteBindPoseToRef;
  59023. /** function to build and bind sphere joint points and spur bone representations. */
  59024. private _buildSpheresAndSpurs;
  59025. private _buildLocalAxes;
  59026. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59027. private _displayLinesUpdate;
  59028. /** Changes the displayMode of the skeleton viewer
  59029. * @param mode The displayMode numerical value
  59030. */
  59031. changeDisplayMode(mode: number): void;
  59032. /** Sets a display option of the skeleton viewer
  59033. *
  59034. * | Option | Type | Default | Description |
  59035. * | ---------------- | ------- | ------- | ----------- |
  59036. * | 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`. |
  59037. * | 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`. |
  59038. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59039. * | 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`. |
  59040. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59041. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59042. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59043. *
  59044. * @param option String of the option name
  59045. * @param value The numerical option value
  59046. */
  59047. changeDisplayOptions(option: string, value: number): void;
  59048. /** Release associated resources */
  59049. dispose(): void;
  59050. }
  59051. }
  59052. declare module BABYLON {
  59053. /**
  59054. * Enum for Device Types
  59055. */
  59056. export enum DeviceType {
  59057. /** Generic */
  59058. Generic = 0,
  59059. /** Keyboard */
  59060. Keyboard = 1,
  59061. /** Mouse */
  59062. Mouse = 2,
  59063. /** Touch Pointers */
  59064. Touch = 3,
  59065. /** PS4 Dual Shock */
  59066. DualShock = 4,
  59067. /** Xbox */
  59068. Xbox = 5,
  59069. /** Switch Controller */
  59070. Switch = 6
  59071. }
  59072. /**
  59073. * Enum for All Pointers (Touch/Mouse)
  59074. */
  59075. export enum PointerInput {
  59076. /** Horizontal Axis */
  59077. Horizontal = 0,
  59078. /** Vertical Axis */
  59079. Vertical = 1,
  59080. /** Left Click or Touch */
  59081. LeftClick = 2,
  59082. /** Middle Click */
  59083. MiddleClick = 3,
  59084. /** Right Click */
  59085. RightClick = 4,
  59086. /** Browser Back */
  59087. BrowserBack = 5,
  59088. /** Browser Forward */
  59089. BrowserForward = 6
  59090. }
  59091. /**
  59092. * Enum for Dual Shock Gamepad
  59093. */
  59094. export enum DualShockInput {
  59095. /** Cross */
  59096. Cross = 0,
  59097. /** Circle */
  59098. Circle = 1,
  59099. /** Square */
  59100. Square = 2,
  59101. /** Triangle */
  59102. Triangle = 3,
  59103. /** L1 */
  59104. L1 = 4,
  59105. /** R1 */
  59106. R1 = 5,
  59107. /** L2 */
  59108. L2 = 6,
  59109. /** R2 */
  59110. R2 = 7,
  59111. /** Share */
  59112. Share = 8,
  59113. /** Options */
  59114. Options = 9,
  59115. /** L3 */
  59116. L3 = 10,
  59117. /** R3 */
  59118. R3 = 11,
  59119. /** DPadUp */
  59120. DPadUp = 12,
  59121. /** DPadDown */
  59122. DPadDown = 13,
  59123. /** DPadLeft */
  59124. DPadLeft = 14,
  59125. /** DRight */
  59126. DPadRight = 15,
  59127. /** Home */
  59128. Home = 16,
  59129. /** TouchPad */
  59130. TouchPad = 17,
  59131. /** LStickXAxis */
  59132. LStickXAxis = 18,
  59133. /** LStickYAxis */
  59134. LStickYAxis = 19,
  59135. /** RStickXAxis */
  59136. RStickXAxis = 20,
  59137. /** RStickYAxis */
  59138. RStickYAxis = 21
  59139. }
  59140. /**
  59141. * Enum for Xbox Gamepad
  59142. */
  59143. export enum XboxInput {
  59144. /** A */
  59145. A = 0,
  59146. /** B */
  59147. B = 1,
  59148. /** X */
  59149. X = 2,
  59150. /** Y */
  59151. Y = 3,
  59152. /** LB */
  59153. LB = 4,
  59154. /** RB */
  59155. RB = 5,
  59156. /** LT */
  59157. LT = 6,
  59158. /** RT */
  59159. RT = 7,
  59160. /** Back */
  59161. Back = 8,
  59162. /** Start */
  59163. Start = 9,
  59164. /** LS */
  59165. LS = 10,
  59166. /** RS */
  59167. RS = 11,
  59168. /** DPadUp */
  59169. DPadUp = 12,
  59170. /** DPadDown */
  59171. DPadDown = 13,
  59172. /** DPadLeft */
  59173. DPadLeft = 14,
  59174. /** DRight */
  59175. DPadRight = 15,
  59176. /** Home */
  59177. Home = 16,
  59178. /** LStickXAxis */
  59179. LStickXAxis = 17,
  59180. /** LStickYAxis */
  59181. LStickYAxis = 18,
  59182. /** RStickXAxis */
  59183. RStickXAxis = 19,
  59184. /** RStickYAxis */
  59185. RStickYAxis = 20
  59186. }
  59187. /**
  59188. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59189. */
  59190. export enum SwitchInput {
  59191. /** B */
  59192. B = 0,
  59193. /** A */
  59194. A = 1,
  59195. /** Y */
  59196. Y = 2,
  59197. /** X */
  59198. X = 3,
  59199. /** L */
  59200. L = 4,
  59201. /** R */
  59202. R = 5,
  59203. /** ZL */
  59204. ZL = 6,
  59205. /** ZR */
  59206. ZR = 7,
  59207. /** Minus */
  59208. Minus = 8,
  59209. /** Plus */
  59210. Plus = 9,
  59211. /** LS */
  59212. LS = 10,
  59213. /** RS */
  59214. RS = 11,
  59215. /** DPadUp */
  59216. DPadUp = 12,
  59217. /** DPadDown */
  59218. DPadDown = 13,
  59219. /** DPadLeft */
  59220. DPadLeft = 14,
  59221. /** DRight */
  59222. DPadRight = 15,
  59223. /** Home */
  59224. Home = 16,
  59225. /** Capture */
  59226. Capture = 17,
  59227. /** LStickXAxis */
  59228. LStickXAxis = 18,
  59229. /** LStickYAxis */
  59230. LStickYAxis = 19,
  59231. /** RStickXAxis */
  59232. RStickXAxis = 20,
  59233. /** RStickYAxis */
  59234. RStickYAxis = 21
  59235. }
  59236. }
  59237. declare module BABYLON {
  59238. /**
  59239. * This class will take all inputs from Keyboard, Pointer, and
  59240. * any Gamepads and provide a polling system that all devices
  59241. * will use. This class assumes that there will only be one
  59242. * pointer device and one keyboard.
  59243. */
  59244. export class DeviceInputSystem implements IDisposable {
  59245. /**
  59246. * Returns onDeviceConnected callback property
  59247. * @returns Callback with function to execute when a device is connected
  59248. */
  59249. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59250. /**
  59251. * Sets callback function when a device is connected and executes against all connected devices
  59252. * @param callback Function to execute when a device is connected
  59253. */
  59254. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59255. /**
  59256. * Callback to be triggered when a device is disconnected
  59257. */
  59258. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59259. /**
  59260. * Callback to be triggered when event driven input is updated
  59261. */
  59262. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59263. private _inputs;
  59264. private _gamepads;
  59265. private _keyboardActive;
  59266. private _pointerActive;
  59267. private _elementToAttachTo;
  59268. private _keyboardDownEvent;
  59269. private _keyboardUpEvent;
  59270. private _pointerMoveEvent;
  59271. private _pointerDownEvent;
  59272. private _pointerUpEvent;
  59273. private _gamepadConnectedEvent;
  59274. private _gamepadDisconnectedEvent;
  59275. private _onDeviceConnected;
  59276. private static _MAX_KEYCODES;
  59277. private static _MAX_POINTER_INPUTS;
  59278. private constructor();
  59279. /**
  59280. * Creates a new DeviceInputSystem instance
  59281. * @param engine Engine to pull input element from
  59282. * @returns The new instance
  59283. */
  59284. static Create(engine: Engine): DeviceInputSystem;
  59285. /**
  59286. * Checks for current device input value, given an id and input index
  59287. * @param deviceName Id of connected device
  59288. * @param inputIndex Index of device input
  59289. * @returns Current value of input
  59290. */
  59291. /**
  59292. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59293. * @param deviceType Enum specifiying device type
  59294. * @param deviceSlot "Slot" or index that device is referenced in
  59295. * @param inputIndex Id of input to be checked
  59296. * @returns Current value of input
  59297. */
  59298. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59299. /**
  59300. * Dispose of all the eventlisteners
  59301. */
  59302. dispose(): void;
  59303. /**
  59304. * Checks for existing connections to devices and register them, if necessary
  59305. * Currently handles gamepads and mouse
  59306. */
  59307. private _checkForConnectedDevices;
  59308. /**
  59309. * Add a gamepad to the DeviceInputSystem
  59310. * @param gamepad A single DOM Gamepad object
  59311. */
  59312. private _addGamePad;
  59313. /**
  59314. * Add pointer device to DeviceInputSystem
  59315. * @param deviceType Type of Pointer to add
  59316. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59317. * @param currentX Current X at point of adding
  59318. * @param currentY Current Y at point of adding
  59319. */
  59320. private _addPointerDevice;
  59321. /**
  59322. * Add device and inputs to device array
  59323. * @param deviceType Enum specifiying device type
  59324. * @param deviceSlot "Slot" or index that device is referenced in
  59325. * @param numberOfInputs Number of input entries to create for given device
  59326. */
  59327. private _registerDevice;
  59328. /**
  59329. * Given a specific device name, remove that device from the device map
  59330. * @param deviceType Enum specifiying device type
  59331. * @param deviceSlot "Slot" or index that device is referenced in
  59332. */
  59333. private _unregisterDevice;
  59334. /**
  59335. * Handle all actions that come from keyboard interaction
  59336. */
  59337. private _handleKeyActions;
  59338. /**
  59339. * Handle all actions that come from pointer interaction
  59340. */
  59341. private _handlePointerActions;
  59342. /**
  59343. * Handle all actions that come from gamepad interaction
  59344. */
  59345. private _handleGamepadActions;
  59346. /**
  59347. * Update all non-event based devices with each frame
  59348. * @param deviceType Enum specifiying device type
  59349. * @param deviceSlot "Slot" or index that device is referenced in
  59350. * @param inputIndex Id of input to be checked
  59351. */
  59352. private _updateDevice;
  59353. /**
  59354. * Gets DeviceType from the device name
  59355. * @param deviceName Name of Device from DeviceInputSystem
  59356. * @returns DeviceType enum value
  59357. */
  59358. private _getGamepadDeviceType;
  59359. }
  59360. }
  59361. declare module BABYLON {
  59362. /**
  59363. * Type to handle enforcement of inputs
  59364. */
  59365. 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;
  59366. }
  59367. declare module BABYLON {
  59368. /**
  59369. * Class that handles all input for a specific device
  59370. */
  59371. export class DeviceSource<T extends DeviceType> {
  59372. /** Type of device */
  59373. readonly deviceType: DeviceType;
  59374. /** "Slot" or index that device is referenced in */
  59375. readonly deviceSlot: number;
  59376. /**
  59377. * Observable to handle device input changes per device
  59378. */
  59379. readonly onInputChangedObservable: Observable<{
  59380. inputIndex: DeviceInput<T>;
  59381. previousState: Nullable<number>;
  59382. currentState: Nullable<number>;
  59383. }>;
  59384. private readonly _deviceInputSystem;
  59385. /**
  59386. * Default Constructor
  59387. * @param deviceInputSystem Reference to DeviceInputSystem
  59388. * @param deviceType Type of device
  59389. * @param deviceSlot "Slot" or index that device is referenced in
  59390. */
  59391. constructor(deviceInputSystem: DeviceInputSystem,
  59392. /** Type of device */
  59393. deviceType: DeviceType,
  59394. /** "Slot" or index that device is referenced in */
  59395. deviceSlot?: number);
  59396. /**
  59397. * Get input for specific input
  59398. * @param inputIndex index of specific input on device
  59399. * @returns Input value from DeviceInputSystem
  59400. */
  59401. getInput(inputIndex: DeviceInput<T>): number;
  59402. }
  59403. /**
  59404. * Class to keep track of devices
  59405. */
  59406. export class DeviceSourceManager implements IDisposable {
  59407. /**
  59408. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59409. */
  59410. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59411. /**
  59412. * Observable to be triggered when after a device is disconnected
  59413. */
  59414. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59415. private readonly _devices;
  59416. private readonly _firstDevice;
  59417. private readonly _deviceInputSystem;
  59418. /**
  59419. * Default Constructor
  59420. * @param engine engine to pull input element from
  59421. */
  59422. constructor(engine: Engine);
  59423. /**
  59424. * Gets a DeviceSource, given a type and slot
  59425. * @param deviceType Enum specifying device type
  59426. * @param deviceSlot "Slot" or index that device is referenced in
  59427. * @returns DeviceSource object
  59428. */
  59429. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59430. /**
  59431. * Gets an array of DeviceSource objects for a given device type
  59432. * @param deviceType Enum specifying device type
  59433. * @returns Array of DeviceSource objects
  59434. */
  59435. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59436. /**
  59437. * Returns a read-only list of all available devices
  59438. * @returns Read-only array with active devices
  59439. */
  59440. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59441. /**
  59442. * Dispose of DeviceInputSystem and other parts
  59443. */
  59444. dispose(): void;
  59445. /**
  59446. * Function to add device name to device list
  59447. * @param deviceType Enum specifying device type
  59448. * @param deviceSlot "Slot" or index that device is referenced in
  59449. */
  59450. private _addDevice;
  59451. /**
  59452. * Function to remove device name to device list
  59453. * @param deviceType Enum specifying device type
  59454. * @param deviceSlot "Slot" or index that device is referenced in
  59455. */
  59456. private _removeDevice;
  59457. /**
  59458. * Updates array storing first connected device of each type
  59459. * @param type Type of Device
  59460. */
  59461. private _updateFirstDevices;
  59462. }
  59463. }
  59464. declare module BABYLON {
  59465. /**
  59466. * Options to create the null engine
  59467. */
  59468. export class NullEngineOptions {
  59469. /**
  59470. * Render width (Default: 512)
  59471. */
  59472. renderWidth: number;
  59473. /**
  59474. * Render height (Default: 256)
  59475. */
  59476. renderHeight: number;
  59477. /**
  59478. * Texture size (Default: 512)
  59479. */
  59480. textureSize: number;
  59481. /**
  59482. * If delta time between frames should be constant
  59483. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59484. */
  59485. deterministicLockstep: boolean;
  59486. /**
  59487. * Maximum about of steps between frames (Default: 4)
  59488. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59489. */
  59490. lockstepMaxSteps: number;
  59491. /**
  59492. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59493. */
  59494. useHighPrecisionMatrix?: boolean;
  59495. }
  59496. /**
  59497. * The null engine class provides support for headless version of babylon.js.
  59498. * This can be used in server side scenario or for testing purposes
  59499. */
  59500. export class NullEngine extends Engine {
  59501. private _options;
  59502. /**
  59503. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59504. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59505. * @returns true if engine is in deterministic lock step mode
  59506. */
  59507. isDeterministicLockStep(): boolean;
  59508. /**
  59509. * Gets the max steps when engine is running in deterministic lock step
  59510. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59511. * @returns the max steps
  59512. */
  59513. getLockstepMaxSteps(): number;
  59514. /**
  59515. * Gets the current hardware scaling level.
  59516. * By default the hardware scaling level is computed from the window device ratio.
  59517. * 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.
  59518. * @returns a number indicating the current hardware scaling level
  59519. */
  59520. getHardwareScalingLevel(): number;
  59521. constructor(options?: NullEngineOptions);
  59522. /**
  59523. * Creates a vertex buffer
  59524. * @param vertices the data for the vertex buffer
  59525. * @returns the new WebGL static buffer
  59526. */
  59527. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59528. /**
  59529. * Creates a new index buffer
  59530. * @param indices defines the content of the index buffer
  59531. * @param updatable defines if the index buffer must be updatable
  59532. * @returns a new webGL buffer
  59533. */
  59534. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59535. /**
  59536. * Clear the current render buffer or the current render target (if any is set up)
  59537. * @param color defines the color to use
  59538. * @param backBuffer defines if the back buffer must be cleared
  59539. * @param depth defines if the depth buffer must be cleared
  59540. * @param stencil defines if the stencil buffer must be cleared
  59541. */
  59542. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59543. /**
  59544. * Gets the current render width
  59545. * @param useScreen defines if screen size must be used (or the current render target if any)
  59546. * @returns a number defining the current render width
  59547. */
  59548. getRenderWidth(useScreen?: boolean): number;
  59549. /**
  59550. * Gets the current render height
  59551. * @param useScreen defines if screen size must be used (or the current render target if any)
  59552. * @returns a number defining the current render height
  59553. */
  59554. getRenderHeight(useScreen?: boolean): number;
  59555. /**
  59556. * Set the WebGL's viewport
  59557. * @param viewport defines the viewport element to be used
  59558. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59559. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59560. */
  59561. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59562. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59563. /**
  59564. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59565. * @param pipelineContext defines the pipeline context to use
  59566. * @param uniformsNames defines the list of uniform names
  59567. * @returns an array of webGL uniform locations
  59568. */
  59569. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59570. /**
  59571. * Gets the lsit of active attributes for a given webGL program
  59572. * @param pipelineContext defines the pipeline context to use
  59573. * @param attributesNames defines the list of attribute names to get
  59574. * @returns an array of indices indicating the offset of each attribute
  59575. */
  59576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59577. /**
  59578. * Binds an effect to the webGL context
  59579. * @param effect defines the effect to bind
  59580. */
  59581. bindSamplers(effect: Effect): void;
  59582. /**
  59583. * Activates an effect, making it the current one (ie. the one used for rendering)
  59584. * @param effect defines the effect to activate
  59585. */
  59586. enableEffect(effect: Effect): void;
  59587. /**
  59588. * Set various states to the webGL context
  59589. * @param culling defines backface culling state
  59590. * @param zOffset defines the value to apply to zOffset (0 by default)
  59591. * @param force defines if states must be applied even if cache is up to date
  59592. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59593. */
  59594. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59595. /**
  59596. * Set the value of an uniform to an array of int32
  59597. * @param uniform defines the webGL uniform location where to store the value
  59598. * @param array defines the array of int32 to store
  59599. * @returns true if value was set
  59600. */
  59601. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59602. /**
  59603. * Set the value of an uniform to an array of int32 (stored as vec2)
  59604. * @param uniform defines the webGL uniform location where to store the value
  59605. * @param array defines the array of int32 to store
  59606. * @returns true if value was set
  59607. */
  59608. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59609. /**
  59610. * Set the value of an uniform to an array of int32 (stored as vec3)
  59611. * @param uniform defines the webGL uniform location where to store the value
  59612. * @param array defines the array of int32 to store
  59613. * @returns true if value was set
  59614. */
  59615. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59616. /**
  59617. * Set the value of an uniform to an array of int32 (stored as vec4)
  59618. * @param uniform defines the webGL uniform location where to store the value
  59619. * @param array defines the array of int32 to store
  59620. * @returns true if value was set
  59621. */
  59622. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59623. /**
  59624. * Set the value of an uniform to an array of float32
  59625. * @param uniform defines the webGL uniform location where to store the value
  59626. * @param array defines the array of float32 to store
  59627. * @returns true if value was set
  59628. */
  59629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59630. /**
  59631. * Set the value of an uniform to an array of float32 (stored as vec2)
  59632. * @param uniform defines the webGL uniform location where to store the value
  59633. * @param array defines the array of float32 to store
  59634. * @returns true if value was set
  59635. */
  59636. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59637. /**
  59638. * Set the value of an uniform to an array of float32 (stored as vec3)
  59639. * @param uniform defines the webGL uniform location where to store the value
  59640. * @param array defines the array of float32 to store
  59641. * @returns true if value was set
  59642. */
  59643. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59644. /**
  59645. * Set the value of an uniform to an array of float32 (stored as vec4)
  59646. * @param uniform defines the webGL uniform location where to store the value
  59647. * @param array defines the array of float32 to store
  59648. * @returns true if value was set
  59649. */
  59650. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59651. /**
  59652. * Set the value of an uniform to an array of number
  59653. * @param uniform defines the webGL uniform location where to store the value
  59654. * @param array defines the array of number to store
  59655. * @returns true if value was set
  59656. */
  59657. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59658. /**
  59659. * Set the value of an uniform to an array of number (stored as vec2)
  59660. * @param uniform defines the webGL uniform location where to store the value
  59661. * @param array defines the array of number to store
  59662. * @returns true if value was set
  59663. */
  59664. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59665. /**
  59666. * Set the value of an uniform to an array of number (stored as vec3)
  59667. * @param uniform defines the webGL uniform location where to store the value
  59668. * @param array defines the array of number to store
  59669. * @returns true if value was set
  59670. */
  59671. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59672. /**
  59673. * Set the value of an uniform to an array of number (stored as vec4)
  59674. * @param uniform defines the webGL uniform location where to store the value
  59675. * @param array defines the array of number to store
  59676. * @returns true if value was set
  59677. */
  59678. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59679. /**
  59680. * Set the value of an uniform to an array of float32 (stored as matrices)
  59681. * @param uniform defines the webGL uniform location where to store the value
  59682. * @param matrices defines the array of float32 to store
  59683. * @returns true if value was set
  59684. */
  59685. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59686. /**
  59687. * Set the value of an uniform to a matrix (3x3)
  59688. * @param uniform defines the webGL uniform location where to store the value
  59689. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59690. * @returns true if value was set
  59691. */
  59692. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59693. /**
  59694. * Set the value of an uniform to a matrix (2x2)
  59695. * @param uniform defines the webGL uniform location where to store the value
  59696. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59697. * @returns true if value was set
  59698. */
  59699. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59700. /**
  59701. * Set the value of an uniform to a number (float)
  59702. * @param uniform defines the webGL uniform location where to store the value
  59703. * @param value defines the float number to store
  59704. * @returns true if value was set
  59705. */
  59706. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59707. /**
  59708. * Set the value of an uniform to a vec2
  59709. * @param uniform defines the webGL uniform location where to store the value
  59710. * @param x defines the 1st component of the value
  59711. * @param y defines the 2nd component of the value
  59712. * @returns true if value was set
  59713. */
  59714. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59715. /**
  59716. * Set the value of an uniform to a vec3
  59717. * @param uniform defines the webGL uniform location where to store the value
  59718. * @param x defines the 1st component of the value
  59719. * @param y defines the 2nd component of the value
  59720. * @param z defines the 3rd component of the value
  59721. * @returns true if value was set
  59722. */
  59723. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59724. /**
  59725. * Set the value of an uniform to a boolean
  59726. * @param uniform defines the webGL uniform location where to store the value
  59727. * @param bool defines the boolean to store
  59728. * @returns true if value was set
  59729. */
  59730. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59731. /**
  59732. * Set the value of an uniform to a vec4
  59733. * @param uniform defines the webGL uniform location where to store the value
  59734. * @param x defines the 1st component of the value
  59735. * @param y defines the 2nd component of the value
  59736. * @param z defines the 3rd component of the value
  59737. * @param w defines the 4th component of the value
  59738. * @returns true if value was set
  59739. */
  59740. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59741. /**
  59742. * Sets the current alpha mode
  59743. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59744. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59745. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59746. */
  59747. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59748. /**
  59749. * Bind webGl buffers directly to the webGL context
  59750. * @param vertexBuffers defines the vertex buffer to bind
  59751. * @param indexBuffer defines the index buffer to bind
  59752. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59753. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59754. * @param effect defines the effect associated with the vertex buffer
  59755. */
  59756. bindBuffers(vertexBuffers: {
  59757. [key: string]: VertexBuffer;
  59758. }, indexBuffer: DataBuffer, effect: Effect): void;
  59759. /**
  59760. * Force the entire cache to be cleared
  59761. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59762. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59763. */
  59764. wipeCaches(bruteForce?: boolean): void;
  59765. /**
  59766. * Send a draw order
  59767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59768. * @param indexStart defines the starting index
  59769. * @param indexCount defines the number of index to draw
  59770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59771. */
  59772. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59773. /**
  59774. * Draw a list of indexed primitives
  59775. * @param fillMode defines the primitive to use
  59776. * @param indexStart defines the starting index
  59777. * @param indexCount defines the number of index to draw
  59778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59779. */
  59780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59781. /**
  59782. * Draw a list of unindexed primitives
  59783. * @param fillMode defines the primitive to use
  59784. * @param verticesStart defines the index of first vertex to draw
  59785. * @param verticesCount defines the count of vertices to draw
  59786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59787. */
  59788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59789. /** @hidden */
  59790. protected _createTexture(): WebGLTexture;
  59791. /** @hidden */
  59792. _releaseTexture(texture: InternalTexture): void;
  59793. /**
  59794. * Usually called from Texture.ts.
  59795. * Passed information to create a WebGLTexture
  59796. * @param urlArg defines a value which contains one of the following:
  59797. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59798. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59799. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59801. * @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)
  59802. * @param scene needed for loading to the correct scene
  59803. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59804. * @param onLoad optional callback to be called upon successful completion
  59805. * @param onError optional callback to be called upon failure
  59806. * @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
  59807. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59808. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59809. * @param forcedExtension defines the extension to use to pick the right loader
  59810. * @param mimeType defines an optional mime type
  59811. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59812. */
  59813. 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;
  59814. /**
  59815. * Creates a new render target texture
  59816. * @param size defines the size of the texture
  59817. * @param options defines the options used to create the texture
  59818. * @returns a new render target texture stored in an InternalTexture
  59819. */
  59820. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59821. /**
  59822. * Update the sampling mode of a given texture
  59823. * @param samplingMode defines the required sampling mode
  59824. * @param texture defines the texture to update
  59825. */
  59826. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59827. /**
  59828. * Binds the frame buffer to the specified texture.
  59829. * @param texture The texture to render to or null for the default canvas
  59830. * @param faceIndex The face of the texture to render to in case of cube texture
  59831. * @param requiredWidth The width of the target to render to
  59832. * @param requiredHeight The height of the target to render to
  59833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59834. * @param lodLevel defines le lod level to bind to the frame buffer
  59835. */
  59836. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59837. /**
  59838. * Unbind the current render target texture from the webGL context
  59839. * @param texture defines the render target texture to unbind
  59840. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59841. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59842. */
  59843. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59844. /**
  59845. * Creates a dynamic vertex buffer
  59846. * @param vertices the data for the dynamic vertex buffer
  59847. * @returns the new WebGL dynamic buffer
  59848. */
  59849. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59850. /**
  59851. * Update the content of a dynamic texture
  59852. * @param texture defines the texture to update
  59853. * @param canvas defines the canvas containing the source
  59854. * @param invertY defines if data must be stored with Y axis inverted
  59855. * @param premulAlpha defines if alpha is stored as premultiplied
  59856. * @param format defines the format of the data
  59857. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59858. */
  59859. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59860. /**
  59861. * Gets a boolean indicating if all created effects are ready
  59862. * @returns true if all effects are ready
  59863. */
  59864. areAllEffectsReady(): boolean;
  59865. /**
  59866. * @hidden
  59867. * Get the current error code of the webGL context
  59868. * @returns the error code
  59869. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59870. */
  59871. getError(): number;
  59872. /** @hidden */
  59873. _getUnpackAlignement(): number;
  59874. /** @hidden */
  59875. _unpackFlipY(value: boolean): void;
  59876. /**
  59877. * Update a dynamic index buffer
  59878. * @param indexBuffer defines the target index buffer
  59879. * @param indices defines the data to update
  59880. * @param offset defines the offset in the target index buffer where update should start
  59881. */
  59882. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59883. /**
  59884. * Updates a dynamic vertex buffer.
  59885. * @param vertexBuffer the vertex buffer to update
  59886. * @param vertices the data used to update the vertex buffer
  59887. * @param byteOffset the byte offset of the data (optional)
  59888. * @param byteLength the byte length of the data (optional)
  59889. */
  59890. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59891. /** @hidden */
  59892. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59893. /** @hidden */
  59894. _bindTexture(channel: number, texture: InternalTexture): void;
  59895. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59896. /**
  59897. * 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
  59898. */
  59899. releaseEffects(): void;
  59900. displayLoadingUI(): void;
  59901. hideLoadingUI(): void;
  59902. /** @hidden */
  59903. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59904. /** @hidden */
  59905. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59906. /** @hidden */
  59907. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59908. /** @hidden */
  59909. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59910. }
  59911. }
  59912. declare module BABYLON {
  59913. /** @hidden */
  59914. export class _OcclusionDataStorage {
  59915. /** @hidden */
  59916. occlusionInternalRetryCounter: number;
  59917. /** @hidden */
  59918. isOcclusionQueryInProgress: boolean;
  59919. /** @hidden */
  59920. isOccluded: boolean;
  59921. /** @hidden */
  59922. occlusionRetryCount: number;
  59923. /** @hidden */
  59924. occlusionType: number;
  59925. /** @hidden */
  59926. occlusionQueryAlgorithmType: number;
  59927. }
  59928. interface Engine {
  59929. /**
  59930. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59931. * @return the new query
  59932. */
  59933. createQuery(): WebGLQuery;
  59934. /**
  59935. * Delete and release a webGL query
  59936. * @param query defines the query to delete
  59937. * @return the current engine
  59938. */
  59939. deleteQuery(query: WebGLQuery): Engine;
  59940. /**
  59941. * Check if a given query has resolved and got its value
  59942. * @param query defines the query to check
  59943. * @returns true if the query got its value
  59944. */
  59945. isQueryResultAvailable(query: WebGLQuery): boolean;
  59946. /**
  59947. * Gets the value of a given query
  59948. * @param query defines the query to check
  59949. * @returns the value of the query
  59950. */
  59951. getQueryResult(query: WebGLQuery): number;
  59952. /**
  59953. * Initiates an occlusion query
  59954. * @param algorithmType defines the algorithm to use
  59955. * @param query defines the query to use
  59956. * @returns the current engine
  59957. * @see https://doc.babylonjs.com/features/occlusionquery
  59958. */
  59959. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59960. /**
  59961. * Ends an occlusion query
  59962. * @see https://doc.babylonjs.com/features/occlusionquery
  59963. * @param algorithmType defines the algorithm to use
  59964. * @returns the current engine
  59965. */
  59966. endOcclusionQuery(algorithmType: number): Engine;
  59967. /**
  59968. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59969. * Please note that only one query can be issued at a time
  59970. * @returns a time token used to track the time span
  59971. */
  59972. startTimeQuery(): Nullable<_TimeToken>;
  59973. /**
  59974. * Ends a time query
  59975. * @param token defines the token used to measure the time span
  59976. * @returns the time spent (in ns)
  59977. */
  59978. endTimeQuery(token: _TimeToken): int;
  59979. /** @hidden */
  59980. _currentNonTimestampToken: Nullable<_TimeToken>;
  59981. /** @hidden */
  59982. _createTimeQuery(): WebGLQuery;
  59983. /** @hidden */
  59984. _deleteTimeQuery(query: WebGLQuery): void;
  59985. /** @hidden */
  59986. _getGlAlgorithmType(algorithmType: number): number;
  59987. /** @hidden */
  59988. _getTimeQueryResult(query: WebGLQuery): any;
  59989. /** @hidden */
  59990. _getTimeQueryAvailability(query: WebGLQuery): any;
  59991. }
  59992. interface AbstractMesh {
  59993. /**
  59994. * Backing filed
  59995. * @hidden
  59996. */
  59997. __occlusionDataStorage: _OcclusionDataStorage;
  59998. /**
  59999. * Access property
  60000. * @hidden
  60001. */
  60002. _occlusionDataStorage: _OcclusionDataStorage;
  60003. /**
  60004. * 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.
  60005. * The default value is -1 which means don't break the query and wait till the result
  60006. * @see https://doc.babylonjs.com/features/occlusionquery
  60007. */
  60008. occlusionRetryCount: number;
  60009. /**
  60010. * 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:
  60011. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60012. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60013. * * 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.
  60014. * @see https://doc.babylonjs.com/features/occlusionquery
  60015. */
  60016. occlusionType: number;
  60017. /**
  60018. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60019. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60020. * * 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.
  60021. * @see https://doc.babylonjs.com/features/occlusionquery
  60022. */
  60023. occlusionQueryAlgorithmType: number;
  60024. /**
  60025. * 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
  60026. * @see https://doc.babylonjs.com/features/occlusionquery
  60027. */
  60028. isOccluded: boolean;
  60029. /**
  60030. * Flag to check the progress status of the query
  60031. * @see https://doc.babylonjs.com/features/occlusionquery
  60032. */
  60033. isOcclusionQueryInProgress: boolean;
  60034. }
  60035. }
  60036. declare module BABYLON {
  60037. /** @hidden */
  60038. export var _forceTransformFeedbackToBundle: boolean;
  60039. interface Engine {
  60040. /**
  60041. * Creates a webGL transform feedback object
  60042. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60043. * @returns the webGL transform feedback object
  60044. */
  60045. createTransformFeedback(): WebGLTransformFeedback;
  60046. /**
  60047. * Delete a webGL transform feedback object
  60048. * @param value defines the webGL transform feedback object to delete
  60049. */
  60050. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60051. /**
  60052. * Bind a webGL transform feedback object to the webgl context
  60053. * @param value defines the webGL transform feedback object to bind
  60054. */
  60055. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60056. /**
  60057. * Begins a transform feedback operation
  60058. * @param usePoints defines if points or triangles must be used
  60059. */
  60060. beginTransformFeedback(usePoints: boolean): void;
  60061. /**
  60062. * Ends a transform feedback operation
  60063. */
  60064. endTransformFeedback(): void;
  60065. /**
  60066. * Specify the varyings to use with transform feedback
  60067. * @param program defines the associated webGL program
  60068. * @param value defines the list of strings representing the varying names
  60069. */
  60070. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60071. /**
  60072. * Bind a webGL buffer for a transform feedback operation
  60073. * @param value defines the webGL buffer to bind
  60074. */
  60075. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60076. }
  60077. }
  60078. declare module BABYLON {
  60079. /**
  60080. * Class used to define an additional view for the engine
  60081. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60082. */
  60083. export class EngineView {
  60084. /** Defines the canvas where to render the view */
  60085. target: HTMLCanvasElement;
  60086. /** Defines an optional camera used to render the view (will use active camera else) */
  60087. camera?: Camera;
  60088. }
  60089. interface Engine {
  60090. /**
  60091. * Gets or sets the HTML element to use for attaching events
  60092. */
  60093. inputElement: Nullable<HTMLElement>;
  60094. /**
  60095. * Gets the current engine view
  60096. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60097. */
  60098. activeView: Nullable<EngineView>;
  60099. /** Gets or sets the list of views */
  60100. views: EngineView[];
  60101. /**
  60102. * Register a new child canvas
  60103. * @param canvas defines the canvas to register
  60104. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60105. * @returns the associated view
  60106. */
  60107. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60108. /**
  60109. * Remove a registered child canvas
  60110. * @param canvas defines the canvas to remove
  60111. * @returns the current engine
  60112. */
  60113. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. interface Engine {
  60118. /** @hidden */
  60119. _excludedCompressedTextures: string[];
  60120. /** @hidden */
  60121. _textureFormatInUse: string;
  60122. /**
  60123. * Gets the list of texture formats supported
  60124. */
  60125. readonly texturesSupported: Array<string>;
  60126. /**
  60127. * Gets the texture format in use
  60128. */
  60129. readonly textureFormatInUse: Nullable<string>;
  60130. /**
  60131. * Set the compressed texture extensions or file names to skip.
  60132. *
  60133. * @param skippedFiles defines the list of those texture files you want to skip
  60134. * Example: [".dds", ".env", "myfile.png"]
  60135. */
  60136. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60137. /**
  60138. * Set the compressed texture format to use, based on the formats you have, and the formats
  60139. * supported by the hardware / browser.
  60140. *
  60141. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60142. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60143. * to API arguments needed to compressed textures. This puts the burden on the container
  60144. * generator to house the arcane code for determining these for current & future formats.
  60145. *
  60146. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60147. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60148. *
  60149. * Note: The result of this call is not taken into account when a texture is base64.
  60150. *
  60151. * @param formatsAvailable defines the list of those format families you have created
  60152. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60153. *
  60154. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60155. * @returns The extension selected.
  60156. */
  60157. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60158. }
  60159. }
  60160. declare module BABYLON {
  60161. /** @hidden */
  60162. export var rgbdEncodePixelShader: {
  60163. name: string;
  60164. shader: string;
  60165. };
  60166. }
  60167. declare module BABYLON {
  60168. /**
  60169. * Raw texture data and descriptor sufficient for WebGL texture upload
  60170. */
  60171. export interface EnvironmentTextureInfo {
  60172. /**
  60173. * Version of the environment map
  60174. */
  60175. version: number;
  60176. /**
  60177. * Width of image
  60178. */
  60179. width: number;
  60180. /**
  60181. * Irradiance information stored in the file.
  60182. */
  60183. irradiance: any;
  60184. /**
  60185. * Specular information stored in the file.
  60186. */
  60187. specular: any;
  60188. }
  60189. /**
  60190. * Defines One Image in the file. It requires only the position in the file
  60191. * as well as the length.
  60192. */
  60193. interface BufferImageData {
  60194. /**
  60195. * Length of the image data.
  60196. */
  60197. length: number;
  60198. /**
  60199. * Position of the data from the null terminator delimiting the end of the JSON.
  60200. */
  60201. position: number;
  60202. }
  60203. /**
  60204. * Defines the specular data enclosed in the file.
  60205. * This corresponds to the version 1 of the data.
  60206. */
  60207. export interface EnvironmentTextureSpecularInfoV1 {
  60208. /**
  60209. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60210. */
  60211. specularDataPosition?: number;
  60212. /**
  60213. * This contains all the images data needed to reconstruct the cubemap.
  60214. */
  60215. mipmaps: Array<BufferImageData>;
  60216. /**
  60217. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60218. */
  60219. lodGenerationScale: number;
  60220. }
  60221. /**
  60222. * Sets of helpers addressing the serialization and deserialization of environment texture
  60223. * stored in a BabylonJS env file.
  60224. * Those files are usually stored as .env files.
  60225. */
  60226. export class EnvironmentTextureTools {
  60227. /**
  60228. * Magic number identifying the env file.
  60229. */
  60230. private static _MagicBytes;
  60231. /**
  60232. * Gets the environment info from an env file.
  60233. * @param data The array buffer containing the .env bytes.
  60234. * @returns the environment file info (the json header) if successfully parsed.
  60235. */
  60236. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60237. /**
  60238. * Creates an environment texture from a loaded cube texture.
  60239. * @param texture defines the cube texture to convert in env file
  60240. * @return a promise containing the environment data if successful.
  60241. */
  60242. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60243. /**
  60244. * Creates a JSON representation of the spherical data.
  60245. * @param texture defines the texture containing the polynomials
  60246. * @return the JSON representation of the spherical info
  60247. */
  60248. private static _CreateEnvTextureIrradiance;
  60249. /**
  60250. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60251. * @param data the image data
  60252. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60253. * @return the views described by info providing access to the underlying buffer
  60254. */
  60255. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60256. /**
  60257. * Uploads the texture info contained in the env file to the GPU.
  60258. * @param texture defines the internal texture to upload to
  60259. * @param data defines the data to load
  60260. * @param info defines the texture info retrieved through the GetEnvInfo method
  60261. * @returns a promise
  60262. */
  60263. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60264. private static _OnImageReadyAsync;
  60265. /**
  60266. * Uploads the levels of image data to the GPU.
  60267. * @param texture defines the internal texture to upload to
  60268. * @param imageData defines the array buffer views of image data [mipmap][face]
  60269. * @returns a promise
  60270. */
  60271. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60272. /**
  60273. * Uploads spherical polynomials information to the texture.
  60274. * @param texture defines the texture we are trying to upload the information to
  60275. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60276. */
  60277. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60278. /** @hidden */
  60279. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60280. }
  60281. }
  60282. declare module BABYLON {
  60283. /**
  60284. * Container for accessors for natively-stored mesh data buffers.
  60285. */
  60286. class NativeDataBuffer extends DataBuffer {
  60287. /**
  60288. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60289. */
  60290. nativeIndexBuffer?: any;
  60291. /**
  60292. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60293. */
  60294. nativeVertexBuffer?: any;
  60295. }
  60296. /** @hidden */
  60297. class NativeTexture extends InternalTexture {
  60298. getInternalTexture(): InternalTexture;
  60299. getViewCount(): number;
  60300. }
  60301. /** @hidden */
  60302. export class NativeEngine extends Engine {
  60303. private readonly _native;
  60304. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60305. private readonly INVALID_HANDLE;
  60306. private _boundBuffersVertexArray;
  60307. private _currentDepthTest;
  60308. getHardwareScalingLevel(): number;
  60309. constructor();
  60310. dispose(): void;
  60311. /**
  60312. * Can be used to override the current requestAnimationFrame requester.
  60313. * @hidden
  60314. */
  60315. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60316. /**
  60317. * Override default engine behavior.
  60318. * @param color
  60319. * @param backBuffer
  60320. * @param depth
  60321. * @param stencil
  60322. */
  60323. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60324. /**
  60325. * Gets host document
  60326. * @returns the host document object
  60327. */
  60328. getHostDocument(): Nullable<Document>;
  60329. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60330. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60331. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60332. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60333. [key: string]: VertexBuffer;
  60334. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60335. bindBuffers(vertexBuffers: {
  60336. [key: string]: VertexBuffer;
  60337. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60338. recordVertexArrayObject(vertexBuffers: {
  60339. [key: string]: VertexBuffer;
  60340. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60341. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60342. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60344. /**
  60345. * Draw a list of indexed primitives
  60346. * @param fillMode defines the primitive to use
  60347. * @param indexStart defines the starting index
  60348. * @param indexCount defines the number of index to draw
  60349. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60350. */
  60351. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60352. /**
  60353. * Draw a list of unindexed primitives
  60354. * @param fillMode defines the primitive to use
  60355. * @param verticesStart defines the index of first vertex to draw
  60356. * @param verticesCount defines the count of vertices to draw
  60357. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60358. */
  60359. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60360. createPipelineContext(): IPipelineContext;
  60361. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60362. /** @hidden */
  60363. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60364. /** @hidden */
  60365. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60366. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60368. protected _setProgram(program: WebGLProgram): void;
  60369. _releaseEffect(effect: Effect): void;
  60370. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60371. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60372. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60373. bindSamplers(effect: Effect): void;
  60374. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60375. getRenderWidth(useScreen?: boolean): number;
  60376. getRenderHeight(useScreen?: boolean): number;
  60377. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60378. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60379. /**
  60380. * Set the z offset to apply to current rendering
  60381. * @param value defines the offset to apply
  60382. */
  60383. setZOffset(value: number): void;
  60384. /**
  60385. * Gets the current value of the zOffset
  60386. * @returns the current zOffset state
  60387. */
  60388. getZOffset(): number;
  60389. /**
  60390. * Enable or disable depth buffering
  60391. * @param enable defines the state to set
  60392. */
  60393. setDepthBuffer(enable: boolean): void;
  60394. /**
  60395. * Gets a boolean indicating if depth writing is enabled
  60396. * @returns the current depth writing state
  60397. */
  60398. getDepthWrite(): boolean;
  60399. setDepthFunctionToGreater(): void;
  60400. setDepthFunctionToGreaterOrEqual(): void;
  60401. setDepthFunctionToLess(): void;
  60402. setDepthFunctionToLessOrEqual(): void;
  60403. /**
  60404. * Enable or disable depth writing
  60405. * @param enable defines the state to set
  60406. */
  60407. setDepthWrite(enable: boolean): void;
  60408. /**
  60409. * Enable or disable color writing
  60410. * @param enable defines the state to set
  60411. */
  60412. setColorWrite(enable: boolean): void;
  60413. /**
  60414. * Gets a boolean indicating if color writing is enabled
  60415. * @returns the current color writing state
  60416. */
  60417. getColorWrite(): boolean;
  60418. /**
  60419. * Sets alpha constants used by some alpha blending modes
  60420. * @param r defines the red component
  60421. * @param g defines the green component
  60422. * @param b defines the blue component
  60423. * @param a defines the alpha component
  60424. */
  60425. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60426. /**
  60427. * Sets the current alpha mode
  60428. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60429. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60430. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60431. */
  60432. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60433. /**
  60434. * Gets the current alpha mode
  60435. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60436. * @returns the current alpha mode
  60437. */
  60438. getAlphaMode(): number;
  60439. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60440. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60441. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60442. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60443. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60444. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60445. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60446. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60447. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60448. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60449. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60450. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60451. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60452. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60453. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60454. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60455. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60456. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60457. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60458. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60459. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60460. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60461. wipeCaches(bruteForce?: boolean): void;
  60462. protected _createTexture(): WebGLTexture;
  60463. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60464. /**
  60465. * Update the content of a dynamic texture
  60466. * @param texture defines the texture to update
  60467. * @param canvas defines the canvas containing the source
  60468. * @param invertY defines if data must be stored with Y axis inverted
  60469. * @param premulAlpha defines if alpha is stored as premultiplied
  60470. * @param format defines the format of the data
  60471. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60472. */
  60473. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60474. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60475. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60476. /**
  60477. * Usually called from Texture.ts.
  60478. * Passed information to create a WebGLTexture
  60479. * @param url defines a value which contains one of the following:
  60480. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60481. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60482. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60483. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60484. * @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)
  60485. * @param scene needed for loading to the correct scene
  60486. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60487. * @param onLoad optional callback to be called upon successful completion
  60488. * @param onError optional callback to be called upon failure
  60489. * @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
  60490. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60491. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60492. * @param forcedExtension defines the extension to use to pick the right loader
  60493. * @param mimeType defines an optional mime type
  60494. * @param loaderOptions options to be passed to the loader
  60495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60496. */
  60497. 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;
  60498. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60499. _releaseFramebufferObjects(texture: InternalTexture): void;
  60500. /**
  60501. * Creates a cube texture
  60502. * @param rootUrl defines the url where the files to load is located
  60503. * @param scene defines the current scene
  60504. * @param files defines the list of files to load (1 per face)
  60505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60506. * @param onLoad defines an optional callback raised when the texture is loaded
  60507. * @param onError defines an optional callback raised if there is an issue to load the texture
  60508. * @param format defines the format of the data
  60509. * @param forcedExtension defines the extension to use to pick the right loader
  60510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60513. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60514. * @returns the cube texture as an InternalTexture
  60515. */
  60516. 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;
  60517. createRenderTargetTexture(size: number | {
  60518. width: number;
  60519. height: number;
  60520. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60522. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60523. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60524. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60525. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60526. /**
  60527. * Updates a dynamic vertex buffer.
  60528. * @param vertexBuffer the vertex buffer to update
  60529. * @param data the data used to update the vertex buffer
  60530. * @param byteOffset the byte offset of the data (optional)
  60531. * @param byteLength the byte length of the data (optional)
  60532. */
  60533. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60534. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60535. private _updateAnisotropicLevel;
  60536. private _getAddressMode;
  60537. /** @hidden */
  60538. _bindTexture(channel: number, texture: InternalTexture): void;
  60539. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60540. releaseEffects(): void;
  60541. /** @hidden */
  60542. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60543. /** @hidden */
  60544. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60545. /** @hidden */
  60546. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60547. /** @hidden */
  60548. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60549. private _getNativeSamplingMode;
  60550. private _getNativeTextureFormat;
  60551. private _getNativeAlphaMode;
  60552. private _getNativeAttribType;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. /**
  60557. * Helper class to create the best engine depending on the current hardware
  60558. */
  60559. export class EngineFactory {
  60560. /**
  60561. * Creates an engine based on the capabilities of the underlying hardware
  60562. * @param canvas Defines the canvas to use to display the result
  60563. * @param options Defines the options passed to the engine to create the context dependencies
  60564. * @returns a promise that resolves with the created engine
  60565. */
  60566. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60567. }
  60568. }
  60569. declare module BABYLON {
  60570. /**
  60571. * Gather the list of clipboard event types as constants.
  60572. */
  60573. export class ClipboardEventTypes {
  60574. /**
  60575. * The clipboard event is fired when a copy command is active (pressed).
  60576. */
  60577. static readonly COPY: number;
  60578. /**
  60579. * The clipboard event is fired when a cut command is active (pressed).
  60580. */
  60581. static readonly CUT: number;
  60582. /**
  60583. * The clipboard event is fired when a paste command is active (pressed).
  60584. */
  60585. static readonly PASTE: number;
  60586. }
  60587. /**
  60588. * This class is used to store clipboard related info for the onClipboardObservable event.
  60589. */
  60590. export class ClipboardInfo {
  60591. /**
  60592. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60593. */
  60594. type: number;
  60595. /**
  60596. * Defines the related dom event
  60597. */
  60598. event: ClipboardEvent;
  60599. /**
  60600. *Creates an instance of ClipboardInfo.
  60601. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60602. * @param event Defines the related dom event
  60603. */
  60604. constructor(
  60605. /**
  60606. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60607. */
  60608. type: number,
  60609. /**
  60610. * Defines the related dom event
  60611. */
  60612. event: ClipboardEvent);
  60613. /**
  60614. * Get the clipboard event's type from the keycode.
  60615. * @param keyCode Defines the keyCode for the current keyboard event.
  60616. * @return {number}
  60617. */
  60618. static GetTypeFromCharacter(keyCode: number): number;
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /**
  60623. * Google Daydream controller
  60624. */
  60625. export class DaydreamController extends WebVRController {
  60626. /**
  60627. * Base Url for the controller model.
  60628. */
  60629. static MODEL_BASE_URL: string;
  60630. /**
  60631. * File name for the controller model.
  60632. */
  60633. static MODEL_FILENAME: string;
  60634. /**
  60635. * Gamepad Id prefix used to identify Daydream Controller.
  60636. */
  60637. static readonly GAMEPAD_ID_PREFIX: string;
  60638. /**
  60639. * Creates a new DaydreamController from a gamepad
  60640. * @param vrGamepad the gamepad that the controller should be created from
  60641. */
  60642. constructor(vrGamepad: any);
  60643. /**
  60644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60645. * @param scene scene in which to add meshes
  60646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60647. */
  60648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60649. /**
  60650. * Called once for each button that changed state since the last frame
  60651. * @param buttonIdx Which button index changed
  60652. * @param state New state of the button
  60653. * @param changes Which properties on the state changed since last frame
  60654. */
  60655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60656. }
  60657. }
  60658. declare module BABYLON {
  60659. /**
  60660. * Gear VR Controller
  60661. */
  60662. export class GearVRController extends WebVRController {
  60663. /**
  60664. * Base Url for the controller model.
  60665. */
  60666. static MODEL_BASE_URL: string;
  60667. /**
  60668. * File name for the controller model.
  60669. */
  60670. static MODEL_FILENAME: string;
  60671. /**
  60672. * Gamepad Id prefix used to identify this controller.
  60673. */
  60674. static readonly GAMEPAD_ID_PREFIX: string;
  60675. private readonly _buttonIndexToObservableNameMap;
  60676. /**
  60677. * Creates a new GearVRController from a gamepad
  60678. * @param vrGamepad the gamepad that the controller should be created from
  60679. */
  60680. constructor(vrGamepad: any);
  60681. /**
  60682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60683. * @param scene scene in which to add meshes
  60684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60685. */
  60686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60687. /**
  60688. * Called once for each button that changed state since the last frame
  60689. * @param buttonIdx Which button index changed
  60690. * @param state New state of the button
  60691. * @param changes Which properties on the state changed since last frame
  60692. */
  60693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60694. }
  60695. }
  60696. declare module BABYLON {
  60697. /**
  60698. * Generic Controller
  60699. */
  60700. export class GenericController extends WebVRController {
  60701. /**
  60702. * Base Url for the controller model.
  60703. */
  60704. static readonly MODEL_BASE_URL: string;
  60705. /**
  60706. * File name for the controller model.
  60707. */
  60708. static readonly MODEL_FILENAME: string;
  60709. /**
  60710. * Creates a new GenericController from a gamepad
  60711. * @param vrGamepad the gamepad that the controller should be created from
  60712. */
  60713. constructor(vrGamepad: any);
  60714. /**
  60715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60716. * @param scene scene in which to add meshes
  60717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60718. */
  60719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60720. /**
  60721. * Called once for each button that changed state since the last frame
  60722. * @param buttonIdx Which button index changed
  60723. * @param state New state of the button
  60724. * @param changes Which properties on the state changed since last frame
  60725. */
  60726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60727. }
  60728. }
  60729. declare module BABYLON {
  60730. /**
  60731. * Oculus Touch Controller
  60732. */
  60733. export class OculusTouchController extends WebVRController {
  60734. /**
  60735. * Base Url for the controller model.
  60736. */
  60737. static MODEL_BASE_URL: string;
  60738. /**
  60739. * File name for the left controller model.
  60740. */
  60741. static MODEL_LEFT_FILENAME: string;
  60742. /**
  60743. * File name for the right controller model.
  60744. */
  60745. static MODEL_RIGHT_FILENAME: string;
  60746. /**
  60747. * Base Url for the Quest controller model.
  60748. */
  60749. static QUEST_MODEL_BASE_URL: string;
  60750. /**
  60751. * @hidden
  60752. * If the controllers are running on a device that needs the updated Quest controller models
  60753. */
  60754. static _IsQuest: boolean;
  60755. /**
  60756. * Fired when the secondary trigger on this controller is modified
  60757. */
  60758. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60759. /**
  60760. * Fired when the thumb rest on this controller is modified
  60761. */
  60762. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60763. /**
  60764. * Creates a new OculusTouchController from a gamepad
  60765. * @param vrGamepad the gamepad that the controller should be created from
  60766. */
  60767. constructor(vrGamepad: any);
  60768. /**
  60769. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60770. * @param scene scene in which to add meshes
  60771. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60772. */
  60773. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60774. /**
  60775. * Fired when the A button on this controller is modified
  60776. */
  60777. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60778. /**
  60779. * Fired when the B button on this controller is modified
  60780. */
  60781. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60782. /**
  60783. * Fired when the X button on this controller is modified
  60784. */
  60785. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60786. /**
  60787. * Fired when the Y button on this controller is modified
  60788. */
  60789. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60790. /**
  60791. * Called once for each button that changed state since the last frame
  60792. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60793. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60794. * 2) secondary trigger (same)
  60795. * 3) A (right) X (left), touch, pressed = value
  60796. * 4) B / Y
  60797. * 5) thumb rest
  60798. * @param buttonIdx Which button index changed
  60799. * @param state New state of the button
  60800. * @param changes Which properties on the state changed since last frame
  60801. */
  60802. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * Vive Controller
  60808. */
  60809. export class ViveController extends WebVRController {
  60810. /**
  60811. * Base Url for the controller model.
  60812. */
  60813. static MODEL_BASE_URL: string;
  60814. /**
  60815. * File name for the controller model.
  60816. */
  60817. static MODEL_FILENAME: string;
  60818. /**
  60819. * Creates a new ViveController from a gamepad
  60820. * @param vrGamepad the gamepad that the controller should be created from
  60821. */
  60822. constructor(vrGamepad: any);
  60823. /**
  60824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60825. * @param scene scene in which to add meshes
  60826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60827. */
  60828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60829. /**
  60830. * Fired when the left button on this controller is modified
  60831. */
  60832. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60833. /**
  60834. * Fired when the right button on this controller is modified
  60835. */
  60836. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60837. /**
  60838. * Fired when the menu button on this controller is modified
  60839. */
  60840. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60841. /**
  60842. * Called once for each button that changed state since the last frame
  60843. * Vive mapping:
  60844. * 0: touchpad
  60845. * 1: trigger
  60846. * 2: left AND right buttons
  60847. * 3: menu button
  60848. * @param buttonIdx Which button index changed
  60849. * @param state New state of the button
  60850. * @param changes Which properties on the state changed since last frame
  60851. */
  60852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60853. }
  60854. }
  60855. declare module BABYLON {
  60856. /**
  60857. * Defines the WindowsMotionController object that the state of the windows motion controller
  60858. */
  60859. export class WindowsMotionController extends WebVRController {
  60860. /**
  60861. * The base url used to load the left and right controller models
  60862. */
  60863. static MODEL_BASE_URL: string;
  60864. /**
  60865. * The name of the left controller model file
  60866. */
  60867. static MODEL_LEFT_FILENAME: string;
  60868. /**
  60869. * The name of the right controller model file
  60870. */
  60871. static MODEL_RIGHT_FILENAME: string;
  60872. /**
  60873. * The controller name prefix for this controller type
  60874. */
  60875. static readonly GAMEPAD_ID_PREFIX: string;
  60876. /**
  60877. * The controller id pattern for this controller type
  60878. */
  60879. private static readonly GAMEPAD_ID_PATTERN;
  60880. private _loadedMeshInfo;
  60881. protected readonly _mapping: {
  60882. buttons: string[];
  60883. buttonMeshNames: {
  60884. trigger: string;
  60885. menu: string;
  60886. grip: string;
  60887. thumbstick: string;
  60888. trackpad: string;
  60889. };
  60890. buttonObservableNames: {
  60891. trigger: string;
  60892. menu: string;
  60893. grip: string;
  60894. thumbstick: string;
  60895. trackpad: string;
  60896. };
  60897. axisMeshNames: string[];
  60898. pointingPoseMeshName: string;
  60899. };
  60900. /**
  60901. * Fired when the trackpad on this controller is clicked
  60902. */
  60903. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60904. /**
  60905. * Fired when the trackpad on this controller is modified
  60906. */
  60907. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60908. /**
  60909. * The current x and y values of this controller's trackpad
  60910. */
  60911. trackpad: StickValues;
  60912. /**
  60913. * Creates a new WindowsMotionController from a gamepad
  60914. * @param vrGamepad the gamepad that the controller should be created from
  60915. */
  60916. constructor(vrGamepad: any);
  60917. /**
  60918. * Fired when the trigger on this controller is modified
  60919. */
  60920. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60921. /**
  60922. * Fired when the menu button on this controller is modified
  60923. */
  60924. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60925. /**
  60926. * Fired when the grip button on this controller is modified
  60927. */
  60928. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60929. /**
  60930. * Fired when the thumbstick button on this controller is modified
  60931. */
  60932. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60933. /**
  60934. * Fired when the touchpad button on this controller is modified
  60935. */
  60936. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60937. /**
  60938. * Fired when the touchpad values on this controller are modified
  60939. */
  60940. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60941. protected _updateTrackpad(): void;
  60942. /**
  60943. * Called once per frame by the engine.
  60944. */
  60945. update(): void;
  60946. /**
  60947. * Called once for each button that changed state since the last frame
  60948. * @param buttonIdx Which button index changed
  60949. * @param state New state of the button
  60950. * @param changes Which properties on the state changed since last frame
  60951. */
  60952. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60953. /**
  60954. * Moves the buttons on the controller mesh based on their current state
  60955. * @param buttonName the name of the button to move
  60956. * @param buttonValue the value of the button which determines the buttons new position
  60957. */
  60958. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60959. /**
  60960. * Moves the axis on the controller mesh based on its current state
  60961. * @param axis the index of the axis
  60962. * @param axisValue the value of the axis which determines the meshes new position
  60963. * @hidden
  60964. */
  60965. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60966. /**
  60967. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60968. * @param scene scene in which to add meshes
  60969. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60970. */
  60971. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60972. /**
  60973. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60974. * can be transformed by button presses and axes values, based on this._mapping.
  60975. *
  60976. * @param scene scene in which the meshes exist
  60977. * @param meshes list of meshes that make up the controller model to process
  60978. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60979. */
  60980. private processModel;
  60981. private createMeshInfo;
  60982. /**
  60983. * Gets the ray of the controller in the direction the controller is pointing
  60984. * @param length the length the resulting ray should be
  60985. * @returns a ray in the direction the controller is pointing
  60986. */
  60987. getForwardRay(length?: number): Ray;
  60988. /**
  60989. * Disposes of the controller
  60990. */
  60991. dispose(): void;
  60992. }
  60993. /**
  60994. * This class represents a new windows motion controller in XR.
  60995. */
  60996. export class XRWindowsMotionController extends WindowsMotionController {
  60997. /**
  60998. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60999. */
  61000. protected readonly _mapping: {
  61001. buttons: string[];
  61002. buttonMeshNames: {
  61003. trigger: string;
  61004. menu: string;
  61005. grip: string;
  61006. thumbstick: string;
  61007. trackpad: string;
  61008. };
  61009. buttonObservableNames: {
  61010. trigger: string;
  61011. menu: string;
  61012. grip: string;
  61013. thumbstick: string;
  61014. trackpad: string;
  61015. };
  61016. axisMeshNames: string[];
  61017. pointingPoseMeshName: string;
  61018. };
  61019. /**
  61020. * Construct a new XR-Based windows motion controller
  61021. *
  61022. * @param gamepadInfo the gamepad object from the browser
  61023. */
  61024. constructor(gamepadInfo: any);
  61025. /**
  61026. * holds the thumbstick values (X,Y)
  61027. */
  61028. thumbstickValues: StickValues;
  61029. /**
  61030. * Fired when the thumbstick on this controller is clicked
  61031. */
  61032. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61033. /**
  61034. * Fired when the thumbstick on this controller is modified
  61035. */
  61036. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61037. /**
  61038. * Fired when the touchpad button on this controller is modified
  61039. */
  61040. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61041. /**
  61042. * Fired when the touchpad values on this controller are modified
  61043. */
  61044. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61045. /**
  61046. * Fired when the thumbstick button on this controller is modified
  61047. * here to prevent breaking changes
  61048. */
  61049. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61050. /**
  61051. * updating the thumbstick(!) and not the trackpad.
  61052. * This is named this way due to the difference between WebVR and XR and to avoid
  61053. * changing the parent class.
  61054. */
  61055. protected _updateTrackpad(): void;
  61056. /**
  61057. * Disposes the class with joy
  61058. */
  61059. dispose(): void;
  61060. }
  61061. }
  61062. declare module BABYLON {
  61063. /**
  61064. * A directional light is defined by a direction (what a surprise!).
  61065. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  61066. * 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.
  61067. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61068. */
  61069. export class DirectionalLight extends ShadowLight {
  61070. private _shadowFrustumSize;
  61071. /**
  61072. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  61073. */
  61074. get shadowFrustumSize(): number;
  61075. /**
  61076. * Specifies a fix frustum size for the shadow generation.
  61077. */
  61078. set shadowFrustumSize(value: number);
  61079. private _shadowOrthoScale;
  61080. /**
  61081. * Gets the shadow projection scale against the optimal computed one.
  61082. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61083. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61084. */
  61085. get shadowOrthoScale(): number;
  61086. /**
  61087. * Sets the shadow projection scale against the optimal computed one.
  61088. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61089. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61090. */
  61091. set shadowOrthoScale(value: number);
  61092. /**
  61093. * Automatically compute the projection matrix to best fit (including all the casters)
  61094. * on each frame.
  61095. */
  61096. autoUpdateExtends: boolean;
  61097. /**
  61098. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61099. * on each frame. autoUpdateExtends must be set to true for this to work
  61100. */
  61101. autoCalcShadowZBounds: boolean;
  61102. private _orthoLeft;
  61103. private _orthoRight;
  61104. private _orthoTop;
  61105. private _orthoBottom;
  61106. /**
  61107. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61108. * The directional light is emitted from everywhere in the given direction.
  61109. * It can cast shadows.
  61110. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61111. * @param name The friendly name of the light
  61112. * @param direction The direction of the light
  61113. * @param scene The scene the light belongs to
  61114. */
  61115. constructor(name: string, direction: Vector3, scene: Scene);
  61116. /**
  61117. * Returns the string "DirectionalLight".
  61118. * @return The class name
  61119. */
  61120. getClassName(): string;
  61121. /**
  61122. * Returns the integer 1.
  61123. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61124. */
  61125. getTypeID(): number;
  61126. /**
  61127. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61128. * Returns the DirectionalLight Shadow projection matrix.
  61129. */
  61130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61131. /**
  61132. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61133. * Returns the DirectionalLight Shadow projection matrix.
  61134. */
  61135. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61136. /**
  61137. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61138. * Returns the DirectionalLight Shadow projection matrix.
  61139. */
  61140. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61141. protected _buildUniformLayout(): void;
  61142. /**
  61143. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61144. * @param effect The effect to update
  61145. * @param lightIndex The index of the light in the effect to update
  61146. * @returns The directional light
  61147. */
  61148. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61149. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61150. /**
  61151. * Gets the minZ used for shadow according to both the scene and the light.
  61152. *
  61153. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61154. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61155. * @param activeCamera The camera we are returning the min for
  61156. * @returns the depth min z
  61157. */
  61158. getDepthMinZ(activeCamera: Camera): number;
  61159. /**
  61160. * Gets the maxZ used for shadow according to both the scene and the light.
  61161. *
  61162. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61163. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61164. * @param activeCamera The camera we are returning the max for
  61165. * @returns the depth max z
  61166. */
  61167. getDepthMaxZ(activeCamera: Camera): number;
  61168. /**
  61169. * Prepares the list of defines specific to the light type.
  61170. * @param defines the list of defines
  61171. * @param lightIndex defines the index of the light for the effect
  61172. */
  61173. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61174. }
  61175. }
  61176. declare module BABYLON {
  61177. /**
  61178. * Class containing static functions to help procedurally build meshes
  61179. */
  61180. export class HemisphereBuilder {
  61181. /**
  61182. * Creates a hemisphere mesh
  61183. * @param name defines the name of the mesh
  61184. * @param options defines the options used to create the mesh
  61185. * @param scene defines the hosting scene
  61186. * @returns the hemisphere mesh
  61187. */
  61188. static CreateHemisphere(name: string, options: {
  61189. segments?: number;
  61190. diameter?: number;
  61191. sideOrientation?: number;
  61192. }, scene: any): Mesh;
  61193. }
  61194. }
  61195. declare module BABYLON {
  61196. /**
  61197. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61198. * These values define a cone of light starting from the position, emitting toward the direction.
  61199. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61200. * and the exponent defines the speed of the decay of the light with distance (reach).
  61201. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61202. */
  61203. export class SpotLight extends ShadowLight {
  61204. private _angle;
  61205. private _innerAngle;
  61206. private _cosHalfAngle;
  61207. private _lightAngleScale;
  61208. private _lightAngleOffset;
  61209. /**
  61210. * Gets the cone angle of the spot light in Radians.
  61211. */
  61212. get angle(): number;
  61213. /**
  61214. * Sets the cone angle of the spot light in Radians.
  61215. */
  61216. set angle(value: number);
  61217. /**
  61218. * Only used in gltf falloff mode, this defines the angle where
  61219. * the directional falloff will start before cutting at angle which could be seen
  61220. * as outer angle.
  61221. */
  61222. get innerAngle(): number;
  61223. /**
  61224. * Only used in gltf falloff mode, this defines the angle where
  61225. * the directional falloff will start before cutting at angle which could be seen
  61226. * as outer angle.
  61227. */
  61228. set innerAngle(value: number);
  61229. private _shadowAngleScale;
  61230. /**
  61231. * Allows scaling the angle of the light for shadow generation only.
  61232. */
  61233. get shadowAngleScale(): number;
  61234. /**
  61235. * Allows scaling the angle of the light for shadow generation only.
  61236. */
  61237. set shadowAngleScale(value: number);
  61238. /**
  61239. * The light decay speed with the distance from the emission spot.
  61240. */
  61241. exponent: number;
  61242. private _projectionTextureMatrix;
  61243. /**
  61244. * Allows reading the projection texture
  61245. */
  61246. get projectionTextureMatrix(): Matrix;
  61247. protected _projectionTextureLightNear: number;
  61248. /**
  61249. * Gets the near clip of the Spotlight for texture projection.
  61250. */
  61251. get projectionTextureLightNear(): number;
  61252. /**
  61253. * Sets the near clip of the Spotlight for texture projection.
  61254. */
  61255. set projectionTextureLightNear(value: number);
  61256. protected _projectionTextureLightFar: number;
  61257. /**
  61258. * Gets the far clip of the Spotlight for texture projection.
  61259. */
  61260. get projectionTextureLightFar(): number;
  61261. /**
  61262. * Sets the far clip of the Spotlight for texture projection.
  61263. */
  61264. set projectionTextureLightFar(value: number);
  61265. protected _projectionTextureUpDirection: Vector3;
  61266. /**
  61267. * Gets the Up vector of the Spotlight for texture projection.
  61268. */
  61269. get projectionTextureUpDirection(): Vector3;
  61270. /**
  61271. * Sets the Up vector of the Spotlight for texture projection.
  61272. */
  61273. set projectionTextureUpDirection(value: Vector3);
  61274. private _projectionTexture;
  61275. /**
  61276. * Gets the projection texture of the light.
  61277. */
  61278. get projectionTexture(): Nullable<BaseTexture>;
  61279. /**
  61280. * Sets the projection texture of the light.
  61281. */
  61282. set projectionTexture(value: Nullable<BaseTexture>);
  61283. private static _IsProceduralTexture;
  61284. private static _IsTexture;
  61285. private _projectionTextureViewLightDirty;
  61286. private _projectionTextureProjectionLightDirty;
  61287. private _projectionTextureDirty;
  61288. private _projectionTextureViewTargetVector;
  61289. private _projectionTextureViewLightMatrix;
  61290. private _projectionTextureProjectionLightMatrix;
  61291. private _projectionTextureScalingMatrix;
  61292. /**
  61293. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61294. * It can cast shadows.
  61295. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61296. * @param name The light friendly name
  61297. * @param position The position of the spot light in the scene
  61298. * @param direction The direction of the light in the scene
  61299. * @param angle The cone angle of the light in Radians
  61300. * @param exponent The light decay speed with the distance from the emission spot
  61301. * @param scene The scene the lights belongs to
  61302. */
  61303. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61304. /**
  61305. * Returns the string "SpotLight".
  61306. * @returns the class name
  61307. */
  61308. getClassName(): string;
  61309. /**
  61310. * Returns the integer 2.
  61311. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61312. */
  61313. getTypeID(): number;
  61314. /**
  61315. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61316. */
  61317. protected _setDirection(value: Vector3): void;
  61318. /**
  61319. * Overrides the position setter to recompute the projection texture view light Matrix.
  61320. */
  61321. protected _setPosition(value: Vector3): void;
  61322. /**
  61323. * 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.
  61324. * Returns the SpotLight.
  61325. */
  61326. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61327. protected _computeProjectionTextureViewLightMatrix(): void;
  61328. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61329. /**
  61330. * Main function for light texture projection matrix computing.
  61331. */
  61332. protected _computeProjectionTextureMatrix(): void;
  61333. protected _buildUniformLayout(): void;
  61334. private _computeAngleValues;
  61335. /**
  61336. * Sets the passed Effect "effect" with the Light textures.
  61337. * @param effect The effect to update
  61338. * @param lightIndex The index of the light in the effect to update
  61339. * @returns The light
  61340. */
  61341. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61342. /**
  61343. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61344. * @param effect The effect to update
  61345. * @param lightIndex The index of the light in the effect to update
  61346. * @returns The spot light
  61347. */
  61348. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61349. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61350. /**
  61351. * Disposes the light and the associated resources.
  61352. */
  61353. dispose(): void;
  61354. /**
  61355. * Prepares the list of defines specific to the light type.
  61356. * @param defines the list of defines
  61357. * @param lightIndex defines the index of the light for the effect
  61358. */
  61359. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61360. }
  61361. }
  61362. declare module BABYLON {
  61363. /**
  61364. * Gizmo that enables viewing a light
  61365. */
  61366. export class LightGizmo extends Gizmo {
  61367. private _lightMesh;
  61368. private _material;
  61369. private _cachedPosition;
  61370. private _cachedForward;
  61371. private _attachedMeshParent;
  61372. private _pointerObserver;
  61373. /**
  61374. * Event that fires each time the gizmo is clicked
  61375. */
  61376. onClickedObservable: Observable<Light>;
  61377. /**
  61378. * Creates a LightGizmo
  61379. * @param gizmoLayer The utility layer the gizmo will be added to
  61380. */
  61381. constructor(gizmoLayer?: UtilityLayerRenderer);
  61382. private _light;
  61383. /**
  61384. * The light that the gizmo is attached to
  61385. */
  61386. set light(light: Nullable<Light>);
  61387. get light(): Nullable<Light>;
  61388. /**
  61389. * Gets the material used to render the light gizmo
  61390. */
  61391. get material(): StandardMaterial;
  61392. /**
  61393. * @hidden
  61394. * Updates the gizmo to match the attached mesh's position/rotation
  61395. */
  61396. protected _update(): void;
  61397. private static _Scale;
  61398. /**
  61399. * Creates the lines for a light mesh
  61400. */
  61401. private static _CreateLightLines;
  61402. /**
  61403. * Disposes of the light gizmo
  61404. */
  61405. dispose(): void;
  61406. private static _CreateHemisphericLightMesh;
  61407. private static _CreatePointLightMesh;
  61408. private static _CreateSpotLightMesh;
  61409. private static _CreateDirectionalLightMesh;
  61410. }
  61411. }
  61412. declare module BABYLON {
  61413. /**
  61414. * Gizmo that enables viewing a camera
  61415. */
  61416. export class CameraGizmo extends Gizmo {
  61417. private _cameraMesh;
  61418. private _cameraLinesMesh;
  61419. private _material;
  61420. private _pointerObserver;
  61421. /**
  61422. * Event that fires each time the gizmo is clicked
  61423. */
  61424. onClickedObservable: Observable<Camera>;
  61425. /**
  61426. * Creates a CameraGizmo
  61427. * @param gizmoLayer The utility layer the gizmo will be added to
  61428. */
  61429. constructor(gizmoLayer?: UtilityLayerRenderer);
  61430. private _camera;
  61431. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61432. get displayFrustum(): boolean;
  61433. set displayFrustum(value: boolean);
  61434. /**
  61435. * The camera that the gizmo is attached to
  61436. */
  61437. set camera(camera: Nullable<Camera>);
  61438. get camera(): Nullable<Camera>;
  61439. /**
  61440. * Gets the material used to render the camera gizmo
  61441. */
  61442. get material(): StandardMaterial;
  61443. /**
  61444. * @hidden
  61445. * Updates the gizmo to match the attached mesh's position/rotation
  61446. */
  61447. protected _update(): void;
  61448. private static _Scale;
  61449. private _invProjection;
  61450. /**
  61451. * Disposes of the camera gizmo
  61452. */
  61453. dispose(): void;
  61454. private static _CreateCameraMesh;
  61455. private static _CreateCameraFrustum;
  61456. }
  61457. }
  61458. declare module BABYLON {
  61459. /** @hidden */
  61460. export var backgroundFragmentDeclaration: {
  61461. name: string;
  61462. shader: string;
  61463. };
  61464. }
  61465. declare module BABYLON {
  61466. /** @hidden */
  61467. export var backgroundUboDeclaration: {
  61468. name: string;
  61469. shader: string;
  61470. };
  61471. }
  61472. declare module BABYLON {
  61473. /** @hidden */
  61474. export var backgroundPixelShader: {
  61475. name: string;
  61476. shader: string;
  61477. };
  61478. }
  61479. declare module BABYLON {
  61480. /** @hidden */
  61481. export var backgroundVertexDeclaration: {
  61482. name: string;
  61483. shader: string;
  61484. };
  61485. }
  61486. declare module BABYLON {
  61487. /** @hidden */
  61488. export var backgroundVertexShader: {
  61489. name: string;
  61490. shader: string;
  61491. };
  61492. }
  61493. declare module BABYLON {
  61494. /**
  61495. * Background material used to create an efficient environment around your scene.
  61496. */
  61497. export class BackgroundMaterial extends PushMaterial {
  61498. /**
  61499. * Standard reflectance value at parallel view angle.
  61500. */
  61501. static StandardReflectance0: number;
  61502. /**
  61503. * Standard reflectance value at grazing angle.
  61504. */
  61505. static StandardReflectance90: number;
  61506. protected _primaryColor: Color3;
  61507. /**
  61508. * Key light Color (multiply against the environment texture)
  61509. */
  61510. primaryColor: Color3;
  61511. protected __perceptualColor: Nullable<Color3>;
  61512. /**
  61513. * Experimental Internal Use Only.
  61514. *
  61515. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61516. * This acts as a helper to set the primary color to a more "human friendly" value.
  61517. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61518. * output color as close as possible from the chosen value.
  61519. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61520. * part of lighting setup.)
  61521. */
  61522. get _perceptualColor(): Nullable<Color3>;
  61523. set _perceptualColor(value: Nullable<Color3>);
  61524. protected _primaryColorShadowLevel: float;
  61525. /**
  61526. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61527. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61528. */
  61529. get primaryColorShadowLevel(): float;
  61530. set primaryColorShadowLevel(value: float);
  61531. protected _primaryColorHighlightLevel: float;
  61532. /**
  61533. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61534. * The primary color is used at the level chosen to define what the white area would look.
  61535. */
  61536. get primaryColorHighlightLevel(): float;
  61537. set primaryColorHighlightLevel(value: float);
  61538. protected _reflectionTexture: Nullable<BaseTexture>;
  61539. /**
  61540. * Reflection Texture used in the material.
  61541. * Should be author in a specific way for the best result (refer to the documentation).
  61542. */
  61543. reflectionTexture: Nullable<BaseTexture>;
  61544. protected _reflectionBlur: float;
  61545. /**
  61546. * Reflection Texture level of blur.
  61547. *
  61548. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61549. * texture twice.
  61550. */
  61551. reflectionBlur: float;
  61552. protected _diffuseTexture: Nullable<BaseTexture>;
  61553. /**
  61554. * Diffuse Texture used in the material.
  61555. * Should be author in a specific way for the best result (refer to the documentation).
  61556. */
  61557. diffuseTexture: Nullable<BaseTexture>;
  61558. protected _shadowLights: Nullable<IShadowLight[]>;
  61559. /**
  61560. * Specify the list of lights casting shadow on the material.
  61561. * All scene shadow lights will be included if null.
  61562. */
  61563. shadowLights: Nullable<IShadowLight[]>;
  61564. protected _shadowLevel: float;
  61565. /**
  61566. * Helps adjusting the shadow to a softer level if required.
  61567. * 0 means black shadows and 1 means no shadows.
  61568. */
  61569. shadowLevel: float;
  61570. protected _sceneCenter: Vector3;
  61571. /**
  61572. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61573. * It is usually zero but might be interesting to modify according to your setup.
  61574. */
  61575. sceneCenter: Vector3;
  61576. protected _opacityFresnel: boolean;
  61577. /**
  61578. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61579. * This helps ensuring a nice transition when the camera goes under the ground.
  61580. */
  61581. opacityFresnel: boolean;
  61582. protected _reflectionFresnel: boolean;
  61583. /**
  61584. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61585. * This helps adding a mirror texture on the ground.
  61586. */
  61587. reflectionFresnel: boolean;
  61588. protected _reflectionFalloffDistance: number;
  61589. /**
  61590. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61591. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61592. */
  61593. reflectionFalloffDistance: number;
  61594. protected _reflectionAmount: number;
  61595. /**
  61596. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61597. */
  61598. reflectionAmount: number;
  61599. protected _reflectionReflectance0: number;
  61600. /**
  61601. * This specifies the weight of the reflection at grazing angle.
  61602. */
  61603. reflectionReflectance0: number;
  61604. protected _reflectionReflectance90: number;
  61605. /**
  61606. * This specifies the weight of the reflection at a perpendicular point of view.
  61607. */
  61608. reflectionReflectance90: number;
  61609. /**
  61610. * Sets the reflection reflectance fresnel values according to the default standard
  61611. * empirically know to work well :-)
  61612. */
  61613. set reflectionStandardFresnelWeight(value: number);
  61614. protected _useRGBColor: boolean;
  61615. /**
  61616. * Helps to directly use the maps channels instead of their level.
  61617. */
  61618. useRGBColor: boolean;
  61619. protected _enableNoise: boolean;
  61620. /**
  61621. * This helps reducing the banding effect that could occur on the background.
  61622. */
  61623. enableNoise: boolean;
  61624. /**
  61625. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61626. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61627. * Recommended to be keep at 1.0 except for special cases.
  61628. */
  61629. get fovMultiplier(): number;
  61630. set fovMultiplier(value: number);
  61631. private _fovMultiplier;
  61632. /**
  61633. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61634. */
  61635. useEquirectangularFOV: boolean;
  61636. private _maxSimultaneousLights;
  61637. /**
  61638. * Number of Simultaneous lights allowed on the material.
  61639. */
  61640. maxSimultaneousLights: int;
  61641. private _shadowOnly;
  61642. /**
  61643. * Make the material only render shadows
  61644. */
  61645. shadowOnly: boolean;
  61646. /**
  61647. * Default configuration related to image processing available in the Background Material.
  61648. */
  61649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61650. /**
  61651. * Keep track of the image processing observer to allow dispose and replace.
  61652. */
  61653. private _imageProcessingObserver;
  61654. /**
  61655. * Attaches a new image processing configuration to the PBR Material.
  61656. * @param configuration (if null the scene configuration will be use)
  61657. */
  61658. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61659. /**
  61660. * Gets the image processing configuration used either in this material.
  61661. */
  61662. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61663. /**
  61664. * Sets the Default image processing configuration used either in the this material.
  61665. *
  61666. * If sets to null, the scene one is in use.
  61667. */
  61668. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61669. /**
  61670. * Gets whether the color curves effect is enabled.
  61671. */
  61672. get cameraColorCurvesEnabled(): boolean;
  61673. /**
  61674. * Sets whether the color curves effect is enabled.
  61675. */
  61676. set cameraColorCurvesEnabled(value: boolean);
  61677. /**
  61678. * Gets whether the color grading effect is enabled.
  61679. */
  61680. get cameraColorGradingEnabled(): boolean;
  61681. /**
  61682. * Gets whether the color grading effect is enabled.
  61683. */
  61684. set cameraColorGradingEnabled(value: boolean);
  61685. /**
  61686. * Gets whether tonemapping is enabled or not.
  61687. */
  61688. get cameraToneMappingEnabled(): boolean;
  61689. /**
  61690. * Sets whether tonemapping is enabled or not
  61691. */
  61692. set cameraToneMappingEnabled(value: boolean);
  61693. /**
  61694. * The camera exposure used on this material.
  61695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61696. * This corresponds to a photographic exposure.
  61697. */
  61698. get cameraExposure(): float;
  61699. /**
  61700. * The camera exposure used on this material.
  61701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61702. * This corresponds to a photographic exposure.
  61703. */
  61704. set cameraExposure(value: float);
  61705. /**
  61706. * Gets The camera contrast used on this material.
  61707. */
  61708. get cameraContrast(): float;
  61709. /**
  61710. * Sets The camera contrast used on this material.
  61711. */
  61712. set cameraContrast(value: float);
  61713. /**
  61714. * Gets the Color Grading 2D Lookup Texture.
  61715. */
  61716. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61717. /**
  61718. * Sets the Color Grading 2D Lookup Texture.
  61719. */
  61720. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61721. /**
  61722. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61724. * 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;
  61725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61726. */
  61727. get cameraColorCurves(): Nullable<ColorCurves>;
  61728. /**
  61729. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61731. * 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;
  61732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61733. */
  61734. set cameraColorCurves(value: Nullable<ColorCurves>);
  61735. /**
  61736. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61737. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61738. */
  61739. switchToBGR: boolean;
  61740. private _renderTargets;
  61741. private _reflectionControls;
  61742. private _white;
  61743. private _primaryShadowColor;
  61744. private _primaryHighlightColor;
  61745. /**
  61746. * Instantiates a Background Material in the given scene
  61747. * @param name The friendly name of the material
  61748. * @param scene The scene to add the material to
  61749. */
  61750. constructor(name: string, scene: Scene);
  61751. /**
  61752. * Gets a boolean indicating that current material needs to register RTT
  61753. */
  61754. get hasRenderTargetTextures(): boolean;
  61755. /**
  61756. * The entire material has been created in order to prevent overdraw.
  61757. * @returns false
  61758. */
  61759. needAlphaTesting(): boolean;
  61760. /**
  61761. * The entire material has been created in order to prevent overdraw.
  61762. * @returns true if blending is enable
  61763. */
  61764. needAlphaBlending(): boolean;
  61765. /**
  61766. * Checks whether the material is ready to be rendered for a given mesh.
  61767. * @param mesh The mesh to render
  61768. * @param subMesh The submesh to check against
  61769. * @param useInstances Specify wether or not the material is used with instances
  61770. * @returns true if all the dependencies are ready (Textures, Effects...)
  61771. */
  61772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61773. /**
  61774. * Compute the primary color according to the chosen perceptual color.
  61775. */
  61776. private _computePrimaryColorFromPerceptualColor;
  61777. /**
  61778. * Compute the highlights and shadow colors according to their chosen levels.
  61779. */
  61780. private _computePrimaryColors;
  61781. /**
  61782. * Build the uniform buffer used in the material.
  61783. */
  61784. buildUniformLayout(): void;
  61785. /**
  61786. * Unbind the material.
  61787. */
  61788. unbind(): void;
  61789. /**
  61790. * Bind only the world matrix to the material.
  61791. * @param world The world matrix to bind.
  61792. */
  61793. bindOnlyWorldMatrix(world: Matrix): void;
  61794. /**
  61795. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61796. * @param world The world matrix to bind.
  61797. * @param subMesh The submesh to bind for.
  61798. */
  61799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61800. /**
  61801. * Checks to see if a texture is used in the material.
  61802. * @param texture - Base texture to use.
  61803. * @returns - Boolean specifying if a texture is used in the material.
  61804. */
  61805. hasTexture(texture: BaseTexture): boolean;
  61806. /**
  61807. * Dispose the material.
  61808. * @param forceDisposeEffect Force disposal of the associated effect.
  61809. * @param forceDisposeTextures Force disposal of the associated textures.
  61810. */
  61811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61812. /**
  61813. * Clones the material.
  61814. * @param name The cloned name.
  61815. * @returns The cloned material.
  61816. */
  61817. clone(name: string): BackgroundMaterial;
  61818. /**
  61819. * Serializes the current material to its JSON representation.
  61820. * @returns The JSON representation.
  61821. */
  61822. serialize(): any;
  61823. /**
  61824. * Gets the class name of the material
  61825. * @returns "BackgroundMaterial"
  61826. */
  61827. getClassName(): string;
  61828. /**
  61829. * Parse a JSON input to create back a background material.
  61830. * @param source The JSON data to parse
  61831. * @param scene The scene to create the parsed material in
  61832. * @param rootUrl The root url of the assets the material depends upon
  61833. * @returns the instantiated BackgroundMaterial.
  61834. */
  61835. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /**
  61840. * Represents the different options available during the creation of
  61841. * a Environment helper.
  61842. *
  61843. * This can control the default ground, skybox and image processing setup of your scene.
  61844. */
  61845. export interface IEnvironmentHelperOptions {
  61846. /**
  61847. * Specifies whether or not to create a ground.
  61848. * True by default.
  61849. */
  61850. createGround: boolean;
  61851. /**
  61852. * Specifies the ground size.
  61853. * 15 by default.
  61854. */
  61855. groundSize: number;
  61856. /**
  61857. * The texture used on the ground for the main color.
  61858. * Comes from the BabylonJS CDN by default.
  61859. *
  61860. * Remarks: Can be either a texture or a url.
  61861. */
  61862. groundTexture: string | BaseTexture;
  61863. /**
  61864. * The color mixed in the ground texture by default.
  61865. * BabylonJS clearColor by default.
  61866. */
  61867. groundColor: Color3;
  61868. /**
  61869. * Specifies the ground opacity.
  61870. * 1 by default.
  61871. */
  61872. groundOpacity: number;
  61873. /**
  61874. * Enables the ground to receive shadows.
  61875. * True by default.
  61876. */
  61877. enableGroundShadow: boolean;
  61878. /**
  61879. * Helps preventing the shadow to be fully black on the ground.
  61880. * 0.5 by default.
  61881. */
  61882. groundShadowLevel: number;
  61883. /**
  61884. * Creates a mirror texture attach to the ground.
  61885. * false by default.
  61886. */
  61887. enableGroundMirror: boolean;
  61888. /**
  61889. * Specifies the ground mirror size ratio.
  61890. * 0.3 by default as the default kernel is 64.
  61891. */
  61892. groundMirrorSizeRatio: number;
  61893. /**
  61894. * Specifies the ground mirror blur kernel size.
  61895. * 64 by default.
  61896. */
  61897. groundMirrorBlurKernel: number;
  61898. /**
  61899. * Specifies the ground mirror visibility amount.
  61900. * 1 by default
  61901. */
  61902. groundMirrorAmount: number;
  61903. /**
  61904. * Specifies the ground mirror reflectance weight.
  61905. * This uses the standard weight of the background material to setup the fresnel effect
  61906. * of the mirror.
  61907. * 1 by default.
  61908. */
  61909. groundMirrorFresnelWeight: number;
  61910. /**
  61911. * Specifies the ground mirror Falloff distance.
  61912. * This can helps reducing the size of the reflection.
  61913. * 0 by Default.
  61914. */
  61915. groundMirrorFallOffDistance: number;
  61916. /**
  61917. * Specifies the ground mirror texture type.
  61918. * Unsigned Int by Default.
  61919. */
  61920. groundMirrorTextureType: number;
  61921. /**
  61922. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61923. * the shown objects.
  61924. */
  61925. groundYBias: number;
  61926. /**
  61927. * Specifies whether or not to create a skybox.
  61928. * True by default.
  61929. */
  61930. createSkybox: boolean;
  61931. /**
  61932. * Specifies the skybox size.
  61933. * 20 by default.
  61934. */
  61935. skyboxSize: number;
  61936. /**
  61937. * The texture used on the skybox for the main color.
  61938. * Comes from the BabylonJS CDN by default.
  61939. *
  61940. * Remarks: Can be either a texture or a url.
  61941. */
  61942. skyboxTexture: string | BaseTexture;
  61943. /**
  61944. * The color mixed in the skybox texture by default.
  61945. * BabylonJS clearColor by default.
  61946. */
  61947. skyboxColor: Color3;
  61948. /**
  61949. * The background rotation around the Y axis of the scene.
  61950. * This helps aligning the key lights of your scene with the background.
  61951. * 0 by default.
  61952. */
  61953. backgroundYRotation: number;
  61954. /**
  61955. * Compute automatically the size of the elements to best fit with the scene.
  61956. */
  61957. sizeAuto: boolean;
  61958. /**
  61959. * Default position of the rootMesh if autoSize is not true.
  61960. */
  61961. rootPosition: Vector3;
  61962. /**
  61963. * Sets up the image processing in the scene.
  61964. * true by default.
  61965. */
  61966. setupImageProcessing: boolean;
  61967. /**
  61968. * The texture used as your environment texture in the scene.
  61969. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61970. *
  61971. * Remarks: Can be either a texture or a url.
  61972. */
  61973. environmentTexture: string | BaseTexture;
  61974. /**
  61975. * The value of the exposure to apply to the scene.
  61976. * 0.6 by default if setupImageProcessing is true.
  61977. */
  61978. cameraExposure: number;
  61979. /**
  61980. * The value of the contrast to apply to the scene.
  61981. * 1.6 by default if setupImageProcessing is true.
  61982. */
  61983. cameraContrast: number;
  61984. /**
  61985. * Specifies whether or not tonemapping should be enabled in the scene.
  61986. * true by default if setupImageProcessing is true.
  61987. */
  61988. toneMappingEnabled: boolean;
  61989. }
  61990. /**
  61991. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  61992. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61993. * It also helps with the default setup of your imageProcessing configuration.
  61994. */
  61995. export class EnvironmentHelper {
  61996. /**
  61997. * Default ground texture URL.
  61998. */
  61999. private static _groundTextureCDNUrl;
  62000. /**
  62001. * Default skybox texture URL.
  62002. */
  62003. private static _skyboxTextureCDNUrl;
  62004. /**
  62005. * Default environment texture URL.
  62006. */
  62007. private static _environmentTextureCDNUrl;
  62008. /**
  62009. * Creates the default options for the helper.
  62010. */
  62011. private static _getDefaultOptions;
  62012. private _rootMesh;
  62013. /**
  62014. * Gets the root mesh created by the helper.
  62015. */
  62016. get rootMesh(): Mesh;
  62017. private _skybox;
  62018. /**
  62019. * Gets the skybox created by the helper.
  62020. */
  62021. get skybox(): Nullable<Mesh>;
  62022. private _skyboxTexture;
  62023. /**
  62024. * Gets the skybox texture created by the helper.
  62025. */
  62026. get skyboxTexture(): Nullable<BaseTexture>;
  62027. private _skyboxMaterial;
  62028. /**
  62029. * Gets the skybox material created by the helper.
  62030. */
  62031. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62032. private _ground;
  62033. /**
  62034. * Gets the ground mesh created by the helper.
  62035. */
  62036. get ground(): Nullable<Mesh>;
  62037. private _groundTexture;
  62038. /**
  62039. * Gets the ground texture created by the helper.
  62040. */
  62041. get groundTexture(): Nullable<BaseTexture>;
  62042. private _groundMirror;
  62043. /**
  62044. * Gets the ground mirror created by the helper.
  62045. */
  62046. get groundMirror(): Nullable<MirrorTexture>;
  62047. /**
  62048. * Gets the ground mirror render list to helps pushing the meshes
  62049. * you wish in the ground reflection.
  62050. */
  62051. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62052. private _groundMaterial;
  62053. /**
  62054. * Gets the ground material created by the helper.
  62055. */
  62056. get groundMaterial(): Nullable<BackgroundMaterial>;
  62057. /**
  62058. * Stores the creation options.
  62059. */
  62060. private readonly _scene;
  62061. private _options;
  62062. /**
  62063. * This observable will be notified with any error during the creation of the environment,
  62064. * mainly texture creation errors.
  62065. */
  62066. onErrorObservable: Observable<{
  62067. message?: string;
  62068. exception?: any;
  62069. }>;
  62070. /**
  62071. * constructor
  62072. * @param options Defines the options we want to customize the helper
  62073. * @param scene The scene to add the material to
  62074. */
  62075. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62076. /**
  62077. * Updates the background according to the new options
  62078. * @param options
  62079. */
  62080. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62081. /**
  62082. * Sets the primary color of all the available elements.
  62083. * @param color the main color to affect to the ground and the background
  62084. */
  62085. setMainColor(color: Color3): void;
  62086. /**
  62087. * Setup the image processing according to the specified options.
  62088. */
  62089. private _setupImageProcessing;
  62090. /**
  62091. * Setup the environment texture according to the specified options.
  62092. */
  62093. private _setupEnvironmentTexture;
  62094. /**
  62095. * Setup the background according to the specified options.
  62096. */
  62097. private _setupBackground;
  62098. /**
  62099. * Get the scene sizes according to the setup.
  62100. */
  62101. private _getSceneSize;
  62102. /**
  62103. * Setup the ground according to the specified options.
  62104. */
  62105. private _setupGround;
  62106. /**
  62107. * Setup the ground material according to the specified options.
  62108. */
  62109. private _setupGroundMaterial;
  62110. /**
  62111. * Setup the ground diffuse texture according to the specified options.
  62112. */
  62113. private _setupGroundDiffuseTexture;
  62114. /**
  62115. * Setup the ground mirror texture according to the specified options.
  62116. */
  62117. private _setupGroundMirrorTexture;
  62118. /**
  62119. * Setup the ground to receive the mirror texture.
  62120. */
  62121. private _setupMirrorInGroundMaterial;
  62122. /**
  62123. * Setup the skybox according to the specified options.
  62124. */
  62125. private _setupSkybox;
  62126. /**
  62127. * Setup the skybox material according to the specified options.
  62128. */
  62129. private _setupSkyboxMaterial;
  62130. /**
  62131. * Setup the skybox reflection texture according to the specified options.
  62132. */
  62133. private _setupSkyboxReflectionTexture;
  62134. private _errorHandler;
  62135. /**
  62136. * Dispose all the elements created by the Helper.
  62137. */
  62138. dispose(): void;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62144. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62145. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62146. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62147. */
  62148. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62149. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62150. /**
  62151. * Define the source as a Monoscopic panoramic 360/180.
  62152. */
  62153. static readonly MODE_MONOSCOPIC: number;
  62154. /**
  62155. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62156. */
  62157. static readonly MODE_TOPBOTTOM: number;
  62158. /**
  62159. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62160. */
  62161. static readonly MODE_SIDEBYSIDE: number;
  62162. private _halfDome;
  62163. private _crossEye;
  62164. protected _useDirectMapping: boolean;
  62165. /**
  62166. * The texture being displayed on the sphere
  62167. */
  62168. protected _texture: T;
  62169. /**
  62170. * Gets the texture being displayed on the sphere
  62171. */
  62172. get texture(): T;
  62173. /**
  62174. * Sets the texture being displayed on the sphere
  62175. */
  62176. set texture(newTexture: T);
  62177. /**
  62178. * The skybox material
  62179. */
  62180. protected _material: BackgroundMaterial;
  62181. /**
  62182. * The surface used for the dome
  62183. */
  62184. protected _mesh: Mesh;
  62185. /**
  62186. * Gets the mesh used for the dome.
  62187. */
  62188. get mesh(): Mesh;
  62189. /**
  62190. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62191. */
  62192. private _halfDomeMask;
  62193. /**
  62194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62195. * Also see the options.resolution property.
  62196. */
  62197. get fovMultiplier(): number;
  62198. set fovMultiplier(value: number);
  62199. protected _textureMode: number;
  62200. /**
  62201. * Gets or set the current texture mode for the texture. It can be:
  62202. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62203. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62204. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62205. */
  62206. get textureMode(): number;
  62207. /**
  62208. * Sets the current texture mode for the texture. It can be:
  62209. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62210. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62211. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62212. */
  62213. set textureMode(value: number);
  62214. /**
  62215. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62216. */
  62217. get halfDome(): boolean;
  62218. /**
  62219. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62220. */
  62221. set halfDome(enabled: boolean);
  62222. /**
  62223. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62224. */
  62225. set crossEye(enabled: boolean);
  62226. /**
  62227. * Is it a cross-eye texture?
  62228. */
  62229. get crossEye(): boolean;
  62230. /**
  62231. * The background material of this dome.
  62232. */
  62233. get material(): BackgroundMaterial;
  62234. /**
  62235. * Oberserver used in Stereoscopic VR Mode.
  62236. */
  62237. private _onBeforeCameraRenderObserver;
  62238. /**
  62239. * Observable raised when an error occurred while loading the texture
  62240. */
  62241. onLoadErrorObservable: Observable<string>;
  62242. /**
  62243. * Observable raised when the texture finished loading
  62244. */
  62245. onLoadObservable: Observable<void>;
  62246. /**
  62247. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62248. * @param name Element's name, child elements will append suffixes for their own names.
  62249. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62250. * @param options An object containing optional or exposed sub element properties
  62251. */
  62252. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62253. resolution?: number;
  62254. clickToPlay?: boolean;
  62255. autoPlay?: boolean;
  62256. loop?: boolean;
  62257. size?: number;
  62258. poster?: string;
  62259. faceForward?: boolean;
  62260. useDirectMapping?: boolean;
  62261. halfDomeMode?: boolean;
  62262. crossEyeMode?: boolean;
  62263. generateMipMaps?: boolean;
  62264. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62265. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62266. protected _changeTextureMode(value: number): void;
  62267. /**
  62268. * Releases resources associated with this node.
  62269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62271. */
  62272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62278. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62279. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62280. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62281. */
  62282. export class PhotoDome extends TextureDome<Texture> {
  62283. /**
  62284. * Define the image as a Monoscopic panoramic 360 image.
  62285. */
  62286. static readonly MODE_MONOSCOPIC: number;
  62287. /**
  62288. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62289. */
  62290. static readonly MODE_TOPBOTTOM: number;
  62291. /**
  62292. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62293. */
  62294. static readonly MODE_SIDEBYSIDE: number;
  62295. /**
  62296. * Gets or sets the texture being displayed on the sphere
  62297. */
  62298. get photoTexture(): Texture;
  62299. /**
  62300. * sets the texture being displayed on the sphere
  62301. */
  62302. set photoTexture(value: Texture);
  62303. /**
  62304. * Gets the current video mode for the video. It can be:
  62305. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62306. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62307. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62308. */
  62309. get imageMode(): number;
  62310. /**
  62311. * Sets the current video mode for the video. It can be:
  62312. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62313. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62314. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62315. */
  62316. set imageMode(value: number);
  62317. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62318. }
  62319. }
  62320. declare module BABYLON {
  62321. /**
  62322. * Direct draw surface info
  62323. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62324. */
  62325. export interface DDSInfo {
  62326. /**
  62327. * Width of the texture
  62328. */
  62329. width: number;
  62330. /**
  62331. * Width of the texture
  62332. */
  62333. height: number;
  62334. /**
  62335. * Number of Mipmaps for the texture
  62336. * @see https://en.wikipedia.org/wiki/Mipmap
  62337. */
  62338. mipmapCount: number;
  62339. /**
  62340. * If the textures format is a known fourCC format
  62341. * @see https://www.fourcc.org/
  62342. */
  62343. isFourCC: boolean;
  62344. /**
  62345. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62346. */
  62347. isRGB: boolean;
  62348. /**
  62349. * If the texture is a lumincance format
  62350. */
  62351. isLuminance: boolean;
  62352. /**
  62353. * If this is a cube texture
  62354. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62355. */
  62356. isCube: boolean;
  62357. /**
  62358. * If the texture is a compressed format eg. FOURCC_DXT1
  62359. */
  62360. isCompressed: boolean;
  62361. /**
  62362. * The dxgiFormat of the texture
  62363. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62364. */
  62365. dxgiFormat: number;
  62366. /**
  62367. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62368. */
  62369. textureType: number;
  62370. /**
  62371. * Sphericle polynomial created for the dds texture
  62372. */
  62373. sphericalPolynomial?: SphericalPolynomial;
  62374. }
  62375. /**
  62376. * Class used to provide DDS decompression tools
  62377. */
  62378. export class DDSTools {
  62379. /**
  62380. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62381. */
  62382. static StoreLODInAlphaChannel: boolean;
  62383. /**
  62384. * Gets DDS information from an array buffer
  62385. * @param data defines the array buffer view to read data from
  62386. * @returns the DDS information
  62387. */
  62388. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62389. private static _FloatView;
  62390. private static _Int32View;
  62391. private static _ToHalfFloat;
  62392. private static _FromHalfFloat;
  62393. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62394. private static _GetHalfFloatRGBAArrayBuffer;
  62395. private static _GetFloatRGBAArrayBuffer;
  62396. private static _GetFloatAsUIntRGBAArrayBuffer;
  62397. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62398. private static _GetRGBAArrayBuffer;
  62399. private static _ExtractLongWordOrder;
  62400. private static _GetRGBArrayBuffer;
  62401. private static _GetLuminanceArrayBuffer;
  62402. /**
  62403. * Uploads DDS Levels to a Babylon Texture
  62404. * @hidden
  62405. */
  62406. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62407. }
  62408. interface ThinEngine {
  62409. /**
  62410. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62411. * @param rootUrl defines the url where the file to load is located
  62412. * @param scene defines the current scene
  62413. * @param lodScale defines scale to apply to the mip map selection
  62414. * @param lodOffset defines offset to apply to the mip map selection
  62415. * @param onLoad defines an optional callback raised when the texture is loaded
  62416. * @param onError defines an optional callback raised if there is an issue to load the texture
  62417. * @param format defines the format of the data
  62418. * @param forcedExtension defines the extension to use to pick the right loader
  62419. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62420. * @returns the cube texture as an InternalTexture
  62421. */
  62422. 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;
  62423. }
  62424. }
  62425. declare module BABYLON {
  62426. /**
  62427. * Implementation of the DDS Texture Loader.
  62428. * @hidden
  62429. */
  62430. export class _DDSTextureLoader implements IInternalTextureLoader {
  62431. /**
  62432. * Defines whether the loader supports cascade loading the different faces.
  62433. */
  62434. readonly supportCascades: boolean;
  62435. /**
  62436. * This returns if the loader support the current file information.
  62437. * @param extension defines the file extension of the file being loaded
  62438. * @returns true if the loader can load the specified file
  62439. */
  62440. canLoad(extension: string): boolean;
  62441. /**
  62442. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62443. * @param data contains the texture data
  62444. * @param texture defines the BabylonJS internal texture
  62445. * @param createPolynomials will be true if polynomials have been requested
  62446. * @param onLoad defines the callback to trigger once the texture is ready
  62447. * @param onError defines the callback to trigger in case of error
  62448. */
  62449. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62450. /**
  62451. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62452. * @param data contains the texture data
  62453. * @param texture defines the BabylonJS internal texture
  62454. * @param callback defines the method to call once ready to upload
  62455. */
  62456. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62457. }
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * Implementation of the ENV Texture Loader.
  62462. * @hidden
  62463. */
  62464. export class _ENVTextureLoader implements IInternalTextureLoader {
  62465. /**
  62466. * Defines whether the loader supports cascade loading the different faces.
  62467. */
  62468. readonly supportCascades: boolean;
  62469. /**
  62470. * This returns if the loader support the current file information.
  62471. * @param extension defines the file extension of the file being loaded
  62472. * @returns true if the loader can load the specified file
  62473. */
  62474. canLoad(extension: string): boolean;
  62475. /**
  62476. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62477. * @param data contains the texture data
  62478. * @param texture defines the BabylonJS internal texture
  62479. * @param createPolynomials will be true if polynomials have been requested
  62480. * @param onLoad defines the callback to trigger once the texture is ready
  62481. * @param onError defines the callback to trigger in case of error
  62482. */
  62483. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62484. /**
  62485. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62486. * @param data contains the texture data
  62487. * @param texture defines the BabylonJS internal texture
  62488. * @param callback defines the method to call once ready to upload
  62489. */
  62490. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62491. }
  62492. }
  62493. declare module BABYLON {
  62494. /**
  62495. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62496. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62497. */
  62498. export class KhronosTextureContainer {
  62499. /** contents of the KTX container file */
  62500. data: ArrayBufferView;
  62501. private static HEADER_LEN;
  62502. private static COMPRESSED_2D;
  62503. private static COMPRESSED_3D;
  62504. private static TEX_2D;
  62505. private static TEX_3D;
  62506. /**
  62507. * Gets the openGL type
  62508. */
  62509. glType: number;
  62510. /**
  62511. * Gets the openGL type size
  62512. */
  62513. glTypeSize: number;
  62514. /**
  62515. * Gets the openGL format
  62516. */
  62517. glFormat: number;
  62518. /**
  62519. * Gets the openGL internal format
  62520. */
  62521. glInternalFormat: number;
  62522. /**
  62523. * Gets the base internal format
  62524. */
  62525. glBaseInternalFormat: number;
  62526. /**
  62527. * Gets image width in pixel
  62528. */
  62529. pixelWidth: number;
  62530. /**
  62531. * Gets image height in pixel
  62532. */
  62533. pixelHeight: number;
  62534. /**
  62535. * Gets image depth in pixels
  62536. */
  62537. pixelDepth: number;
  62538. /**
  62539. * Gets the number of array elements
  62540. */
  62541. numberOfArrayElements: number;
  62542. /**
  62543. * Gets the number of faces
  62544. */
  62545. numberOfFaces: number;
  62546. /**
  62547. * Gets the number of mipmap levels
  62548. */
  62549. numberOfMipmapLevels: number;
  62550. /**
  62551. * Gets the bytes of key value data
  62552. */
  62553. bytesOfKeyValueData: number;
  62554. /**
  62555. * Gets the load type
  62556. */
  62557. loadType: number;
  62558. /**
  62559. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62560. */
  62561. isInvalid: boolean;
  62562. /**
  62563. * Creates a new KhronosTextureContainer
  62564. * @param data contents of the KTX container file
  62565. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62566. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62567. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62568. */
  62569. constructor(
  62570. /** contents of the KTX container file */
  62571. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62572. /**
  62573. * Uploads KTX content to a Babylon Texture.
  62574. * It is assumed that the texture has already been created & is currently bound
  62575. * @hidden
  62576. */
  62577. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62578. private _upload2DCompressedLevels;
  62579. /**
  62580. * Checks if the given data starts with a KTX file identifier.
  62581. * @param data the data to check
  62582. * @returns true if the data is a KTX file or false otherwise
  62583. */
  62584. static IsValid(data: ArrayBufferView): boolean;
  62585. }
  62586. }
  62587. declare module BABYLON {
  62588. /**
  62589. * Helper class to push actions to a pool of workers.
  62590. */
  62591. export class WorkerPool implements IDisposable {
  62592. private _workerInfos;
  62593. private _pendingActions;
  62594. /**
  62595. * Constructor
  62596. * @param workers Array of workers to use for actions
  62597. */
  62598. constructor(workers: Array<Worker>);
  62599. /**
  62600. * Terminates all workers and clears any pending actions.
  62601. */
  62602. dispose(): void;
  62603. /**
  62604. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62605. * pended until a worker has completed its action.
  62606. * @param action The action to perform. Call onComplete when the action is complete.
  62607. */
  62608. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62609. private _execute;
  62610. }
  62611. }
  62612. declare module BABYLON {
  62613. /**
  62614. * Class for loading KTX2 files
  62615. */
  62616. export class KhronosTextureContainer2 {
  62617. private static _WorkerPoolPromise?;
  62618. private static _Initialized;
  62619. private static _Ktx2Decoder;
  62620. /**
  62621. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62622. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62623. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62624. * Urls you can change:
  62625. * URLConfig.jsDecoderModule
  62626. * URLConfig.wasmUASTCToASTC
  62627. * URLConfig.wasmUASTCToBC7
  62628. * URLConfig.wasmUASTCToRGBA_UNORM
  62629. * URLConfig.wasmUASTCToRGBA_SRGB
  62630. * URLConfig.jsMSCTranscoder
  62631. * URLConfig.wasmMSCTranscoder
  62632. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62633. */
  62634. static URLConfig: {
  62635. jsDecoderModule: string;
  62636. wasmUASTCToASTC: null;
  62637. wasmUASTCToBC7: null;
  62638. wasmUASTCToRGBA_UNORM: null;
  62639. wasmUASTCToRGBA_SRGB: null;
  62640. jsMSCTranscoder: null;
  62641. wasmMSCTranscoder: null;
  62642. };
  62643. /**
  62644. * Default number of workers used to handle data decoding
  62645. */
  62646. static DefaultNumWorkers: number;
  62647. private static GetDefaultNumWorkers;
  62648. private _engine;
  62649. private static _CreateWorkerPool;
  62650. /**
  62651. * Constructor
  62652. * @param engine The engine to use
  62653. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62654. */
  62655. constructor(engine: ThinEngine, numWorkers?: number);
  62656. /** @hidden */
  62657. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62658. /**
  62659. * Stop all async operations and release resources.
  62660. */
  62661. dispose(): void;
  62662. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62663. /**
  62664. * Checks if the given data starts with a KTX2 file identifier.
  62665. * @param data the data to check
  62666. * @returns true if the data is a KTX2 file or false otherwise
  62667. */
  62668. static IsValid(data: ArrayBufferView): boolean;
  62669. }
  62670. }
  62671. declare module BABYLON {
  62672. /**
  62673. * Implementation of the KTX Texture Loader.
  62674. * @hidden
  62675. */
  62676. export class _KTXTextureLoader implements IInternalTextureLoader {
  62677. /**
  62678. * Defines whether the loader supports cascade loading the different faces.
  62679. */
  62680. readonly supportCascades: boolean;
  62681. /**
  62682. * This returns if the loader support the current file information.
  62683. * @param extension defines the file extension of the file being loaded
  62684. * @param mimeType defines the optional mime type of the file being loaded
  62685. * @returns true if the loader can load the specified file
  62686. */
  62687. canLoad(extension: string, mimeType?: string): boolean;
  62688. /**
  62689. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62690. * @param data contains the texture data
  62691. * @param texture defines the BabylonJS internal texture
  62692. * @param createPolynomials will be true if polynomials have been requested
  62693. * @param onLoad defines the callback to trigger once the texture is ready
  62694. * @param onError defines the callback to trigger in case of error
  62695. */
  62696. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62697. /**
  62698. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62699. * @param data contains the texture data
  62700. * @param texture defines the BabylonJS internal texture
  62701. * @param callback defines the method to call once ready to upload
  62702. */
  62703. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62704. }
  62705. }
  62706. declare module BABYLON {
  62707. /** @hidden */
  62708. export var _forceSceneHelpersToBundle: boolean;
  62709. interface Scene {
  62710. /**
  62711. * Creates a default light for the scene.
  62712. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62713. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62714. */
  62715. createDefaultLight(replace?: boolean): void;
  62716. /**
  62717. * Creates a default camera for the scene.
  62718. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62719. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62720. * @param replace has default false, when true replaces the active camera in the scene
  62721. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62722. */
  62723. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62724. /**
  62725. * Creates a default camera and a default light.
  62726. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62727. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62728. * @param replace has the default false, when true replaces the active camera/light in the scene
  62729. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62730. */
  62731. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62732. /**
  62733. * Creates a new sky box
  62734. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62735. * @param environmentTexture defines the texture to use as environment texture
  62736. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62737. * @param scale defines the overall scale of the skybox
  62738. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62739. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62740. * @returns a new mesh holding the sky box
  62741. */
  62742. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62743. /**
  62744. * Creates a new environment
  62745. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62746. * @param options defines the options you can use to configure the environment
  62747. * @returns the new EnvironmentHelper
  62748. */
  62749. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62750. /**
  62751. * Creates a new VREXperienceHelper
  62752. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62753. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62754. * @returns a new VREXperienceHelper
  62755. */
  62756. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62757. /**
  62758. * Creates a new WebXRDefaultExperience
  62759. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62760. * @param options experience options
  62761. * @returns a promise for a new WebXRDefaultExperience
  62762. */
  62763. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62764. }
  62765. }
  62766. declare module BABYLON {
  62767. /**
  62768. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62769. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62770. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62771. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62772. */
  62773. export class VideoDome extends TextureDome<VideoTexture> {
  62774. /**
  62775. * Define the video source as a Monoscopic panoramic 360 video.
  62776. */
  62777. static readonly MODE_MONOSCOPIC: number;
  62778. /**
  62779. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62780. */
  62781. static readonly MODE_TOPBOTTOM: number;
  62782. /**
  62783. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62784. */
  62785. static readonly MODE_SIDEBYSIDE: number;
  62786. /**
  62787. * Get the video texture associated with this video dome
  62788. */
  62789. get videoTexture(): VideoTexture;
  62790. /**
  62791. * Get the video mode of this dome
  62792. */
  62793. get videoMode(): number;
  62794. /**
  62795. * Set the video mode of this dome.
  62796. * @see textureMode
  62797. */
  62798. set videoMode(value: number);
  62799. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * This class can be used to get instrumentation data from a Babylon engine
  62805. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62806. */
  62807. export class EngineInstrumentation implements IDisposable {
  62808. /**
  62809. * Define the instrumented engine.
  62810. */
  62811. engine: Engine;
  62812. private _captureGPUFrameTime;
  62813. private _gpuFrameTimeToken;
  62814. private _gpuFrameTime;
  62815. private _captureShaderCompilationTime;
  62816. private _shaderCompilationTime;
  62817. private _onBeginFrameObserver;
  62818. private _onEndFrameObserver;
  62819. private _onBeforeShaderCompilationObserver;
  62820. private _onAfterShaderCompilationObserver;
  62821. /**
  62822. * Gets the perf counter used for GPU frame time
  62823. */
  62824. get gpuFrameTimeCounter(): PerfCounter;
  62825. /**
  62826. * Gets the GPU frame time capture status
  62827. */
  62828. get captureGPUFrameTime(): boolean;
  62829. /**
  62830. * Enable or disable the GPU frame time capture
  62831. */
  62832. set captureGPUFrameTime(value: boolean);
  62833. /**
  62834. * Gets the perf counter used for shader compilation time
  62835. */
  62836. get shaderCompilationTimeCounter(): PerfCounter;
  62837. /**
  62838. * Gets the shader compilation time capture status
  62839. */
  62840. get captureShaderCompilationTime(): boolean;
  62841. /**
  62842. * Enable or disable the shader compilation time capture
  62843. */
  62844. set captureShaderCompilationTime(value: boolean);
  62845. /**
  62846. * Instantiates a new engine instrumentation.
  62847. * This class can be used to get instrumentation data from a Babylon engine
  62848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62849. * @param engine Defines the engine to instrument
  62850. */
  62851. constructor(
  62852. /**
  62853. * Define the instrumented engine.
  62854. */
  62855. engine: Engine);
  62856. /**
  62857. * Dispose and release associated resources.
  62858. */
  62859. dispose(): void;
  62860. }
  62861. }
  62862. declare module BABYLON {
  62863. /**
  62864. * This class can be used to get instrumentation data from a Babylon engine
  62865. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62866. */
  62867. export class SceneInstrumentation implements IDisposable {
  62868. /**
  62869. * Defines the scene to instrument
  62870. */
  62871. scene: Scene;
  62872. private _captureActiveMeshesEvaluationTime;
  62873. private _activeMeshesEvaluationTime;
  62874. private _captureRenderTargetsRenderTime;
  62875. private _renderTargetsRenderTime;
  62876. private _captureFrameTime;
  62877. private _frameTime;
  62878. private _captureRenderTime;
  62879. private _renderTime;
  62880. private _captureInterFrameTime;
  62881. private _interFrameTime;
  62882. private _captureParticlesRenderTime;
  62883. private _particlesRenderTime;
  62884. private _captureSpritesRenderTime;
  62885. private _spritesRenderTime;
  62886. private _capturePhysicsTime;
  62887. private _physicsTime;
  62888. private _captureAnimationsTime;
  62889. private _animationsTime;
  62890. private _captureCameraRenderTime;
  62891. private _cameraRenderTime;
  62892. private _onBeforeActiveMeshesEvaluationObserver;
  62893. private _onAfterActiveMeshesEvaluationObserver;
  62894. private _onBeforeRenderTargetsRenderObserver;
  62895. private _onAfterRenderTargetsRenderObserver;
  62896. private _onAfterRenderObserver;
  62897. private _onBeforeDrawPhaseObserver;
  62898. private _onAfterDrawPhaseObserver;
  62899. private _onBeforeAnimationsObserver;
  62900. private _onBeforeParticlesRenderingObserver;
  62901. private _onAfterParticlesRenderingObserver;
  62902. private _onBeforeSpritesRenderingObserver;
  62903. private _onAfterSpritesRenderingObserver;
  62904. private _onBeforePhysicsObserver;
  62905. private _onAfterPhysicsObserver;
  62906. private _onAfterAnimationsObserver;
  62907. private _onBeforeCameraRenderObserver;
  62908. private _onAfterCameraRenderObserver;
  62909. /**
  62910. * Gets the perf counter used for active meshes evaluation time
  62911. */
  62912. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62913. /**
  62914. * Gets the active meshes evaluation time capture status
  62915. */
  62916. get captureActiveMeshesEvaluationTime(): boolean;
  62917. /**
  62918. * Enable or disable the active meshes evaluation time capture
  62919. */
  62920. set captureActiveMeshesEvaluationTime(value: boolean);
  62921. /**
  62922. * Gets the perf counter used for render targets render time
  62923. */
  62924. get renderTargetsRenderTimeCounter(): PerfCounter;
  62925. /**
  62926. * Gets the render targets render time capture status
  62927. */
  62928. get captureRenderTargetsRenderTime(): boolean;
  62929. /**
  62930. * Enable or disable the render targets render time capture
  62931. */
  62932. set captureRenderTargetsRenderTime(value: boolean);
  62933. /**
  62934. * Gets the perf counter used for particles render time
  62935. */
  62936. get particlesRenderTimeCounter(): PerfCounter;
  62937. /**
  62938. * Gets the particles render time capture status
  62939. */
  62940. get captureParticlesRenderTime(): boolean;
  62941. /**
  62942. * Enable or disable the particles render time capture
  62943. */
  62944. set captureParticlesRenderTime(value: boolean);
  62945. /**
  62946. * Gets the perf counter used for sprites render time
  62947. */
  62948. get spritesRenderTimeCounter(): PerfCounter;
  62949. /**
  62950. * Gets the sprites render time capture status
  62951. */
  62952. get captureSpritesRenderTime(): boolean;
  62953. /**
  62954. * Enable or disable the sprites render time capture
  62955. */
  62956. set captureSpritesRenderTime(value: boolean);
  62957. /**
  62958. * Gets the perf counter used for physics time
  62959. */
  62960. get physicsTimeCounter(): PerfCounter;
  62961. /**
  62962. * Gets the physics time capture status
  62963. */
  62964. get capturePhysicsTime(): boolean;
  62965. /**
  62966. * Enable or disable the physics time capture
  62967. */
  62968. set capturePhysicsTime(value: boolean);
  62969. /**
  62970. * Gets the perf counter used for animations time
  62971. */
  62972. get animationsTimeCounter(): PerfCounter;
  62973. /**
  62974. * Gets the animations time capture status
  62975. */
  62976. get captureAnimationsTime(): boolean;
  62977. /**
  62978. * Enable or disable the animations time capture
  62979. */
  62980. set captureAnimationsTime(value: boolean);
  62981. /**
  62982. * Gets the perf counter used for frame time capture
  62983. */
  62984. get frameTimeCounter(): PerfCounter;
  62985. /**
  62986. * Gets the frame time capture status
  62987. */
  62988. get captureFrameTime(): boolean;
  62989. /**
  62990. * Enable or disable the frame time capture
  62991. */
  62992. set captureFrameTime(value: boolean);
  62993. /**
  62994. * Gets the perf counter used for inter-frames time capture
  62995. */
  62996. get interFrameTimeCounter(): PerfCounter;
  62997. /**
  62998. * Gets the inter-frames time capture status
  62999. */
  63000. get captureInterFrameTime(): boolean;
  63001. /**
  63002. * Enable or disable the inter-frames time capture
  63003. */
  63004. set captureInterFrameTime(value: boolean);
  63005. /**
  63006. * Gets the perf counter used for render time capture
  63007. */
  63008. get renderTimeCounter(): PerfCounter;
  63009. /**
  63010. * Gets the render time capture status
  63011. */
  63012. get captureRenderTime(): boolean;
  63013. /**
  63014. * Enable or disable the render time capture
  63015. */
  63016. set captureRenderTime(value: boolean);
  63017. /**
  63018. * Gets the perf counter used for camera render time capture
  63019. */
  63020. get cameraRenderTimeCounter(): PerfCounter;
  63021. /**
  63022. * Gets the camera render time capture status
  63023. */
  63024. get captureCameraRenderTime(): boolean;
  63025. /**
  63026. * Enable or disable the camera render time capture
  63027. */
  63028. set captureCameraRenderTime(value: boolean);
  63029. /**
  63030. * Gets the perf counter used for draw calls
  63031. */
  63032. get drawCallsCounter(): PerfCounter;
  63033. /**
  63034. * Instantiates a new scene instrumentation.
  63035. * This class can be used to get instrumentation data from a Babylon engine
  63036. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63037. * @param scene Defines the scene to instrument
  63038. */
  63039. constructor(
  63040. /**
  63041. * Defines the scene to instrument
  63042. */
  63043. scene: Scene);
  63044. /**
  63045. * Dispose and release associated resources.
  63046. */
  63047. dispose(): void;
  63048. }
  63049. }
  63050. declare module BABYLON {
  63051. /** @hidden */
  63052. export var glowMapGenerationPixelShader: {
  63053. name: string;
  63054. shader: string;
  63055. };
  63056. }
  63057. declare module BABYLON {
  63058. /** @hidden */
  63059. export var glowMapGenerationVertexShader: {
  63060. name: string;
  63061. shader: string;
  63062. };
  63063. }
  63064. declare module BABYLON {
  63065. /**
  63066. * Effect layer options. This helps customizing the behaviour
  63067. * of the effect layer.
  63068. */
  63069. export interface IEffectLayerOptions {
  63070. /**
  63071. * Multiplication factor apply to the canvas size to compute the render target size
  63072. * used to generated the objects (the smaller the faster).
  63073. */
  63074. mainTextureRatio: number;
  63075. /**
  63076. * Enforces a fixed size texture to ensure effect stability across devices.
  63077. */
  63078. mainTextureFixedSize?: number;
  63079. /**
  63080. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63081. */
  63082. alphaBlendingMode: number;
  63083. /**
  63084. * The camera attached to the layer.
  63085. */
  63086. camera: Nullable<Camera>;
  63087. /**
  63088. * The rendering group to draw the layer in.
  63089. */
  63090. renderingGroupId: number;
  63091. }
  63092. /**
  63093. * The effect layer Helps adding post process effect blended with the main pass.
  63094. *
  63095. * This can be for instance use to generate glow or highlight effects on the scene.
  63096. *
  63097. * The effect layer class can not be used directly and is intented to inherited from to be
  63098. * customized per effects.
  63099. */
  63100. export abstract class EffectLayer {
  63101. private _vertexBuffers;
  63102. private _indexBuffer;
  63103. private _cachedDefines;
  63104. private _effectLayerMapGenerationEffect;
  63105. private _effectLayerOptions;
  63106. private _mergeEffect;
  63107. protected _scene: Scene;
  63108. protected _engine: Engine;
  63109. protected _maxSize: number;
  63110. protected _mainTextureDesiredSize: ISize;
  63111. protected _mainTexture: RenderTargetTexture;
  63112. protected _shouldRender: boolean;
  63113. protected _postProcesses: PostProcess[];
  63114. protected _textures: BaseTexture[];
  63115. protected _emissiveTextureAndColor: {
  63116. texture: Nullable<BaseTexture>;
  63117. color: Color4;
  63118. };
  63119. /**
  63120. * The name of the layer
  63121. */
  63122. name: string;
  63123. /**
  63124. * The clear color of the texture used to generate the glow map.
  63125. */
  63126. neutralColor: Color4;
  63127. /**
  63128. * Specifies whether the highlight layer is enabled or not.
  63129. */
  63130. isEnabled: boolean;
  63131. /**
  63132. * Gets the camera attached to the layer.
  63133. */
  63134. get camera(): Nullable<Camera>;
  63135. /**
  63136. * Gets the rendering group id the layer should render in.
  63137. */
  63138. get renderingGroupId(): number;
  63139. set renderingGroupId(renderingGroupId: number);
  63140. /**
  63141. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63142. */
  63143. disableBoundingBoxesFromEffectLayer: boolean;
  63144. /**
  63145. * An event triggered when the effect layer has been disposed.
  63146. */
  63147. onDisposeObservable: Observable<EffectLayer>;
  63148. /**
  63149. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63150. */
  63151. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63152. /**
  63153. * An event triggered when the generated texture is being merged in the scene.
  63154. */
  63155. onBeforeComposeObservable: Observable<EffectLayer>;
  63156. /**
  63157. * An event triggered when the mesh is rendered into the effect render target.
  63158. */
  63159. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63160. /**
  63161. * An event triggered after the mesh has been rendered into the effect render target.
  63162. */
  63163. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63164. /**
  63165. * An event triggered when the generated texture has been merged in the scene.
  63166. */
  63167. onAfterComposeObservable: Observable<EffectLayer>;
  63168. /**
  63169. * An event triggered when the effect layer changes its size.
  63170. */
  63171. onSizeChangedObservable: Observable<EffectLayer>;
  63172. /** @hidden */
  63173. static _SceneComponentInitialization: (scene: Scene) => void;
  63174. /**
  63175. * Instantiates a new effect Layer and references it in the scene.
  63176. * @param name The name of the layer
  63177. * @param scene The scene to use the layer in
  63178. */
  63179. constructor(
  63180. /** The Friendly of the effect in the scene */
  63181. name: string, scene: Scene);
  63182. /**
  63183. * Get the effect name of the layer.
  63184. * @return The effect name
  63185. */
  63186. abstract getEffectName(): string;
  63187. /**
  63188. * Checks for the readiness of the element composing the layer.
  63189. * @param subMesh the mesh to check for
  63190. * @param useInstances specify whether or not to use instances to render the mesh
  63191. * @return true if ready otherwise, false
  63192. */
  63193. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63194. /**
  63195. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63196. * @returns true if the effect requires stencil during the main canvas render pass.
  63197. */
  63198. abstract needStencil(): boolean;
  63199. /**
  63200. * Create the merge effect. This is the shader use to blit the information back
  63201. * to the main canvas at the end of the scene rendering.
  63202. * @returns The effect containing the shader used to merge the effect on the main canvas
  63203. */
  63204. protected abstract _createMergeEffect(): Effect;
  63205. /**
  63206. * Creates the render target textures and post processes used in the effect layer.
  63207. */
  63208. protected abstract _createTextureAndPostProcesses(): void;
  63209. /**
  63210. * Implementation specific of rendering the generating effect on the main canvas.
  63211. * @param effect The effect used to render through
  63212. */
  63213. protected abstract _internalRender(effect: Effect): void;
  63214. /**
  63215. * Sets the required values for both the emissive texture and and the main color.
  63216. */
  63217. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63218. /**
  63219. * Free any resources and references associated to a mesh.
  63220. * Internal use
  63221. * @param mesh The mesh to free.
  63222. */
  63223. abstract _disposeMesh(mesh: Mesh): void;
  63224. /**
  63225. * Serializes this layer (Glow or Highlight for example)
  63226. * @returns a serialized layer object
  63227. */
  63228. abstract serialize?(): any;
  63229. /**
  63230. * Initializes the effect layer with the required options.
  63231. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63232. */
  63233. protected _init(options: Partial<IEffectLayerOptions>): void;
  63234. /**
  63235. * Generates the index buffer of the full screen quad blending to the main canvas.
  63236. */
  63237. private _generateIndexBuffer;
  63238. /**
  63239. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63240. */
  63241. private _generateVertexBuffer;
  63242. /**
  63243. * Sets the main texture desired size which is the closest power of two
  63244. * of the engine canvas size.
  63245. */
  63246. private _setMainTextureSize;
  63247. /**
  63248. * Creates the main texture for the effect layer.
  63249. */
  63250. protected _createMainTexture(): void;
  63251. /**
  63252. * Adds specific effects defines.
  63253. * @param defines The defines to add specifics to.
  63254. */
  63255. protected _addCustomEffectDefines(defines: string[]): void;
  63256. /**
  63257. * Checks for the readiness of the element composing the layer.
  63258. * @param subMesh the mesh to check for
  63259. * @param useInstances specify whether or not to use instances to render the mesh
  63260. * @param emissiveTexture the associated emissive texture used to generate the glow
  63261. * @return true if ready otherwise, false
  63262. */
  63263. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63264. /**
  63265. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63266. */
  63267. render(): void;
  63268. /**
  63269. * Determine if a given mesh will be used in the current effect.
  63270. * @param mesh mesh to test
  63271. * @returns true if the mesh will be used
  63272. */
  63273. hasMesh(mesh: AbstractMesh): boolean;
  63274. /**
  63275. * Returns true if the layer contains information to display, otherwise false.
  63276. * @returns true if the glow layer should be rendered
  63277. */
  63278. shouldRender(): boolean;
  63279. /**
  63280. * Returns true if the mesh should render, otherwise false.
  63281. * @param mesh The mesh to render
  63282. * @returns true if it should render otherwise false
  63283. */
  63284. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63285. /**
  63286. * Returns true if the mesh can be rendered, otherwise false.
  63287. * @param mesh The mesh to render
  63288. * @param material The material used on the mesh
  63289. * @returns true if it can be rendered otherwise false
  63290. */
  63291. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63292. /**
  63293. * Returns true if the mesh should render, otherwise false.
  63294. * @param mesh The mesh to render
  63295. * @returns true if it should render otherwise false
  63296. */
  63297. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63298. /**
  63299. * Renders the submesh passed in parameter to the generation map.
  63300. */
  63301. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63302. /**
  63303. * Defines whether the current material of the mesh should be use to render the effect.
  63304. * @param mesh defines the current mesh to render
  63305. */
  63306. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63307. /**
  63308. * Rebuild the required buffers.
  63309. * @hidden Internal use only.
  63310. */
  63311. _rebuild(): void;
  63312. /**
  63313. * Dispose only the render target textures and post process.
  63314. */
  63315. private _disposeTextureAndPostProcesses;
  63316. /**
  63317. * Dispose the highlight layer and free resources.
  63318. */
  63319. dispose(): void;
  63320. /**
  63321. * Gets the class name of the effect layer
  63322. * @returns the string with the class name of the effect layer
  63323. */
  63324. getClassName(): string;
  63325. /**
  63326. * Creates an effect layer from parsed effect layer data
  63327. * @param parsedEffectLayer defines effect layer data
  63328. * @param scene defines the current scene
  63329. * @param rootUrl defines the root URL containing the effect layer information
  63330. * @returns a parsed effect Layer
  63331. */
  63332. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63333. }
  63334. }
  63335. declare module BABYLON {
  63336. interface AbstractScene {
  63337. /**
  63338. * The list of effect layers (highlights/glow) added to the scene
  63339. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63340. * @see https://doc.babylonjs.com/how_to/glow_layer
  63341. */
  63342. effectLayers: Array<EffectLayer>;
  63343. /**
  63344. * Removes the given effect layer from this scene.
  63345. * @param toRemove defines the effect layer to remove
  63346. * @returns the index of the removed effect layer
  63347. */
  63348. removeEffectLayer(toRemove: EffectLayer): number;
  63349. /**
  63350. * Adds the given effect layer to this scene
  63351. * @param newEffectLayer defines the effect layer to add
  63352. */
  63353. addEffectLayer(newEffectLayer: EffectLayer): void;
  63354. }
  63355. /**
  63356. * Defines the layer scene component responsible to manage any effect layers
  63357. * in a given scene.
  63358. */
  63359. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63360. /**
  63361. * The component name helpful to identify the component in the list of scene components.
  63362. */
  63363. readonly name: string;
  63364. /**
  63365. * The scene the component belongs to.
  63366. */
  63367. scene: Scene;
  63368. private _engine;
  63369. private _renderEffects;
  63370. private _needStencil;
  63371. private _previousStencilState;
  63372. /**
  63373. * Creates a new instance of the component for the given scene
  63374. * @param scene Defines the scene to register the component in
  63375. */
  63376. constructor(scene: Scene);
  63377. /**
  63378. * Registers the component in a given scene
  63379. */
  63380. register(): void;
  63381. /**
  63382. * Rebuilds the elements related to this component in case of
  63383. * context lost for instance.
  63384. */
  63385. rebuild(): void;
  63386. /**
  63387. * Serializes the component data to the specified json object
  63388. * @param serializationObject The object to serialize to
  63389. */
  63390. serialize(serializationObject: any): void;
  63391. /**
  63392. * Adds all the elements from the container to the scene
  63393. * @param container the container holding the elements
  63394. */
  63395. addFromContainer(container: AbstractScene): void;
  63396. /**
  63397. * Removes all the elements in the container from the scene
  63398. * @param container contains the elements to remove
  63399. * @param dispose if the removed element should be disposed (default: false)
  63400. */
  63401. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63402. /**
  63403. * Disposes the component and the associated resources.
  63404. */
  63405. dispose(): void;
  63406. private _isReadyForMesh;
  63407. private _renderMainTexture;
  63408. private _setStencil;
  63409. private _setStencilBack;
  63410. private _draw;
  63411. private _drawCamera;
  63412. private _drawRenderingGroup;
  63413. }
  63414. }
  63415. declare module BABYLON {
  63416. /** @hidden */
  63417. export var glowMapMergePixelShader: {
  63418. name: string;
  63419. shader: string;
  63420. };
  63421. }
  63422. declare module BABYLON {
  63423. /** @hidden */
  63424. export var glowMapMergeVertexShader: {
  63425. name: string;
  63426. shader: string;
  63427. };
  63428. }
  63429. declare module BABYLON {
  63430. interface AbstractScene {
  63431. /**
  63432. * Return a the first highlight layer of the scene with a given name.
  63433. * @param name The name of the highlight layer to look for.
  63434. * @return The highlight layer if found otherwise null.
  63435. */
  63436. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63437. }
  63438. /**
  63439. * Glow layer options. This helps customizing the behaviour
  63440. * of the glow layer.
  63441. */
  63442. export interface IGlowLayerOptions {
  63443. /**
  63444. * Multiplication factor apply to the canvas size to compute the render target size
  63445. * used to generated the glowing objects (the smaller the faster).
  63446. */
  63447. mainTextureRatio: number;
  63448. /**
  63449. * Enforces a fixed size texture to ensure resize independent blur.
  63450. */
  63451. mainTextureFixedSize?: number;
  63452. /**
  63453. * How big is the kernel of the blur texture.
  63454. */
  63455. blurKernelSize: number;
  63456. /**
  63457. * The camera attached to the layer.
  63458. */
  63459. camera: Nullable<Camera>;
  63460. /**
  63461. * Enable MSAA by choosing the number of samples.
  63462. */
  63463. mainTextureSamples?: number;
  63464. /**
  63465. * The rendering group to draw the layer in.
  63466. */
  63467. renderingGroupId: number;
  63468. }
  63469. /**
  63470. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63471. *
  63472. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63473. *
  63474. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63475. */
  63476. export class GlowLayer extends EffectLayer {
  63477. /**
  63478. * Effect Name of the layer.
  63479. */
  63480. static readonly EffectName: string;
  63481. /**
  63482. * The default blur kernel size used for the glow.
  63483. */
  63484. static DefaultBlurKernelSize: number;
  63485. /**
  63486. * The default texture size ratio used for the glow.
  63487. */
  63488. static DefaultTextureRatio: number;
  63489. /**
  63490. * Sets the kernel size of the blur.
  63491. */
  63492. set blurKernelSize(value: number);
  63493. /**
  63494. * Gets the kernel size of the blur.
  63495. */
  63496. get blurKernelSize(): number;
  63497. /**
  63498. * Sets the glow intensity.
  63499. */
  63500. set intensity(value: number);
  63501. /**
  63502. * Gets the glow intensity.
  63503. */
  63504. get intensity(): number;
  63505. private _options;
  63506. private _intensity;
  63507. private _horizontalBlurPostprocess1;
  63508. private _verticalBlurPostprocess1;
  63509. private _horizontalBlurPostprocess2;
  63510. private _verticalBlurPostprocess2;
  63511. private _blurTexture1;
  63512. private _blurTexture2;
  63513. private _postProcesses1;
  63514. private _postProcesses2;
  63515. private _includedOnlyMeshes;
  63516. private _excludedMeshes;
  63517. private _meshesUsingTheirOwnMaterials;
  63518. /**
  63519. * Callback used to let the user override the color selection on a per mesh basis
  63520. */
  63521. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63522. /**
  63523. * Callback used to let the user override the texture selection on a per mesh basis
  63524. */
  63525. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63526. /**
  63527. * Instantiates a new glow Layer and references it to the scene.
  63528. * @param name The name of the layer
  63529. * @param scene The scene to use the layer in
  63530. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63531. */
  63532. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63533. /**
  63534. * Get the effect name of the layer.
  63535. * @return The effect name
  63536. */
  63537. getEffectName(): string;
  63538. /**
  63539. * Create the merge effect. This is the shader use to blit the information back
  63540. * to the main canvas at the end of the scene rendering.
  63541. */
  63542. protected _createMergeEffect(): Effect;
  63543. /**
  63544. * Creates the render target textures and post processes used in the glow layer.
  63545. */
  63546. protected _createTextureAndPostProcesses(): void;
  63547. /**
  63548. * Checks for the readiness of the element composing the layer.
  63549. * @param subMesh the mesh to check for
  63550. * @param useInstances specify whether or not to use instances to render the mesh
  63551. * @param emissiveTexture the associated emissive texture used to generate the glow
  63552. * @return true if ready otherwise, false
  63553. */
  63554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63555. /**
  63556. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63557. */
  63558. needStencil(): boolean;
  63559. /**
  63560. * Returns true if the mesh can be rendered, otherwise false.
  63561. * @param mesh The mesh to render
  63562. * @param material The material used on the mesh
  63563. * @returns true if it can be rendered otherwise false
  63564. */
  63565. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63566. /**
  63567. * Implementation specific of rendering the generating effect on the main canvas.
  63568. * @param effect The effect used to render through
  63569. */
  63570. protected _internalRender(effect: Effect): void;
  63571. /**
  63572. * Sets the required values for both the emissive texture and and the main color.
  63573. */
  63574. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63575. /**
  63576. * Returns true if the mesh should render, otherwise false.
  63577. * @param mesh The mesh to render
  63578. * @returns true if it should render otherwise false
  63579. */
  63580. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63581. /**
  63582. * Adds specific effects defines.
  63583. * @param defines The defines to add specifics to.
  63584. */
  63585. protected _addCustomEffectDefines(defines: string[]): void;
  63586. /**
  63587. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63588. * @param mesh The mesh to exclude from the glow layer
  63589. */
  63590. addExcludedMesh(mesh: Mesh): void;
  63591. /**
  63592. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63593. * @param mesh The mesh to remove
  63594. */
  63595. removeExcludedMesh(mesh: Mesh): void;
  63596. /**
  63597. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63598. * @param mesh The mesh to include in the glow layer
  63599. */
  63600. addIncludedOnlyMesh(mesh: Mesh): void;
  63601. /**
  63602. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63603. * @param mesh The mesh to remove
  63604. */
  63605. removeIncludedOnlyMesh(mesh: Mesh): void;
  63606. /**
  63607. * Determine if a given mesh will be used in the glow layer
  63608. * @param mesh The mesh to test
  63609. * @returns true if the mesh will be highlighted by the current glow layer
  63610. */
  63611. hasMesh(mesh: AbstractMesh): boolean;
  63612. /**
  63613. * Defines whether the current material of the mesh should be use to render the effect.
  63614. * @param mesh defines the current mesh to render
  63615. */
  63616. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63617. /**
  63618. * Add a mesh to be rendered through its own material and not with emissive only.
  63619. * @param mesh The mesh for which we need to use its material
  63620. */
  63621. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63622. /**
  63623. * Remove a mesh from being rendered through its own material and not with emissive only.
  63624. * @param mesh The mesh for which we need to not use its material
  63625. */
  63626. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63627. /**
  63628. * Free any resources and references associated to a mesh.
  63629. * Internal use
  63630. * @param mesh The mesh to free.
  63631. * @hidden
  63632. */
  63633. _disposeMesh(mesh: Mesh): void;
  63634. /**
  63635. * Gets the class name of the effect layer
  63636. * @returns the string with the class name of the effect layer
  63637. */
  63638. getClassName(): string;
  63639. /**
  63640. * Serializes this glow layer
  63641. * @returns a serialized glow layer object
  63642. */
  63643. serialize(): any;
  63644. /**
  63645. * Creates a Glow Layer from parsed glow layer data
  63646. * @param parsedGlowLayer defines glow layer data
  63647. * @param scene defines the current scene
  63648. * @param rootUrl defines the root URL containing the glow layer information
  63649. * @returns a parsed Glow Layer
  63650. */
  63651. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63652. }
  63653. }
  63654. declare module BABYLON {
  63655. /** @hidden */
  63656. export var glowBlurPostProcessPixelShader: {
  63657. name: string;
  63658. shader: string;
  63659. };
  63660. }
  63661. declare module BABYLON {
  63662. interface AbstractScene {
  63663. /**
  63664. * Return a the first highlight layer of the scene with a given name.
  63665. * @param name The name of the highlight layer to look for.
  63666. * @return The highlight layer if found otherwise null.
  63667. */
  63668. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63669. }
  63670. /**
  63671. * Highlight layer options. This helps customizing the behaviour
  63672. * of the highlight layer.
  63673. */
  63674. export interface IHighlightLayerOptions {
  63675. /**
  63676. * Multiplication factor apply to the canvas size to compute the render target size
  63677. * used to generated the glowing objects (the smaller the faster).
  63678. */
  63679. mainTextureRatio: number;
  63680. /**
  63681. * Enforces a fixed size texture to ensure resize independent blur.
  63682. */
  63683. mainTextureFixedSize?: number;
  63684. /**
  63685. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63686. * of the picture to blur (the smaller the faster).
  63687. */
  63688. blurTextureSizeRatio: number;
  63689. /**
  63690. * How big in texel of the blur texture is the vertical blur.
  63691. */
  63692. blurVerticalSize: number;
  63693. /**
  63694. * How big in texel of the blur texture is the horizontal blur.
  63695. */
  63696. blurHorizontalSize: number;
  63697. /**
  63698. * Alpha blending mode used to apply the blur. Default is combine.
  63699. */
  63700. alphaBlendingMode: number;
  63701. /**
  63702. * The camera attached to the layer.
  63703. */
  63704. camera: Nullable<Camera>;
  63705. /**
  63706. * Should we display highlight as a solid stroke?
  63707. */
  63708. isStroke?: boolean;
  63709. /**
  63710. * The rendering group to draw the layer in.
  63711. */
  63712. renderingGroupId: number;
  63713. }
  63714. /**
  63715. * The highlight layer Helps adding a glow effect around a mesh.
  63716. *
  63717. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63718. * glowy meshes to your scene.
  63719. *
  63720. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63721. */
  63722. export class HighlightLayer extends EffectLayer {
  63723. name: string;
  63724. /**
  63725. * Effect Name of the highlight layer.
  63726. */
  63727. static readonly EffectName: string;
  63728. /**
  63729. * The neutral color used during the preparation of the glow effect.
  63730. * This is black by default as the blend operation is a blend operation.
  63731. */
  63732. static NeutralColor: Color4;
  63733. /**
  63734. * Stencil value used for glowing meshes.
  63735. */
  63736. static GlowingMeshStencilReference: number;
  63737. /**
  63738. * Stencil value used for the other meshes in the scene.
  63739. */
  63740. static NormalMeshStencilReference: number;
  63741. /**
  63742. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63743. */
  63744. innerGlow: boolean;
  63745. /**
  63746. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63747. */
  63748. outerGlow: boolean;
  63749. /**
  63750. * Specifies the horizontal size of the blur.
  63751. */
  63752. set blurHorizontalSize(value: number);
  63753. /**
  63754. * Specifies the vertical size of the blur.
  63755. */
  63756. set blurVerticalSize(value: number);
  63757. /**
  63758. * Gets the horizontal size of the blur.
  63759. */
  63760. get blurHorizontalSize(): number;
  63761. /**
  63762. * Gets the vertical size of the blur.
  63763. */
  63764. get blurVerticalSize(): number;
  63765. /**
  63766. * An event triggered when the highlight layer is being blurred.
  63767. */
  63768. onBeforeBlurObservable: Observable<HighlightLayer>;
  63769. /**
  63770. * An event triggered when the highlight layer has been blurred.
  63771. */
  63772. onAfterBlurObservable: Observable<HighlightLayer>;
  63773. private _instanceGlowingMeshStencilReference;
  63774. private _options;
  63775. private _downSamplePostprocess;
  63776. private _horizontalBlurPostprocess;
  63777. private _verticalBlurPostprocess;
  63778. private _blurTexture;
  63779. private _meshes;
  63780. private _excludedMeshes;
  63781. /**
  63782. * Instantiates a new highlight Layer and references it to the scene..
  63783. * @param name The name of the layer
  63784. * @param scene The scene to use the layer in
  63785. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63786. */
  63787. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63788. /**
  63789. * Get the effect name of the layer.
  63790. * @return The effect name
  63791. */
  63792. getEffectName(): string;
  63793. /**
  63794. * Create the merge effect. This is the shader use to blit the information back
  63795. * to the main canvas at the end of the scene rendering.
  63796. */
  63797. protected _createMergeEffect(): Effect;
  63798. /**
  63799. * Creates the render target textures and post processes used in the highlight layer.
  63800. */
  63801. protected _createTextureAndPostProcesses(): void;
  63802. /**
  63803. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63804. */
  63805. needStencil(): boolean;
  63806. /**
  63807. * Checks for the readiness of the element composing the layer.
  63808. * @param subMesh the mesh to check for
  63809. * @param useInstances specify wether or not to use instances to render the mesh
  63810. * @param emissiveTexture the associated emissive texture used to generate the glow
  63811. * @return true if ready otherwise, false
  63812. */
  63813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63814. /**
  63815. * Implementation specific of rendering the generating effect on the main canvas.
  63816. * @param effect The effect used to render through
  63817. */
  63818. protected _internalRender(effect: Effect): void;
  63819. /**
  63820. * Returns true if the layer contains information to display, otherwise false.
  63821. */
  63822. shouldRender(): boolean;
  63823. /**
  63824. * Returns true if the mesh should render, otherwise false.
  63825. * @param mesh The mesh to render
  63826. * @returns true if it should render otherwise false
  63827. */
  63828. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63829. /**
  63830. * Returns true if the mesh can be rendered, otherwise false.
  63831. * @param mesh The mesh to render
  63832. * @param material The material used on the mesh
  63833. * @returns true if it can be rendered otherwise false
  63834. */
  63835. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63836. /**
  63837. * Adds specific effects defines.
  63838. * @param defines The defines to add specifics to.
  63839. */
  63840. protected _addCustomEffectDefines(defines: string[]): void;
  63841. /**
  63842. * Sets the required values for both the emissive texture and and the main color.
  63843. */
  63844. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63845. /**
  63846. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63847. * @param mesh The mesh to exclude from the highlight layer
  63848. */
  63849. addExcludedMesh(mesh: Mesh): void;
  63850. /**
  63851. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63852. * @param mesh The mesh to highlight
  63853. */
  63854. removeExcludedMesh(mesh: Mesh): void;
  63855. /**
  63856. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63857. * @param mesh mesh to test
  63858. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63859. */
  63860. hasMesh(mesh: AbstractMesh): boolean;
  63861. /**
  63862. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63863. * @param mesh The mesh to highlight
  63864. * @param color The color of the highlight
  63865. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63866. */
  63867. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63868. /**
  63869. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63870. * @param mesh The mesh to highlight
  63871. */
  63872. removeMesh(mesh: Mesh): void;
  63873. /**
  63874. * Remove all the meshes currently referenced in the highlight layer
  63875. */
  63876. removeAllMeshes(): void;
  63877. /**
  63878. * Force the stencil to the normal expected value for none glowing parts
  63879. */
  63880. private _defaultStencilReference;
  63881. /**
  63882. * Free any resources and references associated to a mesh.
  63883. * Internal use
  63884. * @param mesh The mesh to free.
  63885. * @hidden
  63886. */
  63887. _disposeMesh(mesh: Mesh): void;
  63888. /**
  63889. * Dispose the highlight layer and free resources.
  63890. */
  63891. dispose(): void;
  63892. /**
  63893. * Gets the class name of the effect layer
  63894. * @returns the string with the class name of the effect layer
  63895. */
  63896. getClassName(): string;
  63897. /**
  63898. * Serializes this Highlight layer
  63899. * @returns a serialized Highlight layer object
  63900. */
  63901. serialize(): any;
  63902. /**
  63903. * Creates a Highlight layer from parsed Highlight layer data
  63904. * @param parsedHightlightLayer defines the Highlight layer data
  63905. * @param scene defines the current scene
  63906. * @param rootUrl defines the root URL containing the Highlight layer information
  63907. * @returns a parsed Highlight layer
  63908. */
  63909. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63910. }
  63911. }
  63912. declare module BABYLON {
  63913. interface AbstractScene {
  63914. /**
  63915. * The list of layers (background and foreground) of the scene
  63916. */
  63917. layers: Array<Layer>;
  63918. }
  63919. /**
  63920. * Defines the layer scene component responsible to manage any layers
  63921. * in a given scene.
  63922. */
  63923. export class LayerSceneComponent implements ISceneComponent {
  63924. /**
  63925. * The component name helpful to identify the component in the list of scene components.
  63926. */
  63927. readonly name: string;
  63928. /**
  63929. * The scene the component belongs to.
  63930. */
  63931. scene: Scene;
  63932. private _engine;
  63933. /**
  63934. * Creates a new instance of the component for the given scene
  63935. * @param scene Defines the scene to register the component in
  63936. */
  63937. constructor(scene: Scene);
  63938. /**
  63939. * Registers the component in a given scene
  63940. */
  63941. register(): void;
  63942. /**
  63943. * Rebuilds the elements related to this component in case of
  63944. * context lost for instance.
  63945. */
  63946. rebuild(): void;
  63947. /**
  63948. * Disposes the component and the associated resources.
  63949. */
  63950. dispose(): void;
  63951. private _draw;
  63952. private _drawCameraPredicate;
  63953. private _drawCameraBackground;
  63954. private _drawCameraForeground;
  63955. private _drawRenderTargetPredicate;
  63956. private _drawRenderTargetBackground;
  63957. private _drawRenderTargetForeground;
  63958. /**
  63959. * Adds all the elements from the container to the scene
  63960. * @param container the container holding the elements
  63961. */
  63962. addFromContainer(container: AbstractScene): void;
  63963. /**
  63964. * Removes all the elements in the container from the scene
  63965. * @param container contains the elements to remove
  63966. * @param dispose if the removed element should be disposed (default: false)
  63967. */
  63968. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63969. }
  63970. }
  63971. declare module BABYLON {
  63972. /** @hidden */
  63973. export var layerPixelShader: {
  63974. name: string;
  63975. shader: string;
  63976. };
  63977. }
  63978. declare module BABYLON {
  63979. /** @hidden */
  63980. export var layerVertexShader: {
  63981. name: string;
  63982. shader: string;
  63983. };
  63984. }
  63985. declare module BABYLON {
  63986. /**
  63987. * This represents a full screen 2d layer.
  63988. * This can be useful to display a picture in the background of your scene for instance.
  63989. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63990. */
  63991. export class Layer {
  63992. /**
  63993. * Define the name of the layer.
  63994. */
  63995. name: string;
  63996. /**
  63997. * Define the texture the layer should display.
  63998. */
  63999. texture: Nullable<Texture>;
  64000. /**
  64001. * Is the layer in background or foreground.
  64002. */
  64003. isBackground: boolean;
  64004. /**
  64005. * Define the color of the layer (instead of texture).
  64006. */
  64007. color: Color4;
  64008. /**
  64009. * Define the scale of the layer in order to zoom in out of the texture.
  64010. */
  64011. scale: Vector2;
  64012. /**
  64013. * Define an offset for the layer in order to shift the texture.
  64014. */
  64015. offset: Vector2;
  64016. /**
  64017. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64018. */
  64019. alphaBlendingMode: number;
  64020. /**
  64021. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64022. * Alpha test will not mix with the background color in case of transparency.
  64023. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64024. */
  64025. alphaTest: boolean;
  64026. /**
  64027. * Define a mask to restrict the layer to only some of the scene cameras.
  64028. */
  64029. layerMask: number;
  64030. /**
  64031. * Define the list of render target the layer is visible into.
  64032. */
  64033. renderTargetTextures: RenderTargetTexture[];
  64034. /**
  64035. * Define if the layer is only used in renderTarget or if it also
  64036. * renders in the main frame buffer of the canvas.
  64037. */
  64038. renderOnlyInRenderTargetTextures: boolean;
  64039. private _scene;
  64040. private _vertexBuffers;
  64041. private _indexBuffer;
  64042. private _effect;
  64043. private _previousDefines;
  64044. /**
  64045. * An event triggered when the layer is disposed.
  64046. */
  64047. onDisposeObservable: Observable<Layer>;
  64048. private _onDisposeObserver;
  64049. /**
  64050. * Back compatibility with callback before the onDisposeObservable existed.
  64051. * The set callback will be triggered when the layer has been disposed.
  64052. */
  64053. set onDispose(callback: () => void);
  64054. /**
  64055. * An event triggered before rendering the scene
  64056. */
  64057. onBeforeRenderObservable: Observable<Layer>;
  64058. private _onBeforeRenderObserver;
  64059. /**
  64060. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64061. * The set callback will be triggered just before rendering the layer.
  64062. */
  64063. set onBeforeRender(callback: () => void);
  64064. /**
  64065. * An event triggered after rendering the scene
  64066. */
  64067. onAfterRenderObservable: Observable<Layer>;
  64068. private _onAfterRenderObserver;
  64069. /**
  64070. * Back compatibility with callback before the onAfterRenderObservable existed.
  64071. * The set callback will be triggered just after rendering the layer.
  64072. */
  64073. set onAfterRender(callback: () => void);
  64074. /**
  64075. * Instantiates a new layer.
  64076. * This represents a full screen 2d layer.
  64077. * This can be useful to display a picture in the background of your scene for instance.
  64078. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64079. * @param name Define the name of the layer in the scene
  64080. * @param imgUrl Define the url of the texture to display in the layer
  64081. * @param scene Define the scene the layer belongs to
  64082. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64083. * @param color Defines a color for the layer
  64084. */
  64085. constructor(
  64086. /**
  64087. * Define the name of the layer.
  64088. */
  64089. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64090. private _createIndexBuffer;
  64091. /** @hidden */
  64092. _rebuild(): void;
  64093. /**
  64094. * Renders the layer in the scene.
  64095. */
  64096. render(): void;
  64097. /**
  64098. * Disposes and releases the associated resources.
  64099. */
  64100. dispose(): void;
  64101. }
  64102. }
  64103. declare module BABYLON {
  64104. /** @hidden */
  64105. export var lensFlarePixelShader: {
  64106. name: string;
  64107. shader: string;
  64108. };
  64109. }
  64110. declare module BABYLON {
  64111. /** @hidden */
  64112. export var lensFlareVertexShader: {
  64113. name: string;
  64114. shader: string;
  64115. };
  64116. }
  64117. declare module BABYLON {
  64118. /**
  64119. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64120. * It is usually composed of several `lensFlare`.
  64121. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64122. */
  64123. export class LensFlareSystem {
  64124. /**
  64125. * Define the name of the lens flare system
  64126. */
  64127. name: string;
  64128. /**
  64129. * List of lens flares used in this system.
  64130. */
  64131. lensFlares: LensFlare[];
  64132. /**
  64133. * Define a limit from the border the lens flare can be visible.
  64134. */
  64135. borderLimit: number;
  64136. /**
  64137. * Define a viewport border we do not want to see the lens flare in.
  64138. */
  64139. viewportBorder: number;
  64140. /**
  64141. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64142. */
  64143. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64144. /**
  64145. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64146. */
  64147. layerMask: number;
  64148. /**
  64149. * Define the id of the lens flare system in the scene.
  64150. * (equal to name by default)
  64151. */
  64152. id: string;
  64153. private _scene;
  64154. private _emitter;
  64155. private _vertexBuffers;
  64156. private _indexBuffer;
  64157. private _effect;
  64158. private _positionX;
  64159. private _positionY;
  64160. private _isEnabled;
  64161. /** @hidden */
  64162. static _SceneComponentInitialization: (scene: Scene) => void;
  64163. /**
  64164. * Instantiates a lens flare system.
  64165. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64166. * It is usually composed of several `lensFlare`.
  64167. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64168. * @param name Define the name of the lens flare system in the scene
  64169. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64170. * @param scene Define the scene the lens flare system belongs to
  64171. */
  64172. constructor(
  64173. /**
  64174. * Define the name of the lens flare system
  64175. */
  64176. name: string, emitter: any, scene: Scene);
  64177. /**
  64178. * Define if the lens flare system is enabled.
  64179. */
  64180. get isEnabled(): boolean;
  64181. set isEnabled(value: boolean);
  64182. /**
  64183. * Get the scene the effects belongs to.
  64184. * @returns the scene holding the lens flare system
  64185. */
  64186. getScene(): Scene;
  64187. /**
  64188. * Get the emitter of the lens flare system.
  64189. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64190. * @returns the emitter of the lens flare system
  64191. */
  64192. getEmitter(): any;
  64193. /**
  64194. * Set the emitter of the lens flare system.
  64195. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64196. * @param newEmitter Define the new emitter of the system
  64197. */
  64198. setEmitter(newEmitter: any): void;
  64199. /**
  64200. * Get the lens flare system emitter position.
  64201. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64202. * @returns the position
  64203. */
  64204. getEmitterPosition(): Vector3;
  64205. /**
  64206. * @hidden
  64207. */
  64208. computeEffectivePosition(globalViewport: Viewport): boolean;
  64209. /** @hidden */
  64210. _isVisible(): boolean;
  64211. /**
  64212. * @hidden
  64213. */
  64214. render(): boolean;
  64215. /**
  64216. * Dispose and release the lens flare with its associated resources.
  64217. */
  64218. dispose(): void;
  64219. /**
  64220. * Parse a lens flare system from a JSON representation
  64221. * @param parsedLensFlareSystem Define the JSON to parse
  64222. * @param scene Define the scene the parsed system should be instantiated in
  64223. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64224. * @returns the parsed system
  64225. */
  64226. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64227. /**
  64228. * Serialize the current Lens Flare System into a JSON representation.
  64229. * @returns the serialized JSON
  64230. */
  64231. serialize(): any;
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /**
  64236. * This represents one of the lens effect in a `lensFlareSystem`.
  64237. * It controls one of the individual texture used in the effect.
  64238. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64239. */
  64240. export class LensFlare {
  64241. /**
  64242. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64243. */
  64244. size: number;
  64245. /**
  64246. * 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.
  64247. */
  64248. position: number;
  64249. /**
  64250. * Define the lens color.
  64251. */
  64252. color: Color3;
  64253. /**
  64254. * Define the lens texture.
  64255. */
  64256. texture: Nullable<Texture>;
  64257. /**
  64258. * Define the alpha mode to render this particular lens.
  64259. */
  64260. alphaMode: number;
  64261. private _system;
  64262. /**
  64263. * Creates a new Lens Flare.
  64264. * This represents one of the lens effect in a `lensFlareSystem`.
  64265. * It controls one of the individual texture used in the effect.
  64266. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64267. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64268. * @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.
  64269. * @param color Define the lens color
  64270. * @param imgUrl Define the lens texture url
  64271. * @param system Define the `lensFlareSystem` this flare is part of
  64272. * @returns The newly created Lens Flare
  64273. */
  64274. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64275. /**
  64276. * Instantiates a new Lens Flare.
  64277. * This represents one of the lens effect in a `lensFlareSystem`.
  64278. * It controls one of the individual texture used in the effect.
  64279. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64280. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64281. * @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.
  64282. * @param color Define the lens color
  64283. * @param imgUrl Define the lens texture url
  64284. * @param system Define the `lensFlareSystem` this flare is part of
  64285. */
  64286. constructor(
  64287. /**
  64288. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64289. */
  64290. size: number,
  64291. /**
  64292. * 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.
  64293. */
  64294. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64295. /**
  64296. * Dispose and release the lens flare with its associated resources.
  64297. */
  64298. dispose(): void;
  64299. }
  64300. }
  64301. declare module BABYLON {
  64302. interface AbstractScene {
  64303. /**
  64304. * The list of lens flare system added to the scene
  64305. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64306. */
  64307. lensFlareSystems: Array<LensFlareSystem>;
  64308. /**
  64309. * Removes the given lens flare system from this scene.
  64310. * @param toRemove The lens flare system to remove
  64311. * @returns The index of the removed lens flare system
  64312. */
  64313. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64314. /**
  64315. * Adds the given lens flare system to this scene
  64316. * @param newLensFlareSystem The lens flare system to add
  64317. */
  64318. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64319. /**
  64320. * Gets a lens flare system using its name
  64321. * @param name defines the name to look for
  64322. * @returns the lens flare system or null if not found
  64323. */
  64324. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64325. /**
  64326. * Gets a lens flare system using its id
  64327. * @param id defines the id to look for
  64328. * @returns the lens flare system or null if not found
  64329. */
  64330. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64331. }
  64332. /**
  64333. * Defines the lens flare scene component responsible to manage any lens flares
  64334. * in a given scene.
  64335. */
  64336. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64337. /**
  64338. * The component name helpful to identify the component in the list of scene components.
  64339. */
  64340. readonly name: string;
  64341. /**
  64342. * The scene the component belongs to.
  64343. */
  64344. scene: Scene;
  64345. /**
  64346. * Creates a new instance of the component for the given scene
  64347. * @param scene Defines the scene to register the component in
  64348. */
  64349. constructor(scene: Scene);
  64350. /**
  64351. * Registers the component in a given scene
  64352. */
  64353. register(): void;
  64354. /**
  64355. * Rebuilds the elements related to this component in case of
  64356. * context lost for instance.
  64357. */
  64358. rebuild(): void;
  64359. /**
  64360. * Adds all the elements from the container to the scene
  64361. * @param container the container holding the elements
  64362. */
  64363. addFromContainer(container: AbstractScene): void;
  64364. /**
  64365. * Removes all the elements in the container from the scene
  64366. * @param container contains the elements to remove
  64367. * @param dispose if the removed element should be disposed (default: false)
  64368. */
  64369. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64370. /**
  64371. * Serializes the component data to the specified json object
  64372. * @param serializationObject The object to serialize to
  64373. */
  64374. serialize(serializationObject: any): void;
  64375. /**
  64376. * Disposes the component and the associated resources.
  64377. */
  64378. dispose(): void;
  64379. private _draw;
  64380. }
  64381. }
  64382. declare module BABYLON {
  64383. /** @hidden */
  64384. export var depthPixelShader: {
  64385. name: string;
  64386. shader: string;
  64387. };
  64388. }
  64389. declare module BABYLON {
  64390. /** @hidden */
  64391. export var depthVertexShader: {
  64392. name: string;
  64393. shader: string;
  64394. };
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * This represents a depth renderer in Babylon.
  64399. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64400. */
  64401. export class DepthRenderer {
  64402. private _scene;
  64403. private _depthMap;
  64404. private _effect;
  64405. private readonly _storeNonLinearDepth;
  64406. private readonly _clearColor;
  64407. /** Get if the depth renderer is using packed depth or not */
  64408. readonly isPacked: boolean;
  64409. private _cachedDefines;
  64410. private _camera;
  64411. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64412. enabled: boolean;
  64413. /**
  64414. * Specifies that the depth renderer will only be used within
  64415. * the camera it is created for.
  64416. * This can help forcing its rendering during the camera processing.
  64417. */
  64418. useOnlyInActiveCamera: boolean;
  64419. /** @hidden */
  64420. static _SceneComponentInitialization: (scene: Scene) => void;
  64421. /**
  64422. * Instantiates a depth renderer
  64423. * @param scene The scene the renderer belongs to
  64424. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64425. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64426. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64427. */
  64428. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64429. /**
  64430. * Creates the depth rendering effect and checks if the effect is ready.
  64431. * @param subMesh The submesh to be used to render the depth map of
  64432. * @param useInstances If multiple world instances should be used
  64433. * @returns if the depth renderer is ready to render the depth map
  64434. */
  64435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64436. /**
  64437. * Gets the texture which the depth map will be written to.
  64438. * @returns The depth map texture
  64439. */
  64440. getDepthMap(): RenderTargetTexture;
  64441. /**
  64442. * Disposes of the depth renderer.
  64443. */
  64444. dispose(): void;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /** @hidden */
  64449. export var minmaxReduxPixelShader: {
  64450. name: string;
  64451. shader: string;
  64452. };
  64453. }
  64454. declare module BABYLON {
  64455. /**
  64456. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64457. * and maximum values from all values of the texture.
  64458. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64459. * The source values are read from the red channel of the texture.
  64460. */
  64461. export class MinMaxReducer {
  64462. /**
  64463. * Observable triggered when the computation has been performed
  64464. */
  64465. onAfterReductionPerformed: Observable<{
  64466. min: number;
  64467. max: number;
  64468. }>;
  64469. protected _camera: Camera;
  64470. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64471. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64472. protected _postProcessManager: PostProcessManager;
  64473. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64474. protected _forceFullscreenViewport: boolean;
  64475. /**
  64476. * Creates a min/max reducer
  64477. * @param camera The camera to use for the post processes
  64478. */
  64479. constructor(camera: Camera);
  64480. /**
  64481. * Gets the texture used to read the values from.
  64482. */
  64483. get sourceTexture(): Nullable<RenderTargetTexture>;
  64484. /**
  64485. * Sets the source texture to read the values from.
  64486. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64487. * because in such textures '1' value must not be taken into account to compute the maximum
  64488. * as this value is used to clear the texture.
  64489. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64490. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64491. * @param depthRedux Indicates if the texture is a depth texture or not
  64492. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64493. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64494. */
  64495. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64496. /**
  64497. * Defines the refresh rate of the computation.
  64498. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64499. */
  64500. get refreshRate(): number;
  64501. set refreshRate(value: number);
  64502. protected _activated: boolean;
  64503. /**
  64504. * Gets the activation status of the reducer
  64505. */
  64506. get activated(): boolean;
  64507. /**
  64508. * Activates the reduction computation.
  64509. * When activated, the observers registered in onAfterReductionPerformed are
  64510. * called after the computation is performed
  64511. */
  64512. activate(): void;
  64513. /**
  64514. * Deactivates the reduction computation.
  64515. */
  64516. deactivate(): void;
  64517. /**
  64518. * Disposes the min/max reducer
  64519. * @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.
  64520. */
  64521. dispose(disposeAll?: boolean): void;
  64522. }
  64523. }
  64524. declare module BABYLON {
  64525. /**
  64526. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64527. */
  64528. export class DepthReducer extends MinMaxReducer {
  64529. private _depthRenderer;
  64530. private _depthRendererId;
  64531. /**
  64532. * Gets the depth renderer used for the computation.
  64533. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64534. */
  64535. get depthRenderer(): Nullable<DepthRenderer>;
  64536. /**
  64537. * Creates a depth reducer
  64538. * @param camera The camera used to render the depth texture
  64539. */
  64540. constructor(camera: Camera);
  64541. /**
  64542. * Sets the depth renderer to use to generate the depth map
  64543. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64544. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64545. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64546. */
  64547. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64548. /** @hidden */
  64549. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64550. /**
  64551. * Activates the reduction computation.
  64552. * When activated, the observers registered in onAfterReductionPerformed are
  64553. * called after the computation is performed
  64554. */
  64555. activate(): void;
  64556. /**
  64557. * Deactivates the reduction computation.
  64558. */
  64559. deactivate(): void;
  64560. /**
  64561. * Disposes the depth reducer
  64562. * @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.
  64563. */
  64564. dispose(disposeAll?: boolean): void;
  64565. }
  64566. }
  64567. declare module BABYLON {
  64568. /**
  64569. * A CSM implementation allowing casting shadows on large scenes.
  64570. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64571. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64572. */
  64573. export class CascadedShadowGenerator extends ShadowGenerator {
  64574. private static readonly frustumCornersNDCSpace;
  64575. /**
  64576. * Name of the CSM class
  64577. */
  64578. static CLASSNAME: string;
  64579. /**
  64580. * Defines the default number of cascades used by the CSM.
  64581. */
  64582. static readonly DEFAULT_CASCADES_COUNT: number;
  64583. /**
  64584. * Defines the minimum number of cascades used by the CSM.
  64585. */
  64586. static readonly MIN_CASCADES_COUNT: number;
  64587. /**
  64588. * Defines the maximum number of cascades used by the CSM.
  64589. */
  64590. static readonly MAX_CASCADES_COUNT: number;
  64591. protected _validateFilter(filter: number): number;
  64592. /**
  64593. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64594. */
  64595. penumbraDarkness: number;
  64596. private _numCascades;
  64597. /**
  64598. * Gets or set the number of cascades used by the CSM.
  64599. */
  64600. get numCascades(): number;
  64601. set numCascades(value: number);
  64602. /**
  64603. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64604. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64605. */
  64606. stabilizeCascades: boolean;
  64607. private _freezeShadowCastersBoundingInfo;
  64608. private _freezeShadowCastersBoundingInfoObservable;
  64609. /**
  64610. * Enables or disables the shadow casters bounding info computation.
  64611. * If your shadow casters don't move, you can disable this feature.
  64612. * If it is enabled, the bounding box computation is done every frame.
  64613. */
  64614. get freezeShadowCastersBoundingInfo(): boolean;
  64615. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64616. private _scbiMin;
  64617. private _scbiMax;
  64618. protected _computeShadowCastersBoundingInfo(): void;
  64619. protected _shadowCastersBoundingInfo: BoundingInfo;
  64620. /**
  64621. * Gets or sets the shadow casters bounding info.
  64622. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64623. * so that the system won't overwrite the bounds you provide
  64624. */
  64625. get shadowCastersBoundingInfo(): BoundingInfo;
  64626. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64627. protected _breaksAreDirty: boolean;
  64628. protected _minDistance: number;
  64629. protected _maxDistance: number;
  64630. /**
  64631. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64632. *
  64633. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64634. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64635. * @param min minimal distance for the breaks (default to 0.)
  64636. * @param max maximal distance for the breaks (default to 1.)
  64637. */
  64638. setMinMaxDistance(min: number, max: number): void;
  64639. /** Gets the minimal distance used in the cascade break computation */
  64640. get minDistance(): number;
  64641. /** Gets the maximal distance used in the cascade break computation */
  64642. get maxDistance(): number;
  64643. /**
  64644. * Gets the class name of that object
  64645. * @returns "CascadedShadowGenerator"
  64646. */
  64647. getClassName(): string;
  64648. private _cascadeMinExtents;
  64649. private _cascadeMaxExtents;
  64650. /**
  64651. * Gets a cascade minimum extents
  64652. * @param cascadeIndex index of the cascade
  64653. * @returns the minimum cascade extents
  64654. */
  64655. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64656. /**
  64657. * Gets a cascade maximum extents
  64658. * @param cascadeIndex index of the cascade
  64659. * @returns the maximum cascade extents
  64660. */
  64661. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64662. private _cascades;
  64663. private _currentLayer;
  64664. private _viewSpaceFrustumsZ;
  64665. private _viewMatrices;
  64666. private _projectionMatrices;
  64667. private _transformMatrices;
  64668. private _transformMatricesAsArray;
  64669. private _frustumLengths;
  64670. private _lightSizeUVCorrection;
  64671. private _depthCorrection;
  64672. private _frustumCornersWorldSpace;
  64673. private _frustumCenter;
  64674. private _shadowCameraPos;
  64675. private _shadowMaxZ;
  64676. /**
  64677. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64678. * It defaults to camera.maxZ
  64679. */
  64680. get shadowMaxZ(): number;
  64681. /**
  64682. * Sets the shadow max z distance.
  64683. */
  64684. set shadowMaxZ(value: number);
  64685. protected _debug: boolean;
  64686. /**
  64687. * Gets or sets the debug flag.
  64688. * When enabled, the cascades are materialized by different colors on the screen.
  64689. */
  64690. get debug(): boolean;
  64691. set debug(dbg: boolean);
  64692. private _depthClamp;
  64693. /**
  64694. * Gets or sets the depth clamping value.
  64695. *
  64696. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64697. * to account for the shadow casters far away.
  64698. *
  64699. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64700. */
  64701. get depthClamp(): boolean;
  64702. set depthClamp(value: boolean);
  64703. private _cascadeBlendPercentage;
  64704. /**
  64705. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64706. * It defaults to 0.1 (10% blending).
  64707. */
  64708. get cascadeBlendPercentage(): number;
  64709. set cascadeBlendPercentage(value: number);
  64710. private _lambda;
  64711. /**
  64712. * Gets or set the lambda parameter.
  64713. * This parameter is used to split the camera frustum and create the cascades.
  64714. * 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.
  64715. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64716. */
  64717. get lambda(): number;
  64718. set lambda(value: number);
  64719. /**
  64720. * Gets the view matrix corresponding to a given cascade
  64721. * @param cascadeNum cascade to retrieve the view matrix from
  64722. * @returns the cascade view matrix
  64723. */
  64724. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64725. /**
  64726. * Gets the projection matrix corresponding to a given cascade
  64727. * @param cascadeNum cascade to retrieve the projection matrix from
  64728. * @returns the cascade projection matrix
  64729. */
  64730. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64731. /**
  64732. * Gets the transformation matrix corresponding to a given cascade
  64733. * @param cascadeNum cascade to retrieve the transformation matrix from
  64734. * @returns the cascade transformation matrix
  64735. */
  64736. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64737. private _depthRenderer;
  64738. /**
  64739. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64740. *
  64741. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64742. *
  64743. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64744. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64745. * @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
  64746. */
  64747. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64748. private _depthReducer;
  64749. private _autoCalcDepthBounds;
  64750. /**
  64751. * Gets or sets the autoCalcDepthBounds property.
  64752. *
  64753. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64754. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64755. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64756. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64757. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64758. */
  64759. get autoCalcDepthBounds(): boolean;
  64760. set autoCalcDepthBounds(value: boolean);
  64761. /**
  64762. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64763. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64764. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64765. * for setting the refresh rate on the renderer yourself!
  64766. */
  64767. get autoCalcDepthBoundsRefreshRate(): number;
  64768. set autoCalcDepthBoundsRefreshRate(value: number);
  64769. /**
  64770. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64771. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64772. * you change the camera near/far planes!
  64773. */
  64774. splitFrustum(): void;
  64775. private _splitFrustum;
  64776. private _computeMatrices;
  64777. private _computeFrustumInWorldSpace;
  64778. private _computeCascadeFrustum;
  64779. /**
  64780. * Support test.
  64781. */
  64782. static get IsSupported(): boolean;
  64783. /** @hidden */
  64784. static _SceneComponentInitialization: (scene: Scene) => void;
  64785. /**
  64786. * Creates a Cascaded Shadow Generator object.
  64787. * A ShadowGenerator is the required tool to use the shadows.
  64788. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64789. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64790. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64791. * @param light The directional light object generating the shadows.
  64792. * @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.
  64793. */
  64794. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64795. protected _initializeGenerator(): void;
  64796. protected _createTargetRenderTexture(): void;
  64797. protected _initializeShadowMap(): void;
  64798. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64799. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64800. /**
  64801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64802. * @param defines Defines of the material we want to update
  64803. * @param lightIndex Index of the light in the enabled light list of the material
  64804. */
  64805. prepareDefines(defines: any, lightIndex: number): void;
  64806. /**
  64807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64808. * defined in the generator but impacting the effect).
  64809. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64810. * @param effect The effect we are binfing the information for
  64811. */
  64812. bindShadowLight(lightIndex: string, effect: Effect): void;
  64813. /**
  64814. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64815. * (eq to view projection * shadow projection matrices)
  64816. * @returns The transform matrix used to create the shadow map
  64817. */
  64818. getTransformMatrix(): Matrix;
  64819. /**
  64820. * Disposes the ShadowGenerator.
  64821. * Returns nothing.
  64822. */
  64823. dispose(): void;
  64824. /**
  64825. * Serializes the shadow generator setup to a json object.
  64826. * @returns The serialized JSON object
  64827. */
  64828. serialize(): any;
  64829. /**
  64830. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64831. * @param parsedShadowGenerator The JSON object to parse
  64832. * @param scene The scene to create the shadow map for
  64833. * @returns The parsed shadow generator
  64834. */
  64835. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64836. }
  64837. }
  64838. declare module BABYLON {
  64839. /**
  64840. * Defines the shadow generator component responsible to manage any shadow generators
  64841. * in a given scene.
  64842. */
  64843. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64844. /**
  64845. * The component name helpful to identify the component in the list of scene components.
  64846. */
  64847. readonly name: string;
  64848. /**
  64849. * The scene the component belongs to.
  64850. */
  64851. scene: Scene;
  64852. /**
  64853. * Creates a new instance of the component for the given scene
  64854. * @param scene Defines the scene to register the component in
  64855. */
  64856. constructor(scene: Scene);
  64857. /**
  64858. * Registers the component in a given scene
  64859. */
  64860. register(): void;
  64861. /**
  64862. * Rebuilds the elements related to this component in case of
  64863. * context lost for instance.
  64864. */
  64865. rebuild(): void;
  64866. /**
  64867. * Serializes the component data to the specified json object
  64868. * @param serializationObject The object to serialize to
  64869. */
  64870. serialize(serializationObject: any): void;
  64871. /**
  64872. * Adds all the elements from the container to the scene
  64873. * @param container the container holding the elements
  64874. */
  64875. addFromContainer(container: AbstractScene): void;
  64876. /**
  64877. * Removes all the elements in the container from the scene
  64878. * @param container contains the elements to remove
  64879. * @param dispose if the removed element should be disposed (default: false)
  64880. */
  64881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64882. /**
  64883. * Rebuilds the elements related to this component in case of
  64884. * context lost for instance.
  64885. */
  64886. dispose(): void;
  64887. private _gatherRenderTargets;
  64888. }
  64889. }
  64890. declare module BABYLON {
  64891. /**
  64892. * A point light is a light defined by an unique point in world space.
  64893. * The light is emitted in every direction from this point.
  64894. * A good example of a point light is a standard light bulb.
  64895. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64896. */
  64897. export class PointLight extends ShadowLight {
  64898. private _shadowAngle;
  64899. /**
  64900. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64901. * This specifies what angle the shadow will use to be created.
  64902. *
  64903. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64904. */
  64905. get shadowAngle(): number;
  64906. /**
  64907. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64908. * This specifies what angle the shadow will use to be created.
  64909. *
  64910. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64911. */
  64912. set shadowAngle(value: number);
  64913. /**
  64914. * Gets the direction if it has been set.
  64915. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64916. */
  64917. get direction(): Vector3;
  64918. /**
  64919. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64920. */
  64921. set direction(value: Vector3);
  64922. /**
  64923. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64924. * A PointLight emits the light in every direction.
  64925. * It can cast shadows.
  64926. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64927. * ```javascript
  64928. * var pointLight = new PointLight("pl", camera.position, scene);
  64929. * ```
  64930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64931. * @param name The light friendly name
  64932. * @param position The position of the point light in the scene
  64933. * @param scene The scene the lights belongs to
  64934. */
  64935. constructor(name: string, position: Vector3, scene: Scene);
  64936. /**
  64937. * Returns the string "PointLight"
  64938. * @returns the class name
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * Returns the integer 0.
  64943. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64944. */
  64945. getTypeID(): number;
  64946. /**
  64947. * Specifies whether or not the shadowmap should be a cube texture.
  64948. * @returns true if the shadowmap needs to be a cube texture.
  64949. */
  64950. needCube(): boolean;
  64951. /**
  64952. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64953. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64954. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64955. */
  64956. getShadowDirection(faceIndex?: number): Vector3;
  64957. /**
  64958. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64959. * - fov = PI / 2
  64960. * - aspect ratio : 1.0
  64961. * - z-near and far equal to the active camera minZ and maxZ.
  64962. * Returns the PointLight.
  64963. */
  64964. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64965. protected _buildUniformLayout(): void;
  64966. /**
  64967. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64968. * @param effect The effect to update
  64969. * @param lightIndex The index of the light in the effect to update
  64970. * @returns The point light
  64971. */
  64972. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64973. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64974. /**
  64975. * Prepares the list of defines specific to the light type.
  64976. * @param defines the list of defines
  64977. * @param lightIndex defines the index of the light for the effect
  64978. */
  64979. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64980. }
  64981. }
  64982. declare module BABYLON {
  64983. /**
  64984. * Header information of HDR texture files.
  64985. */
  64986. export interface HDRInfo {
  64987. /**
  64988. * The height of the texture in pixels.
  64989. */
  64990. height: number;
  64991. /**
  64992. * The width of the texture in pixels.
  64993. */
  64994. width: number;
  64995. /**
  64996. * The index of the beginning of the data in the binary file.
  64997. */
  64998. dataPosition: number;
  64999. }
  65000. /**
  65001. * This groups tools to convert HDR texture to native colors array.
  65002. */
  65003. export class HDRTools {
  65004. private static Ldexp;
  65005. private static Rgbe2float;
  65006. private static readStringLine;
  65007. /**
  65008. * Reads header information from an RGBE texture stored in a native array.
  65009. * More information on this format are available here:
  65010. * https://en.wikipedia.org/wiki/RGBE_image_format
  65011. *
  65012. * @param uint8array The binary file stored in native array.
  65013. * @return The header information.
  65014. */
  65015. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65016. /**
  65017. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65018. * This RGBE texture needs to store the information as a panorama.
  65019. *
  65020. * More information on this format are available here:
  65021. * https://en.wikipedia.org/wiki/RGBE_image_format
  65022. *
  65023. * @param buffer The binary file stored in an array buffer.
  65024. * @param size The expected size of the extracted cubemap.
  65025. * @return The Cube Map information.
  65026. */
  65027. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65028. /**
  65029. * Returns the pixels data extracted from an RGBE texture.
  65030. * This pixels will be stored left to right up to down in the R G B order in one array.
  65031. *
  65032. * More information on this format are available here:
  65033. * https://en.wikipedia.org/wiki/RGBE_image_format
  65034. *
  65035. * @param uint8array The binary file stored in an array buffer.
  65036. * @param hdrInfo The header information of the file.
  65037. * @return The pixels data in RGB right to left up to down order.
  65038. */
  65039. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65040. private static RGBE_ReadPixels_RLE;
  65041. private static RGBE_ReadPixels_NOT_RLE;
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /**
  65046. * Effect Render Options
  65047. */
  65048. export interface IEffectRendererOptions {
  65049. /**
  65050. * Defines the vertices positions.
  65051. */
  65052. positions?: number[];
  65053. /**
  65054. * Defines the indices.
  65055. */
  65056. indices?: number[];
  65057. }
  65058. /**
  65059. * Helper class to render one or more effects.
  65060. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65061. */
  65062. export class EffectRenderer {
  65063. private engine;
  65064. private static _DefaultOptions;
  65065. private _vertexBuffers;
  65066. private _indexBuffer;
  65067. private _fullscreenViewport;
  65068. /**
  65069. * Creates an effect renderer
  65070. * @param engine the engine to use for rendering
  65071. * @param options defines the options of the effect renderer
  65072. */
  65073. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65074. /**
  65075. * Sets the current viewport in normalized coordinates 0-1
  65076. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65077. */
  65078. setViewport(viewport?: Viewport): void;
  65079. /**
  65080. * Binds the embedded attributes buffer to the effect.
  65081. * @param effect Defines the effect to bind the attributes for
  65082. */
  65083. bindBuffers(effect: Effect): void;
  65084. /**
  65085. * Sets the current effect wrapper to use during draw.
  65086. * The effect needs to be ready before calling this api.
  65087. * This also sets the default full screen position attribute.
  65088. * @param effectWrapper Defines the effect to draw with
  65089. */
  65090. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65091. /**
  65092. * Restores engine states
  65093. */
  65094. restoreStates(): void;
  65095. /**
  65096. * Draws a full screen quad.
  65097. */
  65098. draw(): void;
  65099. private isRenderTargetTexture;
  65100. /**
  65101. * renders one or more effects to a specified texture
  65102. * @param effectWrapper the effect to renderer
  65103. * @param outputTexture texture to draw to, if null it will render to the screen.
  65104. */
  65105. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65106. /**
  65107. * Disposes of the effect renderer
  65108. */
  65109. dispose(): void;
  65110. }
  65111. /**
  65112. * Options to create an EffectWrapper
  65113. */
  65114. interface EffectWrapperCreationOptions {
  65115. /**
  65116. * Engine to use to create the effect
  65117. */
  65118. engine: ThinEngine;
  65119. /**
  65120. * Fragment shader for the effect
  65121. */
  65122. fragmentShader: string;
  65123. /**
  65124. * Use the shader store instead of direct source code
  65125. */
  65126. useShaderStore?: boolean;
  65127. /**
  65128. * Vertex shader for the effect
  65129. */
  65130. vertexShader?: string;
  65131. /**
  65132. * Attributes to use in the shader
  65133. */
  65134. attributeNames?: Array<string>;
  65135. /**
  65136. * Uniforms to use in the shader
  65137. */
  65138. uniformNames?: Array<string>;
  65139. /**
  65140. * Texture sampler names to use in the shader
  65141. */
  65142. samplerNames?: Array<string>;
  65143. /**
  65144. * Defines to use in the shader
  65145. */
  65146. defines?: Array<string>;
  65147. /**
  65148. * Callback when effect is compiled
  65149. */
  65150. onCompiled?: Nullable<(effect: Effect) => void>;
  65151. /**
  65152. * The friendly name of the effect displayed in Spector.
  65153. */
  65154. name?: string;
  65155. }
  65156. /**
  65157. * Wraps an effect to be used for rendering
  65158. */
  65159. export class EffectWrapper {
  65160. /**
  65161. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65162. */
  65163. onApplyObservable: Observable<{}>;
  65164. /**
  65165. * The underlying effect
  65166. */
  65167. effect: Effect;
  65168. /**
  65169. * Creates an effect to be renderer
  65170. * @param creationOptions options to create the effect
  65171. */
  65172. constructor(creationOptions: EffectWrapperCreationOptions);
  65173. /**
  65174. * Disposes of the effect wrapper
  65175. */
  65176. dispose(): void;
  65177. }
  65178. }
  65179. declare module BABYLON {
  65180. /** @hidden */
  65181. export var hdrFilteringVertexShader: {
  65182. name: string;
  65183. shader: string;
  65184. };
  65185. }
  65186. declare module BABYLON {
  65187. /** @hidden */
  65188. export var hdrFilteringPixelShader: {
  65189. name: string;
  65190. shader: string;
  65191. };
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Options for texture filtering
  65196. */
  65197. interface IHDRFilteringOptions {
  65198. /**
  65199. * Scales pixel intensity for the input HDR map.
  65200. */
  65201. hdrScale?: number;
  65202. /**
  65203. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65204. */
  65205. quality?: number;
  65206. }
  65207. /**
  65208. * Filters HDR maps to get correct renderings of PBR reflections
  65209. */
  65210. export class HDRFiltering {
  65211. private _engine;
  65212. private _effectRenderer;
  65213. private _effectWrapper;
  65214. private _lodGenerationOffset;
  65215. private _lodGenerationScale;
  65216. /**
  65217. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65218. * you care about baking speed.
  65219. */
  65220. quality: number;
  65221. /**
  65222. * Scales pixel intensity for the input HDR map.
  65223. */
  65224. hdrScale: number;
  65225. /**
  65226. * Instantiates HDR filter for reflection maps
  65227. *
  65228. * @param engine Thin engine
  65229. * @param options Options
  65230. */
  65231. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65232. private _createRenderTarget;
  65233. private _prefilterInternal;
  65234. private _createEffect;
  65235. /**
  65236. * Get a value indicating if the filter is ready to be used
  65237. * @param texture Texture to filter
  65238. * @returns true if the filter is ready
  65239. */
  65240. isReady(texture: BaseTexture): boolean;
  65241. /**
  65242. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65243. * Prefiltering will be invoked at the end of next rendering pass.
  65244. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65245. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65246. * @param texture Texture to filter
  65247. * @param onFinished Callback when filtering is done
  65248. * @return Promise called when prefiltering is done
  65249. */
  65250. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65251. }
  65252. }
  65253. declare module BABYLON {
  65254. /**
  65255. * This represents a texture coming from an HDR input.
  65256. *
  65257. * The only supported format is currently panorama picture stored in RGBE format.
  65258. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65259. */
  65260. export class HDRCubeTexture extends BaseTexture {
  65261. private static _facesMapping;
  65262. private _generateHarmonics;
  65263. private _noMipmap;
  65264. private _prefilterOnLoad;
  65265. private _textureMatrix;
  65266. private _size;
  65267. private _onLoad;
  65268. private _onError;
  65269. /**
  65270. * The texture URL.
  65271. */
  65272. url: string;
  65273. protected _isBlocking: boolean;
  65274. /**
  65275. * Sets whether or not the texture is blocking during loading.
  65276. */
  65277. set isBlocking(value: boolean);
  65278. /**
  65279. * Gets whether or not the texture is blocking during loading.
  65280. */
  65281. get isBlocking(): boolean;
  65282. protected _rotationY: number;
  65283. /**
  65284. * Sets texture matrix rotation angle around Y axis in radians.
  65285. */
  65286. set rotationY(value: number);
  65287. /**
  65288. * Gets texture matrix rotation angle around Y axis radians.
  65289. */
  65290. get rotationY(): number;
  65291. /**
  65292. * Gets or sets the center of the bounding box associated with the cube texture
  65293. * It must define where the camera used to render the texture was set
  65294. */
  65295. boundingBoxPosition: Vector3;
  65296. private _boundingBoxSize;
  65297. /**
  65298. * Gets or sets the size of the bounding box associated with the cube texture
  65299. * When defined, the cubemap will switch to local mode
  65300. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65301. * @example https://www.babylonjs-playground.com/#RNASML
  65302. */
  65303. set boundingBoxSize(value: Vector3);
  65304. get boundingBoxSize(): Vector3;
  65305. /**
  65306. * Instantiates an HDRTexture from the following parameters.
  65307. *
  65308. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65309. * @param sceneOrEngine The scene or engine the texture will be used in
  65310. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65311. * @param noMipmap Forces to not generate the mipmap if true
  65312. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65313. * @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)
  65314. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65315. */
  65316. 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>);
  65317. /**
  65318. * Get the current class name of the texture useful for serialization or dynamic coding.
  65319. * @returns "HDRCubeTexture"
  65320. */
  65321. getClassName(): string;
  65322. /**
  65323. * Occurs when the file is raw .hdr file.
  65324. */
  65325. private loadTexture;
  65326. clone(): HDRCubeTexture;
  65327. delayLoad(): void;
  65328. /**
  65329. * Get the texture reflection matrix used to rotate/transform the reflection.
  65330. * @returns the reflection matrix
  65331. */
  65332. getReflectionTextureMatrix(): Matrix;
  65333. /**
  65334. * Set the texture reflection matrix used to rotate/transform the reflection.
  65335. * @param value Define the reflection matrix to set
  65336. */
  65337. setReflectionTextureMatrix(value: Matrix): void;
  65338. /**
  65339. * Parses a JSON representation of an HDR Texture in order to create the texture
  65340. * @param parsedTexture Define the JSON representation
  65341. * @param scene Define the scene the texture should be created in
  65342. * @param rootUrl Define the root url in case we need to load relative dependencies
  65343. * @returns the newly created texture after parsing
  65344. */
  65345. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65346. serialize(): any;
  65347. }
  65348. }
  65349. declare module BABYLON {
  65350. /**
  65351. * Class used to control physics engine
  65352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65353. */
  65354. export class PhysicsEngine implements IPhysicsEngine {
  65355. private _physicsPlugin;
  65356. /**
  65357. * Global value used to control the smallest number supported by the simulation
  65358. */
  65359. static Epsilon: number;
  65360. private _impostors;
  65361. private _joints;
  65362. private _subTimeStep;
  65363. /**
  65364. * Gets the gravity vector used by the simulation
  65365. */
  65366. gravity: Vector3;
  65367. /**
  65368. * Factory used to create the default physics plugin.
  65369. * @returns The default physics plugin
  65370. */
  65371. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65372. /**
  65373. * Creates a new Physics Engine
  65374. * @param gravity defines the gravity vector used by the simulation
  65375. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65376. */
  65377. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65378. /**
  65379. * Sets the gravity vector used by the simulation
  65380. * @param gravity defines the gravity vector to use
  65381. */
  65382. setGravity(gravity: Vector3): void;
  65383. /**
  65384. * Set the time step of the physics engine.
  65385. * Default is 1/60.
  65386. * To slow it down, enter 1/600 for example.
  65387. * To speed it up, 1/30
  65388. * @param newTimeStep defines the new timestep to apply to this world.
  65389. */
  65390. setTimeStep(newTimeStep?: number): void;
  65391. /**
  65392. * Get the time step of the physics engine.
  65393. * @returns the current time step
  65394. */
  65395. getTimeStep(): number;
  65396. /**
  65397. * Set the sub time step of the physics engine.
  65398. * Default is 0 meaning there is no sub steps
  65399. * To increase physics resolution precision, set a small value (like 1 ms)
  65400. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65401. */
  65402. setSubTimeStep(subTimeStep?: number): void;
  65403. /**
  65404. * Get the sub time step of the physics engine.
  65405. * @returns the current sub time step
  65406. */
  65407. getSubTimeStep(): number;
  65408. /**
  65409. * Release all resources
  65410. */
  65411. dispose(): void;
  65412. /**
  65413. * Gets the name of the current physics plugin
  65414. * @returns the name of the plugin
  65415. */
  65416. getPhysicsPluginName(): string;
  65417. /**
  65418. * Adding a new impostor for the impostor tracking.
  65419. * This will be done by the impostor itself.
  65420. * @param impostor the impostor to add
  65421. */
  65422. addImpostor(impostor: PhysicsImpostor): void;
  65423. /**
  65424. * Remove an impostor from the engine.
  65425. * This impostor and its mesh will not longer be updated by the physics engine.
  65426. * @param impostor the impostor to remove
  65427. */
  65428. removeImpostor(impostor: PhysicsImpostor): void;
  65429. /**
  65430. * Add a joint to the physics engine
  65431. * @param mainImpostor defines the main impostor to which the joint is added.
  65432. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65433. * @param joint defines the joint that will connect both impostors.
  65434. */
  65435. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65436. /**
  65437. * Removes a joint from the simulation
  65438. * @param mainImpostor defines the impostor used with the joint
  65439. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65440. * @param joint defines the joint to remove
  65441. */
  65442. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65443. /**
  65444. * Called by the scene. No need to call it.
  65445. * @param delta defines the timespan between frames
  65446. */
  65447. _step(delta: number): void;
  65448. /**
  65449. * Gets the current plugin used to run the simulation
  65450. * @returns current plugin
  65451. */
  65452. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65453. /**
  65454. * Gets the list of physic impostors
  65455. * @returns an array of PhysicsImpostor
  65456. */
  65457. getImpostors(): Array<PhysicsImpostor>;
  65458. /**
  65459. * Gets the impostor for a physics enabled object
  65460. * @param object defines the object impersonated by the impostor
  65461. * @returns the PhysicsImpostor or null if not found
  65462. */
  65463. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65464. /**
  65465. * Gets the impostor for a physics body object
  65466. * @param body defines physics body used by the impostor
  65467. * @returns the PhysicsImpostor or null if not found
  65468. */
  65469. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65470. /**
  65471. * Does a raycast in the physics world
  65472. * @param from when should the ray start?
  65473. * @param to when should the ray end?
  65474. * @returns PhysicsRaycastResult
  65475. */
  65476. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65477. }
  65478. }
  65479. declare module BABYLON {
  65480. /** @hidden */
  65481. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65482. private _useDeltaForWorldStep;
  65483. world: any;
  65484. name: string;
  65485. private _physicsMaterials;
  65486. private _fixedTimeStep;
  65487. private _cannonRaycastResult;
  65488. private _raycastResult;
  65489. private _physicsBodysToRemoveAfterStep;
  65490. private _firstFrame;
  65491. BJSCANNON: any;
  65492. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65493. setGravity(gravity: Vector3): void;
  65494. setTimeStep(timeStep: number): void;
  65495. getTimeStep(): number;
  65496. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65497. private _removeMarkedPhysicsBodiesFromWorld;
  65498. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65499. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65500. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65501. private _processChildMeshes;
  65502. removePhysicsBody(impostor: PhysicsImpostor): void;
  65503. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65504. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65505. private _addMaterial;
  65506. private _checkWithEpsilon;
  65507. private _createShape;
  65508. private _createHeightmap;
  65509. private _minus90X;
  65510. private _plus90X;
  65511. private _tmpPosition;
  65512. private _tmpDeltaPosition;
  65513. private _tmpUnityRotation;
  65514. private _updatePhysicsBodyTransformation;
  65515. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65516. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65517. isSupported(): boolean;
  65518. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65519. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65520. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65521. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65522. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65523. getBodyMass(impostor: PhysicsImpostor): number;
  65524. getBodyFriction(impostor: PhysicsImpostor): number;
  65525. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65526. getBodyRestitution(impostor: PhysicsImpostor): number;
  65527. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65528. sleepBody(impostor: PhysicsImpostor): void;
  65529. wakeUpBody(impostor: PhysicsImpostor): void;
  65530. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65531. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65532. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65533. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65534. getRadius(impostor: PhysicsImpostor): number;
  65535. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65536. dispose(): void;
  65537. private _extendNamespace;
  65538. /**
  65539. * Does a raycast in the physics world
  65540. * @param from when should the ray start?
  65541. * @param to when should the ray end?
  65542. * @returns PhysicsRaycastResult
  65543. */
  65544. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65545. }
  65546. }
  65547. declare module BABYLON {
  65548. /** @hidden */
  65549. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65550. private _useDeltaForWorldStep;
  65551. world: any;
  65552. name: string;
  65553. BJSOIMO: any;
  65554. private _raycastResult;
  65555. private _fixedTimeStep;
  65556. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65557. setGravity(gravity: Vector3): void;
  65558. setTimeStep(timeStep: number): void;
  65559. getTimeStep(): number;
  65560. private _tmpImpostorsArray;
  65561. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65563. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65564. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65565. private _tmpPositionVector;
  65566. removePhysicsBody(impostor: PhysicsImpostor): void;
  65567. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65568. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65569. isSupported(): boolean;
  65570. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65571. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65572. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65574. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65575. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65576. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65577. getBodyMass(impostor: PhysicsImpostor): number;
  65578. getBodyFriction(impostor: PhysicsImpostor): number;
  65579. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65580. getBodyRestitution(impostor: PhysicsImpostor): number;
  65581. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65582. sleepBody(impostor: PhysicsImpostor): void;
  65583. wakeUpBody(impostor: PhysicsImpostor): void;
  65584. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65585. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65586. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65587. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65588. getRadius(impostor: PhysicsImpostor): number;
  65589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65590. dispose(): void;
  65591. /**
  65592. * Does a raycast in the physics world
  65593. * @param from when should the ray start?
  65594. * @param to when should the ray end?
  65595. * @returns PhysicsRaycastResult
  65596. */
  65597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65598. }
  65599. }
  65600. declare module BABYLON {
  65601. /**
  65602. * AmmoJS Physics plugin
  65603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65604. * @see https://github.com/kripken/ammo.js/
  65605. */
  65606. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65607. private _useDeltaForWorldStep;
  65608. /**
  65609. * Reference to the Ammo library
  65610. */
  65611. bjsAMMO: any;
  65612. /**
  65613. * Created ammoJS world which physics bodies are added to
  65614. */
  65615. world: any;
  65616. /**
  65617. * Name of the plugin
  65618. */
  65619. name: string;
  65620. private _timeStep;
  65621. private _fixedTimeStep;
  65622. private _maxSteps;
  65623. private _tmpQuaternion;
  65624. private _tmpAmmoTransform;
  65625. private _tmpAmmoQuaternion;
  65626. private _tmpAmmoConcreteContactResultCallback;
  65627. private _collisionConfiguration;
  65628. private _dispatcher;
  65629. private _overlappingPairCache;
  65630. private _solver;
  65631. private _softBodySolver;
  65632. private _tmpAmmoVectorA;
  65633. private _tmpAmmoVectorB;
  65634. private _tmpAmmoVectorC;
  65635. private _tmpAmmoVectorD;
  65636. private _tmpContactCallbackResult;
  65637. private _tmpAmmoVectorRCA;
  65638. private _tmpAmmoVectorRCB;
  65639. private _raycastResult;
  65640. private _tmpContactPoint;
  65641. private static readonly DISABLE_COLLISION_FLAG;
  65642. private static readonly KINEMATIC_FLAG;
  65643. private static readonly DISABLE_DEACTIVATION_FLAG;
  65644. /**
  65645. * Initializes the ammoJS plugin
  65646. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65647. * @param ammoInjection can be used to inject your own ammo reference
  65648. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65649. */
  65650. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65651. /**
  65652. * Sets the gravity of the physics world (m/(s^2))
  65653. * @param gravity Gravity to set
  65654. */
  65655. setGravity(gravity: Vector3): void;
  65656. /**
  65657. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65658. * @param timeStep timestep to use in seconds
  65659. */
  65660. setTimeStep(timeStep: number): void;
  65661. /**
  65662. * 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)
  65663. * @param fixedTimeStep fixedTimeStep to use in seconds
  65664. */
  65665. setFixedTimeStep(fixedTimeStep: number): void;
  65666. /**
  65667. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65668. * @param maxSteps the maximum number of steps by the physics engine per frame
  65669. */
  65670. setMaxSteps(maxSteps: number): void;
  65671. /**
  65672. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65673. * @returns the current timestep in seconds
  65674. */
  65675. getTimeStep(): number;
  65676. /**
  65677. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65678. */
  65679. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65680. private _isImpostorInContact;
  65681. private _isImpostorPairInContact;
  65682. private _stepSimulation;
  65683. /**
  65684. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65685. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65686. * After the step the babylon meshes are set to the position of the physics imposters
  65687. * @param delta amount of time to step forward
  65688. * @param impostors array of imposters to update before/after the step
  65689. */
  65690. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65691. /**
  65692. * Update babylon mesh to match physics world object
  65693. * @param impostor imposter to match
  65694. */
  65695. private _afterSoftStep;
  65696. /**
  65697. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65698. * @param impostor imposter to match
  65699. */
  65700. private _ropeStep;
  65701. /**
  65702. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65703. * @param impostor imposter to match
  65704. */
  65705. private _softbodyOrClothStep;
  65706. private _tmpMatrix;
  65707. /**
  65708. * Applies an impulse on the imposter
  65709. * @param impostor imposter to apply impulse to
  65710. * @param force amount of force to be applied to the imposter
  65711. * @param contactPoint the location to apply the impulse on the imposter
  65712. */
  65713. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65714. /**
  65715. * Applies a force on the imposter
  65716. * @param impostor imposter to apply force
  65717. * @param force amount of force to be applied to the imposter
  65718. * @param contactPoint the location to apply the force on the imposter
  65719. */
  65720. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65721. /**
  65722. * Creates a physics body using the plugin
  65723. * @param impostor the imposter to create the physics body on
  65724. */
  65725. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65726. /**
  65727. * Removes the physics body from the imposter and disposes of the body's memory
  65728. * @param impostor imposter to remove the physics body from
  65729. */
  65730. removePhysicsBody(impostor: PhysicsImpostor): void;
  65731. /**
  65732. * Generates a joint
  65733. * @param impostorJoint the imposter joint to create the joint with
  65734. */
  65735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65736. /**
  65737. * Removes a joint
  65738. * @param impostorJoint the imposter joint to remove the joint from
  65739. */
  65740. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65741. private _addMeshVerts;
  65742. /**
  65743. * Initialise the soft body vertices to match its object's (mesh) vertices
  65744. * Softbody vertices (nodes) are in world space and to match this
  65745. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65746. * @param impostor to create the softbody for
  65747. */
  65748. private _softVertexData;
  65749. /**
  65750. * Create an impostor's soft body
  65751. * @param impostor to create the softbody for
  65752. */
  65753. private _createSoftbody;
  65754. /**
  65755. * Create cloth for an impostor
  65756. * @param impostor to create the softbody for
  65757. */
  65758. private _createCloth;
  65759. /**
  65760. * Create rope for an impostor
  65761. * @param impostor to create the softbody for
  65762. */
  65763. private _createRope;
  65764. /**
  65765. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65766. * @param impostor to create the custom physics shape for
  65767. */
  65768. private _createCustom;
  65769. private _addHullVerts;
  65770. private _createShape;
  65771. /**
  65772. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65773. * @param impostor imposter containing the physics body and babylon object
  65774. */
  65775. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65776. /**
  65777. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65778. * @param impostor imposter containing the physics body and babylon object
  65779. * @param newPosition new position
  65780. * @param newRotation new rotation
  65781. */
  65782. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65783. /**
  65784. * If this plugin is supported
  65785. * @returns true if its supported
  65786. */
  65787. isSupported(): boolean;
  65788. /**
  65789. * Sets the linear velocity of the physics body
  65790. * @param impostor imposter to set the velocity on
  65791. * @param velocity velocity to set
  65792. */
  65793. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65794. /**
  65795. * Sets the angular velocity of the physics body
  65796. * @param impostor imposter to set the velocity on
  65797. * @param velocity velocity to set
  65798. */
  65799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65800. /**
  65801. * gets the linear velocity
  65802. * @param impostor imposter to get linear velocity from
  65803. * @returns linear velocity
  65804. */
  65805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65806. /**
  65807. * gets the angular velocity
  65808. * @param impostor imposter to get angular velocity from
  65809. * @returns angular velocity
  65810. */
  65811. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65812. /**
  65813. * Sets the mass of physics body
  65814. * @param impostor imposter to set the mass on
  65815. * @param mass mass to set
  65816. */
  65817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65818. /**
  65819. * Gets the mass of the physics body
  65820. * @param impostor imposter to get the mass from
  65821. * @returns mass
  65822. */
  65823. getBodyMass(impostor: PhysicsImpostor): number;
  65824. /**
  65825. * Gets friction of the impostor
  65826. * @param impostor impostor to get friction from
  65827. * @returns friction value
  65828. */
  65829. getBodyFriction(impostor: PhysicsImpostor): number;
  65830. /**
  65831. * Sets friction of the impostor
  65832. * @param impostor impostor to set friction on
  65833. * @param friction friction value
  65834. */
  65835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65836. /**
  65837. * Gets restitution of the impostor
  65838. * @param impostor impostor to get restitution from
  65839. * @returns restitution value
  65840. */
  65841. getBodyRestitution(impostor: PhysicsImpostor): number;
  65842. /**
  65843. * Sets restitution of the impostor
  65844. * @param impostor impostor to set resitution on
  65845. * @param restitution resitution value
  65846. */
  65847. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65848. /**
  65849. * Gets pressure inside the impostor
  65850. * @param impostor impostor to get pressure from
  65851. * @returns pressure value
  65852. */
  65853. getBodyPressure(impostor: PhysicsImpostor): number;
  65854. /**
  65855. * Sets pressure inside a soft body impostor
  65856. * Cloth and rope must remain 0 pressure
  65857. * @param impostor impostor to set pressure on
  65858. * @param pressure pressure value
  65859. */
  65860. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65861. /**
  65862. * Gets stiffness of the impostor
  65863. * @param impostor impostor to get stiffness from
  65864. * @returns pressure value
  65865. */
  65866. getBodyStiffness(impostor: PhysicsImpostor): number;
  65867. /**
  65868. * Sets stiffness of the impostor
  65869. * @param impostor impostor to set stiffness on
  65870. * @param stiffness stiffness value from 0 to 1
  65871. */
  65872. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65873. /**
  65874. * Gets velocityIterations of the impostor
  65875. * @param impostor impostor to get velocity iterations from
  65876. * @returns velocityIterations value
  65877. */
  65878. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65879. /**
  65880. * Sets velocityIterations of the impostor
  65881. * @param impostor impostor to set velocity iterations on
  65882. * @param velocityIterations velocityIterations value
  65883. */
  65884. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65885. /**
  65886. * Gets positionIterations of the impostor
  65887. * @param impostor impostor to get position iterations from
  65888. * @returns positionIterations value
  65889. */
  65890. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65891. /**
  65892. * Sets positionIterations of the impostor
  65893. * @param impostor impostor to set position on
  65894. * @param positionIterations positionIterations value
  65895. */
  65896. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65897. /**
  65898. * Append an anchor to a cloth object
  65899. * @param impostor is the cloth impostor to add anchor to
  65900. * @param otherImpostor is the rigid impostor to anchor to
  65901. * @param width ratio across width from 0 to 1
  65902. * @param height ratio up height from 0 to 1
  65903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  65904. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65905. */
  65906. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65907. /**
  65908. * Append an hook to a rope object
  65909. * @param impostor is the rope impostor to add hook to
  65910. * @param otherImpostor is the rigid impostor to hook to
  65911. * @param length ratio along the rope from 0 to 1
  65912. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  65913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65914. */
  65915. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65916. /**
  65917. * Sleeps the physics body and stops it from being active
  65918. * @param impostor impostor to sleep
  65919. */
  65920. sleepBody(impostor: PhysicsImpostor): void;
  65921. /**
  65922. * Activates the physics body
  65923. * @param impostor impostor to activate
  65924. */
  65925. wakeUpBody(impostor: PhysicsImpostor): void;
  65926. /**
  65927. * Updates the distance parameters of the joint
  65928. * @param joint joint to update
  65929. * @param maxDistance maximum distance of the joint
  65930. * @param minDistance minimum distance of the joint
  65931. */
  65932. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65933. /**
  65934. * Sets a motor on the joint
  65935. * @param joint joint to set motor on
  65936. * @param speed speed of the motor
  65937. * @param maxForce maximum force of the motor
  65938. * @param motorIndex index of the motor
  65939. */
  65940. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65941. /**
  65942. * Sets the motors limit
  65943. * @param joint joint to set limit on
  65944. * @param upperLimit upper limit
  65945. * @param lowerLimit lower limit
  65946. */
  65947. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65948. /**
  65949. * Syncs the position and rotation of a mesh with the impostor
  65950. * @param mesh mesh to sync
  65951. * @param impostor impostor to update the mesh with
  65952. */
  65953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65954. /**
  65955. * Gets the radius of the impostor
  65956. * @param impostor impostor to get radius from
  65957. * @returns the radius
  65958. */
  65959. getRadius(impostor: PhysicsImpostor): number;
  65960. /**
  65961. * Gets the box size of the impostor
  65962. * @param impostor impostor to get box size from
  65963. * @param result the resulting box size
  65964. */
  65965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65966. /**
  65967. * Disposes of the impostor
  65968. */
  65969. dispose(): void;
  65970. /**
  65971. * Does a raycast in the physics world
  65972. * @param from when should the ray start?
  65973. * @param to when should the ray end?
  65974. * @returns PhysicsRaycastResult
  65975. */
  65976. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65977. }
  65978. }
  65979. declare module BABYLON {
  65980. interface AbstractScene {
  65981. /**
  65982. * The list of reflection probes added to the scene
  65983. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65984. */
  65985. reflectionProbes: Array<ReflectionProbe>;
  65986. /**
  65987. * Removes the given reflection probe from this scene.
  65988. * @param toRemove The reflection probe to remove
  65989. * @returns The index of the removed reflection probe
  65990. */
  65991. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65992. /**
  65993. * Adds the given reflection probe to this scene.
  65994. * @param newReflectionProbe The reflection probe to add
  65995. */
  65996. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65997. }
  65998. /**
  65999. * Class used to generate realtime reflection / refraction cube textures
  66000. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66001. */
  66002. export class ReflectionProbe {
  66003. /** defines the name of the probe */
  66004. name: string;
  66005. private _scene;
  66006. private _renderTargetTexture;
  66007. private _projectionMatrix;
  66008. private _viewMatrix;
  66009. private _target;
  66010. private _add;
  66011. private _attachedMesh;
  66012. private _invertYAxis;
  66013. /** Gets or sets probe position (center of the cube map) */
  66014. position: Vector3;
  66015. /**
  66016. * Creates a new reflection probe
  66017. * @param name defines the name of the probe
  66018. * @param size defines the texture resolution (for each face)
  66019. * @param scene defines the hosting scene
  66020. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66021. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66022. */
  66023. constructor(
  66024. /** defines the name of the probe */
  66025. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  66026. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66027. get samples(): number;
  66028. set samples(value: number);
  66029. /** Gets or sets the refresh rate to use (on every frame by default) */
  66030. get refreshRate(): number;
  66031. set refreshRate(value: number);
  66032. /**
  66033. * Gets the hosting scene
  66034. * @returns a Scene
  66035. */
  66036. getScene(): Scene;
  66037. /** Gets the internal CubeTexture used to render to */
  66038. get cubeTexture(): RenderTargetTexture;
  66039. /** Gets the list of meshes to render */
  66040. get renderList(): Nullable<AbstractMesh[]>;
  66041. /**
  66042. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66043. * @param mesh defines the mesh to attach to
  66044. */
  66045. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66046. /**
  66047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66048. * @param renderingGroupId The rendering group id corresponding to its index
  66049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66050. */
  66051. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66052. /**
  66053. * Clean all associated resources
  66054. */
  66055. dispose(): void;
  66056. /**
  66057. * Converts the reflection probe information to a readable string for debug purpose.
  66058. * @param fullDetails Supports for multiple levels of logging within scene loading
  66059. * @returns the human readable reflection probe info
  66060. */
  66061. toString(fullDetails?: boolean): string;
  66062. /**
  66063. * Get the class name of the refection probe.
  66064. * @returns "ReflectionProbe"
  66065. */
  66066. getClassName(): string;
  66067. /**
  66068. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66069. * @returns The JSON representation of the texture
  66070. */
  66071. serialize(): any;
  66072. /**
  66073. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66074. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66075. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66076. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66077. * @returns The parsed reflection probe if successful
  66078. */
  66079. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /** @hidden */
  66084. export var _BabylonLoaderRegistered: boolean;
  66085. /**
  66086. * Helps setting up some configuration for the babylon file loader.
  66087. */
  66088. export class BabylonFileLoaderConfiguration {
  66089. /**
  66090. * The loader does not allow injecting custom physics engine into the plugins.
  66091. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66092. * So you could set this variable to your engine import to make it work.
  66093. */
  66094. static LoaderInjectedPhysicsEngine: any;
  66095. }
  66096. }
  66097. declare module BABYLON {
  66098. /**
  66099. * A material to use for fast depth-only rendering.
  66100. */
  66101. export class OcclusionMaterial extends ShaderMaterial {
  66102. constructor(name: string, scene: Scene);
  66103. }
  66104. }
  66105. declare module BABYLON {
  66106. /**
  66107. * The Physically based simple base material of BJS.
  66108. *
  66109. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66110. * It is used as the base class for both the specGloss and metalRough conventions.
  66111. */
  66112. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66113. /**
  66114. * Number of Simultaneous lights allowed on the material.
  66115. */
  66116. maxSimultaneousLights: number;
  66117. /**
  66118. * If sets to true, disables all the lights affecting the material.
  66119. */
  66120. disableLighting: boolean;
  66121. /**
  66122. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66123. */
  66124. environmentTexture: BaseTexture;
  66125. /**
  66126. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66127. */
  66128. invertNormalMapX: boolean;
  66129. /**
  66130. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66131. */
  66132. invertNormalMapY: boolean;
  66133. /**
  66134. * Normal map used in the model.
  66135. */
  66136. normalTexture: BaseTexture;
  66137. /**
  66138. * Emissivie color used to self-illuminate the model.
  66139. */
  66140. emissiveColor: Color3;
  66141. /**
  66142. * Emissivie texture used to self-illuminate the model.
  66143. */
  66144. emissiveTexture: BaseTexture;
  66145. /**
  66146. * Occlusion Channel Strength.
  66147. */
  66148. occlusionStrength: number;
  66149. /**
  66150. * Occlusion Texture of the material (adding extra occlusion effects).
  66151. */
  66152. occlusionTexture: BaseTexture;
  66153. /**
  66154. * Defines the alpha limits in alpha test mode.
  66155. */
  66156. alphaCutOff: number;
  66157. /**
  66158. * Gets the current double sided mode.
  66159. */
  66160. get doubleSided(): boolean;
  66161. /**
  66162. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66163. */
  66164. set doubleSided(value: boolean);
  66165. /**
  66166. * Stores the pre-calculated light information of a mesh in a texture.
  66167. */
  66168. lightmapTexture: BaseTexture;
  66169. /**
  66170. * If true, the light map contains occlusion information instead of lighting info.
  66171. */
  66172. useLightmapAsShadowmap: boolean;
  66173. /**
  66174. * Instantiates a new PBRMaterial instance.
  66175. *
  66176. * @param name The material name
  66177. * @param scene The scene the material will be use in.
  66178. */
  66179. constructor(name: string, scene: Scene);
  66180. getClassName(): string;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * The PBR material of BJS following the metal roughness convention.
  66186. *
  66187. * This fits to the PBR convention in the GLTF definition:
  66188. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66189. */
  66190. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66191. /**
  66192. * The base color has two different interpretations depending on the value of metalness.
  66193. * When the material is a metal, the base color is the specific measured reflectance value
  66194. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66195. * of the material.
  66196. */
  66197. baseColor: Color3;
  66198. /**
  66199. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66200. * well as opacity information in the alpha channel.
  66201. */
  66202. baseTexture: BaseTexture;
  66203. /**
  66204. * Specifies the metallic scalar value of the material.
  66205. * Can also be used to scale the metalness values of the metallic texture.
  66206. */
  66207. metallic: number;
  66208. /**
  66209. * Specifies the roughness scalar value of the material.
  66210. * Can also be used to scale the roughness values of the metallic texture.
  66211. */
  66212. roughness: number;
  66213. /**
  66214. * Texture containing both the metallic value in the B channel and the
  66215. * roughness value in the G channel to keep better precision.
  66216. */
  66217. metallicRoughnessTexture: BaseTexture;
  66218. /**
  66219. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66220. *
  66221. * @param name The material name
  66222. * @param scene The scene the material will be use in.
  66223. */
  66224. constructor(name: string, scene: Scene);
  66225. /**
  66226. * Return the current class name of the material.
  66227. */
  66228. getClassName(): string;
  66229. /**
  66230. * Makes a duplicate of the current material.
  66231. * @param name - name to use for the new material.
  66232. */
  66233. clone(name: string): PBRMetallicRoughnessMaterial;
  66234. /**
  66235. * Serialize the material to a parsable JSON object.
  66236. */
  66237. serialize(): any;
  66238. /**
  66239. * Parses a JSON object corresponding to the serialize function.
  66240. */
  66241. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66242. }
  66243. }
  66244. declare module BABYLON {
  66245. /**
  66246. * The PBR material of BJS following the specular glossiness convention.
  66247. *
  66248. * This fits to the PBR convention in the GLTF definition:
  66249. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66250. */
  66251. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66252. /**
  66253. * Specifies the diffuse color of the material.
  66254. */
  66255. diffuseColor: Color3;
  66256. /**
  66257. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66258. * channel.
  66259. */
  66260. diffuseTexture: BaseTexture;
  66261. /**
  66262. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66263. */
  66264. specularColor: Color3;
  66265. /**
  66266. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66267. */
  66268. glossiness: number;
  66269. /**
  66270. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66271. */
  66272. specularGlossinessTexture: BaseTexture;
  66273. /**
  66274. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66275. */
  66276. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66277. /**
  66278. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66279. *
  66280. * @param name The material name
  66281. * @param scene The scene the material will be use in.
  66282. */
  66283. constructor(name: string, scene: Scene);
  66284. /**
  66285. * Return the current class name of the material.
  66286. */
  66287. getClassName(): string;
  66288. /**
  66289. * Makes a duplicate of the current material.
  66290. * @param name - name to use for the new material.
  66291. */
  66292. clone(name: string): PBRSpecularGlossinessMaterial;
  66293. /**
  66294. * Serialize the material to a parsable JSON object.
  66295. */
  66296. serialize(): any;
  66297. /**
  66298. * Parses a JSON object corresponding to the serialize function.
  66299. */
  66300. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66301. }
  66302. }
  66303. declare module BABYLON {
  66304. /**
  66305. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66306. * It can help converting any input color in a desired output one. This can then be used to create effects
  66307. * from sepia, black and white to sixties or futuristic rendering...
  66308. *
  66309. * The only supported format is currently 3dl.
  66310. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66311. */
  66312. export class ColorGradingTexture extends BaseTexture {
  66313. /**
  66314. * The texture URL.
  66315. */
  66316. url: string;
  66317. /**
  66318. * Empty line regex stored for GC.
  66319. */
  66320. private static _noneEmptyLineRegex;
  66321. private _textureMatrix;
  66322. private _onLoad;
  66323. /**
  66324. * Instantiates a ColorGradingTexture from the following parameters.
  66325. *
  66326. * @param url The location of the color grading data (currently only supporting 3dl)
  66327. * @param sceneOrEngine The scene or engine the texture will be used in
  66328. * @param onLoad defines a callback triggered when the texture has been loaded
  66329. */
  66330. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66331. /**
  66332. * Fires the onload event from the constructor if requested.
  66333. */
  66334. private _triggerOnLoad;
  66335. /**
  66336. * Returns the texture matrix used in most of the material.
  66337. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66338. */
  66339. getTextureMatrix(): Matrix;
  66340. /**
  66341. * Occurs when the file being loaded is a .3dl LUT file.
  66342. */
  66343. private load3dlTexture;
  66344. /**
  66345. * Starts the loading process of the texture.
  66346. */
  66347. private loadTexture;
  66348. /**
  66349. * Clones the color grading texture.
  66350. */
  66351. clone(): ColorGradingTexture;
  66352. /**
  66353. * Called during delayed load for textures.
  66354. */
  66355. delayLoad(): void;
  66356. /**
  66357. * Parses a color grading texture serialized by Babylon.
  66358. * @param parsedTexture The texture information being parsedTexture
  66359. * @param scene The scene to load the texture in
  66360. * @param rootUrl The root url of the data assets to load
  66361. * @return A color grading texture
  66362. */
  66363. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66364. /**
  66365. * Serializes the LUT texture to json format.
  66366. */
  66367. serialize(): any;
  66368. }
  66369. }
  66370. declare module BABYLON {
  66371. /**
  66372. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66373. */
  66374. export class EquiRectangularCubeTexture extends BaseTexture {
  66375. /** The six faces of the cube. */
  66376. private static _FacesMapping;
  66377. private _noMipmap;
  66378. private _onLoad;
  66379. private _onError;
  66380. /** The size of the cubemap. */
  66381. private _size;
  66382. /** The buffer of the image. */
  66383. private _buffer;
  66384. /** The width of the input image. */
  66385. private _width;
  66386. /** The height of the input image. */
  66387. private _height;
  66388. /** The URL to the image. */
  66389. url: string;
  66390. /**
  66391. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66392. * @param url The location of the image
  66393. * @param scene The scene the texture will be used in
  66394. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66395. * @param noMipmap Forces to not generate the mipmap if true
  66396. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66397. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66398. * @param onLoad — defines a callback called when texture is loaded
  66399. * @param onError — defines a callback called if there is an error
  66400. */
  66401. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66402. /**
  66403. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66404. */
  66405. private loadImage;
  66406. /**
  66407. * Convert the image buffer into a cubemap and create a CubeTexture.
  66408. */
  66409. private loadTexture;
  66410. /**
  66411. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66412. * @param buffer The ArrayBuffer that should be converted.
  66413. * @returns The buffer as Float32Array.
  66414. */
  66415. private getFloat32ArrayFromArrayBuffer;
  66416. /**
  66417. * Get the current class name of the texture useful for serialization or dynamic coding.
  66418. * @returns "EquiRectangularCubeTexture"
  66419. */
  66420. getClassName(): string;
  66421. /**
  66422. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66423. * @returns A clone of the current EquiRectangularCubeTexture.
  66424. */
  66425. clone(): EquiRectangularCubeTexture;
  66426. }
  66427. }
  66428. declare module BABYLON {
  66429. /**
  66430. * Defines the options related to the creation of an HtmlElementTexture
  66431. */
  66432. export interface IHtmlElementTextureOptions {
  66433. /**
  66434. * Defines whether mip maps should be created or not.
  66435. */
  66436. generateMipMaps?: boolean;
  66437. /**
  66438. * Defines the sampling mode of the texture.
  66439. */
  66440. samplingMode?: number;
  66441. /**
  66442. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66443. */
  66444. engine: Nullable<ThinEngine>;
  66445. /**
  66446. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66447. */
  66448. scene: Nullable<Scene>;
  66449. }
  66450. /**
  66451. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66452. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66453. * is automatically managed.
  66454. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66455. * in your application.
  66456. *
  66457. * As the update is not automatic, you need to call them manually.
  66458. */
  66459. export class HtmlElementTexture extends BaseTexture {
  66460. /**
  66461. * The texture URL.
  66462. */
  66463. element: HTMLVideoElement | HTMLCanvasElement;
  66464. private static readonly DefaultOptions;
  66465. private _textureMatrix;
  66466. private _isVideo;
  66467. private _generateMipMaps;
  66468. private _samplingMode;
  66469. /**
  66470. * Instantiates a HtmlElementTexture from the following parameters.
  66471. *
  66472. * @param name Defines the name of the texture
  66473. * @param element Defines the video or canvas the texture is filled with
  66474. * @param options Defines the other none mandatory texture creation options
  66475. */
  66476. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66477. private _createInternalTexture;
  66478. /**
  66479. * Returns the texture matrix used in most of the material.
  66480. */
  66481. getTextureMatrix(): Matrix;
  66482. /**
  66483. * Updates the content of the texture.
  66484. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66485. */
  66486. update(invertY?: Nullable<boolean>): void;
  66487. }
  66488. }
  66489. declare module BABYLON {
  66490. /**
  66491. * Based on jsTGALoader - Javascript loader for TGA file
  66492. * By Vincent Thibault
  66493. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66494. */
  66495. export class TGATools {
  66496. private static _TYPE_INDEXED;
  66497. private static _TYPE_RGB;
  66498. private static _TYPE_GREY;
  66499. private static _TYPE_RLE_INDEXED;
  66500. private static _TYPE_RLE_RGB;
  66501. private static _TYPE_RLE_GREY;
  66502. private static _ORIGIN_MASK;
  66503. private static _ORIGIN_SHIFT;
  66504. private static _ORIGIN_BL;
  66505. private static _ORIGIN_BR;
  66506. private static _ORIGIN_UL;
  66507. private static _ORIGIN_UR;
  66508. /**
  66509. * Gets the header of a TGA file
  66510. * @param data defines the TGA data
  66511. * @returns the header
  66512. */
  66513. static GetTGAHeader(data: Uint8Array): any;
  66514. /**
  66515. * Uploads TGA content to a Babylon Texture
  66516. * @hidden
  66517. */
  66518. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66519. /** @hidden */
  66520. 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;
  66521. /** @hidden */
  66522. 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;
  66523. /** @hidden */
  66524. 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;
  66525. /** @hidden */
  66526. 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;
  66527. /** @hidden */
  66528. 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;
  66529. /** @hidden */
  66530. 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;
  66531. }
  66532. }
  66533. declare module BABYLON {
  66534. /**
  66535. * Implementation of the TGA Texture Loader.
  66536. * @hidden
  66537. */
  66538. export class _TGATextureLoader implements IInternalTextureLoader {
  66539. /**
  66540. * Defines whether the loader supports cascade loading the different faces.
  66541. */
  66542. readonly supportCascades: boolean;
  66543. /**
  66544. * This returns if the loader support the current file information.
  66545. * @param extension defines the file extension of the file being loaded
  66546. * @returns true if the loader can load the specified file
  66547. */
  66548. canLoad(extension: string): boolean;
  66549. /**
  66550. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66551. * @param data contains the texture data
  66552. * @param texture defines the BabylonJS internal texture
  66553. * @param createPolynomials will be true if polynomials have been requested
  66554. * @param onLoad defines the callback to trigger once the texture is ready
  66555. * @param onError defines the callback to trigger in case of error
  66556. */
  66557. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66558. /**
  66559. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66560. * @param data contains the texture data
  66561. * @param texture defines the BabylonJS internal texture
  66562. * @param callback defines the method to call once ready to upload
  66563. */
  66564. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66565. }
  66566. }
  66567. declare module BABYLON {
  66568. /**
  66569. * Implementation of the HDR Texture Loader.
  66570. * @hidden
  66571. */
  66572. export class _HDRTextureLoader implements IInternalTextureLoader {
  66573. /**
  66574. * Defines whether the loader supports cascade loading the different faces.
  66575. */
  66576. readonly supportCascades: boolean;
  66577. /**
  66578. * This returns if the loader support the current file information.
  66579. * @param extension defines the file extension of the file being loaded
  66580. * @returns true if the loader can load the specified file
  66581. */
  66582. canLoad(extension: string): boolean;
  66583. /**
  66584. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66585. * @param data contains the texture data
  66586. * @param texture defines the BabylonJS internal texture
  66587. * @param createPolynomials will be true if polynomials have been requested
  66588. * @param onLoad defines the callback to trigger once the texture is ready
  66589. * @param onError defines the callback to trigger in case of error
  66590. */
  66591. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66592. /**
  66593. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66594. * @param data contains the texture data
  66595. * @param texture defines the BabylonJS internal texture
  66596. * @param callback defines the method to call once ready to upload
  66597. */
  66598. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66599. }
  66600. }
  66601. declare module BABYLON {
  66602. /**
  66603. * Info about the .basis files
  66604. */
  66605. class BasisFileInfo {
  66606. /**
  66607. * If the file has alpha
  66608. */
  66609. hasAlpha: boolean;
  66610. /**
  66611. * Info about each image of the basis file
  66612. */
  66613. images: Array<{
  66614. levels: Array<{
  66615. width: number;
  66616. height: number;
  66617. transcodedPixels: ArrayBufferView;
  66618. }>;
  66619. }>;
  66620. }
  66621. /**
  66622. * Result of transcoding a basis file
  66623. */
  66624. class TranscodeResult {
  66625. /**
  66626. * Info about the .basis file
  66627. */
  66628. fileInfo: BasisFileInfo;
  66629. /**
  66630. * Format to use when loading the file
  66631. */
  66632. format: number;
  66633. }
  66634. /**
  66635. * Configuration options for the Basis transcoder
  66636. */
  66637. export class BasisTranscodeConfiguration {
  66638. /**
  66639. * Supported compression formats used to determine the supported output format of the transcoder
  66640. */
  66641. supportedCompressionFormats?: {
  66642. /**
  66643. * etc1 compression format
  66644. */
  66645. etc1?: boolean;
  66646. /**
  66647. * s3tc compression format
  66648. */
  66649. s3tc?: boolean;
  66650. /**
  66651. * pvrtc compression format
  66652. */
  66653. pvrtc?: boolean;
  66654. /**
  66655. * etc2 compression format
  66656. */
  66657. etc2?: boolean;
  66658. };
  66659. /**
  66660. * If mipmap levels should be loaded for transcoded images (Default: true)
  66661. */
  66662. loadMipmapLevels?: boolean;
  66663. /**
  66664. * Index of a single image to load (Default: all images)
  66665. */
  66666. loadSingleImage?: number;
  66667. }
  66668. /**
  66669. * Used to load .Basis files
  66670. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66671. */
  66672. export class BasisTools {
  66673. private static _IgnoreSupportedFormats;
  66674. /**
  66675. * URL to use when loading the basis transcoder
  66676. */
  66677. static JSModuleURL: string;
  66678. /**
  66679. * URL to use when loading the wasm module for the transcoder
  66680. */
  66681. static WasmModuleURL: string;
  66682. /**
  66683. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66684. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66685. * @returns internal format corresponding to the Basis format
  66686. */
  66687. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66688. private static _WorkerPromise;
  66689. private static _Worker;
  66690. private static _actionId;
  66691. private static _CreateWorkerAsync;
  66692. /**
  66693. * Transcodes a loaded image file to compressed pixel data
  66694. * @param data image data to transcode
  66695. * @param config configuration options for the transcoding
  66696. * @returns a promise resulting in the transcoded image
  66697. */
  66698. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66699. /**
  66700. * Loads a texture from the transcode result
  66701. * @param texture texture load to
  66702. * @param transcodeResult the result of transcoding the basis file to load from
  66703. */
  66704. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66705. }
  66706. }
  66707. declare module BABYLON {
  66708. /**
  66709. * Loader for .basis file format
  66710. */
  66711. export class _BasisTextureLoader implements IInternalTextureLoader {
  66712. /**
  66713. * Defines whether the loader supports cascade loading the different faces.
  66714. */
  66715. readonly supportCascades: boolean;
  66716. /**
  66717. * This returns if the loader support the current file information.
  66718. * @param extension defines the file extension of the file being loaded
  66719. * @returns true if the loader can load the specified file
  66720. */
  66721. canLoad(extension: string): boolean;
  66722. /**
  66723. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66724. * @param data contains the texture data
  66725. * @param texture defines the BabylonJS internal texture
  66726. * @param createPolynomials will be true if polynomials have been requested
  66727. * @param onLoad defines the callback to trigger once the texture is ready
  66728. * @param onError defines the callback to trigger in case of error
  66729. */
  66730. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66731. /**
  66732. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66733. * @param data contains the texture data
  66734. * @param texture defines the BabylonJS internal texture
  66735. * @param callback defines the method to call once ready to upload
  66736. */
  66737. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66738. }
  66739. }
  66740. declare module BABYLON {
  66741. /**
  66742. * Defines the basic options interface of a TexturePacker Frame
  66743. */
  66744. export interface ITexturePackerFrame {
  66745. /**
  66746. * The frame ID
  66747. */
  66748. id: number;
  66749. /**
  66750. * The frames Scale
  66751. */
  66752. scale: Vector2;
  66753. /**
  66754. * The Frames offset
  66755. */
  66756. offset: Vector2;
  66757. }
  66758. /**
  66759. * This is a support class for frame Data on texture packer sets.
  66760. */
  66761. export class TexturePackerFrame implements ITexturePackerFrame {
  66762. /**
  66763. * The frame ID
  66764. */
  66765. id: number;
  66766. /**
  66767. * The frames Scale
  66768. */
  66769. scale: Vector2;
  66770. /**
  66771. * The Frames offset
  66772. */
  66773. offset: Vector2;
  66774. /**
  66775. * Initializes a texture package frame.
  66776. * @param id The numerical frame identifier
  66777. * @param scale Scalar Vector2 for UV frame
  66778. * @param offset Vector2 for the frame position in UV units.
  66779. * @returns TexturePackerFrame
  66780. */
  66781. constructor(id: number, scale: Vector2, offset: Vector2);
  66782. }
  66783. }
  66784. declare module BABYLON {
  66785. /**
  66786. * Defines the basic options interface of a TexturePacker
  66787. */
  66788. export interface ITexturePackerOptions {
  66789. /**
  66790. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66791. */
  66792. map?: string[];
  66793. /**
  66794. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66795. */
  66796. uvsIn?: string;
  66797. /**
  66798. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66799. */
  66800. uvsOut?: string;
  66801. /**
  66802. * number representing the layout style. Defaults to LAYOUT_STRIP
  66803. */
  66804. layout?: number;
  66805. /**
  66806. * number of columns if using custom column count layout(2). This defaults to 4.
  66807. */
  66808. colnum?: number;
  66809. /**
  66810. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66811. */
  66812. updateInputMeshes?: boolean;
  66813. /**
  66814. * boolean flag to dispose all the source textures. Defaults to true.
  66815. */
  66816. disposeSources?: boolean;
  66817. /**
  66818. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66819. */
  66820. fillBlanks?: boolean;
  66821. /**
  66822. * string value representing the context fill style color. Defaults to 'black'.
  66823. */
  66824. customFillColor?: string;
  66825. /**
  66826. * Width and Height Value of each Frame in the TexturePacker Sets
  66827. */
  66828. frameSize?: number;
  66829. /**
  66830. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66831. */
  66832. paddingRatio?: number;
  66833. /**
  66834. * Number that declares the fill method for the padding gutter.
  66835. */
  66836. paddingMode?: number;
  66837. /**
  66838. * If in SUBUV_COLOR padding mode what color to use.
  66839. */
  66840. paddingColor?: Color3 | Color4;
  66841. }
  66842. /**
  66843. * Defines the basic interface of a TexturePacker JSON File
  66844. */
  66845. export interface ITexturePackerJSON {
  66846. /**
  66847. * The frame ID
  66848. */
  66849. name: string;
  66850. /**
  66851. * The base64 channel data
  66852. */
  66853. sets: any;
  66854. /**
  66855. * The options of the Packer
  66856. */
  66857. options: ITexturePackerOptions;
  66858. /**
  66859. * The frame data of the Packer
  66860. */
  66861. frames: Array<number>;
  66862. }
  66863. /**
  66864. * This is a support class that generates a series of packed texture sets.
  66865. * @see https://doc.babylonjs.com/babylon101/materials
  66866. */
  66867. export class TexturePacker {
  66868. /** Packer Layout Constant 0 */
  66869. static readonly LAYOUT_STRIP: number;
  66870. /** Packer Layout Constant 1 */
  66871. static readonly LAYOUT_POWER2: number;
  66872. /** Packer Layout Constant 2 */
  66873. static readonly LAYOUT_COLNUM: number;
  66874. /** Packer Layout Constant 0 */
  66875. static readonly SUBUV_WRAP: number;
  66876. /** Packer Layout Constant 1 */
  66877. static readonly SUBUV_EXTEND: number;
  66878. /** Packer Layout Constant 2 */
  66879. static readonly SUBUV_COLOR: number;
  66880. /** The Name of the Texture Package */
  66881. name: string;
  66882. /** The scene scope of the TexturePacker */
  66883. scene: Scene;
  66884. /** The Meshes to target */
  66885. meshes: AbstractMesh[];
  66886. /** Arguments passed with the Constructor */
  66887. options: ITexturePackerOptions;
  66888. /** The promise that is started upon initialization */
  66889. promise: Nullable<Promise<TexturePacker | string>>;
  66890. /** The Container object for the channel sets that are generated */
  66891. sets: object;
  66892. /** The Container array for the frames that are generated */
  66893. frames: TexturePackerFrame[];
  66894. /** The expected number of textures the system is parsing. */
  66895. private _expecting;
  66896. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66897. private _paddingValue;
  66898. /**
  66899. * Initializes a texture package series from an array of meshes or a single mesh.
  66900. * @param name The name of the package
  66901. * @param meshes The target meshes to compose the package from
  66902. * @param options The arguments that texture packer should follow while building.
  66903. * @param scene The scene which the textures are scoped to.
  66904. * @returns TexturePacker
  66905. */
  66906. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66907. /**
  66908. * Starts the package process
  66909. * @param resolve The promises resolution function
  66910. * @returns TexturePacker
  66911. */
  66912. private _createFrames;
  66913. /**
  66914. * Calculates the Size of the Channel Sets
  66915. * @returns Vector2
  66916. */
  66917. private _calculateSize;
  66918. /**
  66919. * Calculates the UV data for the frames.
  66920. * @param baseSize the base frameSize
  66921. * @param padding the base frame padding
  66922. * @param dtSize size of the Dynamic Texture for that channel
  66923. * @param dtUnits is 1/dtSize
  66924. * @param update flag to update the input meshes
  66925. */
  66926. private _calculateMeshUVFrames;
  66927. /**
  66928. * Calculates the frames Offset.
  66929. * @param index of the frame
  66930. * @returns Vector2
  66931. */
  66932. private _getFrameOffset;
  66933. /**
  66934. * Updates a Mesh to the frame data
  66935. * @param mesh that is the target
  66936. * @param frameID or the frame index
  66937. */
  66938. private _updateMeshUV;
  66939. /**
  66940. * Updates a Meshes materials to use the texture packer channels
  66941. * @param m is the mesh to target
  66942. * @param force all channels on the packer to be set.
  66943. */
  66944. private _updateTextureReferences;
  66945. /**
  66946. * Public method to set a Mesh to a frame
  66947. * @param m that is the target
  66948. * @param frameID or the frame index
  66949. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66950. */
  66951. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66952. /**
  66953. * Starts the async promise to compile the texture packer.
  66954. * @returns Promise<void>
  66955. */
  66956. processAsync(): Promise<void>;
  66957. /**
  66958. * Disposes all textures associated with this packer
  66959. */
  66960. dispose(): void;
  66961. /**
  66962. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66963. * @param imageType is the image type to use.
  66964. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66965. */
  66966. download(imageType?: string, quality?: number): void;
  66967. /**
  66968. * Public method to load a texturePacker JSON file.
  66969. * @param data of the JSON file in string format.
  66970. */
  66971. updateFromJSON(data: string): void;
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * 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.
  66977. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66978. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66979. */
  66980. export class CustomProceduralTexture extends ProceduralTexture {
  66981. private _animate;
  66982. private _time;
  66983. private _config;
  66984. private _texturePath;
  66985. /**
  66986. * Instantiates a new Custom Procedural Texture.
  66987. * 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.
  66988. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66989. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66990. * @param name Define the name of the texture
  66991. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  66992. * @param size Define the size of the texture to create
  66993. * @param scene Define the scene the texture belongs to
  66994. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66995. * @param generateMipMaps Define if the texture should creates mip maps or not
  66996. */
  66997. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66998. private _loadJson;
  66999. /**
  67000. * Is the texture ready to be used ? (rendered at least once)
  67001. * @returns true if ready, otherwise, false.
  67002. */
  67003. isReady(): boolean;
  67004. /**
  67005. * Render the texture to its associated render target.
  67006. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67007. */
  67008. render(useCameraPostProcess?: boolean): void;
  67009. /**
  67010. * Update the list of dependant textures samplers in the shader.
  67011. */
  67012. updateTextures(): void;
  67013. /**
  67014. * Update the uniform values of the procedural texture in the shader.
  67015. */
  67016. updateShaderUniforms(): void;
  67017. /**
  67018. * Define if the texture animates or not.
  67019. */
  67020. get animate(): boolean;
  67021. set animate(value: boolean);
  67022. }
  67023. }
  67024. declare module BABYLON {
  67025. /** @hidden */
  67026. export var noisePixelShader: {
  67027. name: string;
  67028. shader: string;
  67029. };
  67030. }
  67031. declare module BABYLON {
  67032. /**
  67033. * Class used to generate noise procedural textures
  67034. */
  67035. export class NoiseProceduralTexture extends ProceduralTexture {
  67036. /** Gets or sets the start time (default is 0) */
  67037. time: number;
  67038. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67039. brightness: number;
  67040. /** Defines the number of octaves to process */
  67041. octaves: number;
  67042. /** Defines the level of persistence (0.8 by default) */
  67043. persistence: number;
  67044. /** Gets or sets animation speed factor (default is 1) */
  67045. animationSpeedFactor: number;
  67046. /**
  67047. * Creates a new NoiseProceduralTexture
  67048. * @param name defines the name fo the texture
  67049. * @param size defines the size of the texture (default is 256)
  67050. * @param scene defines the hosting scene
  67051. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67052. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67053. */
  67054. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67055. private _updateShaderUniforms;
  67056. protected _getDefines(): string;
  67057. /** Generate the current state of the procedural texture */
  67058. render(useCameraPostProcess?: boolean): void;
  67059. /**
  67060. * Serializes this noise procedural texture
  67061. * @returns a serialized noise procedural texture object
  67062. */
  67063. serialize(): any;
  67064. /**
  67065. * Clone the texture.
  67066. * @returns the cloned texture
  67067. */
  67068. clone(): NoiseProceduralTexture;
  67069. /**
  67070. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67071. * @param parsedTexture defines parsed texture data
  67072. * @param scene defines the current scene
  67073. * @param rootUrl defines the root URL containing noise procedural texture information
  67074. * @returns a parsed NoiseProceduralTexture
  67075. */
  67076. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67077. }
  67078. }
  67079. declare module BABYLON {
  67080. /**
  67081. * Raw cube texture where the raw buffers are passed in
  67082. */
  67083. export class RawCubeTexture extends CubeTexture {
  67084. /**
  67085. * Creates a cube texture where the raw buffers are passed in.
  67086. * @param scene defines the scene the texture is attached to
  67087. * @param data defines the array of data to use to create each face
  67088. * @param size defines the size of the textures
  67089. * @param format defines the format of the data
  67090. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67091. * @param generateMipMaps defines if the engine should generate the mip levels
  67092. * @param invertY defines if data must be stored with Y axis inverted
  67093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67094. * @param compression defines the compression used (null by default)
  67095. */
  67096. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67097. /**
  67098. * Updates the raw cube texture.
  67099. * @param data defines the data to store
  67100. * @param format defines the data format
  67101. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67102. * @param invertY defines if data must be stored with Y axis inverted
  67103. * @param compression defines the compression used (null by default)
  67104. * @param level defines which level of the texture to update
  67105. */
  67106. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67107. /**
  67108. * Updates a raw cube texture with RGBD encoded data.
  67109. * @param data defines the array of data [mipmap][face] to use to create each face
  67110. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67111. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67112. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67113. * @returns a promise that resolves when the operation is complete
  67114. */
  67115. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67116. /**
  67117. * Clones the raw cube texture.
  67118. * @return a new cube texture
  67119. */
  67120. clone(): CubeTexture;
  67121. /** @hidden */
  67122. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67123. }
  67124. }
  67125. declare module BABYLON {
  67126. /**
  67127. * Class used to store 2D array textures containing user data
  67128. */
  67129. export class RawTexture2DArray extends Texture {
  67130. /** Gets or sets the texture format to use */
  67131. format: number;
  67132. /**
  67133. * Create a new RawTexture2DArray
  67134. * @param data defines the data of the texture
  67135. * @param width defines the width of the texture
  67136. * @param height defines the height of the texture
  67137. * @param depth defines the number of layers of the texture
  67138. * @param format defines the texture format to use
  67139. * @param scene defines the hosting scene
  67140. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67141. * @param invertY defines if texture must be stored with Y axis inverted
  67142. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67143. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67144. */
  67145. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67146. /** Gets or sets the texture format to use */
  67147. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67148. /**
  67149. * Update the texture with new data
  67150. * @param data defines the data to store in the texture
  67151. */
  67152. update(data: ArrayBufferView): void;
  67153. }
  67154. }
  67155. declare module BABYLON {
  67156. /**
  67157. * Class used to store 3D textures containing user data
  67158. */
  67159. export class RawTexture3D extends Texture {
  67160. /** Gets or sets the texture format to use */
  67161. format: number;
  67162. /**
  67163. * Create a new RawTexture3D
  67164. * @param data defines the data of the texture
  67165. * @param width defines the width of the texture
  67166. * @param height defines the height of the texture
  67167. * @param depth defines the depth of the texture
  67168. * @param format defines the texture format to use
  67169. * @param scene defines the hosting scene
  67170. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67171. * @param invertY defines if texture must be stored with Y axis inverted
  67172. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67173. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67174. */
  67175. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67176. /** Gets or sets the texture format to use */
  67177. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67178. /**
  67179. * Update the texture with new data
  67180. * @param data defines the data to store in the texture
  67181. */
  67182. update(data: ArrayBufferView): void;
  67183. }
  67184. }
  67185. declare module BABYLON {
  67186. /**
  67187. * Creates a refraction texture used by refraction channel of the standard material.
  67188. * It is like a mirror but to see through a material.
  67189. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67190. */
  67191. export class RefractionTexture extends RenderTargetTexture {
  67192. /**
  67193. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67194. * 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.
  67195. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67196. */
  67197. refractionPlane: Plane;
  67198. /**
  67199. * Define how deep under the surface we should see.
  67200. */
  67201. depth: number;
  67202. /**
  67203. * Creates a refraction texture used by refraction channel of the standard material.
  67204. * It is like a mirror but to see through a material.
  67205. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67206. * @param name Define the texture name
  67207. * @param size Define the size of the underlying texture
  67208. * @param scene Define the scene the refraction belongs to
  67209. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67210. */
  67211. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67212. /**
  67213. * Clone the refraction texture.
  67214. * @returns the cloned texture
  67215. */
  67216. clone(): RefractionTexture;
  67217. /**
  67218. * Serialize the texture to a JSON representation you could use in Parse later on
  67219. * @returns the serialized JSON representation
  67220. */
  67221. serialize(): any;
  67222. }
  67223. }
  67224. declare module BABYLON {
  67225. /**
  67226. * Block used to add support for vertex skinning (bones)
  67227. */
  67228. export class BonesBlock extends NodeMaterialBlock {
  67229. /**
  67230. * Creates a new BonesBlock
  67231. * @param name defines the block name
  67232. */
  67233. constructor(name: string);
  67234. /**
  67235. * Initialize the block and prepare the context for build
  67236. * @param state defines the state that will be used for the build
  67237. */
  67238. initialize(state: NodeMaterialBuildState): void;
  67239. /**
  67240. * Gets the current class name
  67241. * @returns the class name
  67242. */
  67243. getClassName(): string;
  67244. /**
  67245. * Gets the matrix indices input component
  67246. */
  67247. get matricesIndices(): NodeMaterialConnectionPoint;
  67248. /**
  67249. * Gets the matrix weights input component
  67250. */
  67251. get matricesWeights(): NodeMaterialConnectionPoint;
  67252. /**
  67253. * Gets the extra matrix indices input component
  67254. */
  67255. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67256. /**
  67257. * Gets the extra matrix weights input component
  67258. */
  67259. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67260. /**
  67261. * Gets the world input component
  67262. */
  67263. get world(): NodeMaterialConnectionPoint;
  67264. /**
  67265. * Gets the output component
  67266. */
  67267. get output(): NodeMaterialConnectionPoint;
  67268. autoConfigure(material: NodeMaterial): void;
  67269. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67272. protected _buildBlock(state: NodeMaterialBuildState): this;
  67273. }
  67274. }
  67275. declare module BABYLON {
  67276. /**
  67277. * Block used to add support for instances
  67278. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67279. */
  67280. export class InstancesBlock extends NodeMaterialBlock {
  67281. /**
  67282. * Creates a new InstancesBlock
  67283. * @param name defines the block name
  67284. */
  67285. constructor(name: string);
  67286. /**
  67287. * Gets the current class name
  67288. * @returns the class name
  67289. */
  67290. getClassName(): string;
  67291. /**
  67292. * Gets the first world row input component
  67293. */
  67294. get world0(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the second world row input component
  67297. */
  67298. get world1(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the third world row input component
  67301. */
  67302. get world2(): NodeMaterialConnectionPoint;
  67303. /**
  67304. * Gets the forth world row input component
  67305. */
  67306. get world3(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the world input component
  67309. */
  67310. get world(): NodeMaterialConnectionPoint;
  67311. /**
  67312. * Gets the output component
  67313. */
  67314. get output(): NodeMaterialConnectionPoint;
  67315. /**
  67316. * Gets the instanceID component
  67317. */
  67318. get instanceID(): NodeMaterialConnectionPoint;
  67319. autoConfigure(material: NodeMaterial): void;
  67320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67321. protected _buildBlock(state: NodeMaterialBuildState): this;
  67322. }
  67323. }
  67324. declare module BABYLON {
  67325. /**
  67326. * Block used to add morph targets support to vertex shader
  67327. */
  67328. export class MorphTargetsBlock extends NodeMaterialBlock {
  67329. private _repeatableContentAnchor;
  67330. /**
  67331. * Create a new MorphTargetsBlock
  67332. * @param name defines the block name
  67333. */
  67334. constructor(name: string);
  67335. /**
  67336. * Gets the current class name
  67337. * @returns the class name
  67338. */
  67339. getClassName(): string;
  67340. /**
  67341. * Gets the position input component
  67342. */
  67343. get position(): NodeMaterialConnectionPoint;
  67344. /**
  67345. * Gets the normal input component
  67346. */
  67347. get normal(): NodeMaterialConnectionPoint;
  67348. /**
  67349. * Gets the tangent input component
  67350. */
  67351. get tangent(): NodeMaterialConnectionPoint;
  67352. /**
  67353. * Gets the tangent input component
  67354. */
  67355. get uv(): NodeMaterialConnectionPoint;
  67356. /**
  67357. * Gets the position output component
  67358. */
  67359. get positionOutput(): NodeMaterialConnectionPoint;
  67360. /**
  67361. * Gets the normal output component
  67362. */
  67363. get normalOutput(): NodeMaterialConnectionPoint;
  67364. /**
  67365. * Gets the tangent output component
  67366. */
  67367. get tangentOutput(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the tangent output component
  67370. */
  67371. get uvOutput(): NodeMaterialConnectionPoint;
  67372. initialize(state: NodeMaterialBuildState): void;
  67373. autoConfigure(material: NodeMaterial): void;
  67374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67376. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67377. protected _buildBlock(state: NodeMaterialBuildState): this;
  67378. }
  67379. }
  67380. declare module BABYLON {
  67381. /**
  67382. * Block used to get data information from a light
  67383. */
  67384. export class LightInformationBlock extends NodeMaterialBlock {
  67385. private _lightDataUniformName;
  67386. private _lightColorUniformName;
  67387. private _lightTypeDefineName;
  67388. /**
  67389. * Gets or sets the light associated with this block
  67390. */
  67391. light: Nullable<Light>;
  67392. /**
  67393. * Creates a new LightInformationBlock
  67394. * @param name defines the block name
  67395. */
  67396. constructor(name: string);
  67397. /**
  67398. * Gets the current class name
  67399. * @returns the class name
  67400. */
  67401. getClassName(): string;
  67402. /**
  67403. * Gets the world position input component
  67404. */
  67405. get worldPosition(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the direction output component
  67408. */
  67409. get direction(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Gets the direction output component
  67412. */
  67413. get color(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the direction output component
  67416. */
  67417. get intensity(): NodeMaterialConnectionPoint;
  67418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67420. protected _buildBlock(state: NodeMaterialBuildState): this;
  67421. serialize(): any;
  67422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67423. }
  67424. }
  67425. declare module BABYLON {
  67426. /**
  67427. * Block used to add image processing support to fragment shader
  67428. */
  67429. export class ImageProcessingBlock extends NodeMaterialBlock {
  67430. /**
  67431. * Create a new ImageProcessingBlock
  67432. * @param name defines the block name
  67433. */
  67434. constructor(name: string);
  67435. /**
  67436. * Gets the current class name
  67437. * @returns the class name
  67438. */
  67439. getClassName(): string;
  67440. /**
  67441. * Gets the color input component
  67442. */
  67443. get color(): NodeMaterialConnectionPoint;
  67444. /**
  67445. * Gets the output component
  67446. */
  67447. get output(): NodeMaterialConnectionPoint;
  67448. /**
  67449. * Initialize the block and prepare the context for build
  67450. * @param state defines the state that will be used for the build
  67451. */
  67452. initialize(state: NodeMaterialBuildState): void;
  67453. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67456. protected _buildBlock(state: NodeMaterialBuildState): this;
  67457. }
  67458. }
  67459. declare module BABYLON {
  67460. /**
  67461. * Block used to perturb normals based on a normal map
  67462. */
  67463. export class PerturbNormalBlock extends NodeMaterialBlock {
  67464. private _tangentSpaceParameterName;
  67465. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67466. invertX: boolean;
  67467. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67468. invertY: boolean;
  67469. /**
  67470. * Create a new PerturbNormalBlock
  67471. * @param name defines the block name
  67472. */
  67473. constructor(name: string);
  67474. /**
  67475. * Gets the current class name
  67476. * @returns the class name
  67477. */
  67478. getClassName(): string;
  67479. /**
  67480. * Gets the world position input component
  67481. */
  67482. get worldPosition(): NodeMaterialConnectionPoint;
  67483. /**
  67484. * Gets the world normal input component
  67485. */
  67486. get worldNormal(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the world tangent input component
  67489. */
  67490. get worldTangent(): NodeMaterialConnectionPoint;
  67491. /**
  67492. * Gets the uv input component
  67493. */
  67494. get uv(): NodeMaterialConnectionPoint;
  67495. /**
  67496. * Gets the normal map color input component
  67497. */
  67498. get normalMapColor(): NodeMaterialConnectionPoint;
  67499. /**
  67500. * Gets the strength input component
  67501. */
  67502. get strength(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the output component
  67505. */
  67506. get output(): NodeMaterialConnectionPoint;
  67507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67509. autoConfigure(material: NodeMaterial): void;
  67510. protected _buildBlock(state: NodeMaterialBuildState): this;
  67511. protected _dumpPropertiesCode(): string;
  67512. serialize(): any;
  67513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67514. }
  67515. }
  67516. declare module BABYLON {
  67517. /**
  67518. * Block used to discard a pixel if a value is smaller than a cutoff
  67519. */
  67520. export class DiscardBlock extends NodeMaterialBlock {
  67521. /**
  67522. * Create a new DiscardBlock
  67523. * @param name defines the block name
  67524. */
  67525. constructor(name: string);
  67526. /**
  67527. * Gets the current class name
  67528. * @returns the class name
  67529. */
  67530. getClassName(): string;
  67531. /**
  67532. * Gets the color input component
  67533. */
  67534. get value(): NodeMaterialConnectionPoint;
  67535. /**
  67536. * Gets the cutoff input component
  67537. */
  67538. get cutoff(): NodeMaterialConnectionPoint;
  67539. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67540. }
  67541. }
  67542. declare module BABYLON {
  67543. /**
  67544. * Block used to test if the fragment shader is front facing
  67545. */
  67546. export class FrontFacingBlock extends NodeMaterialBlock {
  67547. /**
  67548. * Creates a new FrontFacingBlock
  67549. * @param name defines the block name
  67550. */
  67551. constructor(name: string);
  67552. /**
  67553. * Gets the current class name
  67554. * @returns the class name
  67555. */
  67556. getClassName(): string;
  67557. /**
  67558. * Gets the output component
  67559. */
  67560. get output(): NodeMaterialConnectionPoint;
  67561. protected _buildBlock(state: NodeMaterialBuildState): this;
  67562. }
  67563. }
  67564. declare module BABYLON {
  67565. /**
  67566. * Block used to get the derivative value on x and y of a given input
  67567. */
  67568. export class DerivativeBlock extends NodeMaterialBlock {
  67569. /**
  67570. * Create a new DerivativeBlock
  67571. * @param name defines the block name
  67572. */
  67573. constructor(name: string);
  67574. /**
  67575. * Gets the current class name
  67576. * @returns the class name
  67577. */
  67578. getClassName(): string;
  67579. /**
  67580. * Gets the input component
  67581. */
  67582. get input(): NodeMaterialConnectionPoint;
  67583. /**
  67584. * Gets the derivative output on x
  67585. */
  67586. get dx(): NodeMaterialConnectionPoint;
  67587. /**
  67588. * Gets the derivative output on y
  67589. */
  67590. get dy(): NodeMaterialConnectionPoint;
  67591. protected _buildBlock(state: NodeMaterialBuildState): this;
  67592. }
  67593. }
  67594. declare module BABYLON {
  67595. /**
  67596. * Block used to make gl_FragCoord available
  67597. */
  67598. export class FragCoordBlock extends NodeMaterialBlock {
  67599. /**
  67600. * Creates a new FragCoordBlock
  67601. * @param name defines the block name
  67602. */
  67603. constructor(name: string);
  67604. /**
  67605. * Gets the current class name
  67606. * @returns the class name
  67607. */
  67608. getClassName(): string;
  67609. /**
  67610. * Gets the xy component
  67611. */
  67612. get xy(): NodeMaterialConnectionPoint;
  67613. /**
  67614. * Gets the xyz component
  67615. */
  67616. get xyz(): NodeMaterialConnectionPoint;
  67617. /**
  67618. * Gets the xyzw component
  67619. */
  67620. get xyzw(): NodeMaterialConnectionPoint;
  67621. /**
  67622. * Gets the x component
  67623. */
  67624. get x(): NodeMaterialConnectionPoint;
  67625. /**
  67626. * Gets the y component
  67627. */
  67628. get y(): NodeMaterialConnectionPoint;
  67629. /**
  67630. * Gets the z component
  67631. */
  67632. get z(): NodeMaterialConnectionPoint;
  67633. /**
  67634. * Gets the w component
  67635. */
  67636. get output(): NodeMaterialConnectionPoint;
  67637. protected writeOutputs(state: NodeMaterialBuildState): string;
  67638. protected _buildBlock(state: NodeMaterialBuildState): this;
  67639. }
  67640. }
  67641. declare module BABYLON {
  67642. /**
  67643. * Block used to get the screen sizes
  67644. */
  67645. export class ScreenSizeBlock extends NodeMaterialBlock {
  67646. private _varName;
  67647. private _scene;
  67648. /**
  67649. * Creates a new ScreenSizeBlock
  67650. * @param name defines the block name
  67651. */
  67652. constructor(name: string);
  67653. /**
  67654. * Gets the current class name
  67655. * @returns the class name
  67656. */
  67657. getClassName(): string;
  67658. /**
  67659. * Gets the xy component
  67660. */
  67661. get xy(): NodeMaterialConnectionPoint;
  67662. /**
  67663. * Gets the x component
  67664. */
  67665. get x(): NodeMaterialConnectionPoint;
  67666. /**
  67667. * Gets the y component
  67668. */
  67669. get y(): NodeMaterialConnectionPoint;
  67670. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67671. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67672. protected _buildBlock(state: NodeMaterialBuildState): this;
  67673. }
  67674. }
  67675. declare module BABYLON {
  67676. /**
  67677. * Block used to add support for scene fog
  67678. */
  67679. export class FogBlock extends NodeMaterialBlock {
  67680. private _fogDistanceName;
  67681. private _fogParameters;
  67682. /**
  67683. * Create a new FogBlock
  67684. * @param name defines the block name
  67685. */
  67686. constructor(name: string);
  67687. /**
  67688. * Gets the current class name
  67689. * @returns the class name
  67690. */
  67691. getClassName(): string;
  67692. /**
  67693. * Gets the world position input component
  67694. */
  67695. get worldPosition(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the view input component
  67698. */
  67699. get view(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Gets the color input component
  67702. */
  67703. get input(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the fog color input component
  67706. */
  67707. get fogColor(): NodeMaterialConnectionPoint;
  67708. /**
  67709. * Gets the output component
  67710. */
  67711. get output(): NodeMaterialConnectionPoint;
  67712. autoConfigure(material: NodeMaterial): void;
  67713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67715. protected _buildBlock(state: NodeMaterialBuildState): this;
  67716. }
  67717. }
  67718. declare module BABYLON {
  67719. /**
  67720. * Block used to add light in the fragment shader
  67721. */
  67722. export class LightBlock extends NodeMaterialBlock {
  67723. private _lightId;
  67724. /**
  67725. * Gets or sets the light associated with this block
  67726. */
  67727. light: Nullable<Light>;
  67728. /**
  67729. * Create a new LightBlock
  67730. * @param name defines the block name
  67731. */
  67732. constructor(name: string);
  67733. /**
  67734. * Gets the current class name
  67735. * @returns the class name
  67736. */
  67737. getClassName(): string;
  67738. /**
  67739. * Gets the world position input component
  67740. */
  67741. get worldPosition(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the world normal input component
  67744. */
  67745. get worldNormal(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the camera (or eye) position component
  67748. */
  67749. get cameraPosition(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the glossiness component
  67752. */
  67753. get glossiness(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the glossiness power component
  67756. */
  67757. get glossPower(): NodeMaterialConnectionPoint;
  67758. /**
  67759. * Gets the diffuse color component
  67760. */
  67761. get diffuseColor(): NodeMaterialConnectionPoint;
  67762. /**
  67763. * Gets the specular color component
  67764. */
  67765. get specularColor(): NodeMaterialConnectionPoint;
  67766. /**
  67767. * Gets the view matrix component
  67768. */
  67769. get view(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the diffuse output component
  67772. */
  67773. get diffuseOutput(): NodeMaterialConnectionPoint;
  67774. /**
  67775. * Gets the specular output component
  67776. */
  67777. get specularOutput(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the shadow output component
  67780. */
  67781. get shadow(): NodeMaterialConnectionPoint;
  67782. autoConfigure(material: NodeMaterial): void;
  67783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67784. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67786. private _injectVertexCode;
  67787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67788. serialize(): any;
  67789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67790. }
  67791. }
  67792. declare module BABYLON {
  67793. /**
  67794. * Block used to read a reflection texture from a sampler
  67795. */
  67796. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67797. /**
  67798. * Create a new ReflectionTextureBlock
  67799. * @param name defines the block name
  67800. */
  67801. constructor(name: string);
  67802. /**
  67803. * Gets the current class name
  67804. * @returns the class name
  67805. */
  67806. getClassName(): string;
  67807. /**
  67808. * Gets the world position input component
  67809. */
  67810. get position(): NodeMaterialConnectionPoint;
  67811. /**
  67812. * Gets the world position input component
  67813. */
  67814. get worldPosition(): NodeMaterialConnectionPoint;
  67815. /**
  67816. * Gets the world normal input component
  67817. */
  67818. get worldNormal(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the world input component
  67821. */
  67822. get world(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the camera (or eye) position component
  67825. */
  67826. get cameraPosition(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the view input component
  67829. */
  67830. get view(): NodeMaterialConnectionPoint;
  67831. /**
  67832. * Gets the rgb output component
  67833. */
  67834. get rgb(): NodeMaterialConnectionPoint;
  67835. /**
  67836. * Gets the rgba output component
  67837. */
  67838. get rgba(): NodeMaterialConnectionPoint;
  67839. /**
  67840. * Gets the r output component
  67841. */
  67842. get r(): NodeMaterialConnectionPoint;
  67843. /**
  67844. * Gets the g output component
  67845. */
  67846. get g(): NodeMaterialConnectionPoint;
  67847. /**
  67848. * Gets the b output component
  67849. */
  67850. get b(): NodeMaterialConnectionPoint;
  67851. /**
  67852. * Gets the a output component
  67853. */
  67854. get a(): NodeMaterialConnectionPoint;
  67855. autoConfigure(material: NodeMaterial): void;
  67856. protected _buildBlock(state: NodeMaterialBuildState): this;
  67857. }
  67858. }
  67859. declare module BABYLON {
  67860. /**
  67861. * Block used to add 2 vectors
  67862. */
  67863. export class AddBlock extends NodeMaterialBlock {
  67864. /**
  67865. * Creates a new AddBlock
  67866. * @param name defines the block name
  67867. */
  67868. constructor(name: string);
  67869. /**
  67870. * Gets the current class name
  67871. * @returns the class name
  67872. */
  67873. getClassName(): string;
  67874. /**
  67875. * Gets the left operand input component
  67876. */
  67877. get left(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the right operand input component
  67880. */
  67881. get right(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the output component
  67884. */
  67885. get output(): NodeMaterialConnectionPoint;
  67886. protected _buildBlock(state: NodeMaterialBuildState): this;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Block used to scale a vector by a float
  67892. */
  67893. export class ScaleBlock extends NodeMaterialBlock {
  67894. /**
  67895. * Creates a new ScaleBlock
  67896. * @param name defines the block name
  67897. */
  67898. constructor(name: string);
  67899. /**
  67900. * Gets the current class name
  67901. * @returns the class name
  67902. */
  67903. getClassName(): string;
  67904. /**
  67905. * Gets the input component
  67906. */
  67907. get input(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the factor input component
  67910. */
  67911. get factor(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the output component
  67914. */
  67915. get output(): NodeMaterialConnectionPoint;
  67916. protected _buildBlock(state: NodeMaterialBuildState): this;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Block used to clamp a float
  67922. */
  67923. export class ClampBlock extends NodeMaterialBlock {
  67924. /** Gets or sets the minimum range */
  67925. minimum: number;
  67926. /** Gets or sets the maximum range */
  67927. maximum: number;
  67928. /**
  67929. * Creates a new ClampBlock
  67930. * @param name defines the block name
  67931. */
  67932. constructor(name: string);
  67933. /**
  67934. * Gets the current class name
  67935. * @returns the class name
  67936. */
  67937. getClassName(): string;
  67938. /**
  67939. * Gets the value input component
  67940. */
  67941. get value(): NodeMaterialConnectionPoint;
  67942. /**
  67943. * Gets the output component
  67944. */
  67945. get output(): NodeMaterialConnectionPoint;
  67946. protected _buildBlock(state: NodeMaterialBuildState): this;
  67947. protected _dumpPropertiesCode(): string;
  67948. serialize(): any;
  67949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67950. }
  67951. }
  67952. declare module BABYLON {
  67953. /**
  67954. * Block used to apply a cross product between 2 vectors
  67955. */
  67956. export class CrossBlock extends NodeMaterialBlock {
  67957. /**
  67958. * Creates a new CrossBlock
  67959. * @param name defines the block name
  67960. */
  67961. constructor(name: string);
  67962. /**
  67963. * Gets the current class name
  67964. * @returns the class name
  67965. */
  67966. getClassName(): string;
  67967. /**
  67968. * Gets the left operand input component
  67969. */
  67970. get left(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the right operand input component
  67973. */
  67974. get right(): NodeMaterialConnectionPoint;
  67975. /**
  67976. * Gets the output component
  67977. */
  67978. get output(): NodeMaterialConnectionPoint;
  67979. protected _buildBlock(state: NodeMaterialBuildState): this;
  67980. }
  67981. }
  67982. declare module BABYLON {
  67983. /**
  67984. * Block used to apply a dot product between 2 vectors
  67985. */
  67986. export class DotBlock extends NodeMaterialBlock {
  67987. /**
  67988. * Creates a new DotBlock
  67989. * @param name defines the block name
  67990. */
  67991. constructor(name: string);
  67992. /**
  67993. * Gets the current class name
  67994. * @returns the class name
  67995. */
  67996. getClassName(): string;
  67997. /**
  67998. * Gets the left operand input component
  67999. */
  68000. get left(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the right operand input component
  68003. */
  68004. get right(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the output component
  68007. */
  68008. get output(): NodeMaterialConnectionPoint;
  68009. protected _buildBlock(state: NodeMaterialBuildState): this;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /**
  68014. * Block used to normalize a vector
  68015. */
  68016. export class NormalizeBlock extends NodeMaterialBlock {
  68017. /**
  68018. * Creates a new NormalizeBlock
  68019. * @param name defines the block name
  68020. */
  68021. constructor(name: string);
  68022. /**
  68023. * Gets the current class name
  68024. * @returns the class name
  68025. */
  68026. getClassName(): string;
  68027. /**
  68028. * Gets the input component
  68029. */
  68030. get input(): NodeMaterialConnectionPoint;
  68031. /**
  68032. * Gets the output component
  68033. */
  68034. get output(): NodeMaterialConnectionPoint;
  68035. protected _buildBlock(state: NodeMaterialBuildState): this;
  68036. }
  68037. }
  68038. declare module BABYLON {
  68039. /**
  68040. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68041. */
  68042. export class ColorMergerBlock extends NodeMaterialBlock {
  68043. /**
  68044. * Create a new ColorMergerBlock
  68045. * @param name defines the block name
  68046. */
  68047. constructor(name: string);
  68048. /**
  68049. * Gets the current class name
  68050. * @returns the class name
  68051. */
  68052. getClassName(): string;
  68053. /**
  68054. * Gets the rgb component (input)
  68055. */
  68056. get rgbIn(): NodeMaterialConnectionPoint;
  68057. /**
  68058. * Gets the r component (input)
  68059. */
  68060. get r(): NodeMaterialConnectionPoint;
  68061. /**
  68062. * Gets the g component (input)
  68063. */
  68064. get g(): NodeMaterialConnectionPoint;
  68065. /**
  68066. * Gets the b component (input)
  68067. */
  68068. get b(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the a component (input)
  68071. */
  68072. get a(): NodeMaterialConnectionPoint;
  68073. /**
  68074. * Gets the rgba component (output)
  68075. */
  68076. get rgba(): NodeMaterialConnectionPoint;
  68077. /**
  68078. * Gets the rgb component (output)
  68079. */
  68080. get rgbOut(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the rgb component (output)
  68083. * @deprecated Please use rgbOut instead.
  68084. */
  68085. get rgb(): NodeMaterialConnectionPoint;
  68086. protected _buildBlock(state: NodeMaterialBuildState): this;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68092. */
  68093. export class VectorSplitterBlock extends NodeMaterialBlock {
  68094. /**
  68095. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  68106. */
  68107. get xyzw(): NodeMaterialConnectionPoint;
  68108. /**
  68109. * Gets the xyz component (input)
  68110. */
  68111. get xyzIn(): NodeMaterialConnectionPoint;
  68112. /**
  68113. * Gets the xy component (input)
  68114. */
  68115. get xyIn(): NodeMaterialConnectionPoint;
  68116. /**
  68117. * Gets the xyz component (output)
  68118. */
  68119. get xyzOut(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the xy component (output)
  68122. */
  68123. get xyOut(): NodeMaterialConnectionPoint;
  68124. /**
  68125. * Gets the x component (output)
  68126. */
  68127. get x(): NodeMaterialConnectionPoint;
  68128. /**
  68129. * Gets the y component (output)
  68130. */
  68131. get y(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the z component (output)
  68134. */
  68135. get z(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the w component (output)
  68138. */
  68139. get w(): NodeMaterialConnectionPoint;
  68140. protected _inputRename(name: string): string;
  68141. protected _outputRename(name: string): string;
  68142. protected _buildBlock(state: NodeMaterialBuildState): this;
  68143. }
  68144. }
  68145. declare module BABYLON {
  68146. /**
  68147. * Block used to lerp between 2 values
  68148. */
  68149. export class LerpBlock extends NodeMaterialBlock {
  68150. /**
  68151. * Creates a new LerpBlock
  68152. * @param name defines the block name
  68153. */
  68154. constructor(name: string);
  68155. /**
  68156. * Gets the current class name
  68157. * @returns the class name
  68158. */
  68159. getClassName(): string;
  68160. /**
  68161. * Gets the left operand input component
  68162. */
  68163. get left(): NodeMaterialConnectionPoint;
  68164. /**
  68165. * Gets the right operand input component
  68166. */
  68167. get right(): NodeMaterialConnectionPoint;
  68168. /**
  68169. * Gets the gradient operand input component
  68170. */
  68171. get gradient(): NodeMaterialConnectionPoint;
  68172. /**
  68173. * Gets the output component
  68174. */
  68175. get output(): NodeMaterialConnectionPoint;
  68176. protected _buildBlock(state: NodeMaterialBuildState): this;
  68177. }
  68178. }
  68179. declare module BABYLON {
  68180. /**
  68181. * Block used to divide 2 vectors
  68182. */
  68183. export class DivideBlock extends NodeMaterialBlock {
  68184. /**
  68185. * Creates a new DivideBlock
  68186. * @param name defines the block name
  68187. */
  68188. constructor(name: string);
  68189. /**
  68190. * Gets the current class name
  68191. * @returns the class name
  68192. */
  68193. getClassName(): string;
  68194. /**
  68195. * Gets the left operand input component
  68196. */
  68197. get left(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the right operand input component
  68200. */
  68201. get right(): NodeMaterialConnectionPoint;
  68202. /**
  68203. * Gets the output component
  68204. */
  68205. get output(): NodeMaterialConnectionPoint;
  68206. protected _buildBlock(state: NodeMaterialBuildState): this;
  68207. }
  68208. }
  68209. declare module BABYLON {
  68210. /**
  68211. * Block used to subtract 2 vectors
  68212. */
  68213. export class SubtractBlock extends NodeMaterialBlock {
  68214. /**
  68215. * Creates a new SubtractBlock
  68216. * @param name defines the block name
  68217. */
  68218. constructor(name: string);
  68219. /**
  68220. * Gets the current class name
  68221. * @returns the class name
  68222. */
  68223. getClassName(): string;
  68224. /**
  68225. * Gets the left operand input component
  68226. */
  68227. get left(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the right operand input component
  68230. */
  68231. get right(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the output component
  68234. */
  68235. get output(): NodeMaterialConnectionPoint;
  68236. protected _buildBlock(state: NodeMaterialBuildState): this;
  68237. }
  68238. }
  68239. declare module BABYLON {
  68240. /**
  68241. * Block used to step a value
  68242. */
  68243. export class StepBlock extends NodeMaterialBlock {
  68244. /**
  68245. * Creates a new StepBlock
  68246. * @param name defines the block name
  68247. */
  68248. constructor(name: string);
  68249. /**
  68250. * Gets the current class name
  68251. * @returns the class name
  68252. */
  68253. getClassName(): string;
  68254. /**
  68255. * Gets the value operand input component
  68256. */
  68257. get value(): NodeMaterialConnectionPoint;
  68258. /**
  68259. * Gets the edge operand input component
  68260. */
  68261. get edge(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the output component
  68264. */
  68265. get output(): NodeMaterialConnectionPoint;
  68266. protected _buildBlock(state: NodeMaterialBuildState): this;
  68267. }
  68268. }
  68269. declare module BABYLON {
  68270. /**
  68271. * Block used to get the opposite (1 - x) of a value
  68272. */
  68273. export class OneMinusBlock extends NodeMaterialBlock {
  68274. /**
  68275. * Creates a new OneMinusBlock
  68276. * @param name defines the block name
  68277. */
  68278. constructor(name: string);
  68279. /**
  68280. * Gets the current class name
  68281. * @returns the class name
  68282. */
  68283. getClassName(): string;
  68284. /**
  68285. * Gets the input component
  68286. */
  68287. get input(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the output component
  68290. */
  68291. get output(): NodeMaterialConnectionPoint;
  68292. protected _buildBlock(state: NodeMaterialBuildState): this;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /**
  68297. * Block used to get the view direction
  68298. */
  68299. export class ViewDirectionBlock extends NodeMaterialBlock {
  68300. /**
  68301. * Creates a new ViewDirectionBlock
  68302. * @param name defines the block name
  68303. */
  68304. constructor(name: string);
  68305. /**
  68306. * Gets the current class name
  68307. * @returns the class name
  68308. */
  68309. getClassName(): string;
  68310. /**
  68311. * Gets the world position component
  68312. */
  68313. get worldPosition(): NodeMaterialConnectionPoint;
  68314. /**
  68315. * Gets the camera position component
  68316. */
  68317. get cameraPosition(): NodeMaterialConnectionPoint;
  68318. /**
  68319. * Gets the output component
  68320. */
  68321. get output(): NodeMaterialConnectionPoint;
  68322. autoConfigure(material: NodeMaterial): void;
  68323. protected _buildBlock(state: NodeMaterialBuildState): this;
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * Block used to compute fresnel value
  68329. */
  68330. export class FresnelBlock extends NodeMaterialBlock {
  68331. /**
  68332. * Create a new FresnelBlock
  68333. * @param name defines the block name
  68334. */
  68335. constructor(name: string);
  68336. /**
  68337. * Gets the current class name
  68338. * @returns the class name
  68339. */
  68340. getClassName(): string;
  68341. /**
  68342. * Gets the world normal input component
  68343. */
  68344. get worldNormal(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the view direction input component
  68347. */
  68348. get viewDirection(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the bias input component
  68351. */
  68352. get bias(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the camera (or eye) position component
  68355. */
  68356. get power(): NodeMaterialConnectionPoint;
  68357. /**
  68358. * Gets the fresnel output component
  68359. */
  68360. get fresnel(): NodeMaterialConnectionPoint;
  68361. autoConfigure(material: NodeMaterial): void;
  68362. protected _buildBlock(state: NodeMaterialBuildState): this;
  68363. }
  68364. }
  68365. declare module BABYLON {
  68366. /**
  68367. * Block used to get the max of 2 values
  68368. */
  68369. export class MaxBlock extends NodeMaterialBlock {
  68370. /**
  68371. * Creates a new MaxBlock
  68372. * @param name defines the block name
  68373. */
  68374. constructor(name: string);
  68375. /**
  68376. * Gets the current class name
  68377. * @returns the class name
  68378. */
  68379. getClassName(): string;
  68380. /**
  68381. * Gets the left operand input component
  68382. */
  68383. get left(): NodeMaterialConnectionPoint;
  68384. /**
  68385. * Gets the right operand input component
  68386. */
  68387. get right(): NodeMaterialConnectionPoint;
  68388. /**
  68389. * Gets the output component
  68390. */
  68391. get output(): NodeMaterialConnectionPoint;
  68392. protected _buildBlock(state: NodeMaterialBuildState): this;
  68393. }
  68394. }
  68395. declare module BABYLON {
  68396. /**
  68397. * Block used to get the min of 2 values
  68398. */
  68399. export class MinBlock extends NodeMaterialBlock {
  68400. /**
  68401. * Creates a new MinBlock
  68402. * @param name defines the block name
  68403. */
  68404. constructor(name: string);
  68405. /**
  68406. * Gets the current class name
  68407. * @returns the class name
  68408. */
  68409. getClassName(): string;
  68410. /**
  68411. * Gets the left operand input component
  68412. */
  68413. get left(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the right operand input component
  68416. */
  68417. get right(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the output component
  68420. */
  68421. get output(): NodeMaterialConnectionPoint;
  68422. protected _buildBlock(state: NodeMaterialBuildState): this;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * Block used to get the distance between 2 values
  68428. */
  68429. export class DistanceBlock extends NodeMaterialBlock {
  68430. /**
  68431. * Creates a new DistanceBlock
  68432. * @param name defines the block name
  68433. */
  68434. constructor(name: string);
  68435. /**
  68436. * Gets the current class name
  68437. * @returns the class name
  68438. */
  68439. getClassName(): string;
  68440. /**
  68441. * Gets the left operand input component
  68442. */
  68443. get left(): NodeMaterialConnectionPoint;
  68444. /**
  68445. * Gets the right operand input component
  68446. */
  68447. get right(): NodeMaterialConnectionPoint;
  68448. /**
  68449. * Gets the output component
  68450. */
  68451. get output(): NodeMaterialConnectionPoint;
  68452. protected _buildBlock(state: NodeMaterialBuildState): this;
  68453. }
  68454. }
  68455. declare module BABYLON {
  68456. /**
  68457. * Block used to get the length of a vector
  68458. */
  68459. export class LengthBlock extends NodeMaterialBlock {
  68460. /**
  68461. * Creates a new LengthBlock
  68462. * @param name defines the block name
  68463. */
  68464. constructor(name: string);
  68465. /**
  68466. * Gets the current class name
  68467. * @returns the class name
  68468. */
  68469. getClassName(): string;
  68470. /**
  68471. * Gets the value input component
  68472. */
  68473. get value(): NodeMaterialConnectionPoint;
  68474. /**
  68475. * Gets the output component
  68476. */
  68477. get output(): NodeMaterialConnectionPoint;
  68478. protected _buildBlock(state: NodeMaterialBuildState): this;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /**
  68483. * Block used to get negative version of a value (i.e. x * -1)
  68484. */
  68485. export class NegateBlock extends NodeMaterialBlock {
  68486. /**
  68487. * Creates a new NegateBlock
  68488. * @param name defines the block name
  68489. */
  68490. constructor(name: string);
  68491. /**
  68492. * Gets the current class name
  68493. * @returns the class name
  68494. */
  68495. getClassName(): string;
  68496. /**
  68497. * Gets the value input component
  68498. */
  68499. get value(): NodeMaterialConnectionPoint;
  68500. /**
  68501. * Gets the output component
  68502. */
  68503. get output(): NodeMaterialConnectionPoint;
  68504. protected _buildBlock(state: NodeMaterialBuildState): this;
  68505. }
  68506. }
  68507. declare module BABYLON {
  68508. /**
  68509. * Block used to get the value of the first parameter raised to the power of the second
  68510. */
  68511. export class PowBlock extends NodeMaterialBlock {
  68512. /**
  68513. * Creates a new PowBlock
  68514. * @param name defines the block name
  68515. */
  68516. constructor(name: string);
  68517. /**
  68518. * Gets the current class name
  68519. * @returns the class name
  68520. */
  68521. getClassName(): string;
  68522. /**
  68523. * Gets the value operand input component
  68524. */
  68525. get value(): NodeMaterialConnectionPoint;
  68526. /**
  68527. * Gets the power operand input component
  68528. */
  68529. get power(): NodeMaterialConnectionPoint;
  68530. /**
  68531. * Gets the output component
  68532. */
  68533. get output(): NodeMaterialConnectionPoint;
  68534. protected _buildBlock(state: NodeMaterialBuildState): this;
  68535. }
  68536. }
  68537. declare module BABYLON {
  68538. /**
  68539. * Block used to get a random number
  68540. */
  68541. export class RandomNumberBlock extends NodeMaterialBlock {
  68542. /**
  68543. * Creates a new RandomNumberBlock
  68544. * @param name defines the block name
  68545. */
  68546. constructor(name: string);
  68547. /**
  68548. * Gets the current class name
  68549. * @returns the class name
  68550. */
  68551. getClassName(): string;
  68552. /**
  68553. * Gets the seed input component
  68554. */
  68555. get seed(): NodeMaterialConnectionPoint;
  68556. /**
  68557. * Gets the output component
  68558. */
  68559. get output(): NodeMaterialConnectionPoint;
  68560. protected _buildBlock(state: NodeMaterialBuildState): this;
  68561. }
  68562. }
  68563. declare module BABYLON {
  68564. /**
  68565. * Block used to compute arc tangent of 2 values
  68566. */
  68567. export class ArcTan2Block extends NodeMaterialBlock {
  68568. /**
  68569. * Creates a new ArcTan2Block
  68570. * @param name defines the block name
  68571. */
  68572. constructor(name: string);
  68573. /**
  68574. * Gets the current class name
  68575. * @returns the class name
  68576. */
  68577. getClassName(): string;
  68578. /**
  68579. * Gets the x operand input component
  68580. */
  68581. get x(): NodeMaterialConnectionPoint;
  68582. /**
  68583. * Gets the y operand input component
  68584. */
  68585. get y(): NodeMaterialConnectionPoint;
  68586. /**
  68587. * Gets the output component
  68588. */
  68589. get output(): NodeMaterialConnectionPoint;
  68590. protected _buildBlock(state: NodeMaterialBuildState): this;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * Block used to smooth step a value
  68596. */
  68597. export class SmoothStepBlock extends NodeMaterialBlock {
  68598. /**
  68599. * Creates a new SmoothStepBlock
  68600. * @param name defines the block name
  68601. */
  68602. constructor(name: string);
  68603. /**
  68604. * Gets the current class name
  68605. * @returns the class name
  68606. */
  68607. getClassName(): string;
  68608. /**
  68609. * Gets the value operand input component
  68610. */
  68611. get value(): NodeMaterialConnectionPoint;
  68612. /**
  68613. * Gets the first edge operand input component
  68614. */
  68615. get edge0(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the second edge operand input component
  68618. */
  68619. get edge1(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the output component
  68622. */
  68623. get output(): NodeMaterialConnectionPoint;
  68624. protected _buildBlock(state: NodeMaterialBuildState): this;
  68625. }
  68626. }
  68627. declare module BABYLON {
  68628. /**
  68629. * Block used to get the reciprocal (1 / x) of a value
  68630. */
  68631. export class ReciprocalBlock extends NodeMaterialBlock {
  68632. /**
  68633. * Creates a new ReciprocalBlock
  68634. * @param name defines the block name
  68635. */
  68636. constructor(name: string);
  68637. /**
  68638. * Gets the current class name
  68639. * @returns the class name
  68640. */
  68641. getClassName(): string;
  68642. /**
  68643. * Gets the input component
  68644. */
  68645. get input(): NodeMaterialConnectionPoint;
  68646. /**
  68647. * Gets the output component
  68648. */
  68649. get output(): NodeMaterialConnectionPoint;
  68650. protected _buildBlock(state: NodeMaterialBuildState): this;
  68651. }
  68652. }
  68653. declare module BABYLON {
  68654. /**
  68655. * Block used to replace a color by another one
  68656. */
  68657. export class ReplaceColorBlock extends NodeMaterialBlock {
  68658. /**
  68659. * Creates a new ReplaceColorBlock
  68660. * @param name defines the block name
  68661. */
  68662. constructor(name: string);
  68663. /**
  68664. * Gets the current class name
  68665. * @returns the class name
  68666. */
  68667. getClassName(): string;
  68668. /**
  68669. * Gets the value input component
  68670. */
  68671. get value(): NodeMaterialConnectionPoint;
  68672. /**
  68673. * Gets the reference input component
  68674. */
  68675. get reference(): NodeMaterialConnectionPoint;
  68676. /**
  68677. * Gets the distance input component
  68678. */
  68679. get distance(): NodeMaterialConnectionPoint;
  68680. /**
  68681. * Gets the replacement input component
  68682. */
  68683. get replacement(): NodeMaterialConnectionPoint;
  68684. /**
  68685. * Gets the output component
  68686. */
  68687. get output(): NodeMaterialConnectionPoint;
  68688. protected _buildBlock(state: NodeMaterialBuildState): this;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /**
  68693. * Block used to posterize a value
  68694. * @see https://en.wikipedia.org/wiki/Posterization
  68695. */
  68696. export class PosterizeBlock extends NodeMaterialBlock {
  68697. /**
  68698. * Creates a new PosterizeBlock
  68699. * @param name defines the block name
  68700. */
  68701. constructor(name: string);
  68702. /**
  68703. * Gets the current class name
  68704. * @returns the class name
  68705. */
  68706. getClassName(): string;
  68707. /**
  68708. * Gets the value input component
  68709. */
  68710. get value(): NodeMaterialConnectionPoint;
  68711. /**
  68712. * Gets the steps input component
  68713. */
  68714. get steps(): NodeMaterialConnectionPoint;
  68715. /**
  68716. * Gets the output component
  68717. */
  68718. get output(): NodeMaterialConnectionPoint;
  68719. protected _buildBlock(state: NodeMaterialBuildState): this;
  68720. }
  68721. }
  68722. declare module BABYLON {
  68723. /**
  68724. * Operations supported by the Wave block
  68725. */
  68726. export enum WaveBlockKind {
  68727. /** SawTooth */
  68728. SawTooth = 0,
  68729. /** Square */
  68730. Square = 1,
  68731. /** Triangle */
  68732. Triangle = 2
  68733. }
  68734. /**
  68735. * Block used to apply wave operation to floats
  68736. */
  68737. export class WaveBlock extends NodeMaterialBlock {
  68738. /**
  68739. * Gets or sets the kibnd of wave to be applied by the block
  68740. */
  68741. kind: WaveBlockKind;
  68742. /**
  68743. * Creates a new WaveBlock
  68744. * @param name defines the block name
  68745. */
  68746. constructor(name: string);
  68747. /**
  68748. * Gets the current class name
  68749. * @returns the class name
  68750. */
  68751. getClassName(): string;
  68752. /**
  68753. * Gets the input component
  68754. */
  68755. get input(): NodeMaterialConnectionPoint;
  68756. /**
  68757. * Gets the output component
  68758. */
  68759. get output(): NodeMaterialConnectionPoint;
  68760. protected _buildBlock(state: NodeMaterialBuildState): this;
  68761. serialize(): any;
  68762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68763. }
  68764. }
  68765. declare module BABYLON {
  68766. /**
  68767. * Class used to store a color step for the GradientBlock
  68768. */
  68769. export class GradientBlockColorStep {
  68770. private _step;
  68771. /**
  68772. * Gets value indicating which step this color is associated with (between 0 and 1)
  68773. */
  68774. get step(): number;
  68775. /**
  68776. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68777. */
  68778. set step(val: number);
  68779. private _color;
  68780. /**
  68781. * Gets the color associated with this step
  68782. */
  68783. get color(): Color3;
  68784. /**
  68785. * Sets the color associated with this step
  68786. */
  68787. set color(val: Color3);
  68788. /**
  68789. * Creates a new GradientBlockColorStep
  68790. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68791. * @param color defines the color associated with this step
  68792. */
  68793. constructor(step: number, color: Color3);
  68794. }
  68795. /**
  68796. * Block used to return a color from a gradient based on an input value between 0 and 1
  68797. */
  68798. export class GradientBlock extends NodeMaterialBlock {
  68799. /**
  68800. * Gets or sets the list of color steps
  68801. */
  68802. colorSteps: GradientBlockColorStep[];
  68803. /** Gets an observable raised when the value is changed */
  68804. onValueChangedObservable: Observable<GradientBlock>;
  68805. /** calls observable when the value is changed*/
  68806. colorStepsUpdated(): void;
  68807. /**
  68808. * Creates a new GradientBlock
  68809. * @param name defines the block name
  68810. */
  68811. constructor(name: string);
  68812. /**
  68813. * Gets the current class name
  68814. * @returns the class name
  68815. */
  68816. getClassName(): string;
  68817. /**
  68818. * Gets the gradient input component
  68819. */
  68820. get gradient(): NodeMaterialConnectionPoint;
  68821. /**
  68822. * Gets the output component
  68823. */
  68824. get output(): NodeMaterialConnectionPoint;
  68825. private _writeColorConstant;
  68826. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68827. serialize(): any;
  68828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68829. protected _dumpPropertiesCode(): string;
  68830. }
  68831. }
  68832. declare module BABYLON {
  68833. /**
  68834. * Block used to normalize lerp between 2 values
  68835. */
  68836. export class NLerpBlock extends NodeMaterialBlock {
  68837. /**
  68838. * Creates a new NLerpBlock
  68839. * @param name defines the block name
  68840. */
  68841. constructor(name: string);
  68842. /**
  68843. * Gets the current class name
  68844. * @returns the class name
  68845. */
  68846. getClassName(): string;
  68847. /**
  68848. * Gets the left operand input component
  68849. */
  68850. get left(): NodeMaterialConnectionPoint;
  68851. /**
  68852. * Gets the right operand input component
  68853. */
  68854. get right(): NodeMaterialConnectionPoint;
  68855. /**
  68856. * Gets the gradient operand input component
  68857. */
  68858. get gradient(): NodeMaterialConnectionPoint;
  68859. /**
  68860. * Gets the output component
  68861. */
  68862. get output(): NodeMaterialConnectionPoint;
  68863. protected _buildBlock(state: NodeMaterialBuildState): this;
  68864. }
  68865. }
  68866. declare module BABYLON {
  68867. /**
  68868. * block used to Generate a Worley Noise 3D Noise Pattern
  68869. */
  68870. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68871. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68872. manhattanDistance: boolean;
  68873. /**
  68874. * Creates a new WorleyNoise3DBlock
  68875. * @param name defines the block name
  68876. */
  68877. constructor(name: string);
  68878. /**
  68879. * Gets the current class name
  68880. * @returns the class name
  68881. */
  68882. getClassName(): string;
  68883. /**
  68884. * Gets the seed input component
  68885. */
  68886. get seed(): NodeMaterialConnectionPoint;
  68887. /**
  68888. * Gets the jitter input component
  68889. */
  68890. get jitter(): NodeMaterialConnectionPoint;
  68891. /**
  68892. * Gets the output component
  68893. */
  68894. get output(): NodeMaterialConnectionPoint;
  68895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68896. /**
  68897. * Exposes the properties to the UI?
  68898. */
  68899. protected _dumpPropertiesCode(): string;
  68900. /**
  68901. * Exposes the properties to the Serialize?
  68902. */
  68903. serialize(): any;
  68904. /**
  68905. * Exposes the properties to the deserialize?
  68906. */
  68907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68908. }
  68909. }
  68910. declare module BABYLON {
  68911. /**
  68912. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68913. */
  68914. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68915. /**
  68916. * Creates a new SimplexPerlin3DBlock
  68917. * @param name defines the block name
  68918. */
  68919. constructor(name: string);
  68920. /**
  68921. * Gets the current class name
  68922. * @returns the class name
  68923. */
  68924. getClassName(): string;
  68925. /**
  68926. * Gets the seed operand input component
  68927. */
  68928. get seed(): NodeMaterialConnectionPoint;
  68929. /**
  68930. * Gets the output component
  68931. */
  68932. get output(): NodeMaterialConnectionPoint;
  68933. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68934. }
  68935. }
  68936. declare module BABYLON {
  68937. /**
  68938. * Block used to blend normals
  68939. */
  68940. export class NormalBlendBlock extends NodeMaterialBlock {
  68941. /**
  68942. * Creates a new NormalBlendBlock
  68943. * @param name defines the block name
  68944. */
  68945. constructor(name: string);
  68946. /**
  68947. * Gets the current class name
  68948. * @returns the class name
  68949. */
  68950. getClassName(): string;
  68951. /**
  68952. * Gets the first input component
  68953. */
  68954. get normalMap0(): NodeMaterialConnectionPoint;
  68955. /**
  68956. * Gets the second input component
  68957. */
  68958. get normalMap1(): NodeMaterialConnectionPoint;
  68959. /**
  68960. * Gets the output component
  68961. */
  68962. get output(): NodeMaterialConnectionPoint;
  68963. protected _buildBlock(state: NodeMaterialBuildState): this;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /**
  68968. * Block used to rotate a 2d vector by a given angle
  68969. */
  68970. export class Rotate2dBlock extends NodeMaterialBlock {
  68971. /**
  68972. * Creates a new Rotate2dBlock
  68973. * @param name defines the block name
  68974. */
  68975. constructor(name: string);
  68976. /**
  68977. * Gets the current class name
  68978. * @returns the class name
  68979. */
  68980. getClassName(): string;
  68981. /**
  68982. * Gets the input vector
  68983. */
  68984. get input(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the input angle
  68987. */
  68988. get angle(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the output component
  68991. */
  68992. get output(): NodeMaterialConnectionPoint;
  68993. autoConfigure(material: NodeMaterial): void;
  68994. protected _buildBlock(state: NodeMaterialBuildState): this;
  68995. }
  68996. }
  68997. declare module BABYLON {
  68998. /**
  68999. * Block used to get the reflected vector from a direction and a normal
  69000. */
  69001. export class ReflectBlock extends NodeMaterialBlock {
  69002. /**
  69003. * Creates a new ReflectBlock
  69004. * @param name defines the block name
  69005. */
  69006. constructor(name: string);
  69007. /**
  69008. * Gets the current class name
  69009. * @returns the class name
  69010. */
  69011. getClassName(): string;
  69012. /**
  69013. * Gets the incident component
  69014. */
  69015. get incident(): NodeMaterialConnectionPoint;
  69016. /**
  69017. * Gets the normal component
  69018. */
  69019. get normal(): NodeMaterialConnectionPoint;
  69020. /**
  69021. * Gets the output component
  69022. */
  69023. get output(): NodeMaterialConnectionPoint;
  69024. protected _buildBlock(state: NodeMaterialBuildState): this;
  69025. }
  69026. }
  69027. declare module BABYLON {
  69028. /**
  69029. * Block used to get the refracted vector from a direction and a normal
  69030. */
  69031. export class RefractBlock extends NodeMaterialBlock {
  69032. /**
  69033. * Creates a new RefractBlock
  69034. * @param name defines the block name
  69035. */
  69036. constructor(name: string);
  69037. /**
  69038. * Gets the current class name
  69039. * @returns the class name
  69040. */
  69041. getClassName(): string;
  69042. /**
  69043. * Gets the incident component
  69044. */
  69045. get incident(): NodeMaterialConnectionPoint;
  69046. /**
  69047. * Gets the normal component
  69048. */
  69049. get normal(): NodeMaterialConnectionPoint;
  69050. /**
  69051. * Gets the index of refraction component
  69052. */
  69053. get ior(): NodeMaterialConnectionPoint;
  69054. /**
  69055. * Gets the output component
  69056. */
  69057. get output(): NodeMaterialConnectionPoint;
  69058. protected _buildBlock(state: NodeMaterialBuildState): this;
  69059. }
  69060. }
  69061. declare module BABYLON {
  69062. /**
  69063. * Block used to desaturate a color
  69064. */
  69065. export class DesaturateBlock extends NodeMaterialBlock {
  69066. /**
  69067. * Creates a new DesaturateBlock
  69068. * @param name defines the block name
  69069. */
  69070. constructor(name: string);
  69071. /**
  69072. * Gets the current class name
  69073. * @returns the class name
  69074. */
  69075. getClassName(): string;
  69076. /**
  69077. * Gets the color operand input component
  69078. */
  69079. get color(): NodeMaterialConnectionPoint;
  69080. /**
  69081. * Gets the level operand input component
  69082. */
  69083. get level(): NodeMaterialConnectionPoint;
  69084. /**
  69085. * Gets the output component
  69086. */
  69087. get output(): NodeMaterialConnectionPoint;
  69088. protected _buildBlock(state: NodeMaterialBuildState): this;
  69089. }
  69090. }
  69091. declare module BABYLON {
  69092. /**
  69093. * Block used to implement the reflection module of the PBR material
  69094. */
  69095. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69096. /** @hidden */
  69097. _defineLODReflectionAlpha: string;
  69098. /** @hidden */
  69099. _defineLinearSpecularReflection: string;
  69100. private _vEnvironmentIrradianceName;
  69101. /** @hidden */
  69102. _vReflectionMicrosurfaceInfosName: string;
  69103. /** @hidden */
  69104. _vReflectionInfosName: string;
  69105. /** @hidden */
  69106. _vReflectionFilteringInfoName: string;
  69107. private _scene;
  69108. /**
  69109. * The properties below are set by the main PBR block prior to calling methods of this class.
  69110. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69111. * It's less burden on the user side in the editor part.
  69112. */
  69113. /** @hidden */
  69114. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69115. /** @hidden */
  69116. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69117. /** @hidden */
  69118. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69119. /** @hidden */
  69120. viewConnectionPoint: NodeMaterialConnectionPoint;
  69121. /**
  69122. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69123. * diffuse part of the IBL.
  69124. */
  69125. useSphericalHarmonics: boolean;
  69126. /**
  69127. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69128. */
  69129. forceIrradianceInFragment: boolean;
  69130. /**
  69131. * Create a new ReflectionBlock
  69132. * @param name defines the block name
  69133. */
  69134. constructor(name: string);
  69135. /**
  69136. * Gets the current class name
  69137. * @returns the class name
  69138. */
  69139. getClassName(): string;
  69140. /**
  69141. * Gets the position input component
  69142. */
  69143. get position(): NodeMaterialConnectionPoint;
  69144. /**
  69145. * Gets the world position input component
  69146. */
  69147. get worldPosition(): NodeMaterialConnectionPoint;
  69148. /**
  69149. * Gets the world normal input component
  69150. */
  69151. get worldNormal(): NodeMaterialConnectionPoint;
  69152. /**
  69153. * Gets the world input component
  69154. */
  69155. get world(): NodeMaterialConnectionPoint;
  69156. /**
  69157. * Gets the camera (or eye) position component
  69158. */
  69159. get cameraPosition(): NodeMaterialConnectionPoint;
  69160. /**
  69161. * Gets the view input component
  69162. */
  69163. get view(): NodeMaterialConnectionPoint;
  69164. /**
  69165. * Gets the color input component
  69166. */
  69167. get color(): NodeMaterialConnectionPoint;
  69168. /**
  69169. * Gets the reflection object output component
  69170. */
  69171. get reflection(): NodeMaterialConnectionPoint;
  69172. /**
  69173. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69174. */
  69175. get hasTexture(): boolean;
  69176. /**
  69177. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69178. */
  69179. get reflectionColor(): string;
  69180. protected _getTexture(): Nullable<BaseTexture>;
  69181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69183. /**
  69184. * Gets the code to inject in the vertex shader
  69185. * @param state current state of the node material building
  69186. * @returns the shader code
  69187. */
  69188. handleVertexSide(state: NodeMaterialBuildState): string;
  69189. /**
  69190. * Gets the main code of the block (fragment side)
  69191. * @param state current state of the node material building
  69192. * @param normalVarName name of the existing variable corresponding to the normal
  69193. * @returns the shader code
  69194. */
  69195. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69196. protected _buildBlock(state: NodeMaterialBuildState): this;
  69197. protected _dumpPropertiesCode(): string;
  69198. serialize(): any;
  69199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69200. }
  69201. }
  69202. declare module BABYLON {
  69203. /**
  69204. * Block used to implement the sheen module of the PBR material
  69205. */
  69206. export class SheenBlock extends NodeMaterialBlock {
  69207. /**
  69208. * Create a new SheenBlock
  69209. * @param name defines the block name
  69210. */
  69211. constructor(name: string);
  69212. /**
  69213. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69214. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69215. * making it easier to setup and tweak the effect
  69216. */
  69217. albedoScaling: boolean;
  69218. /**
  69219. * Defines if the sheen is linked to the sheen color.
  69220. */
  69221. linkSheenWithAlbedo: boolean;
  69222. /**
  69223. * Initialize the block and prepare the context for build
  69224. * @param state defines the state that will be used for the build
  69225. */
  69226. initialize(state: NodeMaterialBuildState): void;
  69227. /**
  69228. * Gets the current class name
  69229. * @returns the class name
  69230. */
  69231. getClassName(): string;
  69232. /**
  69233. * Gets the intensity input component
  69234. */
  69235. get intensity(): NodeMaterialConnectionPoint;
  69236. /**
  69237. * Gets the color input component
  69238. */
  69239. get color(): NodeMaterialConnectionPoint;
  69240. /**
  69241. * Gets the roughness input component
  69242. */
  69243. get roughness(): NodeMaterialConnectionPoint;
  69244. /**
  69245. * Gets the sheen object output component
  69246. */
  69247. get sheen(): NodeMaterialConnectionPoint;
  69248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69249. /**
  69250. * Gets the main code of the block (fragment side)
  69251. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69252. * @returns the shader code
  69253. */
  69254. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69255. protected _buildBlock(state: NodeMaterialBuildState): this;
  69256. protected _dumpPropertiesCode(): string;
  69257. serialize(): any;
  69258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69259. }
  69260. }
  69261. declare module BABYLON {
  69262. /**
  69263. * Block used to implement the anisotropy module of the PBR material
  69264. */
  69265. export class AnisotropyBlock extends NodeMaterialBlock {
  69266. /**
  69267. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69268. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69269. * It's less burden on the user side in the editor part.
  69270. */
  69271. /** @hidden */
  69272. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69273. /** @hidden */
  69274. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69275. /**
  69276. * Create a new AnisotropyBlock
  69277. * @param name defines the block name
  69278. */
  69279. constructor(name: string);
  69280. /**
  69281. * Initialize the block and prepare the context for build
  69282. * @param state defines the state that will be used for the build
  69283. */
  69284. initialize(state: NodeMaterialBuildState): void;
  69285. /**
  69286. * Gets the current class name
  69287. * @returns the class name
  69288. */
  69289. getClassName(): string;
  69290. /**
  69291. * Gets the intensity input component
  69292. */
  69293. get intensity(): NodeMaterialConnectionPoint;
  69294. /**
  69295. * Gets the direction input component
  69296. */
  69297. get direction(): NodeMaterialConnectionPoint;
  69298. /**
  69299. * Gets the uv input component
  69300. */
  69301. get uv(): NodeMaterialConnectionPoint;
  69302. /**
  69303. * Gets the worldTangent input component
  69304. */
  69305. get worldTangent(): NodeMaterialConnectionPoint;
  69306. /**
  69307. * Gets the anisotropy object output component
  69308. */
  69309. get anisotropy(): NodeMaterialConnectionPoint;
  69310. private _generateTBNSpace;
  69311. /**
  69312. * Gets the main code of the block (fragment side)
  69313. * @param state current state of the node material building
  69314. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69315. * @returns the shader code
  69316. */
  69317. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69319. protected _buildBlock(state: NodeMaterialBuildState): this;
  69320. }
  69321. }
  69322. declare module BABYLON {
  69323. /**
  69324. * Block used to implement the clear coat module of the PBR material
  69325. */
  69326. export class ClearCoatBlock extends NodeMaterialBlock {
  69327. private _scene;
  69328. /**
  69329. * Create a new ClearCoatBlock
  69330. * @param name defines the block name
  69331. */
  69332. constructor(name: string);
  69333. /**
  69334. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69335. */
  69336. remapF0OnInterfaceChange: boolean;
  69337. /**
  69338. * Initialize the block and prepare the context for build
  69339. * @param state defines the state that will be used for the build
  69340. */
  69341. initialize(state: NodeMaterialBuildState): void;
  69342. /**
  69343. * Gets the current class name
  69344. * @returns the class name
  69345. */
  69346. getClassName(): string;
  69347. /**
  69348. * Gets the intensity input component
  69349. */
  69350. get intensity(): NodeMaterialConnectionPoint;
  69351. /**
  69352. * Gets the roughness input component
  69353. */
  69354. get roughness(): NodeMaterialConnectionPoint;
  69355. /**
  69356. * Gets the ior input component
  69357. */
  69358. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69359. /**
  69360. * Gets the bump texture input component
  69361. */
  69362. get normalMapColor(): NodeMaterialConnectionPoint;
  69363. /**
  69364. * Gets the uv input component
  69365. */
  69366. get uv(): NodeMaterialConnectionPoint;
  69367. /**
  69368. * Gets the tint color input component
  69369. */
  69370. get tintColor(): NodeMaterialConnectionPoint;
  69371. /**
  69372. * Gets the tint "at distance" input component
  69373. */
  69374. get tintAtDistance(): NodeMaterialConnectionPoint;
  69375. /**
  69376. * Gets the tint thickness input component
  69377. */
  69378. get tintThickness(): NodeMaterialConnectionPoint;
  69379. /**
  69380. * Gets the world tangent input component
  69381. */
  69382. get worldTangent(): NodeMaterialConnectionPoint;
  69383. /**
  69384. * Gets the clear coat object output component
  69385. */
  69386. get clearcoat(): NodeMaterialConnectionPoint;
  69387. autoConfigure(material: NodeMaterial): void;
  69388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69390. private _generateTBNSpace;
  69391. /**
  69392. * Gets the main code of the block (fragment side)
  69393. * @param state current state of the node material building
  69394. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69395. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69396. * @param worldPosVarName name of the variable holding the world position
  69397. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69398. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69399. * @param worldNormalVarName name of the variable holding the world normal
  69400. * @returns the shader code
  69401. */
  69402. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69403. protected _buildBlock(state: NodeMaterialBuildState): this;
  69404. protected _dumpPropertiesCode(): string;
  69405. serialize(): any;
  69406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69407. }
  69408. }
  69409. declare module BABYLON {
  69410. /**
  69411. * Block used to implement the sub surface module of the PBR material
  69412. */
  69413. export class SubSurfaceBlock extends NodeMaterialBlock {
  69414. /**
  69415. * Create a new SubSurfaceBlock
  69416. * @param name defines the block name
  69417. */
  69418. constructor(name: string);
  69419. /**
  69420. * Initialize the block and prepare the context for build
  69421. * @param state defines the state that will be used for the build
  69422. */
  69423. initialize(state: NodeMaterialBuildState): void;
  69424. /**
  69425. * Gets the current class name
  69426. * @returns the class name
  69427. */
  69428. getClassName(): string;
  69429. /**
  69430. * Gets the thickness component
  69431. */
  69432. get thickness(): NodeMaterialConnectionPoint;
  69433. /**
  69434. * Gets the tint color input component
  69435. */
  69436. get tintColor(): NodeMaterialConnectionPoint;
  69437. /**
  69438. * Gets the translucency intensity input component
  69439. */
  69440. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69441. /**
  69442. * Gets the translucency diffusion distance input component
  69443. */
  69444. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69445. /**
  69446. * Gets the refraction object parameters
  69447. */
  69448. get refraction(): NodeMaterialConnectionPoint;
  69449. /**
  69450. * Gets the sub surface object output component
  69451. */
  69452. get subsurface(): NodeMaterialConnectionPoint;
  69453. autoConfigure(material: NodeMaterial): void;
  69454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69455. /**
  69456. * Gets the main code of the block (fragment side)
  69457. * @param state current state of the node material building
  69458. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69459. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69460. * @param worldPosVarName name of the variable holding the world position
  69461. * @returns the shader code
  69462. */
  69463. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69464. protected _buildBlock(state: NodeMaterialBuildState): this;
  69465. }
  69466. }
  69467. declare module BABYLON {
  69468. /**
  69469. * Block used to implement the PBR metallic/roughness model
  69470. */
  69471. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69472. /**
  69473. * Gets or sets the light associated with this block
  69474. */
  69475. light: Nullable<Light>;
  69476. private _lightId;
  69477. private _scene;
  69478. private _environmentBRDFTexture;
  69479. private _environmentBrdfSamplerName;
  69480. private _vNormalWName;
  69481. private _invertNormalName;
  69482. private _metallicReflectanceColor;
  69483. private _metallicF0Factor;
  69484. private _vMetallicReflectanceFactorsName;
  69485. /**
  69486. * Create a new ReflectionBlock
  69487. * @param name defines the block name
  69488. */
  69489. constructor(name: string);
  69490. /**
  69491. * Intensity of the direct lights e.g. the four lights available in your scene.
  69492. * This impacts both the direct diffuse and specular highlights.
  69493. */
  69494. directIntensity: number;
  69495. /**
  69496. * Intensity of the environment e.g. how much the environment will light the object
  69497. * either through harmonics for rough material or through the reflection for shiny ones.
  69498. */
  69499. environmentIntensity: number;
  69500. /**
  69501. * This is a special control allowing the reduction of the specular highlights coming from the
  69502. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69503. */
  69504. specularIntensity: number;
  69505. /**
  69506. * Defines the falloff type used in this material.
  69507. * It by default is Physical.
  69508. */
  69509. lightFalloff: number;
  69510. /**
  69511. * Specifies that alpha test should be used
  69512. */
  69513. useAlphaTest: boolean;
  69514. /**
  69515. * Defines the alpha limits in alpha test mode.
  69516. */
  69517. alphaTestCutoff: number;
  69518. /**
  69519. * Specifies that alpha blending should be used
  69520. */
  69521. useAlphaBlending: boolean;
  69522. /**
  69523. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69524. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69525. */
  69526. useRadianceOverAlpha: boolean;
  69527. /**
  69528. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69529. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69530. */
  69531. useSpecularOverAlpha: boolean;
  69532. /**
  69533. * Enables specular anti aliasing in the PBR shader.
  69534. * It will both interacts on the Geometry for analytical and IBL lighting.
  69535. * It also prefilter the roughness map based on the bump values.
  69536. */
  69537. enableSpecularAntiAliasing: boolean;
  69538. /**
  69539. * Enables realtime filtering on the texture.
  69540. */
  69541. realTimeFiltering: boolean;
  69542. /**
  69543. * Quality switch for realtime filtering
  69544. */
  69545. realTimeFilteringQuality: number;
  69546. /**
  69547. * Defines if the material uses energy conservation.
  69548. */
  69549. useEnergyConservation: boolean;
  69550. /**
  69551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69552. * too much the area relying on ambient texture to define their ambient occlusion.
  69553. */
  69554. useRadianceOcclusion: boolean;
  69555. /**
  69556. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69557. * makes the reflect vector face the model (under horizon).
  69558. */
  69559. useHorizonOcclusion: boolean;
  69560. /**
  69561. * If set to true, no lighting calculations will be applied.
  69562. */
  69563. unlit: boolean;
  69564. /**
  69565. * Force normal to face away from face.
  69566. */
  69567. forceNormalForward: boolean;
  69568. /**
  69569. * Defines the material debug mode.
  69570. * It helps seeing only some components of the material while troubleshooting.
  69571. */
  69572. debugMode: number;
  69573. /**
  69574. * Specify from where on screen the debug mode should start.
  69575. * The value goes from -1 (full screen) to 1 (not visible)
  69576. * It helps with side by side comparison against the final render
  69577. * This defaults to 0
  69578. */
  69579. debugLimit: number;
  69580. /**
  69581. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69582. * You can use the factor to better multiply the final value.
  69583. */
  69584. debugFactor: number;
  69585. /**
  69586. * Initialize the block and prepare the context for build
  69587. * @param state defines the state that will be used for the build
  69588. */
  69589. initialize(state: NodeMaterialBuildState): void;
  69590. /**
  69591. * Gets the current class name
  69592. * @returns the class name
  69593. */
  69594. getClassName(): string;
  69595. /**
  69596. * Gets the world position input component
  69597. */
  69598. get worldPosition(): NodeMaterialConnectionPoint;
  69599. /**
  69600. * Gets the world normal input component
  69601. */
  69602. get worldNormal(): NodeMaterialConnectionPoint;
  69603. /**
  69604. * Gets the view matrix parameter
  69605. */
  69606. get view(): NodeMaterialConnectionPoint;
  69607. /**
  69608. * Gets the camera position input component
  69609. */
  69610. get cameraPosition(): NodeMaterialConnectionPoint;
  69611. /**
  69612. * Gets the perturbed normal input component
  69613. */
  69614. get perturbedNormal(): NodeMaterialConnectionPoint;
  69615. /**
  69616. * Gets the base color input component
  69617. */
  69618. get baseColor(): NodeMaterialConnectionPoint;
  69619. /**
  69620. * Gets the metallic input component
  69621. */
  69622. get metallic(): NodeMaterialConnectionPoint;
  69623. /**
  69624. * Gets the roughness input component
  69625. */
  69626. get roughness(): NodeMaterialConnectionPoint;
  69627. /**
  69628. * Gets the ambient occlusion input component
  69629. */
  69630. get ambientOcc(): NodeMaterialConnectionPoint;
  69631. /**
  69632. * Gets the opacity input component
  69633. */
  69634. get opacity(): NodeMaterialConnectionPoint;
  69635. /**
  69636. * Gets the index of refraction input component
  69637. */
  69638. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69639. /**
  69640. * Gets the ambient color input component
  69641. */
  69642. get ambientColor(): NodeMaterialConnectionPoint;
  69643. /**
  69644. * Gets the reflection object parameters
  69645. */
  69646. get reflection(): NodeMaterialConnectionPoint;
  69647. /**
  69648. * Gets the clear coat object parameters
  69649. */
  69650. get clearcoat(): NodeMaterialConnectionPoint;
  69651. /**
  69652. * Gets the sheen object parameters
  69653. */
  69654. get sheen(): NodeMaterialConnectionPoint;
  69655. /**
  69656. * Gets the sub surface object parameters
  69657. */
  69658. get subsurface(): NodeMaterialConnectionPoint;
  69659. /**
  69660. * Gets the anisotropy object parameters
  69661. */
  69662. get anisotropy(): NodeMaterialConnectionPoint;
  69663. /**
  69664. * Gets the ambient output component
  69665. */
  69666. get ambientClr(): NodeMaterialConnectionPoint;
  69667. /**
  69668. * Gets the diffuse output component
  69669. */
  69670. get diffuseDir(): NodeMaterialConnectionPoint;
  69671. /**
  69672. * Gets the specular output component
  69673. */
  69674. get specularDir(): NodeMaterialConnectionPoint;
  69675. /**
  69676. * Gets the clear coat output component
  69677. */
  69678. get clearcoatDir(): NodeMaterialConnectionPoint;
  69679. /**
  69680. * Gets the sheen output component
  69681. */
  69682. get sheenDir(): NodeMaterialConnectionPoint;
  69683. /**
  69684. * Gets the indirect diffuse output component
  69685. */
  69686. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69687. /**
  69688. * Gets the indirect specular output component
  69689. */
  69690. get specularIndirect(): NodeMaterialConnectionPoint;
  69691. /**
  69692. * Gets the indirect clear coat output component
  69693. */
  69694. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69695. /**
  69696. * Gets the indirect sheen output component
  69697. */
  69698. get sheenIndirect(): NodeMaterialConnectionPoint;
  69699. /**
  69700. * Gets the refraction output component
  69701. */
  69702. get refraction(): NodeMaterialConnectionPoint;
  69703. /**
  69704. * Gets the global lighting output component
  69705. */
  69706. get lighting(): NodeMaterialConnectionPoint;
  69707. /**
  69708. * Gets the shadow output component
  69709. */
  69710. get shadow(): NodeMaterialConnectionPoint;
  69711. /**
  69712. * Gets the alpha output component
  69713. */
  69714. get alpha(): NodeMaterialConnectionPoint;
  69715. autoConfigure(material: NodeMaterial): void;
  69716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69717. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69718. isReady(): boolean;
  69719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69720. private _injectVertexCode;
  69721. private _getAlbedoOpacityCode;
  69722. private _getAmbientOcclusionCode;
  69723. private _getReflectivityCode;
  69724. protected _buildBlock(state: NodeMaterialBuildState): this;
  69725. protected _dumpPropertiesCode(): string;
  69726. serialize(): any;
  69727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69728. }
  69729. }
  69730. declare module BABYLON {
  69731. /**
  69732. * Block used to compute value of one parameter modulo another
  69733. */
  69734. export class ModBlock extends NodeMaterialBlock {
  69735. /**
  69736. * Creates a new ModBlock
  69737. * @param name defines the block name
  69738. */
  69739. constructor(name: string);
  69740. /**
  69741. * Gets the current class name
  69742. * @returns the class name
  69743. */
  69744. getClassName(): string;
  69745. /**
  69746. * Gets the left operand input component
  69747. */
  69748. get left(): NodeMaterialConnectionPoint;
  69749. /**
  69750. * Gets the right operand input component
  69751. */
  69752. get right(): NodeMaterialConnectionPoint;
  69753. /**
  69754. * Gets the output component
  69755. */
  69756. get output(): NodeMaterialConnectionPoint;
  69757. protected _buildBlock(state: NodeMaterialBuildState): this;
  69758. }
  69759. }
  69760. declare module BABYLON {
  69761. /**
  69762. * Configuration for Draco compression
  69763. */
  69764. export interface IDracoCompressionConfiguration {
  69765. /**
  69766. * Configuration for the decoder.
  69767. */
  69768. decoder: {
  69769. /**
  69770. * The url to the WebAssembly module.
  69771. */
  69772. wasmUrl?: string;
  69773. /**
  69774. * The url to the WebAssembly binary.
  69775. */
  69776. wasmBinaryUrl?: string;
  69777. /**
  69778. * The url to the fallback JavaScript module.
  69779. */
  69780. fallbackUrl?: string;
  69781. };
  69782. }
  69783. /**
  69784. * Draco compression (https://google.github.io/draco/)
  69785. *
  69786. * This class wraps the Draco module.
  69787. *
  69788. * **Encoder**
  69789. *
  69790. * The encoder is not currently implemented.
  69791. *
  69792. * **Decoder**
  69793. *
  69794. * 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.
  69795. *
  69796. * To update the configuration, use the following code:
  69797. * ```javascript
  69798. * DracoCompression.Configuration = {
  69799. * decoder: {
  69800. * wasmUrl: "<url to the WebAssembly library>",
  69801. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69802. * fallbackUrl: "<url to the fallback JavaScript library>",
  69803. * }
  69804. * };
  69805. * ```
  69806. *
  69807. * 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.
  69808. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69809. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69810. *
  69811. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69812. * ```javascript
  69813. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69814. * ```
  69815. *
  69816. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69817. */
  69818. export class DracoCompression implements IDisposable {
  69819. private _workerPoolPromise?;
  69820. private _decoderModulePromise?;
  69821. /**
  69822. * The configuration. Defaults to the following urls:
  69823. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69824. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69825. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69826. */
  69827. static Configuration: IDracoCompressionConfiguration;
  69828. /**
  69829. * Returns true if the decoder configuration is available.
  69830. */
  69831. static get DecoderAvailable(): boolean;
  69832. /**
  69833. * Default number of workers to create when creating the draco compression object.
  69834. */
  69835. static DefaultNumWorkers: number;
  69836. private static GetDefaultNumWorkers;
  69837. private static _Default;
  69838. /**
  69839. * Default instance for the draco compression object.
  69840. */
  69841. static get Default(): DracoCompression;
  69842. /**
  69843. * Constructor
  69844. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69845. */
  69846. constructor(numWorkers?: number);
  69847. /**
  69848. * Stop all async operations and release resources.
  69849. */
  69850. dispose(): void;
  69851. /**
  69852. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69853. * @returns a promise that resolves when ready
  69854. */
  69855. whenReadyAsync(): Promise<void>;
  69856. /**
  69857. * Decode Draco compressed mesh data to vertex data.
  69858. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69859. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69860. * @returns A promise that resolves with the decoded vertex data
  69861. */
  69862. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69863. [kind: string]: number;
  69864. }): Promise<VertexData>;
  69865. }
  69866. }
  69867. declare module BABYLON {
  69868. /**
  69869. * Class for building Constructive Solid Geometry
  69870. */
  69871. export class CSG {
  69872. private polygons;
  69873. /**
  69874. * The world matrix
  69875. */
  69876. matrix: Matrix;
  69877. /**
  69878. * Stores the position
  69879. */
  69880. position: Vector3;
  69881. /**
  69882. * Stores the rotation
  69883. */
  69884. rotation: Vector3;
  69885. /**
  69886. * Stores the rotation quaternion
  69887. */
  69888. rotationQuaternion: Nullable<Quaternion>;
  69889. /**
  69890. * Stores the scaling vector
  69891. */
  69892. scaling: Vector3;
  69893. /**
  69894. * Convert the Mesh to CSG
  69895. * @param mesh The Mesh to convert to CSG
  69896. * @returns A new CSG from the Mesh
  69897. */
  69898. static FromMesh(mesh: Mesh): CSG;
  69899. /**
  69900. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69901. * @param polygons Polygons used to construct a CSG solid
  69902. */
  69903. private static FromPolygons;
  69904. /**
  69905. * Clones, or makes a deep copy, of the CSG
  69906. * @returns A new CSG
  69907. */
  69908. clone(): CSG;
  69909. /**
  69910. * Unions this CSG with another CSG
  69911. * @param csg The CSG to union against this CSG
  69912. * @returns The unioned CSG
  69913. */
  69914. union(csg: CSG): CSG;
  69915. /**
  69916. * Unions this CSG with another CSG in place
  69917. * @param csg The CSG to union against this CSG
  69918. */
  69919. unionInPlace(csg: CSG): void;
  69920. /**
  69921. * Subtracts this CSG with another CSG
  69922. * @param csg The CSG to subtract against this CSG
  69923. * @returns A new CSG
  69924. */
  69925. subtract(csg: CSG): CSG;
  69926. /**
  69927. * Subtracts this CSG with another CSG in place
  69928. * @param csg The CSG to subtract against this CSG
  69929. */
  69930. subtractInPlace(csg: CSG): void;
  69931. /**
  69932. * Intersect this CSG with another CSG
  69933. * @param csg The CSG to intersect against this CSG
  69934. * @returns A new CSG
  69935. */
  69936. intersect(csg: CSG): CSG;
  69937. /**
  69938. * Intersects this CSG with another CSG in place
  69939. * @param csg The CSG to intersect against this CSG
  69940. */
  69941. intersectInPlace(csg: CSG): void;
  69942. /**
  69943. * Return a new CSG solid with solid and empty space switched. This solid is
  69944. * not modified.
  69945. * @returns A new CSG solid with solid and empty space switched
  69946. */
  69947. inverse(): CSG;
  69948. /**
  69949. * Inverses the CSG in place
  69950. */
  69951. inverseInPlace(): void;
  69952. /**
  69953. * This is used to keep meshes transformations so they can be restored
  69954. * when we build back a Babylon Mesh
  69955. * NB : All CSG operations are performed in world coordinates
  69956. * @param csg The CSG to copy the transform attributes from
  69957. * @returns This CSG
  69958. */
  69959. copyTransformAttributes(csg: CSG): CSG;
  69960. /**
  69961. * Build Raw mesh from CSG
  69962. * Coordinates here are in world space
  69963. * @param name The name of the mesh geometry
  69964. * @param scene The Scene
  69965. * @param keepSubMeshes Specifies if the submeshes should be kept
  69966. * @returns A new Mesh
  69967. */
  69968. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69969. /**
  69970. * Build Mesh from CSG taking material and transforms into account
  69971. * @param name The name of the Mesh
  69972. * @param material The material of the Mesh
  69973. * @param scene The Scene
  69974. * @param keepSubMeshes Specifies if submeshes should be kept
  69975. * @returns The new Mesh
  69976. */
  69977. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /**
  69982. * Class used to create a trail following a mesh
  69983. */
  69984. export class TrailMesh extends Mesh {
  69985. private _generator;
  69986. private _autoStart;
  69987. private _running;
  69988. private _diameter;
  69989. private _length;
  69990. private _sectionPolygonPointsCount;
  69991. private _sectionVectors;
  69992. private _sectionNormalVectors;
  69993. private _beforeRenderObserver;
  69994. /**
  69995. * @constructor
  69996. * @param name The value used by scene.getMeshByName() to do a lookup.
  69997. * @param generator The mesh or transform node to generate a trail.
  69998. * @param scene The scene to add this mesh to.
  69999. * @param diameter Diameter of trailing mesh. Default is 1.
  70000. * @param length Length of trailing mesh. Default is 60.
  70001. * @param autoStart Automatically start trailing mesh. Default true.
  70002. */
  70003. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70004. /**
  70005. * "TrailMesh"
  70006. * @returns "TrailMesh"
  70007. */
  70008. getClassName(): string;
  70009. private _createMesh;
  70010. /**
  70011. * Start trailing mesh.
  70012. */
  70013. start(): void;
  70014. /**
  70015. * Stop trailing mesh.
  70016. */
  70017. stop(): void;
  70018. /**
  70019. * Update trailing mesh geometry.
  70020. */
  70021. update(): void;
  70022. /**
  70023. * Returns a new TrailMesh object.
  70024. * @param name is a string, the name given to the new mesh
  70025. * @param newGenerator use new generator object for cloned trail mesh
  70026. * @returns a new mesh
  70027. */
  70028. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70029. /**
  70030. * Serializes this trail mesh
  70031. * @param serializationObject object to write serialization to
  70032. */
  70033. serialize(serializationObject: any): void;
  70034. /**
  70035. * Parses a serialized trail mesh
  70036. * @param parsedMesh the serialized mesh
  70037. * @param scene the scene to create the trail mesh in
  70038. * @returns the created trail mesh
  70039. */
  70040. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70041. }
  70042. }
  70043. declare module BABYLON {
  70044. /**
  70045. * Class containing static functions to help procedurally build meshes
  70046. */
  70047. export class TiledBoxBuilder {
  70048. /**
  70049. * Creates a box mesh
  70050. * 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)
  70051. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70053. * * 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
  70054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70055. * @param name defines the name of the mesh
  70056. * @param options defines the options used to create the mesh
  70057. * @param scene defines the hosting scene
  70058. * @returns the box mesh
  70059. */
  70060. static CreateTiledBox(name: string, options: {
  70061. pattern?: number;
  70062. width?: number;
  70063. height?: number;
  70064. depth?: number;
  70065. tileSize?: number;
  70066. tileWidth?: number;
  70067. tileHeight?: number;
  70068. alignHorizontal?: number;
  70069. alignVertical?: number;
  70070. faceUV?: Vector4[];
  70071. faceColors?: Color4[];
  70072. sideOrientation?: number;
  70073. updatable?: boolean;
  70074. }, scene?: Nullable<Scene>): Mesh;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /**
  70079. * Class containing static functions to help procedurally build meshes
  70080. */
  70081. export class TorusKnotBuilder {
  70082. /**
  70083. * Creates a torus knot mesh
  70084. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70085. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70086. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70087. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70089. * * 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
  70090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70091. * @param name defines the name of the mesh
  70092. * @param options defines the options used to create the mesh
  70093. * @param scene defines the hosting scene
  70094. * @returns the torus knot mesh
  70095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70096. */
  70097. static CreateTorusKnot(name: string, options: {
  70098. radius?: number;
  70099. tube?: number;
  70100. radialSegments?: number;
  70101. tubularSegments?: number;
  70102. p?: number;
  70103. q?: number;
  70104. updatable?: boolean;
  70105. sideOrientation?: number;
  70106. frontUVs?: Vector4;
  70107. backUVs?: Vector4;
  70108. }, scene: any): Mesh;
  70109. }
  70110. }
  70111. declare module BABYLON {
  70112. /**
  70113. * Polygon
  70114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70115. */
  70116. export class Polygon {
  70117. /**
  70118. * Creates a rectangle
  70119. * @param xmin bottom X coord
  70120. * @param ymin bottom Y coord
  70121. * @param xmax top X coord
  70122. * @param ymax top Y coord
  70123. * @returns points that make the resulting rectangle
  70124. */
  70125. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70126. /**
  70127. * Creates a circle
  70128. * @param radius radius of circle
  70129. * @param cx scale in x
  70130. * @param cy scale in y
  70131. * @param numberOfSides number of sides that make up the circle
  70132. * @returns points that make the resulting circle
  70133. */
  70134. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70135. /**
  70136. * Creates a polygon from input string
  70137. * @param input Input polygon data
  70138. * @returns the parsed points
  70139. */
  70140. static Parse(input: string): Vector2[];
  70141. /**
  70142. * Starts building a polygon from x and y coordinates
  70143. * @param x x coordinate
  70144. * @param y y coordinate
  70145. * @returns the started path2
  70146. */
  70147. static StartingAt(x: number, y: number): Path2;
  70148. }
  70149. /**
  70150. * Builds a polygon
  70151. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70152. */
  70153. export class PolygonMeshBuilder {
  70154. private _points;
  70155. private _outlinepoints;
  70156. private _holes;
  70157. private _name;
  70158. private _scene;
  70159. private _epoints;
  70160. private _eholes;
  70161. private _addToepoint;
  70162. /**
  70163. * Babylon reference to the earcut plugin.
  70164. */
  70165. bjsEarcut: any;
  70166. /**
  70167. * Creates a PolygonMeshBuilder
  70168. * @param name name of the builder
  70169. * @param contours Path of the polygon
  70170. * @param scene scene to add to when creating the mesh
  70171. * @param earcutInjection can be used to inject your own earcut reference
  70172. */
  70173. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70174. /**
  70175. * Adds a hole within the polygon
  70176. * @param hole Array of points defining the hole
  70177. * @returns this
  70178. */
  70179. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70180. /**
  70181. * Creates the polygon
  70182. * @param updatable If the mesh should be updatable
  70183. * @param depth The depth of the mesh created
  70184. * @param smoothingThreshold Dot product threshold for smoothed normals
  70185. * @returns the created mesh
  70186. */
  70187. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70188. /**
  70189. * Creates the polygon
  70190. * @param depth The depth of the mesh created
  70191. * @param smoothingThreshold Dot product threshold for smoothed normals
  70192. * @returns the created VertexData
  70193. */
  70194. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70195. /**
  70196. * Adds a side to the polygon
  70197. * @param positions points that make the polygon
  70198. * @param normals normals of the polygon
  70199. * @param uvs uvs of the polygon
  70200. * @param indices indices of the polygon
  70201. * @param bounds bounds of the polygon
  70202. * @param points points of the polygon
  70203. * @param depth depth of the polygon
  70204. * @param flip flip of the polygon
  70205. */
  70206. private addSide;
  70207. }
  70208. }
  70209. declare module BABYLON {
  70210. /**
  70211. * Class containing static functions to help procedurally build meshes
  70212. */
  70213. export class PolygonBuilder {
  70214. /**
  70215. * Creates a polygon mesh
  70216. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70217. * * 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
  70218. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70220. * * 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)
  70221. * * Remember you can only change the shape positions, not their number when updating a polygon
  70222. * @param name defines the name of the mesh
  70223. * @param options defines the options used to create the mesh
  70224. * @param scene defines the hosting scene
  70225. * @param earcutInjection can be used to inject your own earcut reference
  70226. * @returns the polygon mesh
  70227. */
  70228. static CreatePolygon(name: string, options: {
  70229. shape: Vector3[];
  70230. holes?: Vector3[][];
  70231. depth?: number;
  70232. smoothingThreshold?: number;
  70233. faceUV?: Vector4[];
  70234. faceColors?: Color4[];
  70235. updatable?: boolean;
  70236. sideOrientation?: number;
  70237. frontUVs?: Vector4;
  70238. backUVs?: Vector4;
  70239. wrap?: boolean;
  70240. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70241. /**
  70242. * Creates an extruded polygon mesh, with depth in the Y direction.
  70243. * * 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)
  70244. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70245. * @param name defines the name of the mesh
  70246. * @param options defines the options used to create the mesh
  70247. * @param scene defines the hosting scene
  70248. * @param earcutInjection can be used to inject your own earcut reference
  70249. * @returns the polygon mesh
  70250. */
  70251. static ExtrudePolygon(name: string, options: {
  70252. shape: Vector3[];
  70253. holes?: Vector3[][];
  70254. depth?: number;
  70255. faceUV?: Vector4[];
  70256. faceColors?: Color4[];
  70257. updatable?: boolean;
  70258. sideOrientation?: number;
  70259. frontUVs?: Vector4;
  70260. backUVs?: Vector4;
  70261. wrap?: boolean;
  70262. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70263. }
  70264. }
  70265. declare module BABYLON {
  70266. /**
  70267. * Class containing static functions to help procedurally build meshes
  70268. */
  70269. export class LatheBuilder {
  70270. /**
  70271. * Creates lathe mesh.
  70272. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70273. * * 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
  70274. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70275. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70276. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70277. * * 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
  70278. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70279. * * 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
  70280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70281. * * 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
  70282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70284. * @param name defines the name of the mesh
  70285. * @param options defines the options used to create the mesh
  70286. * @param scene defines the hosting scene
  70287. * @returns the lathe mesh
  70288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70289. */
  70290. static CreateLathe(name: string, options: {
  70291. shape: Vector3[];
  70292. radius?: number;
  70293. tessellation?: number;
  70294. clip?: number;
  70295. arc?: number;
  70296. closed?: boolean;
  70297. updatable?: boolean;
  70298. sideOrientation?: number;
  70299. frontUVs?: Vector4;
  70300. backUVs?: Vector4;
  70301. cap?: number;
  70302. invertUV?: boolean;
  70303. }, scene?: Nullable<Scene>): Mesh;
  70304. }
  70305. }
  70306. declare module BABYLON {
  70307. /**
  70308. * Class containing static functions to help procedurally build meshes
  70309. */
  70310. export class TiledPlaneBuilder {
  70311. /**
  70312. * Creates a tiled plane mesh
  70313. * * The parameter `pattern` will, depending on value, do nothing or
  70314. * * * flip (reflect about central vertical) alternate tiles across and up
  70315. * * * flip every tile on alternate rows
  70316. * * * rotate (180 degs) alternate tiles across and up
  70317. * * * rotate every tile on alternate rows
  70318. * * * flip and rotate alternate tiles across and up
  70319. * * * flip and rotate every tile on alternate rows
  70320. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70321. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70322. * * 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
  70323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70324. * * 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)
  70325. * * 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)
  70326. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70327. * @param name defines the name of the mesh
  70328. * @param options defines the options used to create the mesh
  70329. * @param scene defines the hosting scene
  70330. * @returns the box mesh
  70331. */
  70332. static CreateTiledPlane(name: string, options: {
  70333. pattern?: number;
  70334. tileSize?: number;
  70335. tileWidth?: number;
  70336. tileHeight?: number;
  70337. size?: number;
  70338. width?: number;
  70339. height?: number;
  70340. alignHorizontal?: number;
  70341. alignVertical?: number;
  70342. sideOrientation?: number;
  70343. frontUVs?: Vector4;
  70344. backUVs?: Vector4;
  70345. updatable?: boolean;
  70346. }, scene?: Nullable<Scene>): Mesh;
  70347. }
  70348. }
  70349. declare module BABYLON {
  70350. /**
  70351. * Class containing static functions to help procedurally build meshes
  70352. */
  70353. export class TubeBuilder {
  70354. /**
  70355. * Creates a tube mesh.
  70356. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70357. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70358. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70359. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70360. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70361. * * 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)
  70362. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70363. * * 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
  70364. * * 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
  70365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70366. * * 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
  70367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70369. * @param name defines the name of the mesh
  70370. * @param options defines the options used to create the mesh
  70371. * @param scene defines the hosting scene
  70372. * @returns the tube mesh
  70373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70374. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70375. */
  70376. static CreateTube(name: string, options: {
  70377. path: Vector3[];
  70378. radius?: number;
  70379. tessellation?: number;
  70380. radiusFunction?: {
  70381. (i: number, distance: number): number;
  70382. };
  70383. cap?: number;
  70384. arc?: number;
  70385. updatable?: boolean;
  70386. sideOrientation?: number;
  70387. frontUVs?: Vector4;
  70388. backUVs?: Vector4;
  70389. instance?: Mesh;
  70390. invertUV?: boolean;
  70391. }, scene?: Nullable<Scene>): Mesh;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /**
  70396. * Class containing static functions to help procedurally build meshes
  70397. */
  70398. export class IcoSphereBuilder {
  70399. /**
  70400. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70401. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70402. * * 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`)
  70403. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70404. * * 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
  70405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70406. * * 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
  70407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70408. * @param name defines the name of the mesh
  70409. * @param options defines the options used to create the mesh
  70410. * @param scene defines the hosting scene
  70411. * @returns the icosahedron mesh
  70412. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70413. */
  70414. static CreateIcoSphere(name: string, options: {
  70415. radius?: number;
  70416. radiusX?: number;
  70417. radiusY?: number;
  70418. radiusZ?: number;
  70419. flat?: boolean;
  70420. subdivisions?: number;
  70421. sideOrientation?: number;
  70422. frontUVs?: Vector4;
  70423. backUVs?: Vector4;
  70424. updatable?: boolean;
  70425. }, scene?: Nullable<Scene>): Mesh;
  70426. }
  70427. }
  70428. declare module BABYLON {
  70429. /**
  70430. * Class containing static functions to help procedurally build meshes
  70431. */
  70432. export class DecalBuilder {
  70433. /**
  70434. * Creates a decal mesh.
  70435. * 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
  70436. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70437. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70438. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70439. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70440. * @param name defines the name of the mesh
  70441. * @param sourceMesh defines the mesh where the decal must be applied
  70442. * @param options defines the options used to create the mesh
  70443. * @param scene defines the hosting scene
  70444. * @returns the decal mesh
  70445. * @see https://doc.babylonjs.com/how_to/decals
  70446. */
  70447. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70448. position?: Vector3;
  70449. normal?: Vector3;
  70450. size?: Vector3;
  70451. angle?: number;
  70452. }): Mesh;
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /**
  70457. * Class containing static functions to help procedurally build meshes
  70458. */
  70459. export class MeshBuilder {
  70460. /**
  70461. * Creates a box mesh
  70462. * * The parameter `size` sets the size (float) of each box side (default 1)
  70463. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70464. * * 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)
  70465. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70467. * * 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
  70468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70469. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70470. * @param name defines the name of the mesh
  70471. * @param options defines the options used to create the mesh
  70472. * @param scene defines the hosting scene
  70473. * @returns the box mesh
  70474. */
  70475. static CreateBox(name: string, options: {
  70476. size?: number;
  70477. width?: number;
  70478. height?: number;
  70479. depth?: number;
  70480. faceUV?: Vector4[];
  70481. faceColors?: Color4[];
  70482. sideOrientation?: number;
  70483. frontUVs?: Vector4;
  70484. backUVs?: Vector4;
  70485. wrap?: boolean;
  70486. topBaseAt?: number;
  70487. bottomBaseAt?: number;
  70488. updatable?: boolean;
  70489. }, scene?: Nullable<Scene>): Mesh;
  70490. /**
  70491. * Creates a tiled box mesh
  70492. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70494. * @param name defines the name of the mesh
  70495. * @param options defines the options used to create the mesh
  70496. * @param scene defines the hosting scene
  70497. * @returns the tiled box mesh
  70498. */
  70499. static CreateTiledBox(name: string, options: {
  70500. pattern?: number;
  70501. size?: number;
  70502. width?: number;
  70503. height?: number;
  70504. depth: number;
  70505. tileSize?: number;
  70506. tileWidth?: number;
  70507. tileHeight?: number;
  70508. faceUV?: Vector4[];
  70509. faceColors?: Color4[];
  70510. alignHorizontal?: number;
  70511. alignVertical?: number;
  70512. sideOrientation?: number;
  70513. updatable?: boolean;
  70514. }, scene?: Nullable<Scene>): Mesh;
  70515. /**
  70516. * Creates a sphere mesh
  70517. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70518. * * 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`)
  70519. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70520. * * 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
  70521. * * 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)
  70522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70523. * * 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
  70524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70525. * @param name defines the name of the mesh
  70526. * @param options defines the options used to create the mesh
  70527. * @param scene defines the hosting scene
  70528. * @returns the sphere mesh
  70529. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70530. */
  70531. static CreateSphere(name: string, options: {
  70532. segments?: number;
  70533. diameter?: number;
  70534. diameterX?: number;
  70535. diameterY?: number;
  70536. diameterZ?: number;
  70537. arc?: number;
  70538. slice?: number;
  70539. sideOrientation?: number;
  70540. frontUVs?: Vector4;
  70541. backUVs?: Vector4;
  70542. updatable?: boolean;
  70543. }, scene?: Nullable<Scene>): Mesh;
  70544. /**
  70545. * Creates a plane polygonal mesh. By default, this is a disc
  70546. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70547. * * 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
  70548. * * 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
  70549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70550. * * 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
  70551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70552. * @param name defines the name of the mesh
  70553. * @param options defines the options used to create the mesh
  70554. * @param scene defines the hosting scene
  70555. * @returns the plane polygonal mesh
  70556. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70557. */
  70558. static CreateDisc(name: string, options: {
  70559. radius?: number;
  70560. tessellation?: number;
  70561. arc?: number;
  70562. updatable?: boolean;
  70563. sideOrientation?: number;
  70564. frontUVs?: Vector4;
  70565. backUVs?: Vector4;
  70566. }, scene?: Nullable<Scene>): Mesh;
  70567. /**
  70568. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70569. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70570. * * 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`)
  70571. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70572. * * 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
  70573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70574. * * 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
  70575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70576. * @param name defines the name of the mesh
  70577. * @param options defines the options used to create the mesh
  70578. * @param scene defines the hosting scene
  70579. * @returns the icosahedron mesh
  70580. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70581. */
  70582. static CreateIcoSphere(name: string, options: {
  70583. radius?: number;
  70584. radiusX?: number;
  70585. radiusY?: number;
  70586. radiusZ?: number;
  70587. flat?: boolean;
  70588. subdivisions?: number;
  70589. sideOrientation?: number;
  70590. frontUVs?: Vector4;
  70591. backUVs?: Vector4;
  70592. updatable?: boolean;
  70593. }, scene?: Nullable<Scene>): Mesh;
  70594. /**
  70595. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70596. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70597. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70598. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70599. * * 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
  70600. * * 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
  70601. * * 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
  70602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70603. * * 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
  70604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70605. * * 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
  70606. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70607. * * 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
  70608. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70610. * @param name defines the name of the mesh
  70611. * @param options defines the options used to create the mesh
  70612. * @param scene defines the hosting scene
  70613. * @returns the ribbon mesh
  70614. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70615. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70616. */
  70617. static CreateRibbon(name: string, options: {
  70618. pathArray: Vector3[][];
  70619. closeArray?: boolean;
  70620. closePath?: boolean;
  70621. offset?: number;
  70622. updatable?: boolean;
  70623. sideOrientation?: number;
  70624. frontUVs?: Vector4;
  70625. backUVs?: Vector4;
  70626. instance?: Mesh;
  70627. invertUV?: boolean;
  70628. uvs?: Vector2[];
  70629. colors?: Color4[];
  70630. }, scene?: Nullable<Scene>): Mesh;
  70631. /**
  70632. * Creates a cylinder or a cone mesh
  70633. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70634. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70635. * * 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.
  70636. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70637. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70638. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70639. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70640. * * 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).
  70641. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70642. * * 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).
  70643. * * 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
  70644. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70645. * * 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
  70646. * * 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.
  70647. * * If `enclose` is false, a ring surface is one element.
  70648. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70649. * * 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
  70650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70651. * * 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
  70652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70653. * @param name defines the name of the mesh
  70654. * @param options defines the options used to create the mesh
  70655. * @param scene defines the hosting scene
  70656. * @returns the cylinder mesh
  70657. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70658. */
  70659. static CreateCylinder(name: string, options: {
  70660. height?: number;
  70661. diameterTop?: number;
  70662. diameterBottom?: number;
  70663. diameter?: number;
  70664. tessellation?: number;
  70665. subdivisions?: number;
  70666. arc?: number;
  70667. faceColors?: Color4[];
  70668. faceUV?: Vector4[];
  70669. updatable?: boolean;
  70670. hasRings?: boolean;
  70671. enclose?: boolean;
  70672. cap?: number;
  70673. sideOrientation?: number;
  70674. frontUVs?: Vector4;
  70675. backUVs?: Vector4;
  70676. }, scene?: Nullable<Scene>): Mesh;
  70677. /**
  70678. * Creates a torus mesh
  70679. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70680. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70681. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70683. * * 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
  70684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70685. * @param name defines the name of the mesh
  70686. * @param options defines the options used to create the mesh
  70687. * @param scene defines the hosting scene
  70688. * @returns the torus mesh
  70689. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70690. */
  70691. static CreateTorus(name: string, options: {
  70692. diameter?: number;
  70693. thickness?: number;
  70694. tessellation?: number;
  70695. updatable?: boolean;
  70696. sideOrientation?: number;
  70697. frontUVs?: Vector4;
  70698. backUVs?: Vector4;
  70699. }, scene?: Nullable<Scene>): Mesh;
  70700. /**
  70701. * Creates a torus knot mesh
  70702. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70703. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70704. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70705. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70707. * * 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
  70708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70709. * @param name defines the name of the mesh
  70710. * @param options defines the options used to create the mesh
  70711. * @param scene defines the hosting scene
  70712. * @returns the torus knot mesh
  70713. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70714. */
  70715. static CreateTorusKnot(name: string, options: {
  70716. radius?: number;
  70717. tube?: number;
  70718. radialSegments?: number;
  70719. tubularSegments?: number;
  70720. p?: number;
  70721. q?: number;
  70722. updatable?: boolean;
  70723. sideOrientation?: number;
  70724. frontUVs?: Vector4;
  70725. backUVs?: Vector4;
  70726. }, scene?: Nullable<Scene>): Mesh;
  70727. /**
  70728. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70729. * * 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
  70730. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70731. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70732. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70733. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70735. * * 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
  70736. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70739. * @param name defines the name of the new line system
  70740. * @param options defines the options used to create the line system
  70741. * @param scene defines the hosting scene
  70742. * @returns a new line system mesh
  70743. */
  70744. static CreateLineSystem(name: string, options: {
  70745. lines: Vector3[][];
  70746. updatable?: boolean;
  70747. instance?: Nullable<LinesMesh>;
  70748. colors?: Nullable<Color4[][]>;
  70749. useVertexAlpha?: boolean;
  70750. }, scene: Nullable<Scene>): LinesMesh;
  70751. /**
  70752. * Creates a line mesh
  70753. * 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
  70754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70755. * * The parameter `points` is an array successive Vector3
  70756. * * 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
  70757. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70759. * * When updating an instance, remember that only point positions can change, not the number of points
  70760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70762. * @param name defines the name of the new line system
  70763. * @param options defines the options used to create the line system
  70764. * @param scene defines the hosting scene
  70765. * @returns a new line mesh
  70766. */
  70767. static CreateLines(name: string, options: {
  70768. points: Vector3[];
  70769. updatable?: boolean;
  70770. instance?: Nullable<LinesMesh>;
  70771. colors?: Color4[];
  70772. useVertexAlpha?: boolean;
  70773. }, scene?: Nullable<Scene>): LinesMesh;
  70774. /**
  70775. * Creates a dashed line mesh
  70776. * * 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
  70777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70778. * * The parameter `points` is an array successive Vector3
  70779. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70780. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70781. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70782. * * 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
  70783. * * When updating an instance, remember that only point positions can change, not the number of points
  70784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70785. * @param name defines the name of the mesh
  70786. * @param options defines the options used to create the mesh
  70787. * @param scene defines the hosting scene
  70788. * @returns the dashed line mesh
  70789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70790. */
  70791. static CreateDashedLines(name: string, options: {
  70792. points: Vector3[];
  70793. dashSize?: number;
  70794. gapSize?: number;
  70795. dashNb?: number;
  70796. updatable?: boolean;
  70797. instance?: LinesMesh;
  70798. }, scene?: Nullable<Scene>): LinesMesh;
  70799. /**
  70800. * 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.
  70801. * * 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.
  70802. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70803. * * 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.
  70804. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70805. * * 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
  70806. * * 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
  70807. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70809. * * 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
  70810. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70812. * @param name defines the name of the mesh
  70813. * @param options defines the options used to create the mesh
  70814. * @param scene defines the hosting scene
  70815. * @returns the extruded shape mesh
  70816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70818. */
  70819. static ExtrudeShape(name: string, options: {
  70820. shape: Vector3[];
  70821. path: Vector3[];
  70822. scale?: number;
  70823. rotation?: number;
  70824. cap?: number;
  70825. updatable?: boolean;
  70826. sideOrientation?: number;
  70827. frontUVs?: Vector4;
  70828. backUVs?: Vector4;
  70829. instance?: Mesh;
  70830. invertUV?: boolean;
  70831. }, scene?: Nullable<Scene>): Mesh;
  70832. /**
  70833. * Creates an custom extruded shape mesh.
  70834. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70835. * * 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.
  70836. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70837. * * 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
  70838. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70839. * * 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
  70840. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70841. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70842. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70843. * * 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
  70844. * * 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
  70845. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70847. * * 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
  70848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70850. * @param name defines the name of the mesh
  70851. * @param options defines the options used to create the mesh
  70852. * @param scene defines the hosting scene
  70853. * @returns the custom extruded shape mesh
  70854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70855. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70857. */
  70858. static ExtrudeShapeCustom(name: string, options: {
  70859. shape: Vector3[];
  70860. path: Vector3[];
  70861. scaleFunction?: any;
  70862. rotationFunction?: any;
  70863. ribbonCloseArray?: boolean;
  70864. ribbonClosePath?: boolean;
  70865. cap?: number;
  70866. updatable?: boolean;
  70867. sideOrientation?: number;
  70868. frontUVs?: Vector4;
  70869. backUVs?: Vector4;
  70870. instance?: Mesh;
  70871. invertUV?: boolean;
  70872. }, scene?: Nullable<Scene>): Mesh;
  70873. /**
  70874. * Creates lathe mesh.
  70875. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70876. * * 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
  70877. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70878. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70879. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70880. * * 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
  70881. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70882. * * 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
  70883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70884. * * 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
  70885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70887. * @param name defines the name of the mesh
  70888. * @param options defines the options used to create the mesh
  70889. * @param scene defines the hosting scene
  70890. * @returns the lathe mesh
  70891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70892. */
  70893. static CreateLathe(name: string, options: {
  70894. shape: Vector3[];
  70895. radius?: number;
  70896. tessellation?: number;
  70897. clip?: number;
  70898. arc?: number;
  70899. closed?: boolean;
  70900. updatable?: boolean;
  70901. sideOrientation?: number;
  70902. frontUVs?: Vector4;
  70903. backUVs?: Vector4;
  70904. cap?: number;
  70905. invertUV?: boolean;
  70906. }, scene?: Nullable<Scene>): Mesh;
  70907. /**
  70908. * Creates a tiled plane mesh
  70909. * * You can set a limited pattern arrangement with the tiles
  70910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70911. * * 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
  70912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70913. * @param name defines the name of the mesh
  70914. * @param options defines the options used to create the mesh
  70915. * @param scene defines the hosting scene
  70916. * @returns the plane mesh
  70917. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70918. */
  70919. static CreateTiledPlane(name: string, options: {
  70920. pattern?: number;
  70921. tileSize?: number;
  70922. tileWidth?: number;
  70923. tileHeight?: number;
  70924. size?: number;
  70925. width?: number;
  70926. height?: number;
  70927. alignHorizontal?: number;
  70928. alignVertical?: number;
  70929. sideOrientation?: number;
  70930. frontUVs?: Vector4;
  70931. backUVs?: Vector4;
  70932. updatable?: boolean;
  70933. }, scene?: Nullable<Scene>): Mesh;
  70934. /**
  70935. * Creates a plane mesh
  70936. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70937. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70938. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70940. * * 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
  70941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70942. * @param name defines the name of the mesh
  70943. * @param options defines the options used to create the mesh
  70944. * @param scene defines the hosting scene
  70945. * @returns the plane mesh
  70946. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70947. */
  70948. static CreatePlane(name: string, options: {
  70949. size?: number;
  70950. width?: number;
  70951. height?: number;
  70952. sideOrientation?: number;
  70953. frontUVs?: Vector4;
  70954. backUVs?: Vector4;
  70955. updatable?: boolean;
  70956. sourcePlane?: Plane;
  70957. }, scene?: Nullable<Scene>): Mesh;
  70958. /**
  70959. * Creates a ground mesh
  70960. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70961. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70963. * @param name defines the name of the mesh
  70964. * @param options defines the options used to create the mesh
  70965. * @param scene defines the hosting scene
  70966. * @returns the ground mesh
  70967. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70968. */
  70969. static CreateGround(name: string, options: {
  70970. width?: number;
  70971. height?: number;
  70972. subdivisions?: number;
  70973. subdivisionsX?: number;
  70974. subdivisionsY?: number;
  70975. updatable?: boolean;
  70976. }, scene?: Nullable<Scene>): Mesh;
  70977. /**
  70978. * Creates a tiled ground mesh
  70979. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70980. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70981. * * 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
  70982. * * 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
  70983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70984. * @param name defines the name of the mesh
  70985. * @param options defines the options used to create the mesh
  70986. * @param scene defines the hosting scene
  70987. * @returns the tiled ground mesh
  70988. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70989. */
  70990. static CreateTiledGround(name: string, options: {
  70991. xmin: number;
  70992. zmin: number;
  70993. xmax: number;
  70994. zmax: number;
  70995. subdivisions?: {
  70996. w: number;
  70997. h: number;
  70998. };
  70999. precision?: {
  71000. w: number;
  71001. h: number;
  71002. };
  71003. updatable?: boolean;
  71004. }, scene?: Nullable<Scene>): Mesh;
  71005. /**
  71006. * Creates a ground mesh from a height map
  71007. * * The parameter `url` sets the URL of the height map image resource.
  71008. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71009. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71010. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71011. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71012. * * 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.
  71013. * * 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).
  71014. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71016. * @param name defines the name of the mesh
  71017. * @param url defines the url to the height map
  71018. * @param options defines the options used to create the mesh
  71019. * @param scene defines the hosting scene
  71020. * @returns the ground mesh
  71021. * @see https://doc.babylonjs.com/babylon101/height_map
  71022. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71023. */
  71024. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71025. width?: number;
  71026. height?: number;
  71027. subdivisions?: number;
  71028. minHeight?: number;
  71029. maxHeight?: number;
  71030. colorFilter?: Color3;
  71031. alphaFilter?: number;
  71032. updatable?: boolean;
  71033. onReady?: (mesh: GroundMesh) => void;
  71034. }, scene?: Nullable<Scene>): GroundMesh;
  71035. /**
  71036. * Creates a polygon mesh
  71037. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71038. * * 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
  71039. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71041. * * 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)
  71042. * * Remember you can only change the shape positions, not their number when updating a polygon
  71043. * @param name defines the name of the mesh
  71044. * @param options defines the options used to create the mesh
  71045. * @param scene defines the hosting scene
  71046. * @param earcutInjection can be used to inject your own earcut reference
  71047. * @returns the polygon mesh
  71048. */
  71049. static CreatePolygon(name: string, options: {
  71050. shape: Vector3[];
  71051. holes?: Vector3[][];
  71052. depth?: number;
  71053. faceUV?: Vector4[];
  71054. faceColors?: Color4[];
  71055. updatable?: boolean;
  71056. sideOrientation?: number;
  71057. frontUVs?: Vector4;
  71058. backUVs?: Vector4;
  71059. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71060. /**
  71061. * Creates an extruded polygon mesh, with depth in the Y direction.
  71062. * * 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)
  71063. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71064. * @param name defines the name of the mesh
  71065. * @param options defines the options used to create the mesh
  71066. * @param scene defines the hosting scene
  71067. * @param earcutInjection can be used to inject your own earcut reference
  71068. * @returns the polygon mesh
  71069. */
  71070. static ExtrudePolygon(name: string, options: {
  71071. shape: Vector3[];
  71072. holes?: Vector3[][];
  71073. depth?: number;
  71074. faceUV?: Vector4[];
  71075. faceColors?: Color4[];
  71076. updatable?: boolean;
  71077. sideOrientation?: number;
  71078. frontUVs?: Vector4;
  71079. backUVs?: Vector4;
  71080. wrap?: boolean;
  71081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71082. /**
  71083. * Creates a tube mesh.
  71084. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71085. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71086. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71087. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71088. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71089. * * 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)
  71090. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71091. * * 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
  71092. * * 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
  71093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71094. * * 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
  71095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71097. * @param name defines the name of the mesh
  71098. * @param options defines the options used to create the mesh
  71099. * @param scene defines the hosting scene
  71100. * @returns the tube mesh
  71101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71102. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71103. */
  71104. static CreateTube(name: string, options: {
  71105. path: Vector3[];
  71106. radius?: number;
  71107. tessellation?: number;
  71108. radiusFunction?: {
  71109. (i: number, distance: number): number;
  71110. };
  71111. cap?: number;
  71112. arc?: number;
  71113. updatable?: boolean;
  71114. sideOrientation?: number;
  71115. frontUVs?: Vector4;
  71116. backUVs?: Vector4;
  71117. instance?: Mesh;
  71118. invertUV?: boolean;
  71119. }, scene?: Nullable<Scene>): Mesh;
  71120. /**
  71121. * Creates a polyhedron mesh
  71122. * * 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
  71123. * * The parameter `size` (positive float, default 1) sets the polygon size
  71124. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71125. * * 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`
  71126. * * 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
  71127. * * 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)`)
  71128. * * 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
  71129. * * 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
  71130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71131. * * 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
  71132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71133. * @param name defines the name of the mesh
  71134. * @param options defines the options used to create the mesh
  71135. * @param scene defines the hosting scene
  71136. * @returns the polyhedron mesh
  71137. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71138. */
  71139. static CreatePolyhedron(name: string, options: {
  71140. type?: number;
  71141. size?: number;
  71142. sizeX?: number;
  71143. sizeY?: number;
  71144. sizeZ?: number;
  71145. custom?: any;
  71146. faceUV?: Vector4[];
  71147. faceColors?: Color4[];
  71148. flat?: boolean;
  71149. updatable?: boolean;
  71150. sideOrientation?: number;
  71151. frontUVs?: Vector4;
  71152. backUVs?: Vector4;
  71153. }, scene?: Nullable<Scene>): Mesh;
  71154. /**
  71155. * Creates a decal mesh.
  71156. * 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
  71157. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71158. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71159. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71160. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71161. * @param name defines the name of the mesh
  71162. * @param sourceMesh defines the mesh where the decal must be applied
  71163. * @param options defines the options used to create the mesh
  71164. * @param scene defines the hosting scene
  71165. * @returns the decal mesh
  71166. * @see https://doc.babylonjs.com/how_to/decals
  71167. */
  71168. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71169. position?: Vector3;
  71170. normal?: Vector3;
  71171. size?: Vector3;
  71172. angle?: number;
  71173. }): Mesh;
  71174. /**
  71175. * Creates a Capsule Mesh
  71176. * @param name defines the name of the mesh.
  71177. * @param options the constructors options used to shape the mesh.
  71178. * @param scene defines the scene the mesh is scoped to.
  71179. * @returns the capsule mesh
  71180. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71181. */
  71182. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. /**
  71187. * A simplifier interface for future simplification implementations
  71188. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71189. */
  71190. export interface ISimplifier {
  71191. /**
  71192. * Simplification of a given mesh according to the given settings.
  71193. * Since this requires computation, it is assumed that the function runs async.
  71194. * @param settings The settings of the simplification, including quality and distance
  71195. * @param successCallback A callback that will be called after the mesh was simplified.
  71196. * @param errorCallback in case of an error, this callback will be called. optional.
  71197. */
  71198. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71199. }
  71200. /**
  71201. * Expected simplification settings.
  71202. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71203. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71204. */
  71205. export interface ISimplificationSettings {
  71206. /**
  71207. * Gets or sets the expected quality
  71208. */
  71209. quality: number;
  71210. /**
  71211. * Gets or sets the distance when this optimized version should be used
  71212. */
  71213. distance: number;
  71214. /**
  71215. * Gets an already optimized mesh
  71216. */
  71217. optimizeMesh?: boolean;
  71218. }
  71219. /**
  71220. * Class used to specify simplification options
  71221. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71222. */
  71223. export class SimplificationSettings implements ISimplificationSettings {
  71224. /** expected quality */
  71225. quality: number;
  71226. /** distance when this optimized version should be used */
  71227. distance: number;
  71228. /** already optimized mesh */
  71229. optimizeMesh?: boolean | undefined;
  71230. /**
  71231. * Creates a SimplificationSettings
  71232. * @param quality expected quality
  71233. * @param distance distance when this optimized version should be used
  71234. * @param optimizeMesh already optimized mesh
  71235. */
  71236. constructor(
  71237. /** expected quality */
  71238. quality: number,
  71239. /** distance when this optimized version should be used */
  71240. distance: number,
  71241. /** already optimized mesh */
  71242. optimizeMesh?: boolean | undefined);
  71243. }
  71244. /**
  71245. * Interface used to define a simplification task
  71246. */
  71247. export interface ISimplificationTask {
  71248. /**
  71249. * Array of settings
  71250. */
  71251. settings: Array<ISimplificationSettings>;
  71252. /**
  71253. * Simplification type
  71254. */
  71255. simplificationType: SimplificationType;
  71256. /**
  71257. * Mesh to simplify
  71258. */
  71259. mesh: Mesh;
  71260. /**
  71261. * Callback called on success
  71262. */
  71263. successCallback?: () => void;
  71264. /**
  71265. * Defines if parallel processing can be used
  71266. */
  71267. parallelProcessing: boolean;
  71268. }
  71269. /**
  71270. * Queue used to order the simplification tasks
  71271. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71272. */
  71273. export class SimplificationQueue {
  71274. private _simplificationArray;
  71275. /**
  71276. * Gets a boolean indicating that the process is still running
  71277. */
  71278. running: boolean;
  71279. /**
  71280. * Creates a new queue
  71281. */
  71282. constructor();
  71283. /**
  71284. * Adds a new simplification task
  71285. * @param task defines a task to add
  71286. */
  71287. addTask(task: ISimplificationTask): void;
  71288. /**
  71289. * Execute next task
  71290. */
  71291. executeNext(): void;
  71292. /**
  71293. * Execute a simplification task
  71294. * @param task defines the task to run
  71295. */
  71296. runSimplification(task: ISimplificationTask): void;
  71297. private getSimplifier;
  71298. }
  71299. /**
  71300. * The implemented types of simplification
  71301. * At the moment only Quadratic Error Decimation is implemented
  71302. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71303. */
  71304. export enum SimplificationType {
  71305. /** Quadratic error decimation */
  71306. QUADRATIC = 0
  71307. }
  71308. /**
  71309. * An implementation of the Quadratic Error simplification algorithm.
  71310. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71311. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71312. * @author RaananW
  71313. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71314. */
  71315. export class QuadraticErrorSimplification implements ISimplifier {
  71316. private _mesh;
  71317. private triangles;
  71318. private vertices;
  71319. private references;
  71320. private _reconstructedMesh;
  71321. /** Gets or sets the number pf sync iterations */
  71322. syncIterations: number;
  71323. /** Gets or sets the aggressiveness of the simplifier */
  71324. aggressiveness: number;
  71325. /** Gets or sets the number of allowed iterations for decimation */
  71326. decimationIterations: number;
  71327. /** Gets or sets the espilon to use for bounding box computation */
  71328. boundingBoxEpsilon: number;
  71329. /**
  71330. * Creates a new QuadraticErrorSimplification
  71331. * @param _mesh defines the target mesh
  71332. */
  71333. constructor(_mesh: Mesh);
  71334. /**
  71335. * Simplification of a given mesh according to the given settings.
  71336. * Since this requires computation, it is assumed that the function runs async.
  71337. * @param settings The settings of the simplification, including quality and distance
  71338. * @param successCallback A callback that will be called after the mesh was simplified.
  71339. */
  71340. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71341. private runDecimation;
  71342. private initWithMesh;
  71343. private init;
  71344. private reconstructMesh;
  71345. private initDecimatedMesh;
  71346. private isFlipped;
  71347. private updateTriangles;
  71348. private identifyBorder;
  71349. private updateMesh;
  71350. private vertexError;
  71351. private calculateError;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. interface Scene {
  71356. /** @hidden (Backing field) */
  71357. _simplificationQueue: SimplificationQueue;
  71358. /**
  71359. * Gets or sets the simplification queue attached to the scene
  71360. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71361. */
  71362. simplificationQueue: SimplificationQueue;
  71363. }
  71364. interface Mesh {
  71365. /**
  71366. * Simplify the mesh according to the given array of settings.
  71367. * Function will return immediately and will simplify async
  71368. * @param settings a collection of simplification settings
  71369. * @param parallelProcessing should all levels calculate parallel or one after the other
  71370. * @param simplificationType the type of simplification to run
  71371. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71372. * @returns the current mesh
  71373. */
  71374. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71375. }
  71376. /**
  71377. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71378. * created in a scene
  71379. */
  71380. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71381. /**
  71382. * The component name helpfull to identify the component in the list of scene components.
  71383. */
  71384. readonly name: string;
  71385. /**
  71386. * The scene the component belongs to.
  71387. */
  71388. scene: Scene;
  71389. /**
  71390. * Creates a new instance of the component for the given scene
  71391. * @param scene Defines the scene to register the component in
  71392. */
  71393. constructor(scene: Scene);
  71394. /**
  71395. * Registers the component in a given scene
  71396. */
  71397. register(): void;
  71398. /**
  71399. * Rebuilds the elements related to this component in case of
  71400. * context lost for instance.
  71401. */
  71402. rebuild(): void;
  71403. /**
  71404. * Disposes the component and the associated resources
  71405. */
  71406. dispose(): void;
  71407. private _beforeCameraUpdate;
  71408. }
  71409. }
  71410. declare module BABYLON {
  71411. interface Mesh {
  71412. /**
  71413. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71414. */
  71415. thinInstanceEnablePicking: boolean;
  71416. /**
  71417. * Creates a new thin instance
  71418. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71419. * @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
  71420. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71421. */
  71422. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71423. /**
  71424. * Adds the transformation (matrix) of the current mesh as a thin instance
  71425. * @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
  71426. * @returns the thin instance index number
  71427. */
  71428. thinInstanceAddSelf(refresh: boolean): number;
  71429. /**
  71430. * Registers a custom attribute to be used with thin instances
  71431. * @param kind name of the attribute
  71432. * @param stride size in floats of the attribute
  71433. */
  71434. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71435. /**
  71436. * Sets the matrix of a thin instance
  71437. * @param index index of the thin instance
  71438. * @param matrix matrix to set
  71439. * @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
  71440. */
  71441. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71442. /**
  71443. * Sets the value of a custom attribute for a thin instance
  71444. * @param kind name of the attribute
  71445. * @param index index of the thin instance
  71446. * @param value value to set
  71447. * @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
  71448. */
  71449. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71450. /**
  71451. * 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.
  71452. */
  71453. thinInstanceCount: number;
  71454. /**
  71455. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71456. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71457. * @param buffer buffer to set
  71458. * @param stride size in floats of each value of the buffer
  71459. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71460. */
  71461. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71462. /**
  71463. * Gets the list of world matrices
  71464. * @return an array containing all the world matrices from the thin instances
  71465. */
  71466. thinInstanceGetWorldMatrices(): Matrix[];
  71467. /**
  71468. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71469. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71470. */
  71471. thinInstanceBufferUpdated(kind: string): void;
  71472. /**
  71473. * Applies a partial update to a buffer directly on the GPU
  71474. * 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
  71475. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71476. * @param data the data to set in the GPU buffer
  71477. * @param offset the offset in the GPU buffer where to update the data
  71478. */
  71479. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71480. /**
  71481. * Refreshes the bounding info, taking into account all the thin instances defined
  71482. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71483. */
  71484. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71485. /** @hidden */
  71486. _thinInstanceInitializeUserStorage(): void;
  71487. /** @hidden */
  71488. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71489. /** @hidden */
  71490. _userThinInstanceBuffersStorage: {
  71491. data: {
  71492. [key: string]: Float32Array;
  71493. };
  71494. sizes: {
  71495. [key: string]: number;
  71496. };
  71497. vertexBuffers: {
  71498. [key: string]: Nullable<VertexBuffer>;
  71499. };
  71500. strides: {
  71501. [key: string]: number;
  71502. };
  71503. };
  71504. }
  71505. }
  71506. declare module BABYLON {
  71507. /**
  71508. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71509. */
  71510. export interface INavigationEnginePlugin {
  71511. /**
  71512. * plugin name
  71513. */
  71514. name: string;
  71515. /**
  71516. * Creates a navigation mesh
  71517. * @param meshes array of all the geometry used to compute the navigation mesh
  71518. * @param parameters bunch of parameters used to filter geometry
  71519. */
  71520. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71521. /**
  71522. * Create a navigation mesh debug mesh
  71523. * @param scene is where the mesh will be added
  71524. * @returns debug display mesh
  71525. */
  71526. createDebugNavMesh(scene: Scene): Mesh;
  71527. /**
  71528. * Get a navigation mesh constrained position, closest to the parameter position
  71529. * @param position world position
  71530. * @returns the closest point to position constrained by the navigation mesh
  71531. */
  71532. getClosestPoint(position: Vector3): Vector3;
  71533. /**
  71534. * Get a navigation mesh constrained position, closest to the parameter position
  71535. * @param position world position
  71536. * @param result output the closest point to position constrained by the navigation mesh
  71537. */
  71538. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71539. /**
  71540. * Get a navigation mesh constrained position, within a particular radius
  71541. * @param position world position
  71542. * @param maxRadius the maximum distance to the constrained world position
  71543. * @returns the closest point to position constrained by the navigation mesh
  71544. */
  71545. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71546. /**
  71547. * Get a navigation mesh constrained position, within a particular radius
  71548. * @param position world position
  71549. * @param maxRadius the maximum distance to the constrained world position
  71550. * @param result output the closest point to position constrained by the navigation mesh
  71551. */
  71552. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71553. /**
  71554. * Compute the final position from a segment made of destination-position
  71555. * @param position world position
  71556. * @param destination world position
  71557. * @returns the resulting point along the navmesh
  71558. */
  71559. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71560. /**
  71561. * Compute the final position from a segment made of destination-position
  71562. * @param position world position
  71563. * @param destination world position
  71564. * @param result output the resulting point along the navmesh
  71565. */
  71566. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71567. /**
  71568. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71569. * @param start world position
  71570. * @param end world position
  71571. * @returns array containing world position composing the path
  71572. */
  71573. computePath(start: Vector3, end: Vector3): Vector3[];
  71574. /**
  71575. * If this plugin is supported
  71576. * @returns true if plugin is supported
  71577. */
  71578. isSupported(): boolean;
  71579. /**
  71580. * Create a new Crowd so you can add agents
  71581. * @param maxAgents the maximum agent count in the crowd
  71582. * @param maxAgentRadius the maximum radius an agent can have
  71583. * @param scene to attach the crowd to
  71584. * @returns the crowd you can add agents to
  71585. */
  71586. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71587. /**
  71588. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71589. * The queries will try to find a solution within those bounds
  71590. * default is (1,1,1)
  71591. * @param extent x,y,z value that define the extent around the queries point of reference
  71592. */
  71593. setDefaultQueryExtent(extent: Vector3): void;
  71594. /**
  71595. * Get the Bounding box extent specified by setDefaultQueryExtent
  71596. * @returns the box extent values
  71597. */
  71598. getDefaultQueryExtent(): Vector3;
  71599. /**
  71600. * build the navmesh from a previously saved state using getNavmeshData
  71601. * @param data the Uint8Array returned by getNavmeshData
  71602. */
  71603. buildFromNavmeshData(data: Uint8Array): void;
  71604. /**
  71605. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71606. * @returns data the Uint8Array that can be saved and reused
  71607. */
  71608. getNavmeshData(): Uint8Array;
  71609. /**
  71610. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71611. * @param result output the box extent values
  71612. */
  71613. getDefaultQueryExtentToRef(result: Vector3): void;
  71614. /**
  71615. * Set the time step of the navigation tick update.
  71616. * Default is 1/60.
  71617. * A value of 0 will disable fixed time update
  71618. * @param newTimeStep the new timestep to apply to this world.
  71619. */
  71620. setTimeStep(newTimeStep: number): void;
  71621. /**
  71622. * Get the time step of the navigation tick update.
  71623. * @returns the current time step
  71624. */
  71625. getTimeStep(): number;
  71626. /**
  71627. * If delta time in navigation tick update is greater than the time step
  71628. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71629. * they will be discarded.
  71630. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71631. * @param newStepCount the maximum number of iterations
  71632. */
  71633. setMaximumSubStepCount(newStepCount: number): void;
  71634. /**
  71635. * Get the maximum number of iterations per navigation tick update
  71636. * @returns the maximum number of iterations
  71637. */
  71638. getMaximumSubStepCount(): number;
  71639. /**
  71640. * Release all resources
  71641. */
  71642. dispose(): void;
  71643. }
  71644. /**
  71645. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71646. */
  71647. export interface ICrowd {
  71648. /**
  71649. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71650. * You can attach anything to that node. The node position is updated in the scene update tick.
  71651. * @param pos world position that will be constrained by the navigation mesh
  71652. * @param parameters agent parameters
  71653. * @param transform hooked to the agent that will be update by the scene
  71654. * @returns agent index
  71655. */
  71656. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71657. /**
  71658. * Returns the agent position in world space
  71659. * @param index agent index returned by addAgent
  71660. * @returns world space position
  71661. */
  71662. getAgentPosition(index: number): Vector3;
  71663. /**
  71664. * Gets the agent position result in world space
  71665. * @param index agent index returned by addAgent
  71666. * @param result output world space position
  71667. */
  71668. getAgentPositionToRef(index: number, result: Vector3): void;
  71669. /**
  71670. * Gets the agent velocity in world space
  71671. * @param index agent index returned by addAgent
  71672. * @returns world space velocity
  71673. */
  71674. getAgentVelocity(index: number): Vector3;
  71675. /**
  71676. * Gets the agent velocity result in world space
  71677. * @param index agent index returned by addAgent
  71678. * @param result output world space velocity
  71679. */
  71680. getAgentVelocityToRef(index: number, result: Vector3): void;
  71681. /**
  71682. * Gets the agent next target point on the path
  71683. * @param index agent index returned by addAgent
  71684. * @returns world space position
  71685. */
  71686. getAgentNextTargetPath(index: number): Vector3;
  71687. /**
  71688. * Gets the agent state
  71689. * @param index agent index returned by addAgent
  71690. * @returns agent state
  71691. */
  71692. getAgentState(index: number): number;
  71693. /**
  71694. * returns true if the agent in over an off mesh link connection
  71695. * @param index agent index returned by addAgent
  71696. * @returns true if over an off mesh link connection
  71697. */
  71698. overOffmeshConnection(index: number): boolean;
  71699. /**
  71700. * Gets the agent next target point on the path
  71701. * @param index agent index returned by addAgent
  71702. * @param result output world space position
  71703. */
  71704. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71705. /**
  71706. * remove a particular agent previously created
  71707. * @param index agent index returned by addAgent
  71708. */
  71709. removeAgent(index: number): void;
  71710. /**
  71711. * get the list of all agents attached to this crowd
  71712. * @returns list of agent indices
  71713. */
  71714. getAgents(): number[];
  71715. /**
  71716. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71717. * @param deltaTime in seconds
  71718. */
  71719. update(deltaTime: number): void;
  71720. /**
  71721. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71722. * @param index agent index returned by addAgent
  71723. * @param destination targeted world position
  71724. */
  71725. agentGoto(index: number, destination: Vector3): void;
  71726. /**
  71727. * Teleport the agent to a new position
  71728. * @param index agent index returned by addAgent
  71729. * @param destination targeted world position
  71730. */
  71731. agentTeleport(index: number, destination: Vector3): void;
  71732. /**
  71733. * Update agent parameters
  71734. * @param index agent index returned by addAgent
  71735. * @param parameters agent parameters
  71736. */
  71737. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71738. /**
  71739. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71740. * The queries will try to find a solution within those bounds
  71741. * default is (1,1,1)
  71742. * @param extent x,y,z value that define the extent around the queries point of reference
  71743. */
  71744. setDefaultQueryExtent(extent: Vector3): void;
  71745. /**
  71746. * Get the Bounding box extent specified by setDefaultQueryExtent
  71747. * @returns the box extent values
  71748. */
  71749. getDefaultQueryExtent(): Vector3;
  71750. /**
  71751. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71752. * @param result output the box extent values
  71753. */
  71754. getDefaultQueryExtentToRef(result: Vector3): void;
  71755. /**
  71756. * Release all resources
  71757. */
  71758. dispose(): void;
  71759. }
  71760. /**
  71761. * Configures an agent
  71762. */
  71763. export interface IAgentParameters {
  71764. /**
  71765. * Agent radius. [Limit: >= 0]
  71766. */
  71767. radius: number;
  71768. /**
  71769. * Agent height. [Limit: > 0]
  71770. */
  71771. height: number;
  71772. /**
  71773. * Maximum allowed acceleration. [Limit: >= 0]
  71774. */
  71775. maxAcceleration: number;
  71776. /**
  71777. * Maximum allowed speed. [Limit: >= 0]
  71778. */
  71779. maxSpeed: number;
  71780. /**
  71781. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71782. */
  71783. collisionQueryRange: number;
  71784. /**
  71785. * The path visibility optimization range. [Limit: > 0]
  71786. */
  71787. pathOptimizationRange: number;
  71788. /**
  71789. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71790. */
  71791. separationWeight: number;
  71792. }
  71793. /**
  71794. * Configures the navigation mesh creation
  71795. */
  71796. export interface INavMeshParameters {
  71797. /**
  71798. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71799. */
  71800. cs: number;
  71801. /**
  71802. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71803. */
  71804. ch: number;
  71805. /**
  71806. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71807. */
  71808. walkableSlopeAngle: number;
  71809. /**
  71810. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71811. * be considered walkable. [Limit: >= 3] [Units: vx]
  71812. */
  71813. walkableHeight: number;
  71814. /**
  71815. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71816. */
  71817. walkableClimb: number;
  71818. /**
  71819. * The distance to erode/shrink the walkable area of the heightfield away from
  71820. * obstructions. [Limit: >=0] [Units: vx]
  71821. */
  71822. walkableRadius: number;
  71823. /**
  71824. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71825. */
  71826. maxEdgeLen: number;
  71827. /**
  71828. * The maximum distance a simplified contour's border edges should deviate
  71829. * the original raw contour. [Limit: >=0] [Units: vx]
  71830. */
  71831. maxSimplificationError: number;
  71832. /**
  71833. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71834. */
  71835. minRegionArea: number;
  71836. /**
  71837. * Any regions with a span count smaller than this value will, if possible,
  71838. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71839. */
  71840. mergeRegionArea: number;
  71841. /**
  71842. * The maximum number of vertices allowed for polygons generated during the
  71843. * contour to polygon conversion process. [Limit: >= 3]
  71844. */
  71845. maxVertsPerPoly: number;
  71846. /**
  71847. * Sets the sampling distance to use when generating the detail mesh.
  71848. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71849. */
  71850. detailSampleDist: number;
  71851. /**
  71852. * The maximum distance the detail mesh surface should deviate from heightfield
  71853. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71854. */
  71855. detailSampleMaxError: number;
  71856. }
  71857. }
  71858. declare module BABYLON {
  71859. /**
  71860. * RecastJS navigation plugin
  71861. */
  71862. export class RecastJSPlugin implements INavigationEnginePlugin {
  71863. /**
  71864. * Reference to the Recast library
  71865. */
  71866. bjsRECAST: any;
  71867. /**
  71868. * plugin name
  71869. */
  71870. name: string;
  71871. /**
  71872. * the first navmesh created. We might extend this to support multiple navmeshes
  71873. */
  71874. navMesh: any;
  71875. private _maximumSubStepCount;
  71876. private _timeStep;
  71877. /**
  71878. * Initializes the recastJS plugin
  71879. * @param recastInjection can be used to inject your own recast reference
  71880. */
  71881. constructor(recastInjection?: any);
  71882. /**
  71883. * Set the time step of the navigation tick update.
  71884. * Default is 1/60.
  71885. * A value of 0 will disable fixed time update
  71886. * @param newTimeStep the new timestep to apply to this world.
  71887. */
  71888. setTimeStep(newTimeStep?: number): void;
  71889. /**
  71890. * Get the time step of the navigation tick update.
  71891. * @returns the current time step
  71892. */
  71893. getTimeStep(): number;
  71894. /**
  71895. * If delta time in navigation tick update is greater than the time step
  71896. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71897. * they will be discarded.
  71898. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71899. * @param newStepCount the maximum number of iterations
  71900. */
  71901. setMaximumSubStepCount(newStepCount?: number): void;
  71902. /**
  71903. * Get the maximum number of iterations per navigation tick update
  71904. * @returns the maximum number of iterations
  71905. */
  71906. getMaximumSubStepCount(): number;
  71907. /**
  71908. * Creates a navigation mesh
  71909. * @param meshes array of all the geometry used to compute the navigation mesh
  71910. * @param parameters bunch of parameters used to filter geometry
  71911. */
  71912. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71913. /**
  71914. * Create a navigation mesh debug mesh
  71915. * @param scene is where the mesh will be added
  71916. * @returns debug display mesh
  71917. */
  71918. createDebugNavMesh(scene: Scene): Mesh;
  71919. /**
  71920. * Get a navigation mesh constrained position, closest to the parameter position
  71921. * @param position world position
  71922. * @returns the closest point to position constrained by the navigation mesh
  71923. */
  71924. getClosestPoint(position: Vector3): Vector3;
  71925. /**
  71926. * Get a navigation mesh constrained position, closest to the parameter position
  71927. * @param position world position
  71928. * @param result output the closest point to position constrained by the navigation mesh
  71929. */
  71930. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71931. /**
  71932. * Get a navigation mesh constrained position, within a particular radius
  71933. * @param position world position
  71934. * @param maxRadius the maximum distance to the constrained world position
  71935. * @returns the closest point to position constrained by the navigation mesh
  71936. */
  71937. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71938. /**
  71939. * Get a navigation mesh constrained position, within a particular radius
  71940. * @param position world position
  71941. * @param maxRadius the maximum distance to the constrained world position
  71942. * @param result output the closest point to position constrained by the navigation mesh
  71943. */
  71944. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71945. /**
  71946. * Compute the final position from a segment made of destination-position
  71947. * @param position world position
  71948. * @param destination world position
  71949. * @returns the resulting point along the navmesh
  71950. */
  71951. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71952. /**
  71953. * Compute the final position from a segment made of destination-position
  71954. * @param position world position
  71955. * @param destination world position
  71956. * @param result output the resulting point along the navmesh
  71957. */
  71958. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71959. /**
  71960. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71961. * @param start world position
  71962. * @param end world position
  71963. * @returns array containing world position composing the path
  71964. */
  71965. computePath(start: Vector3, end: Vector3): Vector3[];
  71966. /**
  71967. * Create a new Crowd so you can add agents
  71968. * @param maxAgents the maximum agent count in the crowd
  71969. * @param maxAgentRadius the maximum radius an agent can have
  71970. * @param scene to attach the crowd to
  71971. * @returns the crowd you can add agents to
  71972. */
  71973. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71974. /**
  71975. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71976. * The queries will try to find a solution within those bounds
  71977. * default is (1,1,1)
  71978. * @param extent x,y,z value that define the extent around the queries point of reference
  71979. */
  71980. setDefaultQueryExtent(extent: Vector3): void;
  71981. /**
  71982. * Get the Bounding box extent specified by setDefaultQueryExtent
  71983. * @returns the box extent values
  71984. */
  71985. getDefaultQueryExtent(): Vector3;
  71986. /**
  71987. * build the navmesh from a previously saved state using getNavmeshData
  71988. * @param data the Uint8Array returned by getNavmeshData
  71989. */
  71990. buildFromNavmeshData(data: Uint8Array): void;
  71991. /**
  71992. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71993. * @returns data the Uint8Array that can be saved and reused
  71994. */
  71995. getNavmeshData(): Uint8Array;
  71996. /**
  71997. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71998. * @param result output the box extent values
  71999. */
  72000. getDefaultQueryExtentToRef(result: Vector3): void;
  72001. /**
  72002. * Disposes
  72003. */
  72004. dispose(): void;
  72005. /**
  72006. * If this plugin is supported
  72007. * @returns true if plugin is supported
  72008. */
  72009. isSupported(): boolean;
  72010. }
  72011. /**
  72012. * Recast detour crowd implementation
  72013. */
  72014. export class RecastJSCrowd implements ICrowd {
  72015. /**
  72016. * Recast/detour plugin
  72017. */
  72018. bjsRECASTPlugin: RecastJSPlugin;
  72019. /**
  72020. * Link to the detour crowd
  72021. */
  72022. recastCrowd: any;
  72023. /**
  72024. * One transform per agent
  72025. */
  72026. transforms: TransformNode[];
  72027. /**
  72028. * All agents created
  72029. */
  72030. agents: number[];
  72031. /**
  72032. * Link to the scene is kept to unregister the crowd from the scene
  72033. */
  72034. private _scene;
  72035. /**
  72036. * Observer for crowd updates
  72037. */
  72038. private _onBeforeAnimationsObserver;
  72039. /**
  72040. * Constructor
  72041. * @param plugin recastJS plugin
  72042. * @param maxAgents the maximum agent count in the crowd
  72043. * @param maxAgentRadius the maximum radius an agent can have
  72044. * @param scene to attach the crowd to
  72045. * @returns the crowd you can add agents to
  72046. */
  72047. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72048. /**
  72049. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72050. * You can attach anything to that node. The node position is updated in the scene update tick.
  72051. * @param pos world position that will be constrained by the navigation mesh
  72052. * @param parameters agent parameters
  72053. * @param transform hooked to the agent that will be update by the scene
  72054. * @returns agent index
  72055. */
  72056. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72057. /**
  72058. * Returns the agent position in world space
  72059. * @param index agent index returned by addAgent
  72060. * @returns world space position
  72061. */
  72062. getAgentPosition(index: number): Vector3;
  72063. /**
  72064. * Returns the agent position result in world space
  72065. * @param index agent index returned by addAgent
  72066. * @param result output world space position
  72067. */
  72068. getAgentPositionToRef(index: number, result: Vector3): void;
  72069. /**
  72070. * Returns the agent velocity in world space
  72071. * @param index agent index returned by addAgent
  72072. * @returns world space velocity
  72073. */
  72074. getAgentVelocity(index: number): Vector3;
  72075. /**
  72076. * Returns the agent velocity result in world space
  72077. * @param index agent index returned by addAgent
  72078. * @param result output world space velocity
  72079. */
  72080. getAgentVelocityToRef(index: number, result: Vector3): void;
  72081. /**
  72082. * Returns the agent next target point on the path
  72083. * @param index agent index returned by addAgent
  72084. * @returns world space position
  72085. */
  72086. getAgentNextTargetPath(index: number): Vector3;
  72087. /**
  72088. * Returns the agent next target point on the path
  72089. * @param index agent index returned by addAgent
  72090. * @param result output world space position
  72091. */
  72092. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72093. /**
  72094. * Gets the agent state
  72095. * @param index agent index returned by addAgent
  72096. * @returns agent state
  72097. */
  72098. getAgentState(index: number): number;
  72099. /**
  72100. * returns true if the agent in over an off mesh link connection
  72101. * @param index agent index returned by addAgent
  72102. * @returns true if over an off mesh link connection
  72103. */
  72104. overOffmeshConnection(index: number): boolean;
  72105. /**
  72106. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72107. * @param index agent index returned by addAgent
  72108. * @param destination targeted world position
  72109. */
  72110. agentGoto(index: number, destination: Vector3): void;
  72111. /**
  72112. * Teleport the agent to a new position
  72113. * @param index agent index returned by addAgent
  72114. * @param destination targeted world position
  72115. */
  72116. agentTeleport(index: number, destination: Vector3): void;
  72117. /**
  72118. * Update agent parameters
  72119. * @param index agent index returned by addAgent
  72120. * @param parameters agent parameters
  72121. */
  72122. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72123. /**
  72124. * remove a particular agent previously created
  72125. * @param index agent index returned by addAgent
  72126. */
  72127. removeAgent(index: number): void;
  72128. /**
  72129. * get the list of all agents attached to this crowd
  72130. * @returns list of agent indices
  72131. */
  72132. getAgents(): number[];
  72133. /**
  72134. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72135. * @param deltaTime in seconds
  72136. */
  72137. update(deltaTime: number): void;
  72138. /**
  72139. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72140. * The queries will try to find a solution within those bounds
  72141. * default is (1,1,1)
  72142. * @param extent x,y,z value that define the extent around the queries point of reference
  72143. */
  72144. setDefaultQueryExtent(extent: Vector3): void;
  72145. /**
  72146. * Get the Bounding box extent specified by setDefaultQueryExtent
  72147. * @returns the box extent values
  72148. */
  72149. getDefaultQueryExtent(): Vector3;
  72150. /**
  72151. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72152. * @param result output the box extent values
  72153. */
  72154. getDefaultQueryExtentToRef(result: Vector3): void;
  72155. /**
  72156. * Release all resources
  72157. */
  72158. dispose(): void;
  72159. }
  72160. }
  72161. declare module BABYLON {
  72162. /**
  72163. * Class used to enable access to IndexedDB
  72164. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72165. */
  72166. export class Database implements IOfflineProvider {
  72167. private _callbackManifestChecked;
  72168. private _currentSceneUrl;
  72169. private _db;
  72170. private _enableSceneOffline;
  72171. private _enableTexturesOffline;
  72172. private _manifestVersionFound;
  72173. private _mustUpdateRessources;
  72174. private _hasReachedQuota;
  72175. private _isSupported;
  72176. private _idbFactory;
  72177. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72178. private static IsUASupportingBlobStorage;
  72179. /**
  72180. * Gets a boolean indicating if Database storage is enabled (off by default)
  72181. */
  72182. static IDBStorageEnabled: boolean;
  72183. /**
  72184. * Gets a boolean indicating if scene must be saved in the database
  72185. */
  72186. get enableSceneOffline(): boolean;
  72187. /**
  72188. * Gets a boolean indicating if textures must be saved in the database
  72189. */
  72190. get enableTexturesOffline(): boolean;
  72191. /**
  72192. * Creates a new Database
  72193. * @param urlToScene defines the url to load the scene
  72194. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72195. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72196. */
  72197. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72198. private static _ParseURL;
  72199. private static _ReturnFullUrlLocation;
  72200. private _checkManifestFile;
  72201. /**
  72202. * Open the database and make it available
  72203. * @param successCallback defines the callback to call on success
  72204. * @param errorCallback defines the callback to call on error
  72205. */
  72206. open(successCallback: () => void, errorCallback: () => void): void;
  72207. /**
  72208. * Loads an image from the database
  72209. * @param url defines the url to load from
  72210. * @param image defines the target DOM image
  72211. */
  72212. loadImage(url: string, image: HTMLImageElement): void;
  72213. private _loadImageFromDBAsync;
  72214. private _saveImageIntoDBAsync;
  72215. private _checkVersionFromDB;
  72216. private _loadVersionFromDBAsync;
  72217. private _saveVersionIntoDBAsync;
  72218. /**
  72219. * Loads a file from database
  72220. * @param url defines the URL to load from
  72221. * @param sceneLoaded defines a callback to call on success
  72222. * @param progressCallBack defines a callback to call when progress changed
  72223. * @param errorCallback defines a callback to call on error
  72224. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72225. */
  72226. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72227. private _loadFileAsync;
  72228. private _saveFileAsync;
  72229. /**
  72230. * Validates if xhr data is correct
  72231. * @param xhr defines the request to validate
  72232. * @param dataType defines the expected data type
  72233. * @returns true if data is correct
  72234. */
  72235. private static _ValidateXHRData;
  72236. }
  72237. }
  72238. declare module BABYLON {
  72239. /** @hidden */
  72240. export var gpuUpdateParticlesPixelShader: {
  72241. name: string;
  72242. shader: string;
  72243. };
  72244. }
  72245. declare module BABYLON {
  72246. /** @hidden */
  72247. export var gpuUpdateParticlesVertexShader: {
  72248. name: string;
  72249. shader: string;
  72250. };
  72251. }
  72252. declare module BABYLON {
  72253. /** @hidden */
  72254. export var clipPlaneFragmentDeclaration2: {
  72255. name: string;
  72256. shader: string;
  72257. };
  72258. }
  72259. declare module BABYLON {
  72260. /** @hidden */
  72261. export var gpuRenderParticlesPixelShader: {
  72262. name: string;
  72263. shader: string;
  72264. };
  72265. }
  72266. declare module BABYLON {
  72267. /** @hidden */
  72268. export var clipPlaneVertexDeclaration2: {
  72269. name: string;
  72270. shader: string;
  72271. };
  72272. }
  72273. declare module BABYLON {
  72274. /** @hidden */
  72275. export var gpuRenderParticlesVertexShader: {
  72276. name: string;
  72277. shader: string;
  72278. };
  72279. }
  72280. declare module BABYLON {
  72281. /**
  72282. * This represents a GPU particle system in Babylon
  72283. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72284. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72285. */
  72286. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72287. /**
  72288. * The layer mask we are rendering the particles through.
  72289. */
  72290. layerMask: number;
  72291. private _capacity;
  72292. private _activeCount;
  72293. private _currentActiveCount;
  72294. private _accumulatedCount;
  72295. private _renderEffect;
  72296. private _updateEffect;
  72297. private _buffer0;
  72298. private _buffer1;
  72299. private _spriteBuffer;
  72300. private _updateVAO;
  72301. private _renderVAO;
  72302. private _targetIndex;
  72303. private _sourceBuffer;
  72304. private _targetBuffer;
  72305. private _currentRenderId;
  72306. private _started;
  72307. private _stopped;
  72308. private _timeDelta;
  72309. private _randomTexture;
  72310. private _randomTexture2;
  72311. private _attributesStrideSize;
  72312. private _updateEffectOptions;
  72313. private _randomTextureSize;
  72314. private _actualFrame;
  72315. private _customEffect;
  72316. private readonly _rawTextureWidth;
  72317. /**
  72318. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72319. */
  72320. static get IsSupported(): boolean;
  72321. /**
  72322. * An event triggered when the system is disposed.
  72323. */
  72324. onDisposeObservable: Observable<IParticleSystem>;
  72325. /**
  72326. * An event triggered when the system is stopped
  72327. */
  72328. onStoppedObservable: Observable<IParticleSystem>;
  72329. /**
  72330. * Gets the maximum number of particles active at the same time.
  72331. * @returns The max number of active particles.
  72332. */
  72333. getCapacity(): number;
  72334. /**
  72335. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72336. * to override the particles.
  72337. */
  72338. forceDepthWrite: boolean;
  72339. /**
  72340. * Gets or set the number of active particles
  72341. */
  72342. get activeParticleCount(): number;
  72343. set activeParticleCount(value: number);
  72344. private _preWarmDone;
  72345. /**
  72346. * Specifies if the particles are updated in emitter local space or world space.
  72347. */
  72348. isLocal: boolean;
  72349. /** Gets or sets a matrix to use to compute projection */
  72350. defaultProjectionMatrix: Matrix;
  72351. /**
  72352. * Is this system ready to be used/rendered
  72353. * @return true if the system is ready
  72354. */
  72355. isReady(): boolean;
  72356. /**
  72357. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72358. * @returns True if it has been started, otherwise false.
  72359. */
  72360. isStarted(): boolean;
  72361. /**
  72362. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72363. * @returns True if it has been stopped, otherwise false.
  72364. */
  72365. isStopped(): boolean;
  72366. /**
  72367. * Gets a boolean indicating that the system is stopping
  72368. * @returns true if the system is currently stopping
  72369. */
  72370. isStopping(): boolean;
  72371. /**
  72372. * Gets the number of particles active at the same time.
  72373. * @returns The number of active particles.
  72374. */
  72375. getActiveCount(): number;
  72376. /**
  72377. * Starts the particle system and begins to emit
  72378. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72379. */
  72380. start(delay?: number): void;
  72381. /**
  72382. * Stops the particle system.
  72383. */
  72384. stop(): void;
  72385. /**
  72386. * Remove all active particles
  72387. */
  72388. reset(): void;
  72389. /**
  72390. * Returns the string "GPUParticleSystem"
  72391. * @returns a string containing the class name
  72392. */
  72393. getClassName(): string;
  72394. /**
  72395. * Gets the custom effect used to render the particles
  72396. * @param blendMode Blend mode for which the effect should be retrieved
  72397. * @returns The effect
  72398. */
  72399. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72400. /**
  72401. * Sets the custom effect used to render the particles
  72402. * @param effect The effect to set
  72403. * @param blendMode Blend mode for which the effect should be set
  72404. */
  72405. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72406. /** @hidden */
  72407. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72408. /**
  72409. * Observable that will be called just before the particles are drawn
  72410. */
  72411. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72412. /**
  72413. * Gets the name of the particle vertex shader
  72414. */
  72415. get vertexShaderName(): string;
  72416. private _colorGradientsTexture;
  72417. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72418. /**
  72419. * Adds a new color gradient
  72420. * @param gradient defines the gradient to use (between 0 and 1)
  72421. * @param color1 defines the color to affect to the specified gradient
  72422. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72423. * @returns the current particle system
  72424. */
  72425. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72426. private _refreshColorGradient;
  72427. /** Force the system to rebuild all gradients that need to be resync */
  72428. forceRefreshGradients(): void;
  72429. /**
  72430. * Remove a specific color gradient
  72431. * @param gradient defines the gradient to remove
  72432. * @returns the current particle system
  72433. */
  72434. removeColorGradient(gradient: number): GPUParticleSystem;
  72435. private _angularSpeedGradientsTexture;
  72436. private _sizeGradientsTexture;
  72437. private _velocityGradientsTexture;
  72438. private _limitVelocityGradientsTexture;
  72439. private _dragGradientsTexture;
  72440. private _addFactorGradient;
  72441. /**
  72442. * Adds a new size gradient
  72443. * @param gradient defines the gradient to use (between 0 and 1)
  72444. * @param factor defines the size factor to affect to the specified gradient
  72445. * @returns the current particle system
  72446. */
  72447. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72448. /**
  72449. * Remove a specific size gradient
  72450. * @param gradient defines the gradient to remove
  72451. * @returns the current particle system
  72452. */
  72453. removeSizeGradient(gradient: number): GPUParticleSystem;
  72454. private _refreshFactorGradient;
  72455. /**
  72456. * Adds a new angular speed gradient
  72457. * @param gradient defines the gradient to use (between 0 and 1)
  72458. * @param factor defines the angular speed to affect to the specified gradient
  72459. * @returns the current particle system
  72460. */
  72461. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72462. /**
  72463. * Remove a specific angular speed gradient
  72464. * @param gradient defines the gradient to remove
  72465. * @returns the current particle system
  72466. */
  72467. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72468. /**
  72469. * Adds a new velocity gradient
  72470. * @param gradient defines the gradient to use (between 0 and 1)
  72471. * @param factor defines the velocity to affect to the specified gradient
  72472. * @returns the current particle system
  72473. */
  72474. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72475. /**
  72476. * Remove a specific velocity gradient
  72477. * @param gradient defines the gradient to remove
  72478. * @returns the current particle system
  72479. */
  72480. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72481. /**
  72482. * Adds a new limit velocity gradient
  72483. * @param gradient defines the gradient to use (between 0 and 1)
  72484. * @param factor defines the limit velocity value to affect to the specified gradient
  72485. * @returns the current particle system
  72486. */
  72487. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72488. /**
  72489. * Remove a specific limit velocity gradient
  72490. * @param gradient defines the gradient to remove
  72491. * @returns the current particle system
  72492. */
  72493. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72494. /**
  72495. * Adds a new drag gradient
  72496. * @param gradient defines the gradient to use (between 0 and 1)
  72497. * @param factor defines the drag value to affect to the specified gradient
  72498. * @returns the current particle system
  72499. */
  72500. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72501. /**
  72502. * Remove a specific drag gradient
  72503. * @param gradient defines the gradient to remove
  72504. * @returns the current particle system
  72505. */
  72506. removeDragGradient(gradient: number): GPUParticleSystem;
  72507. /**
  72508. * Not supported by GPUParticleSystem
  72509. * @param gradient defines the gradient to use (between 0 and 1)
  72510. * @param factor defines the emit rate value to affect to the specified gradient
  72511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72512. * @returns the current particle system
  72513. */
  72514. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72515. /**
  72516. * Not supported by GPUParticleSystem
  72517. * @param gradient defines the gradient to remove
  72518. * @returns the current particle system
  72519. */
  72520. removeEmitRateGradient(gradient: number): IParticleSystem;
  72521. /**
  72522. * Not supported by GPUParticleSystem
  72523. * @param gradient defines the gradient to use (between 0 and 1)
  72524. * @param factor defines the start size value to affect to the specified gradient
  72525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72526. * @returns the current particle system
  72527. */
  72528. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72529. /**
  72530. * Not supported by GPUParticleSystem
  72531. * @param gradient defines the gradient to remove
  72532. * @returns the current particle system
  72533. */
  72534. removeStartSizeGradient(gradient: number): IParticleSystem;
  72535. /**
  72536. * Not supported by GPUParticleSystem
  72537. * @param gradient defines the gradient to use (between 0 and 1)
  72538. * @param min defines the color remap minimal range
  72539. * @param max defines the color remap maximal range
  72540. * @returns the current particle system
  72541. */
  72542. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72543. /**
  72544. * Not supported by GPUParticleSystem
  72545. * @param gradient defines the gradient to remove
  72546. * @returns the current particle system
  72547. */
  72548. removeColorRemapGradient(): IParticleSystem;
  72549. /**
  72550. * Not supported by GPUParticleSystem
  72551. * @param gradient defines the gradient to use (between 0 and 1)
  72552. * @param min defines the alpha remap minimal range
  72553. * @param max defines the alpha remap maximal range
  72554. * @returns the current particle system
  72555. */
  72556. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72557. /**
  72558. * Not supported by GPUParticleSystem
  72559. * @param gradient defines the gradient to remove
  72560. * @returns the current particle system
  72561. */
  72562. removeAlphaRemapGradient(): IParticleSystem;
  72563. /**
  72564. * Not supported by GPUParticleSystem
  72565. * @param gradient defines the gradient to use (between 0 and 1)
  72566. * @param color defines the color to affect to the specified gradient
  72567. * @returns the current particle system
  72568. */
  72569. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72570. /**
  72571. * Not supported by GPUParticleSystem
  72572. * @param gradient defines the gradient to remove
  72573. * @returns the current particle system
  72574. */
  72575. removeRampGradient(): IParticleSystem;
  72576. /**
  72577. * Not supported by GPUParticleSystem
  72578. * @returns the list of ramp gradients
  72579. */
  72580. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72581. /**
  72582. * Not supported by GPUParticleSystem
  72583. * Gets or sets a boolean indicating that ramp gradients must be used
  72584. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72585. */
  72586. get useRampGradients(): boolean;
  72587. set useRampGradients(value: boolean);
  72588. /**
  72589. * Not supported by GPUParticleSystem
  72590. * @param gradient defines the gradient to use (between 0 and 1)
  72591. * @param factor defines the life time factor to affect to the specified gradient
  72592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72593. * @returns the current particle system
  72594. */
  72595. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72596. /**
  72597. * Not supported by GPUParticleSystem
  72598. * @param gradient defines the gradient to remove
  72599. * @returns the current particle system
  72600. */
  72601. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72602. /**
  72603. * Instantiates a GPU particle system.
  72604. * 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.
  72605. * @param name The name of the particle system
  72606. * @param options The options used to create the system
  72607. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72609. * @param customEffect a custom effect used to change the way particles are rendered by default
  72610. */
  72611. constructor(name: string, options: Partial<{
  72612. capacity: number;
  72613. randomTextureSize: number;
  72614. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72615. protected _reset(): void;
  72616. private _createUpdateVAO;
  72617. private _createRenderVAO;
  72618. private _initialize;
  72619. /** @hidden */
  72620. _recreateUpdateEffect(): void;
  72621. private _getEffect;
  72622. /**
  72623. * Fill the defines array according to the current settings of the particle system
  72624. * @param defines Array to be updated
  72625. * @param blendMode blend mode to take into account when updating the array
  72626. */
  72627. fillDefines(defines: Array<string>, blendMode?: number): void;
  72628. /**
  72629. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72630. * @param uniforms Uniforms array to fill
  72631. * @param attributes Attributes array to fill
  72632. * @param samplers Samplers array to fill
  72633. */
  72634. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72635. /** @hidden */
  72636. _recreateRenderEffect(): Effect;
  72637. /**
  72638. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72639. * @param preWarm defines if we are in the pre-warmimg phase
  72640. */
  72641. animate(preWarm?: boolean): void;
  72642. private _createFactorGradientTexture;
  72643. private _createSizeGradientTexture;
  72644. private _createAngularSpeedGradientTexture;
  72645. private _createVelocityGradientTexture;
  72646. private _createLimitVelocityGradientTexture;
  72647. private _createDragGradientTexture;
  72648. private _createColorGradientTexture;
  72649. /**
  72650. * Renders the particle system in its current state
  72651. * @param preWarm defines if the system should only update the particles but not render them
  72652. * @returns the current number of particles
  72653. */
  72654. render(preWarm?: boolean): number;
  72655. /**
  72656. * Rebuilds the particle system
  72657. */
  72658. rebuild(): void;
  72659. private _releaseBuffers;
  72660. private _releaseVAOs;
  72661. /**
  72662. * Disposes the particle system and free the associated resources
  72663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72664. */
  72665. dispose(disposeTexture?: boolean): void;
  72666. /**
  72667. * Clones the particle system.
  72668. * @param name The name of the cloned object
  72669. * @param newEmitter The new emitter to use
  72670. * @returns the cloned particle system
  72671. */
  72672. clone(name: string, newEmitter: any): GPUParticleSystem;
  72673. /**
  72674. * Serializes the particle system to a JSON object
  72675. * @param serializeTexture defines if the texture must be serialized as well
  72676. * @returns the JSON object
  72677. */
  72678. serialize(serializeTexture?: boolean): any;
  72679. /**
  72680. * Parses a JSON object to create a GPU particle system.
  72681. * @param parsedParticleSystem The JSON object to parse
  72682. * @param sceneOrEngine The scene or the engine to create the particle system in
  72683. * @param rootUrl The root url to use to load external dependencies like texture
  72684. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72685. * @returns the parsed GPU particle system
  72686. */
  72687. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72688. }
  72689. }
  72690. declare module BABYLON {
  72691. /**
  72692. * Represents a set of particle systems working together to create a specific effect
  72693. */
  72694. export class ParticleSystemSet implements IDisposable {
  72695. /**
  72696. * Gets or sets base Assets URL
  72697. */
  72698. static BaseAssetsUrl: string;
  72699. private _emitterCreationOptions;
  72700. private _emitterNode;
  72701. /**
  72702. * Gets the particle system list
  72703. */
  72704. systems: IParticleSystem[];
  72705. /**
  72706. * Gets the emitter node used with this set
  72707. */
  72708. get emitterNode(): Nullable<TransformNode>;
  72709. /**
  72710. * Creates a new emitter mesh as a sphere
  72711. * @param options defines the options used to create the sphere
  72712. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72713. * @param scene defines the hosting scene
  72714. */
  72715. setEmitterAsSphere(options: {
  72716. diameter: number;
  72717. segments: number;
  72718. color: Color3;
  72719. }, renderingGroupId: number, scene: Scene): void;
  72720. /**
  72721. * Starts all particle systems of the set
  72722. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72723. */
  72724. start(emitter?: AbstractMesh): void;
  72725. /**
  72726. * Release all associated resources
  72727. */
  72728. dispose(): void;
  72729. /**
  72730. * Serialize the set into a JSON compatible object
  72731. * @param serializeTexture defines if the texture must be serialized as well
  72732. * @returns a JSON compatible representation of the set
  72733. */
  72734. serialize(serializeTexture?: boolean): any;
  72735. /**
  72736. * Parse a new ParticleSystemSet from a serialized source
  72737. * @param data defines a JSON compatible representation of the set
  72738. * @param scene defines the hosting scene
  72739. * @param gpu defines if we want GPU particles or CPU particles
  72740. * @returns a new ParticleSystemSet
  72741. */
  72742. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72743. }
  72744. }
  72745. declare module BABYLON {
  72746. /**
  72747. * This class is made for on one-liner static method to help creating particle system set.
  72748. */
  72749. export class ParticleHelper {
  72750. /**
  72751. * Gets or sets base Assets URL
  72752. */
  72753. static BaseAssetsUrl: string;
  72754. /** Define the Url to load snippets */
  72755. static SnippetUrl: string;
  72756. /**
  72757. * Create a default particle system that you can tweak
  72758. * @param emitter defines the emitter to use
  72759. * @param capacity defines the system capacity (default is 500 particles)
  72760. * @param scene defines the hosting scene
  72761. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72762. * @returns the new Particle system
  72763. */
  72764. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72765. /**
  72766. * This is the main static method (one-liner) of this helper to create different particle systems
  72767. * @param type This string represents the type to the particle system to create
  72768. * @param scene The scene where the particle system should live
  72769. * @param gpu If the system will use gpu
  72770. * @returns the ParticleSystemSet created
  72771. */
  72772. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72773. /**
  72774. * Static function used to export a particle system to a ParticleSystemSet variable.
  72775. * Please note that the emitter shape is not exported
  72776. * @param systems defines the particle systems to export
  72777. * @returns the created particle system set
  72778. */
  72779. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72780. /**
  72781. * Creates a particle system from a snippet saved in a remote file
  72782. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72783. * @param url defines the url to load from
  72784. * @param scene defines the hosting scene
  72785. * @param gpu If the system will use gpu
  72786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72787. * @returns a promise that will resolve to the new particle system
  72788. */
  72789. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72790. /**
  72791. * Creates a particle system from a snippet saved by the particle system editor
  72792. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72793. * @param scene defines the hosting scene
  72794. * @param gpu If the system will use gpu
  72795. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72796. * @returns a promise that will resolve to the new particle system
  72797. */
  72798. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72799. }
  72800. }
  72801. declare module BABYLON {
  72802. interface Engine {
  72803. /**
  72804. * Create an effect to use with particle systems.
  72805. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72806. * the particle system for which you want to create a custom effect in the last parameter
  72807. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72808. * @param uniformsNames defines a list of attribute names
  72809. * @param samplers defines an array of string used to represent textures
  72810. * @param defines defines the string containing the defines to use to compile the shaders
  72811. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72812. * @param onCompiled defines a function to call when the effect creation is successful
  72813. * @param onError defines a function to call when the effect creation has failed
  72814. * @param particleSystem the particle system you want to create the effect for
  72815. * @returns the new Effect
  72816. */
  72817. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72818. }
  72819. interface Mesh {
  72820. /**
  72821. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72822. * @returns an array of IParticleSystem
  72823. */
  72824. getEmittedParticleSystems(): IParticleSystem[];
  72825. /**
  72826. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72827. * @returns an array of IParticleSystem
  72828. */
  72829. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72830. }
  72831. }
  72832. declare module BABYLON {
  72833. /** Defines the 4 color options */
  72834. export enum PointColor {
  72835. /** color value */
  72836. Color = 2,
  72837. /** uv value */
  72838. UV = 1,
  72839. /** random value */
  72840. Random = 0,
  72841. /** stated value */
  72842. Stated = 3
  72843. }
  72844. /**
  72845. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72846. * 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.
  72847. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72848. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72849. *
  72850. * Full documentation here : TO BE ENTERED
  72851. */
  72852. export class PointsCloudSystem implements IDisposable {
  72853. /**
  72854. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72855. * Example : var p = SPS.particles[i];
  72856. */
  72857. particles: CloudPoint[];
  72858. /**
  72859. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72860. */
  72861. nbParticles: number;
  72862. /**
  72863. * This a counter for your own usage. It's not set by any SPS functions.
  72864. */
  72865. counter: number;
  72866. /**
  72867. * The PCS name. This name is also given to the underlying mesh.
  72868. */
  72869. name: string;
  72870. /**
  72871. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  72872. */
  72873. mesh: Mesh;
  72874. /**
  72875. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72876. * Please read :
  72877. */
  72878. vars: any;
  72879. /**
  72880. * @hidden
  72881. */
  72882. _size: number;
  72883. private _scene;
  72884. private _promises;
  72885. private _positions;
  72886. private _indices;
  72887. private _normals;
  72888. private _colors;
  72889. private _uvs;
  72890. private _indices32;
  72891. private _positions32;
  72892. private _colors32;
  72893. private _uvs32;
  72894. private _updatable;
  72895. private _isVisibilityBoxLocked;
  72896. private _alwaysVisible;
  72897. private _groups;
  72898. private _groupCounter;
  72899. private _computeParticleColor;
  72900. private _computeParticleTexture;
  72901. private _computeParticleRotation;
  72902. private _computeBoundingBox;
  72903. private _isReady;
  72904. /**
  72905. * Creates a PCS (Points Cloud System) object
  72906. * @param name (String) is the PCS name, this will be the underlying mesh name
  72907. * @param pointSize (number) is the size for each point
  72908. * @param scene (Scene) is the scene in which the PCS is added
  72909. * @param options defines the options of the PCS e.g.
  72910. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72911. */
  72912. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72913. updatable?: boolean;
  72914. });
  72915. /**
  72916. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72917. * If no points were added to the PCS, the returned mesh is just a single point.
  72918. * @returns a promise for the created mesh
  72919. */
  72920. buildMeshAsync(): Promise<Mesh>;
  72921. /**
  72922. * @hidden
  72923. */
  72924. private _buildMesh;
  72925. private _addParticle;
  72926. private _randomUnitVector;
  72927. private _getColorIndicesForCoord;
  72928. private _setPointsColorOrUV;
  72929. private _colorFromTexture;
  72930. private _calculateDensity;
  72931. /**
  72932. * Adds points to the PCS in random positions within a unit sphere
  72933. * @param nb (positive integer) the number of particles to be created from this model
  72934. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72935. * @returns the number of groups in the system
  72936. */
  72937. addPoints(nb: number, pointFunction?: any): number;
  72938. /**
  72939. * Adds points to the PCS from the surface of the model shape
  72940. * @param mesh is any Mesh object that will be used as a surface model for the points
  72941. * @param nb (positive integer) the number of particles to be created from this model
  72942. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72943. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72944. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72945. * @returns the number of groups in the system
  72946. */
  72947. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72948. /**
  72949. * Adds points to the PCS inside the model shape
  72950. * @param mesh is any Mesh object that will be used as a surface model for the points
  72951. * @param nb (positive integer) the number of particles to be created from this model
  72952. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72953. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72954. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72955. * @returns the number of groups in the system
  72956. */
  72957. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72958. /**
  72959. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72960. * This method calls `updateParticle()` for each particle of the SPS.
  72961. * For an animated SPS, it is usually called within the render loop.
  72962. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72963. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72964. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72965. * @returns the PCS.
  72966. */
  72967. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72968. /**
  72969. * Disposes the PCS.
  72970. */
  72971. dispose(): void;
  72972. /**
  72973. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  72974. * doc :
  72975. * @returns the PCS.
  72976. */
  72977. refreshVisibleSize(): PointsCloudSystem;
  72978. /**
  72979. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72980. * @param size the size (float) of the visibility box
  72981. * note : this doesn't lock the PCS mesh bounding box.
  72982. * doc :
  72983. */
  72984. setVisibilityBox(size: number): void;
  72985. /**
  72986. * Gets whether the PCS is always visible or not
  72987. * doc :
  72988. */
  72989. get isAlwaysVisible(): boolean;
  72990. /**
  72991. * Sets the PCS as always visible or not
  72992. * doc :
  72993. */
  72994. set isAlwaysVisible(val: boolean);
  72995. /**
  72996. * Tells to `setParticles()` to compute the particle rotations or not
  72997. * Default value : false. The PCS is faster when it's set to false
  72998. * Note : particle rotations are only applied to parent particles
  72999. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73000. */
  73001. set computeParticleRotation(val: boolean);
  73002. /**
  73003. * Tells to `setParticles()` to compute the particle colors or not.
  73004. * Default value : true. The PCS is faster when it's set to false.
  73005. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73006. */
  73007. set computeParticleColor(val: boolean);
  73008. set computeParticleTexture(val: boolean);
  73009. /**
  73010. * Gets if `setParticles()` computes the particle colors or not.
  73011. * Default value : false. The PCS is faster when it's set to false.
  73012. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73013. */
  73014. get computeParticleColor(): boolean;
  73015. /**
  73016. * Gets if `setParticles()` computes the particle textures or not.
  73017. * Default value : false. The PCS is faster when it's set to false.
  73018. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73019. */
  73020. get computeParticleTexture(): boolean;
  73021. /**
  73022. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73023. */
  73024. set computeBoundingBox(val: boolean);
  73025. /**
  73026. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73027. */
  73028. get computeBoundingBox(): boolean;
  73029. /**
  73030. * This function does nothing. It may be overwritten to set all the particle first values.
  73031. * The PCS doesn't call this function, you may have to call it by your own.
  73032. * doc :
  73033. */
  73034. initParticles(): void;
  73035. /**
  73036. * This function does nothing. It may be overwritten to recycle a particle
  73037. * The PCS doesn't call this function, you can to call it
  73038. * doc :
  73039. * @param particle The particle to recycle
  73040. * @returns the recycled particle
  73041. */
  73042. recycleParticle(particle: CloudPoint): CloudPoint;
  73043. /**
  73044. * Updates a particle : this function should be overwritten by the user.
  73045. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73046. * doc :
  73047. * @example : just set a particle position or velocity and recycle conditions
  73048. * @param particle The particle to update
  73049. * @returns the updated particle
  73050. */
  73051. updateParticle(particle: CloudPoint): CloudPoint;
  73052. /**
  73053. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73054. * This does nothing and may be overwritten by the user.
  73055. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73056. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73057. * @param update the boolean update value actually passed to setParticles()
  73058. */
  73059. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73060. /**
  73061. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73062. * This will be passed three parameters.
  73063. * This does nothing and may be overwritten by the user.
  73064. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73065. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73066. * @param update the boolean update value actually passed to setParticles()
  73067. */
  73068. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73069. }
  73070. }
  73071. declare module BABYLON {
  73072. /**
  73073. * Represents one particle of a points cloud system.
  73074. */
  73075. export class CloudPoint {
  73076. /**
  73077. * particle global index
  73078. */
  73079. idx: number;
  73080. /**
  73081. * The color of the particle
  73082. */
  73083. color: Nullable<Color4>;
  73084. /**
  73085. * The world space position of the particle.
  73086. */
  73087. position: Vector3;
  73088. /**
  73089. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73090. */
  73091. rotation: Vector3;
  73092. /**
  73093. * The world space rotation quaternion of the particle.
  73094. */
  73095. rotationQuaternion: Nullable<Quaternion>;
  73096. /**
  73097. * The uv of the particle.
  73098. */
  73099. uv: Nullable<Vector2>;
  73100. /**
  73101. * The current speed of the particle.
  73102. */
  73103. velocity: Vector3;
  73104. /**
  73105. * The pivot point in the particle local space.
  73106. */
  73107. pivot: Vector3;
  73108. /**
  73109. * Must the particle be translated from its pivot point in its local space ?
  73110. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73111. * Default : false
  73112. */
  73113. translateFromPivot: boolean;
  73114. /**
  73115. * Index of this particle in the global "positions" array (Internal use)
  73116. * @hidden
  73117. */
  73118. _pos: number;
  73119. /**
  73120. * @hidden Index of this particle in the global "indices" array (Internal use)
  73121. */
  73122. _ind: number;
  73123. /**
  73124. * Group this particle belongs to
  73125. */
  73126. _group: PointsGroup;
  73127. /**
  73128. * Group id of this particle
  73129. */
  73130. groupId: number;
  73131. /**
  73132. * Index of the particle in its group id (Internal use)
  73133. */
  73134. idxInGroup: number;
  73135. /**
  73136. * @hidden Particle BoundingInfo object (Internal use)
  73137. */
  73138. _boundingInfo: BoundingInfo;
  73139. /**
  73140. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73141. */
  73142. _pcs: PointsCloudSystem;
  73143. /**
  73144. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73145. */
  73146. _stillInvisible: boolean;
  73147. /**
  73148. * @hidden Last computed particle rotation matrix
  73149. */
  73150. _rotationMatrix: number[];
  73151. /**
  73152. * Parent particle Id, if any.
  73153. * Default null.
  73154. */
  73155. parentId: Nullable<number>;
  73156. /**
  73157. * @hidden Internal global position in the PCS.
  73158. */
  73159. _globalPosition: Vector3;
  73160. /**
  73161. * Creates a Point Cloud object.
  73162. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73163. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73164. * @param group (PointsGroup) is the group the particle belongs to
  73165. * @param groupId (integer) is the group identifier in the PCS.
  73166. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73167. * @param pcs defines the PCS it is associated to
  73168. */
  73169. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73170. /**
  73171. * get point size
  73172. */
  73173. get size(): Vector3;
  73174. /**
  73175. * Set point size
  73176. */
  73177. set size(scale: Vector3);
  73178. /**
  73179. * Legacy support, changed quaternion to rotationQuaternion
  73180. */
  73181. get quaternion(): Nullable<Quaternion>;
  73182. /**
  73183. * Legacy support, changed quaternion to rotationQuaternion
  73184. */
  73185. set quaternion(q: Nullable<Quaternion>);
  73186. /**
  73187. * Returns a boolean. True if the particle intersects a mesh, else false
  73188. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73189. * @param target is the object (point or mesh) what the intersection is computed against
  73190. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73191. * @returns true if it intersects
  73192. */
  73193. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73194. /**
  73195. * get the rotation matrix of the particle
  73196. * @hidden
  73197. */
  73198. getRotationMatrix(m: Matrix): void;
  73199. }
  73200. /**
  73201. * Represents a group of points in a points cloud system
  73202. * * PCS internal tool, don't use it manually.
  73203. */
  73204. export class PointsGroup {
  73205. /**
  73206. * The group id
  73207. * @hidden
  73208. */
  73209. groupID: number;
  73210. /**
  73211. * image data for group (internal use)
  73212. * @hidden
  73213. */
  73214. _groupImageData: Nullable<ArrayBufferView>;
  73215. /**
  73216. * Image Width (internal use)
  73217. * @hidden
  73218. */
  73219. _groupImgWidth: number;
  73220. /**
  73221. * Image Height (internal use)
  73222. * @hidden
  73223. */
  73224. _groupImgHeight: number;
  73225. /**
  73226. * Custom position function (internal use)
  73227. * @hidden
  73228. */
  73229. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73230. /**
  73231. * density per facet for surface points
  73232. * @hidden
  73233. */
  73234. _groupDensity: number[];
  73235. /**
  73236. * Only when points are colored by texture carries pointer to texture list array
  73237. * @hidden
  73238. */
  73239. _textureNb: number;
  73240. /**
  73241. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73242. * PCS internal tool, don't use it manually.
  73243. * @hidden
  73244. */
  73245. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73246. }
  73247. }
  73248. declare module BABYLON {
  73249. interface Scene {
  73250. /** @hidden (Backing field) */
  73251. _physicsEngine: Nullable<IPhysicsEngine>;
  73252. /** @hidden */
  73253. _physicsTimeAccumulator: number;
  73254. /**
  73255. * Gets the current physics engine
  73256. * @returns a IPhysicsEngine or null if none attached
  73257. */
  73258. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73259. /**
  73260. * Enables physics to the current scene
  73261. * @param gravity defines the scene's gravity for the physics engine
  73262. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73263. * @return a boolean indicating if the physics engine was initialized
  73264. */
  73265. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73266. /**
  73267. * Disables and disposes the physics engine associated with the scene
  73268. */
  73269. disablePhysicsEngine(): void;
  73270. /**
  73271. * Gets a boolean indicating if there is an active physics engine
  73272. * @returns a boolean indicating if there is an active physics engine
  73273. */
  73274. isPhysicsEnabled(): boolean;
  73275. /**
  73276. * Deletes a physics compound impostor
  73277. * @param compound defines the compound to delete
  73278. */
  73279. deleteCompoundImpostor(compound: any): void;
  73280. /**
  73281. * An event triggered when physic simulation is about to be run
  73282. */
  73283. onBeforePhysicsObservable: Observable<Scene>;
  73284. /**
  73285. * An event triggered when physic simulation has been done
  73286. */
  73287. onAfterPhysicsObservable: Observable<Scene>;
  73288. }
  73289. interface AbstractMesh {
  73290. /** @hidden */
  73291. _physicsImpostor: Nullable<PhysicsImpostor>;
  73292. /**
  73293. * Gets or sets impostor used for physic simulation
  73294. * @see https://doc.babylonjs.com/features/physics_engine
  73295. */
  73296. physicsImpostor: Nullable<PhysicsImpostor>;
  73297. /**
  73298. * Gets the current physics impostor
  73299. * @see https://doc.babylonjs.com/features/physics_engine
  73300. * @returns a physics impostor or null
  73301. */
  73302. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73303. /** Apply a physic impulse to the mesh
  73304. * @param force defines the force to apply
  73305. * @param contactPoint defines where to apply the force
  73306. * @returns the current mesh
  73307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73308. */
  73309. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73310. /**
  73311. * Creates a physic joint between two meshes
  73312. * @param otherMesh defines the other mesh to use
  73313. * @param pivot1 defines the pivot to use on this mesh
  73314. * @param pivot2 defines the pivot to use on the other mesh
  73315. * @param options defines additional options (can be plugin dependent)
  73316. * @returns the current mesh
  73317. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73318. */
  73319. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73320. /** @hidden */
  73321. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73322. }
  73323. /**
  73324. * Defines the physics engine scene component responsible to manage a physics engine
  73325. */
  73326. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73327. /**
  73328. * The component name helpful to identify the component in the list of scene components.
  73329. */
  73330. readonly name: string;
  73331. /**
  73332. * The scene the component belongs to.
  73333. */
  73334. scene: Scene;
  73335. /**
  73336. * Creates a new instance of the component for the given scene
  73337. * @param scene Defines the scene to register the component in
  73338. */
  73339. constructor(scene: Scene);
  73340. /**
  73341. * Registers the component in a given scene
  73342. */
  73343. register(): void;
  73344. /**
  73345. * Rebuilds the elements related to this component in case of
  73346. * context lost for instance.
  73347. */
  73348. rebuild(): void;
  73349. /**
  73350. * Disposes the component and the associated resources
  73351. */
  73352. dispose(): void;
  73353. }
  73354. }
  73355. declare module BABYLON {
  73356. /**
  73357. * A helper for physics simulations
  73358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73359. */
  73360. export class PhysicsHelper {
  73361. private _scene;
  73362. private _physicsEngine;
  73363. /**
  73364. * Initializes the Physics helper
  73365. * @param scene Babylon.js scene
  73366. */
  73367. constructor(scene: Scene);
  73368. /**
  73369. * Applies a radial explosion impulse
  73370. * @param origin the origin of the explosion
  73371. * @param radiusOrEventOptions the radius or the options of radial explosion
  73372. * @param strength the explosion strength
  73373. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73374. * @returns A physics radial explosion event, or null
  73375. */
  73376. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73377. /**
  73378. * Applies a radial explosion force
  73379. * @param origin the origin of the explosion
  73380. * @param radiusOrEventOptions the radius or the options of radial explosion
  73381. * @param strength the explosion strength
  73382. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73383. * @returns A physics radial explosion event, or null
  73384. */
  73385. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73386. /**
  73387. * Creates a gravitational field
  73388. * @param origin the origin of the explosion
  73389. * @param radiusOrEventOptions the radius or the options of radial explosion
  73390. * @param strength the explosion strength
  73391. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73392. * @returns A physics gravitational field event, or null
  73393. */
  73394. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73395. /**
  73396. * Creates a physics updraft event
  73397. * @param origin the origin of the updraft
  73398. * @param radiusOrEventOptions the radius or the options of the updraft
  73399. * @param strength the strength of the updraft
  73400. * @param height the height of the updraft
  73401. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73402. * @returns A physics updraft event, or null
  73403. */
  73404. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73405. /**
  73406. * Creates a physics vortex event
  73407. * @param origin the of the vortex
  73408. * @param radiusOrEventOptions the radius or the options of the vortex
  73409. * @param strength the strength of the vortex
  73410. * @param height the height of the vortex
  73411. * @returns a Physics vortex event, or null
  73412. * A physics vortex event or null
  73413. */
  73414. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73415. }
  73416. /**
  73417. * Represents a physics radial explosion event
  73418. */
  73419. class PhysicsRadialExplosionEvent {
  73420. private _scene;
  73421. private _options;
  73422. private _sphere;
  73423. private _dataFetched;
  73424. /**
  73425. * Initializes a radial explosion event
  73426. * @param _scene BabylonJS scene
  73427. * @param _options The options for the vortex event
  73428. */
  73429. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73430. /**
  73431. * Returns the data related to the radial explosion event (sphere).
  73432. * @returns The radial explosion event data
  73433. */
  73434. getData(): PhysicsRadialExplosionEventData;
  73435. /**
  73436. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73437. * @param impostor A physics imposter
  73438. * @param origin the origin of the explosion
  73439. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73440. */
  73441. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73442. /**
  73443. * Triggers affected impostors callbacks
  73444. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73445. */
  73446. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73447. /**
  73448. * Disposes the sphere.
  73449. * @param force Specifies if the sphere should be disposed by force
  73450. */
  73451. dispose(force?: boolean): void;
  73452. /*** Helpers ***/
  73453. private _prepareSphere;
  73454. private _intersectsWithSphere;
  73455. }
  73456. /**
  73457. * Represents a gravitational field event
  73458. */
  73459. class PhysicsGravitationalFieldEvent {
  73460. private _physicsHelper;
  73461. private _scene;
  73462. private _origin;
  73463. private _options;
  73464. private _tickCallback;
  73465. private _sphere;
  73466. private _dataFetched;
  73467. /**
  73468. * Initializes the physics gravitational field event
  73469. * @param _physicsHelper A physics helper
  73470. * @param _scene BabylonJS scene
  73471. * @param _origin The origin position of the gravitational field event
  73472. * @param _options The options for the vortex event
  73473. */
  73474. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73475. /**
  73476. * Returns the data related to the gravitational field event (sphere).
  73477. * @returns A gravitational field event
  73478. */
  73479. getData(): PhysicsGravitationalFieldEventData;
  73480. /**
  73481. * Enables the gravitational field.
  73482. */
  73483. enable(): void;
  73484. /**
  73485. * Disables the gravitational field.
  73486. */
  73487. disable(): void;
  73488. /**
  73489. * Disposes the sphere.
  73490. * @param force The force to dispose from the gravitational field event
  73491. */
  73492. dispose(force?: boolean): void;
  73493. private _tick;
  73494. }
  73495. /**
  73496. * Represents a physics updraft event
  73497. */
  73498. class PhysicsUpdraftEvent {
  73499. private _scene;
  73500. private _origin;
  73501. private _options;
  73502. private _physicsEngine;
  73503. private _originTop;
  73504. private _originDirection;
  73505. private _tickCallback;
  73506. private _cylinder;
  73507. private _cylinderPosition;
  73508. private _dataFetched;
  73509. /**
  73510. * Initializes the physics updraft event
  73511. * @param _scene BabylonJS scene
  73512. * @param _origin The origin position of the updraft
  73513. * @param _options The options for the updraft event
  73514. */
  73515. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73516. /**
  73517. * Returns the data related to the updraft event (cylinder).
  73518. * @returns A physics updraft event
  73519. */
  73520. getData(): PhysicsUpdraftEventData;
  73521. /**
  73522. * Enables the updraft.
  73523. */
  73524. enable(): void;
  73525. /**
  73526. * Disables the updraft.
  73527. */
  73528. disable(): void;
  73529. /**
  73530. * Disposes the cylinder.
  73531. * @param force Specifies if the updraft should be disposed by force
  73532. */
  73533. dispose(force?: boolean): void;
  73534. private getImpostorHitData;
  73535. private _tick;
  73536. /*** Helpers ***/
  73537. private _prepareCylinder;
  73538. private _intersectsWithCylinder;
  73539. }
  73540. /**
  73541. * Represents a physics vortex event
  73542. */
  73543. class PhysicsVortexEvent {
  73544. private _scene;
  73545. private _origin;
  73546. private _options;
  73547. private _physicsEngine;
  73548. private _originTop;
  73549. private _tickCallback;
  73550. private _cylinder;
  73551. private _cylinderPosition;
  73552. private _dataFetched;
  73553. /**
  73554. * Initializes the physics vortex event
  73555. * @param _scene The BabylonJS scene
  73556. * @param _origin The origin position of the vortex
  73557. * @param _options The options for the vortex event
  73558. */
  73559. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73560. /**
  73561. * Returns the data related to the vortex event (cylinder).
  73562. * @returns The physics vortex event data
  73563. */
  73564. getData(): PhysicsVortexEventData;
  73565. /**
  73566. * Enables the vortex.
  73567. */
  73568. enable(): void;
  73569. /**
  73570. * Disables the cortex.
  73571. */
  73572. disable(): void;
  73573. /**
  73574. * Disposes the sphere.
  73575. * @param force
  73576. */
  73577. dispose(force?: boolean): void;
  73578. private getImpostorHitData;
  73579. private _tick;
  73580. /*** Helpers ***/
  73581. private _prepareCylinder;
  73582. private _intersectsWithCylinder;
  73583. }
  73584. /**
  73585. * Options fot the radial explosion event
  73586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73587. */
  73588. export class PhysicsRadialExplosionEventOptions {
  73589. /**
  73590. * The radius of the sphere for the radial explosion.
  73591. */
  73592. radius: number;
  73593. /**
  73594. * The strength of the explosion.
  73595. */
  73596. strength: number;
  73597. /**
  73598. * The strength of the force in correspondence to the distance of the affected object
  73599. */
  73600. falloff: PhysicsRadialImpulseFalloff;
  73601. /**
  73602. * Sphere options for the radial explosion.
  73603. */
  73604. sphere: {
  73605. segments: number;
  73606. diameter: number;
  73607. };
  73608. /**
  73609. * Sphere options for the radial explosion.
  73610. */
  73611. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73612. }
  73613. /**
  73614. * Options fot the updraft event
  73615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73616. */
  73617. export class PhysicsUpdraftEventOptions {
  73618. /**
  73619. * The radius of the cylinder for the vortex
  73620. */
  73621. radius: number;
  73622. /**
  73623. * The strength of the updraft.
  73624. */
  73625. strength: number;
  73626. /**
  73627. * The height of the cylinder for the updraft.
  73628. */
  73629. height: number;
  73630. /**
  73631. * The mode for the the updraft.
  73632. */
  73633. updraftMode: PhysicsUpdraftMode;
  73634. }
  73635. /**
  73636. * Options fot the vortex event
  73637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73638. */
  73639. export class PhysicsVortexEventOptions {
  73640. /**
  73641. * The radius of the cylinder for the vortex
  73642. */
  73643. radius: number;
  73644. /**
  73645. * The strength of the vortex.
  73646. */
  73647. strength: number;
  73648. /**
  73649. * The height of the cylinder for the vortex.
  73650. */
  73651. height: number;
  73652. /**
  73653. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73654. */
  73655. centripetalForceThreshold: number;
  73656. /**
  73657. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73658. */
  73659. centripetalForceMultiplier: number;
  73660. /**
  73661. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73662. */
  73663. centrifugalForceMultiplier: number;
  73664. /**
  73665. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73666. */
  73667. updraftForceMultiplier: number;
  73668. }
  73669. /**
  73670. * The strength of the force in correspondence to the distance of the affected object
  73671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73672. */
  73673. export enum PhysicsRadialImpulseFalloff {
  73674. /** Defines that impulse is constant in strength across it's whole radius */
  73675. Constant = 0,
  73676. /** Defines that impulse gets weaker if it's further from the origin */
  73677. Linear = 1
  73678. }
  73679. /**
  73680. * The strength of the force in correspondence to the distance of the affected object
  73681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73682. */
  73683. export enum PhysicsUpdraftMode {
  73684. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73685. Center = 0,
  73686. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73687. Perpendicular = 1
  73688. }
  73689. /**
  73690. * Interface for a physics hit data
  73691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73692. */
  73693. export interface PhysicsHitData {
  73694. /**
  73695. * The force applied at the contact point
  73696. */
  73697. force: Vector3;
  73698. /**
  73699. * The contact point
  73700. */
  73701. contactPoint: Vector3;
  73702. /**
  73703. * The distance from the origin to the contact point
  73704. */
  73705. distanceFromOrigin: number;
  73706. }
  73707. /**
  73708. * Interface for radial explosion event data
  73709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73710. */
  73711. export interface PhysicsRadialExplosionEventData {
  73712. /**
  73713. * A sphere used for the radial explosion event
  73714. */
  73715. sphere: Mesh;
  73716. }
  73717. /**
  73718. * Interface for gravitational field event data
  73719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73720. */
  73721. export interface PhysicsGravitationalFieldEventData {
  73722. /**
  73723. * A sphere mesh used for the gravitational field event
  73724. */
  73725. sphere: Mesh;
  73726. }
  73727. /**
  73728. * Interface for updraft event data
  73729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73730. */
  73731. export interface PhysicsUpdraftEventData {
  73732. /**
  73733. * A cylinder used for the updraft event
  73734. */
  73735. cylinder: Mesh;
  73736. }
  73737. /**
  73738. * Interface for vortex event data
  73739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73740. */
  73741. export interface PhysicsVortexEventData {
  73742. /**
  73743. * A cylinder used for the vortex event
  73744. */
  73745. cylinder: Mesh;
  73746. }
  73747. /**
  73748. * Interface for an affected physics impostor
  73749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73750. */
  73751. export interface PhysicsAffectedImpostorWithData {
  73752. /**
  73753. * The impostor affected by the effect
  73754. */
  73755. impostor: PhysicsImpostor;
  73756. /**
  73757. * The data about the hit/force from the explosion
  73758. */
  73759. hitData: PhysicsHitData;
  73760. }
  73761. }
  73762. declare module BABYLON {
  73763. /** @hidden */
  73764. export var blackAndWhitePixelShader: {
  73765. name: string;
  73766. shader: string;
  73767. };
  73768. }
  73769. declare module BABYLON {
  73770. /**
  73771. * Post process used to render in black and white
  73772. */
  73773. export class BlackAndWhitePostProcess extends PostProcess {
  73774. /**
  73775. * Linear about to convert he result to black and white (default: 1)
  73776. */
  73777. degree: number;
  73778. /**
  73779. * Gets a string identifying the name of the class
  73780. * @returns "BlackAndWhitePostProcess" string
  73781. */
  73782. getClassName(): string;
  73783. /**
  73784. * Creates a black and white post process
  73785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73786. * @param name The name of the effect.
  73787. * @param options The required width/height ratio to downsize to before computing the render pass.
  73788. * @param camera The camera to apply the render pass to.
  73789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73790. * @param engine The engine which the post process will be applied. (default: current engine)
  73791. * @param reusable If the post process can be reused on the same frame. (default: false)
  73792. */
  73793. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73794. /** @hidden */
  73795. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73796. }
  73797. }
  73798. declare module BABYLON {
  73799. /**
  73800. * This represents a set of one or more post processes in Babylon.
  73801. * A post process can be used to apply a shader to a texture after it is rendered.
  73802. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73803. */
  73804. export class PostProcessRenderEffect {
  73805. private _postProcesses;
  73806. private _getPostProcesses;
  73807. private _singleInstance;
  73808. private _cameras;
  73809. private _indicesForCamera;
  73810. /**
  73811. * Name of the effect
  73812. * @hidden
  73813. */
  73814. _name: string;
  73815. /**
  73816. * Instantiates a post process render effect.
  73817. * A post process can be used to apply a shader to a texture after it is rendered.
  73818. * @param engine The engine the effect is tied to
  73819. * @param name The name of the effect
  73820. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73821. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73822. */
  73823. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73824. /**
  73825. * Checks if all the post processes in the effect are supported.
  73826. */
  73827. get isSupported(): boolean;
  73828. /**
  73829. * Updates the current state of the effect
  73830. * @hidden
  73831. */
  73832. _update(): void;
  73833. /**
  73834. * Attaches the effect on cameras
  73835. * @param cameras The camera to attach to.
  73836. * @hidden
  73837. */
  73838. _attachCameras(cameras: Camera): void;
  73839. /**
  73840. * Attaches the effect on cameras
  73841. * @param cameras The camera to attach to.
  73842. * @hidden
  73843. */
  73844. _attachCameras(cameras: Camera[]): void;
  73845. /**
  73846. * Detaches the effect on cameras
  73847. * @param cameras The camera to detach from.
  73848. * @hidden
  73849. */
  73850. _detachCameras(cameras: Camera): void;
  73851. /**
  73852. * Detaches the effect on cameras
  73853. * @param cameras The camera to detach from.
  73854. * @hidden
  73855. */
  73856. _detachCameras(cameras: Camera[]): void;
  73857. /**
  73858. * Enables the effect on given cameras
  73859. * @param cameras The camera to enable.
  73860. * @hidden
  73861. */
  73862. _enable(cameras: Camera): void;
  73863. /**
  73864. * Enables the effect on given cameras
  73865. * @param cameras The camera to enable.
  73866. * @hidden
  73867. */
  73868. _enable(cameras: Nullable<Camera[]>): void;
  73869. /**
  73870. * Disables the effect on the given cameras
  73871. * @param cameras The camera to disable.
  73872. * @hidden
  73873. */
  73874. _disable(cameras: Camera): void;
  73875. /**
  73876. * Disables the effect on the given cameras
  73877. * @param cameras The camera to disable.
  73878. * @hidden
  73879. */
  73880. _disable(cameras: Nullable<Camera[]>): void;
  73881. /**
  73882. * Gets a list of the post processes contained in the effect.
  73883. * @param camera The camera to get the post processes on.
  73884. * @returns The list of the post processes in the effect.
  73885. */
  73886. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73887. }
  73888. }
  73889. declare module BABYLON {
  73890. /** @hidden */
  73891. export var extractHighlightsPixelShader: {
  73892. name: string;
  73893. shader: string;
  73894. };
  73895. }
  73896. declare module BABYLON {
  73897. /**
  73898. * 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.
  73899. */
  73900. export class ExtractHighlightsPostProcess extends PostProcess {
  73901. /**
  73902. * The luminance threshold, pixels below this value will be set to black.
  73903. */
  73904. threshold: number;
  73905. /** @hidden */
  73906. _exposure: number;
  73907. /**
  73908. * Post process which has the input texture to be used when performing highlight extraction
  73909. * @hidden
  73910. */
  73911. _inputPostProcess: Nullable<PostProcess>;
  73912. /**
  73913. * Gets a string identifying the name of the class
  73914. * @returns "ExtractHighlightsPostProcess" string
  73915. */
  73916. getClassName(): string;
  73917. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73918. }
  73919. }
  73920. declare module BABYLON {
  73921. /** @hidden */
  73922. export var bloomMergePixelShader: {
  73923. name: string;
  73924. shader: string;
  73925. };
  73926. }
  73927. declare module BABYLON {
  73928. /**
  73929. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73930. */
  73931. export class BloomMergePostProcess extends PostProcess {
  73932. /** Weight of the bloom to be added to the original input. */
  73933. weight: number;
  73934. /**
  73935. * Gets a string identifying the name of the class
  73936. * @returns "BloomMergePostProcess" string
  73937. */
  73938. getClassName(): string;
  73939. /**
  73940. * Creates a new instance of @see BloomMergePostProcess
  73941. * @param name The name of the effect.
  73942. * @param originalFromInput Post process which's input will be used for the merge.
  73943. * @param blurred Blurred highlights post process which's output will be used.
  73944. * @param weight Weight of the bloom to be added to the original input.
  73945. * @param options The required width/height ratio to downsize to before computing the render pass.
  73946. * @param camera The camera to apply the render pass to.
  73947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73948. * @param engine The engine which the post process will be applied. (default: current engine)
  73949. * @param reusable If the post process can be reused on the same frame. (default: false)
  73950. * @param textureType Type of textures used when performing the post process. (default: 0)
  73951. * @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)
  73952. */
  73953. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73954. /** Weight of the bloom to be added to the original input. */
  73955. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73956. }
  73957. }
  73958. declare module BABYLON {
  73959. /**
  73960. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73961. */
  73962. export class BloomEffect extends PostProcessRenderEffect {
  73963. private bloomScale;
  73964. /**
  73965. * @hidden Internal
  73966. */
  73967. _effects: Array<PostProcess>;
  73968. /**
  73969. * @hidden Internal
  73970. */
  73971. _downscale: ExtractHighlightsPostProcess;
  73972. private _blurX;
  73973. private _blurY;
  73974. private _merge;
  73975. /**
  73976. * The luminance threshold to find bright areas of the image to bloom.
  73977. */
  73978. get threshold(): number;
  73979. set threshold(value: number);
  73980. /**
  73981. * The strength of the bloom.
  73982. */
  73983. get weight(): number;
  73984. set weight(value: number);
  73985. /**
  73986. * Specifies the size of the bloom blur kernel, relative to the final output size
  73987. */
  73988. get kernel(): number;
  73989. set kernel(value: number);
  73990. /**
  73991. * Creates a new instance of @see BloomEffect
  73992. * @param scene The scene the effect belongs to.
  73993. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73994. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73995. * @param bloomWeight The the strength of bloom.
  73996. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73997. * @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)
  73998. */
  73999. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74000. /**
  74001. * Disposes each of the internal effects for a given camera.
  74002. * @param camera The camera to dispose the effect on.
  74003. */
  74004. disposeEffects(camera: Camera): void;
  74005. /**
  74006. * @hidden Internal
  74007. */
  74008. _updateEffects(): void;
  74009. /**
  74010. * Internal
  74011. * @returns if all the contained post processes are ready.
  74012. * @hidden
  74013. */
  74014. _isReady(): boolean;
  74015. }
  74016. }
  74017. declare module BABYLON {
  74018. /** @hidden */
  74019. export var chromaticAberrationPixelShader: {
  74020. name: string;
  74021. shader: string;
  74022. };
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74027. */
  74028. export class ChromaticAberrationPostProcess extends PostProcess {
  74029. /**
  74030. * The amount of separation of rgb channels (default: 30)
  74031. */
  74032. aberrationAmount: number;
  74033. /**
  74034. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74035. */
  74036. radialIntensity: number;
  74037. /**
  74038. * 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))
  74039. */
  74040. direction: Vector2;
  74041. /**
  74042. * 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))
  74043. */
  74044. centerPosition: Vector2;
  74045. /** The width of the screen to apply the effect on */
  74046. screenWidth: number;
  74047. /** The height of the screen to apply the effect on */
  74048. screenHeight: number;
  74049. /**
  74050. * Gets a string identifying the name of the class
  74051. * @returns "ChromaticAberrationPostProcess" string
  74052. */
  74053. getClassName(): string;
  74054. /**
  74055. * Creates a new instance ChromaticAberrationPostProcess
  74056. * @param name The name of the effect.
  74057. * @param screenWidth The width of the screen to apply the effect on.
  74058. * @param screenHeight The height of the screen to apply the effect on.
  74059. * @param options The required width/height ratio to downsize to before computing the render pass.
  74060. * @param camera The camera to apply the render pass to.
  74061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74062. * @param engine The engine which the post process will be applied. (default: current engine)
  74063. * @param reusable If the post process can be reused on the same frame. (default: false)
  74064. * @param textureType Type of textures used when performing the post process. (default: 0)
  74065. * @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)
  74066. */
  74067. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74068. /** @hidden */
  74069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. /** @hidden */
  74074. export var circleOfConfusionPixelShader: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module BABYLON {
  74080. /**
  74081. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74082. */
  74083. export class CircleOfConfusionPostProcess extends PostProcess {
  74084. /**
  74085. * 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.
  74086. */
  74087. lensSize: number;
  74088. /**
  74089. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74090. */
  74091. fStop: number;
  74092. /**
  74093. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74094. */
  74095. focusDistance: number;
  74096. /**
  74097. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74098. */
  74099. focalLength: number;
  74100. /**
  74101. * Gets a string identifying the name of the class
  74102. * @returns "CircleOfConfusionPostProcess" string
  74103. */
  74104. getClassName(): string;
  74105. private _depthTexture;
  74106. /**
  74107. * Creates a new instance CircleOfConfusionPostProcess
  74108. * @param name The name of the effect.
  74109. * @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.
  74110. * @param options The required width/height ratio to downsize to before computing the render pass.
  74111. * @param camera The camera to apply the render pass to.
  74112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74113. * @param engine The engine which the post process will be applied. (default: current engine)
  74114. * @param reusable If the post process can be reused on the same frame. (default: false)
  74115. * @param textureType Type of textures used when performing the post process. (default: 0)
  74116. * @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)
  74117. */
  74118. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74119. /**
  74120. * 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.
  74121. */
  74122. set depthTexture(value: RenderTargetTexture);
  74123. }
  74124. }
  74125. declare module BABYLON {
  74126. /** @hidden */
  74127. export var colorCorrectionPixelShader: {
  74128. name: string;
  74129. shader: string;
  74130. };
  74131. }
  74132. declare module BABYLON {
  74133. /**
  74134. *
  74135. * This post-process allows the modification of rendered colors by using
  74136. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74137. *
  74138. * The object needs to be provided an url to a texture containing the color
  74139. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74140. * Use an image editing software to tweak the LUT to match your needs.
  74141. *
  74142. * For an example of a color LUT, see here:
  74143. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74144. * For explanations on color grading, see here:
  74145. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74146. *
  74147. */
  74148. export class ColorCorrectionPostProcess extends PostProcess {
  74149. private _colorTableTexture;
  74150. /**
  74151. * Gets the color table url used to create the LUT texture
  74152. */
  74153. colorTableUrl: string;
  74154. /**
  74155. * Gets a string identifying the name of the class
  74156. * @returns "ColorCorrectionPostProcess" string
  74157. */
  74158. getClassName(): string;
  74159. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74160. /** @hidden */
  74161. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74162. }
  74163. }
  74164. declare module BABYLON {
  74165. /** @hidden */
  74166. export var convolutionPixelShader: {
  74167. name: string;
  74168. shader: string;
  74169. };
  74170. }
  74171. declare module BABYLON {
  74172. /**
  74173. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74174. * input texture to perform effects such as edge detection or sharpening
  74175. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74176. */
  74177. export class ConvolutionPostProcess extends PostProcess {
  74178. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74179. kernel: number[];
  74180. /**
  74181. * Gets a string identifying the name of the class
  74182. * @returns "ConvolutionPostProcess" string
  74183. */
  74184. getClassName(): string;
  74185. /**
  74186. * Creates a new instance ConvolutionPostProcess
  74187. * @param name The name of the effect.
  74188. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74189. * @param options The required width/height ratio to downsize to before computing the render pass.
  74190. * @param camera The camera to apply the render pass to.
  74191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74192. * @param engine The engine which the post process will be applied. (default: current engine)
  74193. * @param reusable If the post process can be reused on the same frame. (default: false)
  74194. * @param textureType Type of textures used when performing the post process. (default: 0)
  74195. */
  74196. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74197. /** @hidden */
  74198. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74199. /**
  74200. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74201. */
  74202. static EdgeDetect0Kernel: number[];
  74203. /**
  74204. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74205. */
  74206. static EdgeDetect1Kernel: number[];
  74207. /**
  74208. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74209. */
  74210. static EdgeDetect2Kernel: number[];
  74211. /**
  74212. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74213. */
  74214. static SharpenKernel: number[];
  74215. /**
  74216. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74217. */
  74218. static EmbossKernel: number[];
  74219. /**
  74220. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74221. */
  74222. static GaussianKernel: number[];
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /**
  74227. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74228. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74229. * based on samples that have a large difference in distance than the center pixel.
  74230. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74231. */
  74232. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74233. /**
  74234. * The direction the blur should be applied
  74235. */
  74236. direction: Vector2;
  74237. /**
  74238. * Gets a string identifying the name of the class
  74239. * @returns "DepthOfFieldBlurPostProcess" string
  74240. */
  74241. getClassName(): string;
  74242. /**
  74243. * Creates a new instance CircleOfConfusionPostProcess
  74244. * @param name The name of the effect.
  74245. * @param scene The scene the effect belongs to.
  74246. * @param direction The direction the blur should be applied.
  74247. * @param kernel The size of the kernel used to blur.
  74248. * @param options The required width/height ratio to downsize to before computing the render pass.
  74249. * @param camera The camera to apply the render pass to.
  74250. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74251. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74253. * @param engine The engine which the post process will be applied. (default: current engine)
  74254. * @param reusable If the post process can be reused on the same frame. (default: false)
  74255. * @param textureType Type of textures used when performing the post process. (default: 0)
  74256. * @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)
  74257. */
  74258. 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);
  74259. }
  74260. }
  74261. declare module BABYLON {
  74262. /** @hidden */
  74263. export var depthOfFieldMergePixelShader: {
  74264. name: string;
  74265. shader: string;
  74266. };
  74267. }
  74268. declare module BABYLON {
  74269. /**
  74270. * Options to be set when merging outputs from the default pipeline.
  74271. */
  74272. export class DepthOfFieldMergePostProcessOptions {
  74273. /**
  74274. * The original image to merge on top of
  74275. */
  74276. originalFromInput: PostProcess;
  74277. /**
  74278. * Parameters to perform the merge of the depth of field effect
  74279. */
  74280. depthOfField?: {
  74281. circleOfConfusion: PostProcess;
  74282. blurSteps: Array<PostProcess>;
  74283. };
  74284. /**
  74285. * Parameters to perform the merge of bloom effect
  74286. */
  74287. bloom?: {
  74288. blurred: PostProcess;
  74289. weight: number;
  74290. };
  74291. }
  74292. /**
  74293. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74294. */
  74295. export class DepthOfFieldMergePostProcess extends PostProcess {
  74296. private blurSteps;
  74297. /**
  74298. * Gets a string identifying the name of the class
  74299. * @returns "DepthOfFieldMergePostProcess" string
  74300. */
  74301. getClassName(): string;
  74302. /**
  74303. * Creates a new instance of DepthOfFieldMergePostProcess
  74304. * @param name The name of the effect.
  74305. * @param originalFromInput Post process which's input will be used for the merge.
  74306. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74307. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74308. * @param options The required width/height ratio to downsize to before computing the render pass.
  74309. * @param camera The camera to apply the render pass to.
  74310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74311. * @param engine The engine which the post process will be applied. (default: current engine)
  74312. * @param reusable If the post process can be reused on the same frame. (default: false)
  74313. * @param textureType Type of textures used when performing the post process. (default: 0)
  74314. * @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)
  74315. */
  74316. 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);
  74317. /**
  74318. * Updates the effect with the current post process compile time values and recompiles the shader.
  74319. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74320. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74321. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74322. * @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
  74323. * @param onCompiled Called when the shader has been compiled.
  74324. * @param onError Called if there is an error when compiling a shader.
  74325. */
  74326. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74327. }
  74328. }
  74329. declare module BABYLON {
  74330. /**
  74331. * Specifies the level of max blur that should be applied when using the depth of field effect
  74332. */
  74333. export enum DepthOfFieldEffectBlurLevel {
  74334. /**
  74335. * Subtle blur
  74336. */
  74337. Low = 0,
  74338. /**
  74339. * Medium blur
  74340. */
  74341. Medium = 1,
  74342. /**
  74343. * Large blur
  74344. */
  74345. High = 2
  74346. }
  74347. /**
  74348. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74349. */
  74350. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74351. private _circleOfConfusion;
  74352. /**
  74353. * @hidden Internal, blurs from high to low
  74354. */
  74355. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74356. private _depthOfFieldBlurY;
  74357. private _dofMerge;
  74358. /**
  74359. * @hidden Internal post processes in depth of field effect
  74360. */
  74361. _effects: Array<PostProcess>;
  74362. /**
  74363. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74364. */
  74365. set focalLength(value: number);
  74366. get focalLength(): number;
  74367. /**
  74368. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74369. */
  74370. set fStop(value: number);
  74371. get fStop(): number;
  74372. /**
  74373. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74374. */
  74375. set focusDistance(value: number);
  74376. get focusDistance(): number;
  74377. /**
  74378. * 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.
  74379. */
  74380. set lensSize(value: number);
  74381. get lensSize(): number;
  74382. /**
  74383. * Creates a new instance DepthOfFieldEffect
  74384. * @param scene The scene the effect belongs to.
  74385. * @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.
  74386. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74387. * @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)
  74388. */
  74389. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74390. /**
  74391. * Get the current class name of the current effect
  74392. * @returns "DepthOfFieldEffect"
  74393. */
  74394. getClassName(): string;
  74395. /**
  74396. * 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.
  74397. */
  74398. set depthTexture(value: RenderTargetTexture);
  74399. /**
  74400. * Disposes each of the internal effects for a given camera.
  74401. * @param camera The camera to dispose the effect on.
  74402. */
  74403. disposeEffects(camera: Camera): void;
  74404. /**
  74405. * @hidden Internal
  74406. */
  74407. _updateEffects(): void;
  74408. /**
  74409. * Internal
  74410. * @returns if all the contained post processes are ready.
  74411. * @hidden
  74412. */
  74413. _isReady(): boolean;
  74414. }
  74415. }
  74416. declare module BABYLON {
  74417. /** @hidden */
  74418. export var displayPassPixelShader: {
  74419. name: string;
  74420. shader: string;
  74421. };
  74422. }
  74423. declare module BABYLON {
  74424. /**
  74425. * DisplayPassPostProcess which produces an output the same as it's input
  74426. */
  74427. export class DisplayPassPostProcess extends PostProcess {
  74428. /**
  74429. * Gets a string identifying the name of the class
  74430. * @returns "DisplayPassPostProcess" string
  74431. */
  74432. getClassName(): string;
  74433. /**
  74434. * Creates the DisplayPassPostProcess
  74435. * @param name The name of the effect.
  74436. * @param options The required width/height ratio to downsize to before computing the render pass.
  74437. * @param camera The camera to apply the render pass to.
  74438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74439. * @param engine The engine which the post process will be applied. (default: current engine)
  74440. * @param reusable If the post process can be reused on the same frame. (default: false)
  74441. */
  74442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74443. /** @hidden */
  74444. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /** @hidden */
  74449. export var filterPixelShader: {
  74450. name: string;
  74451. shader: string;
  74452. };
  74453. }
  74454. declare module BABYLON {
  74455. /**
  74456. * Applies a kernel filter to the image
  74457. */
  74458. export class FilterPostProcess extends PostProcess {
  74459. /** The matrix to be applied to the image */
  74460. kernelMatrix: Matrix;
  74461. /**
  74462. * Gets a string identifying the name of the class
  74463. * @returns "FilterPostProcess" string
  74464. */
  74465. getClassName(): string;
  74466. /**
  74467. *
  74468. * @param name The name of the effect.
  74469. * @param kernelMatrix The matrix to be applied to the image
  74470. * @param options The required width/height ratio to downsize to before computing the render pass.
  74471. * @param camera The camera to apply the render pass to.
  74472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74473. * @param engine The engine which the post process will be applied. (default: current engine)
  74474. * @param reusable If the post process can be reused on the same frame. (default: false)
  74475. */
  74476. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74477. /** @hidden */
  74478. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74479. }
  74480. }
  74481. declare module BABYLON {
  74482. /** @hidden */
  74483. export var fxaaPixelShader: {
  74484. name: string;
  74485. shader: string;
  74486. };
  74487. }
  74488. declare module BABYLON {
  74489. /** @hidden */
  74490. export var fxaaVertexShader: {
  74491. name: string;
  74492. shader: string;
  74493. };
  74494. }
  74495. declare module BABYLON {
  74496. /**
  74497. * Fxaa post process
  74498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74499. */
  74500. export class FxaaPostProcess extends PostProcess {
  74501. /**
  74502. * Gets a string identifying the name of the class
  74503. * @returns "FxaaPostProcess" string
  74504. */
  74505. getClassName(): string;
  74506. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74507. private _getDefines;
  74508. /** @hidden */
  74509. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74510. }
  74511. }
  74512. declare module BABYLON {
  74513. /** @hidden */
  74514. export var grainPixelShader: {
  74515. name: string;
  74516. shader: string;
  74517. };
  74518. }
  74519. declare module BABYLON {
  74520. /**
  74521. * The GrainPostProcess adds noise to the image at mid luminance levels
  74522. */
  74523. export class GrainPostProcess extends PostProcess {
  74524. /**
  74525. * The intensity of the grain added (default: 30)
  74526. */
  74527. intensity: number;
  74528. /**
  74529. * If the grain should be randomized on every frame
  74530. */
  74531. animated: boolean;
  74532. /**
  74533. * Gets a string identifying the name of the class
  74534. * @returns "GrainPostProcess" string
  74535. */
  74536. getClassName(): string;
  74537. /**
  74538. * Creates a new instance of @see GrainPostProcess
  74539. * @param name The name of the effect.
  74540. * @param options The required width/height ratio to downsize to before computing the render pass.
  74541. * @param camera The camera to apply the render pass to.
  74542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74543. * @param engine The engine which the post process will be applied. (default: current engine)
  74544. * @param reusable If the post process can be reused on the same frame. (default: false)
  74545. * @param textureType Type of textures used when performing the post process. (default: 0)
  74546. * @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)
  74547. */
  74548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74549. /** @hidden */
  74550. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74551. }
  74552. }
  74553. declare module BABYLON {
  74554. /** @hidden */
  74555. export var highlightsPixelShader: {
  74556. name: string;
  74557. shader: string;
  74558. };
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * Extracts highlights from the image
  74563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74564. */
  74565. export class HighlightsPostProcess extends PostProcess {
  74566. /**
  74567. * Gets a string identifying the name of the class
  74568. * @returns "HighlightsPostProcess" string
  74569. */
  74570. getClassName(): string;
  74571. /**
  74572. * Extracts highlights from the image
  74573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74574. * @param name The name of the effect.
  74575. * @param options The required width/height ratio to downsize to before computing the render pass.
  74576. * @param camera The camera to apply the render pass to.
  74577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74578. * @param engine The engine which the post process will be applied. (default: current engine)
  74579. * @param reusable If the post process can be reused on the same frame. (default: false)
  74580. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74581. */
  74582. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74583. }
  74584. }
  74585. declare module BABYLON {
  74586. /**
  74587. * Contains all parameters needed for the prepass to perform
  74588. * motion blur
  74589. */
  74590. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74591. /**
  74592. * Is motion blur enabled
  74593. */
  74594. enabled: boolean;
  74595. /**
  74596. * Name of the configuration
  74597. */
  74598. name: string;
  74599. /**
  74600. * Textures that should be present in the MRT for this effect to work
  74601. */
  74602. readonly texturesRequired: number[];
  74603. }
  74604. }
  74605. declare module BABYLON {
  74606. interface Scene {
  74607. /** @hidden (Backing field) */
  74608. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74609. /**
  74610. * Gets or Sets the current geometry buffer associated to the scene.
  74611. */
  74612. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74613. /**
  74614. * Enables a GeometryBufferRender and associates it with the scene
  74615. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74616. * @returns the GeometryBufferRenderer
  74617. */
  74618. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74619. /**
  74620. * Disables the GeometryBufferRender associated with the scene
  74621. */
  74622. disableGeometryBufferRenderer(): void;
  74623. }
  74624. /**
  74625. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74626. * in several rendering techniques.
  74627. */
  74628. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74629. /**
  74630. * The component name helpful to identify the component in the list of scene components.
  74631. */
  74632. readonly name: string;
  74633. /**
  74634. * The scene the component belongs to.
  74635. */
  74636. scene: Scene;
  74637. /**
  74638. * Creates a new instance of the component for the given scene
  74639. * @param scene Defines the scene to register the component in
  74640. */
  74641. constructor(scene: Scene);
  74642. /**
  74643. * Registers the component in a given scene
  74644. */
  74645. register(): void;
  74646. /**
  74647. * Rebuilds the elements related to this component in case of
  74648. * context lost for instance.
  74649. */
  74650. rebuild(): void;
  74651. /**
  74652. * Disposes the component and the associated resources
  74653. */
  74654. dispose(): void;
  74655. private _gatherRenderTargets;
  74656. }
  74657. }
  74658. declare module BABYLON {
  74659. /** @hidden */
  74660. export var motionBlurPixelShader: {
  74661. name: string;
  74662. shader: string;
  74663. };
  74664. }
  74665. declare module BABYLON {
  74666. /**
  74667. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74668. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74669. * As an example, all you have to do is to create the post-process:
  74670. * var mb = new BABYLON.MotionBlurPostProcess(
  74671. * 'mb', // The name of the effect.
  74672. * scene, // The scene containing the objects to blur according to their velocity.
  74673. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74674. * camera // The camera to apply the render pass to.
  74675. * );
  74676. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74677. */
  74678. export class MotionBlurPostProcess extends PostProcess {
  74679. /**
  74680. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74681. */
  74682. motionStrength: number;
  74683. /**
  74684. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74685. */
  74686. get motionBlurSamples(): number;
  74687. /**
  74688. * Sets the number of iterations to be used for motion blur quality
  74689. */
  74690. set motionBlurSamples(samples: number);
  74691. private _motionBlurSamples;
  74692. /**
  74693. * Gets whether or not the motion blur post-process is in object based mode.
  74694. */
  74695. get isObjectBased(): boolean;
  74696. /**
  74697. * Sets whether or not the motion blur post-process is in object based mode.
  74698. */
  74699. set isObjectBased(value: boolean);
  74700. private _isObjectBased;
  74701. private _forceGeometryBuffer;
  74702. private _geometryBufferRenderer;
  74703. private _prePassRenderer;
  74704. private _invViewProjection;
  74705. private _previousViewProjection;
  74706. /**
  74707. * Gets a string identifying the name of the class
  74708. * @returns "MotionBlurPostProcess" string
  74709. */
  74710. getClassName(): string;
  74711. /**
  74712. * Creates a new instance MotionBlurPostProcess
  74713. * @param name The name of the effect.
  74714. * @param scene The scene containing the objects to blur according to their velocity.
  74715. * @param options The required width/height ratio to downsize to before computing the render pass.
  74716. * @param camera The camera to apply the render pass to.
  74717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74718. * @param engine The engine which the post process will be applied. (default: current engine)
  74719. * @param reusable If the post process can be reused on the same frame. (default: false)
  74720. * @param textureType Type of textures used when performing the post process. (default: 0)
  74721. * @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)
  74722. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74723. */
  74724. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74725. /**
  74726. * Excludes the given skinned mesh from computing bones velocities.
  74727. * 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.
  74728. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74729. */
  74730. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74731. /**
  74732. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74733. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74734. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74735. */
  74736. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74737. /**
  74738. * Disposes the post process.
  74739. * @param camera The camera to dispose the post process on.
  74740. */
  74741. dispose(camera?: Camera): void;
  74742. /**
  74743. * Called on the mode changed (object based or screen based).
  74744. */
  74745. private _applyMode;
  74746. /**
  74747. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74748. */
  74749. private _onApplyObjectBased;
  74750. /**
  74751. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74752. */
  74753. private _onApplyScreenBased;
  74754. /**
  74755. * Called on the effect must be updated (changed mode, samples count, etc.).
  74756. */
  74757. private _updateEffect;
  74758. /** @hidden */
  74759. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74760. }
  74761. }
  74762. declare module BABYLON {
  74763. /** @hidden */
  74764. export var refractionPixelShader: {
  74765. name: string;
  74766. shader: string;
  74767. };
  74768. }
  74769. declare module BABYLON {
  74770. /**
  74771. * Post process which applies a refraction texture
  74772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74773. */
  74774. export class RefractionPostProcess extends PostProcess {
  74775. private _refTexture;
  74776. private _ownRefractionTexture;
  74777. /** the base color of the refraction (used to taint the rendering) */
  74778. color: Color3;
  74779. /** simulated refraction depth */
  74780. depth: number;
  74781. /** the coefficient of the base color (0 to remove base color tainting) */
  74782. colorLevel: number;
  74783. /** Gets the url used to load the refraction texture */
  74784. refractionTextureUrl: string;
  74785. /**
  74786. * Gets or sets the refraction texture
  74787. * Please note that you are responsible for disposing the texture if you set it manually
  74788. */
  74789. get refractionTexture(): Texture;
  74790. set refractionTexture(value: Texture);
  74791. /**
  74792. * Gets a string identifying the name of the class
  74793. * @returns "RefractionPostProcess" string
  74794. */
  74795. getClassName(): string;
  74796. /**
  74797. * Initializes the RefractionPostProcess
  74798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74799. * @param name The name of the effect.
  74800. * @param refractionTextureUrl Url of the refraction texture to use
  74801. * @param color the base color of the refraction (used to taint the rendering)
  74802. * @param depth simulated refraction depth
  74803. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74804. * @param camera The camera to apply the render pass to.
  74805. * @param options The required width/height ratio to downsize to before computing the render pass.
  74806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74807. * @param engine The engine which the post process will be applied. (default: current engine)
  74808. * @param reusable If the post process can be reused on the same frame. (default: false)
  74809. */
  74810. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74811. /**
  74812. * Disposes of the post process
  74813. * @param camera Camera to dispose post process on
  74814. */
  74815. dispose(camera: Camera): void;
  74816. /** @hidden */
  74817. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74818. }
  74819. }
  74820. declare module BABYLON {
  74821. /** @hidden */
  74822. export var sharpenPixelShader: {
  74823. name: string;
  74824. shader: string;
  74825. };
  74826. }
  74827. declare module BABYLON {
  74828. /**
  74829. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74830. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74831. */
  74832. export class SharpenPostProcess extends PostProcess {
  74833. /**
  74834. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74835. */
  74836. colorAmount: number;
  74837. /**
  74838. * How much sharpness should be applied (default: 0.3)
  74839. */
  74840. edgeAmount: number;
  74841. /**
  74842. * Gets a string identifying the name of the class
  74843. * @returns "SharpenPostProcess" string
  74844. */
  74845. getClassName(): string;
  74846. /**
  74847. * Creates a new instance ConvolutionPostProcess
  74848. * @param name The name of the effect.
  74849. * @param options The required width/height ratio to downsize to before computing the render pass.
  74850. * @param camera The camera to apply the render pass to.
  74851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74852. * @param engine The engine which the post process will be applied. (default: current engine)
  74853. * @param reusable If the post process can be reused on the same frame. (default: false)
  74854. * @param textureType Type of textures used when performing the post process. (default: 0)
  74855. * @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)
  74856. */
  74857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74858. /** @hidden */
  74859. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * PostProcessRenderPipeline
  74865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74866. */
  74867. export class PostProcessRenderPipeline {
  74868. private engine;
  74869. private _renderEffects;
  74870. private _renderEffectsForIsolatedPass;
  74871. /**
  74872. * List of inspectable custom properties (used by the Inspector)
  74873. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74874. */
  74875. inspectableCustomProperties: IInspectable[];
  74876. /**
  74877. * @hidden
  74878. */
  74879. protected _cameras: Camera[];
  74880. /** @hidden */
  74881. _name: string;
  74882. /**
  74883. * Gets pipeline name
  74884. */
  74885. get name(): string;
  74886. /** Gets the list of attached cameras */
  74887. get cameras(): Camera[];
  74888. /**
  74889. * Initializes a PostProcessRenderPipeline
  74890. * @param engine engine to add the pipeline to
  74891. * @param name name of the pipeline
  74892. */
  74893. constructor(engine: Engine, name: string);
  74894. /**
  74895. * Gets the class name
  74896. * @returns "PostProcessRenderPipeline"
  74897. */
  74898. getClassName(): string;
  74899. /**
  74900. * If all the render effects in the pipeline are supported
  74901. */
  74902. get isSupported(): boolean;
  74903. /**
  74904. * Adds an effect to the pipeline
  74905. * @param renderEffect the effect to add
  74906. */
  74907. addEffect(renderEffect: PostProcessRenderEffect): void;
  74908. /** @hidden */
  74909. _rebuild(): void;
  74910. /** @hidden */
  74911. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74912. /** @hidden */
  74913. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74914. /** @hidden */
  74915. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74916. /** @hidden */
  74917. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74918. /** @hidden */
  74919. _attachCameras(cameras: Camera, unique: boolean): void;
  74920. /** @hidden */
  74921. _attachCameras(cameras: Camera[], unique: boolean): void;
  74922. /** @hidden */
  74923. _detachCameras(cameras: Camera): void;
  74924. /** @hidden */
  74925. _detachCameras(cameras: Nullable<Camera[]>): void;
  74926. /** @hidden */
  74927. _update(): void;
  74928. /** @hidden */
  74929. _reset(): void;
  74930. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74931. /**
  74932. * Sets the required values to the prepass renderer.
  74933. * @param prePassRenderer defines the prepass renderer to setup.
  74934. * @returns true if the pre pass is needed.
  74935. */
  74936. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74937. /**
  74938. * Disposes of the pipeline
  74939. */
  74940. dispose(): void;
  74941. }
  74942. }
  74943. declare module BABYLON {
  74944. /**
  74945. * PostProcessRenderPipelineManager class
  74946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74947. */
  74948. export class PostProcessRenderPipelineManager {
  74949. private _renderPipelines;
  74950. /**
  74951. * Initializes a PostProcessRenderPipelineManager
  74952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74953. */
  74954. constructor();
  74955. /**
  74956. * Gets the list of supported render pipelines
  74957. */
  74958. get supportedPipelines(): PostProcessRenderPipeline[];
  74959. /**
  74960. * Adds a pipeline to the manager
  74961. * @param renderPipeline The pipeline to add
  74962. */
  74963. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74964. /**
  74965. * Attaches a camera to the pipeline
  74966. * @param renderPipelineName The name of the pipeline to attach to
  74967. * @param cameras the camera to attach
  74968. * @param unique if the camera can be attached multiple times to the pipeline
  74969. */
  74970. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74971. /**
  74972. * Detaches a camera from the pipeline
  74973. * @param renderPipelineName The name of the pipeline to detach from
  74974. * @param cameras the camera to detach
  74975. */
  74976. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74977. /**
  74978. * Enables an effect by name on a pipeline
  74979. * @param renderPipelineName the name of the pipeline to enable the effect in
  74980. * @param renderEffectName the name of the effect to enable
  74981. * @param cameras the cameras that the effect should be enabled on
  74982. */
  74983. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74984. /**
  74985. * Disables an effect by name on a pipeline
  74986. * @param renderPipelineName the name of the pipeline to disable the effect in
  74987. * @param renderEffectName the name of the effect to disable
  74988. * @param cameras the cameras that the effect should be disabled on
  74989. */
  74990. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74991. /**
  74992. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74993. */
  74994. update(): void;
  74995. /** @hidden */
  74996. _rebuild(): void;
  74997. /**
  74998. * Disposes of the manager and pipelines
  74999. */
  75000. dispose(): void;
  75001. }
  75002. }
  75003. declare module BABYLON {
  75004. interface Scene {
  75005. /** @hidden (Backing field) */
  75006. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75007. /**
  75008. * Gets the postprocess render pipeline manager
  75009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75010. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75011. */
  75012. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75013. }
  75014. /**
  75015. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75016. */
  75017. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75018. /**
  75019. * The component name helpful to identify the component in the list of scene components.
  75020. */
  75021. readonly name: string;
  75022. /**
  75023. * The scene the component belongs to.
  75024. */
  75025. scene: Scene;
  75026. /**
  75027. * Creates a new instance of the component for the given scene
  75028. * @param scene Defines the scene to register the component in
  75029. */
  75030. constructor(scene: Scene);
  75031. /**
  75032. * Registers the component in a given scene
  75033. */
  75034. register(): void;
  75035. /**
  75036. * Rebuilds the elements related to this component in case of
  75037. * context lost for instance.
  75038. */
  75039. rebuild(): void;
  75040. /**
  75041. * Disposes the component and the associated resources
  75042. */
  75043. dispose(): void;
  75044. private _gatherRenderTargets;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75050. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75051. */
  75052. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75053. private _scene;
  75054. private _camerasToBeAttached;
  75055. /**
  75056. * ID of the sharpen post process,
  75057. */
  75058. private readonly SharpenPostProcessId;
  75059. /**
  75060. * @ignore
  75061. * ID of the image processing post process;
  75062. */
  75063. readonly ImageProcessingPostProcessId: string;
  75064. /**
  75065. * @ignore
  75066. * ID of the Fast Approximate Anti-Aliasing post process;
  75067. */
  75068. readonly FxaaPostProcessId: string;
  75069. /**
  75070. * ID of the chromatic aberration post process,
  75071. */
  75072. private readonly ChromaticAberrationPostProcessId;
  75073. /**
  75074. * ID of the grain post process
  75075. */
  75076. private readonly GrainPostProcessId;
  75077. /**
  75078. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75079. */
  75080. sharpen: SharpenPostProcess;
  75081. private _sharpenEffect;
  75082. private bloom;
  75083. /**
  75084. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75085. */
  75086. depthOfField: DepthOfFieldEffect;
  75087. /**
  75088. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75089. */
  75090. fxaa: FxaaPostProcess;
  75091. /**
  75092. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75093. */
  75094. imageProcessing: ImageProcessingPostProcess;
  75095. /**
  75096. * Chromatic aberration post process which will shift rgb colors in the image
  75097. */
  75098. chromaticAberration: ChromaticAberrationPostProcess;
  75099. private _chromaticAberrationEffect;
  75100. /**
  75101. * Grain post process which add noise to the image
  75102. */
  75103. grain: GrainPostProcess;
  75104. private _grainEffect;
  75105. /**
  75106. * Glow post process which adds a glow to emissive areas of the image
  75107. */
  75108. private _glowLayer;
  75109. /**
  75110. * Animations which can be used to tweak settings over a period of time
  75111. */
  75112. animations: Animation[];
  75113. private _imageProcessingConfigurationObserver;
  75114. private _sharpenEnabled;
  75115. private _bloomEnabled;
  75116. private _depthOfFieldEnabled;
  75117. private _depthOfFieldBlurLevel;
  75118. private _fxaaEnabled;
  75119. private _imageProcessingEnabled;
  75120. private _defaultPipelineTextureType;
  75121. private _bloomScale;
  75122. private _chromaticAberrationEnabled;
  75123. private _grainEnabled;
  75124. private _buildAllowed;
  75125. /**
  75126. * This is triggered each time the pipeline has been built.
  75127. */
  75128. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75129. /**
  75130. * Gets active scene
  75131. */
  75132. get scene(): Scene;
  75133. /**
  75134. * Enable or disable the sharpen process from the pipeline
  75135. */
  75136. set sharpenEnabled(enabled: boolean);
  75137. get sharpenEnabled(): boolean;
  75138. private _resizeObserver;
  75139. private _hardwareScaleLevel;
  75140. private _bloomKernel;
  75141. /**
  75142. * Specifies the size of the bloom blur kernel, relative to the final output size
  75143. */
  75144. get bloomKernel(): number;
  75145. set bloomKernel(value: number);
  75146. /**
  75147. * Specifies the weight of the bloom in the final rendering
  75148. */
  75149. private _bloomWeight;
  75150. /**
  75151. * Specifies the luma threshold for the area that will be blurred by the bloom
  75152. */
  75153. private _bloomThreshold;
  75154. private _hdr;
  75155. /**
  75156. * The strength of the bloom.
  75157. */
  75158. set bloomWeight(value: number);
  75159. get bloomWeight(): number;
  75160. /**
  75161. * The strength of the bloom.
  75162. */
  75163. set bloomThreshold(value: number);
  75164. get bloomThreshold(): number;
  75165. /**
  75166. * The scale of the bloom, lower value will provide better performance.
  75167. */
  75168. set bloomScale(value: number);
  75169. get bloomScale(): number;
  75170. /**
  75171. * Enable or disable the bloom from the pipeline
  75172. */
  75173. set bloomEnabled(enabled: boolean);
  75174. get bloomEnabled(): boolean;
  75175. private _rebuildBloom;
  75176. /**
  75177. * If the depth of field is enabled.
  75178. */
  75179. get depthOfFieldEnabled(): boolean;
  75180. set depthOfFieldEnabled(enabled: boolean);
  75181. /**
  75182. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75183. */
  75184. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75185. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75186. /**
  75187. * If the anti aliasing is enabled.
  75188. */
  75189. set fxaaEnabled(enabled: boolean);
  75190. get fxaaEnabled(): boolean;
  75191. private _samples;
  75192. /**
  75193. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75194. */
  75195. set samples(sampleCount: number);
  75196. get samples(): number;
  75197. /**
  75198. * If image processing is enabled.
  75199. */
  75200. set imageProcessingEnabled(enabled: boolean);
  75201. get imageProcessingEnabled(): boolean;
  75202. /**
  75203. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75204. */
  75205. set glowLayerEnabled(enabled: boolean);
  75206. get glowLayerEnabled(): boolean;
  75207. /**
  75208. * Gets the glow layer (or null if not defined)
  75209. */
  75210. get glowLayer(): Nullable<GlowLayer>;
  75211. /**
  75212. * Enable or disable the chromaticAberration process from the pipeline
  75213. */
  75214. set chromaticAberrationEnabled(enabled: boolean);
  75215. get chromaticAberrationEnabled(): boolean;
  75216. /**
  75217. * Enable or disable the grain process from the pipeline
  75218. */
  75219. set grainEnabled(enabled: boolean);
  75220. get grainEnabled(): boolean;
  75221. /**
  75222. * @constructor
  75223. * @param name - The rendering pipeline name (default: "")
  75224. * @param hdr - If high dynamic range textures should be used (default: true)
  75225. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75226. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75227. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75228. */
  75229. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75230. /**
  75231. * Get the class name
  75232. * @returns "DefaultRenderingPipeline"
  75233. */
  75234. getClassName(): string;
  75235. /**
  75236. * Force the compilation of the entire pipeline.
  75237. */
  75238. prepare(): void;
  75239. private _hasCleared;
  75240. private _prevPostProcess;
  75241. private _prevPrevPostProcess;
  75242. private _setAutoClearAndTextureSharing;
  75243. private _depthOfFieldSceneObserver;
  75244. private _buildPipeline;
  75245. private _disposePostProcesses;
  75246. /**
  75247. * Adds a camera to the pipeline
  75248. * @param camera the camera to be added
  75249. */
  75250. addCamera(camera: Camera): void;
  75251. /**
  75252. * Removes a camera from the pipeline
  75253. * @param camera the camera to remove
  75254. */
  75255. removeCamera(camera: Camera): void;
  75256. /**
  75257. * Dispose of the pipeline and stop all post processes
  75258. */
  75259. dispose(): void;
  75260. /**
  75261. * Serialize the rendering pipeline (Used when exporting)
  75262. * @returns the serialized object
  75263. */
  75264. serialize(): any;
  75265. /**
  75266. * Parse the serialized pipeline
  75267. * @param source Source pipeline.
  75268. * @param scene The scene to load the pipeline to.
  75269. * @param rootUrl The URL of the serialized pipeline.
  75270. * @returns An instantiated pipeline from the serialized object.
  75271. */
  75272. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75273. }
  75274. }
  75275. declare module BABYLON {
  75276. /** @hidden */
  75277. export var lensHighlightsPixelShader: {
  75278. name: string;
  75279. shader: string;
  75280. };
  75281. }
  75282. declare module BABYLON {
  75283. /** @hidden */
  75284. export var depthOfFieldPixelShader: {
  75285. name: string;
  75286. shader: string;
  75287. };
  75288. }
  75289. declare module BABYLON {
  75290. /**
  75291. * BABYLON.JS Chromatic Aberration GLSL Shader
  75292. * Author: Olivier Guyot
  75293. * Separates very slightly R, G and B colors on the edges of the screen
  75294. * Inspired by Francois Tarlier & Martins Upitis
  75295. */
  75296. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75297. /**
  75298. * @ignore
  75299. * The chromatic aberration PostProcess id in the pipeline
  75300. */
  75301. LensChromaticAberrationEffect: string;
  75302. /**
  75303. * @ignore
  75304. * The highlights enhancing PostProcess id in the pipeline
  75305. */
  75306. HighlightsEnhancingEffect: string;
  75307. /**
  75308. * @ignore
  75309. * The depth-of-field PostProcess id in the pipeline
  75310. */
  75311. LensDepthOfFieldEffect: string;
  75312. private _scene;
  75313. private _depthTexture;
  75314. private _grainTexture;
  75315. private _chromaticAberrationPostProcess;
  75316. private _highlightsPostProcess;
  75317. private _depthOfFieldPostProcess;
  75318. private _edgeBlur;
  75319. private _grainAmount;
  75320. private _chromaticAberration;
  75321. private _distortion;
  75322. private _highlightsGain;
  75323. private _highlightsThreshold;
  75324. private _dofDistance;
  75325. private _dofAperture;
  75326. private _dofDarken;
  75327. private _dofPentagon;
  75328. private _blurNoise;
  75329. /**
  75330. * @constructor
  75331. *
  75332. * Effect parameters are as follow:
  75333. * {
  75334. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75335. * edge_blur: number; // from 0 to x (1 for realism)
  75336. * distortion: number; // from 0 to x (1 for realism)
  75337. * grain_amount: number; // from 0 to 1
  75338. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75339. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75340. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75341. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75342. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75343. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75344. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75345. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75346. * }
  75347. * Note: if an effect parameter is unset, effect is disabled
  75348. *
  75349. * @param name The rendering pipeline name
  75350. * @param parameters - An object containing all parameters (see above)
  75351. * @param scene The scene linked to this pipeline
  75352. * @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)
  75353. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75354. */
  75355. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75356. /**
  75357. * Get the class name
  75358. * @returns "LensRenderingPipeline"
  75359. */
  75360. getClassName(): string;
  75361. /**
  75362. * Gets associated scene
  75363. */
  75364. get scene(): Scene;
  75365. /**
  75366. * Gets or sets the edge blur
  75367. */
  75368. get edgeBlur(): number;
  75369. set edgeBlur(value: number);
  75370. /**
  75371. * Gets or sets the grain amount
  75372. */
  75373. get grainAmount(): number;
  75374. set grainAmount(value: number);
  75375. /**
  75376. * Gets or sets the chromatic aberration amount
  75377. */
  75378. get chromaticAberration(): number;
  75379. set chromaticAberration(value: number);
  75380. /**
  75381. * Gets or sets the depth of field aperture
  75382. */
  75383. get dofAperture(): number;
  75384. set dofAperture(value: number);
  75385. /**
  75386. * Gets or sets the edge distortion
  75387. */
  75388. get edgeDistortion(): number;
  75389. set edgeDistortion(value: number);
  75390. /**
  75391. * Gets or sets the depth of field distortion
  75392. */
  75393. get dofDistortion(): number;
  75394. set dofDistortion(value: number);
  75395. /**
  75396. * Gets or sets the darken out of focus amount
  75397. */
  75398. get darkenOutOfFocus(): number;
  75399. set darkenOutOfFocus(value: number);
  75400. /**
  75401. * Gets or sets a boolean indicating if blur noise is enabled
  75402. */
  75403. get blurNoise(): boolean;
  75404. set blurNoise(value: boolean);
  75405. /**
  75406. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75407. */
  75408. get pentagonBokeh(): boolean;
  75409. set pentagonBokeh(value: boolean);
  75410. /**
  75411. * Gets or sets the highlight grain amount
  75412. */
  75413. get highlightsGain(): number;
  75414. set highlightsGain(value: number);
  75415. /**
  75416. * Gets or sets the highlight threshold
  75417. */
  75418. get highlightsThreshold(): number;
  75419. set highlightsThreshold(value: number);
  75420. /**
  75421. * Sets the amount of blur at the edges
  75422. * @param amount blur amount
  75423. */
  75424. setEdgeBlur(amount: number): void;
  75425. /**
  75426. * Sets edge blur to 0
  75427. */
  75428. disableEdgeBlur(): void;
  75429. /**
  75430. * Sets the amount of grain
  75431. * @param amount Amount of grain
  75432. */
  75433. setGrainAmount(amount: number): void;
  75434. /**
  75435. * Set grain amount to 0
  75436. */
  75437. disableGrain(): void;
  75438. /**
  75439. * Sets the chromatic aberration amount
  75440. * @param amount amount of chromatic aberration
  75441. */
  75442. setChromaticAberration(amount: number): void;
  75443. /**
  75444. * Sets chromatic aberration amount to 0
  75445. */
  75446. disableChromaticAberration(): void;
  75447. /**
  75448. * Sets the EdgeDistortion amount
  75449. * @param amount amount of EdgeDistortion
  75450. */
  75451. setEdgeDistortion(amount: number): void;
  75452. /**
  75453. * Sets edge distortion to 0
  75454. */
  75455. disableEdgeDistortion(): void;
  75456. /**
  75457. * Sets the FocusDistance amount
  75458. * @param amount amount of FocusDistance
  75459. */
  75460. setFocusDistance(amount: number): void;
  75461. /**
  75462. * Disables depth of field
  75463. */
  75464. disableDepthOfField(): void;
  75465. /**
  75466. * Sets the Aperture amount
  75467. * @param amount amount of Aperture
  75468. */
  75469. setAperture(amount: number): void;
  75470. /**
  75471. * Sets the DarkenOutOfFocus amount
  75472. * @param amount amount of DarkenOutOfFocus
  75473. */
  75474. setDarkenOutOfFocus(amount: number): void;
  75475. private _pentagonBokehIsEnabled;
  75476. /**
  75477. * Creates a pentagon bokeh effect
  75478. */
  75479. enablePentagonBokeh(): void;
  75480. /**
  75481. * Disables the pentagon bokeh effect
  75482. */
  75483. disablePentagonBokeh(): void;
  75484. /**
  75485. * Enables noise blur
  75486. */
  75487. enableNoiseBlur(): void;
  75488. /**
  75489. * Disables noise blur
  75490. */
  75491. disableNoiseBlur(): void;
  75492. /**
  75493. * Sets the HighlightsGain amount
  75494. * @param amount amount of HighlightsGain
  75495. */
  75496. setHighlightsGain(amount: number): void;
  75497. /**
  75498. * Sets the HighlightsThreshold amount
  75499. * @param amount amount of HighlightsThreshold
  75500. */
  75501. setHighlightsThreshold(amount: number): void;
  75502. /**
  75503. * Disables highlights
  75504. */
  75505. disableHighlights(): void;
  75506. /**
  75507. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75508. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75509. */
  75510. dispose(disableDepthRender?: boolean): void;
  75511. private _createChromaticAberrationPostProcess;
  75512. private _createHighlightsPostProcess;
  75513. private _createDepthOfFieldPostProcess;
  75514. private _createGrainTexture;
  75515. }
  75516. }
  75517. declare module BABYLON {
  75518. /**
  75519. * Contains all parameters needed for the prepass to perform
  75520. * screen space subsurface scattering
  75521. */
  75522. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75523. /**
  75524. * Is subsurface enabled
  75525. */
  75526. enabled: boolean;
  75527. /**
  75528. * Name of the configuration
  75529. */
  75530. name: string;
  75531. /**
  75532. * Textures that should be present in the MRT for this effect to work
  75533. */
  75534. readonly texturesRequired: number[];
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /** @hidden */
  75539. export var ssao2PixelShader: {
  75540. name: string;
  75541. shader: string;
  75542. };
  75543. }
  75544. declare module BABYLON {
  75545. /** @hidden */
  75546. export var ssaoCombinePixelShader: {
  75547. name: string;
  75548. shader: string;
  75549. };
  75550. }
  75551. declare module BABYLON {
  75552. /**
  75553. * Render pipeline to produce ssao effect
  75554. */
  75555. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75556. /**
  75557. * @ignore
  75558. * The PassPostProcess id in the pipeline that contains the original scene color
  75559. */
  75560. SSAOOriginalSceneColorEffect: string;
  75561. /**
  75562. * @ignore
  75563. * The SSAO PostProcess id in the pipeline
  75564. */
  75565. SSAORenderEffect: string;
  75566. /**
  75567. * @ignore
  75568. * The horizontal blur PostProcess id in the pipeline
  75569. */
  75570. SSAOBlurHRenderEffect: string;
  75571. /**
  75572. * @ignore
  75573. * The vertical blur PostProcess id in the pipeline
  75574. */
  75575. SSAOBlurVRenderEffect: string;
  75576. /**
  75577. * @ignore
  75578. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75579. */
  75580. SSAOCombineRenderEffect: string;
  75581. /**
  75582. * The output strength of the SSAO post-process. Default value is 1.0.
  75583. */
  75584. totalStrength: number;
  75585. /**
  75586. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75587. */
  75588. maxZ: number;
  75589. /**
  75590. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75591. */
  75592. minZAspect: number;
  75593. private _samples;
  75594. /**
  75595. * Number of samples used for the SSAO calculations. Default value is 8
  75596. */
  75597. set samples(n: number);
  75598. get samples(): number;
  75599. private _textureSamples;
  75600. /**
  75601. * Number of samples to use for antialiasing
  75602. */
  75603. set textureSamples(n: number);
  75604. get textureSamples(): number;
  75605. /**
  75606. * Force rendering the geometry through geometry buffer
  75607. */
  75608. private _forceGeometryBuffer;
  75609. /**
  75610. * Ratio object used for SSAO ratio and blur ratio
  75611. */
  75612. private _ratio;
  75613. /**
  75614. * Dynamically generated sphere sampler.
  75615. */
  75616. private _sampleSphere;
  75617. /**
  75618. * Blur filter offsets
  75619. */
  75620. private _samplerOffsets;
  75621. private _expensiveBlur;
  75622. /**
  75623. * If bilateral blur should be used
  75624. */
  75625. set expensiveBlur(b: boolean);
  75626. get expensiveBlur(): boolean;
  75627. /**
  75628. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75629. */
  75630. radius: number;
  75631. /**
  75632. * The base color of the SSAO post-process
  75633. * The final result is "base + ssao" between [0, 1]
  75634. */
  75635. base: number;
  75636. /**
  75637. * Support test.
  75638. */
  75639. static get IsSupported(): boolean;
  75640. private _scene;
  75641. private _randomTexture;
  75642. private _originalColorPostProcess;
  75643. private _ssaoPostProcess;
  75644. private _blurHPostProcess;
  75645. private _blurVPostProcess;
  75646. private _ssaoCombinePostProcess;
  75647. private _prePassRenderer;
  75648. /**
  75649. * Gets active scene
  75650. */
  75651. get scene(): Scene;
  75652. /**
  75653. * @constructor
  75654. * @param name The rendering pipeline name
  75655. * @param scene The scene linked to this pipeline
  75656. * @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 }
  75657. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75658. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75659. */
  75660. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75661. /**
  75662. * Get the class name
  75663. * @returns "SSAO2RenderingPipeline"
  75664. */
  75665. getClassName(): string;
  75666. /**
  75667. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75668. */
  75669. dispose(disableGeometryBufferRenderer?: boolean): void;
  75670. private _createBlurPostProcess;
  75671. /** @hidden */
  75672. _rebuild(): void;
  75673. private _bits;
  75674. private _radicalInverse_VdC;
  75675. private _hammersley;
  75676. private _hemisphereSample_uniform;
  75677. private _generateHemisphere;
  75678. private _getDefinesForSSAO;
  75679. private static readonly ORTHO_DEPTH_PROJECTION;
  75680. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75681. private _createSSAOPostProcess;
  75682. private _createSSAOCombinePostProcess;
  75683. private _createRandomTexture;
  75684. /**
  75685. * Serialize the rendering pipeline (Used when exporting)
  75686. * @returns the serialized object
  75687. */
  75688. serialize(): any;
  75689. /**
  75690. * Parse the serialized pipeline
  75691. * @param source Source pipeline.
  75692. * @param scene The scene to load the pipeline to.
  75693. * @param rootUrl The URL of the serialized pipeline.
  75694. * @returns An instantiated pipeline from the serialized object.
  75695. */
  75696. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75697. }
  75698. }
  75699. declare module BABYLON {
  75700. /** @hidden */
  75701. export var ssaoPixelShader: {
  75702. name: string;
  75703. shader: string;
  75704. };
  75705. }
  75706. declare module BABYLON {
  75707. /**
  75708. * Render pipeline to produce ssao effect
  75709. */
  75710. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75711. /**
  75712. * @ignore
  75713. * The PassPostProcess id in the pipeline that contains the original scene color
  75714. */
  75715. SSAOOriginalSceneColorEffect: string;
  75716. /**
  75717. * @ignore
  75718. * The SSAO PostProcess id in the pipeline
  75719. */
  75720. SSAORenderEffect: string;
  75721. /**
  75722. * @ignore
  75723. * The horizontal blur PostProcess id in the pipeline
  75724. */
  75725. SSAOBlurHRenderEffect: string;
  75726. /**
  75727. * @ignore
  75728. * The vertical blur PostProcess id in the pipeline
  75729. */
  75730. SSAOBlurVRenderEffect: string;
  75731. /**
  75732. * @ignore
  75733. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75734. */
  75735. SSAOCombineRenderEffect: string;
  75736. /**
  75737. * The output strength of the SSAO post-process. Default value is 1.0.
  75738. */
  75739. totalStrength: number;
  75740. /**
  75741. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75742. */
  75743. radius: number;
  75744. /**
  75745. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75746. * Must not be equal to fallOff and superior to fallOff.
  75747. * Default value is 0.0075
  75748. */
  75749. area: number;
  75750. /**
  75751. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75752. * Must not be equal to area and inferior to area.
  75753. * Default value is 0.000001
  75754. */
  75755. fallOff: number;
  75756. /**
  75757. * The base color of the SSAO post-process
  75758. * The final result is "base + ssao" between [0, 1]
  75759. */
  75760. base: number;
  75761. private _scene;
  75762. private _depthTexture;
  75763. private _randomTexture;
  75764. private _originalColorPostProcess;
  75765. private _ssaoPostProcess;
  75766. private _blurHPostProcess;
  75767. private _blurVPostProcess;
  75768. private _ssaoCombinePostProcess;
  75769. private _firstUpdate;
  75770. /**
  75771. * Gets active scene
  75772. */
  75773. get scene(): Scene;
  75774. /**
  75775. * @constructor
  75776. * @param name - The rendering pipeline name
  75777. * @param scene - The scene linked to this pipeline
  75778. * @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 }
  75779. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75780. */
  75781. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75782. /**
  75783. * Get the class name
  75784. * @returns "SSAORenderingPipeline"
  75785. */
  75786. getClassName(): string;
  75787. /**
  75788. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75789. */
  75790. dispose(disableDepthRender?: boolean): void;
  75791. private _createBlurPostProcess;
  75792. /** @hidden */
  75793. _rebuild(): void;
  75794. private _createSSAOPostProcess;
  75795. private _createSSAOCombinePostProcess;
  75796. private _createRandomTexture;
  75797. }
  75798. }
  75799. declare module BABYLON {
  75800. /**
  75801. * Contains all parameters needed for the prepass to perform
  75802. * screen space reflections
  75803. */
  75804. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75805. /**
  75806. * Is ssr enabled
  75807. */
  75808. enabled: boolean;
  75809. /**
  75810. * Name of the configuration
  75811. */
  75812. name: string;
  75813. /**
  75814. * Textures that should be present in the MRT for this effect to work
  75815. */
  75816. readonly texturesRequired: number[];
  75817. }
  75818. }
  75819. declare module BABYLON {
  75820. /** @hidden */
  75821. export var screenSpaceReflectionPixelShader: {
  75822. name: string;
  75823. shader: string;
  75824. };
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75829. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75830. */
  75831. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75832. /**
  75833. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75834. */
  75835. threshold: number;
  75836. /**
  75837. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75838. */
  75839. strength: number;
  75840. /**
  75841. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75842. */
  75843. reflectionSpecularFalloffExponent: number;
  75844. /**
  75845. * 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]
  75846. */
  75847. step: number;
  75848. /**
  75849. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75850. */
  75851. roughnessFactor: number;
  75852. private _forceGeometryBuffer;
  75853. private _geometryBufferRenderer;
  75854. private _prePassRenderer;
  75855. private _enableSmoothReflections;
  75856. private _reflectionSamples;
  75857. private _smoothSteps;
  75858. /**
  75859. * Gets a string identifying the name of the class
  75860. * @returns "ScreenSpaceReflectionPostProcess" string
  75861. */
  75862. getClassName(): string;
  75863. /**
  75864. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75865. * @param name The name of the effect.
  75866. * @param scene The scene containing the objects to calculate reflections.
  75867. * @param options The required width/height ratio to downsize to before computing the render pass.
  75868. * @param camera The camera to apply the render pass to.
  75869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75870. * @param engine The engine which the post process will be applied. (default: current engine)
  75871. * @param reusable If the post process can be reused on the same frame. (default: false)
  75872. * @param textureType Type of textures used when performing the post process. (default: 0)
  75873. * @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)
  75874. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75875. */
  75876. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75877. /**
  75878. * Gets whether or not smoothing reflections is enabled.
  75879. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75880. */
  75881. get enableSmoothReflections(): boolean;
  75882. /**
  75883. * Sets whether or not smoothing reflections is enabled.
  75884. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75885. */
  75886. set enableSmoothReflections(enabled: boolean);
  75887. /**
  75888. * Gets the number of samples taken while computing reflections. More samples count is high,
  75889. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75890. */
  75891. get reflectionSamples(): number;
  75892. /**
  75893. * Sets the number of samples taken while computing reflections. More samples count is high,
  75894. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75895. */
  75896. set reflectionSamples(samples: number);
  75897. /**
  75898. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75899. * more the post-process will require GPU power and can generate a drop in FPS.
  75900. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75901. */
  75902. get smoothSteps(): number;
  75903. set smoothSteps(steps: number);
  75904. private _updateEffectDefines;
  75905. /** @hidden */
  75906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75907. }
  75908. }
  75909. declare module BABYLON {
  75910. /** @hidden */
  75911. export var standardPixelShader: {
  75912. name: string;
  75913. shader: string;
  75914. };
  75915. }
  75916. declare module BABYLON {
  75917. /**
  75918. * Standard rendering pipeline
  75919. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75920. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75921. */
  75922. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75923. /**
  75924. * Public members
  75925. */
  75926. /**
  75927. * Post-process which contains the original scene color before the pipeline applies all the effects
  75928. */
  75929. originalPostProcess: Nullable<PostProcess>;
  75930. /**
  75931. * Post-process used to down scale an image x4
  75932. */
  75933. downSampleX4PostProcess: Nullable<PostProcess>;
  75934. /**
  75935. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75936. */
  75937. brightPassPostProcess: Nullable<PostProcess>;
  75938. /**
  75939. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75940. */
  75941. blurHPostProcesses: PostProcess[];
  75942. /**
  75943. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75944. */
  75945. blurVPostProcesses: PostProcess[];
  75946. /**
  75947. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75948. */
  75949. textureAdderPostProcess: Nullable<PostProcess>;
  75950. /**
  75951. * Post-process used to create volumetric lighting effect
  75952. */
  75953. volumetricLightPostProcess: Nullable<PostProcess>;
  75954. /**
  75955. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75956. */
  75957. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75958. /**
  75959. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75960. */
  75961. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75962. /**
  75963. * Post-process used to merge the volumetric light effect and the real scene color
  75964. */
  75965. volumetricLightMergePostProces: Nullable<PostProcess>;
  75966. /**
  75967. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75968. */
  75969. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75970. /**
  75971. * Base post-process used to calculate the average luminance of the final image for HDR
  75972. */
  75973. luminancePostProcess: Nullable<PostProcess>;
  75974. /**
  75975. * Post-processes used to create down sample post-processes in order to get
  75976. * the average luminance of the final image for HDR
  75977. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75978. */
  75979. luminanceDownSamplePostProcesses: PostProcess[];
  75980. /**
  75981. * Post-process used to create a HDR effect (light adaptation)
  75982. */
  75983. hdrPostProcess: Nullable<PostProcess>;
  75984. /**
  75985. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75986. */
  75987. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75988. /**
  75989. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75990. */
  75991. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75992. /**
  75993. * Post-process used to merge the final HDR post-process and the real scene color
  75994. */
  75995. hdrFinalPostProcess: Nullable<PostProcess>;
  75996. /**
  75997. * Post-process used to create a lens flare effect
  75998. */
  75999. lensFlarePostProcess: Nullable<PostProcess>;
  76000. /**
  76001. * Post-process that merges the result of the lens flare post-process and the real scene color
  76002. */
  76003. lensFlareComposePostProcess: Nullable<PostProcess>;
  76004. /**
  76005. * Post-process used to create a motion blur effect
  76006. */
  76007. motionBlurPostProcess: Nullable<PostProcess>;
  76008. /**
  76009. * Post-process used to create a depth of field effect
  76010. */
  76011. depthOfFieldPostProcess: Nullable<PostProcess>;
  76012. /**
  76013. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76014. */
  76015. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76016. /**
  76017. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76018. */
  76019. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76020. /**
  76021. * Represents the brightness threshold in order to configure the illuminated surfaces
  76022. */
  76023. brightThreshold: number;
  76024. /**
  76025. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76026. */
  76027. blurWidth: number;
  76028. /**
  76029. * Sets if the blur for highlighted surfaces must be only horizontal
  76030. */
  76031. horizontalBlur: boolean;
  76032. /**
  76033. * Gets the overall exposure used by the pipeline
  76034. */
  76035. get exposure(): number;
  76036. /**
  76037. * Sets the overall exposure used by the pipeline
  76038. */
  76039. set exposure(value: number);
  76040. /**
  76041. * Texture used typically to simulate "dirty" on camera lens
  76042. */
  76043. lensTexture: Nullable<Texture>;
  76044. /**
  76045. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76046. */
  76047. volumetricLightCoefficient: number;
  76048. /**
  76049. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76050. */
  76051. volumetricLightPower: number;
  76052. /**
  76053. * Used the set the blur intensity to smooth the volumetric lights
  76054. */
  76055. volumetricLightBlurScale: number;
  76056. /**
  76057. * Light (spot or directional) used to generate the volumetric lights rays
  76058. * The source light must have a shadow generate so the pipeline can get its
  76059. * depth map
  76060. */
  76061. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76062. /**
  76063. * For eye adaptation, represents the minimum luminance the eye can see
  76064. */
  76065. hdrMinimumLuminance: number;
  76066. /**
  76067. * For eye adaptation, represents the decrease luminance speed
  76068. */
  76069. hdrDecreaseRate: number;
  76070. /**
  76071. * For eye adaptation, represents the increase luminance speed
  76072. */
  76073. hdrIncreaseRate: number;
  76074. /**
  76075. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76076. */
  76077. get hdrAutoExposure(): boolean;
  76078. /**
  76079. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76080. */
  76081. set hdrAutoExposure(value: boolean);
  76082. /**
  76083. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76084. */
  76085. lensColorTexture: Nullable<Texture>;
  76086. /**
  76087. * The overall strengh for the lens flare effect
  76088. */
  76089. lensFlareStrength: number;
  76090. /**
  76091. * Dispersion coefficient for lens flare ghosts
  76092. */
  76093. lensFlareGhostDispersal: number;
  76094. /**
  76095. * Main lens flare halo width
  76096. */
  76097. lensFlareHaloWidth: number;
  76098. /**
  76099. * Based on the lens distortion effect, defines how much the lens flare result
  76100. * is distorted
  76101. */
  76102. lensFlareDistortionStrength: number;
  76103. /**
  76104. * Configures the blur intensity used for for lens flare (halo)
  76105. */
  76106. lensFlareBlurWidth: number;
  76107. /**
  76108. * Lens star texture must be used to simulate rays on the flares and is available
  76109. * in the documentation
  76110. */
  76111. lensStarTexture: Nullable<Texture>;
  76112. /**
  76113. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76114. * flare effect by taking account of the dirt texture
  76115. */
  76116. lensFlareDirtTexture: Nullable<Texture>;
  76117. /**
  76118. * Represents the focal length for the depth of field effect
  76119. */
  76120. depthOfFieldDistance: number;
  76121. /**
  76122. * Represents the blur intensity for the blurred part of the depth of field effect
  76123. */
  76124. depthOfFieldBlurWidth: number;
  76125. /**
  76126. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76127. */
  76128. get motionStrength(): number;
  76129. /**
  76130. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76131. */
  76132. set motionStrength(strength: number);
  76133. /**
  76134. * Gets whether or not the motion blur post-process is object based or screen based.
  76135. */
  76136. get objectBasedMotionBlur(): boolean;
  76137. /**
  76138. * Sets whether or not the motion blur post-process should be object based or screen based
  76139. */
  76140. set objectBasedMotionBlur(value: boolean);
  76141. /**
  76142. * List of animations for the pipeline (IAnimatable implementation)
  76143. */
  76144. animations: Animation[];
  76145. /**
  76146. * Private members
  76147. */
  76148. private _scene;
  76149. private _currentDepthOfFieldSource;
  76150. private _basePostProcess;
  76151. private _fixedExposure;
  76152. private _currentExposure;
  76153. private _hdrAutoExposure;
  76154. private _hdrCurrentLuminance;
  76155. private _motionStrength;
  76156. private _isObjectBasedMotionBlur;
  76157. private _floatTextureType;
  76158. private _camerasToBeAttached;
  76159. private _ratio;
  76160. private _bloomEnabled;
  76161. private _depthOfFieldEnabled;
  76162. private _vlsEnabled;
  76163. private _lensFlareEnabled;
  76164. private _hdrEnabled;
  76165. private _motionBlurEnabled;
  76166. private _fxaaEnabled;
  76167. private _screenSpaceReflectionsEnabled;
  76168. private _motionBlurSamples;
  76169. private _volumetricLightStepsCount;
  76170. private _samples;
  76171. /**
  76172. * @ignore
  76173. * Specifies if the bloom pipeline is enabled
  76174. */
  76175. get BloomEnabled(): boolean;
  76176. set BloomEnabled(enabled: boolean);
  76177. /**
  76178. * @ignore
  76179. * Specifies if the depth of field pipeline is enabled
  76180. */
  76181. get DepthOfFieldEnabled(): boolean;
  76182. set DepthOfFieldEnabled(enabled: boolean);
  76183. /**
  76184. * @ignore
  76185. * Specifies if the lens flare pipeline is enabled
  76186. */
  76187. get LensFlareEnabled(): boolean;
  76188. set LensFlareEnabled(enabled: boolean);
  76189. /**
  76190. * @ignore
  76191. * Specifies if the HDR pipeline is enabled
  76192. */
  76193. get HDREnabled(): boolean;
  76194. set HDREnabled(enabled: boolean);
  76195. /**
  76196. * @ignore
  76197. * Specifies if the volumetric lights scattering effect is enabled
  76198. */
  76199. get VLSEnabled(): boolean;
  76200. set VLSEnabled(enabled: boolean);
  76201. /**
  76202. * @ignore
  76203. * Specifies if the motion blur effect is enabled
  76204. */
  76205. get MotionBlurEnabled(): boolean;
  76206. set MotionBlurEnabled(enabled: boolean);
  76207. /**
  76208. * Specifies if anti-aliasing is enabled
  76209. */
  76210. get fxaaEnabled(): boolean;
  76211. set fxaaEnabled(enabled: boolean);
  76212. /**
  76213. * Specifies if screen space reflections are enabled.
  76214. */
  76215. get screenSpaceReflectionsEnabled(): boolean;
  76216. set screenSpaceReflectionsEnabled(enabled: boolean);
  76217. /**
  76218. * Specifies the number of steps used to calculate the volumetric lights
  76219. * Typically in interval [50, 200]
  76220. */
  76221. get volumetricLightStepsCount(): number;
  76222. set volumetricLightStepsCount(count: number);
  76223. /**
  76224. * Specifies the number of samples used for the motion blur effect
  76225. * Typically in interval [16, 64]
  76226. */
  76227. get motionBlurSamples(): number;
  76228. set motionBlurSamples(samples: number);
  76229. /**
  76230. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76231. */
  76232. get samples(): number;
  76233. set samples(sampleCount: number);
  76234. /**
  76235. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76236. * @constructor
  76237. * @param name The rendering pipeline name
  76238. * @param scene The scene linked to this pipeline
  76239. * @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)
  76240. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76241. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76242. */
  76243. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76244. private _buildPipeline;
  76245. private _createDownSampleX4PostProcess;
  76246. private _createBrightPassPostProcess;
  76247. private _createBlurPostProcesses;
  76248. private _createTextureAdderPostProcess;
  76249. private _createVolumetricLightPostProcess;
  76250. private _createLuminancePostProcesses;
  76251. private _createHdrPostProcess;
  76252. private _createLensFlarePostProcess;
  76253. private _createDepthOfFieldPostProcess;
  76254. private _createMotionBlurPostProcess;
  76255. private _getDepthTexture;
  76256. private _disposePostProcesses;
  76257. /**
  76258. * Dispose of the pipeline and stop all post processes
  76259. */
  76260. dispose(): void;
  76261. /**
  76262. * Serialize the rendering pipeline (Used when exporting)
  76263. * @returns the serialized object
  76264. */
  76265. serialize(): any;
  76266. /**
  76267. * Parse the serialized pipeline
  76268. * @param source Source pipeline.
  76269. * @param scene The scene to load the pipeline to.
  76270. * @param rootUrl The URL of the serialized pipeline.
  76271. * @returns An instantiated pipeline from the serialized object.
  76272. */
  76273. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76274. /**
  76275. * Luminance steps
  76276. */
  76277. static LuminanceSteps: number;
  76278. }
  76279. }
  76280. declare module BABYLON {
  76281. /** @hidden */
  76282. export var tonemapPixelShader: {
  76283. name: string;
  76284. shader: string;
  76285. };
  76286. }
  76287. declare module BABYLON {
  76288. /** Defines operator used for tonemapping */
  76289. export enum TonemappingOperator {
  76290. /** Hable */
  76291. Hable = 0,
  76292. /** Reinhard */
  76293. Reinhard = 1,
  76294. /** HejiDawson */
  76295. HejiDawson = 2,
  76296. /** Photographic */
  76297. Photographic = 3
  76298. }
  76299. /**
  76300. * Defines a post process to apply tone mapping
  76301. */
  76302. export class TonemapPostProcess extends PostProcess {
  76303. private _operator;
  76304. /** Defines the required exposure adjustment */
  76305. exposureAdjustment: number;
  76306. /**
  76307. * Gets a string identifying the name of the class
  76308. * @returns "TonemapPostProcess" string
  76309. */
  76310. getClassName(): string;
  76311. /**
  76312. * Creates a new TonemapPostProcess
  76313. * @param name defines the name of the postprocess
  76314. * @param _operator defines the operator to use
  76315. * @param exposureAdjustment defines the required exposure adjustement
  76316. * @param camera defines the camera to use (can be null)
  76317. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76318. * @param engine defines the hosting engine (can be ignore if camera is set)
  76319. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76320. */
  76321. constructor(name: string, _operator: TonemappingOperator,
  76322. /** Defines the required exposure adjustment */
  76323. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76324. }
  76325. }
  76326. declare module BABYLON {
  76327. /** @hidden */
  76328. export var volumetricLightScatteringPixelShader: {
  76329. name: string;
  76330. shader: string;
  76331. };
  76332. }
  76333. declare module BABYLON {
  76334. /** @hidden */
  76335. export var volumetricLightScatteringPassVertexShader: {
  76336. name: string;
  76337. shader: string;
  76338. };
  76339. }
  76340. declare module BABYLON {
  76341. /** @hidden */
  76342. export var volumetricLightScatteringPassPixelShader: {
  76343. name: string;
  76344. shader: string;
  76345. };
  76346. }
  76347. declare module BABYLON {
  76348. /**
  76349. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76350. */
  76351. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76352. private _volumetricLightScatteringPass;
  76353. private _volumetricLightScatteringRTT;
  76354. private _viewPort;
  76355. private _screenCoordinates;
  76356. private _cachedDefines;
  76357. /**
  76358. * If not undefined, the mesh position is computed from the attached node position
  76359. */
  76360. attachedNode: {
  76361. position: Vector3;
  76362. };
  76363. /**
  76364. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76365. */
  76366. customMeshPosition: Vector3;
  76367. /**
  76368. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76369. */
  76370. useCustomMeshPosition: boolean;
  76371. /**
  76372. * If the post-process should inverse the light scattering direction
  76373. */
  76374. invert: boolean;
  76375. /**
  76376. * The internal mesh used by the post-process
  76377. */
  76378. mesh: Mesh;
  76379. /**
  76380. * @hidden
  76381. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76382. */
  76383. get useDiffuseColor(): boolean;
  76384. set useDiffuseColor(useDiffuseColor: boolean);
  76385. /**
  76386. * Array containing the excluded meshes not rendered in the internal pass
  76387. */
  76388. excludedMeshes: AbstractMesh[];
  76389. /**
  76390. * Controls the overall intensity of the post-process
  76391. */
  76392. exposure: number;
  76393. /**
  76394. * Dissipates each sample's contribution in range [0, 1]
  76395. */
  76396. decay: number;
  76397. /**
  76398. * Controls the overall intensity of each sample
  76399. */
  76400. weight: number;
  76401. /**
  76402. * Controls the density of each sample
  76403. */
  76404. density: number;
  76405. /**
  76406. * @constructor
  76407. * @param name The post-process name
  76408. * @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)
  76409. * @param camera The camera that the post-process will be attached to
  76410. * @param mesh The mesh used to create the light scattering
  76411. * @param samples The post-process quality, default 100
  76412. * @param samplingModeThe post-process filtering mode
  76413. * @param engine The babylon engine
  76414. * @param reusable If the post-process is reusable
  76415. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76416. */
  76417. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76418. /**
  76419. * Returns the string "VolumetricLightScatteringPostProcess"
  76420. * @returns "VolumetricLightScatteringPostProcess"
  76421. */
  76422. getClassName(): string;
  76423. private _isReady;
  76424. /**
  76425. * Sets the new light position for light scattering effect
  76426. * @param position The new custom light position
  76427. */
  76428. setCustomMeshPosition(position: Vector3): void;
  76429. /**
  76430. * Returns the light position for light scattering effect
  76431. * @return Vector3 The custom light position
  76432. */
  76433. getCustomMeshPosition(): Vector3;
  76434. /**
  76435. * Disposes the internal assets and detaches the post-process from the camera
  76436. */
  76437. dispose(camera: Camera): void;
  76438. /**
  76439. * Returns the render target texture used by the post-process
  76440. * @return the render target texture used by the post-process
  76441. */
  76442. getPass(): RenderTargetTexture;
  76443. private _meshExcluded;
  76444. private _createPass;
  76445. private _updateMeshScreenCoordinates;
  76446. /**
  76447. * Creates a default mesh for the Volumeric Light Scattering post-process
  76448. * @param name The mesh name
  76449. * @param scene The scene where to create the mesh
  76450. * @return the default mesh
  76451. */
  76452. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76453. }
  76454. }
  76455. declare module BABYLON {
  76456. /** @hidden */
  76457. export var screenSpaceCurvaturePixelShader: {
  76458. name: string;
  76459. shader: string;
  76460. };
  76461. }
  76462. declare module BABYLON {
  76463. /**
  76464. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76465. */
  76466. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76467. /**
  76468. * Defines how much ridge the curvature effect displays.
  76469. */
  76470. ridge: number;
  76471. /**
  76472. * Defines how much valley the curvature effect displays.
  76473. */
  76474. valley: number;
  76475. private _geometryBufferRenderer;
  76476. /**
  76477. * Gets a string identifying the name of the class
  76478. * @returns "ScreenSpaceCurvaturePostProcess" string
  76479. */
  76480. getClassName(): string;
  76481. /**
  76482. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76483. * @param name The name of the effect.
  76484. * @param scene The scene containing the objects to blur according to their velocity.
  76485. * @param options The required width/height ratio to downsize to before computing the render pass.
  76486. * @param camera The camera to apply the render pass to.
  76487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76488. * @param engine The engine which the post process will be applied. (default: current engine)
  76489. * @param reusable If the post process can be reused on the same frame. (default: false)
  76490. * @param textureType Type of textures used when performing the post process. (default: 0)
  76491. * @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)
  76492. */
  76493. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76494. /**
  76495. * Support test.
  76496. */
  76497. static get IsSupported(): boolean;
  76498. /** @hidden */
  76499. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76500. }
  76501. }
  76502. declare module BABYLON {
  76503. interface Scene {
  76504. /** @hidden (Backing field) */
  76505. _boundingBoxRenderer: BoundingBoxRenderer;
  76506. /** @hidden (Backing field) */
  76507. _forceShowBoundingBoxes: boolean;
  76508. /**
  76509. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76510. */
  76511. forceShowBoundingBoxes: boolean;
  76512. /**
  76513. * Gets the bounding box renderer associated with the scene
  76514. * @returns a BoundingBoxRenderer
  76515. */
  76516. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76517. }
  76518. interface AbstractMesh {
  76519. /** @hidden (Backing field) */
  76520. _showBoundingBox: boolean;
  76521. /**
  76522. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76523. */
  76524. showBoundingBox: boolean;
  76525. }
  76526. /**
  76527. * Component responsible of rendering the bounding box of the meshes in a scene.
  76528. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76529. */
  76530. export class BoundingBoxRenderer implements ISceneComponent {
  76531. /**
  76532. * The component name helpful to identify the component in the list of scene components.
  76533. */
  76534. readonly name: string;
  76535. /**
  76536. * The scene the component belongs to.
  76537. */
  76538. scene: Scene;
  76539. /**
  76540. * Color of the bounding box lines placed in front of an object
  76541. */
  76542. frontColor: Color3;
  76543. /**
  76544. * Color of the bounding box lines placed behind an object
  76545. */
  76546. backColor: Color3;
  76547. /**
  76548. * Defines if the renderer should show the back lines or not
  76549. */
  76550. showBackLines: boolean;
  76551. /**
  76552. * Observable raised before rendering a bounding box
  76553. */
  76554. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76555. /**
  76556. * Observable raised after rendering a bounding box
  76557. */
  76558. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76559. /**
  76560. * Observable raised after resources are created
  76561. */
  76562. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76563. /**
  76564. * When false, no bounding boxes will be rendered
  76565. */
  76566. enabled: boolean;
  76567. /**
  76568. * @hidden
  76569. */
  76570. renderList: SmartArray<BoundingBox>;
  76571. private _colorShader;
  76572. private _vertexBuffers;
  76573. private _indexBuffer;
  76574. private _fillIndexBuffer;
  76575. private _fillIndexData;
  76576. /**
  76577. * Instantiates a new bounding box renderer in a scene.
  76578. * @param scene the scene the renderer renders in
  76579. */
  76580. constructor(scene: Scene);
  76581. /**
  76582. * Registers the component in a given scene
  76583. */
  76584. register(): void;
  76585. private _evaluateSubMesh;
  76586. private _preActiveMesh;
  76587. private _prepareResources;
  76588. private _createIndexBuffer;
  76589. /**
  76590. * Rebuilds the elements related to this component in case of
  76591. * context lost for instance.
  76592. */
  76593. rebuild(): void;
  76594. /**
  76595. * @hidden
  76596. */
  76597. reset(): void;
  76598. /**
  76599. * Render the bounding boxes of a specific rendering group
  76600. * @param renderingGroupId defines the rendering group to render
  76601. */
  76602. render(renderingGroupId: number): void;
  76603. /**
  76604. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76605. * @param mesh Define the mesh to render the occlusion bounding box for
  76606. */
  76607. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76608. /**
  76609. * Dispose and release the resources attached to this renderer.
  76610. */
  76611. dispose(): void;
  76612. }
  76613. }
  76614. declare module BABYLON {
  76615. interface Scene {
  76616. /** @hidden (Backing field) */
  76617. _depthRenderer: {
  76618. [id: string]: DepthRenderer;
  76619. };
  76620. /**
  76621. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76622. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76623. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76624. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76625. * @returns the created depth renderer
  76626. */
  76627. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76628. /**
  76629. * Disables a depth renderer for a given camera
  76630. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76631. */
  76632. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76633. }
  76634. /**
  76635. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76636. * in several rendering techniques.
  76637. */
  76638. export class DepthRendererSceneComponent implements ISceneComponent {
  76639. /**
  76640. * The component name helpful to identify the component in the list of scene components.
  76641. */
  76642. readonly name: string;
  76643. /**
  76644. * The scene the component belongs to.
  76645. */
  76646. scene: Scene;
  76647. /**
  76648. * Creates a new instance of the component for the given scene
  76649. * @param scene Defines the scene to register the component in
  76650. */
  76651. constructor(scene: Scene);
  76652. /**
  76653. * Registers the component in a given scene
  76654. */
  76655. register(): void;
  76656. /**
  76657. * Rebuilds the elements related to this component in case of
  76658. * context lost for instance.
  76659. */
  76660. rebuild(): void;
  76661. /**
  76662. * Disposes the component and the associated resources
  76663. */
  76664. dispose(): void;
  76665. private _gatherRenderTargets;
  76666. private _gatherActiveCameraRenderTargets;
  76667. }
  76668. }
  76669. declare module BABYLON {
  76670. interface AbstractScene {
  76671. /** @hidden (Backing field) */
  76672. _prePassRenderer: Nullable<PrePassRenderer>;
  76673. /**
  76674. * Gets or Sets the current prepass renderer associated to the scene.
  76675. */
  76676. prePassRenderer: Nullable<PrePassRenderer>;
  76677. /**
  76678. * Enables the prepass and associates it with the scene
  76679. * @returns the PrePassRenderer
  76680. */
  76681. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76682. /**
  76683. * Disables the prepass associated with the scene
  76684. */
  76685. disablePrePassRenderer(): void;
  76686. }
  76687. interface RenderTargetTexture {
  76688. /** @hidden */
  76689. _prePassRenderTarget: PrePassRenderTarget;
  76690. }
  76691. /**
  76692. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76693. * in several rendering techniques.
  76694. */
  76695. export class PrePassRendererSceneComponent implements ISceneComponent {
  76696. /**
  76697. * The component name helpful to identify the component in the list of scene components.
  76698. */
  76699. readonly name: string;
  76700. /**
  76701. * The scene the component belongs to.
  76702. */
  76703. scene: Scene;
  76704. /**
  76705. * Creates a new instance of the component for the given scene
  76706. * @param scene Defines the scene to register the component in
  76707. */
  76708. constructor(scene: Scene);
  76709. /**
  76710. * Registers the component in a given scene
  76711. */
  76712. register(): void;
  76713. private _beforeRenderTargetDraw;
  76714. private _afterRenderTargetDraw;
  76715. private _beforeRenderTargetClearStage;
  76716. private _beforeCameraDraw;
  76717. private _afterCameraDraw;
  76718. private _beforeClearStage;
  76719. private _beforeRenderingMeshStage;
  76720. private _afterRenderingMeshStage;
  76721. /**
  76722. * Rebuilds the elements related to this component in case of
  76723. * context lost for instance.
  76724. */
  76725. rebuild(): void;
  76726. /**
  76727. * Disposes the component and the associated resources
  76728. */
  76729. dispose(): void;
  76730. }
  76731. }
  76732. declare module BABYLON {
  76733. /** @hidden */
  76734. export var fibonacci: {
  76735. name: string;
  76736. shader: string;
  76737. };
  76738. }
  76739. declare module BABYLON {
  76740. /** @hidden */
  76741. export var diffusionProfile: {
  76742. name: string;
  76743. shader: string;
  76744. };
  76745. }
  76746. declare module BABYLON {
  76747. /** @hidden */
  76748. export var subSurfaceScatteringPixelShader: {
  76749. name: string;
  76750. shader: string;
  76751. };
  76752. }
  76753. declare module BABYLON {
  76754. /**
  76755. * Sub surface scattering post process
  76756. */
  76757. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76758. /**
  76759. * Gets a string identifying the name of the class
  76760. * @returns "SubSurfaceScatteringPostProcess" string
  76761. */
  76762. getClassName(): string;
  76763. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76764. }
  76765. }
  76766. declare module BABYLON {
  76767. /**
  76768. * Contains all parameters needed for the prepass to perform
  76769. * screen space subsurface scattering
  76770. */
  76771. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76772. /** @hidden */
  76773. static _SceneComponentInitialization: (scene: Scene) => void;
  76774. private _ssDiffusionS;
  76775. private _ssFilterRadii;
  76776. private _ssDiffusionD;
  76777. /**
  76778. * Post process to attach for screen space subsurface scattering
  76779. */
  76780. postProcess: SubSurfaceScatteringPostProcess;
  76781. /**
  76782. * Diffusion profile color for subsurface scattering
  76783. */
  76784. get ssDiffusionS(): number[];
  76785. /**
  76786. * Diffusion profile max color channel value for subsurface scattering
  76787. */
  76788. get ssDiffusionD(): number[];
  76789. /**
  76790. * Diffusion profile filter radius for subsurface scattering
  76791. */
  76792. get ssFilterRadii(): number[];
  76793. /**
  76794. * Is subsurface enabled
  76795. */
  76796. enabled: boolean;
  76797. /**
  76798. * Does the output of this prepass need to go through imageprocessing
  76799. */
  76800. needsImageProcessing: boolean;
  76801. /**
  76802. * Name of the configuration
  76803. */
  76804. name: string;
  76805. /**
  76806. * Diffusion profile colors for subsurface scattering
  76807. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76808. * See ...
  76809. * Note that you can only store up to 5 of them
  76810. */
  76811. ssDiffusionProfileColors: Color3[];
  76812. /**
  76813. * Defines the ratio real world => scene units.
  76814. * Used for subsurface scattering
  76815. */
  76816. metersPerUnit: number;
  76817. /**
  76818. * Textures that should be present in the MRT for this effect to work
  76819. */
  76820. readonly texturesRequired: number[];
  76821. private _scene;
  76822. /**
  76823. * Builds a subsurface configuration object
  76824. * @param scene The scene
  76825. */
  76826. constructor(scene: Scene);
  76827. /**
  76828. * Adds a new diffusion profile.
  76829. * Useful for more realistic subsurface scattering on diverse materials.
  76830. * @param color The color of the diffusion profile. Should be the average color of the material.
  76831. * @return The index of the diffusion profile for the material subsurface configuration
  76832. */
  76833. addDiffusionProfile(color: Color3): number;
  76834. /**
  76835. * Creates the sss post process
  76836. * @return The created post process
  76837. */
  76838. createPostProcess(): SubSurfaceScatteringPostProcess;
  76839. /**
  76840. * Deletes all diffusion profiles.
  76841. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76842. */
  76843. clearAllDiffusionProfiles(): void;
  76844. /**
  76845. * Disposes this object
  76846. */
  76847. dispose(): void;
  76848. /**
  76849. * @hidden
  76850. * https://zero-radiance.github.io/post/sampling-diffusion/
  76851. *
  76852. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76853. * ------------------------------------------------------------------------------------
  76854. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76855. * PDF[r, phi, s] = r * R[r, phi, s]
  76856. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76857. * ------------------------------------------------------------------------------------
  76858. * We importance sample the color channel with the widest scattering distance.
  76859. */
  76860. getDiffusionProfileParameters(color: Color3): number;
  76861. /**
  76862. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76863. * 'u' is the random number (the value of the CDF): [0, 1).
  76864. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76865. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76866. */
  76867. private _sampleBurleyDiffusionProfile;
  76868. }
  76869. }
  76870. declare module BABYLON {
  76871. interface AbstractScene {
  76872. /** @hidden (Backing field) */
  76873. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76874. /**
  76875. * Gets or Sets the current prepass renderer associated to the scene.
  76876. */
  76877. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76878. /**
  76879. * Enables the subsurface effect for prepass
  76880. * @returns the SubSurfaceConfiguration
  76881. */
  76882. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76883. /**
  76884. * Disables the subsurface effect for prepass
  76885. */
  76886. disableSubSurfaceForPrePass(): void;
  76887. }
  76888. /**
  76889. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76890. * in several rendering techniques.
  76891. */
  76892. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76893. /**
  76894. * The component name helpful to identify the component in the list of scene components.
  76895. */
  76896. readonly name: string;
  76897. /**
  76898. * The scene the component belongs to.
  76899. */
  76900. scene: Scene;
  76901. /**
  76902. * Creates a new instance of the component for the given scene
  76903. * @param scene Defines the scene to register the component in
  76904. */
  76905. constructor(scene: Scene);
  76906. /**
  76907. * Registers the component in a given scene
  76908. */
  76909. register(): void;
  76910. /**
  76911. * Serializes the component data to the specified json object
  76912. * @param serializationObject The object to serialize to
  76913. */
  76914. serialize(serializationObject: any): void;
  76915. /**
  76916. * Adds all the elements from the container to the scene
  76917. * @param container the container holding the elements
  76918. */
  76919. addFromContainer(container: AbstractScene): void;
  76920. /**
  76921. * Removes all the elements in the container from the scene
  76922. * @param container contains the elements to remove
  76923. * @param dispose if the removed element should be disposed (default: false)
  76924. */
  76925. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76926. /**
  76927. * Rebuilds the elements related to this component in case of
  76928. * context lost for instance.
  76929. */
  76930. rebuild(): void;
  76931. /**
  76932. * Disposes the component and the associated resources
  76933. */
  76934. dispose(): void;
  76935. }
  76936. }
  76937. declare module BABYLON {
  76938. /** @hidden */
  76939. export var outlinePixelShader: {
  76940. name: string;
  76941. shader: string;
  76942. };
  76943. }
  76944. declare module BABYLON {
  76945. /** @hidden */
  76946. export var outlineVertexShader: {
  76947. name: string;
  76948. shader: string;
  76949. };
  76950. }
  76951. declare module BABYLON {
  76952. interface Scene {
  76953. /** @hidden */
  76954. _outlineRenderer: OutlineRenderer;
  76955. /**
  76956. * Gets the outline renderer associated with the scene
  76957. * @returns a OutlineRenderer
  76958. */
  76959. getOutlineRenderer(): OutlineRenderer;
  76960. }
  76961. interface AbstractMesh {
  76962. /** @hidden (Backing field) */
  76963. _renderOutline: boolean;
  76964. /**
  76965. * Gets or sets a boolean indicating if the outline must be rendered as well
  76966. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76967. */
  76968. renderOutline: boolean;
  76969. /** @hidden (Backing field) */
  76970. _renderOverlay: boolean;
  76971. /**
  76972. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76973. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76974. */
  76975. renderOverlay: boolean;
  76976. }
  76977. /**
  76978. * This class is responsible to draw the outline/overlay of meshes.
  76979. * It should not be used directly but through the available method on mesh.
  76980. */
  76981. export class OutlineRenderer implements ISceneComponent {
  76982. /**
  76983. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76984. */
  76985. private static _StencilReference;
  76986. /**
  76987. * The name of the component. Each component must have a unique name.
  76988. */
  76989. name: string;
  76990. /**
  76991. * The scene the component belongs to.
  76992. */
  76993. scene: Scene;
  76994. /**
  76995. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76996. */
  76997. zOffset: number;
  76998. private _engine;
  76999. private _effect;
  77000. private _cachedDefines;
  77001. private _savedDepthWrite;
  77002. /**
  77003. * Instantiates a new outline renderer. (There could be only one per scene).
  77004. * @param scene Defines the scene it belongs to
  77005. */
  77006. constructor(scene: Scene);
  77007. /**
  77008. * Register the component to one instance of a scene.
  77009. */
  77010. register(): void;
  77011. /**
  77012. * Rebuilds the elements related to this component in case of
  77013. * context lost for instance.
  77014. */
  77015. rebuild(): void;
  77016. /**
  77017. * Disposes the component and the associated resources.
  77018. */
  77019. dispose(): void;
  77020. /**
  77021. * Renders the outline in the canvas.
  77022. * @param subMesh Defines the sumesh to render
  77023. * @param batch Defines the batch of meshes in case of instances
  77024. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77025. */
  77026. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77027. /**
  77028. * Returns whether or not the outline renderer is ready for a given submesh.
  77029. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77030. * @param subMesh Defines the submesh to check readiness for
  77031. * @param useInstances Defines whether wee are trying to render instances or not
  77032. * @returns true if ready otherwise false
  77033. */
  77034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77035. private _beforeRenderingMesh;
  77036. private _afterRenderingMesh;
  77037. }
  77038. }
  77039. declare module BABYLON {
  77040. /**
  77041. * Defines the basic options interface of a Sprite Frame Source Size.
  77042. */
  77043. export interface ISpriteJSONSpriteSourceSize {
  77044. /**
  77045. * number of the original width of the Frame
  77046. */
  77047. w: number;
  77048. /**
  77049. * number of the original height of the Frame
  77050. */
  77051. h: number;
  77052. }
  77053. /**
  77054. * Defines the basic options interface of a Sprite Frame Data.
  77055. */
  77056. export interface ISpriteJSONSpriteFrameData {
  77057. /**
  77058. * number of the x offset of the Frame
  77059. */
  77060. x: number;
  77061. /**
  77062. * number of the y offset of the Frame
  77063. */
  77064. y: number;
  77065. /**
  77066. * number of the width of the Frame
  77067. */
  77068. w: number;
  77069. /**
  77070. * number of the height of the Frame
  77071. */
  77072. h: number;
  77073. }
  77074. /**
  77075. * Defines the basic options interface of a JSON Sprite.
  77076. */
  77077. export interface ISpriteJSONSprite {
  77078. /**
  77079. * string name of the Frame
  77080. */
  77081. filename: string;
  77082. /**
  77083. * ISpriteJSONSpriteFrame basic object of the frame data
  77084. */
  77085. frame: ISpriteJSONSpriteFrameData;
  77086. /**
  77087. * boolean to flag is the frame was rotated.
  77088. */
  77089. rotated: boolean;
  77090. /**
  77091. * boolean to flag is the frame was trimmed.
  77092. */
  77093. trimmed: boolean;
  77094. /**
  77095. * ISpriteJSONSpriteFrame basic object of the source data
  77096. */
  77097. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77098. /**
  77099. * ISpriteJSONSpriteFrame basic object of the source data
  77100. */
  77101. sourceSize: ISpriteJSONSpriteSourceSize;
  77102. }
  77103. /**
  77104. * Defines the basic options interface of a JSON atlas.
  77105. */
  77106. export interface ISpriteJSONAtlas {
  77107. /**
  77108. * Array of objects that contain the frame data.
  77109. */
  77110. frames: Array<ISpriteJSONSprite>;
  77111. /**
  77112. * object basic object containing the sprite meta data.
  77113. */
  77114. meta?: object;
  77115. }
  77116. }
  77117. declare module BABYLON {
  77118. /** @hidden */
  77119. export var spriteMapPixelShader: {
  77120. name: string;
  77121. shader: string;
  77122. };
  77123. }
  77124. declare module BABYLON {
  77125. /** @hidden */
  77126. export var spriteMapVertexShader: {
  77127. name: string;
  77128. shader: string;
  77129. };
  77130. }
  77131. declare module BABYLON {
  77132. /**
  77133. * Defines the basic options interface of a SpriteMap
  77134. */
  77135. export interface ISpriteMapOptions {
  77136. /**
  77137. * Vector2 of the number of cells in the grid.
  77138. */
  77139. stageSize?: Vector2;
  77140. /**
  77141. * Vector2 of the size of the output plane in World Units.
  77142. */
  77143. outputSize?: Vector2;
  77144. /**
  77145. * Vector3 of the position of the output plane in World Units.
  77146. */
  77147. outputPosition?: Vector3;
  77148. /**
  77149. * Vector3 of the rotation of the output plane.
  77150. */
  77151. outputRotation?: Vector3;
  77152. /**
  77153. * number of layers that the system will reserve in resources.
  77154. */
  77155. layerCount?: number;
  77156. /**
  77157. * number of max animation frames a single cell will reserve in resources.
  77158. */
  77159. maxAnimationFrames?: number;
  77160. /**
  77161. * number cell index of the base tile when the system compiles.
  77162. */
  77163. baseTile?: number;
  77164. /**
  77165. * boolean flip the sprite after its been repositioned by the framing data.
  77166. */
  77167. flipU?: boolean;
  77168. /**
  77169. * Vector3 scalar of the global RGB values of the SpriteMap.
  77170. */
  77171. colorMultiply?: Vector3;
  77172. }
  77173. /**
  77174. * Defines the IDisposable interface in order to be cleanable from resources.
  77175. */
  77176. export interface ISpriteMap extends IDisposable {
  77177. /**
  77178. * String name of the SpriteMap.
  77179. */
  77180. name: string;
  77181. /**
  77182. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77183. */
  77184. atlasJSON: ISpriteJSONAtlas;
  77185. /**
  77186. * Texture of the SpriteMap.
  77187. */
  77188. spriteSheet: Texture;
  77189. /**
  77190. * The parameters to initialize the SpriteMap with.
  77191. */
  77192. options: ISpriteMapOptions;
  77193. }
  77194. /**
  77195. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77196. */
  77197. export class SpriteMap implements ISpriteMap {
  77198. /** The Name of the spriteMap */
  77199. name: string;
  77200. /** The JSON file with the frame and meta data */
  77201. atlasJSON: ISpriteJSONAtlas;
  77202. /** The systems Sprite Sheet Texture */
  77203. spriteSheet: Texture;
  77204. /** Arguments passed with the Constructor */
  77205. options: ISpriteMapOptions;
  77206. /** Public Sprite Storage array, parsed from atlasJSON */
  77207. sprites: Array<ISpriteJSONSprite>;
  77208. /** Returns the Number of Sprites in the System */
  77209. get spriteCount(): number;
  77210. /** Returns the Position of Output Plane*/
  77211. get position(): Vector3;
  77212. /** Returns the Position of Output Plane*/
  77213. set position(v: Vector3);
  77214. /** Returns the Rotation of Output Plane*/
  77215. get rotation(): Vector3;
  77216. /** Returns the Rotation of Output Plane*/
  77217. set rotation(v: Vector3);
  77218. /** Sets the AnimationMap*/
  77219. get animationMap(): RawTexture;
  77220. /** Sets the AnimationMap*/
  77221. set animationMap(v: RawTexture);
  77222. /** Scene that the SpriteMap was created in */
  77223. private _scene;
  77224. /** Texture Buffer of Float32 that holds tile frame data*/
  77225. private _frameMap;
  77226. /** Texture Buffers of Float32 that holds tileMap data*/
  77227. private _tileMaps;
  77228. /** Texture Buffer of Float32 that holds Animation Data*/
  77229. private _animationMap;
  77230. /** Custom ShaderMaterial Central to the System*/
  77231. private _material;
  77232. /** Custom ShaderMaterial Central to the System*/
  77233. private _output;
  77234. /** Systems Time Ticker*/
  77235. private _time;
  77236. /**
  77237. * Creates a new SpriteMap
  77238. * @param name defines the SpriteMaps Name
  77239. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77240. * @param spriteSheet is the Texture that the Sprites are on.
  77241. * @param options a basic deployment configuration
  77242. * @param scene The Scene that the map is deployed on
  77243. */
  77244. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77245. /**
  77246. * Returns tileID location
  77247. * @returns Vector2 the cell position ID
  77248. */
  77249. getTileID(): Vector2;
  77250. /**
  77251. * Gets the UV location of the mouse over the SpriteMap.
  77252. * @returns Vector2 the UV position of the mouse interaction
  77253. */
  77254. getMousePosition(): Vector2;
  77255. /**
  77256. * Creates the "frame" texture Buffer
  77257. * -------------------------------------
  77258. * Structure of frames
  77259. * "filename": "Falling-Water-2.png",
  77260. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77261. * "rotated": true,
  77262. * "trimmed": true,
  77263. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77264. * "sourceSize": {"w":32,"h":32}
  77265. * @returns RawTexture of the frameMap
  77266. */
  77267. private _createFrameBuffer;
  77268. /**
  77269. * Creates the tileMap texture Buffer
  77270. * @param buffer normally and array of numbers, or a false to generate from scratch
  77271. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77272. * @returns RawTexture of the tileMap
  77273. */
  77274. private _createTileBuffer;
  77275. /**
  77276. * Modifies the data of the tileMaps
  77277. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77278. * @param pos is the iVector2 Coordinates of the Tile
  77279. * @param tile The SpriteIndex of the new Tile
  77280. */
  77281. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77282. /**
  77283. * Creates the animationMap texture Buffer
  77284. * @param buffer normally and array of numbers, or a false to generate from scratch
  77285. * @returns RawTexture of the animationMap
  77286. */
  77287. private _createTileAnimationBuffer;
  77288. /**
  77289. * Modifies the data of the animationMap
  77290. * @param cellID is the Index of the Sprite
  77291. * @param _frame is the target Animation frame
  77292. * @param toCell is the Target Index of the next frame of the animation
  77293. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77294. * @param speed is a global scalar of the time variable on the map.
  77295. */
  77296. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77297. /**
  77298. * Exports the .tilemaps file
  77299. */
  77300. saveTileMaps(): void;
  77301. /**
  77302. * Imports the .tilemaps file
  77303. * @param url of the .tilemaps file
  77304. */
  77305. loadTileMaps(url: string): void;
  77306. /**
  77307. * Release associated resources
  77308. */
  77309. dispose(): void;
  77310. }
  77311. }
  77312. declare module BABYLON {
  77313. /**
  77314. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77315. * @see https://doc.babylonjs.com/babylon101/sprites
  77316. */
  77317. export class SpritePackedManager extends SpriteManager {
  77318. /** defines the packed manager's name */
  77319. name: string;
  77320. /**
  77321. * Creates a new sprite manager from a packed sprite sheet
  77322. * @param name defines the manager's name
  77323. * @param imgUrl defines the sprite sheet url
  77324. * @param capacity defines the maximum allowed number of sprites
  77325. * @param scene defines the hosting scene
  77326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77327. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77328. * @param samplingMode defines the sampling mode to use with spritesheet
  77329. * @param fromPacked set to true; do not alter
  77330. */
  77331. constructor(
  77332. /** defines the packed manager's name */
  77333. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77334. }
  77335. }
  77336. declare module BABYLON {
  77337. /**
  77338. * Defines the list of states available for a task inside a AssetsManager
  77339. */
  77340. export enum AssetTaskState {
  77341. /**
  77342. * Initialization
  77343. */
  77344. INIT = 0,
  77345. /**
  77346. * Running
  77347. */
  77348. RUNNING = 1,
  77349. /**
  77350. * Done
  77351. */
  77352. DONE = 2,
  77353. /**
  77354. * Error
  77355. */
  77356. ERROR = 3
  77357. }
  77358. /**
  77359. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77360. */
  77361. export abstract class AbstractAssetTask {
  77362. /**
  77363. * Task name
  77364. */ name: string;
  77365. /**
  77366. * Callback called when the task is successful
  77367. */
  77368. onSuccess: (task: any) => void;
  77369. /**
  77370. * Callback called when the task is not successful
  77371. */
  77372. onError: (task: any, message?: string, exception?: any) => void;
  77373. /**
  77374. * Creates a new AssetsManager
  77375. * @param name defines the name of the task
  77376. */
  77377. constructor(
  77378. /**
  77379. * Task name
  77380. */ name: string);
  77381. private _isCompleted;
  77382. private _taskState;
  77383. private _errorObject;
  77384. /**
  77385. * Get if the task is completed
  77386. */
  77387. get isCompleted(): boolean;
  77388. /**
  77389. * Gets the current state of the task
  77390. */
  77391. get taskState(): AssetTaskState;
  77392. /**
  77393. * Gets the current error object (if task is in error)
  77394. */
  77395. get errorObject(): {
  77396. message?: string;
  77397. exception?: any;
  77398. };
  77399. /**
  77400. * Internal only
  77401. * @hidden
  77402. */
  77403. _setErrorObject(message?: string, exception?: any): void;
  77404. /**
  77405. * Execute the current task
  77406. * @param scene defines the scene where you want your assets to be loaded
  77407. * @param onSuccess is a callback called when the task is successfully executed
  77408. * @param onError is a callback called if an error occurs
  77409. */
  77410. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77411. /**
  77412. * Execute the current task
  77413. * @param scene defines the scene where you want your assets to be loaded
  77414. * @param onSuccess is a callback called when the task is successfully executed
  77415. * @param onError is a callback called if an error occurs
  77416. */
  77417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77418. /**
  77419. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77420. * This can be used with failed tasks that have the reason for failure fixed.
  77421. */
  77422. reset(): void;
  77423. private onErrorCallback;
  77424. private onDoneCallback;
  77425. }
  77426. /**
  77427. * Define the interface used by progress events raised during assets loading
  77428. */
  77429. export interface IAssetsProgressEvent {
  77430. /**
  77431. * Defines the number of remaining tasks to process
  77432. */
  77433. remainingCount: number;
  77434. /**
  77435. * Defines the total number of tasks
  77436. */
  77437. totalCount: number;
  77438. /**
  77439. * Defines the task that was just processed
  77440. */
  77441. task: AbstractAssetTask;
  77442. }
  77443. /**
  77444. * Class used to share progress information about assets loading
  77445. */
  77446. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77447. /**
  77448. * Defines the number of remaining tasks to process
  77449. */
  77450. remainingCount: number;
  77451. /**
  77452. * Defines the total number of tasks
  77453. */
  77454. totalCount: number;
  77455. /**
  77456. * Defines the task that was just processed
  77457. */
  77458. task: AbstractAssetTask;
  77459. /**
  77460. * Creates a AssetsProgressEvent
  77461. * @param remainingCount defines the number of remaining tasks to process
  77462. * @param totalCount defines the total number of tasks
  77463. * @param task defines the task that was just processed
  77464. */
  77465. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77466. }
  77467. /**
  77468. * Define a task used by AssetsManager to load assets into a container
  77469. */
  77470. export class ContainerAssetTask extends AbstractAssetTask {
  77471. /**
  77472. * Defines the name of the task
  77473. */
  77474. name: string;
  77475. /**
  77476. * Defines the list of mesh's names you want to load
  77477. */
  77478. meshesNames: any;
  77479. /**
  77480. * Defines the root url to use as a base to load your meshes and associated resources
  77481. */
  77482. rootUrl: string;
  77483. /**
  77484. * Defines the filename or File of the scene to load from
  77485. */
  77486. sceneFilename: string | File;
  77487. /**
  77488. * Get the loaded asset container
  77489. */
  77490. loadedContainer: AssetContainer;
  77491. /**
  77492. * Gets the list of loaded meshes
  77493. */
  77494. loadedMeshes: Array<AbstractMesh>;
  77495. /**
  77496. * Gets the list of loaded particle systems
  77497. */
  77498. loadedParticleSystems: Array<IParticleSystem>;
  77499. /**
  77500. * Gets the list of loaded skeletons
  77501. */
  77502. loadedSkeletons: Array<Skeleton>;
  77503. /**
  77504. * Gets the list of loaded animation groups
  77505. */
  77506. loadedAnimationGroups: Array<AnimationGroup>;
  77507. /**
  77508. * Callback called when the task is successful
  77509. */
  77510. onSuccess: (task: ContainerAssetTask) => void;
  77511. /**
  77512. * Callback called when the task is successful
  77513. */
  77514. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77515. /**
  77516. * Creates a new ContainerAssetTask
  77517. * @param name defines the name of the task
  77518. * @param meshesNames defines the list of mesh's names you want to load
  77519. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77520. * @param sceneFilename defines the filename or File of the scene to load from
  77521. */
  77522. constructor(
  77523. /**
  77524. * Defines the name of the task
  77525. */
  77526. name: string,
  77527. /**
  77528. * Defines the list of mesh's names you want to load
  77529. */
  77530. meshesNames: any,
  77531. /**
  77532. * Defines the root url to use as a base to load your meshes and associated resources
  77533. */
  77534. rootUrl: string,
  77535. /**
  77536. * Defines the filename or File of the scene to load from
  77537. */
  77538. sceneFilename: string | File);
  77539. /**
  77540. * Execute the current task
  77541. * @param scene defines the scene where you want your assets to be loaded
  77542. * @param onSuccess is a callback called when the task is successfully executed
  77543. * @param onError is a callback called if an error occurs
  77544. */
  77545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77546. }
  77547. /**
  77548. * Define a task used by AssetsManager to load meshes
  77549. */
  77550. export class MeshAssetTask extends AbstractAssetTask {
  77551. /**
  77552. * Defines the name of the task
  77553. */
  77554. name: string;
  77555. /**
  77556. * Defines the list of mesh's names you want to load
  77557. */
  77558. meshesNames: any;
  77559. /**
  77560. * Defines the root url to use as a base to load your meshes and associated resources
  77561. */
  77562. rootUrl: string;
  77563. /**
  77564. * Defines the filename or File of the scene to load from
  77565. */
  77566. sceneFilename: string | File;
  77567. /**
  77568. * Gets the list of loaded meshes
  77569. */
  77570. loadedMeshes: Array<AbstractMesh>;
  77571. /**
  77572. * Gets the list of loaded particle systems
  77573. */
  77574. loadedParticleSystems: Array<IParticleSystem>;
  77575. /**
  77576. * Gets the list of loaded skeletons
  77577. */
  77578. loadedSkeletons: Array<Skeleton>;
  77579. /**
  77580. * Gets the list of loaded animation groups
  77581. */
  77582. loadedAnimationGroups: Array<AnimationGroup>;
  77583. /**
  77584. * Callback called when the task is successful
  77585. */
  77586. onSuccess: (task: MeshAssetTask) => void;
  77587. /**
  77588. * Callback called when the task is successful
  77589. */
  77590. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77591. /**
  77592. * Creates a new MeshAssetTask
  77593. * @param name defines the name of the task
  77594. * @param meshesNames defines the list of mesh's names you want to load
  77595. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77596. * @param sceneFilename defines the filename or File of the scene to load from
  77597. */
  77598. constructor(
  77599. /**
  77600. * Defines the name of the task
  77601. */
  77602. name: string,
  77603. /**
  77604. * Defines the list of mesh's names you want to load
  77605. */
  77606. meshesNames: any,
  77607. /**
  77608. * Defines the root url to use as a base to load your meshes and associated resources
  77609. */
  77610. rootUrl: string,
  77611. /**
  77612. * Defines the filename or File of the scene to load from
  77613. */
  77614. sceneFilename: string | File);
  77615. /**
  77616. * Execute the current task
  77617. * @param scene defines the scene where you want your assets to be loaded
  77618. * @param onSuccess is a callback called when the task is successfully executed
  77619. * @param onError is a callback called if an error occurs
  77620. */
  77621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77622. }
  77623. /**
  77624. * Define a task used by AssetsManager to load text content
  77625. */
  77626. export class TextFileAssetTask extends AbstractAssetTask {
  77627. /**
  77628. * Defines the name of the task
  77629. */
  77630. name: string;
  77631. /**
  77632. * Defines the location of the file to load
  77633. */
  77634. url: string;
  77635. /**
  77636. * Gets the loaded text string
  77637. */
  77638. text: string;
  77639. /**
  77640. * Callback called when the task is successful
  77641. */
  77642. onSuccess: (task: TextFileAssetTask) => void;
  77643. /**
  77644. * Callback called when the task is successful
  77645. */
  77646. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77647. /**
  77648. * Creates a new TextFileAssetTask object
  77649. * @param name defines the name of the task
  77650. * @param url defines the location of the file to load
  77651. */
  77652. constructor(
  77653. /**
  77654. * Defines the name of the task
  77655. */
  77656. name: string,
  77657. /**
  77658. * Defines the location of the file to load
  77659. */
  77660. url: string);
  77661. /**
  77662. * Execute the current task
  77663. * @param scene defines the scene where you want your assets to be loaded
  77664. * @param onSuccess is a callback called when the task is successfully executed
  77665. * @param onError is a callback called if an error occurs
  77666. */
  77667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77668. }
  77669. /**
  77670. * Define a task used by AssetsManager to load binary data
  77671. */
  77672. export class BinaryFileAssetTask extends AbstractAssetTask {
  77673. /**
  77674. * Defines the name of the task
  77675. */
  77676. name: string;
  77677. /**
  77678. * Defines the location of the file to load
  77679. */
  77680. url: string;
  77681. /**
  77682. * Gets the lodaded data (as an array buffer)
  77683. */
  77684. data: ArrayBuffer;
  77685. /**
  77686. * Callback called when the task is successful
  77687. */
  77688. onSuccess: (task: BinaryFileAssetTask) => void;
  77689. /**
  77690. * Callback called when the task is successful
  77691. */
  77692. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77693. /**
  77694. * Creates a new BinaryFileAssetTask object
  77695. * @param name defines the name of the new task
  77696. * @param url defines the location of the file to load
  77697. */
  77698. constructor(
  77699. /**
  77700. * Defines the name of the task
  77701. */
  77702. name: string,
  77703. /**
  77704. * Defines the location of the file to load
  77705. */
  77706. url: string);
  77707. /**
  77708. * Execute the current task
  77709. * @param scene defines the scene where you want your assets to be loaded
  77710. * @param onSuccess is a callback called when the task is successfully executed
  77711. * @param onError is a callback called if an error occurs
  77712. */
  77713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77714. }
  77715. /**
  77716. * Define a task used by AssetsManager to load images
  77717. */
  77718. export class ImageAssetTask extends AbstractAssetTask {
  77719. /**
  77720. * Defines the name of the task
  77721. */
  77722. name: string;
  77723. /**
  77724. * Defines the location of the image to load
  77725. */
  77726. url: string;
  77727. /**
  77728. * Gets the loaded images
  77729. */
  77730. image: HTMLImageElement;
  77731. /**
  77732. * Callback called when the task is successful
  77733. */
  77734. onSuccess: (task: ImageAssetTask) => void;
  77735. /**
  77736. * Callback called when the task is successful
  77737. */
  77738. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77739. /**
  77740. * Creates a new ImageAssetTask
  77741. * @param name defines the name of the task
  77742. * @param url defines the location of the image to load
  77743. */
  77744. constructor(
  77745. /**
  77746. * Defines the name of the task
  77747. */
  77748. name: string,
  77749. /**
  77750. * Defines the location of the image to load
  77751. */
  77752. url: string);
  77753. /**
  77754. * Execute the current task
  77755. * @param scene defines the scene where you want your assets to be loaded
  77756. * @param onSuccess is a callback called when the task is successfully executed
  77757. * @param onError is a callback called if an error occurs
  77758. */
  77759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77760. }
  77761. /**
  77762. * Defines the interface used by texture loading tasks
  77763. */
  77764. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77765. /**
  77766. * Gets the loaded texture
  77767. */
  77768. texture: TEX;
  77769. }
  77770. /**
  77771. * Define a task used by AssetsManager to load 2D textures
  77772. */
  77773. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77774. /**
  77775. * Defines the name of the task
  77776. */
  77777. name: string;
  77778. /**
  77779. * Defines the location of the file to load
  77780. */
  77781. url: string;
  77782. /**
  77783. * Defines if mipmap should not be generated (default is false)
  77784. */
  77785. noMipmap?: boolean | undefined;
  77786. /**
  77787. * Defines if texture must be inverted on Y axis (default is true)
  77788. */
  77789. invertY: boolean;
  77790. /**
  77791. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77792. */
  77793. samplingMode: number;
  77794. /**
  77795. * Gets the loaded texture
  77796. */
  77797. texture: Texture;
  77798. /**
  77799. * Callback called when the task is successful
  77800. */
  77801. onSuccess: (task: TextureAssetTask) => void;
  77802. /**
  77803. * Callback called when the task is successful
  77804. */
  77805. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77806. /**
  77807. * Creates a new TextureAssetTask object
  77808. * @param name defines the name of the task
  77809. * @param url defines the location of the file to load
  77810. * @param noMipmap defines if mipmap should not be generated (default is false)
  77811. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77812. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77813. */
  77814. constructor(
  77815. /**
  77816. * Defines the name of the task
  77817. */
  77818. name: string,
  77819. /**
  77820. * Defines the location of the file to load
  77821. */
  77822. url: string,
  77823. /**
  77824. * Defines if mipmap should not be generated (default is false)
  77825. */
  77826. noMipmap?: boolean | undefined,
  77827. /**
  77828. * Defines if texture must be inverted on Y axis (default is true)
  77829. */
  77830. invertY?: boolean,
  77831. /**
  77832. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77833. */
  77834. samplingMode?: number);
  77835. /**
  77836. * Execute the current task
  77837. * @param scene defines the scene where you want your assets to be loaded
  77838. * @param onSuccess is a callback called when the task is successfully executed
  77839. * @param onError is a callback called if an error occurs
  77840. */
  77841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77842. }
  77843. /**
  77844. * Define a task used by AssetsManager to load cube textures
  77845. */
  77846. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77847. /**
  77848. * Defines the name of the task
  77849. */
  77850. name: string;
  77851. /**
  77852. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77853. */
  77854. url: string;
  77855. /**
  77856. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77857. */
  77858. extensions?: string[] | undefined;
  77859. /**
  77860. * Defines if mipmaps should not be generated (default is false)
  77861. */
  77862. noMipmap?: boolean | undefined;
  77863. /**
  77864. * Defines the explicit list of files (undefined by default)
  77865. */
  77866. files?: string[] | undefined;
  77867. /**
  77868. * Gets the loaded texture
  77869. */
  77870. texture: CubeTexture;
  77871. /**
  77872. * Callback called when the task is successful
  77873. */
  77874. onSuccess: (task: CubeTextureAssetTask) => void;
  77875. /**
  77876. * Callback called when the task is successful
  77877. */
  77878. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77879. /**
  77880. * Creates a new CubeTextureAssetTask
  77881. * @param name defines the name of the task
  77882. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77883. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77884. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77885. * @param files defines the explicit list of files (undefined by default)
  77886. */
  77887. constructor(
  77888. /**
  77889. * Defines the name of the task
  77890. */
  77891. name: string,
  77892. /**
  77893. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77894. */
  77895. url: string,
  77896. /**
  77897. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77898. */
  77899. extensions?: string[] | undefined,
  77900. /**
  77901. * Defines if mipmaps should not be generated (default is false)
  77902. */
  77903. noMipmap?: boolean | undefined,
  77904. /**
  77905. * Defines the explicit list of files (undefined by default)
  77906. */
  77907. files?: string[] | undefined);
  77908. /**
  77909. * Execute the current task
  77910. * @param scene defines the scene where you want your assets to be loaded
  77911. * @param onSuccess is a callback called when the task is successfully executed
  77912. * @param onError is a callback called if an error occurs
  77913. */
  77914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77915. }
  77916. /**
  77917. * Define a task used by AssetsManager to load HDR cube textures
  77918. */
  77919. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77920. /**
  77921. * Defines the name of the task
  77922. */
  77923. name: string;
  77924. /**
  77925. * Defines the location of the file to load
  77926. */
  77927. url: string;
  77928. /**
  77929. * Defines the desired size (the more it increases the longer the generation will be)
  77930. */
  77931. size: number;
  77932. /**
  77933. * Defines if mipmaps should not be generated (default is false)
  77934. */
  77935. noMipmap: boolean;
  77936. /**
  77937. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77938. */
  77939. generateHarmonics: boolean;
  77940. /**
  77941. * 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)
  77942. */
  77943. gammaSpace: boolean;
  77944. /**
  77945. * Internal Use Only
  77946. */
  77947. reserved: boolean;
  77948. /**
  77949. * Gets the loaded texture
  77950. */
  77951. texture: HDRCubeTexture;
  77952. /**
  77953. * Callback called when the task is successful
  77954. */
  77955. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77956. /**
  77957. * Callback called when the task is successful
  77958. */
  77959. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77960. /**
  77961. * Creates a new HDRCubeTextureAssetTask object
  77962. * @param name defines the name of the task
  77963. * @param url defines the location of the file to load
  77964. * @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.
  77965. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77966. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77967. * @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)
  77968. * @param reserved Internal use only
  77969. */
  77970. constructor(
  77971. /**
  77972. * Defines the name of the task
  77973. */
  77974. name: string,
  77975. /**
  77976. * Defines the location of the file to load
  77977. */
  77978. url: string,
  77979. /**
  77980. * Defines the desired size (the more it increases the longer the generation will be)
  77981. */
  77982. size: number,
  77983. /**
  77984. * Defines if mipmaps should not be generated (default is false)
  77985. */
  77986. noMipmap?: boolean,
  77987. /**
  77988. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77989. */
  77990. generateHarmonics?: boolean,
  77991. /**
  77992. * 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)
  77993. */
  77994. gammaSpace?: boolean,
  77995. /**
  77996. * Internal Use Only
  77997. */
  77998. reserved?: boolean);
  77999. /**
  78000. * Execute the current task
  78001. * @param scene defines the scene where you want your assets to be loaded
  78002. * @param onSuccess is a callback called when the task is successfully executed
  78003. * @param onError is a callback called if an error occurs
  78004. */
  78005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78006. }
  78007. /**
  78008. * Define a task used by AssetsManager to load Equirectangular cube textures
  78009. */
  78010. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78011. /**
  78012. * Defines the name of the task
  78013. */
  78014. name: string;
  78015. /**
  78016. * Defines the location of the file to load
  78017. */
  78018. url: string;
  78019. /**
  78020. * Defines the desired size (the more it increases the longer the generation will be)
  78021. */
  78022. size: number;
  78023. /**
  78024. * Defines if mipmaps should not be generated (default is false)
  78025. */
  78026. noMipmap: boolean;
  78027. /**
  78028. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78029. * but the standard material would require them in Gamma space) (default is true)
  78030. */
  78031. gammaSpace: boolean;
  78032. /**
  78033. * Gets the loaded texture
  78034. */
  78035. texture: EquiRectangularCubeTexture;
  78036. /**
  78037. * Callback called when the task is successful
  78038. */
  78039. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78040. /**
  78041. * Callback called when the task is successful
  78042. */
  78043. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78044. /**
  78045. * Creates a new EquiRectangularCubeTextureAssetTask object
  78046. * @param name defines the name of the task
  78047. * @param url defines the location of the file to load
  78048. * @param size defines the desired size (the more it increases the longer the generation will be)
  78049. * If the size is omitted this implies you are using a preprocessed cubemap.
  78050. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78051. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78052. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78053. * (default is true)
  78054. */
  78055. constructor(
  78056. /**
  78057. * Defines the name of the task
  78058. */
  78059. name: string,
  78060. /**
  78061. * Defines the location of the file to load
  78062. */
  78063. url: string,
  78064. /**
  78065. * Defines the desired size (the more it increases the longer the generation will be)
  78066. */
  78067. size: number,
  78068. /**
  78069. * Defines if mipmaps should not be generated (default is false)
  78070. */
  78071. noMipmap?: boolean,
  78072. /**
  78073. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78074. * but the standard material would require them in Gamma space) (default is true)
  78075. */
  78076. gammaSpace?: boolean);
  78077. /**
  78078. * Execute the current task
  78079. * @param scene defines the scene where you want your assets to be loaded
  78080. * @param onSuccess is a callback called when the task is successfully executed
  78081. * @param onError is a callback called if an error occurs
  78082. */
  78083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78084. }
  78085. /**
  78086. * This class can be used to easily import assets into a scene
  78087. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78088. */
  78089. export class AssetsManager {
  78090. private _scene;
  78091. private _isLoading;
  78092. protected _tasks: AbstractAssetTask[];
  78093. protected _waitingTasksCount: number;
  78094. protected _totalTasksCount: number;
  78095. /**
  78096. * Callback called when all tasks are processed
  78097. */
  78098. onFinish: (tasks: AbstractAssetTask[]) => void;
  78099. /**
  78100. * Callback called when a task is successful
  78101. */
  78102. onTaskSuccess: (task: AbstractAssetTask) => void;
  78103. /**
  78104. * Callback called when a task had an error
  78105. */
  78106. onTaskError: (task: AbstractAssetTask) => void;
  78107. /**
  78108. * Callback called when a task is done (whatever the result is)
  78109. */
  78110. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78111. /**
  78112. * Observable called when all tasks are processed
  78113. */
  78114. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78115. /**
  78116. * Observable called when a task had an error
  78117. */
  78118. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78119. /**
  78120. * Observable called when all tasks were executed
  78121. */
  78122. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78123. /**
  78124. * Observable called when a task is done (whatever the result is)
  78125. */
  78126. onProgressObservable: Observable<IAssetsProgressEvent>;
  78127. /**
  78128. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78129. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78130. */
  78131. useDefaultLoadingScreen: boolean;
  78132. /**
  78133. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78134. * when all assets have been downloaded.
  78135. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78136. */
  78137. autoHideLoadingUI: boolean;
  78138. /**
  78139. * Creates a new AssetsManager
  78140. * @param scene defines the scene to work on
  78141. */
  78142. constructor(scene: Scene);
  78143. /**
  78144. * Add a ContainerAssetTask to the list of active tasks
  78145. * @param taskName defines the name of the new task
  78146. * @param meshesNames defines the name of meshes to load
  78147. * @param rootUrl defines the root url to use to locate files
  78148. * @param sceneFilename defines the filename of the scene file
  78149. * @returns a new ContainerAssetTask object
  78150. */
  78151. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78152. /**
  78153. * Add a MeshAssetTask to the list of active tasks
  78154. * @param taskName defines the name of the new task
  78155. * @param meshesNames defines the name of meshes to load
  78156. * @param rootUrl defines the root url to use to locate files
  78157. * @param sceneFilename defines the filename of the scene file
  78158. * @returns a new MeshAssetTask object
  78159. */
  78160. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78161. /**
  78162. * Add a TextFileAssetTask to the list of active tasks
  78163. * @param taskName defines the name of the new task
  78164. * @param url defines the url of the file to load
  78165. * @returns a new TextFileAssetTask object
  78166. */
  78167. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78168. /**
  78169. * Add a BinaryFileAssetTask to the list of active tasks
  78170. * @param taskName defines the name of the new task
  78171. * @param url defines the url of the file to load
  78172. * @returns a new BinaryFileAssetTask object
  78173. */
  78174. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78175. /**
  78176. * Add a ImageAssetTask to the list of active tasks
  78177. * @param taskName defines the name of the new task
  78178. * @param url defines the url of the file to load
  78179. * @returns a new ImageAssetTask object
  78180. */
  78181. addImageTask(taskName: string, url: string): ImageAssetTask;
  78182. /**
  78183. * Add a TextureAssetTask to the list of active tasks
  78184. * @param taskName defines the name of the new task
  78185. * @param url defines the url of the file to load
  78186. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78187. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78188. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78189. * @returns a new TextureAssetTask object
  78190. */
  78191. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78192. /**
  78193. * Add a CubeTextureAssetTask to the list of active tasks
  78194. * @param taskName defines the name of the new task
  78195. * @param url defines the url of the file to load
  78196. * @param extensions defines the extension to use to load the cube map (can be null)
  78197. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78198. * @param files defines the list of files to load (can be null)
  78199. * @returns a new CubeTextureAssetTask object
  78200. */
  78201. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78202. /**
  78203. *
  78204. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78205. * @param taskName defines the name of the new task
  78206. * @param url defines the url of the file to load
  78207. * @param size defines the size you want for the cubemap (can be null)
  78208. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78209. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78210. * @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)
  78211. * @param reserved Internal use only
  78212. * @returns a new HDRCubeTextureAssetTask object
  78213. */
  78214. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78215. /**
  78216. *
  78217. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78218. * @param taskName defines the name of the new task
  78219. * @param url defines the url of the file to load
  78220. * @param size defines the size you want for the cubemap (can be null)
  78221. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78222. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78223. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78224. * @returns a new EquiRectangularCubeTextureAssetTask object
  78225. */
  78226. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78227. /**
  78228. * Remove a task from the assets manager.
  78229. * @param task the task to remove
  78230. */
  78231. removeTask(task: AbstractAssetTask): void;
  78232. private _decreaseWaitingTasksCount;
  78233. private _runTask;
  78234. /**
  78235. * Reset the AssetsManager and remove all tasks
  78236. * @return the current instance of the AssetsManager
  78237. */
  78238. reset(): AssetsManager;
  78239. /**
  78240. * Start the loading process
  78241. * @return the current instance of the AssetsManager
  78242. */
  78243. load(): AssetsManager;
  78244. /**
  78245. * Start the loading process as an async operation
  78246. * @return a promise returning the list of failed tasks
  78247. */
  78248. loadAsync(): Promise<void>;
  78249. }
  78250. }
  78251. declare module BABYLON {
  78252. /**
  78253. * Wrapper class for promise with external resolve and reject.
  78254. */
  78255. export class Deferred<T> {
  78256. /**
  78257. * The promise associated with this deferred object.
  78258. */
  78259. readonly promise: Promise<T>;
  78260. private _resolve;
  78261. private _reject;
  78262. /**
  78263. * The resolve method of the promise associated with this deferred object.
  78264. */
  78265. get resolve(): (value: T | PromiseLike<T>) => void;
  78266. /**
  78267. * The reject method of the promise associated with this deferred object.
  78268. */
  78269. get reject(): (reason?: any) => void;
  78270. /**
  78271. * Constructor for this deferred object.
  78272. */
  78273. constructor();
  78274. }
  78275. }
  78276. declare module BABYLON {
  78277. /**
  78278. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78279. */
  78280. export class MeshExploder {
  78281. private _centerMesh;
  78282. private _meshes;
  78283. private _meshesOrigins;
  78284. private _toCenterVectors;
  78285. private _scaledDirection;
  78286. private _newPosition;
  78287. private _centerPosition;
  78288. /**
  78289. * Explodes meshes from a center mesh.
  78290. * @param meshes The meshes to explode.
  78291. * @param centerMesh The mesh to be center of explosion.
  78292. */
  78293. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78294. private _setCenterMesh;
  78295. /**
  78296. * Get class name
  78297. * @returns "MeshExploder"
  78298. */
  78299. getClassName(): string;
  78300. /**
  78301. * "Exploded meshes"
  78302. * @returns Array of meshes with the centerMesh at index 0.
  78303. */
  78304. getMeshes(): Array<Mesh>;
  78305. /**
  78306. * Explodes meshes giving a specific direction
  78307. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78308. */
  78309. explode(direction?: number): void;
  78310. }
  78311. }
  78312. declare module BABYLON {
  78313. /**
  78314. * Class used to help managing file picking and drag'n'drop
  78315. */
  78316. export class FilesInput {
  78317. /**
  78318. * List of files ready to be loaded
  78319. */
  78320. static get FilesToLoad(): {
  78321. [key: string]: File;
  78322. };
  78323. /**
  78324. * Callback called when a file is processed
  78325. */
  78326. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78327. /**
  78328. * Function used when loading the scene file
  78329. */
  78330. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78331. private _engine;
  78332. private _currentScene;
  78333. private _sceneLoadedCallback;
  78334. private _progressCallback;
  78335. private _additionalRenderLoopLogicCallback;
  78336. private _textureLoadingCallback;
  78337. private _startingProcessingFilesCallback;
  78338. private _onReloadCallback;
  78339. private _errorCallback;
  78340. private _elementToMonitor;
  78341. private _sceneFileToLoad;
  78342. private _filesToLoad;
  78343. /**
  78344. * Creates a new FilesInput
  78345. * @param engine defines the rendering engine
  78346. * @param scene defines the hosting scene
  78347. * @param sceneLoadedCallback callback called when scene is loaded
  78348. * @param progressCallback callback called to track progress
  78349. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78350. * @param textureLoadingCallback callback called when a texture is loading
  78351. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78352. * @param onReloadCallback callback called when a reload is requested
  78353. * @param errorCallback callback call if an error occurs
  78354. */
  78355. 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>);
  78356. private _dragEnterHandler;
  78357. private _dragOverHandler;
  78358. private _dropHandler;
  78359. /**
  78360. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78361. * @param elementToMonitor defines the DOM element to track
  78362. */
  78363. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78364. /** Gets the current list of files to load */
  78365. get filesToLoad(): File[];
  78366. /**
  78367. * Release all associated resources
  78368. */
  78369. dispose(): void;
  78370. private renderFunction;
  78371. private drag;
  78372. private drop;
  78373. private _traverseFolder;
  78374. private _processFiles;
  78375. /**
  78376. * Load files from a drop event
  78377. * @param event defines the drop event to use as source
  78378. */
  78379. loadFiles(event: any): void;
  78380. private _processReload;
  78381. /**
  78382. * Reload the current scene from the loaded files
  78383. */
  78384. reload(): void;
  78385. }
  78386. }
  78387. declare module BABYLON {
  78388. /**
  78389. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78390. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78391. */
  78392. export class SceneOptimization {
  78393. /**
  78394. * Defines the priority of this optimization (0 by default which means first in the list)
  78395. */
  78396. priority: number;
  78397. /**
  78398. * Gets a string describing the action executed by the current optimization
  78399. * @returns description string
  78400. */
  78401. getDescription(): string;
  78402. /**
  78403. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78404. * @param scene defines the current scene where to apply this optimization
  78405. * @param optimizer defines the current optimizer
  78406. * @returns true if everything that can be done was applied
  78407. */
  78408. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78409. /**
  78410. * Creates the SceneOptimization object
  78411. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78412. * @param desc defines the description associated with the optimization
  78413. */
  78414. constructor(
  78415. /**
  78416. * Defines the priority of this optimization (0 by default which means first in the list)
  78417. */
  78418. priority?: number);
  78419. }
  78420. /**
  78421. * Defines an optimization used to reduce the size of render target textures
  78422. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78423. */
  78424. export class TextureOptimization extends SceneOptimization {
  78425. /**
  78426. * Defines the priority of this optimization (0 by default which means first in the list)
  78427. */
  78428. priority: number;
  78429. /**
  78430. * 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
  78431. */
  78432. maximumSize: number;
  78433. /**
  78434. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78435. */
  78436. step: number;
  78437. /**
  78438. * Gets a string describing the action executed by the current optimization
  78439. * @returns description string
  78440. */
  78441. getDescription(): string;
  78442. /**
  78443. * Creates the TextureOptimization object
  78444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78445. * @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
  78446. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78447. */
  78448. constructor(
  78449. /**
  78450. * Defines the priority of this optimization (0 by default which means first in the list)
  78451. */
  78452. priority?: number,
  78453. /**
  78454. * 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
  78455. */
  78456. maximumSize?: number,
  78457. /**
  78458. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78459. */
  78460. step?: number);
  78461. /**
  78462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78463. * @param scene defines the current scene where to apply this optimization
  78464. * @param optimizer defines the current optimizer
  78465. * @returns true if everything that can be done was applied
  78466. */
  78467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78468. }
  78469. /**
  78470. * Defines an optimization used to increase or decrease the rendering resolution
  78471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78472. */
  78473. export class HardwareScalingOptimization extends SceneOptimization {
  78474. /**
  78475. * Defines the priority of this optimization (0 by default which means first in the list)
  78476. */
  78477. priority: number;
  78478. /**
  78479. * Defines the maximum scale to use (2 by default)
  78480. */
  78481. maximumScale: number;
  78482. /**
  78483. * Defines the step to use between two passes (0.5 by default)
  78484. */
  78485. step: number;
  78486. private _currentScale;
  78487. private _directionOffset;
  78488. /**
  78489. * Gets a string describing the action executed by the current optimization
  78490. * @return description string
  78491. */
  78492. getDescription(): string;
  78493. /**
  78494. * Creates the HardwareScalingOptimization object
  78495. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78496. * @param maximumScale defines the maximum scale to use (2 by default)
  78497. * @param step defines the step to use between two passes (0.5 by default)
  78498. */
  78499. constructor(
  78500. /**
  78501. * Defines the priority of this optimization (0 by default which means first in the list)
  78502. */
  78503. priority?: number,
  78504. /**
  78505. * Defines the maximum scale to use (2 by default)
  78506. */
  78507. maximumScale?: number,
  78508. /**
  78509. * Defines the step to use between two passes (0.5 by default)
  78510. */
  78511. step?: number);
  78512. /**
  78513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78514. * @param scene defines the current scene where to apply this optimization
  78515. * @param optimizer defines the current optimizer
  78516. * @returns true if everything that can be done was applied
  78517. */
  78518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78519. }
  78520. /**
  78521. * Defines an optimization used to remove shadows
  78522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78523. */
  78524. export class ShadowsOptimization extends SceneOptimization {
  78525. /**
  78526. * Gets a string describing the action executed by the current optimization
  78527. * @return description string
  78528. */
  78529. getDescription(): string;
  78530. /**
  78531. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78532. * @param scene defines the current scene where to apply this optimization
  78533. * @param optimizer defines the current optimizer
  78534. * @returns true if everything that can be done was applied
  78535. */
  78536. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78537. }
  78538. /**
  78539. * Defines an optimization used to turn post-processes off
  78540. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78541. */
  78542. export class PostProcessesOptimization extends SceneOptimization {
  78543. /**
  78544. * Gets a string describing the action executed by the current optimization
  78545. * @return description string
  78546. */
  78547. getDescription(): string;
  78548. /**
  78549. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78550. * @param scene defines the current scene where to apply this optimization
  78551. * @param optimizer defines the current optimizer
  78552. * @returns true if everything that can be done was applied
  78553. */
  78554. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78555. }
  78556. /**
  78557. * Defines an optimization used to turn lens flares off
  78558. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78559. */
  78560. export class LensFlaresOptimization extends SceneOptimization {
  78561. /**
  78562. * Gets a string describing the action executed by the current optimization
  78563. * @return description string
  78564. */
  78565. getDescription(): string;
  78566. /**
  78567. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78568. * @param scene defines the current scene where to apply this optimization
  78569. * @param optimizer defines the current optimizer
  78570. * @returns true if everything that can be done was applied
  78571. */
  78572. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78573. }
  78574. /**
  78575. * Defines an optimization based on user defined callback.
  78576. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78577. */
  78578. export class CustomOptimization extends SceneOptimization {
  78579. /**
  78580. * Callback called to apply the custom optimization.
  78581. */
  78582. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78583. /**
  78584. * Callback called to get custom description
  78585. */
  78586. onGetDescription: () => string;
  78587. /**
  78588. * Gets a string describing the action executed by the current optimization
  78589. * @returns description string
  78590. */
  78591. getDescription(): string;
  78592. /**
  78593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78594. * @param scene defines the current scene where to apply this optimization
  78595. * @param optimizer defines the current optimizer
  78596. * @returns true if everything that can be done was applied
  78597. */
  78598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78599. }
  78600. /**
  78601. * Defines an optimization used to turn particles off
  78602. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78603. */
  78604. export class ParticlesOptimization extends SceneOptimization {
  78605. /**
  78606. * Gets a string describing the action executed by the current optimization
  78607. * @return description string
  78608. */
  78609. getDescription(): string;
  78610. /**
  78611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78612. * @param scene defines the current scene where to apply this optimization
  78613. * @param optimizer defines the current optimizer
  78614. * @returns true if everything that can be done was applied
  78615. */
  78616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78617. }
  78618. /**
  78619. * Defines an optimization used to turn render targets off
  78620. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78621. */
  78622. export class RenderTargetsOptimization extends SceneOptimization {
  78623. /**
  78624. * Gets a string describing the action executed by the current optimization
  78625. * @return description string
  78626. */
  78627. getDescription(): string;
  78628. /**
  78629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78630. * @param scene defines the current scene where to apply this optimization
  78631. * @param optimizer defines the current optimizer
  78632. * @returns true if everything that can be done was applied
  78633. */
  78634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78635. }
  78636. /**
  78637. * Defines an optimization used to merge meshes with compatible materials
  78638. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78639. */
  78640. export class MergeMeshesOptimization extends SceneOptimization {
  78641. private static _UpdateSelectionTree;
  78642. /**
  78643. * Gets or sets a boolean which defines if optimization octree has to be updated
  78644. */
  78645. static get UpdateSelectionTree(): boolean;
  78646. /**
  78647. * Gets or sets a boolean which defines if optimization octree has to be updated
  78648. */
  78649. static set UpdateSelectionTree(value: boolean);
  78650. /**
  78651. * Gets a string describing the action executed by the current optimization
  78652. * @return description string
  78653. */
  78654. getDescription(): string;
  78655. private _canBeMerged;
  78656. /**
  78657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78658. * @param scene defines the current scene where to apply this optimization
  78659. * @param optimizer defines the current optimizer
  78660. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78661. * @returns true if everything that can be done was applied
  78662. */
  78663. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78664. }
  78665. /**
  78666. * Defines a list of options used by SceneOptimizer
  78667. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78668. */
  78669. export class SceneOptimizerOptions {
  78670. /**
  78671. * Defines the target frame rate to reach (60 by default)
  78672. */
  78673. targetFrameRate: number;
  78674. /**
  78675. * Defines the interval between two checks (2000ms by default)
  78676. */
  78677. trackerDuration: number;
  78678. /**
  78679. * Gets the list of optimizations to apply
  78680. */
  78681. optimizations: SceneOptimization[];
  78682. /**
  78683. * Creates a new list of options used by SceneOptimizer
  78684. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78685. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78686. */
  78687. constructor(
  78688. /**
  78689. * Defines the target frame rate to reach (60 by default)
  78690. */
  78691. targetFrameRate?: number,
  78692. /**
  78693. * Defines the interval between two checks (2000ms by default)
  78694. */
  78695. trackerDuration?: number);
  78696. /**
  78697. * Add a new optimization
  78698. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78699. * @returns the current SceneOptimizerOptions
  78700. */
  78701. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78702. /**
  78703. * Add a new custom optimization
  78704. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78705. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78706. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78707. * @returns the current SceneOptimizerOptions
  78708. */
  78709. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78710. /**
  78711. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78712. * @param targetFrameRate defines the target frame rate (60 by default)
  78713. * @returns a SceneOptimizerOptions object
  78714. */
  78715. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78716. /**
  78717. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78718. * @param targetFrameRate defines the target frame rate (60 by default)
  78719. * @returns a SceneOptimizerOptions object
  78720. */
  78721. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78722. /**
  78723. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78724. * @param targetFrameRate defines the target frame rate (60 by default)
  78725. * @returns a SceneOptimizerOptions object
  78726. */
  78727. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78728. }
  78729. /**
  78730. * Class used to run optimizations in order to reach a target frame rate
  78731. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78732. */
  78733. export class SceneOptimizer implements IDisposable {
  78734. private _isRunning;
  78735. private _options;
  78736. private _scene;
  78737. private _currentPriorityLevel;
  78738. private _targetFrameRate;
  78739. private _trackerDuration;
  78740. private _currentFrameRate;
  78741. private _sceneDisposeObserver;
  78742. private _improvementMode;
  78743. /**
  78744. * Defines an observable called when the optimizer reaches the target frame rate
  78745. */
  78746. onSuccessObservable: Observable<SceneOptimizer>;
  78747. /**
  78748. * Defines an observable called when the optimizer enables an optimization
  78749. */
  78750. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78751. /**
  78752. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78753. */
  78754. onFailureObservable: Observable<SceneOptimizer>;
  78755. /**
  78756. * Gets a boolean indicating if the optimizer is in improvement mode
  78757. */
  78758. get isInImprovementMode(): boolean;
  78759. /**
  78760. * Gets the current priority level (0 at start)
  78761. */
  78762. get currentPriorityLevel(): number;
  78763. /**
  78764. * Gets the current frame rate checked by the SceneOptimizer
  78765. */
  78766. get currentFrameRate(): number;
  78767. /**
  78768. * Gets or sets the current target frame rate (60 by default)
  78769. */
  78770. get targetFrameRate(): number;
  78771. /**
  78772. * Gets or sets the current target frame rate (60 by default)
  78773. */
  78774. set targetFrameRate(value: number);
  78775. /**
  78776. * Gets or sets the current interval between two checks (every 2000ms by default)
  78777. */
  78778. get trackerDuration(): number;
  78779. /**
  78780. * Gets or sets the current interval between two checks (every 2000ms by default)
  78781. */
  78782. set trackerDuration(value: number);
  78783. /**
  78784. * Gets the list of active optimizations
  78785. */
  78786. get optimizations(): SceneOptimization[];
  78787. /**
  78788. * Creates a new SceneOptimizer
  78789. * @param scene defines the scene to work on
  78790. * @param options defines the options to use with the SceneOptimizer
  78791. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78792. * @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)
  78793. */
  78794. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78795. /**
  78796. * Stops the current optimizer
  78797. */
  78798. stop(): void;
  78799. /**
  78800. * Reset the optimizer to initial step (current priority level = 0)
  78801. */
  78802. reset(): void;
  78803. /**
  78804. * Start the optimizer. By default it will try to reach a specific framerate
  78805. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78806. */
  78807. start(): void;
  78808. private _checkCurrentState;
  78809. /**
  78810. * Release all resources
  78811. */
  78812. dispose(): void;
  78813. /**
  78814. * Helper function to create a SceneOptimizer with one single line of code
  78815. * @param scene defines the scene to work on
  78816. * @param options defines the options to use with the SceneOptimizer
  78817. * @param onSuccess defines a callback to call on success
  78818. * @param onFailure defines a callback to call on failure
  78819. * @returns the new SceneOptimizer object
  78820. */
  78821. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78822. }
  78823. }
  78824. declare module BABYLON {
  78825. /**
  78826. * Class used to serialize a scene into a string
  78827. */
  78828. export class SceneSerializer {
  78829. /**
  78830. * Clear cache used by a previous serialization
  78831. */
  78832. static ClearCache(): void;
  78833. /**
  78834. * Serialize a scene into a JSON compatible object
  78835. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78836. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78837. * @param scene defines the scene to serialize
  78838. * @returns a JSON compatible object
  78839. */
  78840. static Serialize(scene: Scene): any;
  78841. private static _Serialize;
  78842. /**
  78843. * Serialize a scene into a JSON compatible object
  78844. * @param scene defines the scene to serialize
  78845. * @returns a JSON promise compatible object
  78846. */
  78847. static SerializeAsync(scene: Scene): Promise<any>;
  78848. private static _CollectPromises;
  78849. /**
  78850. * Serialize a mesh into a JSON compatible object
  78851. * @param toSerialize defines the mesh to serialize
  78852. * @param withParents defines if parents must be serialized as well
  78853. * @param withChildren defines if children must be serialized as well
  78854. * @returns a JSON compatible object
  78855. */
  78856. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78857. }
  78858. }
  78859. declare module BABYLON {
  78860. /**
  78861. * This represents the different options available for the video capture.
  78862. */
  78863. export interface VideoRecorderOptions {
  78864. /** Defines the mime type of the video. */
  78865. mimeType: string;
  78866. /** Defines the FPS the video should be recorded at. */
  78867. fps: number;
  78868. /** Defines the chunk size for the recording data. */
  78869. recordChunckSize: number;
  78870. /** The audio tracks to attach to the recording. */
  78871. audioTracks?: MediaStreamTrack[];
  78872. }
  78873. /**
  78874. * This can help with recording videos from BabylonJS.
  78875. * This is based on the available WebRTC functionalities of the browser.
  78876. *
  78877. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78878. */
  78879. export class VideoRecorder {
  78880. private static readonly _defaultOptions;
  78881. /**
  78882. * Returns whether or not the VideoRecorder is available in your browser.
  78883. * @param engine Defines the Babylon Engine.
  78884. * @returns true if supported otherwise false.
  78885. */
  78886. static IsSupported(engine: Engine): boolean;
  78887. private readonly _options;
  78888. private _canvas;
  78889. private _mediaRecorder;
  78890. private _recordedChunks;
  78891. private _fileName;
  78892. private _resolve;
  78893. private _reject;
  78894. /**
  78895. * True when a recording is already in progress.
  78896. */
  78897. get isRecording(): boolean;
  78898. /**
  78899. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78900. * @param engine Defines the BabylonJS Engine you wish to record.
  78901. * @param options Defines options that can be used to customize the capture.
  78902. */
  78903. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78904. /**
  78905. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78906. */
  78907. stopRecording(): void;
  78908. /**
  78909. * Starts recording the canvas for a max duration specified in parameters.
  78910. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78911. * If null no automatic download will start and you can rely on the promise to get the data back.
  78912. * @param maxDuration Defines the maximum recording time in seconds.
  78913. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78914. * @return A promise callback at the end of the recording with the video data in Blob.
  78915. */
  78916. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78917. /**
  78918. * Releases internal resources used during the recording.
  78919. */
  78920. dispose(): void;
  78921. private _handleDataAvailable;
  78922. private _handleError;
  78923. private _handleStop;
  78924. }
  78925. }
  78926. declare module BABYLON {
  78927. /**
  78928. * Class containing a set of static utilities functions for screenshots
  78929. */
  78930. export class ScreenshotTools {
  78931. /**
  78932. * Captures a screenshot of the current rendering
  78933. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78934. * @param engine defines the rendering engine
  78935. * @param camera defines the source camera
  78936. * @param size This parameter can be set to a single number or to an object with the
  78937. * following (optional) properties: precision, width, height. If a single number is passed,
  78938. * it will be used for both width and height. If an object is passed, the screenshot size
  78939. * will be derived from the parameters. The precision property is a multiplier allowing
  78940. * rendering at a higher or lower resolution
  78941. * @param successCallback defines the callback receives a single parameter which contains the
  78942. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78943. * src parameter of an <img> to display it
  78944. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78945. * Check your browser for supported MIME types
  78946. * @param forceDownload force the system to download the image even if a successCallback is provided
  78947. */
  78948. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78949. /**
  78950. * Captures a screenshot of the current rendering
  78951. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78952. * @param engine defines the rendering engine
  78953. * @param camera defines the source camera
  78954. * @param size This parameter can be set to a single number or to an object with the
  78955. * following (optional) properties: precision, width, height. If a single number is passed,
  78956. * it will be used for both width and height. If an object is passed, the screenshot size
  78957. * will be derived from the parameters. The precision property is a multiplier allowing
  78958. * rendering at a higher or lower resolution
  78959. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78960. * Check your browser for supported MIME types
  78961. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78962. * to the src parameter of an <img> to display it
  78963. */
  78964. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78965. /**
  78966. * 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)
  78967. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78968. * @param engine defines the rendering engine
  78969. * @param camera defines the source camera
  78970. * @param width defines the expected width
  78971. * @param height defines the expected height
  78972. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78973. * Check your browser for supported MIME types
  78974. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78975. * to the src parameter of an <img> to display it
  78976. */
  78977. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78978. /**
  78979. * Generates an image screenshot from the specified camera.
  78980. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78981. * @param engine The engine to use for rendering
  78982. * @param camera The camera to use for rendering
  78983. * @param size This parameter can be set to a single number or to an object with the
  78984. * following (optional) properties: precision, width, height. If a single number is passed,
  78985. * it will be used for both width and height. If an object is passed, the screenshot size
  78986. * will be derived from the parameters. The precision property is a multiplier allowing
  78987. * rendering at a higher or lower resolution
  78988. * @param successCallback The callback receives a single parameter which contains the
  78989. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78990. * src parameter of an <img> to display it
  78991. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78992. * Check your browser for supported MIME types
  78993. * @param samples Texture samples (default: 1)
  78994. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78995. * @param fileName A name for for the downloaded file.
  78996. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78997. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78998. */
  78999. 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;
  79000. /**
  79001. * Generates an image screenshot from the specified camera.
  79002. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79003. * @param engine The engine to use for rendering
  79004. * @param camera The camera to use for rendering
  79005. * @param size This parameter can be set to a single number or to an object with the
  79006. * following (optional) properties: precision, width, height. If a single number is passed,
  79007. * it will be used for both width and height. If an object is passed, the screenshot size
  79008. * will be derived from the parameters. The precision property is a multiplier allowing
  79009. * rendering at a higher or lower resolution
  79010. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79011. * Check your browser for supported MIME types
  79012. * @param samples Texture samples (default: 1)
  79013. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79014. * @param fileName A name for for the downloaded file.
  79015. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79016. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79017. * to the src parameter of an <img> to display it
  79018. */
  79019. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79020. /**
  79021. * Gets height and width for screenshot size
  79022. * @private
  79023. */
  79024. private static _getScreenshotSize;
  79025. }
  79026. }
  79027. declare module BABYLON {
  79028. /**
  79029. * Interface for a data buffer
  79030. */
  79031. export interface IDataBuffer {
  79032. /**
  79033. * Reads bytes from the data buffer.
  79034. * @param byteOffset The byte offset to read
  79035. * @param byteLength The byte length to read
  79036. * @returns A promise that resolves when the bytes are read
  79037. */
  79038. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79039. /**
  79040. * The byte length of the buffer.
  79041. */
  79042. readonly byteLength: number;
  79043. }
  79044. /**
  79045. * Utility class for reading from a data buffer
  79046. */
  79047. export class DataReader {
  79048. /**
  79049. * The data buffer associated with this data reader.
  79050. */
  79051. readonly buffer: IDataBuffer;
  79052. /**
  79053. * The current byte offset from the beginning of the data buffer.
  79054. */
  79055. byteOffset: number;
  79056. private _dataView;
  79057. private _dataByteOffset;
  79058. /**
  79059. * Constructor
  79060. * @param buffer The buffer to read
  79061. */
  79062. constructor(buffer: IDataBuffer);
  79063. /**
  79064. * Loads the given byte length.
  79065. * @param byteLength The byte length to load
  79066. * @returns A promise that resolves when the load is complete
  79067. */
  79068. loadAsync(byteLength: number): Promise<void>;
  79069. /**
  79070. * Read a unsigned 32-bit integer from the currently loaded data range.
  79071. * @returns The 32-bit integer read
  79072. */
  79073. readUint32(): number;
  79074. /**
  79075. * Read a byte array from the currently loaded data range.
  79076. * @param byteLength The byte length to read
  79077. * @returns The byte array read
  79078. */
  79079. readUint8Array(byteLength: number): Uint8Array;
  79080. /**
  79081. * Read a string from the currently loaded data range.
  79082. * @param byteLength The byte length to read
  79083. * @returns The string read
  79084. */
  79085. readString(byteLength: number): string;
  79086. /**
  79087. * Skips the given byte length the currently loaded data range.
  79088. * @param byteLength The byte length to skip
  79089. */
  79090. skipBytes(byteLength: number): void;
  79091. }
  79092. }
  79093. declare module BABYLON {
  79094. /**
  79095. * Class for storing data to local storage if available or in-memory storage otherwise
  79096. */
  79097. export class DataStorage {
  79098. private static _Storage;
  79099. private static _GetStorage;
  79100. /**
  79101. * Reads a string from the data storage
  79102. * @param key The key to read
  79103. * @param defaultValue The value if the key doesn't exist
  79104. * @returns The string value
  79105. */
  79106. static ReadString(key: string, defaultValue: string): string;
  79107. /**
  79108. * Writes a string to the data storage
  79109. * @param key The key to write
  79110. * @param value The value to write
  79111. */
  79112. static WriteString(key: string, value: string): void;
  79113. /**
  79114. * Reads a boolean from the data storage
  79115. * @param key The key to read
  79116. * @param defaultValue The value if the key doesn't exist
  79117. * @returns The boolean value
  79118. */
  79119. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79120. /**
  79121. * Writes a boolean to the data storage
  79122. * @param key The key to write
  79123. * @param value The value to write
  79124. */
  79125. static WriteBoolean(key: string, value: boolean): void;
  79126. /**
  79127. * Reads a number from the data storage
  79128. * @param key The key to read
  79129. * @param defaultValue The value if the key doesn't exist
  79130. * @returns The number value
  79131. */
  79132. static ReadNumber(key: string, defaultValue: number): number;
  79133. /**
  79134. * Writes a number to the data storage
  79135. * @param key The key to write
  79136. * @param value The value to write
  79137. */
  79138. static WriteNumber(key: string, value: number): void;
  79139. }
  79140. }
  79141. declare module BABYLON {
  79142. /**
  79143. * Class used to record delta files between 2 scene states
  79144. */
  79145. export class SceneRecorder {
  79146. private _trackedScene;
  79147. private _savedJSON;
  79148. /**
  79149. * Track a given scene. This means the current scene state will be considered the original state
  79150. * @param scene defines the scene to track
  79151. */
  79152. track(scene: Scene): void;
  79153. /**
  79154. * Get the delta between current state and original state
  79155. * @returns a any containing the delta
  79156. */
  79157. getDelta(): any;
  79158. private _compareArray;
  79159. private _compareObjects;
  79160. private _compareCollections;
  79161. private static GetShadowGeneratorById;
  79162. /**
  79163. * Apply a given delta to a given scene
  79164. * @param deltaJSON defines the JSON containing the delta
  79165. * @param scene defines the scene to apply the delta to
  79166. */
  79167. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79168. private static _ApplyPropertiesToEntity;
  79169. private static _ApplyDeltaForEntity;
  79170. }
  79171. }
  79172. declare module BABYLON {
  79173. /**
  79174. * A 3D trajectory consisting of an order list of vectors describing a
  79175. * path of motion through 3D space.
  79176. */
  79177. export class Trajectory {
  79178. private _points;
  79179. private readonly _segmentLength;
  79180. /**
  79181. * Serialize to JSON.
  79182. * @returns serialized JSON string
  79183. */
  79184. serialize(): string;
  79185. /**
  79186. * Deserialize from JSON.
  79187. * @param json serialized JSON string
  79188. * @returns deserialized Trajectory
  79189. */
  79190. static Deserialize(json: string): Trajectory;
  79191. /**
  79192. * Create a new empty Trajectory.
  79193. * @param segmentLength radius of discretization for Trajectory points
  79194. */
  79195. constructor(segmentLength?: number);
  79196. /**
  79197. * Get the length of the Trajectory.
  79198. * @returns length of the Trajectory
  79199. */
  79200. getLength(): number;
  79201. /**
  79202. * Append a new point to the Trajectory.
  79203. * NOTE: This implementation has many allocations.
  79204. * @param point point to append to the Trajectory
  79205. */
  79206. add(point: DeepImmutable<Vector3>): void;
  79207. /**
  79208. * Create a new Trajectory with a segment length chosen to make it
  79209. * probable that the new Trajectory will have a specified number of
  79210. * segments. This operation is imprecise.
  79211. * @param targetResolution number of segments desired
  79212. * @returns new Trajectory with approximately the requested number of segments
  79213. */
  79214. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79215. /**
  79216. * Convert Trajectory segments into tokenized representation. This
  79217. * representation is an array of numbers where each nth number is the
  79218. * index of the token which is most similar to the nth segment of the
  79219. * Trajectory.
  79220. * @param tokens list of vectors which serve as discrete tokens
  79221. * @returns list of indices of most similar token per segment
  79222. */
  79223. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79224. private static _forwardDir;
  79225. private static _inverseFromVec;
  79226. private static _upDir;
  79227. private static _fromToVec;
  79228. private static _lookMatrix;
  79229. /**
  79230. * Transform the rotation (i.e., direction) of a segment to isolate
  79231. * the relative transformation represented by the segment. This operation
  79232. * may or may not succeed due to singularities in the equations that define
  79233. * motion relativity in this context.
  79234. * @param priorVec the origin of the prior segment
  79235. * @param fromVec the origin of the current segment
  79236. * @param toVec the destination of the current segment
  79237. * @param result reference to output variable
  79238. * @returns whether or not transformation was successful
  79239. */
  79240. private static _transformSegmentDirToRef;
  79241. private static _bestMatch;
  79242. private static _score;
  79243. private static _bestScore;
  79244. /**
  79245. * Determine which token vector is most similar to the
  79246. * segment vector.
  79247. * @param segment segment vector
  79248. * @param tokens token vector list
  79249. * @returns index of the most similar token to the segment
  79250. */
  79251. private static _tokenizeSegment;
  79252. }
  79253. /**
  79254. * Class representing a set of known, named trajectories to which Trajectories can be
  79255. * added and using which Trajectories can be recognized.
  79256. */
  79257. export class TrajectoryClassifier {
  79258. private _maximumAllowableMatchCost;
  79259. private _vector3Alphabet;
  79260. private _levenshteinAlphabet;
  79261. private _nameToDescribedTrajectory;
  79262. /**
  79263. * Serialize to JSON.
  79264. * @returns JSON serialization
  79265. */
  79266. serialize(): string;
  79267. /**
  79268. * Deserialize from JSON.
  79269. * @param json JSON serialization
  79270. * @returns deserialized TrajectorySet
  79271. */
  79272. static Deserialize(json: string): TrajectoryClassifier;
  79273. /**
  79274. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79275. * VERY naive, need to be generating these things from known
  79276. * sets. Better version later, probably eliminating this one.
  79277. * @returns auto-generated TrajectorySet
  79278. */
  79279. static Generate(): TrajectoryClassifier;
  79280. private constructor();
  79281. /**
  79282. * Add a new Trajectory to the set with a given name.
  79283. * @param trajectory new Trajectory to be added
  79284. * @param classification name to which to add the Trajectory
  79285. */
  79286. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79287. /**
  79288. * Remove a known named trajectory and all Trajectories associated with it.
  79289. * @param classification name to remove
  79290. * @returns whether anything was removed
  79291. */
  79292. deleteClassification(classification: string): boolean;
  79293. /**
  79294. * Attempt to recognize a Trajectory from among all the classifications
  79295. * already known to the classifier.
  79296. * @param trajectory Trajectory to be recognized
  79297. * @returns classification of Trajectory if recognized, null otherwise
  79298. */
  79299. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79300. }
  79301. }
  79302. declare module BABYLON {
  79303. /**
  79304. * An interface for all Hit test features
  79305. */
  79306. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79307. /**
  79308. * Triggered when new babylon (transformed) hit test results are available
  79309. */
  79310. onHitTestResultObservable: Observable<T[]>;
  79311. }
  79312. /**
  79313. * Options used for hit testing
  79314. */
  79315. export interface IWebXRLegacyHitTestOptions {
  79316. /**
  79317. * Only test when user interacted with the scene. Default - hit test every frame
  79318. */
  79319. testOnPointerDownOnly?: boolean;
  79320. /**
  79321. * The node to use to transform the local results to world coordinates
  79322. */
  79323. worldParentNode?: TransformNode;
  79324. }
  79325. /**
  79326. * Interface defining the babylon result of raycasting/hit-test
  79327. */
  79328. export interface IWebXRLegacyHitResult {
  79329. /**
  79330. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79331. */
  79332. transformationMatrix: Matrix;
  79333. /**
  79334. * The native hit test result
  79335. */
  79336. xrHitResult: XRHitResult | XRHitTestResult;
  79337. }
  79338. /**
  79339. * The currently-working hit-test module.
  79340. * Hit test (or Ray-casting) is used to interact with the real world.
  79341. * For further information read here - https://github.com/immersive-web/hit-test
  79342. */
  79343. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79344. /**
  79345. * options to use when constructing this feature
  79346. */
  79347. readonly options: IWebXRLegacyHitTestOptions;
  79348. private _direction;
  79349. private _mat;
  79350. private _onSelectEnabled;
  79351. private _origin;
  79352. /**
  79353. * The module's name
  79354. */
  79355. static readonly Name: string;
  79356. /**
  79357. * The (Babylon) version of this module.
  79358. * This is an integer representing the implementation version.
  79359. * This number does not correspond to the WebXR specs version
  79360. */
  79361. static readonly Version: number;
  79362. /**
  79363. * Populated with the last native XR Hit Results
  79364. */
  79365. lastNativeXRHitResults: XRHitResult[];
  79366. /**
  79367. * Triggered when new babylon (transformed) hit test results are available
  79368. */
  79369. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79370. /**
  79371. * Creates a new instance of the (legacy version) hit test feature
  79372. * @param _xrSessionManager an instance of WebXRSessionManager
  79373. * @param options options to use when constructing this feature
  79374. */
  79375. constructor(_xrSessionManager: WebXRSessionManager,
  79376. /**
  79377. * options to use when constructing this feature
  79378. */
  79379. options?: IWebXRLegacyHitTestOptions);
  79380. /**
  79381. * execute a hit test with an XR Ray
  79382. *
  79383. * @param xrSession a native xrSession that will execute this hit test
  79384. * @param xrRay the ray (position and direction) to use for ray-casting
  79385. * @param referenceSpace native XR reference space to use for the hit-test
  79386. * @param filter filter function that will filter the results
  79387. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79388. */
  79389. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79390. /**
  79391. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79392. * @param event the (select) event to use to select with
  79393. * @param referenceSpace the reference space to use for this hit test
  79394. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79395. */
  79396. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79397. /**
  79398. * attach this feature
  79399. * Will usually be called by the features manager
  79400. *
  79401. * @returns true if successful.
  79402. */
  79403. attach(): boolean;
  79404. /**
  79405. * detach this feature.
  79406. * Will usually be called by the features manager
  79407. *
  79408. * @returns true if successful.
  79409. */
  79410. detach(): boolean;
  79411. /**
  79412. * Dispose this feature and all of the resources attached
  79413. */
  79414. dispose(): void;
  79415. protected _onXRFrame(frame: XRFrame): void;
  79416. private _onHitTestResults;
  79417. private _onSelect;
  79418. }
  79419. }
  79420. declare module BABYLON {
  79421. /**
  79422. * Options used for hit testing (version 2)
  79423. */
  79424. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79425. /**
  79426. * Do not create a permanent hit test. Will usually be used when only
  79427. * transient inputs are needed.
  79428. */
  79429. disablePermanentHitTest?: boolean;
  79430. /**
  79431. * Enable transient (for example touch-based) hit test inspections
  79432. */
  79433. enableTransientHitTest?: boolean;
  79434. /**
  79435. * Offset ray for the permanent hit test
  79436. */
  79437. offsetRay?: Vector3;
  79438. /**
  79439. * Offset ray for the transient hit test
  79440. */
  79441. transientOffsetRay?: Vector3;
  79442. /**
  79443. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79444. */
  79445. useReferenceSpace?: boolean;
  79446. /**
  79447. * Override the default entity type(s) of the hit-test result
  79448. */
  79449. entityTypes?: XRHitTestTrackableType[];
  79450. }
  79451. /**
  79452. * Interface defining the babylon result of hit-test
  79453. */
  79454. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79455. /**
  79456. * The input source that generated this hit test (if transient)
  79457. */
  79458. inputSource?: XRInputSource;
  79459. /**
  79460. * Is this a transient hit test
  79461. */
  79462. isTransient?: boolean;
  79463. /**
  79464. * Position of the hit test result
  79465. */
  79466. position: Vector3;
  79467. /**
  79468. * Rotation of the hit test result
  79469. */
  79470. rotationQuaternion: Quaternion;
  79471. /**
  79472. * The native hit test result
  79473. */
  79474. xrHitResult: XRHitTestResult;
  79475. }
  79476. /**
  79477. * The currently-working hit-test module.
  79478. * Hit test (or Ray-casting) is used to interact with the real world.
  79479. * For further information read here - https://github.com/immersive-web/hit-test
  79480. *
  79481. * Tested on chrome (mobile) 80.
  79482. */
  79483. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79484. /**
  79485. * options to use when constructing this feature
  79486. */
  79487. readonly options: IWebXRHitTestOptions;
  79488. private _tmpMat;
  79489. private _tmpPos;
  79490. private _tmpQuat;
  79491. private _transientXrHitTestSource;
  79492. private _xrHitTestSource;
  79493. private initHitTestSource;
  79494. /**
  79495. * The module's name
  79496. */
  79497. static readonly Name: string;
  79498. /**
  79499. * The (Babylon) version of this module.
  79500. * This is an integer representing the implementation version.
  79501. * This number does not correspond to the WebXR specs version
  79502. */
  79503. static readonly Version: number;
  79504. /**
  79505. * When set to true, each hit test will have its own position/rotation objects
  79506. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79507. * the developers will clone them or copy them as they see fit.
  79508. */
  79509. autoCloneTransformation: boolean;
  79510. /**
  79511. * Triggered when new babylon (transformed) hit test results are available
  79512. * Note - this will be called when results come back from the device. It can be an empty array!!
  79513. */
  79514. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79515. /**
  79516. * Use this to temporarily pause hit test checks.
  79517. */
  79518. paused: boolean;
  79519. /**
  79520. * Creates a new instance of the hit test feature
  79521. * @param _xrSessionManager an instance of WebXRSessionManager
  79522. * @param options options to use when constructing this feature
  79523. */
  79524. constructor(_xrSessionManager: WebXRSessionManager,
  79525. /**
  79526. * options to use when constructing this feature
  79527. */
  79528. options?: IWebXRHitTestOptions);
  79529. /**
  79530. * attach this feature
  79531. * Will usually be called by the features manager
  79532. *
  79533. * @returns true if successful.
  79534. */
  79535. attach(): boolean;
  79536. /**
  79537. * detach this feature.
  79538. * Will usually be called by the features manager
  79539. *
  79540. * @returns true if successful.
  79541. */
  79542. detach(): boolean;
  79543. /**
  79544. * Dispose this feature and all of the resources attached
  79545. */
  79546. dispose(): void;
  79547. protected _onXRFrame(frame: XRFrame): void;
  79548. private _processWebXRHitTestResult;
  79549. }
  79550. }
  79551. declare module BABYLON {
  79552. /**
  79553. * Configuration options of the anchor system
  79554. */
  79555. export interface IWebXRAnchorSystemOptions {
  79556. /**
  79557. * a node that will be used to convert local to world coordinates
  79558. */
  79559. worldParentNode?: TransformNode;
  79560. /**
  79561. * If set to true a reference of the created anchors will be kept until the next session starts
  79562. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79563. */
  79564. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79565. }
  79566. /**
  79567. * A babylon container for an XR Anchor
  79568. */
  79569. export interface IWebXRAnchor {
  79570. /**
  79571. * A babylon-assigned ID for this anchor
  79572. */
  79573. id: number;
  79574. /**
  79575. * Transformation matrix to apply to an object attached to this anchor
  79576. */
  79577. transformationMatrix: Matrix;
  79578. /**
  79579. * The native anchor object
  79580. */
  79581. xrAnchor: XRAnchor;
  79582. /**
  79583. * if defined, this object will be constantly updated by the anchor's position and rotation
  79584. */
  79585. attachedNode?: TransformNode;
  79586. /**
  79587. * Remove this anchor from the scene
  79588. */
  79589. remove(): void;
  79590. }
  79591. /**
  79592. * An implementation of the anchor system for WebXR.
  79593. * For further information see https://github.com/immersive-web/anchors/
  79594. */
  79595. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79596. private _options;
  79597. private _lastFrameDetected;
  79598. private _trackedAnchors;
  79599. private _referenceSpaceForFrameAnchors;
  79600. private _futureAnchors;
  79601. /**
  79602. * The module's name
  79603. */
  79604. static readonly Name: string;
  79605. /**
  79606. * The (Babylon) version of this module.
  79607. * This is an integer representing the implementation version.
  79608. * This number does not correspond to the WebXR specs version
  79609. */
  79610. static readonly Version: number;
  79611. /**
  79612. * Observers registered here will be executed when a new anchor was added to the session
  79613. */
  79614. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79615. /**
  79616. * Observers registered here will be executed when an anchor was removed from the session
  79617. */
  79618. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79619. /**
  79620. * Observers registered here will be executed when an existing anchor updates
  79621. * This can execute N times every frame
  79622. */
  79623. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79624. /**
  79625. * Set the reference space to use for anchor creation, when not using a hit test.
  79626. * Will default to the session's reference space if not defined
  79627. */
  79628. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79629. /**
  79630. * constructs a new anchor system
  79631. * @param _xrSessionManager an instance of WebXRSessionManager
  79632. * @param _options configuration object for this feature
  79633. */
  79634. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79635. private _tmpVector;
  79636. private _tmpQuaternion;
  79637. private _populateTmpTransformation;
  79638. /**
  79639. * Create a new anchor point using a hit test result at a specific point in the scene
  79640. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79641. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79642. *
  79643. * @param hitTestResult The hit test result to use for this anchor creation
  79644. * @param position an optional position offset for this anchor
  79645. * @param rotationQuaternion an optional rotation offset for this anchor
  79646. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79647. */
  79648. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79649. /**
  79650. * Add a new anchor at a specific position and rotation
  79651. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79652. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79653. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79654. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79655. *
  79656. * @param position the position in which to add an anchor
  79657. * @param rotationQuaternion an optional rotation for the anchor transformation
  79658. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79659. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79660. */
  79661. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79662. /**
  79663. * Get the list of anchors currently being tracked by the system
  79664. */
  79665. get anchors(): IWebXRAnchor[];
  79666. /**
  79667. * detach this feature.
  79668. * Will usually be called by the features manager
  79669. *
  79670. * @returns true if successful.
  79671. */
  79672. detach(): boolean;
  79673. /**
  79674. * Dispose this feature and all of the resources attached
  79675. */
  79676. dispose(): void;
  79677. protected _onXRFrame(frame: XRFrame): void;
  79678. /**
  79679. * avoiding using Array.find for global support.
  79680. * @param xrAnchor the plane to find in the array
  79681. */
  79682. private _findIndexInAnchorArray;
  79683. private _updateAnchorWithXRFrame;
  79684. private _createAnchorAtTransformation;
  79685. }
  79686. }
  79687. declare module BABYLON {
  79688. /**
  79689. * Options used in the plane detector module
  79690. */
  79691. export interface IWebXRPlaneDetectorOptions {
  79692. /**
  79693. * The node to use to transform the local results to world coordinates
  79694. */
  79695. worldParentNode?: TransformNode;
  79696. /**
  79697. * If set to true a reference of the created planes will be kept until the next session starts
  79698. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79699. */
  79700. doNotRemovePlanesOnSessionEnded?: boolean;
  79701. /**
  79702. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79703. */
  79704. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79705. }
  79706. /**
  79707. * A babylon interface for a WebXR plane.
  79708. * A Plane is actually a polygon, built from N points in space
  79709. *
  79710. * Supported in chrome 79, not supported in canary 81 ATM
  79711. */
  79712. export interface IWebXRPlane {
  79713. /**
  79714. * a babylon-assigned ID for this polygon
  79715. */
  79716. id: number;
  79717. /**
  79718. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79719. */
  79720. polygonDefinition: Array<Vector3>;
  79721. /**
  79722. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79723. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79724. */
  79725. transformationMatrix: Matrix;
  79726. /**
  79727. * the native xr-plane object
  79728. */
  79729. xrPlane: XRPlane;
  79730. }
  79731. /**
  79732. * The plane detector is used to detect planes in the real world when in AR
  79733. * For more information see https://github.com/immersive-web/real-world-geometry/
  79734. */
  79735. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79736. private _options;
  79737. private _detectedPlanes;
  79738. private _enabled;
  79739. private _lastFrameDetected;
  79740. /**
  79741. * The module's name
  79742. */
  79743. static readonly Name: string;
  79744. /**
  79745. * The (Babylon) version of this module.
  79746. * This is an integer representing the implementation version.
  79747. * This number does not correspond to the WebXR specs version
  79748. */
  79749. static readonly Version: number;
  79750. /**
  79751. * Observers registered here will be executed when a new plane was added to the session
  79752. */
  79753. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79754. /**
  79755. * Observers registered here will be executed when a plane is no longer detected in the session
  79756. */
  79757. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79758. /**
  79759. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79760. * This can execute N times every frame
  79761. */
  79762. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79763. /**
  79764. * construct a new Plane Detector
  79765. * @param _xrSessionManager an instance of xr Session manager
  79766. * @param _options configuration to use when constructing this feature
  79767. */
  79768. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79769. /**
  79770. * detach this feature.
  79771. * Will usually be called by the features manager
  79772. *
  79773. * @returns true if successful.
  79774. */
  79775. detach(): boolean;
  79776. /**
  79777. * Dispose this feature and all of the resources attached
  79778. */
  79779. dispose(): void;
  79780. /**
  79781. * Check if the needed objects are defined.
  79782. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79783. */
  79784. isCompatible(): boolean;
  79785. protected _onXRFrame(frame: XRFrame): void;
  79786. private _init;
  79787. private _updatePlaneWithXRPlane;
  79788. /**
  79789. * avoiding using Array.find for global support.
  79790. * @param xrPlane the plane to find in the array
  79791. */
  79792. private _findIndexInPlaneArray;
  79793. }
  79794. }
  79795. declare module BABYLON {
  79796. /**
  79797. * Options interface for the background remover plugin
  79798. */
  79799. export interface IWebXRBackgroundRemoverOptions {
  79800. /**
  79801. * Further background meshes to disable when entering AR
  79802. */
  79803. backgroundMeshes?: AbstractMesh[];
  79804. /**
  79805. * flags to configure the removal of the environment helper.
  79806. * If not set, the entire background will be removed. If set, flags should be set as well.
  79807. */
  79808. environmentHelperRemovalFlags?: {
  79809. /**
  79810. * Should the skybox be removed (default false)
  79811. */
  79812. skyBox?: boolean;
  79813. /**
  79814. * Should the ground be removed (default false)
  79815. */
  79816. ground?: boolean;
  79817. };
  79818. /**
  79819. * don't disable the environment helper
  79820. */
  79821. ignoreEnvironmentHelper?: boolean;
  79822. }
  79823. /**
  79824. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79825. */
  79826. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79827. /**
  79828. * read-only options to be used in this module
  79829. */
  79830. readonly options: IWebXRBackgroundRemoverOptions;
  79831. /**
  79832. * The module's name
  79833. */
  79834. static readonly Name: string;
  79835. /**
  79836. * The (Babylon) version of this module.
  79837. * This is an integer representing the implementation version.
  79838. * This number does not correspond to the WebXR specs version
  79839. */
  79840. static readonly Version: number;
  79841. /**
  79842. * registered observers will be triggered when the background state changes
  79843. */
  79844. onBackgroundStateChangedObservable: Observable<boolean>;
  79845. /**
  79846. * constructs a new background remover module
  79847. * @param _xrSessionManager the session manager for this module
  79848. * @param options read-only options to be used in this module
  79849. */
  79850. constructor(_xrSessionManager: WebXRSessionManager,
  79851. /**
  79852. * read-only options to be used in this module
  79853. */
  79854. options?: IWebXRBackgroundRemoverOptions);
  79855. /**
  79856. * attach this feature
  79857. * Will usually be called by the features manager
  79858. *
  79859. * @returns true if successful.
  79860. */
  79861. attach(): boolean;
  79862. /**
  79863. * detach this feature.
  79864. * Will usually be called by the features manager
  79865. *
  79866. * @returns true if successful.
  79867. */
  79868. detach(): boolean;
  79869. /**
  79870. * Dispose this feature and all of the resources attached
  79871. */
  79872. dispose(): void;
  79873. protected _onXRFrame(_xrFrame: XRFrame): void;
  79874. private _setBackgroundState;
  79875. }
  79876. }
  79877. declare module BABYLON {
  79878. /**
  79879. * Options for the controller physics feature
  79880. */
  79881. export class IWebXRControllerPhysicsOptions {
  79882. /**
  79883. * Should the headset get its own impostor
  79884. */
  79885. enableHeadsetImpostor?: boolean;
  79886. /**
  79887. * Optional parameters for the headset impostor
  79888. */
  79889. headsetImpostorParams?: {
  79890. /**
  79891. * The type of impostor to create. Default is sphere
  79892. */
  79893. impostorType: number;
  79894. /**
  79895. * the size of the impostor. Defaults to 10cm
  79896. */
  79897. impostorSize?: number | {
  79898. width: number;
  79899. height: number;
  79900. depth: number;
  79901. };
  79902. /**
  79903. * Friction definitions
  79904. */
  79905. friction?: number;
  79906. /**
  79907. * Restitution
  79908. */
  79909. restitution?: number;
  79910. };
  79911. /**
  79912. * The physics properties of the future impostors
  79913. */
  79914. physicsProperties?: {
  79915. /**
  79916. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79917. * Note that this requires a physics engine that supports mesh impostors!
  79918. */
  79919. useControllerMesh?: boolean;
  79920. /**
  79921. * The type of impostor to create. Default is sphere
  79922. */
  79923. impostorType?: number;
  79924. /**
  79925. * the size of the impostor. Defaults to 10cm
  79926. */
  79927. impostorSize?: number | {
  79928. width: number;
  79929. height: number;
  79930. depth: number;
  79931. };
  79932. /**
  79933. * Friction definitions
  79934. */
  79935. friction?: number;
  79936. /**
  79937. * Restitution
  79938. */
  79939. restitution?: number;
  79940. };
  79941. /**
  79942. * the xr input to use with this pointer selection
  79943. */
  79944. xrInput: WebXRInput;
  79945. }
  79946. /**
  79947. * Add physics impostor to your webxr controllers,
  79948. * including naive calculation of their linear and angular velocity
  79949. */
  79950. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79951. private readonly _options;
  79952. private _attachController;
  79953. private _controllers;
  79954. private _debugMode;
  79955. private _delta;
  79956. private _headsetImpostor?;
  79957. private _headsetMesh?;
  79958. private _lastTimestamp;
  79959. private _tmpQuaternion;
  79960. private _tmpVector;
  79961. /**
  79962. * The module's name
  79963. */
  79964. static readonly Name: string;
  79965. /**
  79966. * The (Babylon) version of this module.
  79967. * This is an integer representing the implementation version.
  79968. * This number does not correspond to the webxr specs version
  79969. */
  79970. static readonly Version: number;
  79971. /**
  79972. * Construct a new Controller Physics Feature
  79973. * @param _xrSessionManager the corresponding xr session manager
  79974. * @param _options options to create this feature with
  79975. */
  79976. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79977. /**
  79978. * @hidden
  79979. * enable debugging - will show console outputs and the impostor mesh
  79980. */
  79981. _enablePhysicsDebug(): void;
  79982. /**
  79983. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79984. * @param xrController the controller to add
  79985. */
  79986. addController(xrController: WebXRInputSource): void;
  79987. /**
  79988. * attach this feature
  79989. * Will usually be called by the features manager
  79990. *
  79991. * @returns true if successful.
  79992. */
  79993. attach(): boolean;
  79994. /**
  79995. * detach this feature.
  79996. * Will usually be called by the features manager
  79997. *
  79998. * @returns true if successful.
  79999. */
  80000. detach(): boolean;
  80001. /**
  80002. * Get the headset impostor, if enabled
  80003. * @returns the impostor
  80004. */
  80005. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80006. /**
  80007. * Get the physics impostor of a specific controller.
  80008. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80009. * @param controller the controller or the controller id of which to get the impostor
  80010. * @returns the impostor or null
  80011. */
  80012. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80013. /**
  80014. * Update the physics properties provided in the constructor
  80015. * @param newProperties the new properties object
  80016. */
  80017. setPhysicsProperties(newProperties: {
  80018. impostorType?: number;
  80019. impostorSize?: number | {
  80020. width: number;
  80021. height: number;
  80022. depth: number;
  80023. };
  80024. friction?: number;
  80025. restitution?: number;
  80026. }): void;
  80027. protected _onXRFrame(_xrFrame: any): void;
  80028. private _detachController;
  80029. }
  80030. }
  80031. declare module BABYLON {
  80032. /**
  80033. * A babylon interface for a "WebXR" feature point.
  80034. * Represents the position and confidence value of a given feature point.
  80035. */
  80036. export interface IWebXRFeaturePoint {
  80037. /**
  80038. * Represents the position of the feature point in world space.
  80039. */
  80040. position: Vector3;
  80041. /**
  80042. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80043. */
  80044. confidenceValue: number;
  80045. }
  80046. /**
  80047. * The feature point system is used to detect feature points from real world geometry.
  80048. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80049. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80050. */
  80051. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80052. private _enabled;
  80053. private _featurePointCloud;
  80054. /**
  80055. * The module's name
  80056. */
  80057. static readonly Name: string;
  80058. /**
  80059. * The (Babylon) version of this module.
  80060. * This is an integer representing the implementation version.
  80061. * This number does not correspond to the WebXR specs version
  80062. */
  80063. static readonly Version: number;
  80064. /**
  80065. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80066. * Will notify the observers about which feature points have been added.
  80067. */
  80068. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80069. /**
  80070. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80071. * Will notify the observers about which feature points have been updated.
  80072. */
  80073. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80074. /**
  80075. * The current feature point cloud maintained across frames.
  80076. */
  80077. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80078. /**
  80079. * construct the feature point system
  80080. * @param _xrSessionManager an instance of xr Session manager
  80081. */
  80082. constructor(_xrSessionManager: WebXRSessionManager);
  80083. /**
  80084. * Detach this feature.
  80085. * Will usually be called by the features manager
  80086. *
  80087. * @returns true if successful.
  80088. */
  80089. detach(): boolean;
  80090. /**
  80091. * Dispose this feature and all of the resources attached
  80092. */
  80093. dispose(): void;
  80094. /**
  80095. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80096. */
  80097. protected _onXRFrame(frame: XRFrame): void;
  80098. /**
  80099. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80100. */
  80101. private _init;
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /**
  80106. * Configuration interface for the hand tracking feature
  80107. */
  80108. export interface IWebXRHandTrackingOptions {
  80109. /**
  80110. * The xrInput that will be used as source for new hands
  80111. */
  80112. xrInput: WebXRInput;
  80113. /**
  80114. * Configuration object for the joint meshes
  80115. */
  80116. jointMeshes?: {
  80117. /**
  80118. * Should the meshes created be invisible (defaults to false)
  80119. */
  80120. invisible?: boolean;
  80121. /**
  80122. * A source mesh to be used to create instances. Defaults to a sphere.
  80123. * This mesh will be the source for all other (25) meshes.
  80124. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80125. */
  80126. sourceMesh?: Mesh;
  80127. /**
  80128. * This function will be called after a mesh was created for a specific joint.
  80129. * Using this function you can either manipulate the instance or return a new mesh.
  80130. * When returning a new mesh the instance created before will be disposed
  80131. */
  80132. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80133. /**
  80134. * Should the source mesh stay visible. Defaults to false
  80135. */
  80136. keepOriginalVisible?: boolean;
  80137. /**
  80138. * Scale factor for all instances (defaults to 2)
  80139. */
  80140. scaleFactor?: number;
  80141. /**
  80142. * Should each instance have its own physics impostor
  80143. */
  80144. enablePhysics?: boolean;
  80145. /**
  80146. * If enabled, override default physics properties
  80147. */
  80148. physicsProps?: {
  80149. friction?: number;
  80150. restitution?: number;
  80151. impostorType?: number;
  80152. };
  80153. /**
  80154. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80155. */
  80156. disableDefaultHandMesh?: boolean;
  80157. /**
  80158. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80159. */
  80160. handMeshes?: {
  80161. right: AbstractMesh;
  80162. left: AbstractMesh;
  80163. };
  80164. /**
  80165. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80166. */
  80167. rigMapping?: {
  80168. right: string[];
  80169. left: string[];
  80170. };
  80171. };
  80172. }
  80173. /**
  80174. * Parts of the hands divided to writs and finger names
  80175. */
  80176. export const enum HandPart {
  80177. /**
  80178. * HandPart - Wrist
  80179. */
  80180. WRIST = "wrist",
  80181. /**
  80182. * HandPart - The Thumb
  80183. */
  80184. THUMB = "thumb",
  80185. /**
  80186. * HandPart - Index finger
  80187. */
  80188. INDEX = "index",
  80189. /**
  80190. * HandPart - Middle finger
  80191. */
  80192. MIDDLE = "middle",
  80193. /**
  80194. * HandPart - Ring finger
  80195. */
  80196. RING = "ring",
  80197. /**
  80198. * HandPart - Little finger
  80199. */
  80200. LITTLE = "little"
  80201. }
  80202. /**
  80203. * Representing a single hand (with its corresponding native XRHand object)
  80204. */
  80205. export class WebXRHand implements IDisposable {
  80206. /** the controller to which the hand correlates */
  80207. readonly xrController: WebXRInputSource;
  80208. /** the meshes to be used to track the hand joints */
  80209. readonly trackedMeshes: AbstractMesh[];
  80210. private _handMesh?;
  80211. private _rigMapping?;
  80212. private _scene;
  80213. private _defaultHandMesh;
  80214. private _transformNodeMapping;
  80215. /**
  80216. * Hand-parts definition (key is HandPart)
  80217. */
  80218. handPartsDefinition: {
  80219. [key: string]: number[];
  80220. };
  80221. /**
  80222. * Observers will be triggered when the mesh for this hand was initialized.
  80223. */
  80224. onHandMeshReadyObservable: Observable<WebXRHand>;
  80225. /**
  80226. * Populate the HandPartsDefinition object.
  80227. * This is called as a side effect since certain browsers don't have XRHand defined.
  80228. */
  80229. private generateHandPartsDefinition;
  80230. /**
  80231. * Construct a new hand object
  80232. * @param xrController the controller to which the hand correlates
  80233. * @param trackedMeshes the meshes to be used to track the hand joints
  80234. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80235. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80236. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80237. */
  80238. constructor(
  80239. /** the controller to which the hand correlates */
  80240. xrController: WebXRInputSource,
  80241. /** the meshes to be used to track the hand joints */
  80242. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  80243. /**
  80244. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80245. */
  80246. get handMesh(): AbstractMesh | undefined;
  80247. /**
  80248. * Update this hand from the latest xr frame
  80249. * @param xrFrame xrFrame to update from
  80250. * @param referenceSpace The current viewer reference space
  80251. * @param scaleFactor optional scale factor for the meshes
  80252. */
  80253. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80254. /**
  80255. * Get meshes of part of the hand
  80256. * @param part the part of hand to get
  80257. * @returns An array of meshes that correlate to the hand part requested
  80258. */
  80259. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80260. /**
  80261. * Dispose this Hand object
  80262. */
  80263. dispose(): void;
  80264. private _generateDefaultHandMesh;
  80265. }
  80266. /**
  80267. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80268. */
  80269. export class WebXRHandTracking extends WebXRAbstractFeature {
  80270. /**
  80271. * options to use when constructing this feature
  80272. */
  80273. readonly options: IWebXRHandTrackingOptions;
  80274. private static _idCounter;
  80275. /**
  80276. * The module's name
  80277. */
  80278. static readonly Name: string;
  80279. /**
  80280. * The (Babylon) version of this module.
  80281. * This is an integer representing the implementation version.
  80282. * This number does not correspond to the WebXR specs version
  80283. */
  80284. static readonly Version: number;
  80285. /**
  80286. * This observable will notify registered observers when a new hand object was added and initialized
  80287. */
  80288. onHandAddedObservable: Observable<WebXRHand>;
  80289. /**
  80290. * This observable will notify its observers right before the hand object is disposed
  80291. */
  80292. onHandRemovedObservable: Observable<WebXRHand>;
  80293. private _hands;
  80294. /**
  80295. * Creates a new instance of the hit test feature
  80296. * @param _xrSessionManager an instance of WebXRSessionManager
  80297. * @param options options to use when constructing this feature
  80298. */
  80299. constructor(_xrSessionManager: WebXRSessionManager,
  80300. /**
  80301. * options to use when constructing this feature
  80302. */
  80303. options: IWebXRHandTrackingOptions);
  80304. /**
  80305. * Check if the needed objects are defined.
  80306. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80307. */
  80308. isCompatible(): boolean;
  80309. /**
  80310. * attach this feature
  80311. * Will usually be called by the features manager
  80312. *
  80313. * @returns true if successful.
  80314. */
  80315. attach(): boolean;
  80316. /**
  80317. * detach this feature.
  80318. * Will usually be called by the features manager
  80319. *
  80320. * @returns true if successful.
  80321. */
  80322. detach(): boolean;
  80323. /**
  80324. * Dispose this feature and all of the resources attached
  80325. */
  80326. dispose(): void;
  80327. /**
  80328. * Get the hand object according to the controller id
  80329. * @param controllerId the controller id to which we want to get the hand
  80330. * @returns null if not found or the WebXRHand object if found
  80331. */
  80332. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80333. /**
  80334. * Get a hand object according to the requested handedness
  80335. * @param handedness the handedness to request
  80336. * @returns null if not found or the WebXRHand object if found
  80337. */
  80338. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80339. protected _onXRFrame(_xrFrame: XRFrame): void;
  80340. private _attachHand;
  80341. private _detachHand;
  80342. }
  80343. }
  80344. declare module BABYLON {
  80345. /**
  80346. * Options used in the mesh detector module
  80347. */
  80348. export interface IWebXRMeshDetectorOptions {
  80349. /**
  80350. * The node to use to transform the local results to world coordinates
  80351. */
  80352. worldParentNode?: TransformNode;
  80353. /**
  80354. * If set to true a reference of the created meshes will be kept until the next session starts
  80355. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80356. */
  80357. doNotRemoveMeshesOnSessionEnded?: boolean;
  80358. /**
  80359. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80360. */
  80361. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80362. /**
  80363. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80364. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80365. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80366. */
  80367. convertCoordinateSystems?: boolean;
  80368. }
  80369. /**
  80370. * A babylon interface for a XR mesh's vertex data.
  80371. *
  80372. * Currently not supported by WebXR, available only with BabylonNative
  80373. */
  80374. export interface IWebXRVertexData {
  80375. /**
  80376. * A babylon-assigned ID for this mesh
  80377. */
  80378. id: number;
  80379. /**
  80380. * Data required for constructing a mesh in Babylon.js.
  80381. */
  80382. xrMesh: XRMesh;
  80383. /**
  80384. * The node to use to transform the local results to world coordinates.
  80385. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80386. */
  80387. worldParentNode?: TransformNode;
  80388. /**
  80389. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80390. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80391. */
  80392. positions?: Float32Array;
  80393. /**
  80394. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80395. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80396. */
  80397. indices?: Uint32Array;
  80398. /**
  80399. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80400. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80401. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80402. */
  80403. normals?: Float32Array;
  80404. /**
  80405. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80406. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80407. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80408. */
  80409. transformationMatrix?: Matrix;
  80410. }
  80411. /**
  80412. * The mesh detector is used to detect meshes in the real world when in AR
  80413. */
  80414. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80415. private _options;
  80416. private _detectedMeshes;
  80417. /**
  80418. * The module's name
  80419. */
  80420. static readonly Name: string;
  80421. /**
  80422. * The (Babylon) version of this module.
  80423. * This is an integer representing the implementation version.
  80424. * This number does not correspond to the WebXR specs version
  80425. */
  80426. static readonly Version: number;
  80427. /**
  80428. * Observers registered here will be executed when a new mesh was added to the session
  80429. */
  80430. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80431. /**
  80432. * Observers registered here will be executed when a mesh is no longer detected in the session
  80433. */
  80434. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80435. /**
  80436. * Observers registered here will be executed when an existing mesh updates
  80437. */
  80438. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80439. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80440. detach(): boolean;
  80441. dispose(): void;
  80442. protected _onXRFrame(frame: XRFrame): void;
  80443. private _init;
  80444. private _updateVertexDataWithXRMesh;
  80445. }
  80446. }
  80447. declare module BABYLON {
  80448. /**
  80449. * Options interface for the background remover plugin
  80450. */
  80451. export interface IWebXRImageTrackingOptions {
  80452. /**
  80453. * A required array with images to track
  80454. */
  80455. images: {
  80456. /**
  80457. * The source of the image. can be a URL or an image bitmap
  80458. */
  80459. src: string | ImageBitmap;
  80460. /**
  80461. * The estimated width in the real world (in meters)
  80462. */
  80463. estimatedRealWorldWidth: number;
  80464. }[];
  80465. }
  80466. /**
  80467. * An object representing an image tracked by the system
  80468. */
  80469. export interface IWebXRTrackedImage {
  80470. /**
  80471. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80472. */
  80473. id: number;
  80474. /**
  80475. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80476. */
  80477. emulated?: boolean;
  80478. /**
  80479. * Just in case it is needed - the image bitmap that is being tracked
  80480. */
  80481. originalBitmap: ImageBitmap;
  80482. /**
  80483. * The native XR result image tracking result, untouched
  80484. */
  80485. xrTrackingResult?: XRImageTrackingResult;
  80486. /**
  80487. * Width in real world (meters)
  80488. */
  80489. realWorldWidth?: number;
  80490. /**
  80491. * A transformation matrix of this current image in the current reference space.
  80492. */
  80493. transformationMatrix: Matrix;
  80494. /**
  80495. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80496. */
  80497. ratio?: number;
  80498. }
  80499. /**
  80500. * Image tracking for immersive AR sessions.
  80501. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80502. */
  80503. export class WebXRImageTracking extends WebXRAbstractFeature {
  80504. /**
  80505. * read-only options to be used in this module
  80506. */
  80507. readonly options: IWebXRImageTrackingOptions;
  80508. /**
  80509. * The module's name
  80510. */
  80511. static readonly Name: string;
  80512. /**
  80513. * The (Babylon) version of this module.
  80514. * This is an integer representing the implementation version.
  80515. * This number does not correspond to the WebXR specs version
  80516. */
  80517. static readonly Version: number;
  80518. /**
  80519. * This will be triggered if the underlying system deems an image untrackable.
  80520. * The index is the index of the image from the array used to initialize the feature.
  80521. */
  80522. onUntrackableImageFoundObservable: Observable<number>;
  80523. /**
  80524. * An image was deemed trackable, and the system will start tracking it.
  80525. */
  80526. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80527. /**
  80528. * The image was found and its state was updated.
  80529. */
  80530. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80531. private _trackedImages;
  80532. private _originalTrackingRequest;
  80533. /**
  80534. * constructs the image tracking feature
  80535. * @param _xrSessionManager the session manager for this module
  80536. * @param options read-only options to be used in this module
  80537. */
  80538. constructor(_xrSessionManager: WebXRSessionManager,
  80539. /**
  80540. * read-only options to be used in this module
  80541. */
  80542. options: IWebXRImageTrackingOptions);
  80543. /**
  80544. * attach this feature
  80545. * Will usually be called by the features manager
  80546. *
  80547. * @returns true if successful.
  80548. */
  80549. attach(): boolean;
  80550. /**
  80551. * detach this feature.
  80552. * Will usually be called by the features manager
  80553. *
  80554. * @returns true if successful.
  80555. */
  80556. detach(): boolean;
  80557. /**
  80558. * Check if the needed objects are defined.
  80559. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80560. */
  80561. isCompatible(): boolean;
  80562. /**
  80563. * Get a tracked image by its ID.
  80564. *
  80565. * @param id the id of the image to load (position in the init array)
  80566. * @returns a trackable image, if exists in this location
  80567. */
  80568. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80569. /**
  80570. * Dispose this feature and all of the resources attached
  80571. */
  80572. dispose(): void;
  80573. /**
  80574. * Extends the session init object if needed
  80575. * @returns augmentation object fo the xr session init object.
  80576. */
  80577. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80578. protected _onXRFrame(_xrFrame: XRFrame): void;
  80579. private _init;
  80580. }
  80581. }
  80582. declare module BABYLON {
  80583. /**
  80584. * The motion controller class for all microsoft mixed reality controllers
  80585. */
  80586. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80587. protected readonly _mapping: {
  80588. defaultButton: {
  80589. valueNodeName: string;
  80590. unpressedNodeName: string;
  80591. pressedNodeName: string;
  80592. };
  80593. defaultAxis: {
  80594. valueNodeName: string;
  80595. minNodeName: string;
  80596. maxNodeName: string;
  80597. };
  80598. buttons: {
  80599. "xr-standard-trigger": {
  80600. rootNodeName: string;
  80601. componentProperty: string;
  80602. states: string[];
  80603. };
  80604. "xr-standard-squeeze": {
  80605. rootNodeName: string;
  80606. componentProperty: string;
  80607. states: string[];
  80608. };
  80609. "xr-standard-touchpad": {
  80610. rootNodeName: string;
  80611. labelAnchorNodeName: string;
  80612. touchPointNodeName: string;
  80613. };
  80614. "xr-standard-thumbstick": {
  80615. rootNodeName: string;
  80616. componentProperty: string;
  80617. states: string[];
  80618. };
  80619. };
  80620. axes: {
  80621. "xr-standard-touchpad": {
  80622. "x-axis": {
  80623. rootNodeName: string;
  80624. };
  80625. "y-axis": {
  80626. rootNodeName: string;
  80627. };
  80628. };
  80629. "xr-standard-thumbstick": {
  80630. "x-axis": {
  80631. rootNodeName: string;
  80632. };
  80633. "y-axis": {
  80634. rootNodeName: string;
  80635. };
  80636. };
  80637. };
  80638. };
  80639. /**
  80640. * The base url used to load the left and right controller models
  80641. */
  80642. static MODEL_BASE_URL: string;
  80643. /**
  80644. * The name of the left controller model file
  80645. */
  80646. static MODEL_LEFT_FILENAME: string;
  80647. /**
  80648. * The name of the right controller model file
  80649. */
  80650. static MODEL_RIGHT_FILENAME: string;
  80651. profileId: string;
  80652. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80653. protected _getFilenameAndPath(): {
  80654. filename: string;
  80655. path: string;
  80656. };
  80657. protected _getModelLoadingConstraints(): boolean;
  80658. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80659. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80660. protected _updateModel(): void;
  80661. }
  80662. }
  80663. declare module BABYLON {
  80664. /**
  80665. * The motion controller class for oculus touch (quest, rift).
  80666. * This class supports legacy mapping as well the standard xr mapping
  80667. */
  80668. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80669. private _forceLegacyControllers;
  80670. private _modelRootNode;
  80671. /**
  80672. * The base url used to load the left and right controller models
  80673. */
  80674. static MODEL_BASE_URL: string;
  80675. /**
  80676. * The name of the left controller model file
  80677. */
  80678. static MODEL_LEFT_FILENAME: string;
  80679. /**
  80680. * The name of the right controller model file
  80681. */
  80682. static MODEL_RIGHT_FILENAME: string;
  80683. /**
  80684. * Base Url for the Quest controller model.
  80685. */
  80686. static QUEST_MODEL_BASE_URL: string;
  80687. profileId: string;
  80688. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80689. protected _getFilenameAndPath(): {
  80690. filename: string;
  80691. path: string;
  80692. };
  80693. protected _getModelLoadingConstraints(): boolean;
  80694. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80695. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80696. protected _updateModel(): void;
  80697. /**
  80698. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80699. * between the touch and touch 2.
  80700. */
  80701. private _isQuest;
  80702. }
  80703. }
  80704. declare module BABYLON {
  80705. /**
  80706. * The motion controller class for the standard HTC-Vive controllers
  80707. */
  80708. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80709. private _modelRootNode;
  80710. /**
  80711. * The base url used to load the left and right controller models
  80712. */
  80713. static MODEL_BASE_URL: string;
  80714. /**
  80715. * File name for the controller model.
  80716. */
  80717. static MODEL_FILENAME: string;
  80718. profileId: string;
  80719. /**
  80720. * Create a new Vive motion controller object
  80721. * @param scene the scene to use to create this controller
  80722. * @param gamepadObject the corresponding gamepad object
  80723. * @param handedness the handedness of the controller
  80724. */
  80725. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80726. protected _getFilenameAndPath(): {
  80727. filename: string;
  80728. path: string;
  80729. };
  80730. protected _getModelLoadingConstraints(): boolean;
  80731. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80732. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80733. protected _updateModel(): void;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /**
  80738. * A cursor which tracks a point on a path
  80739. */
  80740. export class PathCursor {
  80741. private path;
  80742. /**
  80743. * Stores path cursor callbacks for when an onchange event is triggered
  80744. */
  80745. private _onchange;
  80746. /**
  80747. * The value of the path cursor
  80748. */
  80749. value: number;
  80750. /**
  80751. * The animation array of the path cursor
  80752. */
  80753. animations: Animation[];
  80754. /**
  80755. * Initializes the path cursor
  80756. * @param path The path to track
  80757. */
  80758. constructor(path: Path2);
  80759. /**
  80760. * Gets the cursor point on the path
  80761. * @returns A point on the path cursor at the cursor location
  80762. */
  80763. getPoint(): Vector3;
  80764. /**
  80765. * Moves the cursor ahead by the step amount
  80766. * @param step The amount to move the cursor forward
  80767. * @returns This path cursor
  80768. */
  80769. moveAhead(step?: number): PathCursor;
  80770. /**
  80771. * Moves the cursor behind by the step amount
  80772. * @param step The amount to move the cursor back
  80773. * @returns This path cursor
  80774. */
  80775. moveBack(step?: number): PathCursor;
  80776. /**
  80777. * Moves the cursor by the step amount
  80778. * If the step amount is greater than one, an exception is thrown
  80779. * @param step The amount to move the cursor
  80780. * @returns This path cursor
  80781. */
  80782. move(step: number): PathCursor;
  80783. /**
  80784. * Ensures that the value is limited between zero and one
  80785. * @returns This path cursor
  80786. */
  80787. private ensureLimits;
  80788. /**
  80789. * Runs onchange callbacks on change (used by the animation engine)
  80790. * @returns This path cursor
  80791. */
  80792. private raiseOnChange;
  80793. /**
  80794. * Executes a function on change
  80795. * @param f A path cursor onchange callback
  80796. * @returns This path cursor
  80797. */
  80798. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80799. }
  80800. }
  80801. declare module BABYLON {
  80802. /** @hidden */
  80803. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  80804. private static _Cache;
  80805. protected _getRenderPipeline(param: {
  80806. token: any;
  80807. pipeline: Nullable<GPURenderPipeline>;
  80808. }): void;
  80809. protected _setRenderPipeline(param: {
  80810. token: any;
  80811. pipeline: Nullable<GPURenderPipeline>;
  80812. }): void;
  80813. }
  80814. }
  80815. declare module BABYLON {
  80816. /** @hidden */
  80817. export var blurPixelShader: {
  80818. name: string;
  80819. shader: string;
  80820. };
  80821. }
  80822. declare module BABYLON {
  80823. /** @hidden */
  80824. export var pointCloudVertexDeclaration: {
  80825. name: string;
  80826. shader: string;
  80827. };
  80828. }
  80829. // Mixins
  80830. interface Window {
  80831. mozIndexedDB: IDBFactory;
  80832. webkitIndexedDB: IDBFactory;
  80833. msIndexedDB: IDBFactory;
  80834. webkitURL: typeof URL;
  80835. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80836. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80837. WebGLRenderingContext: WebGLRenderingContext;
  80838. MSGesture: MSGesture;
  80839. CANNON: any;
  80840. AudioContext: AudioContext;
  80841. webkitAudioContext: AudioContext;
  80842. PointerEvent: any;
  80843. Math: Math;
  80844. Uint8Array: Uint8ArrayConstructor;
  80845. Float32Array: Float32ArrayConstructor;
  80846. mozURL: typeof URL;
  80847. msURL: typeof URL;
  80848. VRFrameData: any; // WebVR, from specs 1.1
  80849. DracoDecoderModule: any;
  80850. setImmediate(handler: (...args: any[]) => void): number;
  80851. }
  80852. interface HTMLCanvasElement {
  80853. requestPointerLock(): void;
  80854. msRequestPointerLock?(): void;
  80855. mozRequestPointerLock?(): void;
  80856. webkitRequestPointerLock?(): void;
  80857. /** Track whether a record is in progress */
  80858. isRecording: boolean;
  80859. /** Capture Stream method defined by some browsers */
  80860. captureStream(fps?: number): MediaStream;
  80861. }
  80862. interface CanvasRenderingContext2D {
  80863. msImageSmoothingEnabled: boolean;
  80864. }
  80865. interface MouseEvent {
  80866. mozMovementX: number;
  80867. mozMovementY: number;
  80868. webkitMovementX: number;
  80869. webkitMovementY: number;
  80870. msMovementX: number;
  80871. msMovementY: number;
  80872. }
  80873. interface Navigator {
  80874. mozGetVRDevices: (any: any) => any;
  80875. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80876. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80877. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80878. webkitGetGamepads(): Gamepad[];
  80879. msGetGamepads(): Gamepad[];
  80880. webkitGamepads(): Gamepad[];
  80881. }
  80882. interface HTMLVideoElement {
  80883. mozSrcObject: any;
  80884. }
  80885. interface Math {
  80886. fround(x: number): number;
  80887. imul(a: number, b: number): number;
  80888. log2(x: number): number;
  80889. }
  80890. interface WebGLRenderingContext {
  80891. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80892. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80893. vertexAttribDivisor(index: number, divisor: number): void;
  80894. createVertexArray(): any;
  80895. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80896. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80897. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80898. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80899. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80900. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80901. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80902. // Queries
  80903. createQuery(): WebGLQuery;
  80904. deleteQuery(query: WebGLQuery): void;
  80905. beginQuery(target: number, query: WebGLQuery): void;
  80906. endQuery(target: number): void;
  80907. getQueryParameter(query: WebGLQuery, pname: number): any;
  80908. getQuery(target: number, pname: number): any;
  80909. MAX_SAMPLES: number;
  80910. RGBA8: number;
  80911. READ_FRAMEBUFFER: number;
  80912. DRAW_FRAMEBUFFER: number;
  80913. UNIFORM_BUFFER: number;
  80914. HALF_FLOAT_OES: number;
  80915. RGBA16F: number;
  80916. RGBA32F: number;
  80917. R32F: number;
  80918. RG32F: number;
  80919. RGB32F: number;
  80920. R16F: number;
  80921. RG16F: number;
  80922. RGB16F: number;
  80923. RED: number;
  80924. RG: number;
  80925. R8: number;
  80926. RG8: number;
  80927. UNSIGNED_INT_24_8: number;
  80928. DEPTH24_STENCIL8: number;
  80929. MIN: number;
  80930. MAX: number;
  80931. /* Multiple Render Targets */
  80932. drawBuffers(buffers: number[]): void;
  80933. readBuffer(src: number): void;
  80934. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80935. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80936. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80937. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80938. // Occlusion Query
  80939. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80940. ANY_SAMPLES_PASSED: number;
  80941. QUERY_RESULT_AVAILABLE: number;
  80942. QUERY_RESULT: number;
  80943. }
  80944. interface WebGLProgram {
  80945. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80946. }
  80947. interface EXT_disjoint_timer_query {
  80948. QUERY_COUNTER_BITS_EXT: number;
  80949. TIME_ELAPSED_EXT: number;
  80950. TIMESTAMP_EXT: number;
  80951. GPU_DISJOINT_EXT: number;
  80952. QUERY_RESULT_EXT: number;
  80953. QUERY_RESULT_AVAILABLE_EXT: number;
  80954. queryCounterEXT(query: WebGLQuery, target: number): void;
  80955. createQueryEXT(): WebGLQuery;
  80956. beginQueryEXT(target: number, query: WebGLQuery): void;
  80957. endQueryEXT(target: number): void;
  80958. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80959. deleteQueryEXT(query: WebGLQuery): void;
  80960. }
  80961. interface WebGLUniformLocation {
  80962. _currentState: any;
  80963. }
  80964. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80965. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80966. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80967. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80968. interface WebGLRenderingContext {
  80969. readonly RASTERIZER_DISCARD: number;
  80970. readonly DEPTH_COMPONENT24: number;
  80971. readonly TEXTURE_3D: number;
  80972. readonly TEXTURE_2D_ARRAY: number;
  80973. readonly TEXTURE_COMPARE_FUNC: number;
  80974. readonly TEXTURE_COMPARE_MODE: number;
  80975. readonly COMPARE_REF_TO_TEXTURE: number;
  80976. readonly TEXTURE_WRAP_R: number;
  80977. readonly HALF_FLOAT: number;
  80978. readonly RGB8: number;
  80979. readonly RED_INTEGER: number;
  80980. readonly RG_INTEGER: number;
  80981. readonly RGB_INTEGER: number;
  80982. readonly RGBA_INTEGER: number;
  80983. readonly R8_SNORM: number;
  80984. readonly RG8_SNORM: number;
  80985. readonly RGB8_SNORM: number;
  80986. readonly RGBA8_SNORM: number;
  80987. readonly R8I: number;
  80988. readonly RG8I: number;
  80989. readonly RGB8I: number;
  80990. readonly RGBA8I: number;
  80991. readonly R8UI: number;
  80992. readonly RG8UI: number;
  80993. readonly RGB8UI: number;
  80994. readonly RGBA8UI: number;
  80995. readonly R16I: number;
  80996. readonly RG16I: number;
  80997. readonly RGB16I: number;
  80998. readonly RGBA16I: number;
  80999. readonly R16UI: number;
  81000. readonly RG16UI: number;
  81001. readonly RGB16UI: number;
  81002. readonly RGBA16UI: number;
  81003. readonly R32I: number;
  81004. readonly RG32I: number;
  81005. readonly RGB32I: number;
  81006. readonly RGBA32I: number;
  81007. readonly R32UI: number;
  81008. readonly RG32UI: number;
  81009. readonly RGB32UI: number;
  81010. readonly RGBA32UI: number;
  81011. readonly RGB10_A2UI: number;
  81012. readonly R11F_G11F_B10F: number;
  81013. readonly RGB9_E5: number;
  81014. readonly RGB10_A2: number;
  81015. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81016. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81017. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81018. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81019. readonly DEPTH_COMPONENT32F: number;
  81020. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81021. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81022. 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;
  81023. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81024. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81025. readonly TRANSFORM_FEEDBACK: number;
  81026. readonly INTERLEAVED_ATTRIBS: number;
  81027. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81028. createTransformFeedback(): WebGLTransformFeedback;
  81029. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81030. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81031. beginTransformFeedback(primitiveMode: number): void;
  81032. endTransformFeedback(): void;
  81033. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81034. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81035. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81036. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81037. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81038. }
  81039. interface ImageBitmap {
  81040. readonly width: number;
  81041. readonly height: number;
  81042. close(): void;
  81043. }
  81044. interface WebGLQuery extends WebGLObject {
  81045. }
  81046. declare var WebGLQuery: {
  81047. prototype: WebGLQuery;
  81048. new(): WebGLQuery;
  81049. };
  81050. interface WebGLSampler extends WebGLObject {
  81051. }
  81052. declare var WebGLSampler: {
  81053. prototype: WebGLSampler;
  81054. new(): WebGLSampler;
  81055. };
  81056. interface WebGLSync extends WebGLObject {
  81057. }
  81058. declare var WebGLSync: {
  81059. prototype: WebGLSync;
  81060. new(): WebGLSync;
  81061. };
  81062. interface WebGLTransformFeedback extends WebGLObject {
  81063. }
  81064. declare var WebGLTransformFeedback: {
  81065. prototype: WebGLTransformFeedback;
  81066. new(): WebGLTransformFeedback;
  81067. };
  81068. interface WebGLVertexArrayObject extends WebGLObject {
  81069. }
  81070. declare var WebGLVertexArrayObject: {
  81071. prototype: WebGLVertexArrayObject;
  81072. new(): WebGLVertexArrayObject;
  81073. };
  81074. interface Navigator {
  81075. readonly gpu: GPU | undefined;
  81076. }
  81077. interface GPUColorDict {
  81078. a: number;
  81079. b: number;
  81080. g: number;
  81081. r: number;
  81082. }
  81083. type GPUColor = [number, number, number, number] | GPUColorDict;
  81084. interface GPUOrigin2DDict {
  81085. x?: number;
  81086. y?: number;
  81087. }
  81088. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81089. interface GPUOrigin3DDict {
  81090. x?: number;
  81091. y?: number;
  81092. z?: number;
  81093. }
  81094. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81095. interface GPUExtent3DDict {
  81096. width: number;
  81097. height: number;
  81098. depth: number;
  81099. }
  81100. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81101. type GPUBindingResource =
  81102. | GPUSampler
  81103. | GPUTextureView
  81104. | GPUBufferBinding;
  81105. type GPUExtensionName =
  81106. | "texture-compression-bc"
  81107. | "timestamp-query"
  81108. | "pipeline-statistics-query"
  81109. | "depth-clamping"
  81110. | "depth24unorm-stencil8"
  81111. | "depth32float-stencil8";
  81112. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81113. type GPUBindingType =
  81114. | "uniform-buffer"
  81115. | "storage-buffer"
  81116. | "readonly-storage-buffer"
  81117. | "sampler"
  81118. | "comparison-sampler"
  81119. | "sampled-texture"
  81120. | "readonly-storage-texture"
  81121. | "writeonly-storage-texture";
  81122. type GPUBlendFactor =
  81123. | "zero"
  81124. | "one"
  81125. | "src-color"
  81126. | "one-minus-src-color"
  81127. | "src-alpha"
  81128. | "one-minus-src-alpha"
  81129. | "dst-color"
  81130. | "one-minus-dst-color"
  81131. | "dst-alpha"
  81132. | "one-minus-dst-alpha"
  81133. | "src-alpha-saturated"
  81134. | "blend-color"
  81135. | "one-minus-blend-color";
  81136. type GPUBlendOperation =
  81137. | "add"
  81138. | "subtract"
  81139. | "reverse-subtract"
  81140. | "min"
  81141. | "max";
  81142. type GPUCompareFunction =
  81143. | "never"
  81144. | "less"
  81145. | "equal"
  81146. | "less-equal"
  81147. | "greater"
  81148. | "not-equal"
  81149. | "greater-equal"
  81150. | "always";
  81151. type GPUCullMode = "none" | "front" | "back";
  81152. type GPUFilterMode = "nearest" | "linear";
  81153. type GPUFrontFace = "ccw" | "cw";
  81154. type GPUIndexFormat = "uint16" | "uint32";
  81155. type GPUInputStepMode = "vertex" | "instance";
  81156. type GPULoadOp = "load";
  81157. type GPUPrimitiveTopology =
  81158. | "point-list"
  81159. | "line-list"
  81160. | "line-strip"
  81161. | "triangle-list"
  81162. | "triangle-strip";
  81163. type GPUStencilOperation =
  81164. | "keep"
  81165. | "zero"
  81166. | "replace"
  81167. | "invert"
  81168. | "increment-clamp"
  81169. | "decrement-clamp"
  81170. | "increment-wrap"
  81171. | "decrement-wrap";
  81172. type GPUStoreOp = "store" | "clear";
  81173. type GPUTextureDimension = "1d" | "2d" | "3d";
  81174. type GPUTextureFormat =
  81175. | "r8unorm"
  81176. | "r8snorm"
  81177. | "r8uint"
  81178. | "r8sint"
  81179. | "r16uint"
  81180. | "r16sint"
  81181. | "r16float"
  81182. | "rg8unorm"
  81183. | "rg8snorm"
  81184. | "rg8uint"
  81185. | "rg8sint"
  81186. | "r32uint"
  81187. | "r32sint"
  81188. | "r32float"
  81189. | "rg16uint"
  81190. | "rg16sint"
  81191. | "rg16float"
  81192. | "rgba8unorm"
  81193. | "rgba8unorm-srgb"
  81194. | "rgba8snorm"
  81195. | "rgba8uint"
  81196. | "rgba8sint"
  81197. | "bgra8unorm"
  81198. | "bgra8unorm-srgb"
  81199. | "rgb9e5ufloat"
  81200. | "rgb10a2unorm"
  81201. | "rg11b10ufloat"
  81202. | "rg32uint"
  81203. | "rg32sint"
  81204. | "rg32float"
  81205. | "rgba16uint"
  81206. | "rgba16sint"
  81207. | "rgba16float"
  81208. | "rgba32uint"
  81209. | "rgba32sint"
  81210. | "rgba32float"
  81211. | "stencil8"
  81212. | "depth16unorm"
  81213. | "depth24plus"
  81214. | "depth24plus-stencil8"
  81215. | "depth32float"
  81216. | "bc1-rgba-unorm"
  81217. | "bc1-rgba-unorm-srgb"
  81218. | "bc2-rgba-unorm"
  81219. | "bc2-rgba-unorm-srgb"
  81220. | "bc3-rgba-unorm"
  81221. | "bc3-rgba-unorm-srgb"
  81222. | "bc4-r-unorm"
  81223. | "bc4-r-snorm"
  81224. | "bc5-rg-unorm"
  81225. | "bc5-rg-snorm"
  81226. | "bc6h-rgb-ufloat"
  81227. | "bc6h-rgb-float"
  81228. | "bc7-rgba-unorm"
  81229. | "bc7-rgba-unorm-srgb"
  81230. | "depth24unorm-stencil8"
  81231. | "depth32float-stencil8";
  81232. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81233. type GPUTextureViewDimension =
  81234. | "1d"
  81235. | "2d"
  81236. | "2d-array"
  81237. | "cube"
  81238. | "cube-array"
  81239. | "3d";
  81240. type GPUVertexFormat =
  81241. | "uchar2"
  81242. | "uchar4"
  81243. | "char2"
  81244. | "char4"
  81245. | "uchar2norm"
  81246. | "uchar4norm"
  81247. | "char2norm"
  81248. | "char4norm"
  81249. | "ushort2"
  81250. | "ushort4"
  81251. | "short2"
  81252. | "short4"
  81253. | "ushort2norm"
  81254. | "ushort4norm"
  81255. | "short2norm"
  81256. | "short4norm"
  81257. | "half2"
  81258. | "half4"
  81259. | "float"
  81260. | "float2"
  81261. | "float3"
  81262. | "float4"
  81263. | "uint"
  81264. | "uint2"
  81265. | "uint3"
  81266. | "uint4"
  81267. | "int"
  81268. | "int2"
  81269. | "int3"
  81270. | "int4";
  81271. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81272. type GPUBufferUsageFlags = number;
  81273. type GPUColorWriteFlags = number;
  81274. type GPUShaderStageFlags = number;
  81275. type GPUTextureUsageFlags = number;
  81276. type GPUMapModeFlags = number;
  81277. interface GPUBindGroupEntry {
  81278. binding: number;
  81279. resource: GPUBindingResource;
  81280. }
  81281. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81282. layout: GPUBindGroupLayout;
  81283. entries: Iterable<GPUBindGroupEntry>;
  81284. }
  81285. interface GPUBindGroupLayoutEntry {
  81286. binding: number;
  81287. visibility: GPUShaderStageFlags;
  81288. type: GPUBindingType;
  81289. hasDynamicOffset?: boolean;
  81290. minBufferBindingSize?: number;
  81291. viewDimension?: GPUTextureViewDimension;
  81292. textureComponentType?: GPUTextureComponentType;
  81293. storageTextureFormat?: GPUTextureFormat;
  81294. }
  81295. interface GPUBindGroupLayoutDescriptor
  81296. extends GPUObjectDescriptorBase {
  81297. entries: Iterable<GPUBindGroupLayoutEntry>;
  81298. }
  81299. interface GPUBlendDescriptor {
  81300. dstFactor?: GPUBlendFactor;
  81301. operation?: GPUBlendOperation;
  81302. srcFactor?: GPUBlendFactor;
  81303. }
  81304. interface GPUColorStateDescriptor {
  81305. format: GPUTextureFormat;
  81306. alphaBlend?: GPUBlendDescriptor;
  81307. colorBlend?: GPUBlendDescriptor;
  81308. writeMask?: GPUColorWriteFlags;
  81309. }
  81310. interface GPUBufferBinding {
  81311. buffer: GPUBuffer;
  81312. offset?: number;
  81313. size?: number;
  81314. }
  81315. interface GPUTextureDataLayout {
  81316. offset?: number;
  81317. bytesPerRow: number;
  81318. rowsPerImage?: number;
  81319. }
  81320. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81321. buffer: GPUBuffer;
  81322. }
  81323. interface GPUTextureCopyView {
  81324. texture: GPUTexture;
  81325. mipLevel?: number;
  81326. origin?: GPUOrigin3D;
  81327. }
  81328. interface GPUImageBitmapCopyView {
  81329. imageBitmap: ImageBitmap;
  81330. origin?: GPUOrigin2D;
  81331. }
  81332. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81333. size: number;
  81334. usage: GPUBufferUsageFlags;
  81335. mappedAtCreation?: boolean;
  81336. }
  81337. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81338. label?: string;
  81339. measureExecutionTime?: boolean;
  81340. }
  81341. interface GPUComputePipelineDescriptor
  81342. extends GPUPipelineDescriptorBase {
  81343. computeStage: GPUProgrammableStageDescriptor;
  81344. }
  81345. interface GPUDepthStencilStateDescriptor {
  81346. format: GPUTextureFormat;
  81347. depthWriteEnabled?: boolean;
  81348. depthCompare?: GPUCompareFunction;
  81349. stencilFront?: GPUStencilStateFaceDescriptor;
  81350. stencilBack?: GPUStencilStateFaceDescriptor;
  81351. stencilReadMask?: number;
  81352. stencilWriteMask?: number;
  81353. }
  81354. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81355. extensions?: Iterable<GPUExtensionName>;
  81356. limits?: GPULimits;
  81357. }
  81358. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81359. initialValue?: number;
  81360. label?: string;
  81361. signalQueue?: GPUQueue;
  81362. }
  81363. interface GPUVertexAttributeDescriptor {
  81364. format: GPUVertexFormat;
  81365. offset: number;
  81366. shaderLocation: number;
  81367. }
  81368. interface GPUVertexBufferLayoutDescriptor {
  81369. arrayStride: number;
  81370. stepMode?: GPUInputStepMode;
  81371. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81372. }
  81373. interface GPUVertexStateDescriptor {
  81374. indexFormat?: GPUIndexFormat;
  81375. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81376. }
  81377. interface GPULimits {
  81378. maxBindGroups?: number;
  81379. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81380. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81381. maxSampledTexturesPerShaderStage?: number;
  81382. maxSamplersPerShaderStage?: number;
  81383. maxStorageBuffersPerShaderStage?: number;
  81384. maxStorageTexturesPerShaderStage?: number;
  81385. maxUniformBuffersPerShaderStage?: number;
  81386. maxUniformBufferBindingSize?: number;
  81387. }
  81388. interface GPUPipelineDescriptorBase {
  81389. label?: string;
  81390. layout?: GPUPipelineLayout;
  81391. }
  81392. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81393. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81394. }
  81395. interface GPUProgrammableStageDescriptor {
  81396. module: GPUShaderModule;
  81397. entryPoint: string;
  81398. }
  81399. interface GPURasterizationStateDescriptor {
  81400. frontFace?: GPUFrontFace;
  81401. cullMode?: GPUCullMode;
  81402. clampDepth?: boolean;
  81403. depthBias?: number;
  81404. depthBiasSlopeScale?: number;
  81405. depthBiasClamp?: number;
  81406. }
  81407. interface GPURenderPassColorAttachmentDescriptor {
  81408. attachment: GPUTextureView;
  81409. resolveTarget?: GPUTextureView;
  81410. loadValue: GPULoadOp | GPUColor;
  81411. storeOp?: GPUStoreOp;
  81412. }
  81413. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81414. attachment: GPUTextureView;
  81415. depthLoadValue: GPULoadOp | number;
  81416. depthStoreOp: GPUStoreOp;
  81417. depthReadOnly?: boolean;
  81418. stencilLoadValue: GPULoadOp | number;
  81419. stencilStoreOp: GPUStoreOp;
  81420. stencilReadOnly?: boolean;
  81421. }
  81422. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81423. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81424. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81425. }
  81426. interface GPURenderPipelineDescriptor
  81427. extends GPUPipelineDescriptorBase {
  81428. vertexStage: GPUProgrammableStageDescriptor;
  81429. fragmentStage?: GPUProgrammableStageDescriptor;
  81430. primitiveTopology: GPUPrimitiveTopology;
  81431. rasterizationState?: GPURasterizationStateDescriptor;
  81432. colorStates: Iterable<GPUColorStateDescriptor>;
  81433. depthStencilState?: GPUDepthStencilStateDescriptor;
  81434. vertexState?: GPUVertexStateDescriptor;
  81435. sampleCount?: number;
  81436. sampleMask?: number;
  81437. alphaToCoverageEnabled?: boolean;
  81438. }
  81439. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81440. addressModeU?: GPUAddressMode;
  81441. addressModeV?: GPUAddressMode;
  81442. addressModeW?: GPUAddressMode;
  81443. magFilter?: GPUFilterMode;
  81444. minFilter?: GPUFilterMode;
  81445. mipmapFilter?: GPUFilterMode;
  81446. lodMinClamp?: number;
  81447. lodMaxClamp?: number;
  81448. compare?: GPUCompareFunction;
  81449. maxAnisotropy?: number;
  81450. }
  81451. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81452. code: Uint32Array | string;
  81453. label?: string;
  81454. sourceMap?: object;
  81455. }
  81456. interface GPUStencilStateFaceDescriptor {
  81457. compare?: GPUCompareFunction;
  81458. depthFailOp?: GPUStencilOperation;
  81459. passOp?: GPUStencilOperation;
  81460. failOp?: GPUStencilOperation;
  81461. }
  81462. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81463. device: GPUDevice;
  81464. format: GPUTextureFormat;
  81465. usage?: GPUTextureUsageFlags;
  81466. }
  81467. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81468. size: GPUExtent3D;
  81469. mipLevelCount?: number;
  81470. sampleCount?: number;
  81471. dimension?: GPUTextureDimension;
  81472. format: GPUTextureFormat;
  81473. usage: GPUTextureUsageFlags;
  81474. }
  81475. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81476. format?: GPUTextureFormat;
  81477. dimension?: GPUTextureViewDimension;
  81478. aspect?: GPUTextureAspect;
  81479. baseArrayLayer?: number;
  81480. baseMipLevel?: number;
  81481. arrayLayerCount?: number;
  81482. mipLevelCount?: number;
  81483. }
  81484. declare class GPUAdapter {
  81485. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81486. private __brand: void;
  81487. readonly name: string;
  81488. readonly extensions: GPUExtensionName[];
  81489. readonly limits: Required<GPULimits>;
  81490. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81491. }
  81492. declare class GPUBindGroup implements GPUObjectBase {
  81493. private __brand: void;
  81494. label: string | undefined;
  81495. }
  81496. declare class GPUBindGroupLayout implements GPUObjectBase {
  81497. private __brand: void;
  81498. label: string | undefined;
  81499. }
  81500. declare class GPUBuffer implements GPUObjectBase {
  81501. private __brand: void;
  81502. label: string | undefined;
  81503. destroy(): void;
  81504. unmap(): void;
  81505. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81506. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81507. }
  81508. declare class GPUCommandBuffer implements GPUObjectBase {
  81509. private __brand: void;
  81510. label: string | undefined;
  81511. readonly executionTime: Promise<number>;
  81512. }
  81513. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81514. declare class GPUCommandEncoder implements GPUObjectBase {
  81515. private __brand: void;
  81516. label: string | undefined;
  81517. beginComputePass(
  81518. descriptor?: GPUComputePassDescriptor
  81519. ): GPUComputePassEncoder;
  81520. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81521. copyBufferToBuffer(
  81522. source: GPUBuffer,
  81523. sourceOffset: number,
  81524. destination: GPUBuffer,
  81525. destinationOffset: number,
  81526. size: number
  81527. ): void;
  81528. copyBufferToTexture(
  81529. source: GPUBufferCopyView,
  81530. destination: GPUTextureCopyView,
  81531. copySize: GPUExtent3D
  81532. ): void;
  81533. copyTextureToBuffer(
  81534. source: GPUTextureCopyView,
  81535. destination: GPUBufferCopyView,
  81536. copySize: GPUExtent3D
  81537. ): void;
  81538. copyTextureToTexture(
  81539. source: GPUTextureCopyView,
  81540. destination: GPUTextureCopyView,
  81541. copySize: GPUExtent3D
  81542. ): void;
  81543. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81544. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81545. popDebugGroup(): void;
  81546. pushDebugGroup(groupLabel: string): void;
  81547. insertDebugMarker(markerLabel: string): void;
  81548. }
  81549. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81550. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81551. private __brand: void;
  81552. label: string | undefined;
  81553. setBindGroup(
  81554. index: number,
  81555. bindGroup: GPUBindGroup,
  81556. dynamicOffsets?: Iterable<number>
  81557. ): void;
  81558. popDebugGroup(): void;
  81559. pushDebugGroup(groupLabel: string): void;
  81560. insertDebugMarker(markerLabel: string): void;
  81561. setPipeline(pipeline: GPUComputePipeline): void;
  81562. dispatch(x: number, y?: number, z?: number): void;
  81563. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81564. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81565. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81566. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81567. endPass(): void;
  81568. }
  81569. declare class GPUComputePipeline implements GPUPipelineBase {
  81570. private __brand: void;
  81571. label: string | undefined;
  81572. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81573. }
  81574. interface GPUObjectBase {
  81575. label: string | undefined;
  81576. }
  81577. interface GPUObjectDescriptorBase {
  81578. label?: string;
  81579. }
  81580. // SwapChain / CanvasContext
  81581. declare class GPUCanvasContext {
  81582. private __brand: void;
  81583. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81584. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81585. }
  81586. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81587. private __brand: void;
  81588. label: string | undefined;
  81589. readonly adapter: GPUAdapter;
  81590. readonly extensions: GPUExtensionName[];
  81591. readonly limits: Required<GPULimits>;
  81592. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81593. createBindGroupLayout(
  81594. descriptor: GPUBindGroupLayoutDescriptor
  81595. ): GPUBindGroupLayout;
  81596. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81597. createPipelineLayout(
  81598. descriptor: GPUPipelineLayoutDescriptor
  81599. ): GPUPipelineLayout;
  81600. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81601. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81602. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81603. createComputePipeline(
  81604. descriptor: GPUComputePipelineDescriptor
  81605. ): GPUComputePipeline;
  81606. createRenderPipeline(
  81607. descriptor: GPURenderPipelineDescriptor
  81608. ): GPURenderPipeline;
  81609. createReadyComputePipeline(
  81610. descriptor: GPUComputePipelineDescriptor
  81611. ): Promise<GPUComputePipeline>;
  81612. createReadyRenderPipeline(
  81613. descriptor: GPURenderPipelineDescriptor
  81614. ): Promise<GPURenderPipeline>;
  81615. createCommandEncoder(
  81616. descriptor?: GPUCommandEncoderDescriptor
  81617. ): GPUCommandEncoder;
  81618. createRenderBundleEncoder(
  81619. descriptor: GPURenderBundleEncoderDescriptor
  81620. ): GPURenderBundleEncoder;
  81621. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81622. defaultQueue: GPUQueue;
  81623. pushErrorScope(filter: GPUErrorFilter): void;
  81624. popErrorScope(): Promise<GPUError | null>;
  81625. onuncapturederror: Event | undefined;
  81626. readonly lost: Promise<GPUDeviceLostInfo>;
  81627. }
  81628. declare class GPUFence implements GPUObjectBase {
  81629. private __brand: void;
  81630. label: string | undefined;
  81631. getCompletedValue(): number;
  81632. onCompletion(completionValue: number): Promise<void>;
  81633. }
  81634. interface GPUPipelineBase extends GPUObjectBase {
  81635. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81636. }
  81637. declare class GPUPipelineLayout implements GPUObjectBase {
  81638. private __brand: void;
  81639. label: string | undefined;
  81640. }
  81641. interface GPUProgrammablePassEncoder {
  81642. setBindGroup(
  81643. index: number,
  81644. bindGroup: GPUBindGroup,
  81645. dynamicOffsets?: Iterable<number>
  81646. ): void;
  81647. popDebugGroup(): void;
  81648. pushDebugGroup(groupLabel: string): void;
  81649. insertDebugMarker(markerLabel: string): void;
  81650. }
  81651. declare class GPUQueue implements GPUObjectBase {
  81652. private __brand: void;
  81653. label: string | undefined;
  81654. signal(fence: GPUFence, signalValue: number): void;
  81655. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81656. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81657. writeBuffer(buffer: GPUBuffer,
  81658. bufferOffset: number,
  81659. data: BufferSource | ArrayBuffer,
  81660. dataOffset?: number,
  81661. size?: number): void;
  81662. writeTexture(destination: GPUTextureCopyView,
  81663. data: BufferSource | ArrayBuffer,
  81664. dataLayout: GPUTextureDataLayout,
  81665. size: GPUExtent3D): void;
  81666. copyImageBitmapToTexture(
  81667. source: GPUImageBitmapCopyView,
  81668. destination: GPUTextureCopyView,
  81669. copySize: GPUExtent3D
  81670. ): void;
  81671. }
  81672. type GPUQueryType =
  81673. | "occlusion"
  81674. | "timestamp"
  81675. | "pipeline-statistics";
  81676. type GPUPipelineStatisticName =
  81677. | "vertex-shader-invocations"
  81678. | "clipper-invocations"
  81679. | "clipper-primitives-out"
  81680. | "fragment-shader-invocations"
  81681. | "compute-shader-invocations";
  81682. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81683. type: GPUQueryType;
  81684. count: number;
  81685. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81686. }
  81687. declare class GPUQuerySet implements GPUObjectBase {
  81688. private __brand: void;
  81689. label: string | undefined;
  81690. destroy(): void;
  81691. }
  81692. interface GPURenderEncoderBase {
  81693. setPipeline(pipeline: GPURenderPipeline): void;
  81694. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81695. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81696. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81697. draw(
  81698. vertexCount: number,
  81699. instanceCount?: number,
  81700. firstVertex?: number,
  81701. firstInstance?: number
  81702. ): void;
  81703. drawIndexed(
  81704. indexCount: number,
  81705. instanceCount?: number,
  81706. firstIndex?: number,
  81707. baseVertex?: number,
  81708. firstInstance?: number
  81709. ): void;
  81710. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81711. drawIndexedIndirect(
  81712. indirectBuffer: GPUBuffer,
  81713. indirectOffset: number
  81714. ): void;
  81715. }
  81716. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81717. private __brand: void;
  81718. label: string | undefined;
  81719. setBindGroup(
  81720. index: number,
  81721. bindGroup: GPUBindGroup,
  81722. dynamicOffsets?: Iterable<number>
  81723. ): void;
  81724. popDebugGroup(): void;
  81725. pushDebugGroup(groupLabel: string): void;
  81726. insertDebugMarker(markerLabel: string): void;
  81727. setPipeline(pipeline: GPURenderPipeline): void;
  81728. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81729. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81730. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81731. draw(
  81732. vertexCount: number,
  81733. instanceCount?: number,
  81734. firstVertex?: number,
  81735. firstInstance?: number
  81736. ): void;
  81737. drawIndexed(
  81738. indexCount: number,
  81739. instanceCount?: number,
  81740. firstIndex?: number,
  81741. baseVertex?: number,
  81742. firstInstance?: number
  81743. ): void;
  81744. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81745. drawIndexedIndirect(
  81746. indirectBuffer: GPUBuffer,
  81747. indirectOffset: number
  81748. ): void;
  81749. setViewport(
  81750. x: number,
  81751. y: number,
  81752. width: number,
  81753. height: number,
  81754. minDepth: number,
  81755. maxDepth: number
  81756. ): void;
  81757. setScissorRect(x: number, y: number, width: number, height: number): void;
  81758. setBlendColor(color: GPUColor): void;
  81759. setStencilReference(reference: number): void;
  81760. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81761. beginOcclusionQuery(queryIndex: number): void;
  81762. endOcclusionQuery(): void;
  81763. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81764. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81765. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81766. endPass(): void;
  81767. }
  81768. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81769. declare class GPURenderBundle implements GPUObjectBase {
  81770. private __brand: void;
  81771. label: string | undefined;
  81772. }
  81773. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81774. private __brand: void;
  81775. label: string | undefined;
  81776. setBindGroup(
  81777. index: number,
  81778. bindGroup: GPUBindGroup,
  81779. dynamicOffsets?: Iterable<number>
  81780. ): void;
  81781. popDebugGroup(): void;
  81782. pushDebugGroup(groupLabel: string): void;
  81783. insertDebugMarker(markerLabel: string): void;
  81784. setPipeline(pipeline: GPURenderPipeline): void;
  81785. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81786. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81787. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81788. draw(
  81789. vertexCount: number,
  81790. instanceCount?: number,
  81791. firstVertex?: number,
  81792. firstInstance?: number
  81793. ): void;
  81794. drawIndexed(
  81795. indexCount: number,
  81796. instanceCount?: number,
  81797. firstIndex?: number,
  81798. baseVertex?: number,
  81799. firstInstance?: number
  81800. ): void;
  81801. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81802. drawIndexedIndirect(
  81803. indirectBuffer: GPUBuffer,
  81804. indirectOffset: number
  81805. ): void;
  81806. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81807. }
  81808. interface GPURenderBundleEncoderDescriptor
  81809. extends GPUObjectDescriptorBase {
  81810. colorFormats: Iterable<GPUTextureFormat>;
  81811. depthStencilFormat?: GPUTextureFormat;
  81812. sampleCount?: number;
  81813. }
  81814. declare class GPURenderPipeline implements GPUPipelineBase {
  81815. private __brand: void;
  81816. label: string | undefined;
  81817. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81818. }
  81819. declare class GPUSampler implements GPUObjectBase {
  81820. private __brand: void;
  81821. label: string | undefined;
  81822. }
  81823. type GPUCompilationMessageType =
  81824. | "error"
  81825. | "warning"
  81826. | "info";
  81827. interface GPUCompilationMessage {
  81828. readonly message: string;
  81829. readonly type: GPUCompilationMessageType;
  81830. readonly lineNum: number;
  81831. readonly linePos: number;
  81832. }
  81833. interface GPUCompilationInfo {
  81834. readonly messages: readonly GPUCompilationMessage[];
  81835. }
  81836. declare class GPUShaderModule implements GPUObjectBase {
  81837. private __brand: void;
  81838. label: string | undefined;
  81839. compilationInfo(): Promise<GPUCompilationInfo>;
  81840. }
  81841. declare class GPUSwapChain implements GPUObjectBase {
  81842. private __brand: void;
  81843. label: string | undefined;
  81844. getCurrentTexture(): GPUTexture;
  81845. }
  81846. declare class GPUTexture implements GPUObjectBase {
  81847. private __brand: void;
  81848. label: string | undefined;
  81849. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81850. destroy(): void;
  81851. }
  81852. declare class GPUTextureView implements GPUObjectBase {
  81853. private __brand: void;
  81854. label: string | undefined;
  81855. }
  81856. type GPUPowerPreference = "low-power" | "high-performance";
  81857. interface GPURequestAdapterOptions {
  81858. powerPreference?: GPUPowerPreference;
  81859. }
  81860. declare class GPU {
  81861. private __brand: void;
  81862. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81863. }
  81864. // ****************************************************************************
  81865. // ERROR SCOPES
  81866. // ****************************************************************************
  81867. type GPUErrorFilter = "out-of-memory" | "validation";
  81868. declare class GPUOutOfMemoryError {
  81869. private __brand: void;
  81870. constructor();
  81871. }
  81872. declare class GPUValidationError {
  81873. private __brand: void;
  81874. constructor(message: string);
  81875. readonly message: string;
  81876. }
  81877. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81878. // ****************************************************************************
  81879. // TELEMETRY
  81880. // ****************************************************************************
  81881. declare class GPUUncapturedErrorEvent extends Event {
  81882. private __brand: void;
  81883. constructor(
  81884. type: string,
  81885. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81886. );
  81887. readonly error: GPUError;
  81888. }
  81889. interface GPUUncapturedErrorEventInit extends EventInit {
  81890. error: GPUError;
  81891. }
  81892. declare class GPUDeviceLostInfo {
  81893. private __brand: void;
  81894. readonly message: string;
  81895. }
  81896. // Type definitions for WebVR API
  81897. // Project: https://w3c.github.io/webvr/
  81898. // Definitions by: six a <https://github.com/lostfictions>
  81899. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81900. interface VRDisplay extends EventTarget {
  81901. /**
  81902. * Dictionary of capabilities describing the VRDisplay.
  81903. */
  81904. readonly capabilities: VRDisplayCapabilities;
  81905. /**
  81906. * z-depth defining the far plane of the eye view frustum
  81907. * enables mapping of values in the render target depth
  81908. * attachment to scene coordinates. Initially set to 10000.0.
  81909. */
  81910. depthFar: number;
  81911. /**
  81912. * z-depth defining the near plane of the eye view frustum
  81913. * enables mapping of values in the render target depth
  81914. * attachment to scene coordinates. Initially set to 0.01.
  81915. */
  81916. depthNear: number;
  81917. /**
  81918. * An identifier for this distinct VRDisplay. Used as an
  81919. * association point in the Gamepad API.
  81920. */
  81921. readonly displayId: number;
  81922. /**
  81923. * A display name, a user-readable name identifying it.
  81924. */
  81925. readonly displayName: string;
  81926. readonly isConnected: boolean;
  81927. readonly isPresenting: boolean;
  81928. /**
  81929. * If this VRDisplay supports room-scale experiences, the optional
  81930. * stage attribute contains details on the room-scale parameters.
  81931. */
  81932. readonly stageParameters: VRStageParameters | null;
  81933. /**
  81934. * Passing the value returned by `requestAnimationFrame` to
  81935. * `cancelAnimationFrame` will unregister the callback.
  81936. * @param handle Define the hanle of the request to cancel
  81937. */
  81938. cancelAnimationFrame(handle: number): void;
  81939. /**
  81940. * Stops presenting to the VRDisplay.
  81941. * @returns a promise to know when it stopped
  81942. */
  81943. exitPresent(): Promise<void>;
  81944. /**
  81945. * Return the current VREyeParameters for the given eye.
  81946. * @param whichEye Define the eye we want the parameter for
  81947. * @returns the eye parameters
  81948. */
  81949. getEyeParameters(whichEye: string): VREyeParameters;
  81950. /**
  81951. * Populates the passed VRFrameData with the information required to render
  81952. * the current frame.
  81953. * @param frameData Define the data structure to populate
  81954. * @returns true if ok otherwise false
  81955. */
  81956. getFrameData(frameData: VRFrameData): boolean;
  81957. /**
  81958. * Get the layers currently being presented.
  81959. * @returns the list of VR layers
  81960. */
  81961. getLayers(): VRLayer[];
  81962. /**
  81963. * Return a VRPose containing the future predicted pose of the VRDisplay
  81964. * when the current frame will be presented. The value returned will not
  81965. * change until JavaScript has returned control to the browser.
  81966. *
  81967. * The VRPose will contain the position, orientation, velocity,
  81968. * and acceleration of each of these properties.
  81969. * @returns the pose object
  81970. */
  81971. getPose(): VRPose;
  81972. /**
  81973. * Return the current instantaneous pose of the VRDisplay, with no
  81974. * prediction applied.
  81975. * @returns the current instantaneous pose
  81976. */
  81977. getImmediatePose(): VRPose;
  81978. /**
  81979. * The callback passed to `requestAnimationFrame` will be called
  81980. * any time a new frame should be rendered. When the VRDisplay is
  81981. * presenting the callback will be called at the native refresh
  81982. * rate of the HMD. When not presenting this function acts
  81983. * identically to how window.requestAnimationFrame acts. Content should
  81984. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81985. * asynchronously from other displays and at differing refresh rates.
  81986. * @param callback Define the action to run next frame
  81987. * @returns the request handle it
  81988. */
  81989. requestAnimationFrame(callback: FrameRequestCallback): number;
  81990. /**
  81991. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81992. * Repeat calls while already presenting will update the VRLayers being displayed.
  81993. * @param layers Define the list of layer to present
  81994. * @returns a promise to know when the request has been fulfilled
  81995. */
  81996. requestPresent(layers: VRLayer[]): Promise<void>;
  81997. /**
  81998. * Reset the pose for this display, treating its current position and
  81999. * orientation as the "origin/zero" values. VRPose.position,
  82000. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82001. * updated when calling resetPose(). This should be called in only
  82002. * sitting-space experiences.
  82003. */
  82004. resetPose(): void;
  82005. /**
  82006. * The VRLayer provided to the VRDisplay will be captured and presented
  82007. * in the HMD. Calling this function has the same effect on the source
  82008. * canvas as any other operation that uses its source image, and canvases
  82009. * created without preserveDrawingBuffer set to true will be cleared.
  82010. * @param pose Define the pose to submit
  82011. */
  82012. submitFrame(pose?: VRPose): void;
  82013. }
  82014. declare var VRDisplay: {
  82015. prototype: VRDisplay;
  82016. new(): VRDisplay;
  82017. };
  82018. interface VRLayer {
  82019. leftBounds?: number[] | Float32Array | null;
  82020. rightBounds?: number[] | Float32Array | null;
  82021. source?: HTMLCanvasElement | null;
  82022. }
  82023. interface VRDisplayCapabilities {
  82024. readonly canPresent: boolean;
  82025. readonly hasExternalDisplay: boolean;
  82026. readonly hasOrientation: boolean;
  82027. readonly hasPosition: boolean;
  82028. readonly maxLayers: number;
  82029. }
  82030. interface VREyeParameters {
  82031. /** @deprecated */
  82032. readonly fieldOfView: VRFieldOfView;
  82033. readonly offset: Float32Array;
  82034. readonly renderHeight: number;
  82035. readonly renderWidth: number;
  82036. }
  82037. interface VRFieldOfView {
  82038. readonly downDegrees: number;
  82039. readonly leftDegrees: number;
  82040. readonly rightDegrees: number;
  82041. readonly upDegrees: number;
  82042. }
  82043. interface VRFrameData {
  82044. readonly leftProjectionMatrix: Float32Array;
  82045. readonly leftViewMatrix: Float32Array;
  82046. readonly pose: VRPose;
  82047. readonly rightProjectionMatrix: Float32Array;
  82048. readonly rightViewMatrix: Float32Array;
  82049. readonly timestamp: number;
  82050. }
  82051. interface VRPose {
  82052. readonly angularAcceleration: Float32Array | null;
  82053. readonly angularVelocity: Float32Array | null;
  82054. readonly linearAcceleration: Float32Array | null;
  82055. readonly linearVelocity: Float32Array | null;
  82056. readonly orientation: Float32Array | null;
  82057. readonly position: Float32Array | null;
  82058. readonly timestamp: number;
  82059. }
  82060. interface VRStageParameters {
  82061. sittingToStandingTransform?: Float32Array;
  82062. sizeX?: number;
  82063. sizeY?: number;
  82064. }
  82065. interface Navigator {
  82066. getVRDisplays(): Promise<VRDisplay[]>;
  82067. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82068. }
  82069. interface Window {
  82070. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82071. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82072. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82073. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82074. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82075. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82076. }
  82077. interface Gamepad {
  82078. readonly displayId: number;
  82079. }
  82080. /**
  82081. * Available session modes
  82082. */
  82083. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82084. /**
  82085. * Reference space types
  82086. */
  82087. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82088. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82089. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82090. /**
  82091. * Handedness types
  82092. */
  82093. type XRHandedness = "none" | "left" | "right";
  82094. /**
  82095. * InputSource target ray modes
  82096. */
  82097. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82098. /**
  82099. * Eye types
  82100. */
  82101. type XREye = "none" | "left" | "right";
  82102. /**
  82103. * Type of XR events available
  82104. */
  82105. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82106. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82107. type XRPlaneSet = Set<XRPlane>;
  82108. type XRAnchorSet = Set<XRAnchor>;
  82109. type XREventHandler = (callback: any) => void;
  82110. interface XRLayer extends EventTarget {}
  82111. interface XRSessionInit {
  82112. optionalFeatures?: string[];
  82113. requiredFeatures?: string[];
  82114. trackedImages?: XRTrackedImageInit[];
  82115. }
  82116. interface XRSessionEvent extends Event {
  82117. readonly session: XRSession;
  82118. }
  82119. interface XRSystem {
  82120. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82121. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82122. }
  82123. interface XRViewport {
  82124. readonly x: number;
  82125. readonly y: number;
  82126. readonly width: number;
  82127. readonly height: number;
  82128. }
  82129. interface XRWebGLLayerInit {
  82130. antialias?: boolean;
  82131. depth?: boolean;
  82132. stencil?: boolean;
  82133. alpha?: boolean;
  82134. multiview?: boolean;
  82135. framebufferScaleFactor?: number;
  82136. }
  82137. declare class XRWebGLLayer {
  82138. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82139. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82140. readonly antialias: boolean;
  82141. readonly framebuffer: WebGLFramebuffer;
  82142. readonly framebufferWidth: number;
  82143. readonly framebufferHeight: number;
  82144. readonly ignoreDepthValues: boolean;
  82145. getViewport: (view: XRView) => XRViewport;
  82146. }
  82147. // tslint:disable-next-line no-empty-interface
  82148. interface XRSpace extends EventTarget {}
  82149. interface XRRenderState {
  82150. readonly baseLayer?: XRWebGLLayer;
  82151. readonly depthFar: number;
  82152. readonly depthNear: number;
  82153. readonly inlineVerticalFieldOfView?: number;
  82154. }
  82155. interface XRRenderStateInit extends XRRenderState {
  82156. baseLayer: XRWebGLLayer;
  82157. depthFar: number;
  82158. depthNear: number;
  82159. inlineVerticalFieldOfView?: number;
  82160. layers?: XRLayer[];
  82161. }
  82162. interface XRReferenceSpace extends XRSpace {
  82163. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82164. onreset: XREventHandler;
  82165. }
  82166. interface XRBoundedReferenceSpace extends XRSpace {
  82167. readonly boundsGeometry: DOMPointReadOnly[];
  82168. }
  82169. interface XRInputSource {
  82170. readonly handedness: XRHandedness;
  82171. readonly targetRayMode: XRTargetRayMode;
  82172. readonly targetRaySpace: XRSpace;
  82173. readonly gripSpace?: XRSpace;
  82174. readonly gamepad?: Gamepad;
  82175. readonly profiles: Array<string>;
  82176. readonly hand?: XRHand;
  82177. }
  82178. interface XRPose {
  82179. readonly transform: XRRigidTransform;
  82180. readonly emulatedPosition: boolean;
  82181. }
  82182. interface XRWorldInformation {
  82183. detectedPlanes?: XRPlaneSet;
  82184. }
  82185. interface XRFrame {
  82186. readonly session: XRSession;
  82187. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82188. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82189. // AR
  82190. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82191. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82192. // Anchors
  82193. trackedAnchors?: XRAnchorSet;
  82194. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82195. // World geometries
  82196. worldInformation?: XRWorldInformation;
  82197. // Hand tracking
  82198. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82199. // Image tracking
  82200. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82201. }
  82202. interface XRInputSourceEvent extends Event {
  82203. readonly frame: XRFrame;
  82204. readonly inputSource: XRInputSource;
  82205. }
  82206. type XRInputSourceArray = XRInputSource[];
  82207. interface XRSession {
  82208. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82209. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82210. /**
  82211. * Returns a list of this session's XRInputSources, each representing an input device
  82212. * used to control the camera and/or scene.
  82213. */
  82214. readonly inputSources: Array<XRInputSource>;
  82215. /**
  82216. * object which contains options affecting how the imagery is rendered.
  82217. * This includes things such as the near and far clipping planes
  82218. */
  82219. readonly renderState: XRRenderState;
  82220. readonly visibilityState: XRVisibilityState;
  82221. /**
  82222. * Removes a callback from the animation frame painting callback from
  82223. * XRSession's set of animation frame rendering callbacks, given the
  82224. * identifying handle returned by a previous call to requestAnimationFrame().
  82225. */
  82226. cancelAnimationFrame: (handle: number) => void;
  82227. /**
  82228. * Ends the WebXR session. Returns a promise which resolves when the
  82229. * session has been shut down.
  82230. */
  82231. end(): Promise<void>;
  82232. /**
  82233. * Schedules the specified method to be called the next time the user agent
  82234. * is working on rendering an animation frame for the WebXR device. Returns an
  82235. * integer value which can be used to identify the request for the purposes of
  82236. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82237. * to the Window.requestAnimationFrame() method.
  82238. */
  82239. requestAnimationFrame: XRFrameRequestCallback;
  82240. /**
  82241. * Requests that a new XRReferenceSpace of the specified type be created.
  82242. * Returns a promise which resolves with the XRReferenceSpace or
  82243. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82244. * the requested space type isn't supported by the device.
  82245. */
  82246. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82247. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82248. onend: XREventHandler;
  82249. oninputsourceschange: XREventHandler;
  82250. onselect: XREventHandler;
  82251. onselectstart: XREventHandler;
  82252. onselectend: XREventHandler;
  82253. onsqueeze: XREventHandler;
  82254. onsqueezestart: XREventHandler;
  82255. onsqueezeend: XREventHandler;
  82256. onvisibilitychange: XREventHandler;
  82257. // hit test
  82258. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82259. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82260. // legacy AR hit test
  82261. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82262. // legacy plane detection
  82263. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82264. // image tracking
  82265. getTrackedImageScores?(): XRImageTrackingScore[];
  82266. }
  82267. interface XRViewerPose extends XRPose {
  82268. readonly views: Array<XRView>;
  82269. }
  82270. declare class XRRigidTransform {
  82271. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82272. position: DOMPointReadOnly;
  82273. orientation: DOMPointReadOnly;
  82274. matrix: Float32Array;
  82275. inverse: XRRigidTransform;
  82276. }
  82277. interface XRView {
  82278. readonly eye: XREye;
  82279. readonly projectionMatrix: Float32Array;
  82280. readonly transform: XRRigidTransform;
  82281. readonly recommendedViewportScale?: number;
  82282. requestViewportScale(scale: number): void;
  82283. }
  82284. interface XRInputSourceChangeEvent extends Event {
  82285. session: XRSession;
  82286. removed: Array<XRInputSource>;
  82287. added: Array<XRInputSource>;
  82288. }
  82289. // Experimental/Draft features
  82290. declare class XRRay {
  82291. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82292. origin: DOMPointReadOnly;
  82293. direction: DOMPointReadOnly;
  82294. matrix: Float32Array;
  82295. }
  82296. declare enum XRHitTestTrackableType {
  82297. "point",
  82298. "plane",
  82299. "mesh",
  82300. }
  82301. interface XRHitResult {
  82302. hitMatrix: Float32Array;
  82303. }
  82304. interface XRTransientInputHitTestResult {
  82305. readonly inputSource: XRInputSource;
  82306. readonly results: Array<XRHitTestResult>;
  82307. }
  82308. interface XRHitTestResult {
  82309. getPose(baseSpace: XRSpace): XRPose | undefined;
  82310. // When anchor system is enabled
  82311. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82312. }
  82313. interface XRHitTestSource {
  82314. cancel(): void;
  82315. }
  82316. interface XRTransientInputHitTestSource {
  82317. cancel(): void;
  82318. }
  82319. interface XRHitTestOptionsInit {
  82320. space: XRSpace;
  82321. entityTypes?: Array<XRHitTestTrackableType>;
  82322. offsetRay?: XRRay;
  82323. }
  82324. interface XRTransientInputHitTestOptionsInit {
  82325. profile: string;
  82326. entityTypes?: Array<XRHitTestTrackableType>;
  82327. offsetRay?: XRRay;
  82328. }
  82329. interface XRAnchor {
  82330. anchorSpace: XRSpace;
  82331. delete(): void;
  82332. }
  82333. interface XRPlane {
  82334. orientation: "Horizontal" | "Vertical";
  82335. planeSpace: XRSpace;
  82336. polygon: Array<DOMPointReadOnly>;
  82337. lastChangedTime: number;
  82338. }
  82339. interface XRJointSpace extends XRSpace {}
  82340. interface XRJointPose extends XRPose {
  82341. radius: number | undefined;
  82342. }
  82343. interface XRHand extends Iterable<XRJointSpace> {
  82344. readonly length: number;
  82345. [index: number]: XRJointSpace;
  82346. readonly WRIST: number;
  82347. readonly THUMB_METACARPAL: number;
  82348. readonly THUMB_PHALANX_PROXIMAL: number;
  82349. readonly THUMB_PHALANX_DISTAL: number;
  82350. readonly THUMB_PHALANX_TIP: number;
  82351. readonly INDEX_METACARPAL: number;
  82352. readonly INDEX_PHALANX_PROXIMAL: number;
  82353. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82354. readonly INDEX_PHALANX_DISTAL: number;
  82355. readonly INDEX_PHALANX_TIP: number;
  82356. readonly MIDDLE_METACARPAL: number;
  82357. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82358. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82359. readonly MIDDLE_PHALANX_DISTAL: number;
  82360. readonly MIDDLE_PHALANX_TIP: number;
  82361. readonly RING_METACARPAL: number;
  82362. readonly RING_PHALANX_PROXIMAL: number;
  82363. readonly RING_PHALANX_INTERMEDIATE: number;
  82364. readonly RING_PHALANX_DISTAL: number;
  82365. readonly RING_PHALANX_TIP: number;
  82366. readonly LITTLE_METACARPAL: number;
  82367. readonly LITTLE_PHALANX_PROXIMAL: number;
  82368. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82369. readonly LITTLE_PHALANX_DISTAL: number;
  82370. readonly LITTLE_PHALANX_TIP: number;
  82371. }
  82372. type XRImageTrackingState = "tracked" | "emulated";
  82373. type XRImageTrackingScore = "untrackable" | "trackable";
  82374. interface XRTrackedImageInit {
  82375. image: ImageBitmap;
  82376. widthInMeters: number;
  82377. }
  82378. interface XRImageTrackingResult {
  82379. readonly imageSpace: XRSpace;
  82380. readonly index: number;
  82381. readonly trackingState: XRImageTrackingState;
  82382. readonly measuredWidthInMeters: number;
  82383. }
  82384. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82385. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82386. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82387. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82388. interface XRSceneObject {
  82389. type: XRSceneObjectType;
  82390. }
  82391. interface XRFieldOfView {
  82392. angleLeft: number;
  82393. angleRight: number;
  82394. angleUp: number;
  82395. angleDown: number;
  82396. }
  82397. interface XRFrustum {
  82398. position: DOMPointReadOnly;
  82399. orientation: DOMPointReadOnly;
  82400. fieldOfView: XRFieldOfView;
  82401. farDistance: number;
  82402. }
  82403. interface XRPlane {
  82404. parentSceneObject?: XRSceneObject;
  82405. }
  82406. interface XRMesh {
  82407. meshSpace: XRSpace;
  82408. positions: Float32Array;
  82409. indices: Uint32Array;
  82410. normals?: Float32Array;
  82411. lastChangedTime: number;
  82412. parentSceneObject?: XRSceneObject;
  82413. }
  82414. interface XRFrustumDetectionBoundary {
  82415. type: "frustum";
  82416. frustum: XRFrustum;
  82417. }
  82418. interface XRSphereDetectionBoundary {
  82419. type: "sphere";
  82420. radius: number;
  82421. }
  82422. interface XRBoxDetectionBoundary {
  82423. type: "box";
  82424. extent: DOMPointReadOnly;
  82425. }
  82426. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82427. interface XRGeometryDetectorOptions {
  82428. detectionBoundary?: XRDetectionBoundary;
  82429. updateInterval?: number;
  82430. }
  82431. interface XRSession {
  82432. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82433. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82434. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82435. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82436. }
  82437. interface XRFrame {
  82438. featurePointCloud?: Array<number>;
  82439. }
  82440. type XRMeshSet = Set<XRMesh>;
  82441. interface XRWorldInformation {
  82442. detectedMeshes?: XRMeshSet;
  82443. }
  82444. /**
  82445. * @ignore
  82446. */
  82447. declare module BABYLON.GLTF2.Exporter {
  82448. }
  82449. /**
  82450. * @ignore
  82451. */
  82452. declare module BABYLON.GLTF1 {
  82453. }
  82454. declare module BABYLON.GUI {
  82455. /**
  82456. * Interface used to define a control that can receive focus
  82457. */
  82458. export interface IFocusableControl {
  82459. /**
  82460. * Function called when the control receives the focus
  82461. */
  82462. onFocus(): void;
  82463. /**
  82464. * Function called when the control loses the focus
  82465. */
  82466. onBlur(): void;
  82467. /**
  82468. * Function called to let the control handle keyboard events
  82469. * @param evt defines the current keyboard event
  82470. */
  82471. processKeyboard(evt: KeyboardEvent): void;
  82472. /**
  82473. * Function called to get the list of controls that should not steal the focus from this control
  82474. * @returns an array of controls
  82475. */
  82476. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82477. /**
  82478. * Function to focus the control programmatically
  82479. */
  82480. focus(): void;
  82481. /**
  82482. * Function to unfocus the control programmatically
  82483. */
  82484. blur(): void;
  82485. }
  82486. }
  82487. declare module BABYLON.GUI {
  82488. /**
  82489. * Class used to specific a value and its associated unit
  82490. */
  82491. export class ValueAndUnit {
  82492. /** defines the unit to store */
  82493. unit: number;
  82494. /** defines a boolean indicating if the value can be negative */
  82495. negativeValueAllowed: boolean;
  82496. private _value;
  82497. private _originalUnit;
  82498. /**
  82499. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82500. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82501. */
  82502. ignoreAdaptiveScaling: boolean;
  82503. /**
  82504. * Creates a new ValueAndUnit
  82505. * @param value defines the value to store
  82506. * @param unit defines the unit to store
  82507. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82508. */
  82509. constructor(value: number,
  82510. /** defines the unit to store */
  82511. unit?: number,
  82512. /** defines a boolean indicating if the value can be negative */
  82513. negativeValueAllowed?: boolean);
  82514. /** Gets a boolean indicating if the value is a percentage */
  82515. get isPercentage(): boolean;
  82516. /** Gets a boolean indicating if the value is store as pixel */
  82517. get isPixel(): boolean;
  82518. /** Gets direct internal value */
  82519. get internalValue(): number;
  82520. /**
  82521. * Gets value as pixel
  82522. * @param host defines the root host
  82523. * @param refValue defines the reference value for percentages
  82524. * @returns the value as pixel
  82525. */
  82526. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82527. /**
  82528. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82529. * @param value defines the value to store
  82530. * @param unit defines the unit to store
  82531. * @returns the current ValueAndUnit
  82532. */
  82533. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82534. /**
  82535. * Gets the value accordingly to its unit
  82536. * @param host defines the root host
  82537. * @returns the value
  82538. */
  82539. getValue(host: AdvancedDynamicTexture): number;
  82540. /**
  82541. * Gets a string representation of the value
  82542. * @param host defines the root host
  82543. * @param decimals defines an optional number of decimals to display
  82544. * @returns a string
  82545. */
  82546. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82547. /**
  82548. * Store a value parsed from a string
  82549. * @param source defines the source string
  82550. * @returns true if the value was successfully parsed
  82551. */
  82552. fromString(source: string | number): boolean;
  82553. private static _Regex;
  82554. private static _UNITMODE_PERCENTAGE;
  82555. private static _UNITMODE_PIXEL;
  82556. /** UNITMODE_PERCENTAGE */
  82557. static get UNITMODE_PERCENTAGE(): number;
  82558. /** UNITMODE_PIXEL */
  82559. static get UNITMODE_PIXEL(): number;
  82560. }
  82561. }
  82562. declare module BABYLON.GUI {
  82563. /**
  82564. * Define a style used by control to automatically setup properties based on a template.
  82565. * Only support font related properties so far
  82566. */
  82567. export class Style implements BABYLON.IDisposable {
  82568. private _fontFamily;
  82569. private _fontStyle;
  82570. private _fontWeight;
  82571. /** @hidden */
  82572. _host: AdvancedDynamicTexture;
  82573. /** @hidden */
  82574. _fontSize: ValueAndUnit;
  82575. /**
  82576. * BABYLON.Observable raised when the style values are changed
  82577. */
  82578. onChangedObservable: BABYLON.Observable<Style>;
  82579. /**
  82580. * Creates a new style object
  82581. * @param host defines the AdvancedDynamicTexture which hosts this style
  82582. */
  82583. constructor(host: AdvancedDynamicTexture);
  82584. /**
  82585. * Gets or sets the font size
  82586. */
  82587. get fontSize(): string | number;
  82588. set fontSize(value: string | number);
  82589. /**
  82590. * Gets or sets the font family
  82591. */
  82592. get fontFamily(): string;
  82593. set fontFamily(value: string);
  82594. /**
  82595. * Gets or sets the font style
  82596. */
  82597. get fontStyle(): string;
  82598. set fontStyle(value: string);
  82599. /** Gets or sets font weight */
  82600. get fontWeight(): string;
  82601. set fontWeight(value: string);
  82602. /** Dispose all associated resources */
  82603. dispose(): void;
  82604. }
  82605. }
  82606. declare module BABYLON.GUI {
  82607. /**
  82608. * Class used to transport BABYLON.Vector2 information for pointer events
  82609. */
  82610. export class Vector2WithInfo extends BABYLON.Vector2 {
  82611. /** defines the current mouse button index */
  82612. buttonIndex: number;
  82613. /**
  82614. * Creates a new Vector2WithInfo
  82615. * @param source defines the vector2 data to transport
  82616. * @param buttonIndex defines the current mouse button index
  82617. */
  82618. constructor(source: BABYLON.Vector2,
  82619. /** defines the current mouse button index */
  82620. buttonIndex?: number);
  82621. }
  82622. /** Class used to provide 2D matrix features */
  82623. export class Matrix2D {
  82624. /** Gets the internal array of 6 floats used to store matrix data */
  82625. m: Float32Array;
  82626. /**
  82627. * Creates a new matrix
  82628. * @param m00 defines value for (0, 0)
  82629. * @param m01 defines value for (0, 1)
  82630. * @param m10 defines value for (1, 0)
  82631. * @param m11 defines value for (1, 1)
  82632. * @param m20 defines value for (2, 0)
  82633. * @param m21 defines value for (2, 1)
  82634. */
  82635. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82636. /**
  82637. * Fills the matrix from direct values
  82638. * @param m00 defines value for (0, 0)
  82639. * @param m01 defines value for (0, 1)
  82640. * @param m10 defines value for (1, 0)
  82641. * @param m11 defines value for (1, 1)
  82642. * @param m20 defines value for (2, 0)
  82643. * @param m21 defines value for (2, 1)
  82644. * @returns the current modified matrix
  82645. */
  82646. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82647. /**
  82648. * Gets matrix determinant
  82649. * @returns the determinant
  82650. */
  82651. determinant(): number;
  82652. /**
  82653. * Inverses the matrix and stores it in a target matrix
  82654. * @param result defines the target matrix
  82655. * @returns the current matrix
  82656. */
  82657. invertToRef(result: Matrix2D): Matrix2D;
  82658. /**
  82659. * Multiplies the current matrix with another one
  82660. * @param other defines the second operand
  82661. * @param result defines the target matrix
  82662. * @returns the current matrix
  82663. */
  82664. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82665. /**
  82666. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82667. * @param x defines the x coordinate to transform
  82668. * @param y defines the x coordinate to transform
  82669. * @param result defines the target vector2
  82670. * @returns the current matrix
  82671. */
  82672. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82673. /**
  82674. * Creates an identity matrix
  82675. * @returns a new matrix
  82676. */
  82677. static Identity(): Matrix2D;
  82678. /**
  82679. * Creates a translation matrix and stores it in a target matrix
  82680. * @param x defines the x coordinate of the translation
  82681. * @param y defines the y coordinate of the translation
  82682. * @param result defines the target matrix
  82683. */
  82684. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82685. /**
  82686. * Creates a scaling matrix and stores it in a target matrix
  82687. * @param x defines the x coordinate of the scaling
  82688. * @param y defines the y coordinate of the scaling
  82689. * @param result defines the target matrix
  82690. */
  82691. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82692. /**
  82693. * Creates a rotation matrix and stores it in a target matrix
  82694. * @param angle defines the rotation angle
  82695. * @param result defines the target matrix
  82696. */
  82697. static RotationToRef(angle: number, result: Matrix2D): void;
  82698. private static _TempPreTranslationMatrix;
  82699. private static _TempPostTranslationMatrix;
  82700. private static _TempRotationMatrix;
  82701. private static _TempScalingMatrix;
  82702. private static _TempCompose0;
  82703. private static _TempCompose1;
  82704. private static _TempCompose2;
  82705. /**
  82706. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82707. * @param tx defines the x coordinate of the translation
  82708. * @param ty defines the y coordinate of the translation
  82709. * @param angle defines the rotation angle
  82710. * @param scaleX defines the x coordinate of the scaling
  82711. * @param scaleY defines the y coordinate of the scaling
  82712. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82713. * @param result defines the target matrix
  82714. */
  82715. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82716. }
  82717. }
  82718. declare module BABYLON.GUI {
  82719. /**
  82720. * Class used to store 2D control sizes
  82721. */
  82722. export class Measure {
  82723. /** defines left coordinate */
  82724. left: number;
  82725. /** defines top coordinate */
  82726. top: number;
  82727. /** defines width dimension */
  82728. width: number;
  82729. /** defines height dimension */
  82730. height: number;
  82731. /**
  82732. * Creates a new measure
  82733. * @param left defines left coordinate
  82734. * @param top defines top coordinate
  82735. * @param width defines width dimension
  82736. * @param height defines height dimension
  82737. */
  82738. constructor(
  82739. /** defines left coordinate */
  82740. left: number,
  82741. /** defines top coordinate */
  82742. top: number,
  82743. /** defines width dimension */
  82744. width: number,
  82745. /** defines height dimension */
  82746. height: number);
  82747. /**
  82748. * Copy from another measure
  82749. * @param other defines the other measure to copy from
  82750. */
  82751. copyFrom(other: Measure): void;
  82752. /**
  82753. * Copy from a group of 4 floats
  82754. * @param left defines left coordinate
  82755. * @param top defines top coordinate
  82756. * @param width defines width dimension
  82757. * @param height defines height dimension
  82758. */
  82759. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82760. /**
  82761. * Computes the axis aligned bounding box measure for two given measures
  82762. * @param a Input measure
  82763. * @param b Input measure
  82764. * @param result the resulting bounding measure
  82765. */
  82766. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82767. /**
  82768. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82769. * @param transform the matrix to transform the measure before computing the AABB
  82770. * @param addX number to add to left
  82771. * @param addY number to add to top
  82772. * @param addWidth number to add to width
  82773. * @param addHeight number to add to height
  82774. * @param result the resulting AABB
  82775. */
  82776. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82777. /**
  82778. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82779. * @param transform the matrix to transform the measure before computing the AABB
  82780. * @param result the resulting AABB
  82781. */
  82782. transformToRef(transform: Matrix2D, result: Measure): void;
  82783. /**
  82784. * Check equality between this measure and another one
  82785. * @param other defines the other measures
  82786. * @returns true if both measures are equals
  82787. */
  82788. isEqualsTo(other: Measure): boolean;
  82789. /**
  82790. * Creates an empty measure
  82791. * @returns a new measure
  82792. */
  82793. static Empty(): Measure;
  82794. }
  82795. }
  82796. declare module BABYLON.GUI {
  82797. /**
  82798. * Class used to create texture to support 2D GUI elements
  82799. * @see https://doc.babylonjs.com/how_to/gui
  82800. */
  82801. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82802. /** Define the Uurl to load snippets */
  82803. static SnippetUrl: string;
  82804. /** Snippet ID if the content was created from the snippet server */
  82805. snippetId: string;
  82806. private _isDirty;
  82807. private _renderObserver;
  82808. private _resizeObserver;
  82809. private _preKeyboardObserver;
  82810. private _pointerMoveObserver;
  82811. private _pointerObserver;
  82812. private _canvasPointerOutObserver;
  82813. private _canvasBlurObserver;
  82814. private _background;
  82815. /** @hidden */
  82816. _rootContainer: Container;
  82817. /** @hidden */
  82818. _lastPickedControl: Control;
  82819. /** @hidden */
  82820. _lastControlOver: {
  82821. [pointerId: number]: Control;
  82822. };
  82823. /** @hidden */
  82824. _lastControlDown: {
  82825. [pointerId: number]: Control;
  82826. };
  82827. /** @hidden */
  82828. _capturingControl: {
  82829. [pointerId: number]: Control;
  82830. };
  82831. /** @hidden */
  82832. _shouldBlockPointer: boolean;
  82833. /** @hidden */
  82834. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82835. /** @hidden */
  82836. _linkedControls: Control[];
  82837. private _isFullscreen;
  82838. private _fullscreenViewport;
  82839. private _idealWidth;
  82840. private _idealHeight;
  82841. private _useSmallestIdeal;
  82842. private _renderAtIdealSize;
  82843. private _focusedControl;
  82844. private _blockNextFocusCheck;
  82845. private _renderScale;
  82846. private _rootElement;
  82847. private _cursorChanged;
  82848. private _defaultMousePointerId;
  82849. /** @hidden */
  82850. _numLayoutCalls: number;
  82851. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82852. get numLayoutCalls(): number;
  82853. /** @hidden */
  82854. _numRenderCalls: number;
  82855. /** Gets the number of render calls made the last time the ADT has been rendered */
  82856. get numRenderCalls(): number;
  82857. /**
  82858. * Define type to string to ensure compatibility across browsers
  82859. * Safari doesn't support DataTransfer constructor
  82860. */
  82861. private _clipboardData;
  82862. /**
  82863. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82864. */
  82865. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82866. /**
  82867. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82868. */
  82869. onControlPickedObservable: BABYLON.Observable<Control>;
  82870. /**
  82871. * BABYLON.Observable event triggered before layout is evaluated
  82872. */
  82873. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82874. /**
  82875. * BABYLON.Observable event triggered after the layout was evaluated
  82876. */
  82877. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82878. /**
  82879. * BABYLON.Observable event triggered before the texture is rendered
  82880. */
  82881. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82882. /**
  82883. * BABYLON.Observable event triggered after the texture was rendered
  82884. */
  82885. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82886. /**
  82887. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82888. */
  82889. premulAlpha: boolean;
  82890. /**
  82891. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82892. */
  82893. applyYInversionOnUpdate: boolean;
  82894. /**
  82895. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82896. * Useful when you want more antialiasing
  82897. */
  82898. get renderScale(): number;
  82899. set renderScale(value: number);
  82900. /** Gets or sets the background color */
  82901. get background(): string;
  82902. set background(value: string);
  82903. /**
  82904. * Gets or sets the ideal width used to design controls.
  82905. * The GUI will then rescale everything accordingly
  82906. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82907. */
  82908. get idealWidth(): number;
  82909. set idealWidth(value: number);
  82910. /**
  82911. * Gets or sets the ideal height used to design controls.
  82912. * The GUI will then rescale everything accordingly
  82913. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82914. */
  82915. get idealHeight(): number;
  82916. set idealHeight(value: number);
  82917. /**
  82918. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82919. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82920. */
  82921. get useSmallestIdeal(): boolean;
  82922. set useSmallestIdeal(value: boolean);
  82923. /**
  82924. * Gets or sets a boolean indicating if adaptive scaling must be used
  82925. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82926. */
  82927. get renderAtIdealSize(): boolean;
  82928. set renderAtIdealSize(value: boolean);
  82929. /**
  82930. * Gets the ratio used when in "ideal mode"
  82931. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82932. * */
  82933. get idealRatio(): number;
  82934. /**
  82935. * Gets the underlying layer used to render the texture when in fullscreen mode
  82936. */
  82937. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82938. /**
  82939. * Gets the root container control
  82940. */
  82941. get rootContainer(): Container;
  82942. /**
  82943. * Returns an array containing the root container.
  82944. * This is mostly used to let the Inspector introspects the ADT
  82945. * @returns an array containing the rootContainer
  82946. */
  82947. getChildren(): Array<Container>;
  82948. /**
  82949. * Will return all controls that are inside this texture
  82950. * @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
  82951. * @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
  82952. * @return all child controls
  82953. */
  82954. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82955. /**
  82956. * Gets or sets the current focused control
  82957. */
  82958. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82959. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82960. /**
  82961. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82962. */
  82963. get isForeground(): boolean;
  82964. set isForeground(value: boolean);
  82965. /**
  82966. * Gets or set information about clipboardData
  82967. */
  82968. get clipboardData(): string;
  82969. set clipboardData(value: string);
  82970. /**
  82971. * Creates a new AdvancedDynamicTexture
  82972. * @param name defines the name of the texture
  82973. * @param width defines the width of the texture
  82974. * @param height defines the height of the texture
  82975. * @param scene defines the hosting scene
  82976. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82977. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82978. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82979. */
  82980. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82981. /**
  82982. * Get the current class name of the texture useful for serialization or dynamic coding.
  82983. * @returns "AdvancedDynamicTexture"
  82984. */
  82985. getClassName(): string;
  82986. /**
  82987. * Function used to execute a function on all controls
  82988. * @param func defines the function to execute
  82989. * @param container defines the container where controls belong. If null the root container will be used
  82990. */
  82991. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82992. private _useInvalidateRectOptimization;
  82993. /**
  82994. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82995. */
  82996. get useInvalidateRectOptimization(): boolean;
  82997. set useInvalidateRectOptimization(value: boolean);
  82998. private _invalidatedRectangle;
  82999. /**
  83000. * Invalidates a rectangle area on the gui texture
  83001. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83002. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83003. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83004. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83005. */
  83006. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83007. /**
  83008. * Marks the texture as dirty forcing a complete update
  83009. */
  83010. markAsDirty(): void;
  83011. /**
  83012. * Helper function used to create a new style
  83013. * @returns a new style
  83014. * @see https://doc.babylonjs.com/how_to/gui#styles
  83015. */
  83016. createStyle(): Style;
  83017. /**
  83018. * Adds a new control to the root container
  83019. * @param control defines the control to add
  83020. * @returns the current texture
  83021. */
  83022. addControl(control: Control): AdvancedDynamicTexture;
  83023. /**
  83024. * Removes a control from the root container
  83025. * @param control defines the control to remove
  83026. * @returns the current texture
  83027. */
  83028. removeControl(control: Control): AdvancedDynamicTexture;
  83029. /**
  83030. * Release all resources
  83031. */
  83032. dispose(): void;
  83033. private _onResize;
  83034. /** @hidden */
  83035. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83036. /**
  83037. * Get screen coordinates for a vector3
  83038. * @param position defines the position to project
  83039. * @param worldMatrix defines the world matrix to use
  83040. * @returns the projected position
  83041. */
  83042. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83043. /**
  83044. * Get screen coordinates for a vector3
  83045. * @param position defines the position to project
  83046. * @param worldMatrix defines the world matrix to use
  83047. * @returns the projected position with Z
  83048. */
  83049. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83050. private _checkUpdate;
  83051. private _clearMeasure;
  83052. private _render;
  83053. /** @hidden */
  83054. _changeCursor(cursor: string): void;
  83055. /** @hidden */
  83056. _registerLastControlDown(control: Control, pointerId: number): void;
  83057. private _doPicking;
  83058. /** @hidden */
  83059. _cleanControlAfterRemovalFromList(list: {
  83060. [pointerId: number]: Control;
  83061. }, control: Control): void;
  83062. /** @hidden */
  83063. _cleanControlAfterRemoval(control: Control): void;
  83064. /** Attach to all scene events required to support pointer events */
  83065. attach(): void;
  83066. /** @hidden */
  83067. private onClipboardCopy;
  83068. /** @hidden */
  83069. private onClipboardCut;
  83070. /** @hidden */
  83071. private onClipboardPaste;
  83072. /**
  83073. * Register the clipboard Events onto the canvas
  83074. */
  83075. registerClipboardEvents(): void;
  83076. /**
  83077. * Unregister the clipboard Events from the canvas
  83078. */
  83079. unRegisterClipboardEvents(): void;
  83080. /**
  83081. * Connect the texture to a hosting mesh to enable interactions
  83082. * @param mesh defines the mesh to attach to
  83083. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83084. */
  83085. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83086. /**
  83087. * Move the focus to a specific control
  83088. * @param control defines the control which will receive the focus
  83089. */
  83090. moveFocusToControl(control: IFocusableControl): void;
  83091. private _manageFocus;
  83092. private _attachToOnPointerOut;
  83093. private _attachToOnBlur;
  83094. /**
  83095. * Serializes the entire GUI system
  83096. * @returns an object with the JSON serialized data
  83097. */
  83098. serializeContent(): any;
  83099. /**
  83100. * Recreate the content of the ADT from a JSON object
  83101. * @param serializedObject define the JSON serialized object to restore from
  83102. */
  83103. parseContent(serializedObject: any): void;
  83104. /**
  83105. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83106. * @param snippetId defines the snippet to load
  83107. * @returns a promise that will resolve on success
  83108. */
  83109. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83110. /**
  83111. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83112. * @param mesh defines the mesh which will receive the texture
  83113. * @param width defines the texture width (1024 by default)
  83114. * @param height defines the texture height (1024 by default)
  83115. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83116. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83117. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83118. * @returns a new AdvancedDynamicTexture
  83119. */
  83120. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83121. /**
  83122. * 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
  83123. * @param mesh defines the mesh which will receive the texture
  83124. * @param width defines the texture width (1024 by default)
  83125. * @param height defines the texture height (1024 by default)
  83126. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83127. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83128. * @returns a new AdvancedDynamicTexture
  83129. */
  83130. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83131. /**
  83132. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83133. * In this mode the texture will rely on a layer for its rendering.
  83134. * This allows it to be treated like any other layer.
  83135. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83136. * LayerMask is set through advancedTexture.layer.layerMask
  83137. * @param name defines name for the texture
  83138. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83139. * @param scene defines the hsoting scene
  83140. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83141. * @returns a new AdvancedDynamicTexture
  83142. */
  83143. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83144. }
  83145. }
  83146. declare module BABYLON.GUI {
  83147. /**
  83148. * Root class used for all 2D controls
  83149. * @see https://doc.babylonjs.com/how_to/gui#controls
  83150. */
  83151. export class Control {
  83152. /** defines the name of the control */
  83153. name?: string | undefined;
  83154. /**
  83155. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83156. */
  83157. static AllowAlphaInheritance: boolean;
  83158. private _alpha;
  83159. private _alphaSet;
  83160. private _zIndex;
  83161. /** @hidden */
  83162. _host: AdvancedDynamicTexture;
  83163. /** Gets or sets the control parent */
  83164. parent: BABYLON.Nullable<Container>;
  83165. /** @hidden */
  83166. _currentMeasure: Measure;
  83167. private _fontFamily;
  83168. private _fontStyle;
  83169. private _fontWeight;
  83170. private _fontSize;
  83171. private _font;
  83172. /** @hidden */
  83173. _width: ValueAndUnit;
  83174. /** @hidden */
  83175. _height: ValueAndUnit;
  83176. /** @hidden */
  83177. protected _fontOffset: {
  83178. ascent: number;
  83179. height: number;
  83180. descent: number;
  83181. };
  83182. private _color;
  83183. private _style;
  83184. private _styleObserver;
  83185. /** @hidden */
  83186. protected _horizontalAlignment: number;
  83187. /** @hidden */
  83188. protected _verticalAlignment: number;
  83189. /** @hidden */
  83190. protected _isDirty: boolean;
  83191. /** @hidden */
  83192. protected _wasDirty: boolean;
  83193. /** @hidden */
  83194. _tempParentMeasure: Measure;
  83195. /** @hidden */
  83196. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83197. /** @hidden */
  83198. protected _cachedParentMeasure: Measure;
  83199. private _paddingLeft;
  83200. private _paddingRight;
  83201. private _paddingTop;
  83202. private _paddingBottom;
  83203. /** @hidden */
  83204. _left: ValueAndUnit;
  83205. /** @hidden */
  83206. _top: ValueAndUnit;
  83207. private _scaleX;
  83208. private _scaleY;
  83209. private _rotation;
  83210. private _transformCenterX;
  83211. private _transformCenterY;
  83212. /** @hidden */
  83213. _transformMatrix: Matrix2D;
  83214. /** @hidden */
  83215. protected _invertTransformMatrix: Matrix2D;
  83216. /** @hidden */
  83217. protected _transformedPosition: BABYLON.Vector2;
  83218. private _isMatrixDirty;
  83219. private _cachedOffsetX;
  83220. private _cachedOffsetY;
  83221. private _isVisible;
  83222. private _isHighlighted;
  83223. /** @hidden */
  83224. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83225. private _fontSet;
  83226. private _dummyVector2;
  83227. private _downCount;
  83228. private _enterCount;
  83229. private _doNotRender;
  83230. private _downPointerIds;
  83231. protected _isEnabled: boolean;
  83232. protected _disabledColor: string;
  83233. protected _disabledColorItem: string;
  83234. /** @hidden */
  83235. protected _rebuildLayout: boolean;
  83236. /** @hidden */
  83237. _customData: any;
  83238. /** @hidden */
  83239. _isClipped: boolean;
  83240. /** @hidden */
  83241. _automaticSize: boolean;
  83242. /** @hidden */
  83243. _tag: any;
  83244. /**
  83245. * 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
  83246. */
  83247. uniqueId: number;
  83248. /**
  83249. * Gets or sets an object used to store user defined information for the node
  83250. */
  83251. metadata: any;
  83252. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83253. isHitTestVisible: boolean;
  83254. /** Gets or sets a boolean indicating if the control can block pointer events */
  83255. isPointerBlocker: boolean;
  83256. /** Gets or sets a boolean indicating if the control can be focusable */
  83257. isFocusInvisible: boolean;
  83258. /**
  83259. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83260. * 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
  83261. */
  83262. clipChildren: boolean;
  83263. /**
  83264. * Gets or sets a boolean indicating that control content must be clipped
  83265. * 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
  83266. */
  83267. clipContent: boolean;
  83268. /**
  83269. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83270. */
  83271. useBitmapCache: boolean;
  83272. private _cacheData;
  83273. private _shadowOffsetX;
  83274. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83275. get shadowOffsetX(): number;
  83276. set shadowOffsetX(value: number);
  83277. private _shadowOffsetY;
  83278. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83279. get shadowOffsetY(): number;
  83280. set shadowOffsetY(value: number);
  83281. private _shadowBlur;
  83282. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83283. get shadowBlur(): number;
  83284. set shadowBlur(value: number);
  83285. private _shadowColor;
  83286. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83287. get shadowColor(): string;
  83288. set shadowColor(value: string);
  83289. /** Gets or sets the cursor to use when the control is hovered */
  83290. hoverCursor: string;
  83291. /** @hidden */
  83292. protected _linkOffsetX: ValueAndUnit;
  83293. /** @hidden */
  83294. protected _linkOffsetY: ValueAndUnit;
  83295. /** Gets the control type name */
  83296. get typeName(): string;
  83297. /**
  83298. * Get the current class name of the control.
  83299. * @returns current class name
  83300. */
  83301. getClassName(): string;
  83302. /**
  83303. * An event triggered when pointer wheel is scrolled
  83304. */
  83305. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83306. /**
  83307. * An event triggered when the pointer move over the control.
  83308. */
  83309. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83310. /**
  83311. * An event triggered when the pointer move out of the control.
  83312. */
  83313. onPointerOutObservable: BABYLON.Observable<Control>;
  83314. /**
  83315. * An event triggered when the pointer taps the control
  83316. */
  83317. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83318. /**
  83319. * An event triggered when pointer up
  83320. */
  83321. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83322. /**
  83323. * An event triggered when a control is clicked on
  83324. */
  83325. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83326. /**
  83327. * An event triggered when pointer enters the control
  83328. */
  83329. onPointerEnterObservable: BABYLON.Observable<Control>;
  83330. /**
  83331. * An event triggered when the control is marked as dirty
  83332. */
  83333. onDirtyObservable: BABYLON.Observable<Control>;
  83334. /**
  83335. * An event triggered before drawing the control
  83336. */
  83337. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83338. /**
  83339. * An event triggered after the control was drawn
  83340. */
  83341. onAfterDrawObservable: BABYLON.Observable<Control>;
  83342. /**
  83343. * An event triggered when the control has been disposed
  83344. */
  83345. onDisposeObservable: BABYLON.Observable<Control>;
  83346. /**
  83347. * Get the hosting AdvancedDynamicTexture
  83348. */
  83349. get host(): AdvancedDynamicTexture;
  83350. /** Gets or set information about font offsets (used to render and align text) */
  83351. get fontOffset(): {
  83352. ascent: number;
  83353. height: number;
  83354. descent: number;
  83355. };
  83356. set fontOffset(offset: {
  83357. ascent: number;
  83358. height: number;
  83359. descent: number;
  83360. });
  83361. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83362. get alpha(): number;
  83363. set alpha(value: number);
  83364. /**
  83365. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83366. */
  83367. get isHighlighted(): boolean;
  83368. set isHighlighted(value: boolean);
  83369. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83370. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83371. */
  83372. get scaleX(): number;
  83373. set scaleX(value: number);
  83374. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83375. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83376. */
  83377. get scaleY(): number;
  83378. set scaleY(value: number);
  83379. /** Gets or sets the rotation angle (0 by default)
  83380. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83381. */
  83382. get rotation(): number;
  83383. set rotation(value: number);
  83384. /** Gets or sets the transformation center on Y axis (0 by default)
  83385. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83386. */
  83387. get transformCenterY(): number;
  83388. set transformCenterY(value: number);
  83389. /** Gets or sets the transformation center on X axis (0 by default)
  83390. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83391. */
  83392. get transformCenterX(): number;
  83393. set transformCenterX(value: number);
  83394. /**
  83395. * Gets or sets the horizontal alignment
  83396. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83397. */
  83398. get horizontalAlignment(): number;
  83399. set horizontalAlignment(value: number);
  83400. /**
  83401. * Gets or sets the vertical alignment
  83402. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83403. */
  83404. get verticalAlignment(): number;
  83405. set verticalAlignment(value: number);
  83406. /**
  83407. * Gets or sets a fixed ratio for this control.
  83408. * When different from 0, the ratio is used to compute the "second" dimension.
  83409. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83410. * second dimension is computed as first dimension * fixedRatio
  83411. */
  83412. fixedRatio: number;
  83413. private _fixedRatioMasterIsWidth;
  83414. /**
  83415. * Gets or sets control width
  83416. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83417. */
  83418. get width(): string | number;
  83419. set width(value: string | number);
  83420. /**
  83421. * Gets or sets the control width in pixel
  83422. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83423. */
  83424. get widthInPixels(): number;
  83425. set widthInPixels(value: number);
  83426. /**
  83427. * Gets or sets control height
  83428. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83429. */
  83430. get height(): string | number;
  83431. set height(value: string | number);
  83432. /**
  83433. * Gets or sets control height in pixel
  83434. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83435. */
  83436. get heightInPixels(): number;
  83437. set heightInPixels(value: number);
  83438. /** Gets or set font family */
  83439. get fontFamily(): string;
  83440. set fontFamily(value: string);
  83441. /** Gets or sets font style */
  83442. get fontStyle(): string;
  83443. set fontStyle(value: string);
  83444. /** Gets or sets font weight */
  83445. get fontWeight(): string;
  83446. set fontWeight(value: string);
  83447. /**
  83448. * Gets or sets style
  83449. * @see https://doc.babylonjs.com/how_to/gui#styles
  83450. */
  83451. get style(): BABYLON.Nullable<Style>;
  83452. set style(value: BABYLON.Nullable<Style>);
  83453. /** @hidden */
  83454. get _isFontSizeInPercentage(): boolean;
  83455. /** Gets or sets font size in pixels */
  83456. get fontSizeInPixels(): number;
  83457. set fontSizeInPixels(value: number);
  83458. /** Gets or sets font size */
  83459. get fontSize(): string | number;
  83460. set fontSize(value: string | number);
  83461. /** Gets or sets foreground color */
  83462. get color(): string;
  83463. set color(value: string);
  83464. /** Gets or sets z index which is used to reorder controls on the z axis */
  83465. get zIndex(): number;
  83466. set zIndex(value: number);
  83467. /** Gets or sets a boolean indicating if the control can be rendered */
  83468. get notRenderable(): boolean;
  83469. set notRenderable(value: boolean);
  83470. /** Gets or sets a boolean indicating if the control is visible */
  83471. get isVisible(): boolean;
  83472. set isVisible(value: boolean);
  83473. /** Gets a boolean indicating that the control needs to update its rendering */
  83474. get isDirty(): boolean;
  83475. /**
  83476. * Gets the current linked mesh (or null if none)
  83477. */
  83478. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83479. /**
  83480. * Gets or sets a value indicating the padding to use on the left of the control
  83481. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83482. */
  83483. get paddingLeft(): string | number;
  83484. set paddingLeft(value: string | number);
  83485. /**
  83486. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83487. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83488. */
  83489. get paddingLeftInPixels(): number;
  83490. set paddingLeftInPixels(value: number);
  83491. /**
  83492. * Gets or sets a value indicating the padding to use on the right of the control
  83493. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83494. */
  83495. get paddingRight(): string | number;
  83496. set paddingRight(value: string | number);
  83497. /**
  83498. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83499. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83500. */
  83501. get paddingRightInPixels(): number;
  83502. set paddingRightInPixels(value: number);
  83503. /**
  83504. * Gets or sets a value indicating the padding to use on the top of the control
  83505. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83506. */
  83507. get paddingTop(): string | number;
  83508. set paddingTop(value: string | number);
  83509. /**
  83510. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83511. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83512. */
  83513. get paddingTopInPixels(): number;
  83514. set paddingTopInPixels(value: number);
  83515. /**
  83516. * Gets or sets a value indicating the padding to use on the bottom of the control
  83517. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83518. */
  83519. get paddingBottom(): string | number;
  83520. set paddingBottom(value: string | number);
  83521. /**
  83522. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83523. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83524. */
  83525. get paddingBottomInPixels(): number;
  83526. set paddingBottomInPixels(value: number);
  83527. /**
  83528. * Gets or sets a value indicating the left coordinate of the control
  83529. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83530. */
  83531. get left(): string | number;
  83532. set left(value: string | number);
  83533. /**
  83534. * Gets or sets a value indicating the left coordinate in pixels of the control
  83535. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83536. */
  83537. get leftInPixels(): number;
  83538. set leftInPixels(value: number);
  83539. /**
  83540. * Gets or sets a value indicating the top coordinate of the control
  83541. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83542. */
  83543. get top(): string | number;
  83544. set top(value: string | number);
  83545. /**
  83546. * Gets or sets a value indicating the top coordinate in pixels of the control
  83547. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83548. */
  83549. get topInPixels(): number;
  83550. set topInPixels(value: number);
  83551. /**
  83552. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83553. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83554. */
  83555. get linkOffsetX(): string | number;
  83556. set linkOffsetX(value: string | number);
  83557. /**
  83558. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83559. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83560. */
  83561. get linkOffsetXInPixels(): number;
  83562. set linkOffsetXInPixels(value: number);
  83563. /**
  83564. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83565. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83566. */
  83567. get linkOffsetY(): string | number;
  83568. set linkOffsetY(value: string | number);
  83569. /**
  83570. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83571. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83572. */
  83573. get linkOffsetYInPixels(): number;
  83574. set linkOffsetYInPixels(value: number);
  83575. /** Gets the center coordinate on X axis */
  83576. get centerX(): number;
  83577. /** Gets the center coordinate on Y axis */
  83578. get centerY(): number;
  83579. /** Gets or sets if control is Enabled */
  83580. get isEnabled(): boolean;
  83581. set isEnabled(value: boolean);
  83582. /** Gets or sets background color of control if it's disabled */
  83583. get disabledColor(): string;
  83584. set disabledColor(value: string);
  83585. /** Gets or sets front color of control if it's disabled */
  83586. get disabledColorItem(): string;
  83587. set disabledColorItem(value: string);
  83588. /**
  83589. * Creates a new control
  83590. * @param name defines the name of the control
  83591. */
  83592. constructor(
  83593. /** defines the name of the control */
  83594. name?: string | undefined);
  83595. /** @hidden */
  83596. protected _getTypeName(): string;
  83597. /**
  83598. * Gets the first ascendant in the hierarchy of the given type
  83599. * @param className defines the required type
  83600. * @returns the ascendant or null if not found
  83601. */
  83602. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83603. /** @hidden */
  83604. _resetFontCache(): void;
  83605. /**
  83606. * Determines if a container is an ascendant of the current control
  83607. * @param container defines the container to look for
  83608. * @returns true if the container is one of the ascendant of the control
  83609. */
  83610. isAscendant(container: Control): boolean;
  83611. /**
  83612. * Gets coordinates in local control space
  83613. * @param globalCoordinates defines the coordinates to transform
  83614. * @returns the new coordinates in local space
  83615. */
  83616. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83617. /**
  83618. * Gets coordinates in local control space
  83619. * @param globalCoordinates defines the coordinates to transform
  83620. * @param result defines the target vector2 where to store the result
  83621. * @returns the current control
  83622. */
  83623. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83624. /**
  83625. * Gets coordinates in parent local control space
  83626. * @param globalCoordinates defines the coordinates to transform
  83627. * @returns the new coordinates in parent local space
  83628. */
  83629. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83630. /**
  83631. * Move the current control to a vector3 position projected onto the screen.
  83632. * @param position defines the target position
  83633. * @param scene defines the hosting scene
  83634. */
  83635. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83636. /**
  83637. * Will store all controls that have this control as ascendant in a given array
  83638. * @param results defines the array where to store the descendants
  83639. * @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
  83640. * @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
  83641. */
  83642. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83643. /**
  83644. * Will return all controls that have this control as ascendant
  83645. * @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
  83646. * @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
  83647. * @return all child controls
  83648. */
  83649. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83650. /**
  83651. * Link current control with a target mesh
  83652. * @param mesh defines the mesh to link with
  83653. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83654. */
  83655. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83656. /**
  83657. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83658. * @param { string | number} paddingTop - The value of the top padding.
  83659. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83660. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83661. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83662. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83663. */
  83664. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83665. /**
  83666. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83667. * @param { number} paddingTop - The value in pixels of the top padding.
  83668. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83669. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83670. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83671. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83672. */
  83673. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83674. /** @hidden */
  83675. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83676. /** @hidden */
  83677. _offsetLeft(offset: number): void;
  83678. /** @hidden */
  83679. _offsetTop(offset: number): void;
  83680. /** @hidden */
  83681. _markMatrixAsDirty(): void;
  83682. /** @hidden */
  83683. _flagDescendantsAsMatrixDirty(): void;
  83684. /** @hidden */
  83685. _intersectsRect(rect: Measure): boolean;
  83686. /** @hidden */
  83687. protected invalidateRect(): void;
  83688. /** @hidden */
  83689. _markAsDirty(force?: boolean): void;
  83690. /** @hidden */
  83691. _markAllAsDirty(): void;
  83692. /** @hidden */
  83693. _link(host: AdvancedDynamicTexture): void;
  83694. /** @hidden */
  83695. protected _transform(context?: CanvasRenderingContext2D): void;
  83696. /** @hidden */
  83697. _renderHighlight(context: CanvasRenderingContext2D): void;
  83698. /** @hidden */
  83699. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83700. /** @hidden */
  83701. protected _applyStates(context: CanvasRenderingContext2D): void;
  83702. /** @hidden */
  83703. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83704. /** @hidden */
  83705. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83706. protected _evaluateClippingState(parentMeasure: Measure): void;
  83707. /** @hidden */
  83708. _measure(): void;
  83709. /** @hidden */
  83710. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83711. /** @hidden */
  83712. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83713. /** @hidden */
  83714. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83715. /** @hidden */
  83716. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83717. private static _ClipMeasure;
  83718. private _tmpMeasureA;
  83719. private _clip;
  83720. /** @hidden */
  83721. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83722. /** @hidden */
  83723. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83724. /**
  83725. * Tests if a given coordinates belong to the current control
  83726. * @param x defines x coordinate to test
  83727. * @param y defines y coordinate to test
  83728. * @returns true if the coordinates are inside the control
  83729. */
  83730. contains(x: number, y: number): boolean;
  83731. /** @hidden */
  83732. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83733. /** @hidden */
  83734. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83735. /** @hidden */
  83736. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83737. /** @hidden */
  83738. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83739. /** @hidden */
  83740. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83741. /** @hidden */
  83742. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83743. /** @hidden */
  83744. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83745. /** @hidden */
  83746. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83747. /** @hidden */
  83748. _onCanvasBlur(): void;
  83749. /** @hidden */
  83750. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83751. private _prepareFont;
  83752. /**
  83753. * Serializes the current control
  83754. * @param serializationObject defined the JSON serialized object
  83755. */
  83756. serialize(serializationObject: any): void;
  83757. /** @hidden */
  83758. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83759. /** Releases associated resources */
  83760. dispose(): void;
  83761. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83762. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83763. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83764. private static _VERTICAL_ALIGNMENT_TOP;
  83765. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83766. private static _VERTICAL_ALIGNMENT_CENTER;
  83767. /** HORIZONTAL_ALIGNMENT_LEFT */
  83768. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83769. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83770. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83771. /** HORIZONTAL_ALIGNMENT_CENTER */
  83772. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83773. /** VERTICAL_ALIGNMENT_TOP */
  83774. static get VERTICAL_ALIGNMENT_TOP(): number;
  83775. /** VERTICAL_ALIGNMENT_BOTTOM */
  83776. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83777. /** VERTICAL_ALIGNMENT_CENTER */
  83778. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83779. private static _FontHeightSizes;
  83780. /** @hidden */
  83781. static _GetFontOffset(font: string): {
  83782. ascent: number;
  83783. height: number;
  83784. descent: number;
  83785. };
  83786. /**
  83787. * Creates a Control from parsed data
  83788. * @param serializedObject defines parsed data
  83789. * @param host defines the hosting AdvancedDynamicTexture
  83790. * @returns a new Control
  83791. */
  83792. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83793. /**
  83794. * Creates a stack panel that can be used to render headers
  83795. * @param control defines the control to associate with the header
  83796. * @param text defines the text of the header
  83797. * @param size defines the size of the header
  83798. * @param options defines options used to configure the header
  83799. * @returns a new StackPanel
  83800. * @ignore
  83801. * @hidden
  83802. */
  83803. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83804. isHorizontal: boolean;
  83805. controlFirst: boolean;
  83806. }) => any;
  83807. /** @hidden */
  83808. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83809. }
  83810. }
  83811. declare module BABYLON.GUI {
  83812. /**
  83813. * Root class for 2D containers
  83814. * @see https://doc.babylonjs.com/how_to/gui#containers
  83815. */
  83816. export class Container extends Control {
  83817. name?: string | undefined;
  83818. /** @hidden */
  83819. _children: Control[];
  83820. /** @hidden */
  83821. protected _measureForChildren: Measure;
  83822. /** @hidden */
  83823. protected _background: string;
  83824. /** @hidden */
  83825. protected _adaptWidthToChildren: boolean;
  83826. /** @hidden */
  83827. protected _adaptHeightToChildren: boolean;
  83828. /**
  83829. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83830. */
  83831. logLayoutCycleErrors: boolean;
  83832. /**
  83833. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83834. */
  83835. maxLayoutCycle: number;
  83836. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83837. get adaptHeightToChildren(): boolean;
  83838. set adaptHeightToChildren(value: boolean);
  83839. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83840. get adaptWidthToChildren(): boolean;
  83841. set adaptWidthToChildren(value: boolean);
  83842. /** Gets or sets background color */
  83843. get background(): string;
  83844. set background(value: string);
  83845. /** Gets the list of children */
  83846. get children(): Control[];
  83847. /**
  83848. * Creates a new Container
  83849. * @param name defines the name of the container
  83850. */
  83851. constructor(name?: string | undefined);
  83852. protected _getTypeName(): string;
  83853. _flagDescendantsAsMatrixDirty(): void;
  83854. /**
  83855. * Gets a child using its name
  83856. * @param name defines the child name to look for
  83857. * @returns the child control if found
  83858. */
  83859. getChildByName(name: string): BABYLON.Nullable<Control>;
  83860. /**
  83861. * Gets a child using its type and its name
  83862. * @param name defines the child name to look for
  83863. * @param type defines the child type to look for
  83864. * @returns the child control if found
  83865. */
  83866. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83867. /**
  83868. * Search for a specific control in children
  83869. * @param control defines the control to look for
  83870. * @returns true if the control is in child list
  83871. */
  83872. containsControl(control: Control): boolean;
  83873. /**
  83874. * Adds a new control to the current container
  83875. * @param control defines the control to add
  83876. * @returns the current container
  83877. */
  83878. addControl(control: BABYLON.Nullable<Control>): Container;
  83879. /**
  83880. * Removes all controls from the current container
  83881. * @returns the current container
  83882. */
  83883. clearControls(): Container;
  83884. /**
  83885. * Removes a control from the current container
  83886. * @param control defines the control to remove
  83887. * @returns the current container
  83888. */
  83889. removeControl(control: Control): Container;
  83890. /** @hidden */
  83891. _reOrderControl(control: Control): void;
  83892. /** @hidden */
  83893. _offsetLeft(offset: number): void;
  83894. /** @hidden */
  83895. _offsetTop(offset: number): void;
  83896. /** @hidden */
  83897. _markAllAsDirty(): void;
  83898. /** @hidden */
  83899. protected _localDraw(context: CanvasRenderingContext2D): void;
  83900. /** @hidden */
  83901. _link(host: AdvancedDynamicTexture): void;
  83902. /** @hidden */
  83903. protected _beforeLayout(): void;
  83904. /** @hidden */
  83905. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83906. /** @hidden */
  83907. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83908. protected _postMeasure(): void;
  83909. /** @hidden */
  83910. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83911. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83912. /** @hidden */
  83913. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83914. /** @hidden */
  83915. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83916. /**
  83917. * Serializes the current control
  83918. * @param serializationObject defined the JSON serialized object
  83919. */
  83920. serialize(serializationObject: any): void;
  83921. /** Releases associated resources */
  83922. dispose(): void;
  83923. /** @hidden */
  83924. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83925. }
  83926. }
  83927. declare module BABYLON.GUI {
  83928. /** Class used to create rectangle container */
  83929. export class Rectangle extends Container {
  83930. name?: string | undefined;
  83931. private _thickness;
  83932. private _cornerRadius;
  83933. /** Gets or sets border thickness */
  83934. get thickness(): number;
  83935. set thickness(value: number);
  83936. /** Gets or sets the corner radius angle */
  83937. get cornerRadius(): number;
  83938. set cornerRadius(value: number);
  83939. /**
  83940. * Creates a new Rectangle
  83941. * @param name defines the control name
  83942. */
  83943. constructor(name?: string | undefined);
  83944. protected _getTypeName(): string;
  83945. protected _localDraw(context: CanvasRenderingContext2D): void;
  83946. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83947. private _drawRoundedRect;
  83948. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83949. }
  83950. }
  83951. declare module BABYLON.GUI {
  83952. /**
  83953. * Enum that determines the text-wrapping mode to use.
  83954. */
  83955. export enum TextWrapping {
  83956. /**
  83957. * Clip the text when it's larger than Control.width; this is the default mode.
  83958. */
  83959. Clip = 0,
  83960. /**
  83961. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83962. */
  83963. WordWrap = 1,
  83964. /**
  83965. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83966. */
  83967. Ellipsis = 2
  83968. }
  83969. /**
  83970. * Class used to create text block control
  83971. */
  83972. export class TextBlock extends Control {
  83973. /**
  83974. * Defines the name of the control
  83975. */
  83976. name?: string | undefined;
  83977. private _text;
  83978. private _textWrapping;
  83979. private _textHorizontalAlignment;
  83980. private _textVerticalAlignment;
  83981. private _lines;
  83982. private _resizeToFit;
  83983. private _lineSpacing;
  83984. private _outlineWidth;
  83985. private _outlineColor;
  83986. private _underline;
  83987. private _lineThrough;
  83988. /**
  83989. * An event triggered after the text is changed
  83990. */
  83991. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83992. /**
  83993. * An event triggered after the text was broken up into lines
  83994. */
  83995. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83996. /**
  83997. * Function used to split a string into words. By default, a string is split at each space character found
  83998. */
  83999. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84000. /**
  84001. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84002. */
  84003. get lines(): any[];
  84004. /**
  84005. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84006. */
  84007. get resizeToFit(): boolean;
  84008. /**
  84009. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84010. */
  84011. set resizeToFit(value: boolean);
  84012. /**
  84013. * Gets or sets a boolean indicating if text must be wrapped
  84014. */
  84015. get textWrapping(): TextWrapping | boolean;
  84016. /**
  84017. * Gets or sets a boolean indicating if text must be wrapped
  84018. */
  84019. set textWrapping(value: TextWrapping | boolean);
  84020. /**
  84021. * Gets or sets text to display
  84022. */
  84023. get text(): string;
  84024. /**
  84025. * Gets or sets text to display
  84026. */
  84027. set text(value: string);
  84028. /**
  84029. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84030. */
  84031. get textHorizontalAlignment(): number;
  84032. /**
  84033. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84034. */
  84035. set textHorizontalAlignment(value: number);
  84036. /**
  84037. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84038. */
  84039. get textVerticalAlignment(): number;
  84040. /**
  84041. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84042. */
  84043. set textVerticalAlignment(value: number);
  84044. /**
  84045. * Gets or sets line spacing value
  84046. */
  84047. set lineSpacing(value: string | number);
  84048. /**
  84049. * Gets or sets line spacing value
  84050. */
  84051. get lineSpacing(): string | number;
  84052. /**
  84053. * Gets or sets outlineWidth of the text to display
  84054. */
  84055. get outlineWidth(): number;
  84056. /**
  84057. * Gets or sets outlineWidth of the text to display
  84058. */
  84059. set outlineWidth(value: number);
  84060. /**
  84061. * Gets or sets a boolean indicating that text must have underline
  84062. */
  84063. get underline(): boolean;
  84064. /**
  84065. * Gets or sets a boolean indicating that text must have underline
  84066. */
  84067. set underline(value: boolean);
  84068. /**
  84069. * Gets or sets an boolean indicating that text must be crossed out
  84070. */
  84071. get lineThrough(): boolean;
  84072. /**
  84073. * Gets or sets an boolean indicating that text must be crossed out
  84074. */
  84075. set lineThrough(value: boolean);
  84076. /**
  84077. * Gets or sets outlineColor of the text to display
  84078. */
  84079. get outlineColor(): string;
  84080. /**
  84081. * Gets or sets outlineColor of the text to display
  84082. */
  84083. set outlineColor(value: string);
  84084. /**
  84085. * Creates a new TextBlock object
  84086. * @param name defines the name of the control
  84087. * @param text defines the text to display (emptry string by default)
  84088. */
  84089. constructor(
  84090. /**
  84091. * Defines the name of the control
  84092. */
  84093. name?: string | undefined, text?: string);
  84094. protected _getTypeName(): string;
  84095. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84096. private _drawText;
  84097. /** @hidden */
  84098. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84099. protected _applyStates(context: CanvasRenderingContext2D): void;
  84100. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84101. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84102. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84103. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84104. protected _renderLines(context: CanvasRenderingContext2D): void;
  84105. /**
  84106. * Given a width constraint applied on the text block, find the expected height
  84107. * @returns expected height
  84108. */
  84109. computeExpectedHeight(): number;
  84110. dispose(): void;
  84111. }
  84112. }
  84113. declare module BABYLON.GUI {
  84114. /**
  84115. * Class used to create 2D images
  84116. */
  84117. export class Image extends Control {
  84118. name?: string | undefined;
  84119. private _workingCanvas;
  84120. private _domImage;
  84121. private _imageWidth;
  84122. private _imageHeight;
  84123. private _loaded;
  84124. private _stretch;
  84125. private _source;
  84126. private _autoScale;
  84127. private _sourceLeft;
  84128. private _sourceTop;
  84129. private _sourceWidth;
  84130. private _sourceHeight;
  84131. private _svgAttributesComputationCompleted;
  84132. private _isSVG;
  84133. private _cellWidth;
  84134. private _cellHeight;
  84135. private _cellId;
  84136. private _populateNinePatchSlicesFromImage;
  84137. private _sliceLeft;
  84138. private _sliceRight;
  84139. private _sliceTop;
  84140. private _sliceBottom;
  84141. private _detectPointerOnOpaqueOnly;
  84142. private _imageDataCache;
  84143. /**
  84144. * BABYLON.Observable notified when the content is loaded
  84145. */
  84146. onImageLoadedObservable: BABYLON.Observable<Image>;
  84147. /**
  84148. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84149. */
  84150. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84151. /**
  84152. * Gets a boolean indicating that the content is loaded
  84153. */
  84154. get isLoaded(): boolean;
  84155. /**
  84156. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84157. */
  84158. get populateNinePatchSlicesFromImage(): boolean;
  84159. set populateNinePatchSlicesFromImage(value: boolean);
  84160. /**
  84161. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84162. * Beware using this as this will comsume more memory as the image has to be stored twice
  84163. */
  84164. get detectPointerOnOpaqueOnly(): boolean;
  84165. set detectPointerOnOpaqueOnly(value: boolean);
  84166. /**
  84167. * Gets or sets the left value for slicing (9-patch)
  84168. */
  84169. get sliceLeft(): number;
  84170. set sliceLeft(value: number);
  84171. /**
  84172. * Gets or sets the right value for slicing (9-patch)
  84173. */
  84174. get sliceRight(): number;
  84175. set sliceRight(value: number);
  84176. /**
  84177. * Gets or sets the top value for slicing (9-patch)
  84178. */
  84179. get sliceTop(): number;
  84180. set sliceTop(value: number);
  84181. /**
  84182. * Gets or sets the bottom value for slicing (9-patch)
  84183. */
  84184. get sliceBottom(): number;
  84185. set sliceBottom(value: number);
  84186. /**
  84187. * Gets or sets the left coordinate in the source image
  84188. */
  84189. get sourceLeft(): number;
  84190. set sourceLeft(value: number);
  84191. /**
  84192. * Gets or sets the top coordinate in the source image
  84193. */
  84194. get sourceTop(): number;
  84195. set sourceTop(value: number);
  84196. /**
  84197. * Gets or sets the width to capture in the source image
  84198. */
  84199. get sourceWidth(): number;
  84200. set sourceWidth(value: number);
  84201. /**
  84202. * Gets or sets the height to capture in the source image
  84203. */
  84204. get sourceHeight(): number;
  84205. set sourceHeight(value: number);
  84206. /** Indicates if the format of the image is SVG */
  84207. get isSVG(): boolean;
  84208. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84209. get svgAttributesComputationCompleted(): boolean;
  84210. /**
  84211. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84212. * @see https://doc.babylonjs.com/how_to/gui#image
  84213. */
  84214. get autoScale(): boolean;
  84215. set autoScale(value: boolean);
  84216. /** Gets or sets the streching mode used by the image */
  84217. get stretch(): number;
  84218. set stretch(value: number);
  84219. /** @hidden */
  84220. _rotate90(n: number, preserveProperties?: boolean): Image;
  84221. private _handleRotationForSVGImage;
  84222. private _rotate90SourceProperties;
  84223. /**
  84224. * Gets or sets the internal DOM image used to render the control
  84225. */
  84226. set domImage(value: HTMLImageElement);
  84227. get domImage(): HTMLImageElement;
  84228. private _onImageLoaded;
  84229. private _extractNinePatchSliceDataFromImage;
  84230. /**
  84231. * Gets the image source url
  84232. */
  84233. get source(): BABYLON.Nullable<string>;
  84234. /**
  84235. * Gets or sets image source url
  84236. */
  84237. set source(value: BABYLON.Nullable<string>);
  84238. /**
  84239. * Checks for svg document with icon id present
  84240. */
  84241. private _svgCheck;
  84242. /**
  84243. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84244. * given external svg file and icon id
  84245. */
  84246. private _getSVGAttribs;
  84247. /**
  84248. * Gets or sets the cell width to use when animation sheet is enabled
  84249. * @see https://doc.babylonjs.com/how_to/gui#image
  84250. */
  84251. get cellWidth(): number;
  84252. set cellWidth(value: number);
  84253. /**
  84254. * Gets or sets the cell height to use when animation sheet is enabled
  84255. * @see https://doc.babylonjs.com/how_to/gui#image
  84256. */
  84257. get cellHeight(): number;
  84258. set cellHeight(value: number);
  84259. /**
  84260. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84261. * @see https://doc.babylonjs.com/how_to/gui#image
  84262. */
  84263. get cellId(): number;
  84264. set cellId(value: number);
  84265. /**
  84266. * Creates a new Image
  84267. * @param name defines the control name
  84268. * @param url defines the image url
  84269. */
  84270. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84271. /**
  84272. * Tests if a given coordinates belong to the current control
  84273. * @param x defines x coordinate to test
  84274. * @param y defines y coordinate to test
  84275. * @returns true if the coordinates are inside the control
  84276. */
  84277. contains(x: number, y: number): boolean;
  84278. protected _getTypeName(): string;
  84279. /** Force the control to synchronize with its content */
  84280. synchronizeSizeWithContent(): void;
  84281. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84282. private _prepareWorkingCanvasForOpaqueDetection;
  84283. private _drawImage;
  84284. _draw(context: CanvasRenderingContext2D): void;
  84285. private _renderCornerPatch;
  84286. private _renderNinePatch;
  84287. dispose(): void;
  84288. /** STRETCH_NONE */
  84289. static readonly STRETCH_NONE: number;
  84290. /** STRETCH_FILL */
  84291. static readonly STRETCH_FILL: number;
  84292. /** STRETCH_UNIFORM */
  84293. static readonly STRETCH_UNIFORM: number;
  84294. /** STRETCH_EXTEND */
  84295. static readonly STRETCH_EXTEND: number;
  84296. /** NINE_PATCH */
  84297. static readonly STRETCH_NINE_PATCH: number;
  84298. }
  84299. }
  84300. declare module BABYLON.GUI {
  84301. /**
  84302. * Class used to create 2D buttons
  84303. */
  84304. export class Button extends Rectangle {
  84305. name?: string | undefined;
  84306. /**
  84307. * Function called to generate a pointer enter animation
  84308. */
  84309. pointerEnterAnimation: () => void;
  84310. /**
  84311. * Function called to generate a pointer out animation
  84312. */
  84313. pointerOutAnimation: () => void;
  84314. /**
  84315. * Function called to generate a pointer down animation
  84316. */
  84317. pointerDownAnimation: () => void;
  84318. /**
  84319. * Function called to generate a pointer up animation
  84320. */
  84321. pointerUpAnimation: () => void;
  84322. /**
  84323. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84324. */
  84325. delegatePickingToChildren: boolean;
  84326. private _image;
  84327. /**
  84328. * Returns the image part of the button (if any)
  84329. */
  84330. get image(): BABYLON.Nullable<Image>;
  84331. private _textBlock;
  84332. /**
  84333. * Returns the image part of the button (if any)
  84334. */
  84335. get textBlock(): BABYLON.Nullable<TextBlock>;
  84336. /**
  84337. * Creates a new Button
  84338. * @param name defines the name of the button
  84339. */
  84340. constructor(name?: string | undefined);
  84341. protected _getTypeName(): string;
  84342. /** @hidden */
  84343. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84344. /** @hidden */
  84345. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84346. /** @hidden */
  84347. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84348. /** @hidden */
  84349. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84350. /** @hidden */
  84351. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84352. /**
  84353. * Creates a new button made with an image and a text
  84354. * @param name defines the name of the button
  84355. * @param text defines the text of the button
  84356. * @param imageUrl defines the url of the image
  84357. * @returns a new Button
  84358. */
  84359. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84360. /**
  84361. * Creates a new button made with an image
  84362. * @param name defines the name of the button
  84363. * @param imageUrl defines the url of the image
  84364. * @returns a new Button
  84365. */
  84366. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84367. /**
  84368. * Creates a new button made with a text
  84369. * @param name defines the name of the button
  84370. * @param text defines the text of the button
  84371. * @returns a new Button
  84372. */
  84373. static CreateSimpleButton(name: string, text: string): Button;
  84374. /**
  84375. * Creates a new button made with an image and a centered text
  84376. * @param name defines the name of the button
  84377. * @param text defines the text of the button
  84378. * @param imageUrl defines the url of the image
  84379. * @returns a new Button
  84380. */
  84381. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84382. }
  84383. }
  84384. declare module BABYLON.GUI {
  84385. /**
  84386. * Class used to create a 2D stack panel container
  84387. */
  84388. export class StackPanel extends Container {
  84389. name?: string | undefined;
  84390. private _isVertical;
  84391. private _manualWidth;
  84392. private _manualHeight;
  84393. private _doNotTrackManualChanges;
  84394. /**
  84395. * Gets or sets a boolean indicating that layou warnings should be ignored
  84396. */
  84397. ignoreLayoutWarnings: boolean;
  84398. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84399. get isVertical(): boolean;
  84400. set isVertical(value: boolean);
  84401. /**
  84402. * Gets or sets panel width.
  84403. * This value should not be set when in horizontal mode as it will be computed automatically
  84404. */
  84405. set width(value: string | number);
  84406. get width(): string | number;
  84407. /**
  84408. * Gets or sets panel height.
  84409. * This value should not be set when in vertical mode as it will be computed automatically
  84410. */
  84411. set height(value: string | number);
  84412. get height(): string | number;
  84413. /**
  84414. * Creates a new StackPanel
  84415. * @param name defines control name
  84416. */
  84417. constructor(name?: string | undefined);
  84418. protected _getTypeName(): string;
  84419. /** @hidden */
  84420. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84422. protected _postMeasure(): void;
  84423. /**
  84424. * Serializes the current control
  84425. * @param serializationObject defined the JSON serialized object
  84426. */
  84427. serialize(serializationObject: any): void;
  84428. /** @hidden */
  84429. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84430. }
  84431. }
  84432. declare module BABYLON.GUI {
  84433. /**
  84434. * Class used to represent a 2D checkbox
  84435. */
  84436. export class Checkbox extends Control {
  84437. name?: string | undefined;
  84438. private _isChecked;
  84439. private _background;
  84440. private _checkSizeRatio;
  84441. private _thickness;
  84442. /** Gets or sets border thickness */
  84443. get thickness(): number;
  84444. set thickness(value: number);
  84445. /**
  84446. * BABYLON.Observable raised when isChecked property changes
  84447. */
  84448. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84449. /** Gets or sets a value indicating the ratio between overall size and check size */
  84450. get checkSizeRatio(): number;
  84451. set checkSizeRatio(value: number);
  84452. /** Gets or sets background color */
  84453. get background(): string;
  84454. set background(value: string);
  84455. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84456. get isChecked(): boolean;
  84457. set isChecked(value: boolean);
  84458. /**
  84459. * Creates a new CheckBox
  84460. * @param name defines the control name
  84461. */
  84462. constructor(name?: string | undefined);
  84463. protected _getTypeName(): string;
  84464. /** @hidden */
  84465. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84466. /** @hidden */
  84467. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84468. /**
  84469. * Utility function to easily create a checkbox with a header
  84470. * @param title defines the label to use for the header
  84471. * @param onValueChanged defines the callback to call when value changes
  84472. * @returns a StackPanel containing the checkbox and a textBlock
  84473. */
  84474. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84475. }
  84476. }
  84477. declare module BABYLON.GUI {
  84478. /**
  84479. * Class used to store key control properties
  84480. */
  84481. export class KeyPropertySet {
  84482. /** Width */
  84483. width?: string;
  84484. /** Height */
  84485. height?: string;
  84486. /** Left padding */
  84487. paddingLeft?: string;
  84488. /** Right padding */
  84489. paddingRight?: string;
  84490. /** Top padding */
  84491. paddingTop?: string;
  84492. /** Bottom padding */
  84493. paddingBottom?: string;
  84494. /** Foreground color */
  84495. color?: string;
  84496. /** Background color */
  84497. background?: string;
  84498. }
  84499. /**
  84500. * Class used to create virtual keyboard
  84501. */
  84502. export class VirtualKeyboard extends StackPanel {
  84503. /** BABYLON.Observable raised when a key is pressed */
  84504. onKeyPressObservable: BABYLON.Observable<string>;
  84505. /** Gets or sets default key button width */
  84506. defaultButtonWidth: string;
  84507. /** Gets or sets default key button height */
  84508. defaultButtonHeight: string;
  84509. /** Gets or sets default key button left padding */
  84510. defaultButtonPaddingLeft: string;
  84511. /** Gets or sets default key button right padding */
  84512. defaultButtonPaddingRight: string;
  84513. /** Gets or sets default key button top padding */
  84514. defaultButtonPaddingTop: string;
  84515. /** Gets or sets default key button bottom padding */
  84516. defaultButtonPaddingBottom: string;
  84517. /** Gets or sets default key button foreground color */
  84518. defaultButtonColor: string;
  84519. /** Gets or sets default key button background color */
  84520. defaultButtonBackground: string;
  84521. /** Gets or sets shift button foreground color */
  84522. shiftButtonColor: string;
  84523. /** Gets or sets shift button thickness*/
  84524. selectedShiftThickness: number;
  84525. /** Gets shift key state */
  84526. shiftState: number;
  84527. protected _getTypeName(): string;
  84528. private _createKey;
  84529. /**
  84530. * Adds a new row of keys
  84531. * @param keys defines the list of keys to add
  84532. * @param propertySets defines the associated property sets
  84533. */
  84534. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84535. /**
  84536. * Set the shift key to a specific state
  84537. * @param shiftState defines the new shift state
  84538. */
  84539. applyShiftState(shiftState: number): void;
  84540. private _currentlyConnectedInputText;
  84541. private _connectedInputTexts;
  84542. private _onKeyPressObserver;
  84543. /** Gets the input text control currently attached to the keyboard */
  84544. get connectedInputText(): BABYLON.Nullable<InputText>;
  84545. /**
  84546. * Connects the keyboard with an input text control
  84547. *
  84548. * @param input defines the target control
  84549. */
  84550. connect(input: InputText): void;
  84551. /**
  84552. * Disconnects the keyboard from connected InputText controls
  84553. *
  84554. * @param input optionally defines a target control, otherwise all are disconnected
  84555. */
  84556. disconnect(input?: InputText): void;
  84557. private _removeConnectedInputObservables;
  84558. /**
  84559. * Release all resources
  84560. */
  84561. dispose(): void;
  84562. /**
  84563. * Creates a new keyboard using a default layout
  84564. *
  84565. * @param name defines control name
  84566. * @returns a new VirtualKeyboard
  84567. */
  84568. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84569. }
  84570. }
  84571. declare module BABYLON.GUI {
  84572. /** @hidden */
  84573. export class TextWrapper {
  84574. private _text;
  84575. private _characters;
  84576. get text(): string;
  84577. set text(txt: string);
  84578. get length(): number;
  84579. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84580. charAt(idx: number): string;
  84581. substr(from: number, length?: number): string;
  84582. substring(from: number, to?: number): string;
  84583. isWord(index: number): boolean;
  84584. }
  84585. }
  84586. declare module BABYLON.GUI {
  84587. /**
  84588. * Class used to create input text control
  84589. */
  84590. export class InputText extends Control implements IFocusableControl {
  84591. name?: string | undefined;
  84592. private _textWrapper;
  84593. private _placeholderText;
  84594. private _background;
  84595. private _focusedBackground;
  84596. private _focusedColor;
  84597. private _placeholderColor;
  84598. private _thickness;
  84599. private _margin;
  84600. private _autoStretchWidth;
  84601. private _maxWidth;
  84602. private _isFocused;
  84603. private _blinkTimeout;
  84604. private _blinkIsEven;
  84605. private _cursorOffset;
  84606. private _scrollLeft;
  84607. private _textWidth;
  84608. private _clickedCoordinate;
  84609. private _deadKey;
  84610. private _addKey;
  84611. private _currentKey;
  84612. private _isTextHighlightOn;
  84613. private _textHighlightColor;
  84614. private _highligherOpacity;
  84615. private _highlightedText;
  84616. private _startHighlightIndex;
  84617. private _endHighlightIndex;
  84618. private _cursorIndex;
  84619. private _onFocusSelectAll;
  84620. private _isPointerDown;
  84621. private _onClipboardObserver;
  84622. private _onPointerDblTapObserver;
  84623. /** @hidden */
  84624. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84625. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84626. promptMessage: string;
  84627. /** Force disable prompt on mobile device */
  84628. disableMobilePrompt: boolean;
  84629. /** BABYLON.Observable raised when the text changes */
  84630. onTextChangedObservable: BABYLON.Observable<InputText>;
  84631. /** BABYLON.Observable raised just before an entered character is to be added */
  84632. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84633. /** BABYLON.Observable raised when the control gets the focus */
  84634. onFocusObservable: BABYLON.Observable<InputText>;
  84635. /** BABYLON.Observable raised when the control loses the focus */
  84636. onBlurObservable: BABYLON.Observable<InputText>;
  84637. /**Observable raised when the text is highlighted */
  84638. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84639. /**Observable raised when copy event is triggered */
  84640. onTextCopyObservable: BABYLON.Observable<InputText>;
  84641. /** BABYLON.Observable raised when cut event is triggered */
  84642. onTextCutObservable: BABYLON.Observable<InputText>;
  84643. /** BABYLON.Observable raised when paste event is triggered */
  84644. onTextPasteObservable: BABYLON.Observable<InputText>;
  84645. /** BABYLON.Observable raised when a key event was processed */
  84646. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84647. /** Gets or sets the maximum width allowed by the control */
  84648. get maxWidth(): string | number;
  84649. /** Gets the maximum width allowed by the control in pixels */
  84650. get maxWidthInPixels(): number;
  84651. set maxWidth(value: string | number);
  84652. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84653. get highligherOpacity(): number;
  84654. set highligherOpacity(value: number);
  84655. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84656. get onFocusSelectAll(): boolean;
  84657. set onFocusSelectAll(value: boolean);
  84658. /** Gets or sets the text hightlight color */
  84659. get textHighlightColor(): string;
  84660. set textHighlightColor(value: string);
  84661. /** Gets or sets control margin */
  84662. get margin(): string;
  84663. /** Gets control margin in pixels */
  84664. get marginInPixels(): number;
  84665. set margin(value: string);
  84666. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84667. get autoStretchWidth(): boolean;
  84668. set autoStretchWidth(value: boolean);
  84669. /** Gets or sets border thickness */
  84670. get thickness(): number;
  84671. set thickness(value: number);
  84672. /** Gets or sets the background color when focused */
  84673. get focusedBackground(): string;
  84674. set focusedBackground(value: string);
  84675. /** Gets or sets the background color when focused */
  84676. get focusedColor(): string;
  84677. set focusedColor(value: string);
  84678. /** Gets or sets the background color */
  84679. get background(): string;
  84680. set background(value: string);
  84681. /** Gets or sets the placeholder color */
  84682. get placeholderColor(): string;
  84683. set placeholderColor(value: string);
  84684. /** Gets or sets the text displayed when the control is empty */
  84685. get placeholderText(): string;
  84686. set placeholderText(value: string);
  84687. /** Gets or sets the dead key flag */
  84688. get deadKey(): boolean;
  84689. set deadKey(flag: boolean);
  84690. /** Gets or sets the highlight text */
  84691. get highlightedText(): string;
  84692. set highlightedText(text: string);
  84693. /** Gets or sets if the current key should be added */
  84694. get addKey(): boolean;
  84695. set addKey(flag: boolean);
  84696. /** Gets or sets the value of the current key being entered */
  84697. get currentKey(): string;
  84698. set currentKey(key: string);
  84699. /** Gets or sets the text displayed in the control */
  84700. get text(): string;
  84701. set text(value: string);
  84702. private _textHasChanged;
  84703. /** Gets or sets control width */
  84704. get width(): string | number;
  84705. set width(value: string | number);
  84706. /**
  84707. * Creates a new InputText
  84708. * @param name defines the control name
  84709. * @param text defines the text of the control
  84710. */
  84711. constructor(name?: string | undefined, text?: string);
  84712. /** @hidden */
  84713. onBlur(): void;
  84714. /** @hidden */
  84715. onFocus(): void;
  84716. /**
  84717. * Function to focus an inputText programmatically
  84718. */
  84719. focus(): void;
  84720. /**
  84721. * Function to unfocus an inputText programmatically
  84722. */
  84723. blur(): void;
  84724. protected _getTypeName(): string;
  84725. /**
  84726. * Function called to get the list of controls that should not steal the focus from this control
  84727. * @returns an array of controls
  84728. */
  84729. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84730. /** @hidden */
  84731. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84732. /** @hidden */
  84733. private _updateValueFromCursorIndex;
  84734. /** @hidden */
  84735. private _processDblClick;
  84736. /** @hidden */
  84737. private _selectAllText;
  84738. /**
  84739. * Handles the keyboard event
  84740. * @param evt Defines the KeyboardEvent
  84741. */
  84742. processKeyboard(evt: KeyboardEvent): void;
  84743. /** @hidden */
  84744. private _onCopyText;
  84745. /** @hidden */
  84746. private _onCutText;
  84747. /** @hidden */
  84748. private _onPasteText;
  84749. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84750. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84751. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84752. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84753. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84754. dispose(): void;
  84755. }
  84756. }
  84757. declare module BABYLON.GUI {
  84758. /**
  84759. * Class used to create a 2D grid container
  84760. */
  84761. export class Grid extends Container {
  84762. name?: string | undefined;
  84763. private _rowDefinitions;
  84764. private _columnDefinitions;
  84765. private _cells;
  84766. private _childControls;
  84767. /**
  84768. * Gets the number of columns
  84769. */
  84770. get columnCount(): number;
  84771. /**
  84772. * Gets the number of rows
  84773. */
  84774. get rowCount(): number;
  84775. /** Gets the list of children */
  84776. get children(): Control[];
  84777. /** Gets the list of cells (e.g. the containers) */
  84778. get cells(): {
  84779. [key: string]: Container;
  84780. };
  84781. /**
  84782. * Gets the definition of a specific row
  84783. * @param index defines the index of the row
  84784. * @returns the row definition
  84785. */
  84786. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84787. /**
  84788. * Gets the definition of a specific column
  84789. * @param index defines the index of the column
  84790. * @returns the column definition
  84791. */
  84792. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84793. /**
  84794. * Adds a new row to the grid
  84795. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84796. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84797. * @returns the current grid
  84798. */
  84799. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84800. /**
  84801. * Adds a new column to the grid
  84802. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84803. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84804. * @returns the current grid
  84805. */
  84806. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84807. /**
  84808. * Update a row definition
  84809. * @param index defines the index of the row to update
  84810. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84811. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84812. * @returns the current grid
  84813. */
  84814. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84815. /**
  84816. * Update a column definition
  84817. * @param index defines the index of the column to update
  84818. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84819. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84820. * @returns the current grid
  84821. */
  84822. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84823. /**
  84824. * Gets the list of children stored in a specific cell
  84825. * @param row defines the row to check
  84826. * @param column defines the column to check
  84827. * @returns the list of controls
  84828. */
  84829. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84830. /**
  84831. * Gets a string representing the child cell info (row x column)
  84832. * @param child defines the control to get info from
  84833. * @returns a string containing the child cell info (row x column)
  84834. */
  84835. getChildCellInfo(child: Control): string;
  84836. private _removeCell;
  84837. private _offsetCell;
  84838. /**
  84839. * Remove a column definition at specified index
  84840. * @param index defines the index of the column to remove
  84841. * @returns the current grid
  84842. */
  84843. removeColumnDefinition(index: number): Grid;
  84844. /**
  84845. * Remove a row definition at specified index
  84846. * @param index defines the index of the row to remove
  84847. * @returns the current grid
  84848. */
  84849. removeRowDefinition(index: number): Grid;
  84850. /**
  84851. * Adds a new control to the current grid
  84852. * @param control defines the control to add
  84853. * @param row defines the row where to add the control (0 by default)
  84854. * @param column defines the column where to add the control (0 by default)
  84855. * @returns the current grid
  84856. */
  84857. addControl(control: Control, row?: number, column?: number): Grid;
  84858. /**
  84859. * Removes a control from the current container
  84860. * @param control defines the control to remove
  84861. * @returns the current container
  84862. */
  84863. removeControl(control: Control): Container;
  84864. /**
  84865. * Creates a new Grid
  84866. * @param name defines control name
  84867. */
  84868. constructor(name?: string | undefined);
  84869. protected _getTypeName(): string;
  84870. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84872. _flagDescendantsAsMatrixDirty(): void;
  84873. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84874. /** Releases associated resources */
  84875. dispose(): void;
  84876. }
  84877. }
  84878. declare module BABYLON.GUI {
  84879. /** Class used to create color pickers */
  84880. export class ColorPicker extends Control {
  84881. name?: string | undefined;
  84882. private static _Epsilon;
  84883. private _colorWheelCanvas;
  84884. private _value;
  84885. private _tmpColor;
  84886. private _pointerStartedOnSquare;
  84887. private _pointerStartedOnWheel;
  84888. private _squareLeft;
  84889. private _squareTop;
  84890. private _squareSize;
  84891. private _h;
  84892. private _s;
  84893. private _v;
  84894. private _lastPointerDownID;
  84895. /**
  84896. * BABYLON.Observable raised when the value changes
  84897. */
  84898. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84899. /** Gets or sets the color of the color picker */
  84900. get value(): BABYLON.Color3;
  84901. set value(value: BABYLON.Color3);
  84902. /**
  84903. * Gets or sets control width
  84904. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84905. */
  84906. get width(): string | number;
  84907. set width(value: string | number);
  84908. /**
  84909. * Gets or sets control height
  84910. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84911. */
  84912. get height(): string | number;
  84913. /** Gets or sets control height */
  84914. set height(value: string | number);
  84915. /** Gets or sets control size */
  84916. get size(): string | number;
  84917. set size(value: string | number);
  84918. /**
  84919. * Creates a new ColorPicker
  84920. * @param name defines the control name
  84921. */
  84922. constructor(name?: string | undefined);
  84923. protected _getTypeName(): string;
  84924. /** @hidden */
  84925. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84926. private _updateSquareProps;
  84927. private _drawGradientSquare;
  84928. private _drawCircle;
  84929. private _createColorWheelCanvas;
  84930. /** @hidden */
  84931. _draw(context: CanvasRenderingContext2D): void;
  84932. private _pointerIsDown;
  84933. private _updateValueFromPointer;
  84934. private _isPointOnSquare;
  84935. private _isPointOnWheel;
  84936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84937. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84938. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84939. _onCanvasBlur(): void;
  84940. /**
  84941. * This function expands the color picker by creating a color picker dialog with manual
  84942. * color value input and the ability to save colors into an array to be used later in
  84943. * subsequent launches of the dialogue.
  84944. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84945. * @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.
  84946. * @returns picked color as a hex string and the saved colors array as hex strings.
  84947. */
  84948. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84949. pickerWidth?: string;
  84950. pickerHeight?: string;
  84951. headerHeight?: string;
  84952. lastColor?: string;
  84953. swatchLimit?: number;
  84954. numSwatchesPerLine?: number;
  84955. savedColors?: Array<string>;
  84956. }): Promise<{
  84957. savedColors?: string[];
  84958. pickedColor: string;
  84959. }>;
  84960. }
  84961. }
  84962. declare module BABYLON.GUI {
  84963. /** Class used to create 2D ellipse containers */
  84964. export class Ellipse extends Container {
  84965. name?: string | undefined;
  84966. private _thickness;
  84967. /** Gets or sets border thickness */
  84968. get thickness(): number;
  84969. set thickness(value: number);
  84970. /**
  84971. * Creates a new Ellipse
  84972. * @param name defines the control name
  84973. */
  84974. constructor(name?: string | undefined);
  84975. protected _getTypeName(): string;
  84976. protected _localDraw(context: CanvasRenderingContext2D): void;
  84977. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84978. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84979. }
  84980. }
  84981. declare module BABYLON.GUI {
  84982. /**
  84983. * Class used to create a focusable button that can easily handle keyboard events
  84984. */
  84985. export class FocusableButton extends Button implements IFocusableControl {
  84986. name?: string | undefined;
  84987. /** Highlight color when button is focused */
  84988. focusedColor: BABYLON.Nullable<string>;
  84989. private _isFocused;
  84990. private _unfocusedColor;
  84991. /** BABYLON.Observable raised when the control gets the focus */
  84992. onFocusObservable: BABYLON.Observable<Button>;
  84993. /** BABYLON.Observable raised when the control loses the focus */
  84994. onBlurObservable: BABYLON.Observable<Button>;
  84995. /** BABYLON.Observable raised when a key event was processed */
  84996. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84997. constructor(name?: string | undefined);
  84998. /** @hidden */
  84999. onBlur(): void;
  85000. /** @hidden */
  85001. onFocus(): void;
  85002. /**
  85003. * Function called to get the list of controls that should not steal the focus from this control
  85004. * @returns an array of controls
  85005. */
  85006. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85007. /**
  85008. * Function to focus a button programmatically
  85009. */
  85010. focus(): void;
  85011. /**
  85012. * Function to unfocus a button programmatically
  85013. */
  85014. blur(): void;
  85015. /**
  85016. * Handles the keyboard event
  85017. * @param evt Defines the KeyboardEvent
  85018. */
  85019. processKeyboard(evt: KeyboardEvent): void;
  85020. /** @hidden */
  85021. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85022. /** @hidden */
  85023. displose(): void;
  85024. }
  85025. }
  85026. declare module BABYLON.GUI {
  85027. /**
  85028. * Class used to create a password control
  85029. */
  85030. export class InputPassword extends InputText {
  85031. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85032. }
  85033. }
  85034. declare module BABYLON.GUI {
  85035. /** Class used to render 2D lines */
  85036. export class Line extends Control {
  85037. name?: string | undefined;
  85038. private _lineWidth;
  85039. private _x1;
  85040. private _y1;
  85041. private _x2;
  85042. private _y2;
  85043. private _dash;
  85044. private _connectedControl;
  85045. private _connectedControlDirtyObserver;
  85046. /** Gets or sets the dash pattern */
  85047. get dash(): Array<number>;
  85048. set dash(value: Array<number>);
  85049. /** Gets or sets the control connected with the line end */
  85050. get connectedControl(): Control;
  85051. set connectedControl(value: Control);
  85052. /** Gets or sets start coordinates on X axis */
  85053. get x1(): string | number;
  85054. set x1(value: string | number);
  85055. /** Gets or sets start coordinates on Y axis */
  85056. get y1(): string | number;
  85057. set y1(value: string | number);
  85058. /** Gets or sets end coordinates on X axis */
  85059. get x2(): string | number;
  85060. set x2(value: string | number);
  85061. /** Gets or sets end coordinates on Y axis */
  85062. get y2(): string | number;
  85063. set y2(value: string | number);
  85064. /** Gets or sets line width */
  85065. get lineWidth(): number;
  85066. set lineWidth(value: number);
  85067. /** Gets or sets horizontal alignment */
  85068. set horizontalAlignment(value: number);
  85069. /** Gets or sets vertical alignment */
  85070. set verticalAlignment(value: number);
  85071. private get _effectiveX2();
  85072. private get _effectiveY2();
  85073. /**
  85074. * Creates a new Line
  85075. * @param name defines the control name
  85076. */
  85077. constructor(name?: string | undefined);
  85078. protected _getTypeName(): string;
  85079. _draw(context: CanvasRenderingContext2D): void;
  85080. _measure(): void;
  85081. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85082. /**
  85083. * Move one end of the line given 3D cartesian coordinates.
  85084. * @param position Targeted world position
  85085. * @param scene BABYLON.Scene
  85086. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85087. */
  85088. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85089. /**
  85090. * Move one end of the line to a position in screen absolute space.
  85091. * @param projectedPosition Position in screen absolute space (X, Y)
  85092. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85093. */
  85094. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85095. }
  85096. }
  85097. declare module BABYLON.GUI {
  85098. /**
  85099. * Class used to store a point for a MultiLine object.
  85100. * The point can be pure 2D coordinates, a mesh or a control
  85101. */
  85102. export class MultiLinePoint {
  85103. private _multiLine;
  85104. private _x;
  85105. private _y;
  85106. private _control;
  85107. private _mesh;
  85108. private _controlObserver;
  85109. private _meshObserver;
  85110. /** @hidden */
  85111. _point: BABYLON.Vector3;
  85112. /**
  85113. * Creates a new MultiLinePoint
  85114. * @param multiLine defines the source MultiLine object
  85115. */
  85116. constructor(multiLine: MultiLine);
  85117. /** Gets or sets x coordinate */
  85118. get x(): string | number;
  85119. set x(value: string | number);
  85120. /** Gets or sets y coordinate */
  85121. get y(): string | number;
  85122. set y(value: string | number);
  85123. /** Gets or sets the control associated with this point */
  85124. get control(): BABYLON.Nullable<Control>;
  85125. set control(value: BABYLON.Nullable<Control>);
  85126. /** Gets or sets the mesh associated with this point */
  85127. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85128. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85129. /** Resets links */
  85130. resetLinks(): void;
  85131. /**
  85132. * Gets a translation vector with Z component
  85133. * @returns the translation vector
  85134. */
  85135. translate(): BABYLON.Vector3;
  85136. private _translatePoint;
  85137. /** Release associated resources */
  85138. dispose(): void;
  85139. }
  85140. }
  85141. declare module BABYLON.GUI {
  85142. /**
  85143. * Class used to create multi line control
  85144. */
  85145. export class MultiLine extends Control {
  85146. name?: string | undefined;
  85147. private _lineWidth;
  85148. private _dash;
  85149. private _points;
  85150. private _minX;
  85151. private _minY;
  85152. private _maxX;
  85153. private _maxY;
  85154. /**
  85155. * Creates a new MultiLine
  85156. * @param name defines the control name
  85157. */
  85158. constructor(name?: string | undefined);
  85159. /** Gets or sets dash pattern */
  85160. get dash(): Array<number>;
  85161. set dash(value: Array<number>);
  85162. /**
  85163. * Gets point stored at specified index
  85164. * @param index defines the index to look for
  85165. * @returns the requested point if found
  85166. */
  85167. getAt(index: number): MultiLinePoint;
  85168. /** Function called when a point is updated */
  85169. onPointUpdate: () => void;
  85170. /**
  85171. * Adds new points to the point collection
  85172. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85173. * @returns the list of created MultiLinePoint
  85174. */
  85175. add(...items: (AbstractMesh | Control | {
  85176. x: string | number;
  85177. y: string | number;
  85178. })[]): MultiLinePoint[];
  85179. /**
  85180. * Adds a new point to the point collection
  85181. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85182. * @returns the created MultiLinePoint
  85183. */
  85184. push(item?: (AbstractMesh | Control | {
  85185. x: string | number;
  85186. y: string | number;
  85187. })): MultiLinePoint;
  85188. /**
  85189. * Remove a specific value or point from the active point collection
  85190. * @param value defines the value or point to remove
  85191. */
  85192. remove(value: number | MultiLinePoint): void;
  85193. /**
  85194. * Resets this object to initial state (no point)
  85195. */
  85196. reset(): void;
  85197. /**
  85198. * Resets all links
  85199. */
  85200. resetLinks(): void;
  85201. /** Gets or sets line width */
  85202. get lineWidth(): number;
  85203. set lineWidth(value: number);
  85204. set horizontalAlignment(value: number);
  85205. set verticalAlignment(value: number);
  85206. protected _getTypeName(): string;
  85207. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85208. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85209. _measure(): void;
  85210. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85211. dispose(): void;
  85212. }
  85213. }
  85214. declare module BABYLON.GUI {
  85215. /**
  85216. * Class used to create radio button controls
  85217. */
  85218. export class RadioButton extends Control {
  85219. name?: string | undefined;
  85220. private _isChecked;
  85221. private _background;
  85222. private _checkSizeRatio;
  85223. private _thickness;
  85224. /** Gets or sets border thickness */
  85225. get thickness(): number;
  85226. set thickness(value: number);
  85227. /** Gets or sets group name */
  85228. group: string;
  85229. /** BABYLON.Observable raised when isChecked is changed */
  85230. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85231. /** Gets or sets a value indicating the ratio between overall size and check size */
  85232. get checkSizeRatio(): number;
  85233. set checkSizeRatio(value: number);
  85234. /** Gets or sets background color */
  85235. get background(): string;
  85236. set background(value: string);
  85237. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85238. get isChecked(): boolean;
  85239. set isChecked(value: boolean);
  85240. /**
  85241. * Creates a new RadioButton
  85242. * @param name defines the control name
  85243. */
  85244. constructor(name?: string | undefined);
  85245. protected _getTypeName(): string;
  85246. _draw(context: CanvasRenderingContext2D): void;
  85247. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85248. /**
  85249. * Utility function to easily create a radio button with a header
  85250. * @param title defines the label to use for the header
  85251. * @param group defines the group to use for the radio button
  85252. * @param isChecked defines the initial state of the radio button
  85253. * @param onValueChanged defines the callback to call when value changes
  85254. * @returns a StackPanel containing the radio button and a textBlock
  85255. */
  85256. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85257. }
  85258. }
  85259. declare module BABYLON.GUI {
  85260. /**
  85261. * Class used to create slider controls
  85262. */
  85263. export class BaseSlider extends Control {
  85264. name?: string | undefined;
  85265. protected _thumbWidth: ValueAndUnit;
  85266. private _minimum;
  85267. private _maximum;
  85268. private _value;
  85269. private _isVertical;
  85270. protected _barOffset: ValueAndUnit;
  85271. private _isThumbClamped;
  85272. protected _displayThumb: boolean;
  85273. private _step;
  85274. private _lastPointerDownID;
  85275. protected _effectiveBarOffset: number;
  85276. protected _renderLeft: number;
  85277. protected _renderTop: number;
  85278. protected _renderWidth: number;
  85279. protected _renderHeight: number;
  85280. protected _backgroundBoxLength: number;
  85281. protected _backgroundBoxThickness: number;
  85282. protected _effectiveThumbThickness: number;
  85283. /** BABYLON.Observable raised when the sldier value changes */
  85284. onValueChangedObservable: BABYLON.Observable<number>;
  85285. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85286. get displayThumb(): boolean;
  85287. set displayThumb(value: boolean);
  85288. /** Gets or sets a step to apply to values (0 by default) */
  85289. get step(): number;
  85290. set step(value: number);
  85291. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85292. get barOffset(): string | number;
  85293. /** Gets main bar offset in pixels*/
  85294. get barOffsetInPixels(): number;
  85295. set barOffset(value: string | number);
  85296. /** Gets or sets thumb width */
  85297. get thumbWidth(): string | number;
  85298. /** Gets thumb width in pixels */
  85299. get thumbWidthInPixels(): number;
  85300. set thumbWidth(value: string | number);
  85301. /** Gets or sets minimum value */
  85302. get minimum(): number;
  85303. set minimum(value: number);
  85304. /** Gets or sets maximum value */
  85305. get maximum(): number;
  85306. set maximum(value: number);
  85307. /** Gets or sets current value */
  85308. get value(): number;
  85309. set value(value: number);
  85310. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85311. get isVertical(): boolean;
  85312. set isVertical(value: boolean);
  85313. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85314. get isThumbClamped(): boolean;
  85315. set isThumbClamped(value: boolean);
  85316. /**
  85317. * Creates a new BaseSlider
  85318. * @param name defines the control name
  85319. */
  85320. constructor(name?: string | undefined);
  85321. protected _getTypeName(): string;
  85322. protected _getThumbPosition(): number;
  85323. protected _getThumbThickness(type: string): number;
  85324. protected _prepareRenderingData(type: string): void;
  85325. private _pointerIsDown;
  85326. /** @hidden */
  85327. protected _updateValueFromPointer(x: number, y: number): void;
  85328. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85329. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85330. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85331. _onCanvasBlur(): void;
  85332. }
  85333. }
  85334. declare module BABYLON.GUI {
  85335. /**
  85336. * Class used to create slider controls
  85337. */
  85338. export class Slider extends BaseSlider {
  85339. name?: string | undefined;
  85340. private _background;
  85341. private _borderColor;
  85342. private _thumbColor;
  85343. private _isThumbCircle;
  85344. protected _displayValueBar: boolean;
  85345. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85346. get displayValueBar(): boolean;
  85347. set displayValueBar(value: boolean);
  85348. /** Gets or sets border color */
  85349. get borderColor(): string;
  85350. set borderColor(value: string);
  85351. /** Gets or sets background color */
  85352. get background(): string;
  85353. set background(value: string);
  85354. /** Gets or sets thumb's color */
  85355. get thumbColor(): string;
  85356. set thumbColor(value: string);
  85357. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85358. get isThumbCircle(): boolean;
  85359. set isThumbCircle(value: boolean);
  85360. /**
  85361. * Creates a new Slider
  85362. * @param name defines the control name
  85363. */
  85364. constructor(name?: string | undefined);
  85365. protected _getTypeName(): string;
  85366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85367. }
  85368. }
  85369. declare module BABYLON.GUI {
  85370. /** Class used to create a RadioGroup
  85371. * which contains groups of radio buttons
  85372. */
  85373. export class SelectorGroup {
  85374. /** name of SelectorGroup */
  85375. name: string;
  85376. private _groupPanel;
  85377. private _selectors;
  85378. private _groupHeader;
  85379. /**
  85380. * Creates a new SelectorGroup
  85381. * @param name of group, used as a group heading
  85382. */
  85383. constructor(
  85384. /** name of SelectorGroup */
  85385. name: string);
  85386. /** Gets the groupPanel of the SelectorGroup */
  85387. get groupPanel(): StackPanel;
  85388. /** Gets the selectors array */
  85389. get selectors(): StackPanel[];
  85390. /** Gets and sets the group header */
  85391. get header(): string;
  85392. set header(label: string);
  85393. /** @hidden */
  85394. private _addGroupHeader;
  85395. /** @hidden*/
  85396. _getSelector(selectorNb: number): StackPanel | undefined;
  85397. /** Removes the selector at the given position
  85398. * @param selectorNb the position of the selector within the group
  85399. */
  85400. removeSelector(selectorNb: number): void;
  85401. }
  85402. /** Class used to create a CheckboxGroup
  85403. * which contains groups of checkbox buttons
  85404. */
  85405. export class CheckboxGroup extends SelectorGroup {
  85406. /** Adds a checkbox as a control
  85407. * @param text is the label for the selector
  85408. * @param func is the function called when the Selector is checked
  85409. * @param checked is true when Selector is checked
  85410. */
  85411. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85412. /** @hidden */
  85413. _setSelectorLabel(selectorNb: number, label: string): void;
  85414. /** @hidden */
  85415. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85416. /** @hidden */
  85417. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85418. /** @hidden */
  85419. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85420. }
  85421. /** Class used to create a RadioGroup
  85422. * which contains groups of radio buttons
  85423. */
  85424. export class RadioGroup extends SelectorGroup {
  85425. private _selectNb;
  85426. /** Adds a radio button as a control
  85427. * @param label is the label for the selector
  85428. * @param func is the function called when the Selector is checked
  85429. * @param checked is true when Selector is checked
  85430. */
  85431. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85432. /** @hidden */
  85433. _setSelectorLabel(selectorNb: number, label: string): void;
  85434. /** @hidden */
  85435. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85436. /** @hidden */
  85437. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85438. /** @hidden */
  85439. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85440. }
  85441. /** Class used to create a SliderGroup
  85442. * which contains groups of slider buttons
  85443. */
  85444. export class SliderGroup extends SelectorGroup {
  85445. /**
  85446. * Adds a slider to the SelectorGroup
  85447. * @param label is the label for the SliderBar
  85448. * @param func is the function called when the Slider moves
  85449. * @param unit is a string describing the units used, eg degrees or metres
  85450. * @param min is the minimum value for the Slider
  85451. * @param max is the maximum value for the Slider
  85452. * @param value is the start value for the Slider between min and max
  85453. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85454. */
  85455. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85456. /** @hidden */
  85457. _setSelectorLabel(selectorNb: number, label: string): void;
  85458. /** @hidden */
  85459. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85460. /** @hidden */
  85461. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85462. /** @hidden */
  85463. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85464. }
  85465. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85466. * @see https://doc.babylonjs.com/how_to/selector
  85467. */
  85468. export class SelectionPanel extends Rectangle {
  85469. /** name of SelectionPanel */
  85470. name: string;
  85471. /** an array of SelectionGroups */
  85472. groups: SelectorGroup[];
  85473. private _panel;
  85474. private _buttonColor;
  85475. private _buttonBackground;
  85476. private _headerColor;
  85477. private _barColor;
  85478. private _barHeight;
  85479. private _spacerHeight;
  85480. private _labelColor;
  85481. private _groups;
  85482. private _bars;
  85483. /**
  85484. * Creates a new SelectionPanel
  85485. * @param name of SelectionPanel
  85486. * @param groups is an array of SelectionGroups
  85487. */
  85488. constructor(
  85489. /** name of SelectionPanel */
  85490. name: string,
  85491. /** an array of SelectionGroups */
  85492. groups?: SelectorGroup[]);
  85493. protected _getTypeName(): string;
  85494. /** Gets the (stack) panel of the SelectionPanel */
  85495. get panel(): StackPanel;
  85496. /** Gets or sets the headerColor */
  85497. get headerColor(): string;
  85498. set headerColor(color: string);
  85499. private _setHeaderColor;
  85500. /** Gets or sets the button color */
  85501. get buttonColor(): string;
  85502. set buttonColor(color: string);
  85503. private _setbuttonColor;
  85504. /** Gets or sets the label color */
  85505. get labelColor(): string;
  85506. set labelColor(color: string);
  85507. private _setLabelColor;
  85508. /** Gets or sets the button background */
  85509. get buttonBackground(): string;
  85510. set buttonBackground(color: string);
  85511. private _setButtonBackground;
  85512. /** Gets or sets the color of separator bar */
  85513. get barColor(): string;
  85514. set barColor(color: string);
  85515. private _setBarColor;
  85516. /** Gets or sets the height of separator bar */
  85517. get barHeight(): string;
  85518. set barHeight(value: string);
  85519. private _setBarHeight;
  85520. /** Gets or sets the height of spacers*/
  85521. get spacerHeight(): string;
  85522. set spacerHeight(value: string);
  85523. private _setSpacerHeight;
  85524. /** Adds a bar between groups */
  85525. private _addSpacer;
  85526. /** Add a group to the selection panel
  85527. * @param group is the selector group to add
  85528. */
  85529. addGroup(group: SelectorGroup): void;
  85530. /** Remove the group from the given position
  85531. * @param groupNb is the position of the group in the list
  85532. */
  85533. removeGroup(groupNb: number): void;
  85534. /** Change a group header label
  85535. * @param label is the new group header label
  85536. * @param groupNb is the number of the group to relabel
  85537. * */
  85538. setHeaderName(label: string, groupNb: number): void;
  85539. /** Change selector label to the one given
  85540. * @param label is the new selector label
  85541. * @param groupNb is the number of the groupcontaining the selector
  85542. * @param selectorNb is the number of the selector within a group to relabel
  85543. * */
  85544. relabel(label: string, groupNb: number, selectorNb: number): void;
  85545. /** For a given group position remove the selector at the given position
  85546. * @param groupNb is the number of the group to remove the selector from
  85547. * @param selectorNb is the number of the selector within the group
  85548. */
  85549. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85550. /** For a given group position of correct type add a checkbox button
  85551. * @param groupNb is the number of the group to remove the selector from
  85552. * @param label is the label for the selector
  85553. * @param func is the function called when the Selector is checked
  85554. * @param checked is true when Selector is checked
  85555. */
  85556. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85557. /** For a given group position of correct type add a radio button
  85558. * @param groupNb is the number of the group to remove the selector from
  85559. * @param label is the label for the selector
  85560. * @param func is the function called when the Selector is checked
  85561. * @param checked is true when Selector is checked
  85562. */
  85563. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85564. /**
  85565. * For a given slider group add a slider
  85566. * @param groupNb is the number of the group to add the slider to
  85567. * @param label is the label for the Slider
  85568. * @param func is the function called when the Slider moves
  85569. * @param unit is a string describing the units used, eg degrees or metres
  85570. * @param min is the minimum value for the Slider
  85571. * @param max is the maximum value for the Slider
  85572. * @param value is the start value for the Slider between min and max
  85573. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85574. */
  85575. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85576. }
  85577. }
  85578. declare module BABYLON.GUI {
  85579. /**
  85580. * Class used to hold a the container for ScrollViewer
  85581. * @hidden
  85582. */
  85583. export class _ScrollViewerWindow extends Container {
  85584. parentClientWidth: number;
  85585. parentClientHeight: number;
  85586. private _freezeControls;
  85587. private _parentMeasure;
  85588. private _oldLeft;
  85589. private _oldTop;
  85590. get freezeControls(): boolean;
  85591. set freezeControls(value: boolean);
  85592. private _bucketWidth;
  85593. private _bucketHeight;
  85594. private _buckets;
  85595. private _bucketLen;
  85596. get bucketWidth(): number;
  85597. get bucketHeight(): number;
  85598. setBucketSizes(width: number, height: number): void;
  85599. private _useBuckets;
  85600. private _makeBuckets;
  85601. private _dispatchInBuckets;
  85602. private _updateMeasures;
  85603. private _updateChildrenMeasures;
  85604. private _restoreMeasures;
  85605. /**
  85606. * Creates a new ScrollViewerWindow
  85607. * @param name of ScrollViewerWindow
  85608. */
  85609. constructor(name?: string);
  85610. protected _getTypeName(): string;
  85611. /** @hidden */
  85612. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85613. /** @hidden */
  85614. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85615. private _scrollChildren;
  85616. private _scrollChildrenWithBuckets;
  85617. /** @hidden */
  85618. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85619. protected _postMeasure(): void;
  85620. }
  85621. }
  85622. declare module BABYLON.GUI {
  85623. /**
  85624. * Class used to create slider controls
  85625. */
  85626. export class ScrollBar extends BaseSlider {
  85627. name?: string | undefined;
  85628. private _background;
  85629. private _borderColor;
  85630. private _tempMeasure;
  85631. /** Gets or sets border color */
  85632. get borderColor(): string;
  85633. set borderColor(value: string);
  85634. /** Gets or sets background color */
  85635. get background(): string;
  85636. set background(value: string);
  85637. /**
  85638. * Creates a new Slider
  85639. * @param name defines the control name
  85640. */
  85641. constructor(name?: string | undefined);
  85642. protected _getTypeName(): string;
  85643. protected _getThumbThickness(): number;
  85644. _draw(context: CanvasRenderingContext2D): void;
  85645. private _first;
  85646. private _originX;
  85647. private _originY;
  85648. /** @hidden */
  85649. protected _updateValueFromPointer(x: number, y: number): void;
  85650. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85651. }
  85652. }
  85653. declare module BABYLON.GUI {
  85654. /**
  85655. * Class used to create slider controls
  85656. */
  85657. export class ImageScrollBar extends BaseSlider {
  85658. name?: string | undefined;
  85659. private _backgroundBaseImage;
  85660. private _backgroundImage;
  85661. private _thumbImage;
  85662. private _thumbBaseImage;
  85663. private _thumbLength;
  85664. private _thumbHeight;
  85665. private _barImageHeight;
  85666. private _tempMeasure;
  85667. /** Number of 90° rotation to apply on the images when in vertical mode */
  85668. num90RotationInVerticalMode: number;
  85669. /**
  85670. * Gets or sets the image used to render the background for horizontal bar
  85671. */
  85672. get backgroundImage(): Image;
  85673. set backgroundImage(value: Image);
  85674. /**
  85675. * Gets or sets the image used to render the thumb
  85676. */
  85677. get thumbImage(): Image;
  85678. set thumbImage(value: Image);
  85679. /**
  85680. * Gets or sets the length of the thumb
  85681. */
  85682. get thumbLength(): number;
  85683. set thumbLength(value: number);
  85684. /**
  85685. * Gets or sets the height of the thumb
  85686. */
  85687. get thumbHeight(): number;
  85688. set thumbHeight(value: number);
  85689. /**
  85690. * Gets or sets the height of the bar image
  85691. */
  85692. get barImageHeight(): number;
  85693. set barImageHeight(value: number);
  85694. /**
  85695. * Creates a new ImageScrollBar
  85696. * @param name defines the control name
  85697. */
  85698. constructor(name?: string | undefined);
  85699. protected _getTypeName(): string;
  85700. protected _getThumbThickness(): number;
  85701. _draw(context: CanvasRenderingContext2D): void;
  85702. private _first;
  85703. private _originX;
  85704. private _originY;
  85705. /** @hidden */
  85706. protected _updateValueFromPointer(x: number, y: number): void;
  85707. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85708. }
  85709. }
  85710. declare module BABYLON.GUI {
  85711. /**
  85712. * Class used to hold a viewer window and sliders in a grid
  85713. */
  85714. export class ScrollViewer extends Rectangle {
  85715. private _grid;
  85716. private _horizontalBarSpace;
  85717. private _verticalBarSpace;
  85718. private _dragSpace;
  85719. private _horizontalBar;
  85720. private _verticalBar;
  85721. private _barColor;
  85722. private _barBackground;
  85723. private _barImage;
  85724. private _horizontalBarImage;
  85725. private _verticalBarImage;
  85726. private _barBackgroundImage;
  85727. private _horizontalBarBackgroundImage;
  85728. private _verticalBarBackgroundImage;
  85729. private _barSize;
  85730. private _window;
  85731. private _pointerIsOver;
  85732. private _wheelPrecision;
  85733. private _onWheelObserver;
  85734. private _clientWidth;
  85735. private _clientHeight;
  85736. private _useImageBar;
  85737. private _thumbLength;
  85738. private _thumbHeight;
  85739. private _barImageHeight;
  85740. private _horizontalBarImageHeight;
  85741. private _verticalBarImageHeight;
  85742. private _oldWindowContentsWidth;
  85743. private _oldWindowContentsHeight;
  85744. /**
  85745. * Gets the horizontal scrollbar
  85746. */
  85747. get horizontalBar(): ScrollBar | ImageScrollBar;
  85748. /**
  85749. * Gets the vertical scrollbar
  85750. */
  85751. get verticalBar(): ScrollBar | ImageScrollBar;
  85752. /**
  85753. * Adds a new control to the current container
  85754. * @param control defines the control to add
  85755. * @returns the current container
  85756. */
  85757. addControl(control: BABYLON.Nullable<Control>): Container;
  85758. /**
  85759. * Removes a control from the current container
  85760. * @param control defines the control to remove
  85761. * @returns the current container
  85762. */
  85763. removeControl(control: Control): Container;
  85764. /** Gets the list of children */
  85765. get children(): Control[];
  85766. _flagDescendantsAsMatrixDirty(): void;
  85767. /**
  85768. * Freezes or unfreezes the controls in the window.
  85769. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85770. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85771. */
  85772. get freezeControls(): boolean;
  85773. set freezeControls(value: boolean);
  85774. /** Gets the bucket width */
  85775. get bucketWidth(): number;
  85776. /** Gets the bucket height */
  85777. get bucketHeight(): number;
  85778. /**
  85779. * Sets the bucket sizes.
  85780. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85781. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85782. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85783. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85784. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85785. * used), that's why it is not enabled by default.
  85786. * @param width width of the bucket
  85787. * @param height height of the bucket
  85788. */
  85789. setBucketSizes(width: number, height: number): void;
  85790. private _forceHorizontalBar;
  85791. private _forceVerticalBar;
  85792. /**
  85793. * Forces the horizontal scroll bar to be displayed
  85794. */
  85795. get forceHorizontalBar(): boolean;
  85796. set forceHorizontalBar(value: boolean);
  85797. /**
  85798. * Forces the vertical scroll bar to be displayed
  85799. */
  85800. get forceVerticalBar(): boolean;
  85801. set forceVerticalBar(value: boolean);
  85802. /**
  85803. * Creates a new ScrollViewer
  85804. * @param name of ScrollViewer
  85805. */
  85806. constructor(name?: string, isImageBased?: boolean);
  85807. /** Reset the scroll viewer window to initial size */
  85808. resetWindow(): void;
  85809. protected _getTypeName(): string;
  85810. private _buildClientSizes;
  85811. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85812. protected _postMeasure(): void;
  85813. /**
  85814. * Gets or sets the mouse wheel precision
  85815. * from 0 to 1 with a default value of 0.05
  85816. * */
  85817. get wheelPrecision(): number;
  85818. set wheelPrecision(value: number);
  85819. /** Gets or sets the scroll bar container background color */
  85820. get scrollBackground(): string;
  85821. set scrollBackground(color: string);
  85822. /** Gets or sets the bar color */
  85823. get barColor(): string;
  85824. set barColor(color: string);
  85825. /** Gets or sets the bar image */
  85826. get thumbImage(): Image;
  85827. set thumbImage(value: Image);
  85828. /** Gets or sets the horizontal bar image */
  85829. get horizontalThumbImage(): Image;
  85830. set horizontalThumbImage(value: Image);
  85831. /** Gets or sets the vertical bar image */
  85832. get verticalThumbImage(): Image;
  85833. set verticalThumbImage(value: Image);
  85834. /** Gets or sets the size of the bar */
  85835. get barSize(): number;
  85836. set barSize(value: number);
  85837. /** Gets or sets the length of the thumb */
  85838. get thumbLength(): number;
  85839. set thumbLength(value: number);
  85840. /** Gets or sets the height of the thumb */
  85841. get thumbHeight(): number;
  85842. set thumbHeight(value: number);
  85843. /** Gets or sets the height of the bar image */
  85844. get barImageHeight(): number;
  85845. set barImageHeight(value: number);
  85846. /** Gets or sets the height of the horizontal bar image */
  85847. get horizontalBarImageHeight(): number;
  85848. set horizontalBarImageHeight(value: number);
  85849. /** Gets or sets the height of the vertical bar image */
  85850. get verticalBarImageHeight(): number;
  85851. set verticalBarImageHeight(value: number);
  85852. /** Gets or sets the bar background */
  85853. get barBackground(): string;
  85854. set barBackground(color: string);
  85855. /** Gets or sets the bar background image */
  85856. get barImage(): Image;
  85857. set barImage(value: Image);
  85858. /** Gets or sets the horizontal bar background image */
  85859. get horizontalBarImage(): Image;
  85860. set horizontalBarImage(value: Image);
  85861. /** Gets or sets the vertical bar background image */
  85862. get verticalBarImage(): Image;
  85863. set verticalBarImage(value: Image);
  85864. private _setWindowPosition;
  85865. /** @hidden */
  85866. private _updateScroller;
  85867. _link(host: AdvancedDynamicTexture): void;
  85868. /** @hidden */
  85869. private _addBar;
  85870. /** @hidden */
  85871. private _attachWheel;
  85872. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85873. /** Releases associated resources */
  85874. dispose(): void;
  85875. }
  85876. }
  85877. declare module BABYLON.GUI {
  85878. /**
  85879. * Class used to create toggle buttons
  85880. */
  85881. export class ToggleButton extends Rectangle {
  85882. name?: string | undefined;
  85883. /**
  85884. * Function called to generate the toActive animation
  85885. */
  85886. toActiveAnimation: () => void;
  85887. /**
  85888. * Function called to generate the toInactive animation
  85889. */
  85890. toInactiveAnimation: () => void;
  85891. /**
  85892. * Function called to generate a pointer enter animation when the toggle button is active.
  85893. */
  85894. pointerEnterActiveAnimation: () => void;
  85895. /**
  85896. * Function called to generate a pointer out animation when the toggle button is active.
  85897. */
  85898. pointerOutActiveAnimation: () => void;
  85899. /**
  85900. * Function called to generate a pointer down animation when the toggle button is active.
  85901. */
  85902. pointerDownActiveAnimation: () => void;
  85903. /**
  85904. * Function called to generate a pointer up animation when the toggle button is active.
  85905. */
  85906. pointerUpActiveAnimation: () => void;
  85907. /**
  85908. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85909. */
  85910. pointerEnterInactiveAnimation: () => void;
  85911. /**
  85912. * Function called to generate a pointer out animation when the toggle button is inactive.
  85913. */
  85914. pointerOutInactiveAnimation: () => void;
  85915. /**
  85916. * Function called to generate a pointer down animation when the toggle button is inactive.
  85917. */
  85918. pointerDownInactiveAnimation: () => void;
  85919. /**
  85920. * Function called to generate a pointer up animation when the toggle button is inactive.
  85921. */
  85922. pointerUpInactiveAnimation: () => void;
  85923. /** BABYLON.Observable raised when isActive is changed */
  85924. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85925. /**
  85926. * 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
  85927. */
  85928. delegatePickingToChildren: boolean;
  85929. private _image;
  85930. /**
  85931. * Returns the ToggleButton's image control if it exists
  85932. */
  85933. get image(): BABYLON.Nullable<Image>;
  85934. private _textBlock;
  85935. /**
  85936. * Returns the ToggleButton's child TextBlock control if it exists
  85937. */
  85938. get textBlock(): BABYLON.Nullable<TextBlock>;
  85939. private _group;
  85940. /** Gets or sets group name this toggle button belongs to */
  85941. get group(): string;
  85942. set group(value: string);
  85943. private _isActive;
  85944. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85945. get isActive(): boolean;
  85946. set isActive(value: boolean);
  85947. /**
  85948. * Creates a new ToggleButton
  85949. * @param name defines the control name
  85950. * @param group defines the toggle group this toggle belongs to
  85951. */
  85952. constructor(name?: string | undefined, group?: string);
  85953. protected _getTypeName(): string;
  85954. /** @hidden */
  85955. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85956. /** @hidden */
  85957. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85958. /** @hidden */
  85959. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85960. /** @hidden */
  85961. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85962. /** @hidden */
  85963. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85964. }
  85965. }
  85966. declare module BABYLON.GUI {
  85967. /** Class used to render a grid */
  85968. export class DisplayGrid extends Control {
  85969. name?: string | undefined;
  85970. private _cellWidth;
  85971. private _cellHeight;
  85972. private _minorLineTickness;
  85973. private _minorLineColor;
  85974. private _majorLineTickness;
  85975. private _majorLineColor;
  85976. private _majorLineFrequency;
  85977. private _background;
  85978. private _displayMajorLines;
  85979. private _displayMinorLines;
  85980. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85981. get displayMinorLines(): boolean;
  85982. set displayMinorLines(value: boolean);
  85983. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85984. get displayMajorLines(): boolean;
  85985. set displayMajorLines(value: boolean);
  85986. /** Gets or sets background color (Black by default) */
  85987. get background(): string;
  85988. set background(value: string);
  85989. /** Gets or sets the width of each cell (20 by default) */
  85990. get cellWidth(): number;
  85991. set cellWidth(value: number);
  85992. /** Gets or sets the height of each cell (20 by default) */
  85993. get cellHeight(): number;
  85994. set cellHeight(value: number);
  85995. /** Gets or sets the tickness of minor lines (1 by default) */
  85996. get minorLineTickness(): number;
  85997. set minorLineTickness(value: number);
  85998. /** Gets or sets the color of minor lines (DarkGray by default) */
  85999. get minorLineColor(): string;
  86000. set minorLineColor(value: string);
  86001. /** Gets or sets the tickness of major lines (2 by default) */
  86002. get majorLineTickness(): number;
  86003. set majorLineTickness(value: number);
  86004. /** Gets or sets the color of major lines (White by default) */
  86005. get majorLineColor(): string;
  86006. set majorLineColor(value: string);
  86007. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86008. get majorLineFrequency(): number;
  86009. set majorLineFrequency(value: number);
  86010. /**
  86011. * Creates a new GridDisplayRectangle
  86012. * @param name defines the control name
  86013. */
  86014. constructor(name?: string | undefined);
  86015. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86016. protected _getTypeName(): string;
  86017. }
  86018. }
  86019. declare module BABYLON.GUI {
  86020. /**
  86021. * Class used to create slider controls based on images
  86022. */
  86023. export class ImageBasedSlider extends BaseSlider {
  86024. name?: string | undefined;
  86025. private _backgroundImage;
  86026. private _thumbImage;
  86027. private _valueBarImage;
  86028. private _tempMeasure;
  86029. get displayThumb(): boolean;
  86030. set displayThumb(value: boolean);
  86031. /**
  86032. * Gets or sets the image used to render the background
  86033. */
  86034. get backgroundImage(): Image;
  86035. set backgroundImage(value: Image);
  86036. /**
  86037. * Gets or sets the image used to render the value bar
  86038. */
  86039. get valueBarImage(): Image;
  86040. set valueBarImage(value: Image);
  86041. /**
  86042. * Gets or sets the image used to render the thumb
  86043. */
  86044. get thumbImage(): Image;
  86045. set thumbImage(value: Image);
  86046. /**
  86047. * Creates a new ImageBasedSlider
  86048. * @param name defines the control name
  86049. */
  86050. constructor(name?: string | undefined);
  86051. protected _getTypeName(): string;
  86052. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86053. }
  86054. }
  86055. declare module BABYLON.GUI {
  86056. /**
  86057. * Forcing an export so that this code will execute
  86058. * @hidden
  86059. */
  86060. const name = "Statics";
  86061. }
  86062. declare module BABYLON.GUI {
  86063. /**
  86064. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86065. */
  86066. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86067. /**
  86068. * Define the instrumented AdvancedDynamicTexture.
  86069. */
  86070. texture: AdvancedDynamicTexture;
  86071. private _captureRenderTime;
  86072. private _renderTime;
  86073. private _captureLayoutTime;
  86074. private _layoutTime;
  86075. private _onBeginRenderObserver;
  86076. private _onEndRenderObserver;
  86077. private _onBeginLayoutObserver;
  86078. private _onEndLayoutObserver;
  86079. /**
  86080. * Gets the perf counter used to capture render time
  86081. */
  86082. get renderTimeCounter(): BABYLON.PerfCounter;
  86083. /**
  86084. * Gets the perf counter used to capture layout time
  86085. */
  86086. get layoutTimeCounter(): BABYLON.PerfCounter;
  86087. /**
  86088. * Enable or disable the render time capture
  86089. */
  86090. get captureRenderTime(): boolean;
  86091. set captureRenderTime(value: boolean);
  86092. /**
  86093. * Enable or disable the layout time capture
  86094. */
  86095. get captureLayoutTime(): boolean;
  86096. set captureLayoutTime(value: boolean);
  86097. /**
  86098. * Instantiates a new advanced dynamic texture instrumentation.
  86099. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86100. * @param texture Defines the AdvancedDynamicTexture to instrument
  86101. */
  86102. constructor(
  86103. /**
  86104. * Define the instrumented AdvancedDynamicTexture.
  86105. */
  86106. texture: AdvancedDynamicTexture);
  86107. /**
  86108. * Dispose and release associated resources.
  86109. */
  86110. dispose(): void;
  86111. }
  86112. }
  86113. declare module BABYLON.GUI {
  86114. /**
  86115. * Class used to load GUI via XML.
  86116. */
  86117. export class XmlLoader {
  86118. private _nodes;
  86119. private _nodeTypes;
  86120. private _isLoaded;
  86121. private _objectAttributes;
  86122. private _parentClass;
  86123. /**
  86124. * Create a new xml loader
  86125. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86126. */
  86127. constructor(parentClass?: null);
  86128. private _getChainElement;
  86129. private _getClassAttribute;
  86130. private _createGuiElement;
  86131. private _parseGrid;
  86132. private _parseElement;
  86133. private _prepareSourceElement;
  86134. private _parseElementsFromSource;
  86135. private _parseXml;
  86136. /**
  86137. * Gets if the loading has finished.
  86138. * @returns whether the loading has finished or not
  86139. */
  86140. isLoaded(): boolean;
  86141. /**
  86142. * Gets a loaded node / control by id.
  86143. * @param id the Controls id set in the xml
  86144. * @returns element of type Control
  86145. */
  86146. getNodeById(id: string): any;
  86147. /**
  86148. * Gets all loaded nodes / controls
  86149. * @returns Array of controls
  86150. */
  86151. getNodes(): any;
  86152. /**
  86153. * Initiates the xml layout loading
  86154. * @param xmlFile defines the xml layout to load
  86155. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86156. * @param callback defines the callback called on layout load.
  86157. */
  86158. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86159. }
  86160. }
  86161. declare module BABYLON.GUI {
  86162. /**
  86163. * Class used to create containers for controls
  86164. */
  86165. export class Container3D extends Control3D {
  86166. private _blockLayout;
  86167. /**
  86168. * Gets the list of child controls
  86169. */
  86170. protected _children: Control3D[];
  86171. /**
  86172. * Gets the list of child controls
  86173. */
  86174. get children(): Array<Control3D>;
  86175. /**
  86176. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86177. * This is helpful to optimize layout operation when adding multiple children in a row
  86178. */
  86179. get blockLayout(): boolean;
  86180. set blockLayout(value: boolean);
  86181. /**
  86182. * Creates a new container
  86183. * @param name defines the container name
  86184. */
  86185. constructor(name?: string);
  86186. /**
  86187. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86188. * @returns the current container
  86189. */
  86190. updateLayout(): Container3D;
  86191. /**
  86192. * Gets a boolean indicating if the given control is in the children of this control
  86193. * @param control defines the control to check
  86194. * @returns true if the control is in the child list
  86195. */
  86196. containsControl(control: Control3D): boolean;
  86197. /**
  86198. * Adds a control to the children of this control
  86199. * @param control defines the control to add
  86200. * @returns the current container
  86201. */
  86202. addControl(control: Control3D): Container3D;
  86203. /**
  86204. * This function will be called everytime a new control is added
  86205. */
  86206. protected _arrangeChildren(): void;
  86207. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86208. /**
  86209. * Removes a control from the children of this control
  86210. * @param control defines the control to remove
  86211. * @returns the current container
  86212. */
  86213. removeControl(control: Control3D): Container3D;
  86214. protected _getTypeName(): string;
  86215. /**
  86216. * Releases all associated resources
  86217. */
  86218. dispose(): void;
  86219. /** Control rotation will remain unchanged */
  86220. static readonly UNSET_ORIENTATION: number;
  86221. /** Control will rotate to make it look at sphere central axis */
  86222. static readonly FACEORIGIN_ORIENTATION: number;
  86223. /** Control will rotate to make it look back at sphere central axis */
  86224. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86225. /** Control will rotate to look at z axis (0, 0, 1) */
  86226. static readonly FACEFORWARD_ORIENTATION: number;
  86227. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86228. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86229. }
  86230. }
  86231. declare module BABYLON.GUI {
  86232. /**
  86233. * Class used to manage 3D user interface
  86234. * @see https://doc.babylonjs.com/how_to/gui3d
  86235. */
  86236. export class GUI3DManager implements BABYLON.IDisposable {
  86237. private _scene;
  86238. private _sceneDisposeObserver;
  86239. private _utilityLayer;
  86240. private _rootContainer;
  86241. private _pointerObserver;
  86242. private _pointerOutObserver;
  86243. /** @hidden */
  86244. _lastPickedControl: Control3D;
  86245. /** @hidden */
  86246. _lastControlOver: {
  86247. [pointerId: number]: Control3D;
  86248. };
  86249. /** @hidden */
  86250. _lastControlDown: {
  86251. [pointerId: number]: Control3D;
  86252. };
  86253. /**
  86254. * BABYLON.Observable raised when the point picked by the pointer events changed
  86255. */
  86256. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86257. /** @hidden */
  86258. _sharedMaterials: {
  86259. [key: string]: BABYLON.Material;
  86260. };
  86261. /** Gets the hosting scene */
  86262. get scene(): BABYLON.Scene;
  86263. /** Gets associated utility layer */
  86264. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86265. /**
  86266. * Creates a new GUI3DManager
  86267. * @param scene
  86268. */
  86269. constructor(scene?: BABYLON.Scene);
  86270. private _handlePointerOut;
  86271. private _doPicking;
  86272. /**
  86273. * Gets the root container
  86274. */
  86275. get rootContainer(): Container3D;
  86276. /**
  86277. * Gets a boolean indicating if the given control is in the root child list
  86278. * @param control defines the control to check
  86279. * @returns true if the control is in the root child list
  86280. */
  86281. containsControl(control: Control3D): boolean;
  86282. /**
  86283. * Adds a control to the root child list
  86284. * @param control defines the control to add
  86285. * @returns the current manager
  86286. */
  86287. addControl(control: Control3D): GUI3DManager;
  86288. /**
  86289. * Removes a control from the root child list
  86290. * @param control defines the control to remove
  86291. * @returns the current container
  86292. */
  86293. removeControl(control: Control3D): GUI3DManager;
  86294. /**
  86295. * Releases all associated resources
  86296. */
  86297. dispose(): void;
  86298. }
  86299. }
  86300. declare module BABYLON.GUI {
  86301. /**
  86302. * Class used to transport BABYLON.Vector3 information for pointer events
  86303. */
  86304. export class Vector3WithInfo extends BABYLON.Vector3 {
  86305. /** defines the current mouse button index */
  86306. buttonIndex: number;
  86307. /**
  86308. * Creates a new Vector3WithInfo
  86309. * @param source defines the vector3 data to transport
  86310. * @param buttonIndex defines the current mouse button index
  86311. */
  86312. constructor(source: BABYLON.Vector3,
  86313. /** defines the current mouse button index */
  86314. buttonIndex?: number);
  86315. }
  86316. }
  86317. declare module BABYLON.GUI {
  86318. /**
  86319. * Class used as base class for controls
  86320. */
  86321. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86322. /** Defines the control name */
  86323. name?: string | undefined;
  86324. /** @hidden */
  86325. _host: GUI3DManager;
  86326. private _node;
  86327. private _downCount;
  86328. private _enterCount;
  86329. private _downPointerIds;
  86330. private _isVisible;
  86331. /** Gets or sets the control position in world space */
  86332. get position(): BABYLON.Vector3;
  86333. set position(value: BABYLON.Vector3);
  86334. /** Gets or sets the control scaling in world space */
  86335. get scaling(): BABYLON.Vector3;
  86336. set scaling(value: BABYLON.Vector3);
  86337. /** Callback used to start pointer enter animation */
  86338. pointerEnterAnimation: () => void;
  86339. /** Callback used to start pointer out animation */
  86340. pointerOutAnimation: () => void;
  86341. /** Callback used to start pointer down animation */
  86342. pointerDownAnimation: () => void;
  86343. /** Callback used to start pointer up animation */
  86344. pointerUpAnimation: () => void;
  86345. /**
  86346. * An event triggered when the pointer move over the control
  86347. */
  86348. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86349. /**
  86350. * An event triggered when the pointer move out of the control
  86351. */
  86352. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86353. /**
  86354. * An event triggered when the pointer taps the control
  86355. */
  86356. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86357. /**
  86358. * An event triggered when pointer is up
  86359. */
  86360. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86361. /**
  86362. * An event triggered when a control is clicked on (with a mouse)
  86363. */
  86364. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86365. /**
  86366. * An event triggered when pointer enters the control
  86367. */
  86368. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86369. /**
  86370. * Gets or sets the parent container
  86371. */
  86372. parent: BABYLON.Nullable<Container3D>;
  86373. private _behaviors;
  86374. /**
  86375. * Gets the list of attached behaviors
  86376. * @see https://doc.babylonjs.com/features/behaviour
  86377. */
  86378. get behaviors(): BABYLON.Behavior<Control3D>[];
  86379. /**
  86380. * Attach a behavior to the control
  86381. * @see https://doc.babylonjs.com/features/behaviour
  86382. * @param behavior defines the behavior to attach
  86383. * @returns the current control
  86384. */
  86385. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86386. /**
  86387. * Remove an attached behavior
  86388. * @see https://doc.babylonjs.com/features/behaviour
  86389. * @param behavior defines the behavior to attach
  86390. * @returns the current control
  86391. */
  86392. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86393. /**
  86394. * Gets an attached behavior by name
  86395. * @param name defines the name of the behavior to look for
  86396. * @see https://doc.babylonjs.com/features/behaviour
  86397. * @returns null if behavior was not found else the requested behavior
  86398. */
  86399. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86400. /** Gets or sets a boolean indicating if the control is visible */
  86401. get isVisible(): boolean;
  86402. set isVisible(value: boolean);
  86403. /**
  86404. * Creates a new control
  86405. * @param name defines the control name
  86406. */
  86407. constructor(
  86408. /** Defines the control name */
  86409. name?: string | undefined);
  86410. /**
  86411. * Gets a string representing the class name
  86412. */
  86413. get typeName(): string;
  86414. /**
  86415. * Get the current class name of the control.
  86416. * @returns current class name
  86417. */
  86418. getClassName(): string;
  86419. protected _getTypeName(): string;
  86420. /**
  86421. * Gets the transform node used by this control
  86422. */
  86423. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86424. /**
  86425. * Gets the mesh used to render this control
  86426. */
  86427. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86428. /**
  86429. * Link the control as child of the given node
  86430. * @param node defines the node to link to. Use null to unlink the control
  86431. * @returns the current control
  86432. */
  86433. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86434. /** @hidden **/
  86435. _prepareNode(scene: BABYLON.Scene): void;
  86436. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86437. /**
  86438. * Node creation.
  86439. * Can be overriden by children
  86440. * @param scene defines the scene where the node must be attached
  86441. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86442. */
  86443. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86444. /**
  86445. * Affect a material to the given mesh
  86446. * @param mesh defines the mesh which will represent the control
  86447. */
  86448. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86449. /** @hidden */
  86450. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86451. /** @hidden */
  86452. _onPointerEnter(target: Control3D): boolean;
  86453. /** @hidden */
  86454. _onPointerOut(target: Control3D): void;
  86455. /** @hidden */
  86456. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86457. /** @hidden */
  86458. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86459. /** @hidden */
  86460. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86461. /** @hidden */
  86462. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86463. /** @hidden */
  86464. _disposeNode(): void;
  86465. /**
  86466. * Releases all associated resources
  86467. */
  86468. dispose(): void;
  86469. }
  86470. }
  86471. declare module BABYLON.GUI {
  86472. /**
  86473. * Class used as a root to all buttons
  86474. */
  86475. export class AbstractButton3D extends Control3D {
  86476. /**
  86477. * Creates a new button
  86478. * @param name defines the control name
  86479. */
  86480. constructor(name?: string);
  86481. protected _getTypeName(): string;
  86482. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86483. }
  86484. }
  86485. declare module BABYLON.GUI {
  86486. /**
  86487. * Class used to create a button in 3D
  86488. */
  86489. export class Button3D extends AbstractButton3D {
  86490. /** @hidden */
  86491. protected _currentMaterial: BABYLON.Material;
  86492. private _facadeTexture;
  86493. private _content;
  86494. private _contentResolution;
  86495. private _contentScaleRatio;
  86496. /**
  86497. * Gets or sets the texture resolution used to render content (512 by default)
  86498. */
  86499. get contentResolution(): BABYLON.int;
  86500. set contentResolution(value: BABYLON.int);
  86501. /**
  86502. * Gets or sets the texture scale ratio used to render content (2 by default)
  86503. */
  86504. get contentScaleRatio(): number;
  86505. set contentScaleRatio(value: number);
  86506. protected _disposeFacadeTexture(): void;
  86507. protected _resetContent(): void;
  86508. /**
  86509. * Creates a new button
  86510. * @param name defines the control name
  86511. */
  86512. constructor(name?: string);
  86513. /**
  86514. * Gets or sets the GUI 2D content used to display the button's facade
  86515. */
  86516. get content(): Control;
  86517. set content(value: Control);
  86518. /**
  86519. * Apply the facade texture (created from the content property).
  86520. * This function can be overloaded by child classes
  86521. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86522. */
  86523. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86524. protected _getTypeName(): string;
  86525. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86526. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86527. /**
  86528. * Releases all associated resources
  86529. */
  86530. dispose(): void;
  86531. }
  86532. }
  86533. declare module BABYLON.GUI {
  86534. /**
  86535. * Abstract class used to create a container panel deployed on the surface of a volume
  86536. */
  86537. export abstract class VolumeBasedPanel extends Container3D {
  86538. private _columns;
  86539. private _rows;
  86540. private _rowThenColum;
  86541. private _orientation;
  86542. protected _cellWidth: number;
  86543. protected _cellHeight: number;
  86544. /**
  86545. * Gets or sets the distance between elements
  86546. */
  86547. margin: number;
  86548. /**
  86549. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86550. * | Value | Type | Description |
  86551. * | ----- | ----------------------------------- | ----------- |
  86552. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86553. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86554. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86555. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86556. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86557. */
  86558. get orientation(): number;
  86559. set orientation(value: number);
  86560. /**
  86561. * Gets or sets the number of columns requested (10 by default).
  86562. * The panel will automatically compute the number of rows based on number of child controls.
  86563. */
  86564. get columns(): BABYLON.int;
  86565. set columns(value: BABYLON.int);
  86566. /**
  86567. * Gets or sets a the number of rows requested.
  86568. * The panel will automatically compute the number of columns based on number of child controls.
  86569. */
  86570. get rows(): BABYLON.int;
  86571. set rows(value: BABYLON.int);
  86572. /**
  86573. * Creates new VolumeBasedPanel
  86574. */
  86575. constructor();
  86576. protected _arrangeChildren(): void;
  86577. /** Child classes must implement this function to provide correct control positioning */
  86578. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86579. /** Child classes can implement this function to provide additional processing */
  86580. protected _finalProcessing(): void;
  86581. }
  86582. }
  86583. declare module BABYLON.GUI {
  86584. /**
  86585. * Class used to create a container panel deployed on the surface of a cylinder
  86586. */
  86587. export class CylinderPanel extends VolumeBasedPanel {
  86588. private _radius;
  86589. /**
  86590. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86591. */
  86592. get radius(): BABYLON.float;
  86593. set radius(value: BABYLON.float);
  86594. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86595. private _cylindricalMapping;
  86596. }
  86597. }
  86598. declare module BABYLON.GUI {
  86599. /** @hidden */
  86600. export var fluentVertexShader: {
  86601. name: string;
  86602. shader: string;
  86603. };
  86604. }
  86605. declare module BABYLON.GUI {
  86606. /** @hidden */
  86607. export var fluentPixelShader: {
  86608. name: string;
  86609. shader: string;
  86610. };
  86611. }
  86612. declare module BABYLON.GUI {
  86613. /** @hidden */
  86614. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86615. INNERGLOW: boolean;
  86616. BORDER: boolean;
  86617. HOVERLIGHT: boolean;
  86618. TEXTURE: boolean;
  86619. constructor();
  86620. }
  86621. /**
  86622. * Class used to render controls with fluent desgin
  86623. */
  86624. export class FluentMaterial extends BABYLON.PushMaterial {
  86625. /**
  86626. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86627. */
  86628. innerGlowColorIntensity: number;
  86629. /**
  86630. * Gets or sets the inner glow color (white by default)
  86631. */
  86632. innerGlowColor: BABYLON.Color3;
  86633. /**
  86634. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86635. */
  86636. albedoColor: BABYLON.Color3;
  86637. /**
  86638. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86639. */
  86640. renderBorders: boolean;
  86641. /**
  86642. * Gets or sets border width (default is 0.5)
  86643. */
  86644. borderWidth: number;
  86645. /**
  86646. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86647. */
  86648. edgeSmoothingValue: number;
  86649. /**
  86650. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86651. */
  86652. borderMinValue: number;
  86653. /**
  86654. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86655. */
  86656. renderHoverLight: boolean;
  86657. /**
  86658. * Gets or sets the radius used to render the hover light (default is 1.0)
  86659. */
  86660. hoverRadius: number;
  86661. /**
  86662. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86663. */
  86664. hoverColor: BABYLON.Color4;
  86665. /**
  86666. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86667. */
  86668. hoverPosition: BABYLON.Vector3;
  86669. private _albedoTexture;
  86670. /** Gets or sets the texture to use for albedo color */
  86671. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86672. /**
  86673. * Creates a new Fluent material
  86674. * @param name defines the name of the material
  86675. * @param scene defines the hosting scene
  86676. */
  86677. constructor(name: string, scene: BABYLON.Scene);
  86678. needAlphaBlending(): boolean;
  86679. needAlphaTesting(): boolean;
  86680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86683. getActiveTextures(): BABYLON.BaseTexture[];
  86684. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86685. dispose(forceDisposeEffect?: boolean): void;
  86686. clone(name: string): FluentMaterial;
  86687. serialize(): any;
  86688. getClassName(): string;
  86689. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86690. }
  86691. }
  86692. declare module BABYLON.GUI {
  86693. /**
  86694. * Class used to create a holographic button in 3D
  86695. */
  86696. export class HolographicButton extends Button3D {
  86697. private _backPlate;
  86698. private _textPlate;
  86699. private _frontPlate;
  86700. private _text;
  86701. private _imageUrl;
  86702. private _shareMaterials;
  86703. private _frontMaterial;
  86704. private _backMaterial;
  86705. private _plateMaterial;
  86706. private _pickedPointObserver;
  86707. private _tooltipFade;
  86708. private _tooltipTextBlock;
  86709. private _tooltipTexture;
  86710. private _tooltipMesh;
  86711. private _tooltipHoverObserver;
  86712. private _tooltipOutObserver;
  86713. private _disposeTooltip;
  86714. /**
  86715. * Rendering ground id of all the mesh in the button
  86716. */
  86717. set renderingGroupId(id: number);
  86718. get renderingGroupId(): number;
  86719. /**
  86720. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86721. */
  86722. set tooltipText(text: BABYLON.Nullable<string>);
  86723. get tooltipText(): BABYLON.Nullable<string>;
  86724. /**
  86725. * Gets or sets text for the button
  86726. */
  86727. get text(): string;
  86728. set text(value: string);
  86729. /**
  86730. * Gets or sets the image url for the button
  86731. */
  86732. get imageUrl(): string;
  86733. set imageUrl(value: string);
  86734. /**
  86735. * Gets the back material used by this button
  86736. */
  86737. get backMaterial(): FluentMaterial;
  86738. /**
  86739. * Gets the front material used by this button
  86740. */
  86741. get frontMaterial(): FluentMaterial;
  86742. /**
  86743. * Gets the plate material used by this button
  86744. */
  86745. get plateMaterial(): BABYLON.StandardMaterial;
  86746. /**
  86747. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86748. */
  86749. get shareMaterials(): boolean;
  86750. /**
  86751. * Creates a new button
  86752. * @param name defines the control name
  86753. */
  86754. constructor(name?: string, shareMaterials?: boolean);
  86755. protected _getTypeName(): string;
  86756. private _rebuildContent;
  86757. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86758. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86759. private _createBackMaterial;
  86760. private _createFrontMaterial;
  86761. private _createPlateMaterial;
  86762. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86763. /**
  86764. * Releases all associated resources
  86765. */
  86766. dispose(): void;
  86767. }
  86768. }
  86769. declare module BABYLON.GUI {
  86770. /**
  86771. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86772. */
  86773. export class MeshButton3D extends Button3D {
  86774. /** @hidden */
  86775. protected _currentMesh: BABYLON.Mesh;
  86776. /**
  86777. * Creates a new 3D button based on a mesh
  86778. * @param mesh mesh to become a 3D button
  86779. * @param name defines the control name
  86780. */
  86781. constructor(mesh: BABYLON.Mesh, name?: string);
  86782. protected _getTypeName(): string;
  86783. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86784. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86785. }
  86786. }
  86787. declare module BABYLON.GUI {
  86788. /**
  86789. * Class used to create a container panel deployed on the surface of a plane
  86790. */
  86791. export class PlanePanel extends VolumeBasedPanel {
  86792. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86793. }
  86794. }
  86795. declare module BABYLON.GUI {
  86796. /**
  86797. * Class used to create a container panel where items get randomized planar mapping
  86798. */
  86799. export class ScatterPanel extends VolumeBasedPanel {
  86800. private _iteration;
  86801. /**
  86802. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86803. */
  86804. get iteration(): BABYLON.float;
  86805. set iteration(value: BABYLON.float);
  86806. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86807. private _scatterMapping;
  86808. protected _finalProcessing(): void;
  86809. }
  86810. }
  86811. declare module BABYLON.GUI {
  86812. /**
  86813. * Class used to create a container panel deployed on the surface of a sphere
  86814. */
  86815. export class SpherePanel extends VolumeBasedPanel {
  86816. private _radius;
  86817. /**
  86818. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86819. */
  86820. get radius(): BABYLON.float;
  86821. set radius(value: BABYLON.float);
  86822. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86823. private _sphericalMapping;
  86824. }
  86825. }
  86826. declare module BABYLON.GUI {
  86827. /**
  86828. * Class used to create a stack panel in 3D on XY plane
  86829. */
  86830. export class StackPanel3D extends Container3D {
  86831. private _isVertical;
  86832. /**
  86833. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86834. */
  86835. get isVertical(): boolean;
  86836. set isVertical(value: boolean);
  86837. /**
  86838. * Gets or sets the distance between elements
  86839. */
  86840. margin: number;
  86841. /**
  86842. * Creates new StackPanel
  86843. * @param isVertical
  86844. */
  86845. constructor(isVertical?: boolean);
  86846. protected _arrangeChildren(): void;
  86847. }
  86848. }
  86849. declare module BABYLON {
  86850. /**
  86851. * Configuration for glTF validation
  86852. */
  86853. export interface IGLTFValidationConfiguration {
  86854. /**
  86855. * The url of the glTF validator.
  86856. */
  86857. url: string;
  86858. }
  86859. /**
  86860. * glTF validation
  86861. */
  86862. export class GLTFValidation {
  86863. /**
  86864. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86865. */
  86866. static Configuration: IGLTFValidationConfiguration;
  86867. private static _LoadScriptPromise;
  86868. /**
  86869. * Validate a glTF asset using the glTF-Validator.
  86870. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86871. * @param rootUrl The root url for the glTF
  86872. * @param fileName The file name for the glTF
  86873. * @param getExternalResource The callback to get external resources for the glTF validator
  86874. * @returns A promise that resolves with the glTF validation results once complete
  86875. */
  86876. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86877. }
  86878. }
  86879. declare module BABYLON {
  86880. /**
  86881. * Mode that determines the coordinate system to use.
  86882. */
  86883. export enum GLTFLoaderCoordinateSystemMode {
  86884. /**
  86885. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86886. */
  86887. AUTO = 0,
  86888. /**
  86889. * Sets the useRightHandedSystem flag on the scene.
  86890. */
  86891. FORCE_RIGHT_HANDED = 1
  86892. }
  86893. /**
  86894. * Mode that determines what animations will start.
  86895. */
  86896. export enum GLTFLoaderAnimationStartMode {
  86897. /**
  86898. * No animation will start.
  86899. */
  86900. NONE = 0,
  86901. /**
  86902. * The first animation will start.
  86903. */
  86904. FIRST = 1,
  86905. /**
  86906. * All animations will start.
  86907. */
  86908. ALL = 2
  86909. }
  86910. /**
  86911. * Interface that contains the data for the glTF asset.
  86912. */
  86913. export interface IGLTFLoaderData {
  86914. /**
  86915. * The object that represents the glTF JSON.
  86916. */
  86917. json: Object;
  86918. /**
  86919. * The BIN chunk of a binary glTF.
  86920. */
  86921. bin: Nullable<IDataBuffer>;
  86922. }
  86923. /**
  86924. * Interface for extending the loader.
  86925. */
  86926. export interface IGLTFLoaderExtension {
  86927. /**
  86928. * The name of this extension.
  86929. */
  86930. readonly name: string;
  86931. /**
  86932. * Defines whether this extension is enabled.
  86933. */
  86934. enabled: boolean;
  86935. /**
  86936. * Defines the order of this extension.
  86937. * The loader sorts the extensions using these values when loading.
  86938. */
  86939. order?: number;
  86940. }
  86941. /**
  86942. * Loader state.
  86943. */
  86944. export enum GLTFLoaderState {
  86945. /**
  86946. * The asset is loading.
  86947. */
  86948. LOADING = 0,
  86949. /**
  86950. * The asset is ready for rendering.
  86951. */
  86952. READY = 1,
  86953. /**
  86954. * The asset is completely loaded.
  86955. */
  86956. COMPLETE = 2
  86957. }
  86958. /** @hidden */
  86959. export interface IGLTFLoader extends IDisposable {
  86960. readonly state: Nullable<GLTFLoaderState>;
  86961. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86962. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86963. }
  86964. /**
  86965. * File loader for loading glTF files into a scene.
  86966. */
  86967. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86968. /** @hidden */
  86969. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86970. /** @hidden */
  86971. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86972. /**
  86973. * Raised when the asset has been parsed
  86974. */
  86975. onParsedObservable: Observable<IGLTFLoaderData>;
  86976. private _onParsedObserver;
  86977. /**
  86978. * Raised when the asset has been parsed
  86979. */
  86980. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86981. /**
  86982. * 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.
  86983. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86984. * Defaults to true.
  86985. * @hidden
  86986. */
  86987. static IncrementalLoading: boolean;
  86988. /**
  86989. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86990. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86991. * @hidden
  86992. */
  86993. static HomogeneousCoordinates: boolean;
  86994. /**
  86995. * The coordinate system mode. Defaults to AUTO.
  86996. */
  86997. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86998. /**
  86999. * The animation start mode. Defaults to FIRST.
  87000. */
  87001. animationStartMode: GLTFLoaderAnimationStartMode;
  87002. /**
  87003. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87004. */
  87005. compileMaterials: boolean;
  87006. /**
  87007. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87008. */
  87009. useClipPlane: boolean;
  87010. /**
  87011. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87012. */
  87013. compileShadowGenerators: boolean;
  87014. /**
  87015. * Defines if the Alpha blended materials are only applied as coverage.
  87016. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87017. * If true, no extra effects are applied to transparent pixels.
  87018. */
  87019. transparencyAsCoverage: boolean;
  87020. /**
  87021. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87022. * Enabling will disable offline support and glTF validator.
  87023. * Defaults to false.
  87024. */
  87025. useRangeRequests: boolean;
  87026. /**
  87027. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87028. */
  87029. createInstances: boolean;
  87030. /**
  87031. * 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.
  87032. */
  87033. alwaysComputeBoundingBox: boolean;
  87034. /**
  87035. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87036. */
  87037. loadAllMaterials: boolean;
  87038. /**
  87039. * Function called before loading a url referenced by the asset.
  87040. */
  87041. preprocessUrlAsync: (url: string) => Promise<string>;
  87042. /**
  87043. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87044. * 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, ...)
  87045. */
  87046. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87047. private _onMeshLoadedObserver;
  87048. /**
  87049. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87050. * 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, ...)
  87051. */
  87052. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87053. /**
  87054. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87055. */
  87056. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87057. private _onTextureLoadedObserver;
  87058. /**
  87059. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87060. */
  87061. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87062. /**
  87063. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87064. */
  87065. readonly onMaterialLoadedObservable: Observable<Material>;
  87066. private _onMaterialLoadedObserver;
  87067. /**
  87068. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87069. */
  87070. set onMaterialLoaded(callback: (material: Material) => void);
  87071. /**
  87072. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87073. */
  87074. readonly onCameraLoadedObservable: Observable<Camera>;
  87075. private _onCameraLoadedObserver;
  87076. /**
  87077. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87078. */
  87079. set onCameraLoaded(callback: (camera: Camera) => void);
  87080. /**
  87081. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87082. * For assets with LODs, raised when all of the LODs are complete.
  87083. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87084. */
  87085. readonly onCompleteObservable: Observable<void>;
  87086. private _onCompleteObserver;
  87087. /**
  87088. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87089. * For assets with LODs, raised when all of the LODs are complete.
  87090. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87091. */
  87092. set onComplete(callback: () => void);
  87093. /**
  87094. * Observable raised when an error occurs.
  87095. */
  87096. readonly onErrorObservable: Observable<any>;
  87097. private _onErrorObserver;
  87098. /**
  87099. * Callback raised when an error occurs.
  87100. */
  87101. set onError(callback: (reason: any) => void);
  87102. /**
  87103. * Observable raised after the loader is disposed.
  87104. */
  87105. readonly onDisposeObservable: Observable<void>;
  87106. private _onDisposeObserver;
  87107. /**
  87108. * Callback raised after the loader is disposed.
  87109. */
  87110. set onDispose(callback: () => void);
  87111. /**
  87112. * Observable raised after a loader extension is created.
  87113. * Set additional options for a loader extension in this event.
  87114. */
  87115. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87116. private _onExtensionLoadedObserver;
  87117. /**
  87118. * Callback raised after a loader extension is created.
  87119. */
  87120. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87121. /**
  87122. * Defines if the loader logging is enabled.
  87123. */
  87124. get loggingEnabled(): boolean;
  87125. set loggingEnabled(value: boolean);
  87126. /**
  87127. * Defines if the loader should capture performance counters.
  87128. */
  87129. get capturePerformanceCounters(): boolean;
  87130. set capturePerformanceCounters(value: boolean);
  87131. /**
  87132. * Defines if the loader should validate the asset.
  87133. */
  87134. validate: boolean;
  87135. /**
  87136. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87137. */
  87138. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87139. private _onValidatedObserver;
  87140. /**
  87141. * Callback raised after a loader extension is created.
  87142. */
  87143. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87144. private _loader;
  87145. private _progressCallback?;
  87146. private _requests;
  87147. private static magicBase64Encoded;
  87148. /**
  87149. * Name of the loader ("gltf")
  87150. */
  87151. name: string;
  87152. /** @hidden */
  87153. extensions: ISceneLoaderPluginExtensions;
  87154. /**
  87155. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87156. */
  87157. dispose(): void;
  87158. /** @hidden */
  87159. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87160. /** @hidden */
  87161. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87162. /** @hidden */
  87163. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87164. /** @hidden */
  87165. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87166. /** @hidden */
  87167. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87168. /** @hidden */
  87169. canDirectLoad(data: string): boolean;
  87170. /** @hidden */
  87171. directLoad(scene: Scene, data: string): Promise<any>;
  87172. /**
  87173. * The callback that allows custom handling of the root url based on the response url.
  87174. * @param rootUrl the original root url
  87175. * @param responseURL the response url if available
  87176. * @returns the new root url
  87177. */
  87178. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87179. /** @hidden */
  87180. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87181. /**
  87182. * The loader state or null if the loader is not active.
  87183. */
  87184. get loaderState(): Nullable<GLTFLoaderState>;
  87185. /**
  87186. * Returns a promise that resolves when the asset is completely loaded.
  87187. * @returns a promise that resolves when the asset is completely loaded.
  87188. */
  87189. whenCompleteAsync(): Promise<void>;
  87190. /** @hidden */
  87191. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87192. /** @hidden */
  87193. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87194. private _onProgress;
  87195. private _validate;
  87196. private _getLoader;
  87197. private _parseJson;
  87198. private _unpackBinaryAsync;
  87199. private _unpackBinaryV1Async;
  87200. private _unpackBinaryV2Async;
  87201. private static _parseVersion;
  87202. private static _compareVersion;
  87203. private static readonly _logSpaces;
  87204. private _logIndentLevel;
  87205. private _loggingEnabled;
  87206. /** @hidden */
  87207. _log: (message: string) => void;
  87208. /** @hidden */
  87209. _logOpen(message: string): void;
  87210. /** @hidden */
  87211. _logClose(): void;
  87212. private _logEnabled;
  87213. private _logDisabled;
  87214. private _capturePerformanceCounters;
  87215. /** @hidden */
  87216. _startPerformanceCounter: (counterName: string) => void;
  87217. /** @hidden */
  87218. _endPerformanceCounter: (counterName: string) => void;
  87219. private _startPerformanceCounterEnabled;
  87220. private _startPerformanceCounterDisabled;
  87221. private _endPerformanceCounterEnabled;
  87222. private _endPerformanceCounterDisabled;
  87223. }
  87224. }
  87225. declare module BABYLON.GLTF1 {
  87226. /**
  87227. * Enums
  87228. * @hidden
  87229. */
  87230. export enum EComponentType {
  87231. BYTE = 5120,
  87232. UNSIGNED_BYTE = 5121,
  87233. SHORT = 5122,
  87234. UNSIGNED_SHORT = 5123,
  87235. FLOAT = 5126
  87236. }
  87237. /** @hidden */
  87238. export enum EShaderType {
  87239. FRAGMENT = 35632,
  87240. VERTEX = 35633
  87241. }
  87242. /** @hidden */
  87243. export enum EParameterType {
  87244. BYTE = 5120,
  87245. UNSIGNED_BYTE = 5121,
  87246. SHORT = 5122,
  87247. UNSIGNED_SHORT = 5123,
  87248. INT = 5124,
  87249. UNSIGNED_INT = 5125,
  87250. FLOAT = 5126,
  87251. FLOAT_VEC2 = 35664,
  87252. FLOAT_VEC3 = 35665,
  87253. FLOAT_VEC4 = 35666,
  87254. INT_VEC2 = 35667,
  87255. INT_VEC3 = 35668,
  87256. INT_VEC4 = 35669,
  87257. BOOL = 35670,
  87258. BOOL_VEC2 = 35671,
  87259. BOOL_VEC3 = 35672,
  87260. BOOL_VEC4 = 35673,
  87261. FLOAT_MAT2 = 35674,
  87262. FLOAT_MAT3 = 35675,
  87263. FLOAT_MAT4 = 35676,
  87264. SAMPLER_2D = 35678
  87265. }
  87266. /** @hidden */
  87267. export enum ETextureWrapMode {
  87268. CLAMP_TO_EDGE = 33071,
  87269. MIRRORED_REPEAT = 33648,
  87270. REPEAT = 10497
  87271. }
  87272. /** @hidden */
  87273. export enum ETextureFilterType {
  87274. NEAREST = 9728,
  87275. LINEAR = 9728,
  87276. NEAREST_MIPMAP_NEAREST = 9984,
  87277. LINEAR_MIPMAP_NEAREST = 9985,
  87278. NEAREST_MIPMAP_LINEAR = 9986,
  87279. LINEAR_MIPMAP_LINEAR = 9987
  87280. }
  87281. /** @hidden */
  87282. export enum ETextureFormat {
  87283. ALPHA = 6406,
  87284. RGB = 6407,
  87285. RGBA = 6408,
  87286. LUMINANCE = 6409,
  87287. LUMINANCE_ALPHA = 6410
  87288. }
  87289. /** @hidden */
  87290. export enum ECullingType {
  87291. FRONT = 1028,
  87292. BACK = 1029,
  87293. FRONT_AND_BACK = 1032
  87294. }
  87295. /** @hidden */
  87296. export enum EBlendingFunction {
  87297. ZERO = 0,
  87298. ONE = 1,
  87299. SRC_COLOR = 768,
  87300. ONE_MINUS_SRC_COLOR = 769,
  87301. DST_COLOR = 774,
  87302. ONE_MINUS_DST_COLOR = 775,
  87303. SRC_ALPHA = 770,
  87304. ONE_MINUS_SRC_ALPHA = 771,
  87305. DST_ALPHA = 772,
  87306. ONE_MINUS_DST_ALPHA = 773,
  87307. CONSTANT_COLOR = 32769,
  87308. ONE_MINUS_CONSTANT_COLOR = 32770,
  87309. CONSTANT_ALPHA = 32771,
  87310. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87311. SRC_ALPHA_SATURATE = 776
  87312. }
  87313. /** @hidden */
  87314. export interface IGLTFProperty {
  87315. extensions?: {
  87316. [key: string]: any;
  87317. };
  87318. extras?: Object;
  87319. }
  87320. /** @hidden */
  87321. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87322. name?: string;
  87323. }
  87324. /** @hidden */
  87325. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87326. bufferView: string;
  87327. byteOffset: number;
  87328. byteStride: number;
  87329. count: number;
  87330. type: string;
  87331. componentType: EComponentType;
  87332. max?: number[];
  87333. min?: number[];
  87334. name?: string;
  87335. }
  87336. /** @hidden */
  87337. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87338. buffer: string;
  87339. byteOffset: number;
  87340. byteLength: number;
  87341. byteStride: number;
  87342. target?: number;
  87343. }
  87344. /** @hidden */
  87345. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87346. uri: string;
  87347. byteLength?: number;
  87348. type?: string;
  87349. }
  87350. /** @hidden */
  87351. export interface IGLTFShader extends IGLTFChildRootProperty {
  87352. uri: string;
  87353. type: EShaderType;
  87354. }
  87355. /** @hidden */
  87356. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87357. attributes: string[];
  87358. fragmentShader: string;
  87359. vertexShader: string;
  87360. }
  87361. /** @hidden */
  87362. export interface IGLTFTechniqueParameter {
  87363. type: number;
  87364. count?: number;
  87365. semantic?: string;
  87366. node?: string;
  87367. value?: number | boolean | string | Array<any>;
  87368. source?: string;
  87369. babylonValue?: any;
  87370. }
  87371. /** @hidden */
  87372. export interface IGLTFTechniqueCommonProfile {
  87373. lightingModel: string;
  87374. texcoordBindings: Object;
  87375. parameters?: Array<any>;
  87376. }
  87377. /** @hidden */
  87378. export interface IGLTFTechniqueStatesFunctions {
  87379. blendColor?: number[];
  87380. blendEquationSeparate?: number[];
  87381. blendFuncSeparate?: number[];
  87382. colorMask: boolean[];
  87383. cullFace: number[];
  87384. }
  87385. /** @hidden */
  87386. export interface IGLTFTechniqueStates {
  87387. enable: number[];
  87388. functions: IGLTFTechniqueStatesFunctions;
  87389. }
  87390. /** @hidden */
  87391. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87392. parameters: {
  87393. [key: string]: IGLTFTechniqueParameter;
  87394. };
  87395. program: string;
  87396. attributes: {
  87397. [key: string]: string;
  87398. };
  87399. uniforms: {
  87400. [key: string]: string;
  87401. };
  87402. states: IGLTFTechniqueStates;
  87403. }
  87404. /** @hidden */
  87405. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87406. technique?: string;
  87407. values: string[];
  87408. }
  87409. /** @hidden */
  87410. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87411. attributes: {
  87412. [key: string]: string;
  87413. };
  87414. indices: string;
  87415. material: string;
  87416. mode?: number;
  87417. }
  87418. /** @hidden */
  87419. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87420. primitives: IGLTFMeshPrimitive[];
  87421. }
  87422. /** @hidden */
  87423. export interface IGLTFImage extends IGLTFChildRootProperty {
  87424. uri: string;
  87425. }
  87426. /** @hidden */
  87427. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87428. magFilter?: number;
  87429. minFilter?: number;
  87430. wrapS?: number;
  87431. wrapT?: number;
  87432. }
  87433. /** @hidden */
  87434. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87435. sampler: string;
  87436. source: string;
  87437. format?: ETextureFormat;
  87438. internalFormat?: ETextureFormat;
  87439. target?: number;
  87440. type?: number;
  87441. babylonTexture?: Texture;
  87442. }
  87443. /** @hidden */
  87444. export interface IGLTFAmbienLight {
  87445. color?: number[];
  87446. }
  87447. /** @hidden */
  87448. export interface IGLTFDirectionalLight {
  87449. color?: number[];
  87450. }
  87451. /** @hidden */
  87452. export interface IGLTFPointLight {
  87453. color?: number[];
  87454. constantAttenuation?: number;
  87455. linearAttenuation?: number;
  87456. quadraticAttenuation?: number;
  87457. }
  87458. /** @hidden */
  87459. export interface IGLTFSpotLight {
  87460. color?: number[];
  87461. constantAttenuation?: number;
  87462. fallOfAngle?: number;
  87463. fallOffExponent?: number;
  87464. linearAttenuation?: number;
  87465. quadraticAttenuation?: number;
  87466. }
  87467. /** @hidden */
  87468. export interface IGLTFLight extends IGLTFChildRootProperty {
  87469. type: string;
  87470. }
  87471. /** @hidden */
  87472. export interface IGLTFCameraOrthographic {
  87473. xmag: number;
  87474. ymag: number;
  87475. zfar: number;
  87476. znear: number;
  87477. }
  87478. /** @hidden */
  87479. export interface IGLTFCameraPerspective {
  87480. aspectRatio: number;
  87481. yfov: number;
  87482. zfar: number;
  87483. znear: number;
  87484. }
  87485. /** @hidden */
  87486. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87487. type: string;
  87488. }
  87489. /** @hidden */
  87490. export interface IGLTFAnimationChannelTarget {
  87491. id: string;
  87492. path: string;
  87493. }
  87494. /** @hidden */
  87495. export interface IGLTFAnimationChannel {
  87496. sampler: string;
  87497. target: IGLTFAnimationChannelTarget;
  87498. }
  87499. /** @hidden */
  87500. export interface IGLTFAnimationSampler {
  87501. input: string;
  87502. output: string;
  87503. interpolation?: string;
  87504. }
  87505. /** @hidden */
  87506. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87507. channels?: IGLTFAnimationChannel[];
  87508. parameters?: {
  87509. [key: string]: string;
  87510. };
  87511. samplers?: {
  87512. [key: string]: IGLTFAnimationSampler;
  87513. };
  87514. }
  87515. /** @hidden */
  87516. export interface IGLTFNodeInstanceSkin {
  87517. skeletons: string[];
  87518. skin: string;
  87519. meshes: string[];
  87520. }
  87521. /** @hidden */
  87522. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87523. bindShapeMatrix: number[];
  87524. inverseBindMatrices: string;
  87525. jointNames: string[];
  87526. babylonSkeleton?: Skeleton;
  87527. }
  87528. /** @hidden */
  87529. export interface IGLTFNode extends IGLTFChildRootProperty {
  87530. camera?: string;
  87531. children: string[];
  87532. skin?: string;
  87533. jointName?: string;
  87534. light?: string;
  87535. matrix: number[];
  87536. mesh?: string;
  87537. meshes?: string[];
  87538. rotation?: number[];
  87539. scale?: number[];
  87540. translation?: number[];
  87541. babylonNode?: Node;
  87542. }
  87543. /** @hidden */
  87544. export interface IGLTFScene extends IGLTFChildRootProperty {
  87545. nodes: string[];
  87546. }
  87547. /** @hidden */
  87548. export interface IGLTFRuntime {
  87549. extensions: {
  87550. [key: string]: any;
  87551. };
  87552. accessors: {
  87553. [key: string]: IGLTFAccessor;
  87554. };
  87555. buffers: {
  87556. [key: string]: IGLTFBuffer;
  87557. };
  87558. bufferViews: {
  87559. [key: string]: IGLTFBufferView;
  87560. };
  87561. meshes: {
  87562. [key: string]: IGLTFMesh;
  87563. };
  87564. lights: {
  87565. [key: string]: IGLTFLight;
  87566. };
  87567. cameras: {
  87568. [key: string]: IGLTFCamera;
  87569. };
  87570. nodes: {
  87571. [key: string]: IGLTFNode;
  87572. };
  87573. images: {
  87574. [key: string]: IGLTFImage;
  87575. };
  87576. textures: {
  87577. [key: string]: IGLTFTexture;
  87578. };
  87579. shaders: {
  87580. [key: string]: IGLTFShader;
  87581. };
  87582. programs: {
  87583. [key: string]: IGLTFProgram;
  87584. };
  87585. samplers: {
  87586. [key: string]: IGLTFSampler;
  87587. };
  87588. techniques: {
  87589. [key: string]: IGLTFTechnique;
  87590. };
  87591. materials: {
  87592. [key: string]: IGLTFMaterial;
  87593. };
  87594. animations: {
  87595. [key: string]: IGLTFAnimation;
  87596. };
  87597. skins: {
  87598. [key: string]: IGLTFSkins;
  87599. };
  87600. currentScene?: Object;
  87601. scenes: {
  87602. [key: string]: IGLTFScene;
  87603. };
  87604. extensionsUsed: string[];
  87605. extensionsRequired?: string[];
  87606. buffersCount: number;
  87607. shaderscount: number;
  87608. scene: Scene;
  87609. rootUrl: string;
  87610. loadedBufferCount: number;
  87611. loadedBufferViews: {
  87612. [name: string]: ArrayBufferView;
  87613. };
  87614. loadedShaderCount: number;
  87615. importOnlyMeshes: boolean;
  87616. importMeshesNames?: string[];
  87617. dummyNodes: Node[];
  87618. forAssetContainer: boolean;
  87619. }
  87620. /** @hidden */
  87621. export interface INodeToRoot {
  87622. bone: Bone;
  87623. node: IGLTFNode;
  87624. id: string;
  87625. }
  87626. /** @hidden */
  87627. export interface IJointNode {
  87628. node: IGLTFNode;
  87629. id: string;
  87630. }
  87631. }
  87632. declare module BABYLON.GLTF1 {
  87633. /**
  87634. * Utils functions for GLTF
  87635. * @hidden
  87636. */
  87637. export class GLTFUtils {
  87638. /**
  87639. * Sets the given "parameter" matrix
  87640. * @param scene: the Scene object
  87641. * @param source: the source node where to pick the matrix
  87642. * @param parameter: the GLTF technique parameter
  87643. * @param uniformName: the name of the shader's uniform
  87644. * @param shaderMaterial: the shader material
  87645. */
  87646. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87647. /**
  87648. * Sets the given "parameter" matrix
  87649. * @param shaderMaterial: the shader material
  87650. * @param uniform: the name of the shader's uniform
  87651. * @param value: the value of the uniform
  87652. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87653. */
  87654. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87655. /**
  87656. * Returns the wrap mode of the texture
  87657. * @param mode: the mode value
  87658. */
  87659. static GetWrapMode(mode: number): number;
  87660. /**
  87661. * Returns the byte stride giving an accessor
  87662. * @param accessor: the GLTF accessor objet
  87663. */
  87664. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87665. /**
  87666. * Returns the texture filter mode giving a mode value
  87667. * @param mode: the filter mode value
  87668. */
  87669. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87670. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87671. /**
  87672. * Returns a buffer from its accessor
  87673. * @param gltfRuntime: the GLTF runtime
  87674. * @param accessor: the GLTF accessor
  87675. */
  87676. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87677. /**
  87678. * Decodes a buffer view into a string
  87679. * @param view: the buffer view
  87680. */
  87681. static DecodeBufferToText(view: ArrayBufferView): string;
  87682. /**
  87683. * Returns the default material of gltf. Related to
  87684. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87685. * @param scene: the Babylon.js scene
  87686. */
  87687. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87688. private static _DefaultMaterial;
  87689. }
  87690. }
  87691. declare module BABYLON.GLTF1 {
  87692. /**
  87693. * Implementation of the base glTF spec
  87694. * @hidden
  87695. */
  87696. export class GLTFLoaderBase {
  87697. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87698. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87699. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87700. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87701. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87702. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87703. }
  87704. /**
  87705. * glTF V1 Loader
  87706. * @hidden
  87707. */
  87708. export class GLTFLoader implements IGLTFLoader {
  87709. static Extensions: {
  87710. [name: string]: GLTFLoaderExtension;
  87711. };
  87712. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87713. state: Nullable<GLTFLoaderState>;
  87714. dispose(): void;
  87715. private _importMeshAsync;
  87716. /**
  87717. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87718. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87719. * @param scene the scene the meshes should be added to
  87720. * @param forAssetContainer defines if the entities must be stored in the scene
  87721. * @param data gltf data containing information of the meshes in a loaded file
  87722. * @param rootUrl root url to load from
  87723. * @param onProgress event that fires when loading progress has occured
  87724. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87725. */
  87726. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87727. private _loadAsync;
  87728. /**
  87729. * Imports all objects from a loaded gltf file and adds them to the scene
  87730. * @param scene the scene the objects should be added to
  87731. * @param data gltf data containing information of the meshes in a loaded file
  87732. * @param rootUrl root url to load from
  87733. * @param onProgress event that fires when loading progress has occured
  87734. * @returns a promise which completes when objects have been loaded to the scene
  87735. */
  87736. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87737. private _loadShadersAsync;
  87738. private _loadBuffersAsync;
  87739. private _createNodes;
  87740. }
  87741. /** @hidden */
  87742. export abstract class GLTFLoaderExtension {
  87743. private _name;
  87744. constructor(name: string);
  87745. get name(): string;
  87746. /**
  87747. * Defines an override for loading the runtime
  87748. * Return true to stop further extensions from loading the runtime
  87749. */
  87750. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87751. /**
  87752. * Defines an onverride for creating gltf runtime
  87753. * Return true to stop further extensions from creating the runtime
  87754. */
  87755. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87756. /**
  87757. * Defines an override for loading buffers
  87758. * Return true to stop further extensions from loading this buffer
  87759. */
  87760. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87761. /**
  87762. * Defines an override for loading texture buffers
  87763. * Return true to stop further extensions from loading this texture data
  87764. */
  87765. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87766. /**
  87767. * Defines an override for creating textures
  87768. * Return true to stop further extensions from loading this texture
  87769. */
  87770. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87771. /**
  87772. * Defines an override for loading shader strings
  87773. * Return true to stop further extensions from loading this shader data
  87774. */
  87775. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87776. /**
  87777. * Defines an override for loading materials
  87778. * Return true to stop further extensions from loading this material
  87779. */
  87780. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87781. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87782. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87783. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87784. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87785. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87786. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87787. private static LoadTextureBufferAsync;
  87788. private static CreateTextureAsync;
  87789. private static ApplyExtensions;
  87790. }
  87791. }
  87792. declare module BABYLON.GLTF1 {
  87793. /** @hidden */
  87794. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87795. private _bin;
  87796. constructor();
  87797. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87798. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87799. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87800. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87801. }
  87802. }
  87803. declare module BABYLON.GLTF1 {
  87804. /** @hidden */
  87805. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87806. constructor();
  87807. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87808. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87809. private _loadTexture;
  87810. }
  87811. }
  87812. declare module BABYLON.GLTF2.Loader {
  87813. /**
  87814. * Loader interface with an index field.
  87815. */
  87816. export interface IArrayItem {
  87817. /**
  87818. * The index of this item in the array.
  87819. */
  87820. index: number;
  87821. }
  87822. /**
  87823. * Loader interface with additional members.
  87824. */
  87825. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87826. /** @hidden */
  87827. _data?: Promise<ArrayBufferView>;
  87828. /** @hidden */
  87829. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87830. }
  87831. /**
  87832. * Loader interface with additional members.
  87833. */
  87834. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87835. }
  87836. /** @hidden */
  87837. export interface _IAnimationSamplerData {
  87838. input: Float32Array;
  87839. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87840. output: Float32Array;
  87841. }
  87842. /**
  87843. * Loader interface with additional members.
  87844. */
  87845. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87846. /** @hidden */
  87847. _data?: Promise<_IAnimationSamplerData>;
  87848. }
  87849. /**
  87850. * Loader interface with additional members.
  87851. */
  87852. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87853. channels: IAnimationChannel[];
  87854. samplers: IAnimationSampler[];
  87855. /** @hidden */
  87856. _babylonAnimationGroup?: AnimationGroup;
  87857. }
  87858. /**
  87859. * Loader interface with additional members.
  87860. */
  87861. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87862. /** @hidden */
  87863. _data?: Promise<ArrayBufferView>;
  87864. }
  87865. /**
  87866. * Loader interface with additional members.
  87867. */
  87868. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87869. /** @hidden */
  87870. _data?: Promise<ArrayBufferView>;
  87871. /** @hidden */
  87872. _babylonBuffer?: Promise<Buffer>;
  87873. }
  87874. /**
  87875. * Loader interface with additional members.
  87876. */
  87877. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87878. }
  87879. /**
  87880. * Loader interface with additional members.
  87881. */
  87882. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87883. /** @hidden */
  87884. _data?: Promise<ArrayBufferView>;
  87885. }
  87886. /**
  87887. * Loader interface with additional members.
  87888. */
  87889. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87890. }
  87891. /**
  87892. * Loader interface with additional members.
  87893. */
  87894. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87895. }
  87896. /**
  87897. * Loader interface with additional members.
  87898. */
  87899. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87900. baseColorTexture?: ITextureInfo;
  87901. metallicRoughnessTexture?: ITextureInfo;
  87902. }
  87903. /**
  87904. * Loader interface with additional members.
  87905. */
  87906. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87907. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87908. normalTexture?: IMaterialNormalTextureInfo;
  87909. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87910. emissiveTexture?: ITextureInfo;
  87911. /** @hidden */
  87912. _data?: {
  87913. [babylonDrawMode: number]: {
  87914. babylonMaterial: Material;
  87915. babylonMeshes: AbstractMesh[];
  87916. promise: Promise<void>;
  87917. };
  87918. };
  87919. }
  87920. /**
  87921. * Loader interface with additional members.
  87922. */
  87923. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87924. primitives: IMeshPrimitive[];
  87925. }
  87926. /**
  87927. * Loader interface with additional members.
  87928. */
  87929. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87930. /** @hidden */
  87931. _instanceData?: {
  87932. babylonSourceMesh: Mesh;
  87933. promise: Promise<any>;
  87934. };
  87935. }
  87936. /**
  87937. * Loader interface with additional members.
  87938. */
  87939. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87940. /**
  87941. * The parent glTF node.
  87942. */
  87943. parent?: INode;
  87944. /** @hidden */
  87945. _babylonTransformNode?: TransformNode;
  87946. /** @hidden */
  87947. _primitiveBabylonMeshes?: AbstractMesh[];
  87948. /** @hidden */
  87949. _babylonBones?: Bone[];
  87950. /** @hidden */
  87951. _numMorphTargets?: number;
  87952. }
  87953. /** @hidden */
  87954. export interface _ISamplerData {
  87955. noMipMaps: boolean;
  87956. samplingMode: number;
  87957. wrapU: number;
  87958. wrapV: number;
  87959. }
  87960. /**
  87961. * Loader interface with additional members.
  87962. */
  87963. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87964. /** @hidden */
  87965. _data?: _ISamplerData;
  87966. }
  87967. /**
  87968. * Loader interface with additional members.
  87969. */
  87970. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87971. }
  87972. /**
  87973. * Loader interface with additional members.
  87974. */
  87975. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87976. /** @hidden */
  87977. _data?: {
  87978. babylonSkeleton: Skeleton;
  87979. promise: Promise<void>;
  87980. };
  87981. }
  87982. /**
  87983. * Loader interface with additional members.
  87984. */
  87985. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87986. /** @hidden */
  87987. _textureInfo: ITextureInfo;
  87988. }
  87989. /**
  87990. * Loader interface with additional members.
  87991. */
  87992. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87993. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87994. nonColorData?: boolean;
  87995. }
  87996. /**
  87997. * Loader interface with additional members.
  87998. */
  87999. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88000. accessors?: IAccessor[];
  88001. animations?: IAnimation[];
  88002. buffers?: IBuffer[];
  88003. bufferViews?: IBufferView[];
  88004. cameras?: ICamera[];
  88005. images?: IImage[];
  88006. materials?: IMaterial[];
  88007. meshes?: IMesh[];
  88008. nodes?: INode[];
  88009. samplers?: ISampler[];
  88010. scenes?: IScene[];
  88011. skins?: ISkin[];
  88012. textures?: ITexture[];
  88013. }
  88014. }
  88015. declare module BABYLON.GLTF2 {
  88016. /**
  88017. * Interface for a glTF loader extension.
  88018. */
  88019. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88020. /**
  88021. * Called after the loader state changes to LOADING.
  88022. */
  88023. onLoading?(): void;
  88024. /**
  88025. * Called after the loader state changes to READY.
  88026. */
  88027. onReady?(): void;
  88028. /**
  88029. * Define this method to modify the default behavior when loading scenes.
  88030. * @param context The context when loading the asset
  88031. * @param scene The glTF scene property
  88032. * @returns A promise that resolves when the load is complete or null if not handled
  88033. */
  88034. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88035. /**
  88036. * Define this method to modify the default behavior when loading nodes.
  88037. * @param context The context when loading the asset
  88038. * @param node The glTF node property
  88039. * @param assign A function called synchronously after parsing the glTF properties
  88040. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88041. */
  88042. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88043. /**
  88044. * Define this method to modify the default behavior when loading cameras.
  88045. * @param context The context when loading the asset
  88046. * @param camera The glTF camera property
  88047. * @param assign A function called synchronously after parsing the glTF properties
  88048. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88049. */
  88050. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88051. /**
  88052. * @hidden
  88053. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88054. * @param context The context when loading the asset
  88055. * @param primitive The glTF mesh primitive property
  88056. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88057. */
  88058. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88059. /**
  88060. * @hidden
  88061. * Define this method to modify the default behavior when loading data for mesh primitives.
  88062. * @param context The context when loading the asset
  88063. * @param name The mesh name when loading the asset
  88064. * @param node The glTF node when loading the asset
  88065. * @param mesh The glTF mesh when loading the asset
  88066. * @param primitive The glTF mesh primitive property
  88067. * @param assign A function called synchronously after parsing the glTF properties
  88068. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88069. */
  88070. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88071. /**
  88072. * @hidden
  88073. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88074. * @param context The context when loading the asset
  88075. * @param material The glTF material property
  88076. * @param assign A function called synchronously after parsing the glTF properties
  88077. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88078. */
  88079. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88080. /**
  88081. * Define this method to modify the default behavior when creating materials.
  88082. * @param context The context when loading the asset
  88083. * @param material The glTF material property
  88084. * @param babylonDrawMode The draw mode for the Babylon material
  88085. * @returns The Babylon material or null if not handled
  88086. */
  88087. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88088. /**
  88089. * Define this method to modify the default behavior when loading material properties.
  88090. * @param context The context when loading the asset
  88091. * @param material The glTF material property
  88092. * @param babylonMaterial The Babylon material
  88093. * @returns A promise that resolves when the load is complete or null if not handled
  88094. */
  88095. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88096. /**
  88097. * Define this method to modify the default behavior when loading texture infos.
  88098. * @param context The context when loading the asset
  88099. * @param textureInfo The glTF texture info property
  88100. * @param assign A function called synchronously after parsing the glTF properties
  88101. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88102. */
  88103. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88104. /**
  88105. * @hidden
  88106. * Define this method to modify the default behavior when loading textures.
  88107. * @param context The context when loading the asset
  88108. * @param texture The glTF texture property
  88109. * @param assign A function called synchronously after parsing the glTF properties
  88110. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88111. */
  88112. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88113. /**
  88114. * Define this method to modify the default behavior when loading animations.
  88115. * @param context The context when loading the asset
  88116. * @param animation The glTF animation property
  88117. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88118. */
  88119. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88120. /**
  88121. * @hidden
  88122. * Define this method to modify the default behavior when loading skins.
  88123. * @param context The context when loading the asset
  88124. * @param node The glTF node property
  88125. * @param skin The glTF skin property
  88126. * @returns A promise that resolves when the load is complete or null if not handled
  88127. */
  88128. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88129. /**
  88130. * @hidden
  88131. * Define this method to modify the default behavior when loading uris.
  88132. * @param context The context when loading the asset
  88133. * @param property The glTF property associated with the uri
  88134. * @param uri The uri to load
  88135. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88136. */
  88137. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88138. /**
  88139. * Define this method to modify the default behavior when loading buffer views.
  88140. * @param context The context when loading the asset
  88141. * @param bufferView The glTF buffer view property
  88142. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88143. */
  88144. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88145. /**
  88146. * Define this method to modify the default behavior when loading buffers.
  88147. * @param context The context when loading the asset
  88148. * @param buffer The glTF buffer property
  88149. * @param byteOffset The byte offset to load
  88150. * @param byteLength The byte length to load
  88151. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88152. */
  88153. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88154. }
  88155. }
  88156. declare module BABYLON.GLTF2 {
  88157. /**
  88158. * Helper class for working with arrays when loading the glTF asset
  88159. */
  88160. export class ArrayItem {
  88161. /**
  88162. * Gets an item from the given array.
  88163. * @param context The context when loading the asset
  88164. * @param array The array to get the item from
  88165. * @param index The index to the array
  88166. * @returns The array item
  88167. */
  88168. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88169. /**
  88170. * Assign an `index` field to each item of the given array.
  88171. * @param array The array of items
  88172. */
  88173. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88174. }
  88175. /**
  88176. * The glTF 2.0 loader
  88177. */
  88178. export class GLTFLoader implements IGLTFLoader {
  88179. /** @hidden */
  88180. _completePromises: Promise<any>[];
  88181. /** @hidden */
  88182. _forAssetContainer: boolean;
  88183. /** Storage */
  88184. _babylonLights: Light[];
  88185. /** @hidden */
  88186. _disableInstancedMesh: number;
  88187. private _disposed;
  88188. private _parent;
  88189. private _state;
  88190. private _extensions;
  88191. private _rootUrl;
  88192. private _fileName;
  88193. private _uniqueRootUrl;
  88194. private _gltf;
  88195. private _bin;
  88196. private _babylonScene;
  88197. private _rootBabylonMesh;
  88198. private _defaultBabylonMaterialData;
  88199. private static _RegisteredExtensions;
  88200. /**
  88201. * The default glTF sampler.
  88202. */
  88203. static readonly DefaultSampler: ISampler;
  88204. /**
  88205. * Registers a loader extension.
  88206. * @param name The name of the loader extension.
  88207. * @param factory The factory function that creates the loader extension.
  88208. */
  88209. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88210. /**
  88211. * Unregisters a loader extension.
  88212. * @param name The name of the loader extension.
  88213. * @returns A boolean indicating whether the extension has been unregistered
  88214. */
  88215. static UnregisterExtension(name: string): boolean;
  88216. /**
  88217. * The loader state.
  88218. */
  88219. get state(): Nullable<GLTFLoaderState>;
  88220. /**
  88221. * The object that represents the glTF JSON.
  88222. */
  88223. get gltf(): IGLTF;
  88224. /**
  88225. * The BIN chunk of a binary glTF.
  88226. */
  88227. get bin(): Nullable<IDataBuffer>;
  88228. /**
  88229. * The parent file loader.
  88230. */
  88231. get parent(): GLTFFileLoader;
  88232. /**
  88233. * The Babylon scene when loading the asset.
  88234. */
  88235. get babylonScene(): Scene;
  88236. /**
  88237. * The root Babylon mesh when loading the asset.
  88238. */
  88239. get rootBabylonMesh(): Mesh;
  88240. /** @hidden */
  88241. constructor(parent: GLTFFileLoader);
  88242. /** @hidden */
  88243. dispose(): void;
  88244. /** @hidden */
  88245. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88246. /** @hidden */
  88247. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88248. private _loadAsync;
  88249. private _loadData;
  88250. private _setupData;
  88251. private _loadExtensions;
  88252. private _checkExtensions;
  88253. private _setState;
  88254. private _createRootNode;
  88255. /**
  88256. * Loads a glTF scene.
  88257. * @param context The context when loading the asset
  88258. * @param scene The glTF scene property
  88259. * @returns A promise that resolves when the load is complete
  88260. */
  88261. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88262. private _forEachPrimitive;
  88263. private _getGeometries;
  88264. private _getMeshes;
  88265. private _getTransformNodes;
  88266. private _getSkeletons;
  88267. private _getAnimationGroups;
  88268. private _startAnimations;
  88269. /**
  88270. * Loads a glTF node.
  88271. * @param context The context when loading the asset
  88272. * @param node The glTF node property
  88273. * @param assign A function called synchronously after parsing the glTF properties
  88274. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88275. */
  88276. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88277. private _loadMeshAsync;
  88278. /**
  88279. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88280. * @param context The context when loading the asset
  88281. * @param name The mesh name when loading the asset
  88282. * @param node The glTF node when loading the asset
  88283. * @param mesh The glTF mesh when loading the asset
  88284. * @param primitive The glTF mesh primitive property
  88285. * @param assign A function called synchronously after parsing the glTF properties
  88286. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88287. */
  88288. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88289. private _loadVertexDataAsync;
  88290. private _createMorphTargets;
  88291. private _loadMorphTargetsAsync;
  88292. private _loadMorphTargetVertexDataAsync;
  88293. private static _LoadTransform;
  88294. private _loadSkinAsync;
  88295. private _loadBones;
  88296. private _loadBone;
  88297. private _loadSkinInverseBindMatricesDataAsync;
  88298. private _updateBoneMatrices;
  88299. private _getNodeMatrix;
  88300. /**
  88301. * Loads a glTF camera.
  88302. * @param context The context when loading the asset
  88303. * @param camera The glTF camera property
  88304. * @param assign A function called synchronously after parsing the glTF properties
  88305. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88306. */
  88307. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88308. private _loadAnimationsAsync;
  88309. /**
  88310. * Loads a glTF animation.
  88311. * @param context The context when loading the asset
  88312. * @param animation The glTF animation property
  88313. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88314. */
  88315. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88316. /**
  88317. * @hidden Loads a glTF animation channel.
  88318. * @param context The context when loading the asset
  88319. * @param animationContext The context of the animation when loading the asset
  88320. * @param animation The glTF animation property
  88321. * @param channel The glTF animation channel property
  88322. * @param babylonAnimationGroup The babylon animation group property
  88323. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88324. * @returns A void promise when the channel load is complete
  88325. */
  88326. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88327. private _loadAnimationSamplerAsync;
  88328. /**
  88329. * Loads a glTF buffer.
  88330. * @param context The context when loading the asset
  88331. * @param buffer The glTF buffer property
  88332. * @param byteOffset The byte offset to use
  88333. * @param byteLength The byte length to use
  88334. * @returns A promise that resolves with the loaded data when the load is complete
  88335. */
  88336. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88337. /**
  88338. * Loads a glTF buffer view.
  88339. * @param context The context when loading the asset
  88340. * @param bufferView The glTF buffer view property
  88341. * @returns A promise that resolves with the loaded data when the load is complete
  88342. */
  88343. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88344. private _loadAccessorAsync;
  88345. /** @hidden */
  88346. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88347. private _loadIndicesAccessorAsync;
  88348. private _loadVertexBufferViewAsync;
  88349. private _loadVertexAccessorAsync;
  88350. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88351. /** @hidden */
  88352. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88353. private _createDefaultMaterial;
  88354. /**
  88355. * Creates a Babylon material from a glTF material.
  88356. * @param context The context when loading the asset
  88357. * @param material The glTF material property
  88358. * @param babylonDrawMode The draw mode for the Babylon material
  88359. * @returns The Babylon material
  88360. */
  88361. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88362. /**
  88363. * Loads properties from a glTF material into a Babylon material.
  88364. * @param context The context when loading the asset
  88365. * @param material The glTF material property
  88366. * @param babylonMaterial The Babylon material
  88367. * @returns A promise that resolves when the load is complete
  88368. */
  88369. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88370. /**
  88371. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88372. * @param context The context when loading the asset
  88373. * @param material The glTF material property
  88374. * @param babylonMaterial The Babylon material
  88375. * @returns A promise that resolves when the load is complete
  88376. */
  88377. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88378. /**
  88379. * Loads the alpha properties from a glTF material into a Babylon material.
  88380. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88381. * @param context The context when loading the asset
  88382. * @param material The glTF material property
  88383. * @param babylonMaterial The Babylon material
  88384. */
  88385. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88386. /**
  88387. * Loads a glTF texture info.
  88388. * @param context The context when loading the asset
  88389. * @param textureInfo The glTF texture info property
  88390. * @param assign A function called synchronously after parsing the glTF properties
  88391. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88392. */
  88393. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88394. /** @hidden */
  88395. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88396. /** @hidden */
  88397. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88398. private _loadSampler;
  88399. /**
  88400. * Loads a glTF image.
  88401. * @param context The context when loading the asset
  88402. * @param image The glTF image property
  88403. * @returns A promise that resolves with the loaded data when the load is complete
  88404. */
  88405. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88406. /**
  88407. * Loads a glTF uri.
  88408. * @param context The context when loading the asset
  88409. * @param property The glTF property associated with the uri
  88410. * @param uri The base64 or relative uri
  88411. * @returns A promise that resolves with the loaded data when the load is complete
  88412. */
  88413. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88414. /**
  88415. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88416. * @param babylonObject the Babylon object with metadata
  88417. * @param pointer the JSON pointer
  88418. */
  88419. static AddPointerMetadata(babylonObject: {
  88420. metadata: any;
  88421. }, pointer: string): void;
  88422. private static _GetTextureWrapMode;
  88423. private static _GetTextureSamplingMode;
  88424. private static _GetTypedArrayConstructor;
  88425. private static _GetTypedArray;
  88426. private static _GetNumComponents;
  88427. private static _ValidateUri;
  88428. /** @hidden */
  88429. static _GetDrawMode(context: string, mode: number | undefined): number;
  88430. private _compileMaterialsAsync;
  88431. private _compileShadowGeneratorsAsync;
  88432. private _forEachExtensions;
  88433. private _applyExtensions;
  88434. private _extensionsOnLoading;
  88435. private _extensionsOnReady;
  88436. private _extensionsLoadSceneAsync;
  88437. private _extensionsLoadNodeAsync;
  88438. private _extensionsLoadCameraAsync;
  88439. private _extensionsLoadVertexDataAsync;
  88440. private _extensionsLoadMeshPrimitiveAsync;
  88441. private _extensionsLoadMaterialAsync;
  88442. private _extensionsCreateMaterial;
  88443. private _extensionsLoadMaterialPropertiesAsync;
  88444. private _extensionsLoadTextureInfoAsync;
  88445. private _extensionsLoadTextureAsync;
  88446. private _extensionsLoadAnimationAsync;
  88447. private _extensionsLoadSkinAsync;
  88448. private _extensionsLoadUriAsync;
  88449. private _extensionsLoadBufferViewAsync;
  88450. private _extensionsLoadBufferAsync;
  88451. /**
  88452. * Helper method called by a loader extension to load an glTF extension.
  88453. * @param context The context when loading the asset
  88454. * @param property The glTF property to load the extension from
  88455. * @param extensionName The name of the extension to load
  88456. * @param actionAsync The action to run
  88457. * @returns The promise returned by actionAsync or null if the extension does not exist
  88458. */
  88459. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88460. /**
  88461. * Helper method called by a loader extension to load a glTF extra.
  88462. * @param context The context when loading the asset
  88463. * @param property The glTF property to load the extra from
  88464. * @param extensionName The name of the extension to load
  88465. * @param actionAsync The action to run
  88466. * @returns The promise returned by actionAsync or null if the extra does not exist
  88467. */
  88468. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88469. /**
  88470. * Checks for presence of an extension.
  88471. * @param name The name of the extension to check
  88472. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88473. */
  88474. isExtensionUsed(name: string): boolean;
  88475. /**
  88476. * Increments the indentation level and logs a message.
  88477. * @param message The message to log
  88478. */
  88479. logOpen(message: string): void;
  88480. /**
  88481. * Decrements the indentation level.
  88482. */
  88483. logClose(): void;
  88484. /**
  88485. * Logs a message
  88486. * @param message The message to log
  88487. */
  88488. log(message: string): void;
  88489. /**
  88490. * Starts a performance counter.
  88491. * @param counterName The name of the performance counter
  88492. */
  88493. startPerformanceCounter(counterName: string): void;
  88494. /**
  88495. * Ends a performance counter.
  88496. * @param counterName The name of the performance counter
  88497. */
  88498. endPerformanceCounter(counterName: string): void;
  88499. }
  88500. }
  88501. declare module BABYLON.GLTF2.Loader.Extensions {
  88502. /** @hidden */
  88503. interface IEXTLightsImageBased_LightImageBased {
  88504. _babylonTexture?: BaseTexture;
  88505. _loaded?: Promise<void>;
  88506. }
  88507. /**
  88508. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88509. */
  88510. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88511. /**
  88512. * The name of this extension.
  88513. */
  88514. readonly name: string;
  88515. /**
  88516. * Defines whether this extension is enabled.
  88517. */
  88518. enabled: boolean;
  88519. private _loader;
  88520. private _lights?;
  88521. /** @hidden */
  88522. constructor(loader: GLTFLoader);
  88523. /** @hidden */
  88524. dispose(): void;
  88525. /** @hidden */
  88526. onLoading(): void;
  88527. /** @hidden */
  88528. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88529. private _loadLightAsync;
  88530. }
  88531. }
  88532. declare module BABYLON.GLTF2.Loader.Extensions {
  88533. /**
  88534. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88535. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88536. * !!! Experimental Extension Subject to Changes !!!
  88537. */
  88538. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88539. /**
  88540. * The name of this extension.
  88541. */
  88542. readonly name: string;
  88543. /**
  88544. * Defines whether this extension is enabled.
  88545. */
  88546. enabled: boolean;
  88547. private _loader;
  88548. /** @hidden */
  88549. constructor(loader: GLTFLoader);
  88550. /** @hidden */
  88551. dispose(): void;
  88552. /** @hidden */
  88553. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88554. }
  88555. }
  88556. declare module BABYLON.GLTF2.Loader.Extensions {
  88557. /**
  88558. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88559. *
  88560. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88561. */
  88562. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88563. /**
  88564. * The name of this extension.
  88565. */
  88566. readonly name: string;
  88567. /**
  88568. * Defines whether this extension is enabled.
  88569. */
  88570. enabled: boolean;
  88571. /**
  88572. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88573. */
  88574. static DecoderPath: string;
  88575. private _loader;
  88576. private _decoderPromise?;
  88577. /** @hidden */
  88578. constructor(loader: GLTFLoader);
  88579. /** @hidden */
  88580. dispose(): void;
  88581. /** @hidden */
  88582. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88583. }
  88584. }
  88585. declare module BABYLON.GLTF2.Loader.Extensions {
  88586. /**
  88587. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88588. */
  88589. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88590. /** The name of this extension. */
  88591. readonly name: string;
  88592. /** Defines whether this extension is enabled. */
  88593. enabled: boolean;
  88594. private _loader;
  88595. /** @hidden */
  88596. constructor(loader: GLTFLoader);
  88597. /** @hidden */
  88598. dispose(): void;
  88599. /** @hidden */
  88600. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88601. }
  88602. }
  88603. declare module BABYLON.GLTF2.Loader.Extensions {
  88604. /**
  88605. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88606. */
  88607. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88608. /**
  88609. * The name of this extension.
  88610. */
  88611. readonly name: string;
  88612. /**
  88613. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88614. */
  88615. dracoCompression?: DracoCompression;
  88616. /**
  88617. * Defines whether this extension is enabled.
  88618. */
  88619. enabled: boolean;
  88620. private _loader;
  88621. /** @hidden */
  88622. constructor(loader: GLTFLoader);
  88623. /** @hidden */
  88624. dispose(): void;
  88625. /** @hidden */
  88626. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88627. }
  88628. }
  88629. declare module BABYLON.GLTF2.Loader.Extensions {
  88630. /**
  88631. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88632. */
  88633. export class KHR_lights implements IGLTFLoaderExtension {
  88634. /**
  88635. * The name of this extension.
  88636. */
  88637. readonly name: string;
  88638. /**
  88639. * Defines whether this extension is enabled.
  88640. */
  88641. enabled: boolean;
  88642. private _loader;
  88643. private _lights?;
  88644. /** @hidden */
  88645. constructor(loader: GLTFLoader);
  88646. /** @hidden */
  88647. dispose(): void;
  88648. /** @hidden */
  88649. onLoading(): void;
  88650. /** @hidden */
  88651. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88652. }
  88653. }
  88654. declare module BABYLON.GLTF2.Loader.Extensions {
  88655. /**
  88656. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88657. */
  88658. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88659. /**
  88660. * The name of this extension.
  88661. */
  88662. readonly name: string;
  88663. /**
  88664. * Defines whether this extension is enabled.
  88665. */
  88666. enabled: boolean;
  88667. /**
  88668. * Defines a number that determines the order the extensions are applied.
  88669. */
  88670. order: number;
  88671. private _loader;
  88672. /** @hidden */
  88673. constructor(loader: GLTFLoader);
  88674. /** @hidden */
  88675. dispose(): void;
  88676. /** @hidden */
  88677. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88678. private _loadSpecularGlossinessPropertiesAsync;
  88679. }
  88680. }
  88681. declare module BABYLON.GLTF2.Loader.Extensions {
  88682. /**
  88683. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88684. */
  88685. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88686. /**
  88687. * The name of this extension.
  88688. */
  88689. readonly name: string;
  88690. /**
  88691. * Defines whether this extension is enabled.
  88692. */
  88693. enabled: boolean;
  88694. /**
  88695. * Defines a number that determines the order the extensions are applied.
  88696. */
  88697. order: number;
  88698. private _loader;
  88699. /** @hidden */
  88700. constructor(loader: GLTFLoader);
  88701. /** @hidden */
  88702. dispose(): void;
  88703. /** @hidden */
  88704. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88705. private _loadUnlitPropertiesAsync;
  88706. }
  88707. }
  88708. declare module BABYLON.GLTF2.Loader.Extensions {
  88709. /**
  88710. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88711. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88712. */
  88713. export class KHR_materials_clearcoat 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. /**
  88723. * Defines a number that determines the order the extensions are applied.
  88724. */
  88725. order: number;
  88726. private _loader;
  88727. /** @hidden */
  88728. constructor(loader: GLTFLoader);
  88729. /** @hidden */
  88730. dispose(): void;
  88731. /** @hidden */
  88732. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88733. private _loadClearCoatPropertiesAsync;
  88734. }
  88735. }
  88736. declare module BABYLON.GLTF2.Loader.Extensions {
  88737. /**
  88738. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88739. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88740. * !!! Experimental Extension Subject to Changes !!!
  88741. */
  88742. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88743. /**
  88744. * The name of this extension.
  88745. */
  88746. readonly name: string;
  88747. /**
  88748. * Defines whether this extension is enabled.
  88749. */
  88750. enabled: boolean;
  88751. /**
  88752. * Defines a number that determines the order the extensions are applied.
  88753. */
  88754. order: number;
  88755. private _loader;
  88756. /** @hidden */
  88757. constructor(loader: GLTFLoader);
  88758. /** @hidden */
  88759. dispose(): void;
  88760. /** @hidden */
  88761. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88762. private _loadSheenPropertiesAsync;
  88763. }
  88764. }
  88765. declare module BABYLON.GLTF2.Loader.Extensions {
  88766. /**
  88767. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88768. * !!! Experimental Extension Subject to Changes !!!
  88769. */
  88770. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88771. /**
  88772. * The name of this extension.
  88773. */
  88774. readonly name: string;
  88775. /**
  88776. * Defines whether this extension is enabled.
  88777. */
  88778. enabled: boolean;
  88779. /**
  88780. * Defines a number that determines the order the extensions are applied.
  88781. */
  88782. order: number;
  88783. private _loader;
  88784. /** @hidden */
  88785. constructor(loader: GLTFLoader);
  88786. /** @hidden */
  88787. dispose(): void;
  88788. /** @hidden */
  88789. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88790. private _loadSpecularPropertiesAsync;
  88791. }
  88792. }
  88793. declare module BABYLON.GLTF2.Loader.Extensions {
  88794. /**
  88795. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88796. * !!! Experimental Extension Subject to Changes !!!
  88797. */
  88798. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88799. /**
  88800. * Default ior Value from the spec.
  88801. */
  88802. private static readonly _DEFAULT_IOR;
  88803. /**
  88804. * The name of this extension.
  88805. */
  88806. readonly name: string;
  88807. /**
  88808. * Defines whether this extension is enabled.
  88809. */
  88810. enabled: boolean;
  88811. /**
  88812. * Defines a number that determines the order the extensions are applied.
  88813. */
  88814. order: number;
  88815. private _loader;
  88816. /** @hidden */
  88817. constructor(loader: GLTFLoader);
  88818. /** @hidden */
  88819. dispose(): void;
  88820. /** @hidden */
  88821. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88822. private _loadIorPropertiesAsync;
  88823. }
  88824. }
  88825. declare module BABYLON.GLTF2.Loader.Extensions {
  88826. /**
  88827. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88828. */
  88829. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88830. /**
  88831. * The name of this extension.
  88832. */
  88833. readonly name: string;
  88834. /**
  88835. * Defines whether this extension is enabled.
  88836. */
  88837. enabled: boolean;
  88838. private _loader;
  88839. private _variants?;
  88840. /** @hidden */
  88841. constructor(loader: GLTFLoader);
  88842. /** @hidden */
  88843. dispose(): void;
  88844. /**
  88845. * Gets the list of available variant names for this asset.
  88846. * @param rootMesh The glTF root mesh
  88847. * @returns the list of all the variant names for this model
  88848. */
  88849. static GetAvailableVariants(rootMesh: Mesh): string[];
  88850. /**
  88851. * Gets the list of available variant names for this asset.
  88852. * @param rootMesh The glTF root mesh
  88853. * @returns the list of all the variant names for this model
  88854. */
  88855. getAvailableVariants(rootMesh: Mesh): string[];
  88856. /**
  88857. * Select a variant given a variant name or a list of variant names.
  88858. * @param rootMesh The glTF root mesh
  88859. * @param variantName The variant name(s) to select.
  88860. */
  88861. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88862. /**
  88863. * Select a variant given a variant name or a list of variant names.
  88864. * @param rootMesh The glTF root mesh
  88865. * @param variantName The variant name(s) to select.
  88866. */
  88867. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88868. /**
  88869. * Reset back to the original before selecting a variant.
  88870. * @param rootMesh The glTF root mesh
  88871. */
  88872. static Reset(rootMesh: Mesh): void;
  88873. /**
  88874. * Reset back to the original before selecting a variant.
  88875. * @param rootMesh The glTF root mesh
  88876. */
  88877. reset(rootMesh: Mesh): void;
  88878. /**
  88879. * Gets the last selected variant name(s) or null if original.
  88880. * @param rootMesh The glTF root mesh
  88881. * @returns The selected variant name(s).
  88882. */
  88883. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88884. /**
  88885. * Gets the last selected variant name(s) or null if original.
  88886. * @param rootMesh The glTF root mesh
  88887. * @returns The selected variant name(s).
  88888. */
  88889. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88890. private static _GetExtensionMetadata;
  88891. /** @hidden */
  88892. onLoading(): void;
  88893. /** @hidden */
  88894. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88895. }
  88896. }
  88897. declare module BABYLON.GLTF2.Loader.Extensions {
  88898. /**
  88899. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88900. */
  88901. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88902. /**
  88903. * The name of this extension.
  88904. */
  88905. readonly name: string;
  88906. /**
  88907. * Defines whether this extension is enabled.
  88908. */
  88909. enabled: boolean;
  88910. /**
  88911. * Defines a number that determines the order the extensions are applied.
  88912. */
  88913. order: number;
  88914. private _loader;
  88915. /** @hidden */
  88916. constructor(loader: GLTFLoader);
  88917. /** @hidden */
  88918. dispose(): void;
  88919. /** @hidden */
  88920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88921. private _loadTransparentPropertiesAsync;
  88922. }
  88923. }
  88924. declare module BABYLON.GLTF2.Loader.Extensions {
  88925. /**
  88926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88927. * !!! Experimental Extension Subject to Changes !!!
  88928. */
  88929. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88930. /**
  88931. * The name of this extension.
  88932. */
  88933. readonly name: string;
  88934. /**
  88935. * Defines whether this extension is enabled.
  88936. */
  88937. enabled: boolean;
  88938. /**
  88939. * Defines a number that determines the order the extensions are applied.
  88940. */
  88941. order: number;
  88942. private _loader;
  88943. /** @hidden */
  88944. constructor(loader: GLTFLoader);
  88945. /** @hidden */
  88946. dispose(): void;
  88947. /** @hidden */
  88948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88949. private _loadTranslucentPropertiesAsync;
  88950. }
  88951. }
  88952. declare module BABYLON.GLTF2.Loader.Extensions {
  88953. /**
  88954. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88955. */
  88956. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88957. /**
  88958. * The name of this extension.
  88959. */
  88960. readonly name: string;
  88961. /**
  88962. * Defines whether this extension is enabled.
  88963. */
  88964. enabled: boolean;
  88965. /** @hidden */
  88966. constructor(loader: GLTFLoader);
  88967. /** @hidden */
  88968. dispose(): void;
  88969. }
  88970. }
  88971. declare module BABYLON.GLTF2.Loader.Extensions {
  88972. /**
  88973. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88974. * !!! Experimental Extension Subject to Changes !!!
  88975. */
  88976. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88977. /** The name of this extension. */
  88978. readonly name: string;
  88979. /** Defines whether this extension is enabled. */
  88980. enabled: boolean;
  88981. private _loader;
  88982. /** @hidden */
  88983. constructor(loader: GLTFLoader);
  88984. /** @hidden */
  88985. dispose(): void;
  88986. /** @hidden */
  88987. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88988. }
  88989. }
  88990. declare module BABYLON.GLTF2.Loader.Extensions {
  88991. /**
  88992. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88993. */
  88994. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88995. /**
  88996. * The name of this extension.
  88997. */
  88998. readonly name: string;
  88999. /**
  89000. * Defines whether this extension is enabled.
  89001. */
  89002. enabled: boolean;
  89003. private _loader;
  89004. /** @hidden */
  89005. constructor(loader: GLTFLoader);
  89006. /** @hidden */
  89007. dispose(): void;
  89008. /** @hidden */
  89009. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89010. }
  89011. }
  89012. declare module BABYLON.GLTF2.Loader.Extensions {
  89013. /**
  89014. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89015. * !!! Experimental Extension Subject to Changes !!!
  89016. */
  89017. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89018. /**
  89019. * The name of this extension.
  89020. */
  89021. readonly name: string;
  89022. /**
  89023. * Defines whether this extension is enabled.
  89024. */
  89025. enabled: boolean;
  89026. /**
  89027. * Defines a number that determines the order the extensions are applied.
  89028. */
  89029. order: number;
  89030. private _loader;
  89031. /** @hidden */
  89032. constructor(loader: GLTFLoader);
  89033. /** @hidden */
  89034. dispose(): void;
  89035. /**
  89036. * Called after the loader state changes to LOADING.
  89037. */
  89038. onLoading(): void;
  89039. }
  89040. }
  89041. declare module BABYLON.GLTF2.Loader.Extensions {
  89042. /**
  89043. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89044. */
  89045. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89046. /**
  89047. * The name of this extension.
  89048. */
  89049. readonly name: string;
  89050. /**
  89051. * Defines whether this extension is enabled.
  89052. */
  89053. enabled: boolean;
  89054. private _loader;
  89055. private _clips;
  89056. private _emitters;
  89057. /** @hidden */
  89058. constructor(loader: GLTFLoader);
  89059. /** @hidden */
  89060. dispose(): void;
  89061. /** @hidden */
  89062. onLoading(): void;
  89063. /** @hidden */
  89064. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89065. /** @hidden */
  89066. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89067. /** @hidden */
  89068. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89069. private _loadClipAsync;
  89070. private _loadEmitterAsync;
  89071. private _getEventAction;
  89072. private _loadAnimationEventAsync;
  89073. }
  89074. }
  89075. declare module BABYLON.GLTF2.Loader.Extensions {
  89076. /**
  89077. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89078. */
  89079. export class MSFT_lod implements IGLTFLoaderExtension {
  89080. /**
  89081. * The name of this extension.
  89082. */
  89083. readonly name: string;
  89084. /**
  89085. * Defines whether this extension is enabled.
  89086. */
  89087. enabled: boolean;
  89088. /**
  89089. * Defines a number that determines the order the extensions are applied.
  89090. */
  89091. order: number;
  89092. /**
  89093. * Maximum number of LODs to load, starting from the lowest LOD.
  89094. */
  89095. maxLODsToLoad: number;
  89096. /**
  89097. * Observable raised when all node LODs of one level are loaded.
  89098. * The event data is the index of the loaded LOD starting from zero.
  89099. * Dispose the loader to cancel the loading of the next level of LODs.
  89100. */
  89101. onNodeLODsLoadedObservable: Observable<number>;
  89102. /**
  89103. * Observable raised when all material LODs of one level are loaded.
  89104. * The event data is the index of the loaded LOD starting from zero.
  89105. * Dispose the loader to cancel the loading of the next level of LODs.
  89106. */
  89107. onMaterialLODsLoadedObservable: Observable<number>;
  89108. private _loader;
  89109. private _bufferLODs;
  89110. private _nodeIndexLOD;
  89111. private _nodeSignalLODs;
  89112. private _nodePromiseLODs;
  89113. private _nodeBufferLODs;
  89114. private _materialIndexLOD;
  89115. private _materialSignalLODs;
  89116. private _materialPromiseLODs;
  89117. private _materialBufferLODs;
  89118. /** @hidden */
  89119. constructor(loader: GLTFLoader);
  89120. /** @hidden */
  89121. dispose(): void;
  89122. /** @hidden */
  89123. onReady(): void;
  89124. /** @hidden */
  89125. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89126. /** @hidden */
  89127. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89128. /** @hidden */
  89129. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89130. /** @hidden */
  89131. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89132. /** @hidden */
  89133. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89134. private _loadBufferLOD;
  89135. /**
  89136. * Gets an array of LOD properties from lowest to highest.
  89137. */
  89138. private _getLODs;
  89139. private _disposeTransformNode;
  89140. private _disposeMaterials;
  89141. }
  89142. }
  89143. declare module BABYLON.GLTF2.Loader.Extensions {
  89144. /** @hidden */
  89145. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89146. readonly name: string;
  89147. enabled: boolean;
  89148. private _loader;
  89149. constructor(loader: GLTFLoader);
  89150. dispose(): void;
  89151. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89152. }
  89153. }
  89154. declare module BABYLON.GLTF2.Loader.Extensions {
  89155. /** @hidden */
  89156. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89157. readonly name: string;
  89158. enabled: boolean;
  89159. private _loader;
  89160. constructor(loader: GLTFLoader);
  89161. dispose(): void;
  89162. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89163. }
  89164. }
  89165. declare module BABYLON.GLTF2.Loader.Extensions {
  89166. /**
  89167. * Store glTF extras (if present) in BJS objects' metadata
  89168. */
  89169. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89170. /**
  89171. * The name of this extension.
  89172. */
  89173. readonly name: string;
  89174. /**
  89175. * Defines whether this extension is enabled.
  89176. */
  89177. enabled: boolean;
  89178. private _loader;
  89179. private _assignExtras;
  89180. /** @hidden */
  89181. constructor(loader: GLTFLoader);
  89182. /** @hidden */
  89183. dispose(): void;
  89184. /** @hidden */
  89185. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89186. /** @hidden */
  89187. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89188. /** @hidden */
  89189. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89190. }
  89191. }
  89192. declare module BABYLON {
  89193. /**
  89194. * Class reading and parsing the MTL file bundled with the obj file.
  89195. */
  89196. export class MTLFileLoader {
  89197. /**
  89198. * Invert Y-Axis of referenced textures on load
  89199. */
  89200. static INVERT_TEXTURE_Y: boolean;
  89201. /**
  89202. * All material loaded from the mtl will be set here
  89203. */
  89204. materials: StandardMaterial[];
  89205. /**
  89206. * This function will read the mtl file and create each material described inside
  89207. * This function could be improve by adding :
  89208. * -some component missing (Ni, Tf...)
  89209. * -including the specific options available
  89210. *
  89211. * @param scene defines the scene the material will be created in
  89212. * @param data defines the mtl data to parse
  89213. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89214. * @param forAssetContainer defines if the material should be registered in the scene
  89215. */
  89216. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89217. /**
  89218. * Gets the texture for the material.
  89219. *
  89220. * If the material is imported from input file,
  89221. * We sanitize the url to ensure it takes the textre from aside the material.
  89222. *
  89223. * @param rootUrl The root url to load from
  89224. * @param value The value stored in the mtl
  89225. * @return The Texture
  89226. */
  89227. private static _getTexture;
  89228. }
  89229. }
  89230. declare module BABYLON {
  89231. /**
  89232. * Options for loading OBJ/MTL files
  89233. */
  89234. type MeshLoadOptions = {
  89235. /**
  89236. * Defines if UVs are optimized by default during load.
  89237. */
  89238. OptimizeWithUV: boolean;
  89239. /**
  89240. * Defines custom scaling of UV coordinates of loaded meshes.
  89241. */
  89242. UVScaling: Vector2;
  89243. /**
  89244. * Invert model on y-axis (does a model scaling inversion)
  89245. */
  89246. InvertY: boolean;
  89247. /**
  89248. * Invert Y-Axis of referenced textures on load
  89249. */
  89250. InvertTextureY: boolean;
  89251. /**
  89252. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89253. */
  89254. ImportVertexColors: boolean;
  89255. /**
  89256. * Compute the normals for the model, even if normals are present in the file.
  89257. */
  89258. ComputeNormals: boolean;
  89259. /**
  89260. * 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.
  89261. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89262. */
  89263. OptimizeNormals: boolean;
  89264. /**
  89265. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89266. */
  89267. SkipMaterials: boolean;
  89268. /**
  89269. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89270. */
  89271. MaterialLoadingFailsSilently: boolean;
  89272. };
  89273. /**
  89274. * OBJ file type loader.
  89275. * This is a babylon scene loader plugin.
  89276. */
  89277. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89278. /**
  89279. * Defines if UVs are optimized by default during load.
  89280. */
  89281. static OPTIMIZE_WITH_UV: boolean;
  89282. /**
  89283. * Invert model on y-axis (does a model scaling inversion)
  89284. */
  89285. static INVERT_Y: boolean;
  89286. /**
  89287. * Invert Y-Axis of referenced textures on load
  89288. */
  89289. static get INVERT_TEXTURE_Y(): boolean;
  89290. static set INVERT_TEXTURE_Y(value: boolean);
  89291. /**
  89292. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89293. */
  89294. static IMPORT_VERTEX_COLORS: boolean;
  89295. /**
  89296. * Compute the normals for the model, even if normals are present in the file.
  89297. */
  89298. static COMPUTE_NORMALS: boolean;
  89299. /**
  89300. * 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.
  89301. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89302. */
  89303. static OPTIMIZE_NORMALS: boolean;
  89304. /**
  89305. * Defines custom scaling of UV coordinates of loaded meshes.
  89306. */
  89307. static UV_SCALING: Vector2;
  89308. /**
  89309. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89310. */
  89311. static SKIP_MATERIALS: boolean;
  89312. /**
  89313. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89314. *
  89315. * Defaults to true for backwards compatibility.
  89316. */
  89317. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89318. /**
  89319. * Defines the name of the plugin.
  89320. */
  89321. name: string;
  89322. /**
  89323. * Defines the extension the plugin is able to load.
  89324. */
  89325. extensions: string;
  89326. /** @hidden */
  89327. obj: RegExp;
  89328. /** @hidden */
  89329. group: RegExp;
  89330. /** @hidden */
  89331. mtllib: RegExp;
  89332. /** @hidden */
  89333. usemtl: RegExp;
  89334. /** @hidden */
  89335. smooth: RegExp;
  89336. /** @hidden */
  89337. vertexPattern: RegExp;
  89338. /** @hidden */
  89339. normalPattern: RegExp;
  89340. /** @hidden */
  89341. uvPattern: RegExp;
  89342. /** @hidden */
  89343. facePattern1: RegExp;
  89344. /** @hidden */
  89345. facePattern2: RegExp;
  89346. /** @hidden */
  89347. facePattern3: RegExp;
  89348. /** @hidden */
  89349. facePattern4: RegExp;
  89350. /** @hidden */
  89351. facePattern5: RegExp;
  89352. private _forAssetContainer;
  89353. private _meshLoadOptions;
  89354. /**
  89355. * Creates loader for .OBJ files
  89356. *
  89357. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89358. */
  89359. constructor(meshLoadOptions?: MeshLoadOptions);
  89360. private static get currentMeshLoadOptions();
  89361. /**
  89362. * Calls synchronously the MTL file attached to this obj.
  89363. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89364. * Without this function materials are not displayed in the first frame (but displayed after).
  89365. * In consequence it is impossible to get material information in your HTML file
  89366. *
  89367. * @param url The URL of the MTL file
  89368. * @param rootUrl
  89369. * @param onSuccess Callback function to be called when the MTL file is loaded
  89370. * @private
  89371. */
  89372. private _loadMTL;
  89373. /**
  89374. * Instantiates a OBJ file loader plugin.
  89375. * @returns the created plugin
  89376. */
  89377. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89378. /**
  89379. * If the data string can be loaded directly.
  89380. *
  89381. * @param data string containing the file data
  89382. * @returns if the data can be loaded directly
  89383. */
  89384. canDirectLoad(data: string): boolean;
  89385. /**
  89386. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89387. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89388. * @param scene the scene the meshes should be added to
  89389. * @param data the OBJ data to load
  89390. * @param rootUrl root url to load from
  89391. * @param onProgress event that fires when loading progress has occured
  89392. * @param fileName Defines the name of the file to load
  89393. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89394. */
  89395. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89396. /**
  89397. * Imports all objects from the loaded OBJ data and adds them to the scene
  89398. * @param scene the scene the objects should be added to
  89399. * @param data the OBJ data to load
  89400. * @param rootUrl root url to load from
  89401. * @param onProgress event that fires when loading progress has occured
  89402. * @param fileName Defines the name of the file to load
  89403. * @returns a promise which completes when objects have been loaded to the scene
  89404. */
  89405. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89406. /**
  89407. * Load into an asset container.
  89408. * @param scene The scene to load into
  89409. * @param data The data to import
  89410. * @param rootUrl The root url for scene and resources
  89411. * @param onProgress The callback when the load progresses
  89412. * @param fileName Defines the name of the file to load
  89413. * @returns The loaded asset container
  89414. */
  89415. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89416. private _optimizeNormals;
  89417. /**
  89418. * Read the OBJ file and create an Array of meshes.
  89419. * Each mesh contains all information given by the OBJ and the MTL file.
  89420. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89421. *
  89422. * @param meshesNames
  89423. * @param scene Scene The scene where are displayed the data
  89424. * @param data String The content of the obj file
  89425. * @param rootUrl String The path to the folder
  89426. * @returns Array<AbstractMesh>
  89427. * @private
  89428. */
  89429. private _parseSolid;
  89430. }
  89431. }
  89432. declare module BABYLON {
  89433. /**
  89434. * STL file type loader.
  89435. * This is a babylon scene loader plugin.
  89436. */
  89437. export class STLFileLoader implements ISceneLoaderPlugin {
  89438. /** @hidden */
  89439. solidPattern: RegExp;
  89440. /** @hidden */
  89441. facetsPattern: RegExp;
  89442. /** @hidden */
  89443. normalPattern: RegExp;
  89444. /** @hidden */
  89445. vertexPattern: RegExp;
  89446. /**
  89447. * Defines the name of the plugin.
  89448. */
  89449. name: string;
  89450. /**
  89451. * Defines the extensions the stl loader is able to load.
  89452. * force data to come in as an ArrayBuffer
  89453. * we'll convert to string if it looks like it's an ASCII .stl
  89454. */
  89455. extensions: ISceneLoaderPluginExtensions;
  89456. /**
  89457. * Import meshes into a scene.
  89458. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89459. * @param scene The scene to import into
  89460. * @param data The data to import
  89461. * @param rootUrl The root url for scene and resources
  89462. * @param meshes The meshes array to import into
  89463. * @param particleSystems The particle systems array to import into
  89464. * @param skeletons The skeletons array to import into
  89465. * @param onError The callback when import fails
  89466. * @returns True if successful or false otherwise
  89467. */
  89468. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89469. /**
  89470. * Load into a scene.
  89471. * @param scene The scene to load into
  89472. * @param data The data to import
  89473. * @param rootUrl The root url for scene and resources
  89474. * @param onError The callback when import fails
  89475. * @returns true if successful or false otherwise
  89476. */
  89477. load(scene: Scene, data: any, rootUrl: string): boolean;
  89478. /**
  89479. * Load into an asset container.
  89480. * @param scene The scene to load into
  89481. * @param data The data to import
  89482. * @param rootUrl The root url for scene and resources
  89483. * @param onError The callback when import fails
  89484. * @returns The loaded asset container
  89485. */
  89486. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89487. private _isBinary;
  89488. private _parseBinary;
  89489. private _parseASCII;
  89490. }
  89491. }
  89492. declare module BABYLON {
  89493. /**
  89494. * Class for generating OBJ data from a Babylon scene.
  89495. */
  89496. export class OBJExport {
  89497. /**
  89498. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89499. * @param mesh defines the list of meshes to serialize
  89500. * @param materials defines if materials should be exported
  89501. * @param matlibname defines the name of the associated mtl file
  89502. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89503. * @returns the OBJ content
  89504. */
  89505. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89506. /**
  89507. * Exports the material(s) of a mesh in .MTL file format (text)
  89508. * @param mesh defines the mesh to extract the material from
  89509. * @returns the mtl content
  89510. */
  89511. static MTL(mesh: Mesh): string;
  89512. }
  89513. }
  89514. declare module BABYLON {
  89515. /** @hidden */
  89516. export var __IGLTFExporterExtension: number;
  89517. /**
  89518. * Interface for extending the exporter
  89519. * @hidden
  89520. */
  89521. export interface IGLTFExporterExtension {
  89522. /**
  89523. * The name of this extension
  89524. */
  89525. readonly name: string;
  89526. /**
  89527. * Defines whether this extension is enabled
  89528. */
  89529. enabled: boolean;
  89530. /**
  89531. * Defines whether this extension is required
  89532. */
  89533. required: boolean;
  89534. }
  89535. }
  89536. declare module BABYLON.GLTF2.Exporter {
  89537. /** @hidden */
  89538. export var __IGLTFExporterExtensionV2: number;
  89539. /**
  89540. * Interface for a glTF exporter extension
  89541. * @hidden
  89542. */
  89543. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89544. /**
  89545. * Define this method to modify the default behavior before exporting a texture
  89546. * @param context The context when loading the asset
  89547. * @param babylonTexture The Babylon.js texture
  89548. * @param mimeType The mime-type of the generated image
  89549. * @returns A promise that resolves with the exported texture
  89550. */
  89551. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89552. /**
  89553. * Define this method to get notified when a texture info is created
  89554. * @param context The context when loading the asset
  89555. * @param textureInfo The glTF texture info
  89556. * @param babylonTexture The Babylon.js texture
  89557. */
  89558. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89559. /**
  89560. * Define this method to modify the default behavior when exporting texture info
  89561. * @param context The context when loading the asset
  89562. * @param meshPrimitive glTF mesh primitive
  89563. * @param babylonSubMesh Babylon submesh
  89564. * @param binaryWriter glTF serializer binary writer instance
  89565. * @returns nullable IMeshPrimitive promise
  89566. */
  89567. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89568. /**
  89569. * Define this method to modify the default behavior when exporting a node
  89570. * @param context The context when exporting the node
  89571. * @param node glTF node
  89572. * @param babylonNode BabylonJS node
  89573. * @returns nullable INode promise
  89574. */
  89575. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89576. [key: number]: number;
  89577. }): Promise<Nullable<INode>>;
  89578. /**
  89579. * Define this method to modify the default behavior when exporting a material
  89580. * @param material glTF material
  89581. * @param babylonMaterial BabylonJS material
  89582. * @returns nullable IMaterial promise
  89583. */
  89584. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89585. /**
  89586. * Define this method to return additional textures to export from a material
  89587. * @param material glTF material
  89588. * @param babylonMaterial BabylonJS material
  89589. * @returns List of textures
  89590. */
  89591. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89592. /** Gets a boolean indicating that this extension was used */
  89593. wasUsed: boolean;
  89594. /** Gets a boolean indicating that this extension is required for the file to work */
  89595. required: boolean;
  89596. /**
  89597. * Called after the exporter state changes to EXPORTING
  89598. */
  89599. onExporting?(): void;
  89600. }
  89601. }
  89602. declare module BABYLON.GLTF2.Exporter {
  89603. /**
  89604. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89605. * @hidden
  89606. */
  89607. export class _GLTFMaterialExporter {
  89608. /**
  89609. * Represents the dielectric specular values for R, G and B
  89610. */
  89611. private static readonly _DielectricSpecular;
  89612. /**
  89613. * Allows the maximum specular power to be defined for material calculations
  89614. */
  89615. private static readonly _MaxSpecularPower;
  89616. /**
  89617. * Mapping to store textures
  89618. */
  89619. private _textureMap;
  89620. /**
  89621. * Numeric tolerance value
  89622. */
  89623. private static readonly _Epsilon;
  89624. /**
  89625. * Reference to the glTF Exporter
  89626. */
  89627. private _exporter;
  89628. constructor(exporter: _Exporter);
  89629. /**
  89630. * Specifies if two colors are approximately equal in value
  89631. * @param color1 first color to compare to
  89632. * @param color2 second color to compare to
  89633. * @param epsilon threshold value
  89634. */
  89635. private static FuzzyEquals;
  89636. /**
  89637. * Gets the materials from a Babylon scene and converts them to glTF materials
  89638. * @param scene babylonjs scene
  89639. * @param mimeType texture mime type
  89640. * @param images array of images
  89641. * @param textures array of textures
  89642. * @param materials array of materials
  89643. * @param imageData mapping of texture names to base64 textures
  89644. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89645. */
  89646. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89647. /**
  89648. * Makes a copy of the glTF material without the texture parameters
  89649. * @param originalMaterial original glTF material
  89650. * @returns glTF material without texture parameters
  89651. */
  89652. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89653. /**
  89654. * Specifies if the material has any texture parameters present
  89655. * @param material glTF Material
  89656. * @returns boolean specifying if texture parameters are present
  89657. */
  89658. _hasTexturesPresent(material: IMaterial): boolean;
  89659. /**
  89660. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89661. * @param babylonStandardMaterial
  89662. * @returns glTF Metallic Roughness Material representation
  89663. */
  89664. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89665. /**
  89666. * Computes the metallic factor
  89667. * @param diffuse diffused value
  89668. * @param specular specular value
  89669. * @param oneMinusSpecularStrength one minus the specular strength
  89670. * @returns metallic value
  89671. */
  89672. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89673. /**
  89674. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89675. * @param glTFMaterial glTF material
  89676. * @param babylonMaterial Babylon material
  89677. */
  89678. private static _SetAlphaMode;
  89679. /**
  89680. * Converts a Babylon Standard Material to a glTF Material
  89681. * @param babylonStandardMaterial BJS Standard Material
  89682. * @param mimeType mime type to use for the textures
  89683. * @param images array of glTF image interfaces
  89684. * @param textures array of glTF texture interfaces
  89685. * @param materials array of glTF material interfaces
  89686. * @param imageData map of image file name to data
  89687. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89688. */
  89689. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89690. private _finishMaterial;
  89691. /**
  89692. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89693. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89694. * @param mimeType mime type to use for the textures
  89695. * @param images array of glTF image interfaces
  89696. * @param textures array of glTF texture interfaces
  89697. * @param materials array of glTF material interfaces
  89698. * @param imageData map of image file name to data
  89699. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89700. */
  89701. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89702. /**
  89703. * Converts an image typed array buffer to a base64 image
  89704. * @param buffer typed array buffer
  89705. * @param width width of the image
  89706. * @param height height of the image
  89707. * @param mimeType mimetype of the image
  89708. * @returns base64 image string
  89709. */
  89710. private _createBase64FromCanvasAsync;
  89711. /**
  89712. * Generates a white texture based on the specified width and height
  89713. * @param width width of the texture in pixels
  89714. * @param height height of the texture in pixels
  89715. * @param scene babylonjs scene
  89716. * @returns white texture
  89717. */
  89718. private _createWhiteTexture;
  89719. /**
  89720. * 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
  89721. * @param texture1 first texture to resize
  89722. * @param texture2 second texture to resize
  89723. * @param scene babylonjs scene
  89724. * @returns resized textures or null
  89725. */
  89726. private _resizeTexturesToSameDimensions;
  89727. /**
  89728. * Converts an array of pixels to a Float32Array
  89729. * Throws an error if the pixel format is not supported
  89730. * @param pixels - array buffer containing pixel values
  89731. * @returns Float32 of pixels
  89732. */
  89733. private _convertPixelArrayToFloat32;
  89734. /**
  89735. * Convert Specular Glossiness Textures to Metallic Roughness
  89736. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89737. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89738. * @param diffuseTexture texture used to store diffuse information
  89739. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89740. * @param factors specular glossiness material factors
  89741. * @param mimeType the mime type to use for the texture
  89742. * @returns pbr metallic roughness interface or null
  89743. */
  89744. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89745. /**
  89746. * Converts specular glossiness material properties to metallic roughness
  89747. * @param specularGlossiness interface with specular glossiness material properties
  89748. * @returns interface with metallic roughness material properties
  89749. */
  89750. private _convertSpecularGlossinessToMetallicRoughness;
  89751. /**
  89752. * Calculates the surface reflectance, independent of lighting conditions
  89753. * @param color Color source to calculate brightness from
  89754. * @returns number representing the perceived brightness, or zero if color is undefined
  89755. */
  89756. private _getPerceivedBrightness;
  89757. /**
  89758. * Returns the maximum color component value
  89759. * @param color
  89760. * @returns maximum color component value, or zero if color is null or undefined
  89761. */
  89762. private _getMaxComponent;
  89763. /**
  89764. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89765. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89766. * @param mimeType mime type to use for the textures
  89767. * @param images array of glTF image interfaces
  89768. * @param textures array of glTF texture interfaces
  89769. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89770. * @param imageData map of image file name to data
  89771. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89772. * @returns glTF PBR Metallic Roughness factors
  89773. */
  89774. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89775. private _getGLTFTextureSampler;
  89776. private _getGLTFTextureWrapMode;
  89777. private _getGLTFTextureWrapModesSampler;
  89778. /**
  89779. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89780. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89781. * @param mimeType mime type to use for the textures
  89782. * @param images array of glTF image interfaces
  89783. * @param textures array of glTF texture interfaces
  89784. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89785. * @param imageData map of image file name to data
  89786. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89787. * @returns glTF PBR Metallic Roughness factors
  89788. */
  89789. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89790. /**
  89791. * Converts a Babylon PBR Base Material to a glTF Material
  89792. * @param babylonPBRMaterial BJS PBR Base Material
  89793. * @param mimeType mime type to use for the textures
  89794. * @param images array of glTF image interfaces
  89795. * @param textures array of glTF texture interfaces
  89796. * @param materials array of glTF material interfaces
  89797. * @param imageData map of image file name to data
  89798. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89799. */
  89800. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89801. private setMetallicRoughnessPbrMaterial;
  89802. private getPixelsFromTexture;
  89803. /**
  89804. * Extracts a texture from a Babylon texture into file data and glTF data
  89805. * @param babylonTexture Babylon texture to extract
  89806. * @param mimeType Mime Type of the babylonTexture
  89807. * @return glTF texture info, or null if the texture format is not supported
  89808. */
  89809. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89810. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89811. /**
  89812. * Builds a texture from base64 string
  89813. * @param base64Texture base64 texture string
  89814. * @param baseTextureName Name to use for the texture
  89815. * @param mimeType image mime type for the texture
  89816. * @param images array of images
  89817. * @param textures array of textures
  89818. * @param imageData map of image data
  89819. * @returns glTF texture info, or null if the texture format is not supported
  89820. */
  89821. private _getTextureInfoFromBase64;
  89822. }
  89823. }
  89824. declare module BABYLON {
  89825. /**
  89826. * Class for holding and downloading glTF file data
  89827. */
  89828. export class GLTFData {
  89829. /**
  89830. * Object which contains the file name as the key and its data as the value
  89831. */
  89832. glTFFiles: {
  89833. [fileName: string]: string | Blob;
  89834. };
  89835. /**
  89836. * Initializes the glTF file object
  89837. */
  89838. constructor();
  89839. /**
  89840. * Downloads the glTF data as files based on their names and data
  89841. */
  89842. downloadFiles(): void;
  89843. }
  89844. }
  89845. declare module BABYLON {
  89846. /**
  89847. * Holds a collection of exporter options and parameters
  89848. */
  89849. export interface IExportOptions {
  89850. /**
  89851. * Function which indicates whether a babylon node should be exported or not
  89852. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89853. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89854. */
  89855. shouldExportNode?(node: Node): boolean;
  89856. /**
  89857. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89858. * @param metadata source metadata to read from
  89859. * @returns the data to store to glTF node extras
  89860. */
  89861. metadataSelector?(metadata: any): any;
  89862. /**
  89863. * The sample rate to bake animation curves
  89864. */
  89865. animationSampleRate?: number;
  89866. /**
  89867. * Begin serialization without waiting for the scene to be ready
  89868. */
  89869. exportWithoutWaitingForScene?: boolean;
  89870. /**
  89871. * Indicates if coordinate system swapping root nodes should be included in export
  89872. */
  89873. includeCoordinateSystemConversionNodes?: boolean;
  89874. }
  89875. /**
  89876. * Class for generating glTF data from a Babylon scene.
  89877. */
  89878. export class GLTF2Export {
  89879. /**
  89880. * Exports the geometry of the scene to .gltf file format asynchronously
  89881. * @param scene Babylon scene with scene hierarchy information
  89882. * @param filePrefix File prefix to use when generating the glTF file
  89883. * @param options Exporter options
  89884. * @returns Returns an object with a .gltf file and associates texture names
  89885. * as keys and their data and paths as values
  89886. */
  89887. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89888. private static _PreExportAsync;
  89889. private static _PostExportAsync;
  89890. /**
  89891. * Exports the geometry of the scene to .glb file format asychronously
  89892. * @param scene Babylon scene with scene hierarchy information
  89893. * @param filePrefix File prefix to use when generating glb file
  89894. * @param options Exporter options
  89895. * @returns Returns an object with a .glb filename as key and data as value
  89896. */
  89897. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89898. }
  89899. }
  89900. declare module BABYLON.GLTF2.Exporter {
  89901. /**
  89902. * @hidden
  89903. */
  89904. export class _GLTFUtilities {
  89905. /**
  89906. * Creates a buffer view based on the supplied arguments
  89907. * @param bufferIndex index value of the specified buffer
  89908. * @param byteOffset byte offset value
  89909. * @param byteLength byte length of the bufferView
  89910. * @param byteStride byte distance between conequential elements
  89911. * @param name name of the buffer view
  89912. * @returns bufferView for glTF
  89913. */
  89914. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89915. /**
  89916. * Creates an accessor based on the supplied arguments
  89917. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89918. * @param name The name of the accessor
  89919. * @param type The type of the accessor
  89920. * @param componentType The datatype of components in the attribute
  89921. * @param count The number of attributes referenced by this accessor
  89922. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89923. * @param min Minimum value of each component in this attribute
  89924. * @param max Maximum value of each component in this attribute
  89925. * @returns accessor for glTF
  89926. */
  89927. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89928. /**
  89929. * Calculates the minimum and maximum values of an array of position floats
  89930. * @param positions Positions array of a mesh
  89931. * @param vertexStart Starting vertex offset to calculate min and max values
  89932. * @param vertexCount Number of vertices to check for min and max values
  89933. * @returns min number array and max number array
  89934. */
  89935. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89936. min: number[];
  89937. max: number[];
  89938. };
  89939. /**
  89940. * Converts a new right-handed Vector3
  89941. * @param vector vector3 array
  89942. * @returns right-handed Vector3
  89943. */
  89944. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89945. /**
  89946. * Converts a Vector3 to right-handed
  89947. * @param vector Vector3 to convert to right-handed
  89948. */
  89949. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89950. /**
  89951. * Converts a three element number array to right-handed
  89952. * @param vector number array to convert to right-handed
  89953. */
  89954. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89955. /**
  89956. * Converts a new right-handed Vector3
  89957. * @param vector vector3 array
  89958. * @returns right-handed Vector3
  89959. */
  89960. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89961. /**
  89962. * Converts a Vector3 to right-handed
  89963. * @param vector Vector3 to convert to right-handed
  89964. */
  89965. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89966. /**
  89967. * Converts a three element number array to right-handed
  89968. * @param vector number array to convert to right-handed
  89969. */
  89970. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89971. /**
  89972. * Converts a Vector4 to right-handed
  89973. * @param vector Vector4 to convert to right-handed
  89974. */
  89975. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89976. /**
  89977. * Converts a Vector4 to right-handed
  89978. * @param vector Vector4 to convert to right-handed
  89979. */
  89980. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89981. /**
  89982. * Converts a Quaternion to right-handed
  89983. * @param quaternion Source quaternion to convert to right-handed
  89984. */
  89985. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89986. /**
  89987. * Converts a Quaternion to right-handed
  89988. * @param quaternion Source quaternion to convert to right-handed
  89989. */
  89990. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89991. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89992. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89993. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89994. }
  89995. }
  89996. declare module BABYLON.GLTF2.Exporter {
  89997. /**
  89998. * Converts Babylon Scene into glTF 2.0.
  89999. * @hidden
  90000. */
  90001. export class _Exporter {
  90002. /**
  90003. * Stores the glTF to export
  90004. */
  90005. _glTF: IGLTF;
  90006. /**
  90007. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90008. */
  90009. _bufferViews: IBufferView[];
  90010. /**
  90011. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90012. */
  90013. _accessors: IAccessor[];
  90014. /**
  90015. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90016. */
  90017. _nodes: INode[];
  90018. /**
  90019. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90020. */
  90021. private _scenes;
  90022. /**
  90023. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90024. */
  90025. private _meshes;
  90026. /**
  90027. * Stores all the generated material information, which represents the appearance of each primitive
  90028. */
  90029. _materials: IMaterial[];
  90030. _materialMap: {
  90031. [materialID: number]: number;
  90032. };
  90033. /**
  90034. * Stores all the generated texture information, which is referenced by glTF materials
  90035. */
  90036. _textures: ITexture[];
  90037. /**
  90038. * Stores all the generated image information, which is referenced by glTF textures
  90039. */
  90040. _images: IImage[];
  90041. /**
  90042. * Stores all the texture samplers
  90043. */
  90044. _samplers: ISampler[];
  90045. /**
  90046. * Stores all the generated glTF skins
  90047. */
  90048. _skins: ISkin[];
  90049. /**
  90050. * Stores all the generated animation samplers, which is referenced by glTF animations
  90051. */
  90052. /**
  90053. * Stores the animations for glTF models
  90054. */
  90055. private _animations;
  90056. /**
  90057. * Stores the total amount of bytes stored in the glTF buffer
  90058. */
  90059. private _totalByteLength;
  90060. /**
  90061. * Stores a reference to the Babylon scene containing the source geometry and material information
  90062. */
  90063. _babylonScene: Scene;
  90064. /**
  90065. * Stores a map of the image data, where the key is the file name and the value
  90066. * is the image data
  90067. */
  90068. _imageData: {
  90069. [fileName: string]: {
  90070. data: Uint8Array;
  90071. mimeType: ImageMimeType;
  90072. };
  90073. };
  90074. protected _orderedImageData: Array<{
  90075. data: Uint8Array;
  90076. mimeType: ImageMimeType;
  90077. }>;
  90078. /**
  90079. * Stores a map of the unique id of a node to its index in the node array
  90080. */
  90081. _nodeMap: {
  90082. [key: number]: number;
  90083. };
  90084. /**
  90085. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90086. */
  90087. _convertToRightHandedSystem: boolean;
  90088. /**
  90089. * Specifies if a Babylon node should be converted to right-handed on export
  90090. */
  90091. _convertToRightHandedSystemMap: {
  90092. [nodeId: number]: boolean;
  90093. };
  90094. _includeCoordinateSystemConversionNodes: boolean;
  90095. /**
  90096. * Baked animation sample rate
  90097. */
  90098. private _animationSampleRate;
  90099. private _options;
  90100. private _localEngine;
  90101. _glTFMaterialExporter: _GLTFMaterialExporter;
  90102. private _extensions;
  90103. private static _ExtensionNames;
  90104. private static _ExtensionFactories;
  90105. private _applyExtension;
  90106. private _applyExtensions;
  90107. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90108. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90109. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90110. [key: number]: number;
  90111. }): Promise<Nullable<INode>>;
  90112. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90113. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90114. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90115. private _forEachExtensions;
  90116. private _extensionsOnExporting;
  90117. /**
  90118. * Load glTF serializer extensions
  90119. */
  90120. private _loadExtensions;
  90121. /**
  90122. * Creates a glTF Exporter instance, which can accept optional exporter options
  90123. * @param babylonScene Babylon scene object
  90124. * @param options Options to modify the behavior of the exporter
  90125. */
  90126. constructor(babylonScene: Scene, options?: IExportOptions);
  90127. dispose(): void;
  90128. /**
  90129. * Registers a glTF exporter extension
  90130. * @param name Name of the extension to export
  90131. * @param factory The factory function that creates the exporter extension
  90132. */
  90133. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90134. /**
  90135. * Un-registers an exporter extension
  90136. * @param name The name fo the exporter extension
  90137. * @returns A boolean indicating whether the extension has been un-registered
  90138. */
  90139. static UnregisterExtension(name: string): boolean;
  90140. private reorderIndicesBasedOnPrimitiveMode;
  90141. /**
  90142. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90143. * clock-wise during export to glTF
  90144. * @param submesh BabylonJS submesh
  90145. * @param primitiveMode Primitive mode of the mesh
  90146. * @param sideOrientation the winding order of the submesh
  90147. * @param vertexBufferKind The type of vertex attribute
  90148. * @param meshAttributeArray The vertex attribute data
  90149. * @param byteOffset The offset to the binary data
  90150. * @param binaryWriter The binary data for the glTF file
  90151. * @param convertToRightHandedSystem Converts the values to right-handed
  90152. */
  90153. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90154. /**
  90155. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90156. * clock-wise during export to glTF
  90157. * @param submesh BabylonJS submesh
  90158. * @param primitiveMode Primitive mode of the mesh
  90159. * @param sideOrientation the winding order of the submesh
  90160. * @param vertexBufferKind The type of vertex attribute
  90161. * @param meshAttributeArray The vertex attribute data
  90162. * @param byteOffset The offset to the binary data
  90163. * @param binaryWriter The binary data for the glTF file
  90164. * @param convertToRightHandedSystem Converts the values to right-handed
  90165. */
  90166. private reorderTriangleFillMode;
  90167. /**
  90168. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90169. * clock-wise during export to glTF
  90170. * @param submesh BabylonJS submesh
  90171. * @param primitiveMode Primitive mode of the mesh
  90172. * @param sideOrientation the winding order of the submesh
  90173. * @param vertexBufferKind The type of vertex attribute
  90174. * @param meshAttributeArray The vertex attribute data
  90175. * @param byteOffset The offset to the binary data
  90176. * @param binaryWriter The binary data for the glTF file
  90177. * @param convertToRightHandedSystem Converts the values to right-handed
  90178. */
  90179. private reorderTriangleStripDrawMode;
  90180. /**
  90181. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90182. * clock-wise during export to glTF
  90183. * @param submesh BabylonJS submesh
  90184. * @param primitiveMode Primitive mode of the mesh
  90185. * @param sideOrientation the winding order of the submesh
  90186. * @param vertexBufferKind The type of vertex attribute
  90187. * @param meshAttributeArray The vertex attribute data
  90188. * @param byteOffset The offset to the binary data
  90189. * @param binaryWriter The binary data for the glTF file
  90190. * @param convertToRightHandedSystem Converts the values to right-handed
  90191. */
  90192. private reorderTriangleFanMode;
  90193. /**
  90194. * Writes the vertex attribute data to binary
  90195. * @param vertices The vertices to write to the binary writer
  90196. * @param byteOffset The offset into the binary writer to overwrite binary data
  90197. * @param vertexAttributeKind The vertex attribute type
  90198. * @param meshAttributeArray The vertex attribute data
  90199. * @param binaryWriter The writer containing the binary data
  90200. * @param convertToRightHandedSystem Converts the values to right-handed
  90201. */
  90202. private writeVertexAttributeData;
  90203. /**
  90204. * Writes mesh attribute data to a data buffer
  90205. * Returns the bytelength of the data
  90206. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90207. * @param meshAttributeArray Array containing the attribute data
  90208. * @param byteStride Specifies the space between data
  90209. * @param binaryWriter The buffer to write the binary data to
  90210. * @param convertToRightHandedSystem Converts the values to right-handed
  90211. */
  90212. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90213. /**
  90214. * Writes mesh attribute data to a data buffer
  90215. * Returns the bytelength of the data
  90216. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90217. * @param meshAttributeArray Array containing the attribute data
  90218. * @param byteStride Specifies the space between data
  90219. * @param binaryWriter The buffer to write the binary data to
  90220. * @param convertToRightHandedSystem Converts the values to right-handed
  90221. */
  90222. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90223. /**
  90224. * Generates glTF json data
  90225. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90226. * @param glTFPrefix Text to use when prefixing a glTF file
  90227. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90228. * @returns json data as string
  90229. */
  90230. private generateJSON;
  90231. /**
  90232. * Generates data for .gltf and .bin files based on the glTF prefix string
  90233. * @param glTFPrefix Text to use when prefixing a glTF file
  90234. * @param dispose Dispose the exporter
  90235. * @returns GLTFData with glTF file data
  90236. */
  90237. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90238. /**
  90239. * Creates a binary buffer for glTF
  90240. * @returns array buffer for binary data
  90241. */
  90242. private _generateBinaryAsync;
  90243. /**
  90244. * Pads the number to a multiple of 4
  90245. * @param num number to pad
  90246. * @returns padded number
  90247. */
  90248. private _getPadding;
  90249. /**
  90250. * @hidden
  90251. */
  90252. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90253. /**
  90254. * Sets the TRS for each node
  90255. * @param node glTF Node for storing the transformation data
  90256. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90257. * @param convertToRightHandedSystem Converts the values to right-handed
  90258. */
  90259. private setNodeTransformation;
  90260. private getVertexBufferFromMesh;
  90261. /**
  90262. * Creates a bufferview based on the vertices type for the Babylon mesh
  90263. * @param kind Indicates the type of vertices data
  90264. * @param componentType Indicates the numerical type used to store the data
  90265. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90266. * @param binaryWriter The buffer to write the bufferview data to
  90267. * @param convertToRightHandedSystem Converts the values to right-handed
  90268. */
  90269. private createBufferViewKind;
  90270. /**
  90271. * Creates a bufferview based on the vertices type for the Babylon mesh
  90272. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90273. * @param babylonMorphTarget the morph target to be exported
  90274. * @param binaryWriter The buffer to write the bufferview data to
  90275. * @param convertToRightHandedSystem Converts the values to right-handed
  90276. */
  90277. private setMorphTargetAttributes;
  90278. /**
  90279. * The primitive mode of the Babylon mesh
  90280. * @param babylonMesh The BabylonJS mesh
  90281. */
  90282. private getMeshPrimitiveMode;
  90283. /**
  90284. * Sets the primitive mode of the glTF mesh primitive
  90285. * @param meshPrimitive glTF mesh primitive
  90286. * @param primitiveMode The primitive mode
  90287. */
  90288. private setPrimitiveMode;
  90289. /**
  90290. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90291. * @param meshPrimitive glTF mesh primitive
  90292. * @param attributeKind vertex attribute
  90293. * @returns boolean specifying if uv coordinates are present
  90294. */
  90295. private setAttributeKind;
  90296. /**
  90297. * Sets data for the primitive attributes of each submesh
  90298. * @param mesh glTF Mesh object to store the primitive attribute information
  90299. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90300. * @param binaryWriter Buffer to write the attribute data to
  90301. * @param convertToRightHandedSystem Converts the values to right-handed
  90302. */
  90303. private setPrimitiveAttributesAsync;
  90304. /**
  90305. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90306. * @param node The node to check
  90307. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90308. */
  90309. private isBabylonCoordinateSystemConvertingNode;
  90310. /**
  90311. * Creates a glTF scene based on the array of meshes
  90312. * Returns the the total byte offset
  90313. * @param babylonScene Babylon scene to get the mesh data from
  90314. * @param binaryWriter Buffer to write binary data to
  90315. */
  90316. private createSceneAsync;
  90317. /**
  90318. * Creates a mapping of Node unique id to node index and handles animations
  90319. * @param babylonScene Babylon Scene
  90320. * @param nodes Babylon transform nodes
  90321. * @param binaryWriter Buffer to write binary data to
  90322. * @returns Node mapping of unique id to index
  90323. */
  90324. private createNodeMapAndAnimationsAsync;
  90325. /**
  90326. * Creates a glTF node from a Babylon mesh
  90327. * @param babylonMesh Source Babylon mesh
  90328. * @param binaryWriter Buffer for storing geometry data
  90329. * @param convertToRightHandedSystem Converts the values to right-handed
  90330. * @param nodeMap Node mapping of unique id to glTF node index
  90331. * @returns glTF node
  90332. */
  90333. private createNodeAsync;
  90334. /**
  90335. * Creates a glTF skin from a Babylon skeleton
  90336. * @param babylonScene Babylon Scene
  90337. * @param nodes Babylon transform nodes
  90338. * @param binaryWriter Buffer to write binary data to
  90339. * @returns Node mapping of unique id to index
  90340. */
  90341. private createSkinsAsync;
  90342. }
  90343. /**
  90344. * @hidden
  90345. *
  90346. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90347. */
  90348. export class _BinaryWriter {
  90349. /**
  90350. * Array buffer which stores all binary data
  90351. */
  90352. private _arrayBuffer;
  90353. /**
  90354. * View of the array buffer
  90355. */
  90356. private _dataView;
  90357. /**
  90358. * byte offset of data in array buffer
  90359. */
  90360. private _byteOffset;
  90361. /**
  90362. * Initialize binary writer with an initial byte length
  90363. * @param byteLength Initial byte length of the array buffer
  90364. */
  90365. constructor(byteLength: number);
  90366. /**
  90367. * Resize the array buffer to the specified byte length
  90368. * @param byteLength
  90369. */
  90370. private resizeBuffer;
  90371. /**
  90372. * Get an array buffer with the length of the byte offset
  90373. * @returns ArrayBuffer resized to the byte offset
  90374. */
  90375. getArrayBuffer(): ArrayBuffer;
  90376. /**
  90377. * Get the byte offset of the array buffer
  90378. * @returns byte offset
  90379. */
  90380. getByteOffset(): number;
  90381. /**
  90382. * Stores an UInt8 in the array buffer
  90383. * @param entry
  90384. * @param byteOffset If defined, specifies where to set the value as an offset.
  90385. */
  90386. setUInt8(entry: number, byteOffset?: number): void;
  90387. /**
  90388. * Stores an UInt16 in the array buffer
  90389. * @param entry
  90390. * @param byteOffset If defined, specifies where to set the value as an offset.
  90391. */
  90392. setUInt16(entry: number, byteOffset?: number): void;
  90393. /**
  90394. * Gets an UInt32 in the array buffer
  90395. * @param entry
  90396. * @param byteOffset If defined, specifies where to set the value as an offset.
  90397. */
  90398. getUInt32(byteOffset: number): number;
  90399. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90400. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90401. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90402. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90403. /**
  90404. * Stores a Float32 in the array buffer
  90405. * @param entry
  90406. */
  90407. setFloat32(entry: number, byteOffset?: number): void;
  90408. /**
  90409. * Stores an UInt32 in the array buffer
  90410. * @param entry
  90411. * @param byteOffset If defined, specifies where to set the value as an offset.
  90412. */
  90413. setUInt32(entry: number, byteOffset?: number): void;
  90414. }
  90415. }
  90416. declare module BABYLON.GLTF2.Exporter {
  90417. /**
  90418. * @hidden
  90419. * Interface to store animation data.
  90420. */
  90421. export interface _IAnimationData {
  90422. /**
  90423. * Keyframe data.
  90424. */
  90425. inputs: number[];
  90426. /**
  90427. * Value data.
  90428. */
  90429. outputs: number[][];
  90430. /**
  90431. * Animation interpolation data.
  90432. */
  90433. samplerInterpolation: AnimationSamplerInterpolation;
  90434. /**
  90435. * Minimum keyframe value.
  90436. */
  90437. inputsMin: number;
  90438. /**
  90439. * Maximum keyframe value.
  90440. */
  90441. inputsMax: number;
  90442. }
  90443. /**
  90444. * @hidden
  90445. */
  90446. export interface _IAnimationInfo {
  90447. /**
  90448. * The target channel for the animation
  90449. */
  90450. animationChannelTargetPath: AnimationChannelTargetPath;
  90451. /**
  90452. * The glTF accessor type for the data.
  90453. */
  90454. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90455. /**
  90456. * Specifies if quaternions should be used.
  90457. */
  90458. useQuaternion: boolean;
  90459. }
  90460. /**
  90461. * @hidden
  90462. * Utility class for generating glTF animation data from BabylonJS.
  90463. */
  90464. export class _GLTFAnimation {
  90465. /**
  90466. * @ignore
  90467. *
  90468. * Creates glTF channel animation from BabylonJS animation.
  90469. * @param babylonTransformNode - BabylonJS mesh.
  90470. * @param animation - animation.
  90471. * @param animationChannelTargetPath - The target animation channel.
  90472. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90473. * @param useQuaternion - Specifies if quaternions are used.
  90474. * @returns nullable IAnimationData
  90475. */
  90476. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90477. private static _DeduceAnimationInfo;
  90478. /**
  90479. * @ignore
  90480. * Create node animations from the transform node animations
  90481. * @param babylonNode
  90482. * @param runtimeGLTFAnimation
  90483. * @param idleGLTFAnimations
  90484. * @param nodeMap
  90485. * @param nodes
  90486. * @param binaryWriter
  90487. * @param bufferViews
  90488. * @param accessors
  90489. * @param convertToRightHandedSystem
  90490. * @param animationSampleRate
  90491. */
  90492. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90493. [key: number]: number;
  90494. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90495. /**
  90496. * @ignore
  90497. * Create individual morph animations from the mesh's morph target animation tracks
  90498. * @param babylonNode
  90499. * @param runtimeGLTFAnimation
  90500. * @param idleGLTFAnimations
  90501. * @param nodeMap
  90502. * @param nodes
  90503. * @param binaryWriter
  90504. * @param bufferViews
  90505. * @param accessors
  90506. * @param convertToRightHandedSystem
  90507. * @param animationSampleRate
  90508. */
  90509. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90510. [key: number]: number;
  90511. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90512. /**
  90513. * @ignore
  90514. * Create node and morph animations from the animation groups
  90515. * @param babylonScene
  90516. * @param glTFAnimations
  90517. * @param nodeMap
  90518. * @param nodes
  90519. * @param binaryWriter
  90520. * @param bufferViews
  90521. * @param accessors
  90522. * @param convertToRightHandedSystemMap
  90523. * @param animationSampleRate
  90524. */
  90525. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90526. [key: number]: number;
  90527. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90528. [nodeId: number]: boolean;
  90529. }, animationSampleRate: number): void;
  90530. private static AddAnimation;
  90531. /**
  90532. * Create a baked animation
  90533. * @param babylonTransformNode BabylonJS mesh
  90534. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90535. * @param animationChannelTargetPath animation target channel
  90536. * @param minFrame minimum animation frame
  90537. * @param maxFrame maximum animation frame
  90538. * @param fps frames per second of the animation
  90539. * @param inputs input key frames of the animation
  90540. * @param outputs output key frame data of the animation
  90541. * @param convertToRightHandedSystem converts the values to right-handed
  90542. * @param useQuaternion specifies if quaternions should be used
  90543. */
  90544. private static _CreateBakedAnimation;
  90545. private static _ConvertFactorToVector3OrQuaternion;
  90546. private static _SetInterpolatedValue;
  90547. /**
  90548. * Creates linear animation from the animation key frames
  90549. * @param babylonTransformNode BabylonJS mesh
  90550. * @param animation BabylonJS animation
  90551. * @param animationChannelTargetPath The target animation channel
  90552. * @param frameDelta The difference between the last and first frame of the animation
  90553. * @param inputs Array to store the key frame times
  90554. * @param outputs Array to store the key frame data
  90555. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90556. * @param useQuaternion Specifies if quaternions are used in the animation
  90557. */
  90558. private static _CreateLinearOrStepAnimation;
  90559. /**
  90560. * Creates cubic spline animation from the animation key frames
  90561. * @param babylonTransformNode BabylonJS mesh
  90562. * @param animation BabylonJS animation
  90563. * @param animationChannelTargetPath The target animation channel
  90564. * @param frameDelta The difference between the last and first frame of the animation
  90565. * @param inputs Array to store the key frame times
  90566. * @param outputs Array to store the key frame data
  90567. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90568. * @param useQuaternion Specifies if quaternions are used in the animation
  90569. */
  90570. private static _CreateCubicSplineAnimation;
  90571. private static _GetBasePositionRotationOrScale;
  90572. /**
  90573. * Adds a key frame value
  90574. * @param keyFrame
  90575. * @param animation
  90576. * @param outputs
  90577. * @param animationChannelTargetPath
  90578. * @param basePositionRotationOrScale
  90579. * @param convertToRightHandedSystem
  90580. * @param useQuaternion
  90581. */
  90582. private static _AddKeyframeValue;
  90583. /**
  90584. * Determine the interpolation based on the key frames
  90585. * @param keyFrames
  90586. * @param animationChannelTargetPath
  90587. * @param useQuaternion
  90588. */
  90589. private static _DeduceInterpolation;
  90590. /**
  90591. * Adds an input tangent or output tangent to the output data
  90592. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90593. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90594. * @param outputs The animation data by keyframe
  90595. * @param animationChannelTargetPath The target animation channel
  90596. * @param interpolation The interpolation type
  90597. * @param keyFrame The key frame with the animation data
  90598. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90599. * @param useQuaternion Specifies if quaternions are used
  90600. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90601. */
  90602. private static AddSplineTangent;
  90603. /**
  90604. * Get the minimum and maximum key frames' frame values
  90605. * @param keyFrames animation key frames
  90606. * @returns the minimum and maximum key frame value
  90607. */
  90608. private static calculateMinMaxKeyFrames;
  90609. }
  90610. }
  90611. declare module BABYLON.GLTF2.Exporter {
  90612. /** @hidden */
  90613. export var textureTransformPixelShader: {
  90614. name: string;
  90615. shader: string;
  90616. };
  90617. }
  90618. declare module BABYLON.GLTF2.Exporter.Extensions {
  90619. /**
  90620. * @hidden
  90621. */
  90622. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90623. private _recordedTextures;
  90624. /** Name of this extension */
  90625. readonly name: string;
  90626. /** Defines whether this extension is enabled */
  90627. enabled: boolean;
  90628. /** Defines whether this extension is required */
  90629. required: boolean;
  90630. /** Reference to the glTF exporter */
  90631. private _wasUsed;
  90632. constructor(exporter: _Exporter);
  90633. dispose(): void;
  90634. /** @hidden */
  90635. get wasUsed(): boolean;
  90636. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90637. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90638. /**
  90639. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90640. * @param babylonTexture
  90641. * @param offset
  90642. * @param rotation
  90643. * @param scale
  90644. * @param scene
  90645. */
  90646. private _textureTransformTextureAsync;
  90647. }
  90648. }
  90649. declare module BABYLON.GLTF2.Exporter.Extensions {
  90650. /**
  90651. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90652. */
  90653. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90654. /** The name of this extension. */
  90655. readonly name: string;
  90656. /** Defines whether this extension is enabled. */
  90657. enabled: boolean;
  90658. /** Defines whether this extension is required */
  90659. required: boolean;
  90660. /** Reference to the glTF exporter */
  90661. private _exporter;
  90662. private _lights;
  90663. /** @hidden */
  90664. constructor(exporter: _Exporter);
  90665. /** @hidden */
  90666. dispose(): void;
  90667. /** @hidden */
  90668. get wasUsed(): boolean;
  90669. /** @hidden */
  90670. onExporting(): void;
  90671. /**
  90672. * Define this method to modify the default behavior when exporting a node
  90673. * @param context The context when exporting the node
  90674. * @param node glTF node
  90675. * @param babylonNode BabylonJS node
  90676. * @param nodeMap Node mapping of unique id to glTF node index
  90677. * @returns nullable INode promise
  90678. */
  90679. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90680. [key: number]: number;
  90681. }): Promise<Nullable<INode>>;
  90682. }
  90683. }
  90684. declare module BABYLON.GLTF2.Exporter.Extensions {
  90685. /**
  90686. * @hidden
  90687. */
  90688. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90689. /** Name of this extension */
  90690. readonly name: string;
  90691. /** Defines whether this extension is enabled */
  90692. enabled: boolean;
  90693. /** Defines whether this extension is required */
  90694. required: boolean;
  90695. /** Reference to the glTF exporter */
  90696. private _textureInfos;
  90697. private _exportedTextures;
  90698. private _wasUsed;
  90699. constructor(exporter: _Exporter);
  90700. dispose(): void;
  90701. /** @hidden */
  90702. get wasUsed(): boolean;
  90703. private _getTextureIndex;
  90704. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90705. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90706. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90707. }
  90708. }
  90709. declare module BABYLON.GLTF2.Exporter.Extensions {
  90710. /**
  90711. * @hidden
  90712. */
  90713. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90714. /** Name of this extension */
  90715. readonly name: string;
  90716. /** Defines whether this extension is enabled */
  90717. enabled: boolean;
  90718. /** Defines whether this extension is required */
  90719. required: boolean;
  90720. private _wasUsed;
  90721. constructor(exporter: _Exporter);
  90722. /** @hidden */
  90723. get wasUsed(): boolean;
  90724. dispose(): void;
  90725. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90726. }
  90727. }
  90728. declare module BABYLON {
  90729. /**
  90730. * Class for generating STL data from a Babylon scene.
  90731. */
  90732. export class STLExport {
  90733. /**
  90734. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90735. * @param meshes list defines the mesh to serialize
  90736. * @param download triggers the automatic download of the file.
  90737. * @param fileName changes the downloads fileName.
  90738. * @param binary changes the STL to a binary type.
  90739. * @param isLittleEndian toggle for binary type exporter.
  90740. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90741. * @returns the STL as UTF8 string
  90742. */
  90743. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90744. }
  90745. }
  90746. declare module "babylonjs-gltf2interface" {
  90747. export = BABYLON.GLTF2;
  90748. }
  90749. /**
  90750. * Module for glTF 2.0 Interface
  90751. */
  90752. declare module BABYLON.GLTF2 {
  90753. /**
  90754. * The datatype of the components in the attribute
  90755. */
  90756. const enum AccessorComponentType {
  90757. /**
  90758. * Byte
  90759. */
  90760. BYTE = 5120,
  90761. /**
  90762. * Unsigned Byte
  90763. */
  90764. UNSIGNED_BYTE = 5121,
  90765. /**
  90766. * Short
  90767. */
  90768. SHORT = 5122,
  90769. /**
  90770. * Unsigned Short
  90771. */
  90772. UNSIGNED_SHORT = 5123,
  90773. /**
  90774. * Unsigned Int
  90775. */
  90776. UNSIGNED_INT = 5125,
  90777. /**
  90778. * Float
  90779. */
  90780. FLOAT = 5126,
  90781. }
  90782. /**
  90783. * Specifies if the attirbute is a scalar, vector, or matrix
  90784. */
  90785. const enum AccessorType {
  90786. /**
  90787. * Scalar
  90788. */
  90789. SCALAR = "SCALAR",
  90790. /**
  90791. * Vector2
  90792. */
  90793. VEC2 = "VEC2",
  90794. /**
  90795. * Vector3
  90796. */
  90797. VEC3 = "VEC3",
  90798. /**
  90799. * Vector4
  90800. */
  90801. VEC4 = "VEC4",
  90802. /**
  90803. * Matrix2x2
  90804. */
  90805. MAT2 = "MAT2",
  90806. /**
  90807. * Matrix3x3
  90808. */
  90809. MAT3 = "MAT3",
  90810. /**
  90811. * Matrix4x4
  90812. */
  90813. MAT4 = "MAT4",
  90814. }
  90815. /**
  90816. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90817. */
  90818. const enum AnimationChannelTargetPath {
  90819. /**
  90820. * Translation
  90821. */
  90822. TRANSLATION = "translation",
  90823. /**
  90824. * Rotation
  90825. */
  90826. ROTATION = "rotation",
  90827. /**
  90828. * Scale
  90829. */
  90830. SCALE = "scale",
  90831. /**
  90832. * Weights
  90833. */
  90834. WEIGHTS = "weights",
  90835. }
  90836. /**
  90837. * Interpolation algorithm
  90838. */
  90839. const enum AnimationSamplerInterpolation {
  90840. /**
  90841. * The animated values are linearly interpolated between keyframes
  90842. */
  90843. LINEAR = "LINEAR",
  90844. /**
  90845. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90846. */
  90847. STEP = "STEP",
  90848. /**
  90849. * The animation's interpolation is computed using a cubic spline with specified tangents
  90850. */
  90851. CUBICSPLINE = "CUBICSPLINE",
  90852. }
  90853. /**
  90854. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90855. */
  90856. const enum CameraType {
  90857. /**
  90858. * A perspective camera containing properties to create a perspective projection matrix
  90859. */
  90860. PERSPECTIVE = "perspective",
  90861. /**
  90862. * An orthographic camera containing properties to create an orthographic projection matrix
  90863. */
  90864. ORTHOGRAPHIC = "orthographic",
  90865. }
  90866. /**
  90867. * The mime-type of the image
  90868. */
  90869. const enum ImageMimeType {
  90870. /**
  90871. * JPEG Mime-type
  90872. */
  90873. JPEG = "image/jpeg",
  90874. /**
  90875. * PNG Mime-type
  90876. */
  90877. PNG = "image/png",
  90878. }
  90879. /**
  90880. * The alpha rendering mode of the material
  90881. */
  90882. const enum MaterialAlphaMode {
  90883. /**
  90884. * The alpha value is ignored and the rendered output is fully opaque
  90885. */
  90886. OPAQUE = "OPAQUE",
  90887. /**
  90888. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90889. */
  90890. MASK = "MASK",
  90891. /**
  90892. * 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)
  90893. */
  90894. BLEND = "BLEND",
  90895. }
  90896. /**
  90897. * The type of the primitives to render
  90898. */
  90899. const enum MeshPrimitiveMode {
  90900. /**
  90901. * Points
  90902. */
  90903. POINTS = 0,
  90904. /**
  90905. * Lines
  90906. */
  90907. LINES = 1,
  90908. /**
  90909. * Line Loop
  90910. */
  90911. LINE_LOOP = 2,
  90912. /**
  90913. * Line Strip
  90914. */
  90915. LINE_STRIP = 3,
  90916. /**
  90917. * Triangles
  90918. */
  90919. TRIANGLES = 4,
  90920. /**
  90921. * Triangle Strip
  90922. */
  90923. TRIANGLE_STRIP = 5,
  90924. /**
  90925. * Triangle Fan
  90926. */
  90927. TRIANGLE_FAN = 6,
  90928. }
  90929. /**
  90930. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90931. */
  90932. const enum TextureMagFilter {
  90933. /**
  90934. * Nearest
  90935. */
  90936. NEAREST = 9728,
  90937. /**
  90938. * Linear
  90939. */
  90940. LINEAR = 9729,
  90941. }
  90942. /**
  90943. * Minification filter. All valid values correspond to WebGL enums
  90944. */
  90945. const enum TextureMinFilter {
  90946. /**
  90947. * Nearest
  90948. */
  90949. NEAREST = 9728,
  90950. /**
  90951. * Linear
  90952. */
  90953. LINEAR = 9729,
  90954. /**
  90955. * Nearest Mip-Map Nearest
  90956. */
  90957. NEAREST_MIPMAP_NEAREST = 9984,
  90958. /**
  90959. * Linear Mipmap Nearest
  90960. */
  90961. LINEAR_MIPMAP_NEAREST = 9985,
  90962. /**
  90963. * Nearest Mipmap Linear
  90964. */
  90965. NEAREST_MIPMAP_LINEAR = 9986,
  90966. /**
  90967. * Linear Mipmap Linear
  90968. */
  90969. LINEAR_MIPMAP_LINEAR = 9987,
  90970. }
  90971. /**
  90972. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90973. */
  90974. const enum TextureWrapMode {
  90975. /**
  90976. * Clamp to Edge
  90977. */
  90978. CLAMP_TO_EDGE = 33071,
  90979. /**
  90980. * Mirrored Repeat
  90981. */
  90982. MIRRORED_REPEAT = 33648,
  90983. /**
  90984. * Repeat
  90985. */
  90986. REPEAT = 10497,
  90987. }
  90988. /**
  90989. * glTF Property
  90990. */
  90991. interface IProperty {
  90992. /**
  90993. * Dictionary object with extension-specific objects
  90994. */
  90995. extensions?: {
  90996. [key: string]: any;
  90997. };
  90998. /**
  90999. * Application-Specific data
  91000. */
  91001. extras?: any;
  91002. }
  91003. /**
  91004. * glTF Child of Root Property
  91005. */
  91006. interface IChildRootProperty extends IProperty {
  91007. /**
  91008. * The user-defined name of this object
  91009. */
  91010. name?: string;
  91011. }
  91012. /**
  91013. * Indices of those attributes that deviate from their initialization value
  91014. */
  91015. interface IAccessorSparseIndices extends IProperty {
  91016. /**
  91017. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91018. */
  91019. bufferView: number;
  91020. /**
  91021. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91022. */
  91023. byteOffset?: number;
  91024. /**
  91025. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91026. */
  91027. componentType: AccessorComponentType;
  91028. }
  91029. /**
  91030. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91031. */
  91032. interface IAccessorSparseValues extends IProperty {
  91033. /**
  91034. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91035. */
  91036. bufferView: number;
  91037. /**
  91038. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91039. */
  91040. byteOffset?: number;
  91041. }
  91042. /**
  91043. * Sparse storage of attributes that deviate from their initialization value
  91044. */
  91045. interface IAccessorSparse extends IProperty {
  91046. /**
  91047. * The number of attributes encoded in this sparse accessor
  91048. */
  91049. count: number;
  91050. /**
  91051. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91052. */
  91053. indices: IAccessorSparseIndices;
  91054. /**
  91055. * 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
  91056. */
  91057. values: IAccessorSparseValues;
  91058. }
  91059. /**
  91060. * 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
  91061. */
  91062. interface IAccessor extends IChildRootProperty {
  91063. /**
  91064. * The index of the bufferview
  91065. */
  91066. bufferView?: number;
  91067. /**
  91068. * The offset relative to the start of the bufferView in bytes
  91069. */
  91070. byteOffset?: number;
  91071. /**
  91072. * The datatype of components in the attribute
  91073. */
  91074. componentType: AccessorComponentType;
  91075. /**
  91076. * Specifies whether integer data values should be normalized
  91077. */
  91078. normalized?: boolean;
  91079. /**
  91080. * The number of attributes referenced by this accessor
  91081. */
  91082. count: number;
  91083. /**
  91084. * Specifies if the attribute is a scalar, vector, or matrix
  91085. */
  91086. type: AccessorType;
  91087. /**
  91088. * Maximum value of each component in this attribute
  91089. */
  91090. max?: number[];
  91091. /**
  91092. * Minimum value of each component in this attribute
  91093. */
  91094. min?: number[];
  91095. /**
  91096. * Sparse storage of attributes that deviate from their initialization value
  91097. */
  91098. sparse?: IAccessorSparse;
  91099. }
  91100. /**
  91101. * Targets an animation's sampler at a node's property
  91102. */
  91103. interface IAnimationChannel extends IProperty {
  91104. /**
  91105. * The index of a sampler in this animation used to compute the value for the target
  91106. */
  91107. sampler: number;
  91108. /**
  91109. * The index of the node and TRS property to target
  91110. */
  91111. target: IAnimationChannelTarget;
  91112. }
  91113. /**
  91114. * The index of the node and TRS property that an animation channel targets
  91115. */
  91116. interface IAnimationChannelTarget extends IProperty {
  91117. /**
  91118. * The index of the node to target
  91119. */
  91120. node: number;
  91121. /**
  91122. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91123. */
  91124. path: AnimationChannelTargetPath;
  91125. }
  91126. /**
  91127. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91128. */
  91129. interface IAnimationSampler extends IProperty {
  91130. /**
  91131. * The index of an accessor containing keyframe input values, e.g., time
  91132. */
  91133. input: number;
  91134. /**
  91135. * Interpolation algorithm
  91136. */
  91137. interpolation?: AnimationSamplerInterpolation;
  91138. /**
  91139. * The index of an accessor, containing keyframe output values
  91140. */
  91141. output: number;
  91142. }
  91143. /**
  91144. * A keyframe animation
  91145. */
  91146. interface IAnimation extends IChildRootProperty {
  91147. /**
  91148. * An array of channels, each of which targets an animation's sampler at a node's property
  91149. */
  91150. channels: IAnimationChannel[];
  91151. /**
  91152. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91153. */
  91154. samplers: IAnimationSampler[];
  91155. }
  91156. /**
  91157. * Metadata about the glTF asset
  91158. */
  91159. interface IAsset extends IChildRootProperty {
  91160. /**
  91161. * A copyright message suitable for display to credit the content creator
  91162. */
  91163. copyright?: string;
  91164. /**
  91165. * Tool that generated this glTF model. Useful for debugging
  91166. */
  91167. generator?: string;
  91168. /**
  91169. * The glTF version that this asset targets
  91170. */
  91171. version: string;
  91172. /**
  91173. * The minimum glTF version that this asset targets
  91174. */
  91175. minVersion?: string;
  91176. }
  91177. /**
  91178. * A buffer points to binary geometry, animation, or skins
  91179. */
  91180. interface IBuffer extends IChildRootProperty {
  91181. /**
  91182. * 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
  91183. */
  91184. uri?: string;
  91185. /**
  91186. * The length of the buffer in bytes
  91187. */
  91188. byteLength: number;
  91189. }
  91190. /**
  91191. * A view into a buffer generally representing a subset of the buffer
  91192. */
  91193. interface IBufferView extends IChildRootProperty {
  91194. /**
  91195. * The index of the buffer
  91196. */
  91197. buffer: number;
  91198. /**
  91199. * The offset into the buffer in bytes
  91200. */
  91201. byteOffset?: number;
  91202. /**
  91203. * The lenth of the bufferView in bytes
  91204. */
  91205. byteLength: number;
  91206. /**
  91207. * The stride, in bytes
  91208. */
  91209. byteStride?: number;
  91210. }
  91211. /**
  91212. * An orthographic camera containing properties to create an orthographic projection matrix
  91213. */
  91214. interface ICameraOrthographic extends IProperty {
  91215. /**
  91216. * The floating-point horizontal magnification of the view. Must not be zero
  91217. */
  91218. xmag: number;
  91219. /**
  91220. * The floating-point vertical magnification of the view. Must not be zero
  91221. */
  91222. ymag: number;
  91223. /**
  91224. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91225. */
  91226. zfar: number;
  91227. /**
  91228. * The floating-point distance to the near clipping plane
  91229. */
  91230. znear: number;
  91231. }
  91232. /**
  91233. * A perspective camera containing properties to create a perspective projection matrix
  91234. */
  91235. interface ICameraPerspective extends IProperty {
  91236. /**
  91237. * The floating-point aspect ratio of the field of view
  91238. */
  91239. aspectRatio?: number;
  91240. /**
  91241. * The floating-point vertical field of view in radians
  91242. */
  91243. yfov: number;
  91244. /**
  91245. * The floating-point distance to the far clipping plane
  91246. */
  91247. zfar?: number;
  91248. /**
  91249. * The floating-point distance to the near clipping plane
  91250. */
  91251. znear: number;
  91252. }
  91253. /**
  91254. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91255. */
  91256. interface ICamera extends IChildRootProperty {
  91257. /**
  91258. * An orthographic camera containing properties to create an orthographic projection matrix
  91259. */
  91260. orthographic?: ICameraOrthographic;
  91261. /**
  91262. * A perspective camera containing properties to create a perspective projection matrix
  91263. */
  91264. perspective?: ICameraPerspective;
  91265. /**
  91266. * Specifies if the camera uses a perspective or orthographic projection
  91267. */
  91268. type: CameraType;
  91269. }
  91270. /**
  91271. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91272. */
  91273. interface IImage extends IChildRootProperty {
  91274. /**
  91275. * 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
  91276. */
  91277. uri?: string;
  91278. /**
  91279. * The image's MIME type
  91280. */
  91281. mimeType?: ImageMimeType;
  91282. /**
  91283. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91284. */
  91285. bufferView?: number;
  91286. }
  91287. /**
  91288. * Material Normal Texture Info
  91289. */
  91290. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91291. /**
  91292. * The scalar multiplier applied to each normal vector of the normal texture
  91293. */
  91294. scale?: number;
  91295. }
  91296. /**
  91297. * Material Occlusion Texture Info
  91298. */
  91299. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91300. /**
  91301. * A scalar multiplier controlling the amount of occlusion applied
  91302. */
  91303. strength?: number;
  91304. }
  91305. /**
  91306. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91307. */
  91308. interface IMaterialPbrMetallicRoughness {
  91309. /**
  91310. * The material's base color factor
  91311. */
  91312. baseColorFactor?: number[];
  91313. /**
  91314. * The base color texture
  91315. */
  91316. baseColorTexture?: ITextureInfo;
  91317. /**
  91318. * The metalness of the material
  91319. */
  91320. metallicFactor?: number;
  91321. /**
  91322. * The roughness of the material
  91323. */
  91324. roughnessFactor?: number;
  91325. /**
  91326. * The metallic-roughness texture
  91327. */
  91328. metallicRoughnessTexture?: ITextureInfo;
  91329. }
  91330. /**
  91331. * The material appearance of a primitive
  91332. */
  91333. interface IMaterial extends IChildRootProperty {
  91334. /**
  91335. * 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
  91336. */
  91337. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91338. /**
  91339. * The normal map texture
  91340. */
  91341. normalTexture?: IMaterialNormalTextureInfo;
  91342. /**
  91343. * The occlusion map texture
  91344. */
  91345. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91346. /**
  91347. * The emissive map texture
  91348. */
  91349. emissiveTexture?: ITextureInfo;
  91350. /**
  91351. * 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
  91352. */
  91353. emissiveFactor?: number[];
  91354. /**
  91355. * The alpha rendering mode of the material
  91356. */
  91357. alphaMode?: MaterialAlphaMode;
  91358. /**
  91359. * The alpha cutoff value of the material
  91360. */
  91361. alphaCutoff?: number;
  91362. /**
  91363. * Specifies whether the material is double sided
  91364. */
  91365. doubleSided?: boolean;
  91366. }
  91367. /**
  91368. * Geometry to be rendered with the given material
  91369. */
  91370. interface IMeshPrimitive extends IProperty {
  91371. /**
  91372. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91373. */
  91374. attributes: {
  91375. [name: string]: number;
  91376. };
  91377. /**
  91378. * The index of the accessor that contains the indices
  91379. */
  91380. indices?: number;
  91381. /**
  91382. * The index of the material to apply to this primitive when rendering
  91383. */
  91384. material?: number;
  91385. /**
  91386. * The type of primitives to render. All valid values correspond to WebGL enums
  91387. */
  91388. mode?: MeshPrimitiveMode;
  91389. /**
  91390. * 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
  91391. */
  91392. targets?: {
  91393. [name: string]: number;
  91394. }[];
  91395. }
  91396. /**
  91397. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91398. */
  91399. interface IMesh extends IChildRootProperty {
  91400. /**
  91401. * An array of primitives, each defining geometry to be rendered with a material
  91402. */
  91403. primitives: IMeshPrimitive[];
  91404. /**
  91405. * Array of weights to be applied to the Morph Targets
  91406. */
  91407. weights?: number[];
  91408. }
  91409. /**
  91410. * A node in the node hierarchy
  91411. */
  91412. interface INode extends IChildRootProperty {
  91413. /**
  91414. * The index of the camera referenced by this node
  91415. */
  91416. camera?: number;
  91417. /**
  91418. * The indices of this node's children
  91419. */
  91420. children?: number[];
  91421. /**
  91422. * The index of the skin referenced by this node
  91423. */
  91424. skin?: number;
  91425. /**
  91426. * A floating-point 4x4 transformation matrix stored in column-major order
  91427. */
  91428. matrix?: number[];
  91429. /**
  91430. * The index of the mesh in this node
  91431. */
  91432. mesh?: number;
  91433. /**
  91434. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91435. */
  91436. rotation?: number[];
  91437. /**
  91438. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91439. */
  91440. scale?: number[];
  91441. /**
  91442. * The node's translation along the x, y, and z axes
  91443. */
  91444. translation?: number[];
  91445. /**
  91446. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91447. */
  91448. weights?: number[];
  91449. }
  91450. /**
  91451. * Texture sampler properties for filtering and wrapping modes
  91452. */
  91453. interface ISampler extends IChildRootProperty {
  91454. /**
  91455. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91456. */
  91457. magFilter?: TextureMagFilter;
  91458. /**
  91459. * Minification filter. All valid values correspond to WebGL enums
  91460. */
  91461. minFilter?: TextureMinFilter;
  91462. /**
  91463. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91464. */
  91465. wrapS?: TextureWrapMode;
  91466. /**
  91467. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91468. */
  91469. wrapT?: TextureWrapMode;
  91470. }
  91471. /**
  91472. * The root nodes of a scene
  91473. */
  91474. interface IScene extends IChildRootProperty {
  91475. /**
  91476. * The indices of each root node
  91477. */
  91478. nodes: number[];
  91479. }
  91480. /**
  91481. * Joints and matrices defining a skin
  91482. */
  91483. interface ISkin extends IChildRootProperty {
  91484. /**
  91485. * 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
  91486. */
  91487. inverseBindMatrices?: number;
  91488. /**
  91489. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91490. */
  91491. skeleton?: number;
  91492. /**
  91493. * 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)
  91494. */
  91495. joints: number[];
  91496. }
  91497. /**
  91498. * A texture and its sampler
  91499. */
  91500. interface ITexture extends IChildRootProperty {
  91501. /**
  91502. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91503. */
  91504. sampler?: number;
  91505. /**
  91506. * The index of the image used by this texture
  91507. */
  91508. source: number;
  91509. }
  91510. /**
  91511. * Reference to a texture
  91512. */
  91513. interface ITextureInfo extends IProperty {
  91514. /**
  91515. * The index of the texture
  91516. */
  91517. index: number;
  91518. /**
  91519. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91520. */
  91521. texCoord?: number;
  91522. }
  91523. /**
  91524. * The root object for a glTF asset
  91525. */
  91526. interface IGLTF extends IProperty {
  91527. /**
  91528. * An array of accessors. An accessor is a typed view into a bufferView
  91529. */
  91530. accessors?: IAccessor[];
  91531. /**
  91532. * An array of keyframe animations
  91533. */
  91534. animations?: IAnimation[];
  91535. /**
  91536. * Metadata about the glTF asset
  91537. */
  91538. asset: IAsset;
  91539. /**
  91540. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91541. */
  91542. buffers?: IBuffer[];
  91543. /**
  91544. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91545. */
  91546. bufferViews?: IBufferView[];
  91547. /**
  91548. * An array of cameras
  91549. */
  91550. cameras?: ICamera[];
  91551. /**
  91552. * Names of glTF extensions used somewhere in this asset
  91553. */
  91554. extensionsUsed?: string[];
  91555. /**
  91556. * Names of glTF extensions required to properly load this asset
  91557. */
  91558. extensionsRequired?: string[];
  91559. /**
  91560. * An array of images. An image defines data used to create a texture
  91561. */
  91562. images?: IImage[];
  91563. /**
  91564. * An array of materials. A material defines the appearance of a primitive
  91565. */
  91566. materials?: IMaterial[];
  91567. /**
  91568. * An array of meshes. A mesh is a set of primitives to be rendered
  91569. */
  91570. meshes?: IMesh[];
  91571. /**
  91572. * An array of nodes
  91573. */
  91574. nodes?: INode[];
  91575. /**
  91576. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91577. */
  91578. samplers?: ISampler[];
  91579. /**
  91580. * The index of the default scene
  91581. */
  91582. scene?: number;
  91583. /**
  91584. * An array of scenes
  91585. */
  91586. scenes?: IScene[];
  91587. /**
  91588. * An array of skins. A skin is defined by joints and matrices
  91589. */
  91590. skins?: ISkin[];
  91591. /**
  91592. * An array of textures
  91593. */
  91594. textures?: ITexture[];
  91595. }
  91596. /**
  91597. * The glTF validation results
  91598. * @ignore
  91599. */
  91600. interface IGLTFValidationResults {
  91601. info: {
  91602. generator: string;
  91603. hasAnimations: boolean;
  91604. hasDefaultScene: boolean;
  91605. hasMaterials: boolean;
  91606. hasMorphTargets: boolean;
  91607. hasSkins: boolean;
  91608. hasTextures: boolean;
  91609. maxAttributesUsed: number;
  91610. primitivesCount: number
  91611. };
  91612. issues: {
  91613. messages: Array<string>;
  91614. numErrors: number;
  91615. numHints: number;
  91616. numInfos: number;
  91617. numWarnings: number;
  91618. truncated: boolean
  91619. };
  91620. mimeType: string;
  91621. uri: string;
  91622. validatedAt: string;
  91623. validatorVersion: string;
  91624. }
  91625. /**
  91626. * The glTF validation options
  91627. */
  91628. interface IGLTFValidationOptions {
  91629. /** Uri to use */
  91630. uri?: string;
  91631. /** Function used to load external resources */
  91632. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91633. /** Boolean indicating that we need to validate accessor data */
  91634. validateAccessorData?: boolean;
  91635. /** max number of issues allowed */
  91636. maxIssues?: number;
  91637. /** Ignored issues */
  91638. ignoredIssues?: Array<string>;
  91639. /** Value to override severy settings */
  91640. severityOverrides?: Object;
  91641. }
  91642. /**
  91643. * The glTF validator object
  91644. * @ignore
  91645. */
  91646. interface IGLTFValidator {
  91647. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91648. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91649. }
  91650. /**
  91651. * Interfaces from the EXT_lights_image_based extension
  91652. */
  91653. /** @hidden */
  91654. interface IEXTLightsImageBased_LightReferenceImageBased {
  91655. light: number;
  91656. }
  91657. /** @hidden */
  91658. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91659. intensity: number;
  91660. rotation: number[];
  91661. specularImageSize: number;
  91662. specularImages: number[][];
  91663. irradianceCoefficients: number[][];
  91664. }
  91665. /** @hidden */
  91666. interface IEXTLightsImageBased {
  91667. lights: IEXTLightsImageBased_LightImageBased[];
  91668. }
  91669. /**
  91670. * Interfaces from the EXT_mesh_gpu_instancing extension
  91671. * !!! Experimental Extension Subject to Changes !!!
  91672. */
  91673. /** @hidden */
  91674. interface IEXTMeshGpuInstancing {
  91675. mesh?: number;
  91676. attributes: { [name: string]: number };
  91677. }
  91678. /**
  91679. * Interfaces from the KHR_draco_mesh_compression extension
  91680. */
  91681. /** @hidden */
  91682. interface IKHRDracoMeshCompression {
  91683. bufferView: number;
  91684. attributes: { [name: string]: number };
  91685. }
  91686. /**
  91687. * Interfaces from the KHR_lights_punctual extension
  91688. */
  91689. /** @hidden */
  91690. const enum IKHRLightsPunctual_LightType {
  91691. DIRECTIONAL = "directional",
  91692. POINT = "point",
  91693. SPOT = "spot"
  91694. }
  91695. /** @hidden */
  91696. interface IKHRLightsPunctual_LightReference {
  91697. light: number;
  91698. }
  91699. /** @hidden */
  91700. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91701. type: IKHRLightsPunctual_LightType;
  91702. color?: number[];
  91703. intensity?: number;
  91704. range?: number;
  91705. spot?: {
  91706. innerConeAngle?: number;
  91707. outerConeAngle?: number;
  91708. };
  91709. }
  91710. /** @hidden */
  91711. interface IKHRLightsPunctual {
  91712. lights: IKHRLightsPunctual_Light[];
  91713. }
  91714. /**
  91715. * Interfaces from the KHR_materials_clearcoat extension
  91716. * !!! Experimental Extension Subject to Changes !!!
  91717. */
  91718. /** @hidden */
  91719. interface IKHRMaterialsClearcoat {
  91720. clearcoatFactor: number;
  91721. clearcoatTexture: ITextureInfo;
  91722. clearcoatRoughnessFactor: number;
  91723. clearcoatRoughnessTexture: ITextureInfo;
  91724. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91725. }
  91726. /**
  91727. * Interfaces from the KHR_materials_ior extension
  91728. * !!! Experimental Extension Subject to Changes !!!
  91729. */
  91730. /** @hidden */
  91731. interface IKHRMaterialsIor {
  91732. ior: number;
  91733. }
  91734. /**
  91735. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91736. */
  91737. /** @hidden */
  91738. interface IKHRMaterialsPbrSpecularGlossiness {
  91739. diffuseFactor: number[];
  91740. diffuseTexture: ITextureInfo;
  91741. specularFactor: number[];
  91742. glossinessFactor: number;
  91743. specularGlossinessTexture: ITextureInfo;
  91744. }
  91745. /**
  91746. * Interfaces from the KHR_materials_sheen extension
  91747. * !!! Experimental Extension Subject to Changes !!!
  91748. */
  91749. /** @hidden */
  91750. interface IKHRMaterialsSheen {
  91751. sheenColorFactor?: number[];
  91752. sheenColorTexture?: ITextureInfo;
  91753. sheenRoughnessFactor?: number;
  91754. sheenRoughnessTexture?: ITextureInfo;
  91755. }
  91756. /**
  91757. * Interfaces from the KHR_materials_specular extension
  91758. * !!! Experimental Extension Subject to Changes !!!
  91759. */
  91760. /** @hidden */
  91761. interface IKHRMaterialsSpecular {
  91762. specularFactor: number;
  91763. specularColorFactor: number[];
  91764. specularTexture: ITextureInfo;
  91765. }
  91766. /**
  91767. * Interfaces from the KHR_materials_transmission extension
  91768. * !!! Experimental Extension Subject to Changes !!!
  91769. */
  91770. /** @hidden */
  91771. interface IKHRMaterialsTransmission {
  91772. transmissionFactor?: number;
  91773. transmissionTexture?: ITextureInfo;
  91774. }
  91775. /**
  91776. * Interfaces from the KHR_materials_translucency extension
  91777. * !!! Experimental Extension Subject to Changes !!!
  91778. */
  91779. /** @hidden */
  91780. interface IKHRMaterialsTranslucency {
  91781. translucencyFactor?: number;
  91782. translucencyTexture?: ITextureInfo;
  91783. }
  91784. /**
  91785. * Interfaces from the KHR_materials_variants extension
  91786. * !!! Experimental Extension Subject to Changes !!!
  91787. */
  91788. /** @hidden */
  91789. interface IKHRMaterialVariants_Mapping extends IProperty {
  91790. mappings: Array<{
  91791. variants: number[];
  91792. material: number;
  91793. }>;
  91794. }
  91795. /** @hidden */
  91796. interface IKHRMaterialVariants_Variant extends IProperty {
  91797. name: string;
  91798. }
  91799. /** @hidden */
  91800. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91801. variants: Array<IKHRMaterialVariants_Variant>;
  91802. }
  91803. /**
  91804. * Interfaces from the KHR_texture_basisu extension
  91805. * !!! Experimental Extension Subject to Changes !!!
  91806. */
  91807. /** @hidden */
  91808. interface IKHRTextureBasisU {
  91809. source: number;
  91810. }
  91811. /**
  91812. * Interfaces from the EXT_texture_webp extension
  91813. */
  91814. /** @hidden */
  91815. interface IEXTTextureWebP {
  91816. source: number;
  91817. }
  91818. /**
  91819. * Interfaces from the KHR_texture_transform extension
  91820. */
  91821. /** @hidden */
  91822. interface IKHRTextureTransform {
  91823. offset?: number[];
  91824. rotation?: number;
  91825. scale?: number[];
  91826. texCoord?: number;
  91827. }
  91828. /**
  91829. * Interfaces from the KHR_xmp_json_ld extension
  91830. * !!! Experimental Extension Subject to Changes !!!
  91831. */
  91832. /** @hidden */
  91833. interface IKHRXmpJsonLd_Gltf {
  91834. packets: Array<{
  91835. [key: string]: unknown;
  91836. }>;
  91837. }
  91838. /** @hidden */
  91839. interface IKHRXmpJsonLd_Node {
  91840. packet: number;
  91841. }
  91842. /**
  91843. * Interfaces from the MSFT_audio_emitter extension
  91844. */
  91845. /** @hidden */
  91846. interface IMSFTAudioEmitter_ClipReference {
  91847. clip: number;
  91848. weight?: number;
  91849. }
  91850. /** @hidden */
  91851. interface IMSFTAudioEmitter_EmittersReference {
  91852. emitters: number[];
  91853. }
  91854. /** @hidden */
  91855. const enum IMSFTAudioEmitter_DistanceModel {
  91856. linear = "linear",
  91857. inverse = "inverse",
  91858. exponential = "exponential",
  91859. }
  91860. /** @hidden */
  91861. interface IMSFTAudioEmitter_Emitter {
  91862. name?: string;
  91863. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91864. refDistance?: number;
  91865. maxDistance?: number;
  91866. rolloffFactor?: number;
  91867. innerAngle?: number;
  91868. outerAngle?: number;
  91869. loop?: boolean;
  91870. volume?: number;
  91871. clips: IMSFTAudioEmitter_ClipReference[];
  91872. }
  91873. /** @hidden */
  91874. const enum IMSFTAudioEmitter_AudioMimeType {
  91875. WAV = "audio/wav",
  91876. }
  91877. /** @hidden */
  91878. interface IMSFTAudioEmitter_Clip extends IProperty {
  91879. uri?: string;
  91880. bufferView?: number;
  91881. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91882. }
  91883. /** @hidden */
  91884. const enum IMSFTAudioEmitter_AnimationEventAction {
  91885. play = "play",
  91886. pause = "pause",
  91887. stop = "stop",
  91888. }
  91889. /** @hidden */
  91890. interface IMSFTAudioEmitter_AnimationEvent {
  91891. action: IMSFTAudioEmitter_AnimationEventAction;
  91892. emitter: number;
  91893. time: number;
  91894. startOffset?: number;
  91895. }
  91896. /**
  91897. * Interfaces from the MSFT_lod extension
  91898. */
  91899. /** @hidden */
  91900. interface IMSFTLOD {
  91901. ids: number[];
  91902. }
  91903. /**
  91904. * Interfaces from the EXT_meshopt_compression extension
  91905. */
  91906. /** @hidden */
  91907. interface IEXTMeshoptCompression {
  91908. buffer: number;
  91909. byteOffset?: number;
  91910. byteLength: number;
  91911. byteStride: number;
  91912. count: number;
  91913. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91914. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91915. }
  91916. }
  91917. declare module BABYLON {
  91918. /** @hidden */
  91919. export var cellPixelShader: {
  91920. name: string;
  91921. shader: string;
  91922. };
  91923. }
  91924. declare module BABYLON {
  91925. /** @hidden */
  91926. export var cellVertexShader: {
  91927. name: string;
  91928. shader: string;
  91929. };
  91930. }
  91931. declare module BABYLON {
  91932. export class CellMaterial extends BABYLON.PushMaterial {
  91933. private _diffuseTexture;
  91934. diffuseTexture: BABYLON.BaseTexture;
  91935. diffuseColor: BABYLON.Color3;
  91936. _computeHighLevel: boolean;
  91937. computeHighLevel: boolean;
  91938. private _disableLighting;
  91939. disableLighting: boolean;
  91940. private _maxSimultaneousLights;
  91941. maxSimultaneousLights: number;
  91942. constructor(name: string, scene: BABYLON.Scene);
  91943. needAlphaBlending(): boolean;
  91944. needAlphaTesting(): boolean;
  91945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91946. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91947. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91948. getAnimatables(): BABYLON.IAnimatable[];
  91949. getActiveTextures(): BABYLON.BaseTexture[];
  91950. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91951. dispose(forceDisposeEffect?: boolean): void;
  91952. getClassName(): string;
  91953. clone(name: string): CellMaterial;
  91954. serialize(): any;
  91955. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91956. }
  91957. }
  91958. declare module BABYLON {
  91959. export class CustomShaderStructure {
  91960. FragmentStore: string;
  91961. VertexStore: string;
  91962. constructor();
  91963. }
  91964. export class ShaderSpecialParts {
  91965. constructor();
  91966. Fragment_Begin: string;
  91967. Fragment_Definitions: string;
  91968. Fragment_MainBegin: string;
  91969. Fragment_Custom_Diffuse: string;
  91970. Fragment_Before_Lights: string;
  91971. Fragment_Before_Fog: string;
  91972. Fragment_Custom_Alpha: string;
  91973. Fragment_Before_FragColor: string;
  91974. Vertex_Begin: string;
  91975. Vertex_Definitions: string;
  91976. Vertex_MainBegin: string;
  91977. Vertex_Before_PositionUpdated: string;
  91978. Vertex_Before_NormalUpdated: string;
  91979. Vertex_After_WorldPosComputed: string;
  91980. Vertex_MainEnd: string;
  91981. }
  91982. export class CustomMaterial extends BABYLON.StandardMaterial {
  91983. static ShaderIndexer: number;
  91984. CustomParts: ShaderSpecialParts;
  91985. _isCreatedShader: boolean;
  91986. _createdShaderName: string;
  91987. _customUniform: string[];
  91988. _newUniforms: string[];
  91989. _newUniformInstances: {
  91990. [name: string]: any;
  91991. };
  91992. _newSamplerInstances: {
  91993. [name: string]: BABYLON.Texture;
  91994. };
  91995. _customAttributes: string[];
  91996. FragmentShader: string;
  91997. VertexShader: string;
  91998. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91999. ReviewUniform(name: string, arr: string[]): string[];
  92000. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92001. constructor(name: string, scene: BABYLON.Scene);
  92002. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92003. AddAttribute(name: string): CustomMaterial;
  92004. Fragment_Begin(shaderPart: string): CustomMaterial;
  92005. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92006. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92007. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92008. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92009. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92010. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92011. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92012. Vertex_Begin(shaderPart: string): CustomMaterial;
  92013. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92014. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92015. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92016. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92017. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92018. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92019. }
  92020. }
  92021. declare module BABYLON {
  92022. export class ShaderAlebdoParts {
  92023. constructor();
  92024. Fragment_Begin: string;
  92025. Fragment_Definitions: string;
  92026. Fragment_MainBegin: string;
  92027. Fragment_Custom_Albedo: string;
  92028. Fragment_Before_Lights: string;
  92029. Fragment_Custom_MetallicRoughness: string;
  92030. Fragment_Custom_MicroSurface: string;
  92031. Fragment_Before_Fog: string;
  92032. Fragment_Custom_Alpha: string;
  92033. Fragment_Before_FragColor: string;
  92034. Vertex_Begin: string;
  92035. Vertex_Definitions: string;
  92036. Vertex_MainBegin: string;
  92037. Vertex_Before_PositionUpdated: string;
  92038. Vertex_Before_NormalUpdated: string;
  92039. Vertex_After_WorldPosComputed: string;
  92040. Vertex_MainEnd: string;
  92041. }
  92042. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92043. static ShaderIndexer: number;
  92044. CustomParts: ShaderAlebdoParts;
  92045. _isCreatedShader: boolean;
  92046. _createdShaderName: string;
  92047. _customUniform: string[];
  92048. _newUniforms: string[];
  92049. _newUniformInstances: {
  92050. [name: string]: any;
  92051. };
  92052. _newSamplerInstances: {
  92053. [name: string]: BABYLON.Texture;
  92054. };
  92055. _customAttributes: string[];
  92056. FragmentShader: string;
  92057. VertexShader: string;
  92058. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92059. ReviewUniform(name: string, arr: string[]): string[];
  92060. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92061. constructor(name: string, scene: BABYLON.Scene);
  92062. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92063. AddAttribute(name: string): PBRCustomMaterial;
  92064. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92065. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92066. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92067. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92068. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92069. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92070. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92071. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92072. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92073. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92074. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92075. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92076. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92077. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92078. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92079. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92080. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92081. }
  92082. }
  92083. declare module BABYLON {
  92084. /** @hidden */
  92085. export var firePixelShader: {
  92086. name: string;
  92087. shader: string;
  92088. };
  92089. }
  92090. declare module BABYLON {
  92091. /** @hidden */
  92092. export var fireVertexShader: {
  92093. name: string;
  92094. shader: string;
  92095. };
  92096. }
  92097. declare module BABYLON {
  92098. export class FireMaterial extends BABYLON.PushMaterial {
  92099. private _diffuseTexture;
  92100. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92101. private _distortionTexture;
  92102. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92103. private _opacityTexture;
  92104. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92105. diffuseColor: BABYLON.Color3;
  92106. speed: number;
  92107. private _scaledDiffuse;
  92108. private _lastTime;
  92109. constructor(name: string, scene: BABYLON.Scene);
  92110. needAlphaBlending(): boolean;
  92111. needAlphaTesting(): boolean;
  92112. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92113. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92114. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92115. getAnimatables(): BABYLON.IAnimatable[];
  92116. getActiveTextures(): BABYLON.BaseTexture[];
  92117. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92118. getClassName(): string;
  92119. dispose(forceDisposeEffect?: boolean): void;
  92120. clone(name: string): FireMaterial;
  92121. serialize(): any;
  92122. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92123. }
  92124. }
  92125. declare module BABYLON {
  92126. /** @hidden */
  92127. export var furPixelShader: {
  92128. name: string;
  92129. shader: string;
  92130. };
  92131. }
  92132. declare module BABYLON {
  92133. /** @hidden */
  92134. export var furVertexShader: {
  92135. name: string;
  92136. shader: string;
  92137. };
  92138. }
  92139. declare module BABYLON {
  92140. export class FurMaterial extends BABYLON.PushMaterial {
  92141. private _diffuseTexture;
  92142. diffuseTexture: BABYLON.BaseTexture;
  92143. private _heightTexture;
  92144. heightTexture: BABYLON.BaseTexture;
  92145. diffuseColor: BABYLON.Color3;
  92146. furLength: number;
  92147. furAngle: number;
  92148. furColor: BABYLON.Color3;
  92149. furOffset: number;
  92150. furSpacing: number;
  92151. furGravity: BABYLON.Vector3;
  92152. furSpeed: number;
  92153. furDensity: number;
  92154. furOcclusion: number;
  92155. furTexture: BABYLON.DynamicTexture;
  92156. private _disableLighting;
  92157. disableLighting: boolean;
  92158. private _maxSimultaneousLights;
  92159. maxSimultaneousLights: number;
  92160. highLevelFur: boolean;
  92161. _meshes: BABYLON.AbstractMesh[];
  92162. private _furTime;
  92163. constructor(name: string, scene: BABYLON.Scene);
  92164. get furTime(): number;
  92165. set furTime(furTime: number);
  92166. needAlphaBlending(): boolean;
  92167. needAlphaTesting(): boolean;
  92168. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92169. updateFur(): void;
  92170. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92171. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92172. getAnimatables(): BABYLON.IAnimatable[];
  92173. getActiveTextures(): BABYLON.BaseTexture[];
  92174. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92175. dispose(forceDisposeEffect?: boolean): void;
  92176. clone(name: string): FurMaterial;
  92177. serialize(): any;
  92178. getClassName(): string;
  92179. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92180. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92181. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92182. }
  92183. }
  92184. declare module BABYLON {
  92185. /** @hidden */
  92186. export var gradientPixelShader: {
  92187. name: string;
  92188. shader: string;
  92189. };
  92190. }
  92191. declare module BABYLON {
  92192. /** @hidden */
  92193. export var gradientVertexShader: {
  92194. name: string;
  92195. shader: string;
  92196. };
  92197. }
  92198. declare module BABYLON {
  92199. export class GradientMaterial extends BABYLON.PushMaterial {
  92200. private _maxSimultaneousLights;
  92201. maxSimultaneousLights: number;
  92202. topColor: BABYLON.Color3;
  92203. topColorAlpha: number;
  92204. bottomColor: BABYLON.Color3;
  92205. bottomColorAlpha: number;
  92206. offset: number;
  92207. scale: number;
  92208. smoothness: number;
  92209. private _disableLighting;
  92210. disableLighting: boolean;
  92211. constructor(name: string, scene: BABYLON.Scene);
  92212. needAlphaBlending(): boolean;
  92213. needAlphaTesting(): boolean;
  92214. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92215. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92216. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92217. getAnimatables(): BABYLON.IAnimatable[];
  92218. dispose(forceDisposeEffect?: boolean): void;
  92219. clone(name: string): GradientMaterial;
  92220. serialize(): any;
  92221. getClassName(): string;
  92222. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92223. }
  92224. }
  92225. declare module BABYLON {
  92226. /** @hidden */
  92227. export var gridPixelShader: {
  92228. name: string;
  92229. shader: string;
  92230. };
  92231. }
  92232. declare module BABYLON {
  92233. /** @hidden */
  92234. export var gridVertexShader: {
  92235. name: string;
  92236. shader: string;
  92237. };
  92238. }
  92239. declare module BABYLON {
  92240. /**
  92241. * The grid materials allows you to wrap any shape with a grid.
  92242. * Colors are customizable.
  92243. */
  92244. export class GridMaterial extends BABYLON.PushMaterial {
  92245. /**
  92246. * Main color of the grid (e.g. between lines)
  92247. */
  92248. mainColor: BABYLON.Color3;
  92249. /**
  92250. * Color of the grid lines.
  92251. */
  92252. lineColor: BABYLON.Color3;
  92253. /**
  92254. * The scale of the grid compared to unit.
  92255. */
  92256. gridRatio: number;
  92257. /**
  92258. * Allows setting an offset for the grid lines.
  92259. */
  92260. gridOffset: BABYLON.Vector3;
  92261. /**
  92262. * The frequency of thicker lines.
  92263. */
  92264. majorUnitFrequency: number;
  92265. /**
  92266. * The visibility of minor units in the grid.
  92267. */
  92268. minorUnitVisibility: number;
  92269. /**
  92270. * The grid opacity outside of the lines.
  92271. */
  92272. opacity: number;
  92273. /**
  92274. * Determine RBG output is premultiplied by alpha value.
  92275. */
  92276. preMultiplyAlpha: boolean;
  92277. private _opacityTexture;
  92278. opacityTexture: BABYLON.BaseTexture;
  92279. private _gridControl;
  92280. /**
  92281. * constructor
  92282. * @param name The name given to the material in order to identify it afterwards.
  92283. * @param scene The scene the material is used in.
  92284. */
  92285. constructor(name: string, scene: BABYLON.Scene);
  92286. /**
  92287. * Returns wehter or not the grid requires alpha blending.
  92288. */
  92289. needAlphaBlending(): boolean;
  92290. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92291. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92292. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92293. /**
  92294. * Dispose the material and its associated resources.
  92295. * @param forceDisposeEffect will also dispose the used effect when true
  92296. */
  92297. dispose(forceDisposeEffect?: boolean): void;
  92298. clone(name: string): GridMaterial;
  92299. serialize(): any;
  92300. getClassName(): string;
  92301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92302. }
  92303. }
  92304. declare module BABYLON {
  92305. /** @hidden */
  92306. export var lavaPixelShader: {
  92307. name: string;
  92308. shader: string;
  92309. };
  92310. }
  92311. declare module BABYLON {
  92312. /** @hidden */
  92313. export var lavaVertexShader: {
  92314. name: string;
  92315. shader: string;
  92316. };
  92317. }
  92318. declare module BABYLON {
  92319. export class LavaMaterial extends BABYLON.PushMaterial {
  92320. private _diffuseTexture;
  92321. diffuseTexture: BABYLON.BaseTexture;
  92322. noiseTexture: BABYLON.BaseTexture;
  92323. fogColor: BABYLON.Color3;
  92324. speed: number;
  92325. movingSpeed: number;
  92326. lowFrequencySpeed: number;
  92327. fogDensity: number;
  92328. private _lastTime;
  92329. diffuseColor: BABYLON.Color3;
  92330. private _disableLighting;
  92331. disableLighting: boolean;
  92332. private _unlit;
  92333. unlit: boolean;
  92334. private _maxSimultaneousLights;
  92335. maxSimultaneousLights: number;
  92336. private _scaledDiffuse;
  92337. constructor(name: string, scene: BABYLON.Scene);
  92338. needAlphaBlending(): boolean;
  92339. needAlphaTesting(): boolean;
  92340. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92341. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92342. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92343. getAnimatables(): BABYLON.IAnimatable[];
  92344. getActiveTextures(): BABYLON.BaseTexture[];
  92345. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92346. dispose(forceDisposeEffect?: boolean): void;
  92347. clone(name: string): LavaMaterial;
  92348. serialize(): any;
  92349. getClassName(): string;
  92350. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92351. }
  92352. }
  92353. declare module BABYLON {
  92354. /** @hidden */
  92355. export var mixPixelShader: {
  92356. name: string;
  92357. shader: string;
  92358. };
  92359. }
  92360. declare module BABYLON {
  92361. /** @hidden */
  92362. export var mixVertexShader: {
  92363. name: string;
  92364. shader: string;
  92365. };
  92366. }
  92367. declare module BABYLON {
  92368. export class MixMaterial extends BABYLON.PushMaterial {
  92369. /**
  92370. * Mix textures
  92371. */
  92372. private _mixTexture1;
  92373. mixTexture1: BABYLON.BaseTexture;
  92374. private _mixTexture2;
  92375. mixTexture2: BABYLON.BaseTexture;
  92376. /**
  92377. * Diffuse textures
  92378. */
  92379. private _diffuseTexture1;
  92380. diffuseTexture1: BABYLON.Texture;
  92381. private _diffuseTexture2;
  92382. diffuseTexture2: BABYLON.Texture;
  92383. private _diffuseTexture3;
  92384. diffuseTexture3: BABYLON.Texture;
  92385. private _diffuseTexture4;
  92386. diffuseTexture4: BABYLON.Texture;
  92387. private _diffuseTexture5;
  92388. diffuseTexture5: BABYLON.Texture;
  92389. private _diffuseTexture6;
  92390. diffuseTexture6: BABYLON.Texture;
  92391. private _diffuseTexture7;
  92392. diffuseTexture7: BABYLON.Texture;
  92393. private _diffuseTexture8;
  92394. diffuseTexture8: BABYLON.Texture;
  92395. /**
  92396. * Uniforms
  92397. */
  92398. diffuseColor: BABYLON.Color3;
  92399. specularColor: BABYLON.Color3;
  92400. specularPower: number;
  92401. private _disableLighting;
  92402. disableLighting: boolean;
  92403. private _maxSimultaneousLights;
  92404. maxSimultaneousLights: number;
  92405. constructor(name: string, scene: BABYLON.Scene);
  92406. needAlphaBlending(): boolean;
  92407. needAlphaTesting(): boolean;
  92408. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92409. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92410. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92411. getAnimatables(): BABYLON.IAnimatable[];
  92412. getActiveTextures(): BABYLON.BaseTexture[];
  92413. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92414. dispose(forceDisposeEffect?: boolean): void;
  92415. clone(name: string): MixMaterial;
  92416. serialize(): any;
  92417. getClassName(): string;
  92418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92419. }
  92420. }
  92421. declare module BABYLON {
  92422. /** @hidden */
  92423. export var normalPixelShader: {
  92424. name: string;
  92425. shader: string;
  92426. };
  92427. }
  92428. declare module BABYLON {
  92429. /** @hidden */
  92430. export var normalVertexShader: {
  92431. name: string;
  92432. shader: string;
  92433. };
  92434. }
  92435. declare module BABYLON {
  92436. export class NormalMaterial extends BABYLON.PushMaterial {
  92437. private _diffuseTexture;
  92438. diffuseTexture: BABYLON.BaseTexture;
  92439. diffuseColor: BABYLON.Color3;
  92440. private _disableLighting;
  92441. disableLighting: boolean;
  92442. private _maxSimultaneousLights;
  92443. maxSimultaneousLights: number;
  92444. constructor(name: string, scene: BABYLON.Scene);
  92445. needAlphaBlending(): boolean;
  92446. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92447. needAlphaTesting(): boolean;
  92448. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92449. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92450. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92451. getAnimatables(): BABYLON.IAnimatable[];
  92452. getActiveTextures(): BABYLON.BaseTexture[];
  92453. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92454. dispose(forceDisposeEffect?: boolean): void;
  92455. clone(name: string): NormalMaterial;
  92456. serialize(): any;
  92457. getClassName(): string;
  92458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92459. }
  92460. }
  92461. declare module BABYLON {
  92462. /** @hidden */
  92463. export var shadowOnlyPixelShader: {
  92464. name: string;
  92465. shader: string;
  92466. };
  92467. }
  92468. declare module BABYLON {
  92469. /** @hidden */
  92470. export var shadowOnlyVertexShader: {
  92471. name: string;
  92472. shader: string;
  92473. };
  92474. }
  92475. declare module BABYLON {
  92476. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92477. private _activeLight;
  92478. private _needAlphaBlending;
  92479. constructor(name: string, scene: BABYLON.Scene);
  92480. shadowColor: BABYLON.Color3;
  92481. needAlphaBlending(): boolean;
  92482. needAlphaTesting(): boolean;
  92483. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92484. get activeLight(): BABYLON.IShadowLight;
  92485. set activeLight(light: BABYLON.IShadowLight);
  92486. private _getFirstShadowLightForMesh;
  92487. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92488. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92489. clone(name: string): ShadowOnlyMaterial;
  92490. serialize(): any;
  92491. getClassName(): string;
  92492. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92493. }
  92494. }
  92495. declare module BABYLON {
  92496. /** @hidden */
  92497. export var simplePixelShader: {
  92498. name: string;
  92499. shader: string;
  92500. };
  92501. }
  92502. declare module BABYLON {
  92503. /** @hidden */
  92504. export var simpleVertexShader: {
  92505. name: string;
  92506. shader: string;
  92507. };
  92508. }
  92509. declare module BABYLON {
  92510. export class SimpleMaterial extends BABYLON.PushMaterial {
  92511. private _diffuseTexture;
  92512. diffuseTexture: BABYLON.BaseTexture;
  92513. diffuseColor: BABYLON.Color3;
  92514. private _disableLighting;
  92515. disableLighting: boolean;
  92516. private _maxSimultaneousLights;
  92517. maxSimultaneousLights: number;
  92518. constructor(name: string, scene: BABYLON.Scene);
  92519. needAlphaBlending(): boolean;
  92520. needAlphaTesting(): boolean;
  92521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92524. getAnimatables(): BABYLON.IAnimatable[];
  92525. getActiveTextures(): BABYLON.BaseTexture[];
  92526. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92527. dispose(forceDisposeEffect?: boolean): void;
  92528. clone(name: string): SimpleMaterial;
  92529. serialize(): any;
  92530. getClassName(): string;
  92531. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92532. }
  92533. }
  92534. declare module BABYLON {
  92535. /** @hidden */
  92536. export var skyPixelShader: {
  92537. name: string;
  92538. shader: string;
  92539. };
  92540. }
  92541. declare module BABYLON {
  92542. /** @hidden */
  92543. export var skyVertexShader: {
  92544. name: string;
  92545. shader: string;
  92546. };
  92547. }
  92548. declare module BABYLON {
  92549. /**
  92550. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92551. * @see https://doc.babylonjs.com/extensions/sky
  92552. */
  92553. export class SkyMaterial extends BABYLON.PushMaterial {
  92554. /**
  92555. * Defines the overall luminance of sky in interval ]0, 1[.
  92556. */
  92557. luminance: number;
  92558. /**
  92559. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92560. */
  92561. turbidity: number;
  92562. /**
  92563. * Defines the sky appearance (light intensity).
  92564. */
  92565. rayleigh: number;
  92566. /**
  92567. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92568. */
  92569. mieCoefficient: number;
  92570. /**
  92571. * Defines the amount of haze particles following the Mie scattering theory.
  92572. */
  92573. mieDirectionalG: number;
  92574. /**
  92575. * Defines the distance of the sun according to the active scene camera.
  92576. */
  92577. distance: number;
  92578. /**
  92579. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92580. * "inclined".
  92581. */
  92582. inclination: number;
  92583. /**
  92584. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92585. * an object direction and a reference direction.
  92586. */
  92587. azimuth: number;
  92588. /**
  92589. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92590. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92591. */
  92592. sunPosition: BABYLON.Vector3;
  92593. /**
  92594. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92595. * .sunPosition property.
  92596. */
  92597. useSunPosition: boolean;
  92598. /**
  92599. * Defines an offset vector used to get a horizon offset.
  92600. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92601. */
  92602. cameraOffset: BABYLON.Vector3;
  92603. /**
  92604. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92605. */
  92606. up: BABYLON.Vector3;
  92607. private _cameraPosition;
  92608. private _skyOrientation;
  92609. /**
  92610. * Instantiates a new sky material.
  92611. * This material allows to create dynamic and texture free
  92612. * effects for skyboxes by taking care of the atmosphere state.
  92613. * @see https://doc.babylonjs.com/extensions/sky
  92614. * @param name Define the name of the material in the scene
  92615. * @param scene Define the scene the material belong to
  92616. */
  92617. constructor(name: string, scene: BABYLON.Scene);
  92618. /**
  92619. * Specifies if the material will require alpha blending
  92620. * @returns a boolean specifying if alpha blending is needed
  92621. */
  92622. needAlphaBlending(): boolean;
  92623. /**
  92624. * Specifies if this material should be rendered in alpha test mode
  92625. * @returns false as the sky material doesn't need alpha testing.
  92626. */
  92627. needAlphaTesting(): boolean;
  92628. /**
  92629. * Get the texture used for alpha test purpose.
  92630. * @returns null as the sky material has no texture.
  92631. */
  92632. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92633. /**
  92634. * Get if the submesh is ready to be used and all its information available.
  92635. * Child classes can use it to update shaders
  92636. * @param mesh defines the mesh to check
  92637. * @param subMesh defines which submesh to check
  92638. * @param useInstances specifies that instances should be used
  92639. * @returns a boolean indicating that the submesh is ready or not
  92640. */
  92641. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92642. /**
  92643. * Binds the submesh to this material by preparing the effect and shader to draw
  92644. * @param world defines the world transformation matrix
  92645. * @param mesh defines the mesh containing the submesh
  92646. * @param subMesh defines the submesh to bind the material to
  92647. */
  92648. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92649. /**
  92650. * Get the list of animatables in the material.
  92651. * @returns the list of animatables object used in the material
  92652. */
  92653. getAnimatables(): BABYLON.IAnimatable[];
  92654. /**
  92655. * Disposes the material
  92656. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92657. */
  92658. dispose(forceDisposeEffect?: boolean): void;
  92659. /**
  92660. * Makes a duplicate of the material, and gives it a new name
  92661. * @param name defines the new name for the duplicated material
  92662. * @returns the cloned material
  92663. */
  92664. clone(name: string): SkyMaterial;
  92665. /**
  92666. * Serializes this material in a JSON representation
  92667. * @returns the serialized material object
  92668. */
  92669. serialize(): any;
  92670. /**
  92671. * Gets the current class name of the material e.g. "SkyMaterial"
  92672. * Mainly use in serialization.
  92673. * @returns the class name
  92674. */
  92675. getClassName(): string;
  92676. /**
  92677. * Creates a sky material from parsed material data
  92678. * @param source defines the JSON representation of the material
  92679. * @param scene defines the hosting scene
  92680. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92681. * @returns a new sky material
  92682. */
  92683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92684. }
  92685. }
  92686. declare module BABYLON {
  92687. /** @hidden */
  92688. export var terrainPixelShader: {
  92689. name: string;
  92690. shader: string;
  92691. };
  92692. }
  92693. declare module BABYLON {
  92694. /** @hidden */
  92695. export var terrainVertexShader: {
  92696. name: string;
  92697. shader: string;
  92698. };
  92699. }
  92700. declare module BABYLON {
  92701. export class TerrainMaterial extends BABYLON.PushMaterial {
  92702. private _mixTexture;
  92703. mixTexture: BABYLON.BaseTexture;
  92704. private _diffuseTexture1;
  92705. diffuseTexture1: BABYLON.Texture;
  92706. private _diffuseTexture2;
  92707. diffuseTexture2: BABYLON.Texture;
  92708. private _diffuseTexture3;
  92709. diffuseTexture3: BABYLON.Texture;
  92710. private _bumpTexture1;
  92711. bumpTexture1: BABYLON.Texture;
  92712. private _bumpTexture2;
  92713. bumpTexture2: BABYLON.Texture;
  92714. private _bumpTexture3;
  92715. bumpTexture3: BABYLON.Texture;
  92716. diffuseColor: BABYLON.Color3;
  92717. specularColor: BABYLON.Color3;
  92718. specularPower: number;
  92719. private _disableLighting;
  92720. disableLighting: boolean;
  92721. private _maxSimultaneousLights;
  92722. maxSimultaneousLights: number;
  92723. constructor(name: string, scene: BABYLON.Scene);
  92724. needAlphaBlending(): boolean;
  92725. needAlphaTesting(): boolean;
  92726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92727. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92728. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92729. getAnimatables(): BABYLON.IAnimatable[];
  92730. getActiveTextures(): BABYLON.BaseTexture[];
  92731. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92732. dispose(forceDisposeEffect?: boolean): void;
  92733. clone(name: string): TerrainMaterial;
  92734. serialize(): any;
  92735. getClassName(): string;
  92736. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. /** @hidden */
  92741. export var triplanarPixelShader: {
  92742. name: string;
  92743. shader: string;
  92744. };
  92745. }
  92746. declare module BABYLON {
  92747. /** @hidden */
  92748. export var triplanarVertexShader: {
  92749. name: string;
  92750. shader: string;
  92751. };
  92752. }
  92753. declare module BABYLON {
  92754. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92755. mixTexture: BABYLON.BaseTexture;
  92756. private _diffuseTextureX;
  92757. diffuseTextureX: BABYLON.BaseTexture;
  92758. private _diffuseTextureY;
  92759. diffuseTextureY: BABYLON.BaseTexture;
  92760. private _diffuseTextureZ;
  92761. diffuseTextureZ: BABYLON.BaseTexture;
  92762. private _normalTextureX;
  92763. normalTextureX: BABYLON.BaseTexture;
  92764. private _normalTextureY;
  92765. normalTextureY: BABYLON.BaseTexture;
  92766. private _normalTextureZ;
  92767. normalTextureZ: BABYLON.BaseTexture;
  92768. tileSize: number;
  92769. diffuseColor: BABYLON.Color3;
  92770. specularColor: BABYLON.Color3;
  92771. specularPower: number;
  92772. private _disableLighting;
  92773. disableLighting: boolean;
  92774. private _maxSimultaneousLights;
  92775. maxSimultaneousLights: number;
  92776. constructor(name: string, scene: BABYLON.Scene);
  92777. needAlphaBlending(): boolean;
  92778. needAlphaTesting(): boolean;
  92779. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92780. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92781. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92782. getAnimatables(): BABYLON.IAnimatable[];
  92783. getActiveTextures(): BABYLON.BaseTexture[];
  92784. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92785. dispose(forceDisposeEffect?: boolean): void;
  92786. clone(name: string): TriPlanarMaterial;
  92787. serialize(): any;
  92788. getClassName(): string;
  92789. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92790. }
  92791. }
  92792. declare module BABYLON {
  92793. /** @hidden */
  92794. export var waterPixelShader: {
  92795. name: string;
  92796. shader: string;
  92797. };
  92798. }
  92799. declare module BABYLON {
  92800. /** @hidden */
  92801. export var waterVertexShader: {
  92802. name: string;
  92803. shader: string;
  92804. };
  92805. }
  92806. declare module BABYLON {
  92807. export class WaterMaterial extends BABYLON.PushMaterial {
  92808. renderTargetSize: BABYLON.Vector2;
  92809. private _bumpTexture;
  92810. bumpTexture: BABYLON.BaseTexture;
  92811. diffuseColor: BABYLON.Color3;
  92812. specularColor: BABYLON.Color3;
  92813. specularPower: number;
  92814. private _disableLighting;
  92815. disableLighting: boolean;
  92816. private _maxSimultaneousLights;
  92817. maxSimultaneousLights: number;
  92818. /**
  92819. * Defines the wind force.
  92820. */
  92821. windForce: number;
  92822. /**
  92823. * Defines the direction of the wind in the plane (X, Z).
  92824. */
  92825. windDirection: BABYLON.Vector2;
  92826. /**
  92827. * Defines the height of the waves.
  92828. */
  92829. waveHeight: number;
  92830. /**
  92831. * Defines the bump height related to the bump map.
  92832. */
  92833. bumpHeight: number;
  92834. /**
  92835. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92836. */
  92837. private _bumpSuperimpose;
  92838. bumpSuperimpose: boolean;
  92839. /**
  92840. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92841. */
  92842. private _fresnelSeparate;
  92843. fresnelSeparate: boolean;
  92844. /**
  92845. * Defines wether or not bump Wwves modify the reflection.
  92846. */
  92847. private _bumpAffectsReflection;
  92848. bumpAffectsReflection: boolean;
  92849. /**
  92850. * Defines the water color blended with the refraction (near).
  92851. */
  92852. waterColor: BABYLON.Color3;
  92853. /**
  92854. * Defines the blend factor related to the water color.
  92855. */
  92856. colorBlendFactor: number;
  92857. /**
  92858. * Defines the water color blended with the reflection (far).
  92859. */
  92860. waterColor2: BABYLON.Color3;
  92861. /**
  92862. * Defines the blend factor related to the water color (reflection, far).
  92863. */
  92864. colorBlendFactor2: number;
  92865. /**
  92866. * Defines the maximum length of a wave.
  92867. */
  92868. waveLength: number;
  92869. /**
  92870. * Defines the waves speed.
  92871. */
  92872. waveSpeed: number;
  92873. /**
  92874. * 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.
  92875. */
  92876. waveCount: number;
  92877. /**
  92878. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92879. * will avoid calculating useless pixels in the pixel shader of the water material.
  92880. */
  92881. disableClipPlane: boolean;
  92882. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92883. private _mesh;
  92884. private _refractionRTT;
  92885. private _reflectionRTT;
  92886. private _reflectionTransform;
  92887. private _lastTime;
  92888. private _lastDeltaTime;
  92889. private _useLogarithmicDepth;
  92890. private _waitingRenderList;
  92891. private _imageProcessingConfiguration;
  92892. private _imageProcessingObserver;
  92893. /**
  92894. * Gets a boolean indicating that current material needs to register RTT
  92895. */
  92896. get hasRenderTargetTextures(): boolean;
  92897. /**
  92898. * Constructor
  92899. */
  92900. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92901. get useLogarithmicDepth(): boolean;
  92902. set useLogarithmicDepth(value: boolean);
  92903. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92904. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92905. addToRenderList(node: any): void;
  92906. enableRenderTargets(enable: boolean): void;
  92907. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92908. get renderTargetsEnabled(): boolean;
  92909. needAlphaBlending(): boolean;
  92910. needAlphaTesting(): boolean;
  92911. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92912. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92913. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92914. private _createRenderTargets;
  92915. getAnimatables(): BABYLON.IAnimatable[];
  92916. getActiveTextures(): BABYLON.BaseTexture[];
  92917. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92918. dispose(forceDisposeEffect?: boolean): void;
  92919. clone(name: string): WaterMaterial;
  92920. serialize(): any;
  92921. getClassName(): string;
  92922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92923. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92924. }
  92925. }
  92926. declare module BABYLON {
  92927. /** @hidden */
  92928. export var asciiartPixelShader: {
  92929. name: string;
  92930. shader: string;
  92931. };
  92932. }
  92933. declare module BABYLON {
  92934. /**
  92935. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92936. *
  92937. * It basically takes care rendering the font front the given font size to a texture.
  92938. * This is used later on in the postprocess.
  92939. */
  92940. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92941. private _font;
  92942. private _text;
  92943. private _charSize;
  92944. /**
  92945. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92946. */
  92947. get charSize(): number;
  92948. /**
  92949. * Create a new instance of the Ascii Art FontTexture class
  92950. * @param name the name of the texture
  92951. * @param font the font to use, use the W3C CSS notation
  92952. * @param text the caracter set to use in the rendering.
  92953. * @param scene the scene that owns the texture
  92954. */
  92955. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92956. /**
  92957. * Gets the max char width of a font.
  92958. * @param font the font to use, use the W3C CSS notation
  92959. * @return the max char width
  92960. */
  92961. private getFontWidth;
  92962. /**
  92963. * Gets the max char height of a font.
  92964. * @param font the font to use, use the W3C CSS notation
  92965. * @return the max char height
  92966. */
  92967. private getFontHeight;
  92968. /**
  92969. * Clones the current AsciiArtTexture.
  92970. * @return the clone of the texture.
  92971. */
  92972. clone(): AsciiArtFontTexture;
  92973. /**
  92974. * Parses a json object representing the texture and returns an instance of it.
  92975. * @param source the source JSON representation
  92976. * @param scene the scene to create the texture for
  92977. * @return the parsed texture
  92978. */
  92979. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92980. }
  92981. /**
  92982. * Option available in the Ascii Art Post Process.
  92983. */
  92984. export interface IAsciiArtPostProcessOptions {
  92985. /**
  92986. * The font to use following the w3c font definition.
  92987. */
  92988. font?: string;
  92989. /**
  92990. * The character set to use in the postprocess.
  92991. */
  92992. characterSet?: string;
  92993. /**
  92994. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92995. * This number is defined between 0 and 1;
  92996. */
  92997. mixToTile?: number;
  92998. /**
  92999. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93000. * This number is defined between 0 and 1;
  93001. */
  93002. mixToNormal?: number;
  93003. }
  93004. /**
  93005. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93006. *
  93007. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93008. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93009. */
  93010. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93011. /**
  93012. * The font texture used to render the char in the post process.
  93013. */
  93014. private _asciiArtFontTexture;
  93015. /**
  93016. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93017. * This number is defined between 0 and 1;
  93018. */
  93019. mixToTile: number;
  93020. /**
  93021. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93022. * This number is defined between 0 and 1;
  93023. */
  93024. mixToNormal: number;
  93025. /**
  93026. * Instantiates a new Ascii Art Post Process.
  93027. * @param name the name to give to the postprocess
  93028. * @camera the camera to apply the post process to.
  93029. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93030. */
  93031. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93032. }
  93033. }
  93034. declare module BABYLON {
  93035. /** @hidden */
  93036. export var digitalrainPixelShader: {
  93037. name: string;
  93038. shader: string;
  93039. };
  93040. }
  93041. declare module BABYLON {
  93042. /**
  93043. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93044. *
  93045. * It basically takes care rendering the font front the given font size to a texture.
  93046. * This is used later on in the postprocess.
  93047. */
  93048. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93049. private _font;
  93050. private _text;
  93051. private _charSize;
  93052. /**
  93053. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93054. */
  93055. get charSize(): number;
  93056. /**
  93057. * Create a new instance of the Digital Rain FontTexture class
  93058. * @param name the name of the texture
  93059. * @param font the font to use, use the W3C CSS notation
  93060. * @param text the caracter set to use in the rendering.
  93061. * @param scene the scene that owns the texture
  93062. */
  93063. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93064. /**
  93065. * Gets the max char width of a font.
  93066. * @param font the font to use, use the W3C CSS notation
  93067. * @return the max char width
  93068. */
  93069. private getFontWidth;
  93070. /**
  93071. * Gets the max char height of a font.
  93072. * @param font the font to use, use the W3C CSS notation
  93073. * @return the max char height
  93074. */
  93075. private getFontHeight;
  93076. /**
  93077. * Clones the current DigitalRainFontTexture.
  93078. * @return the clone of the texture.
  93079. */
  93080. clone(): DigitalRainFontTexture;
  93081. /**
  93082. * Parses a json object representing the texture and returns an instance of it.
  93083. * @param source the source JSON representation
  93084. * @param scene the scene to create the texture for
  93085. * @return the parsed texture
  93086. */
  93087. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93088. }
  93089. /**
  93090. * Option available in the Digital Rain Post Process.
  93091. */
  93092. export interface IDigitalRainPostProcessOptions {
  93093. /**
  93094. * The font to use following the w3c font definition.
  93095. */
  93096. font?: string;
  93097. /**
  93098. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93099. * This number is defined between 0 and 1;
  93100. */
  93101. mixToTile?: number;
  93102. /**
  93103. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93104. * This number is defined between 0 and 1;
  93105. */
  93106. mixToNormal?: number;
  93107. }
  93108. /**
  93109. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93110. *
  93111. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93112. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93113. */
  93114. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93115. /**
  93116. * The font texture used to render the char in the post process.
  93117. */
  93118. private _digitalRainFontTexture;
  93119. /**
  93120. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93121. * This number is defined between 0 and 1;
  93122. */
  93123. mixToTile: number;
  93124. /**
  93125. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93126. * This number is defined between 0 and 1;
  93127. */
  93128. mixToNormal: number;
  93129. /**
  93130. * Instantiates a new Digital Rain Post Process.
  93131. * @param name the name to give to the postprocess
  93132. * @camera the camera to apply the post process to.
  93133. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93134. */
  93135. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. /** @hidden */
  93140. export var brickProceduralTexturePixelShader: {
  93141. name: string;
  93142. shader: string;
  93143. };
  93144. }
  93145. declare module BABYLON {
  93146. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93147. private _numberOfBricksHeight;
  93148. private _numberOfBricksWidth;
  93149. private _jointColor;
  93150. private _brickColor;
  93151. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93152. updateShaderUniforms(): void;
  93153. get numberOfBricksHeight(): number;
  93154. set numberOfBricksHeight(value: number);
  93155. get numberOfBricksWidth(): number;
  93156. set numberOfBricksWidth(value: number);
  93157. get jointColor(): BABYLON.Color3;
  93158. set jointColor(value: BABYLON.Color3);
  93159. get brickColor(): BABYLON.Color3;
  93160. set brickColor(value: BABYLON.Color3);
  93161. /**
  93162. * Serializes this brick procedural texture
  93163. * @returns a serialized brick procedural texture object
  93164. */
  93165. serialize(): any;
  93166. /**
  93167. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93168. * @param parsedTexture defines parsed texture data
  93169. * @param scene defines the current scene
  93170. * @param rootUrl defines the root URL containing brick procedural texture information
  93171. * @returns a parsed Brick Procedural BABYLON.Texture
  93172. */
  93173. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93174. }
  93175. }
  93176. declare module BABYLON {
  93177. /** @hidden */
  93178. export var cloudProceduralTexturePixelShader: {
  93179. name: string;
  93180. shader: string;
  93181. };
  93182. }
  93183. declare module BABYLON {
  93184. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93185. private _skyColor;
  93186. private _cloudColor;
  93187. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93188. updateShaderUniforms(): void;
  93189. get skyColor(): BABYLON.Color4;
  93190. set skyColor(value: BABYLON.Color4);
  93191. get cloudColor(): BABYLON.Color4;
  93192. set cloudColor(value: BABYLON.Color4);
  93193. /**
  93194. * Serializes this cloud procedural texture
  93195. * @returns a serialized cloud procedural texture object
  93196. */
  93197. serialize(): any;
  93198. /**
  93199. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93200. * @param parsedTexture defines parsed texture data
  93201. * @param scene defines the current scene
  93202. * @param rootUrl defines the root URL containing cloud procedural texture information
  93203. * @returns a parsed Cloud Procedural BABYLON.Texture
  93204. */
  93205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93206. }
  93207. }
  93208. declare module BABYLON {
  93209. /** @hidden */
  93210. export var fireProceduralTexturePixelShader: {
  93211. name: string;
  93212. shader: string;
  93213. };
  93214. }
  93215. declare module BABYLON {
  93216. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93217. private _time;
  93218. private _speed;
  93219. private _autoGenerateTime;
  93220. private _fireColors;
  93221. private _alphaThreshold;
  93222. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93223. updateShaderUniforms(): void;
  93224. render(useCameraPostProcess?: boolean): void;
  93225. static get PurpleFireColors(): BABYLON.Color3[];
  93226. static get GreenFireColors(): BABYLON.Color3[];
  93227. static get RedFireColors(): BABYLON.Color3[];
  93228. static get BlueFireColors(): BABYLON.Color3[];
  93229. get autoGenerateTime(): boolean;
  93230. set autoGenerateTime(value: boolean);
  93231. get fireColors(): BABYLON.Color3[];
  93232. set fireColors(value: BABYLON.Color3[]);
  93233. get time(): number;
  93234. set time(value: number);
  93235. get speed(): BABYLON.Vector2;
  93236. set speed(value: BABYLON.Vector2);
  93237. get alphaThreshold(): number;
  93238. set alphaThreshold(value: number);
  93239. /**
  93240. * Serializes this fire procedural texture
  93241. * @returns a serialized fire procedural texture object
  93242. */
  93243. serialize(): any;
  93244. /**
  93245. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93246. * @param parsedTexture defines parsed texture data
  93247. * @param scene defines the current scene
  93248. * @param rootUrl defines the root URL containing fire procedural texture information
  93249. * @returns a parsed Fire Procedural BABYLON.Texture
  93250. */
  93251. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93252. }
  93253. }
  93254. declare module BABYLON {
  93255. /** @hidden */
  93256. export var grassProceduralTexturePixelShader: {
  93257. name: string;
  93258. shader: string;
  93259. };
  93260. }
  93261. declare module BABYLON {
  93262. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93263. private _grassColors;
  93264. private _groundColor;
  93265. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93266. updateShaderUniforms(): void;
  93267. get grassColors(): BABYLON.Color3[];
  93268. set grassColors(value: BABYLON.Color3[]);
  93269. get groundColor(): BABYLON.Color3;
  93270. set groundColor(value: BABYLON.Color3);
  93271. /**
  93272. * Serializes this grass procedural texture
  93273. * @returns a serialized grass procedural texture object
  93274. */
  93275. serialize(): any;
  93276. /**
  93277. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93278. * @param parsedTexture defines parsed texture data
  93279. * @param scene defines the current scene
  93280. * @param rootUrl defines the root URL containing grass procedural texture information
  93281. * @returns a parsed Grass Procedural BABYLON.Texture
  93282. */
  93283. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93284. }
  93285. }
  93286. declare module BABYLON {
  93287. /** @hidden */
  93288. export var marbleProceduralTexturePixelShader: {
  93289. name: string;
  93290. shader: string;
  93291. };
  93292. }
  93293. declare module BABYLON {
  93294. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93295. private _numberOfTilesHeight;
  93296. private _numberOfTilesWidth;
  93297. private _amplitude;
  93298. private _jointColor;
  93299. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93300. updateShaderUniforms(): void;
  93301. get numberOfTilesHeight(): number;
  93302. set numberOfTilesHeight(value: number);
  93303. get amplitude(): number;
  93304. set amplitude(value: number);
  93305. get numberOfTilesWidth(): number;
  93306. set numberOfTilesWidth(value: number);
  93307. get jointColor(): BABYLON.Color3;
  93308. set jointColor(value: BABYLON.Color3);
  93309. /**
  93310. * Serializes this marble procedural texture
  93311. * @returns a serialized marble procedural texture object
  93312. */
  93313. serialize(): any;
  93314. /**
  93315. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93316. * @param parsedTexture defines parsed texture data
  93317. * @param scene defines the current scene
  93318. * @param rootUrl defines the root URL containing marble procedural texture information
  93319. * @returns a parsed Marble Procedural BABYLON.Texture
  93320. */
  93321. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93322. }
  93323. }
  93324. declare module BABYLON {
  93325. /** @hidden */
  93326. export var normalMapProceduralTexturePixelShader: {
  93327. name: string;
  93328. shader: string;
  93329. };
  93330. }
  93331. declare module BABYLON {
  93332. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93333. private _baseTexture;
  93334. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93335. updateShaderUniforms(): void;
  93336. render(useCameraPostProcess?: boolean): void;
  93337. resize(size: any, generateMipMaps: any): void;
  93338. isReady(): boolean;
  93339. get baseTexture(): BABYLON.Texture;
  93340. set baseTexture(texture: BABYLON.Texture);
  93341. /**
  93342. * Serializes this normal map procedural texture
  93343. * @returns a serialized normal map procedural texture object
  93344. */
  93345. serialize(): any;
  93346. /**
  93347. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93348. * @param parsedTexture defines parsed texture data
  93349. * @param scene defines the current scene
  93350. * @param rootUrl defines the root URL containing normal map procedural texture information
  93351. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93352. */
  93353. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93354. }
  93355. }
  93356. declare module BABYLON {
  93357. /** @hidden */
  93358. export var perlinNoiseProceduralTexturePixelShader: {
  93359. name: string;
  93360. shader: string;
  93361. };
  93362. }
  93363. declare module BABYLON {
  93364. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93365. time: number;
  93366. timeScale: number;
  93367. translationSpeed: number;
  93368. private _currentTranslation;
  93369. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93370. updateShaderUniforms(): void;
  93371. render(useCameraPostProcess?: boolean): void;
  93372. resize(size: any, generateMipMaps: any): void;
  93373. /**
  93374. * Serializes this perlin noise procedural texture
  93375. * @returns a serialized perlin noise procedural texture object
  93376. */
  93377. serialize(): any;
  93378. /**
  93379. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93380. * @param parsedTexture defines parsed texture data
  93381. * @param scene defines the current scene
  93382. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93383. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93384. */
  93385. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93386. }
  93387. }
  93388. declare module BABYLON {
  93389. /** @hidden */
  93390. export var roadProceduralTexturePixelShader: {
  93391. name: string;
  93392. shader: string;
  93393. };
  93394. }
  93395. declare module BABYLON {
  93396. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93397. private _roadColor;
  93398. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93399. updateShaderUniforms(): void;
  93400. get roadColor(): BABYLON.Color3;
  93401. set roadColor(value: BABYLON.Color3);
  93402. /**
  93403. * Serializes this road procedural texture
  93404. * @returns a serialized road procedural texture object
  93405. */
  93406. serialize(): any;
  93407. /**
  93408. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93409. * @param parsedTexture defines parsed texture data
  93410. * @param scene defines the current scene
  93411. * @param rootUrl defines the root URL containing road procedural texture information
  93412. * @returns a parsed Road Procedural BABYLON.Texture
  93413. */
  93414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93415. }
  93416. }
  93417. declare module BABYLON {
  93418. /** @hidden */
  93419. export var starfieldProceduralTexturePixelShader: {
  93420. name: string;
  93421. shader: string;
  93422. };
  93423. }
  93424. declare module BABYLON {
  93425. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93426. private _time;
  93427. private _alpha;
  93428. private _beta;
  93429. private _zoom;
  93430. private _formuparam;
  93431. private _stepsize;
  93432. private _tile;
  93433. private _brightness;
  93434. private _darkmatter;
  93435. private _distfading;
  93436. private _saturation;
  93437. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93438. updateShaderUniforms(): void;
  93439. get time(): number;
  93440. set time(value: number);
  93441. get alpha(): number;
  93442. set alpha(value: number);
  93443. get beta(): number;
  93444. set beta(value: number);
  93445. get formuparam(): number;
  93446. set formuparam(value: number);
  93447. get stepsize(): number;
  93448. set stepsize(value: number);
  93449. get zoom(): number;
  93450. set zoom(value: number);
  93451. get tile(): number;
  93452. set tile(value: number);
  93453. get brightness(): number;
  93454. set brightness(value: number);
  93455. get darkmatter(): number;
  93456. set darkmatter(value: number);
  93457. get distfading(): number;
  93458. set distfading(value: number);
  93459. get saturation(): number;
  93460. set saturation(value: number);
  93461. /**
  93462. * Serializes this starfield procedural texture
  93463. * @returns a serialized starfield procedural texture object
  93464. */
  93465. serialize(): any;
  93466. /**
  93467. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93468. * @param parsedTexture defines parsed texture data
  93469. * @param scene defines the current scene
  93470. * @param rootUrl defines the root URL containing startfield procedural texture information
  93471. * @returns a parsed Starfield Procedural BABYLON.Texture
  93472. */
  93473. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93474. }
  93475. }
  93476. declare module BABYLON {
  93477. /** @hidden */
  93478. export var woodProceduralTexturePixelShader: {
  93479. name: string;
  93480. shader: string;
  93481. };
  93482. }
  93483. declare module BABYLON {
  93484. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93485. private _ampScale;
  93486. private _woodColor;
  93487. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93488. updateShaderUniforms(): void;
  93489. get ampScale(): number;
  93490. set ampScale(value: number);
  93491. get woodColor(): BABYLON.Color3;
  93492. set woodColor(value: BABYLON.Color3);
  93493. /**
  93494. * Serializes this wood procedural texture
  93495. * @returns a serialized wood procedural texture object
  93496. */
  93497. serialize(): any;
  93498. /**
  93499. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93500. * @param parsedTexture defines parsed texture data
  93501. * @param scene defines the current scene
  93502. * @param rootUrl defines the root URL containing wood procedural texture information
  93503. * @returns a parsed Wood Procedural BABYLON.Texture
  93504. */
  93505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93506. }
  93507. }